@gramlot/gramlot 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +1 -1
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +1 -1
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/gramlot.js +1095 -618
- package/dist/gramlot.min.js +37 -37
- package/package.json +2 -2
- package/src/binding/data-binder.js +71 -0
- package/src/binding/providers.js +7 -4
- package/src/binding/router.js +3 -1
- package/src/binding/runtime.js +9 -1
- package/src/builder/binding.json +49 -0
- package/src/frame-messages.js +142 -73
- package/src/gramlot.d.ts +6 -3
- package/src/gramlot.js +10 -3
- package/src/handlers/rpc-handler.js +1 -1
- package/src/handlers/subscriptions-handler.js +20 -14
- package/src/page-store-connection.js +220 -0
- package/src/server-adapter.d.ts +4 -3
- package/src/server-adapter.js +6 -5
- package/src/websocket-transport.d.ts +10 -0
- package/src/websocket-transport.js +13 -0
package/dist/gramlot.min.js
CHANGED
|
@@ -6,38 +6,38 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
var gd=Object.create;var Zs=Object.defineProperty;var bd=Object.getOwnPropertyDescriptor;var _d=Object.getOwnPropertyNames;var wd=Object.getPrototypeOf,yd=Object.prototype.hasOwnProperty;var dt=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},vd=(n,e)=>{for(var t in e)Zs(n,t,{get:e[t],enumerable:!0})},Ed=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _d(e))!yd.call(n,i)&&i!==t&&Zs(n,i,{get:()=>e[i],enumerable:!(r=bd(e,i))||r.enumerable});return n};var Ia=(n,e,t)=>(t=n!=null?gd(wd(n)):{},Ed(e||!n||!n.__esModule?Zs(t,"default",{value:n,enumerable:!0}):t,n));var zt=dt(me=>{"use strict";function Gf(n,e,t){if(t===void 0&&(t=Array.prototype),n&&typeof t.find=="function")return t.find.call(n,e);for(var r=0;r<n.length;r++)if(Vt(n,r)){var i=n[r];if(e.call(void 0,i,r,n))return i}}function br(n,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(n=e.create(null,e.getOwnPropertyDescriptors(n))),e&&typeof e.freeze=="function"?e.freeze(n):n}function Vt(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Xf(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Vt(e,t)&&(n[t]=e[t]);return n}var pl=br({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 Yf(n){return Vt(pl,n.toLowerCase())}var ml=br({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 Zf(n){return Vt(ml,n.toLowerCase())}var fn=br({script:!1,style:!1,textarea:!0,title:!0});function Jf(n){var e=n.toLowerCase();return Vt(fn,e)&&!fn[e]}function Kf(n){var e=n.toLowerCase();return Vt(fn,e)&&fn[e]}function gl(n){return n===hn.HTML}function Qf(n){return gl(n)||n===hn.XML_XHTML_APPLICATION}var hn=br({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),eh=Object.keys(hn).map(function(n){return hn[n]});function th(n){return eh.indexOf(n)>-1}var rh=br({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/"});me.assign=Xf;me.find=Gf;me.freeze=br;me.HTML_BOOLEAN_ATTRIBUTES=pl;me.HTML_RAW_TEXT_ELEMENTS=fn;me.HTML_VOID_ELEMENTS=ml;me.hasDefaultHTMLNamespace=Qf;me.hasOwn=Vt;me.isHTMLBooleanAttribute=Yf;me.isHTMLRawTextElement=Jf;me.isHTMLEscapableRawTextElement=Kf;me.isHTMLMimeType=gl;me.isHTMLVoidElement=Zf;me.isValidMimeType=th;me.MIME_TYPE=hn;me.NAMESPACE=rh});var _n=dt(bn=>{"use strict";var nh=zt();function _l(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var mn=nh.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"}),wl=Object.keys(mn);function yl(n){return typeof n=="number"&&n>=1&&n<=25}function ih(n){return typeof n=="string"&&n.substring(n.length-mn.Error.length)===mn.Error}function gn(n,e){yl(n)?(this.name=wl[n],this.message=e||""):(this.message=n,this.name=ih(e)?e:mn.Error),Error.captureStackTrace&&Error.captureStackTrace(this,gn)}_l(gn,!0);Object.defineProperties(gn.prototype,{code:{enumerable:!0,get:function(){var n=wl.indexOf(this.name);return yl(n)?n:0}}});var vl={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},po=Object.entries(vl);for(pn=0;pn<po.length;pn++)bl=po[pn][0],gn[bl]=po[pn][1];var bl,pn;function mo(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,mo)}_l(mo);bn.DOMException=gn;bn.DOMExceptionName=mn;bn.ExceptionCode=vl;bn.ParseError=mo});var Eo=dt($=>{"use strict";function Dl(n){try{typeof n!="function"&&(n=RegExp);var e=new n("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var yr=Dl();function _t(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function _r(n,e){if(n.source[0]!=="[")throw new Error("/"+n.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(n.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+n.source+"/");if(e==="-"&&n.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+n.source+"/");return new RegExp(n.source.replace(e,""),yr?"u":"")}function P(n){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var r=typeof t=="string";if(r&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?t:t.source}).join(""),yr?"u":"")}function B(n){if(arguments.length===0)throw new Error("no parameters provided");return P.apply(B,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var sh="\uFFFD",wt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;yr&&(wt=P("[",_t(wt),"\\u{10000}-\\u{10FFFF}","]"));var oh=new RegExp("[^"+_t(wt)+"]",yr?"u":""),Mi=/[\x20\x09\x0D\x0A]/,ah=_t(Mi),X=P(Mi,"+"),te=P(Mi,"*"),wn=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;yr&&(wn=P("[",_t(wn),"\\u{10000}-\\u{10FFFF}","]"));var lh=_t(wn),_o=P("[",lh,_t(/[-.0-9\xB7]/),_t(/[\u0300-\u036F\u203F-\u2040]/),"]"),Be=P(wn,_o,"*"),uh=P("^",Be,"$"),El=P(_o,"+"),ch=P("&",Be,";"),dh=B(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),yn=B(ch,"|",dh),vn=P("%",Be,";"),wo=B(P('"',B(/[^%&"]/,"|",vn,"|",yn),"*",'"'),"|",P("'",B(/[^%&']/,"|",vn,"|",yn),"*","'")),fh=B('"',B(/[^<&"]/,"|",yn),"*",'"',"|","'",B(/[^<&']/,"|",yn),"*","'"),hh=_r(wn,":"),ph=_r(_o,":"),go=P(hh,ph,"*"),mh=P("^",go,"$"),En=P(go,B(":",go),"?"),gh=P("^",En,"$"),bh=P("(",En,")"),wr=B(/"[^"]*"|'[^']*'/),_h=P(/^<\?/,"(",Be,")",B(X,"(?!",Mi,")(",wt,"*?)"),"?",/\?>/),xl=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,xn=B('"',xl,'*"',"|","'",_r(xl,"'"),"*'"),Cl="<!--",Sl="-->",wh=P(Cl,B(_r(wt,"-"),"|",P("-",_r(wt,"-"))),"*",Sl),kl="#PCDATA",yh=B(P(/\(/,te,kl,B(te,/\|/,te,En),"*",te,/\)\*/),"|",P(/\(/,te,kl,te,/\)/)),vh=/[?*+]?/,Eh=P(/\([^>]+\)/,vh),xh=B("EMPTY","|","ANY","|",yh,"|",Eh),kh="<!ELEMENT",Ah=P(kh,X,B(En,"|",vn),X,B(xh,"|",vn),te,">"),Th=P("NOTATION",X,/\(/,te,Be,B(te,/\|/,te,Be),"*",te,/\)/),Dh=P(/\(/,te,El,B(te,/\|/,te,El),"*",te,/\)/),Ch=B(Th,"|",Dh),Sh=B(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Ch),Nh=B(/#REQUIRED|#IMPLIED/,"|",B(B("#FIXED",X),"?",fh)),Ih=B(X,Be,X,Sh,X,Nh),Oh="<!ATTLIST",Bh=P(Oh,X,Be,Ih,"*",te,">"),bo="about:legacy-compat",Rh=B('"'+bo+'"',"|","'"+bo+"'"),yo="SYSTEM",Li="PUBLIC",Pi=B(B(yo,X,wr),"|",B(Li,X,xn,X,wr)),$h=P("^",B(B(yo,X,"(?<SystemLiteralOnly>",wr,")"),"|",B(Li,X,"(?<PubidLiteral>",xn,")",X,"(?<SystemLiteral>",wr,")"))),Mh=P("^",xn,"$"),Lh=P("^",wr,"$"),Ph=B(X,"NDATA",X,Be),jh=B(wo,"|",B(Pi,Ph,"?")),Nl="<!ENTITY",Fh=P(Nl,X,Be,X,jh,te,">"),qh=B(wo,"|",Pi),Uh=P(Nl,X,"%",X,Be,X,qh,te,">"),Vh=B(Fh,"|",Uh),zh=P(Li,X,xn),Hh=P("<!NOTATION",X,Be,X,B(Pi,"|",zh),te,">"),vo=P(te,"=",te),Al=/1[.]\d+/,Wh=P(X,"version",vo,B("'",Al,"'","|",'"',Al,'"')),Tl=/[A-Za-z][-A-Za-z0-9._]*/,Gh=B(X,"encoding",vo,B('"',Tl,'"',"|","'",Tl,"'")),Xh=B(X,"standalone",vo,B("'",B("yes","|","no"),"'","|",'"',B("yes","|","no"),'"')),Yh=P(/^<\?xml/,Wh,Gh,"?",Xh,"?",te,/\?>/),Zh="<!DOCTYPE",Jh="<![CDATA[",Kh="]]>",Qh=/<!\[CDATA\[/,ep=/\]\]>/,tp=P(wt,"*?",ep),rp=P(Qh,tp);$.chars=_t;$.chars_without=_r;$.detectUnicodeSupport=Dl;$.reg=P;$.regg=B;$.ABOUT_LEGACY_COMPAT=bo;$.ABOUT_LEGACY_COMPAT_SystemLiteral=Rh;$.AttlistDecl=Bh;$.CDATA_START=Jh;$.CDATA_END=Kh;$.CDSect=rp;$.Char=wt;$.Comment=wh;$.COMMENT_START=Cl;$.COMMENT_END=Sl;$.DOCTYPE_DECL_START=Zh;$.elementdecl=Ah;$.EntityDecl=Vh;$.EntityValue=wo;$.ExternalID=Pi;$.ExternalID_match=$h;$.Name=Be;$.Name_exact=uh;$.NCName_exact=mh;$.NotationDecl=Hh;$.Reference=yn;$.PEReference=vn;$.PI=_h;$.PUBLIC=Li;$.PubidLiteral=xn;$.PubidLiteral_match=Mh;$.QName=En;$.QName_exact=gh;$.QName_group=bh;$.S=X;$.SChar_s=ah;$.S_OPT=te;$.SYSTEM=yo;$.SystemLiteral=wr;$.SystemLiteral_match=Lh;$.InvalidChar=oh;$.UNICODE_REPLACEMENT_CHARACTER=sh;$.UNICODE_SUPPORT=yr;$.XMLDecl=Yh});var Oo=dt(ie=>{"use strict";var Pe=zt(),Ke=Pe.find,np=Pe.hasDefaultHTMLNamespace,Er=Pe.hasOwn,ip=Pe.isHTMLMimeType,sp=Pe.isHTMLRawTextElement,op=Pe.isHTMLVoidElement,kn=Pe.MIME_TYPE,Qe=Pe.NAMESPACE,ke=Symbol(),Ll=_n(),k=Ll.DOMException,xe=Ll.DOMExceptionName,ne=Eo();function Se(n){if(n!==ke)throw new TypeError("Illegal constructor")}function ap(n){return n!==""}function lp(n){return n?n.split(/[\t\n\f\r ]+/).filter(ap):[]}function up(n,e){return Er(n,e)||(n[e]=!0),n}function Il(n){if(!n)return[];var e=lp(n);return Object.keys(e.reduce(up,{}))}function cp(n){return function(e){return n&&n.indexOf(e)!==-1}}function Pl(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function ko(n,e){Pl(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var i=e.split(":");t=i[0],r=i[1]}if(t!==null&&n===null)throw new k(k.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==Pe.NAMESPACE.XML)throw new k(k.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==Pe.NAMESPACE.XMLNS)throw new k(k.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===Pe.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new k(k.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function Ar(n,e){for(var t in n)Er(n,t)&&(e[t]=n[t])}function Ne(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Ar(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var Ie={},Le=Ie.ELEMENT_NODE=1,xr=Ie.ATTRIBUTE_NODE=2,An=Ie.TEXT_NODE=3,jl=Ie.CDATA_SECTION_NODE=4,Fl=Ie.ENTITY_REFERENCE_NODE=5,dp=Ie.ENTITY_NODE=6,Ao=Ie.PROCESSING_INSTRUCTION_NODE=7,To=Ie.COMMENT_NODE=8,vr=Ie.DOCUMENT_NODE=9,ql=Ie.DOCUMENT_TYPE_NODE=10,yt=Ie.DOCUMENT_FRAGMENT_NODE=11,fp=Ie.NOTATION_NODE=12,re=Pe.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 Ul(n,e){if(e.length<n.length)return Ul(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function Ol(n){return n.guid||(n.guid=Math.random()),n.guid}function ue(){}ue.prototype={length:0,item:function(n){return n>=0&&n<this.length?this[n]:null},toString:function(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],r=0;r<this.length;r++)Io(this[r],t,null,e);return t.join("")},filter:function(n){return Array.prototype.filter.call(this,n)},indexOf:function(n){return Array.prototype.indexOf.call(this,n)}};ue.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Je(n,e){this._node=n,this._refresh=e,Ui(this)}function Ui(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if(Ql(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)Er(n,r)&&delete n[r];Ar(t,n),n._inc=e}}Je.prototype.item=function(n){return Ui(this),this[n]||null};Ne(Je,ue);function kr(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Vl(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function Do(n,e,t){if(!e)return n._noNsIndex;var r=n._nsIndex[e];return!r&&t&&(r=n._nsIndex[e]=Object.create(null)),r}function hp(n,e,t){var r=Do(n,e,!1),i=r&&r[t];return i||null}function pp(n,e){Do(n,e.namespaceURI,!0)[e.localName]=e}function mp(n,e){var t=Do(n,e.namespaceURI,!1);t&&delete t[e.localName]}function gp(n,e,t,r){if(r?e[Vl(e,r)]=t:(e[e.length]=t,e.length++),pp(e,t),n){t.ownerElement=n;var i=n.ownerDocument;i&&(r&&Wl(i,n,r),bp(i,n,t))}}function Bl(n,e,t){var r=Vl(e,t);if(r>=0){for(var i=e.length-1;r<=i;)e[r]=e[++r];if(e.length=i,mp(e,t),n){var s=n.ownerDocument;s&&Wl(s,n,t),t.ownerElement=null}}}kr.prototype={length:0,item:ue.prototype.item,getNamedItem:function(n){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===n)return t;e++}return null},setNamedItem:function(n){var e=n.ownerElement;if(e&&e!==this._ownerElement)throw new k(k.INUSE_ATTRIBUTE_ERR);var t=hp(this,n.namespaceURI,n.localName);return t===n?n:(gp(this._ownerElement,this,n,t),t)},setNamedItemNS:function(n){return this.setNamedItem(n)},removeNamedItem:function(n){var e=this.getNamedItem(n);if(!e)throw new k(k.NOT_FOUND_ERR,n);return Bl(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new k(k.NOT_FOUND_ERR,n?n+" : "+e:e);return Bl(this._ownerElement,this,t),t},getNamedItemNS:function(n,e){n||(n=null);for(var t=0;t<this.length;){var r=this[t];if(r.localName===e&&r.namespaceURI===n)return r;t++}return null}};kr.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function zl(){}zl.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=kn.XML_APPLICATION;n===Qe.HTML?r=kn.XML_XHTML_APPLICATION:n===Qe.SVG&&(r=kn.XML_SVG_IMAGE);var i=new ot(ke,{contentType:r});if(i.implementation=this,i.childNodes=new ue,i.doctype=t||null,t&&i.appendChild(t),e){var s=i.createElementNS(n,e);i.appendChild(s)}return i},createDocumentType:function(n,e,t,r){Pl(n);var i=new Hi(ke);return i.name=n,i.nodeName=n,i.publicId=e||"",i.systemId=t||"",i.internalSubset=r||"",i.childNodes=new ue,i},createHTMLDocument:function(n){var e=new ot(ke,{contentType:kn.HTML});if(e.implementation=this,e.childNodes=new ue,n!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var r=e.createElement("head");if(t.appendChild(r),typeof n=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(n)),r.appendChild(i)}t.appendChild(e.createElement("body"))}return e}};function F(n){Se(n)}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 n=this.getRootNode();return n&&n.nodeType===n.DOCUMENT_NODE},contains:function(n){if(!n)return!1;var e=n;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(n){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(n){if(!n)return!1;for(var e=[{node:this,other:n}];e.length>0;){var t=e.pop(),r=t.node,i=t.other;if(r.nodeType!==i.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==i.name||r.publicId!==i.publicId||r.systemId!==i.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==i.namespaceURI||r.prefix!==i.prefix||r.localName!==i.localName||r.attributes.length!==i.attributes.length)return!1;for(var s=0;s<r.attributes.length;s++){var o=r.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==i.namespaceURI||r.localName!==i.localName||r.value!==i.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==i.target||r.data!==i.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==i.data)return!1;break}if(r.childNodes.length!==i.childNodes.length)return!1;for(var s=r.childNodes.length-1;s>=0;s--)e.push({node:r.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return qi(this,n,e)},replaceChild:function(n,e){qi(this,n,e,Yl),e&&this.removeChild(e)},removeChild:function(n){return Gl(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return Kl(this.ownerDocument||this,this,n)},normalize:function(){ge(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===An&&e.nodeType===An){for(var r=[],i=t;i!==null&&i.nodeType===An;)r.push(i.data),i=i.nextSibling;for(var s=e.nextSibling;s!==i;){var o=s.nextSibling;s.parentNode=null,s.previousSibling=null,s.nextSibling=null,s=o}e.nextSibling=i,i!==null?i.previousSibling=e:n.lastChild=e,e.appendData(r.join("")),Co(n.ownerDocument,n),e=i}else e=t}return!0}})},isSupported:function(n,e){return this.ownerDocument.implementation.hasFeature(n,e)},lookupPrefix:function(n){for(var e=this;e;){var t=e._nsMap;if(t){for(var r in t)if(Er(t,r)&&t[r]===n)return r}e=e.nodeType==xr?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&Er(t,n))return t[n];e=e.nodeType==xr?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(n){var e=this.lookupPrefix(n);return e==null},compareDocumentPosition:function(n){if(this===n)return 0;var e=n,t=this,r=null,i=null;if(e instanceof Ht&&(r=e,e=r.ownerElement),t instanceof Ht&&(i=t,t=i.ownerElement,r&&e&&t===e))for(var s=0,o;o=t.attributes[s];s++){if(o===r)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_PRECEDING;if(o===i)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return re.DOCUMENT_POSITION_DISCONNECTED+re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Ol(t.ownerDocument)>Ol(e.ownerDocument)?re.DOCUMENT_POSITION_FOLLOWING:re.DOCUMENT_POSITION_PRECEDING);if(i&&e===t)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=Ul(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return re.DOCUMENT_POSITION_FOLLOWING;if(h===e)return re.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return re.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return re.DOCUMENT_POSITION_PRECEDING}return 0}};function Hl(n){return n=="<"&&"<"||n==">"&&">"||n=="&"&&"&"||n=='"'&&"""||"&#"+n.charCodeAt()+";"}Ar(Ie,F);Ar(Ie,F.prototype);Ar(re,F);Ar(re,F.prototype);function Fi(n,e){ge(n,null,{enter:function(t){return e(t)?ge.STOP:!0}})}function ge(n,e,t){for(var r=[{node:n,context:e,phase:ge.ENTER}];r.length>0;){var i=r.pop();if(i.phase===ge.ENTER){var s=t.enter(i.node,i.context);if(s===ge.STOP)return ge.STOP;if(r.push({node:i.node,context:s,phase:ge.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)r.push({node:o,context:s,phase:ge.ENTER}),o=o.previousSibling}else t.exit&&t.exit(i.node,i.context)}}ge.STOP=Symbol("walkDOM.STOP");ge.ENTER=0;ge.EXIT=1;function ot(n,e){Se(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||kn.XML_APPLICATION,this.type=ip(this.contentType)?"html":"xml"}function bp(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===Qe.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Wl(n,e,t,r){n&&n._inc++;var i=t.namespaceURI;i===Qe.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function Co(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var i=e.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s,delete r[r.length]}}}function Gl(n,e){if(n!==e.parentNode)throw new k(k.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,r=e.nextSibling;return t?t.nextSibling=r:n.firstChild=r,r?r.previousSibling=t:n.lastChild=t,Co(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function _p(n){return n&&(n.nodeType===F.DOCUMENT_NODE||n.nodeType===F.DOCUMENT_FRAGMENT_NODE||n.nodeType===F.ELEMENT_NODE)}function wp(n){return n&&(n.nodeType===F.CDATA_SECTION_NODE||n.nodeType===F.COMMENT_NODE||n.nodeType===F.DOCUMENT_FRAGMENT_NODE||n.nodeType===F.DOCUMENT_TYPE_NODE||n.nodeType===F.ELEMENT_NODE||n.nodeType===F.PROCESSING_INSTRUCTION_NODE||n.nodeType===F.TEXT_NODE)}function vt(n){return n&&n.nodeType===F.DOCUMENT_TYPE_NODE}function st(n){return n&&n.nodeType===F.ELEMENT_NODE}function Xl(n){return n&&n.nodeType===F.TEXT_NODE}function Rl(n,e){var t=n.childNodes||[];if(Ke(t,st)||vt(e))return!1;var r=Ke(t,vt);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function $l(n,e){var t=n.childNodes||[];function r(s){return st(s)&&s!==e}if(Ke(t,r))return!1;var i=Ke(t,vt);return!(e&&i&&t.indexOf(i)>t.indexOf(e))}function yp(n,e,t){if(!_p(n))throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new k(k.NOT_FOUND_ERR,"child not in parent");if(!wp(e)||vt(e)&&n.nodeType!==F.DOCUMENT_NODE)throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function vp(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var s=i.filter(st);if(s.length>1||Ke(i,Xl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Rl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(st(e)&&!Rl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(vt(e)){if(Ke(r,vt))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,st);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function Yl(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var s=i.filter(st);if(s.length>1||Ke(i,Xl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!$l(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(st(e)&&!$l(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(vt(e)){if(Ke(r,function(l){return vt(l)&&l!==t}))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,st);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function qi(n,e,t,r){yp(n,e,t),n.nodeType===F.DOCUMENT_NODE&&(r||vp)(n,e,t);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===yt){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=t?t.previousSibling:n.lastChild;s.previousSibling=a,o.nextSibling=t,a?a.nextSibling=s:n.firstChild=s,t==null?n.lastChild=o:t.previousSibling=o;do s.parentNode=n;while(s!==o&&(s=s.nextSibling));return Co(n.ownerDocument||n,n,e),e.nodeType==yt&&(e.firstChild=e.lastChild=null),e}ot.prototype={implementation:null,nodeName:"#document",nodeType:vr,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===yt){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return qi(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===Le&&(this.documentElement=n),n},removeChild:function(n){var e=Gl(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){qi(this,n,e,Yl),n.ownerDocument=this,e&&this.removeChild(e),st(n)&&(this.documentElement=n)},importNode:function(n,e){return Ep(this,n,e)},getElementById:function(n){var e=null;return Fi(this.documentElement,function(t){if(t.nodeType==Le&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new at(ke);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),np(this.contentType)&&(e.namespaceURI=Qe.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new ue;var t=e.attributes=new kr;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new Tr(ke);return n.ownerDocument=this,n.childNodes=new ue,n},createTextNode:function(n){var e=new Tn(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createComment:function(n){var e=new Vi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new k(k.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new zi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new Gi(ke);return t.ownerDocument=this,t.childNodes=new ue,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new Ht(ke);return e.ownerDocument=this,e.childNodes=new ue,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!ne.Name_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new k("document is an html document",xe.NotSupportedError);var e=new Wi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.nodeName=n,e},createElementNS:function(n,e){var t=ko(n,e),r=new at(ke),i=r.attributes=new kr;return r.childNodes=new ue,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],i._ownerElement=r,r},createAttributeNS:function(n,e){var t=ko(n,e),r=new Ht(ke);return r.ownerDocument=this,r.childNodes=new ue,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};Ne(ot,F);function at(n){Se(n),this._nsMap=Object.create(null)}at.prototype={nodeType:Le,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Qe.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(n){return!!this.getAttributeNode(n)},getAttribute:function(n){var e=this.getAttributeNode(n);return e?e.value:null},getAttributeNode:function(n){return this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase()),this.attributes.getNamedItem(n)},setAttribute:function(n,e){this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());var t=this.getAttributeNode(n);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(n),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(n){var e=this.getAttributeNode(n);e&&this.removeAttributeNode(e)},setAttributeNode:function(n){return this.attributes.setNamedItem(n)},setAttributeNodeNS:function(n){return this.attributes.setNamedItemNS(n)},removeAttributeNode:function(n){return this.attributes.removeNamedItem(n.nodeName)},removeAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(n,e){return this.getAttributeNodeNS(n,e)!=null},getAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);return t?t.value:null},setAttributeNS:function(n,e,t){var r=ko(n,e),i=r[2],s=this.getAttributeNodeNS(n,i);s?s.value=s.nodeValue=""+t:(s=this.ownerDocument.createAttributeNS(n,e),s.value=s.nodeValue=""+t,this.setAttributeNode(s))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=Il(n);return new Je(this,function(t){var r=[];return e.length>0&&Fi(t,function(i){if(i!==t&&i.nodeType===Le){var s=i.getAttribute("class");if(s){var o=n===s;if(!o){var a=Il(s);o=e.every(cp(a))}o&&r.push(i)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===vr?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Je(this,function(r){var i=[];return Fi(r,function(s){if(!(s===r||s.nodeType!==Le))if(n==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Qe.HTML?t:n;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(n,e){return new Je(this,function(t){var r=[];return Fi(t,function(i){i!==t&&i.nodeType===Le&&(n==="*"||i.namespaceURI===n)&&(e==="*"||i.localName==e)&&r.push(i)}),r})}};ot.prototype.getElementsByClassName=at.prototype.getElementsByClassName;ot.prototype.getElementsByTagName=at.prototype.getElementsByTagName;ot.prototype.getElementsByTagNameNS=at.prototype.getElementsByTagNameNS;Ne(at,F);function Ht(n){Se(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Ht.prototype.nodeType=xr;Ne(Ht,F);function Et(n){Se(n)}Et.prototype={data:"",substringData:function(n,e){return this.data.substring(n,n+e)},appendData:function(n){n=this.data+n,this.nodeValue=this.data=n,this.length=n.length},insertData:function(n,e){this.replaceData(n,0,e)},deleteData:function(n,e){this.replaceData(n,e,"")},replaceData:function(n,e,t){var r=this.data.substring(0,n),i=this.data.substring(n+e);t=r+t+i,this.nodeValue=this.data=t,this.length=t.length}};Ne(Et,F);function Tn(n){Se(n)}Tn.prototype={nodeName:"#text",nodeType:An,splitText:function(n){var e=this.data,t=e.substring(n);e=e.substring(0,n),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};Ne(Tn,Et);function Vi(n){Se(n)}Vi.prototype={nodeName:"#comment",nodeType:To};Ne(Vi,Et);function zi(n){Se(n)}zi.prototype={nodeName:"#cdata-section",nodeType:jl};Ne(zi,Tn);function Hi(n){Se(n)}Hi.prototype.nodeType=ql;Ne(Hi,F);function So(n){Se(n)}So.prototype.nodeType=fp;Ne(So,F);function No(n){Se(n)}No.prototype.nodeType=dp;Ne(No,F);function Wi(n){Se(n)}Wi.prototype.nodeType=Fl;Ne(Wi,F);function Tr(n){Se(n)}Tr.prototype.nodeName="#document-fragment";Tr.prototype.nodeType=yt;Ne(Tr,F);function Gi(n){Se(n)}Gi.prototype.nodeType=Ao;Ne(Gi,Et);function Zl(){}Zl.prototype.serializeToString=function(n,e){return Jl.call(n,e)};F.prototype.toString=Jl;function Jl(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n!=null?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],r=this.nodeType===vr&&this.documentElement||this,i=r.prefix,s=r.namespaceURI;if(s&&i==null){var i=r.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return Io(this,t,o,e),t.join("")}function Ml(n,e,t){var r=n.prefix||"",i=n.namespaceURI;if(!i||r==="xml"&&i===Qe.XML||i===Qe.XMLNS)return!1;for(var s=t.length;s--;){var o=t[s];if(o.prefix===r)return o.namespace!==i}return!0}function ji(n,e,t,r){if(r&&!ne.QName_exact.test(e))throw new k('The attribute name "'+e+'" is not a valid XML QName',xe.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Hl),'"')}function Io(n,e,t,r){t||(t=[]);var i=r.nodeFilter,s=r.requireWellFormed,o=r.splitCDATASections,a=n.nodeType===vr?n:n.ownerDocument,l=a.type==="html";ge(n,{ns:t},{enter:function(u,c){var d=c.ns;if(i)if(u=i(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case Le:var f=u.attributes,h=f.length,m=u.tagName,p=m;if(!l&&!u.prefix&&u.namespaceURI){for(var b,g=0;g<f.length;g++)if(f.item(g).name==="xmlns"){b=f.item(g).value;break}if(!b)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.prefix===""&&w.namespace===u.namespaceURI){b=w.namespace;break}}if(b!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.namespace===u.namespaceURI){w.prefix&&(p=w.prefix+":"+m);break}}}if(s&&!ne.QName_exact.test(p))throw new k('The element name "'+p+'" is not a valid XML QName',xe.InvalidStateError);e.push("<",p);for(var E=d.slice(),D=0;D<h;D++){var y=f.item(D);y.prefix=="xmlns"?E.push({prefix:y.localName,namespace:y.value}):y.nodeName=="xmlns"&&E.push({prefix:"",namespace:y.value})}for(var D=0;D<h;D++){var y=f.item(D);if(Ml(y,l,E)){var T=y.prefix||"",S=y.namespaceURI;ji(e,T?"xmlns:"+T:"xmlns",S,s),E.push({prefix:T,namespace:S})}var I=i?i(y):y;I&&(typeof I=="string"?e.push(I):ji(e,I.name,I.value,s))}if(m===p&&Ml(u,l,E)){var W=u.prefix||"",S=u.namespaceURI;ji(e,W?"xmlns:"+W:"xmlns",S,s),E.push({prefix:W,namespace:S})}var ee=!u.firstChild;if(ee&&(l||u.namespaceURI===Qe.HTML)&&(ee=op(m)),ee)return e.push("/>"),null;if(e.push(">"),l&&sp(m)){for(var se=u.firstChild;se;)se.data?e.push(se.data):Io(se,e,E.slice(),r),se=se.nextSibling;return e.push("</",p,">"),null}return{ns:E,tag:p};case vr:case yt:if(s&&u.nodeType===vr&&u.documentElement==null)throw new k("The Document has no documentElement",xe.InvalidStateError);return{ns:d};case xr:return ji(e,u.name,u.value,s),null;case An:if(s&&ne.InvalidChar.test(u.data))throw new k("The Text node data contains characters outside the XML Char production",xe.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Hl)),null;case jl:if(s&&u.data.indexOf("]]>")!==-1)throw new k('The CDATASection data contains "]]>"',xe.InvalidStateError);return o?e.push(ne.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),ne.CDATA_END):e.push(ne.CDATA_START,u.data,ne.CDATA_END),null;case To:if(s){if(ne.InvalidChar.test(u.data))throw new k("The comment node data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new k('The comment node data contains "--" or ends with "-"',xe.InvalidStateError)}return e.push(ne.COMMENT_START,u.data,ne.COMMENT_END),null;case ql:var he=u.publicId,Y=u.systemId;if(s){if(!ne.Name_exact.test(u.name))throw new k('The doctype name "'+u.name+'" is not a valid XML Name',xe.InvalidStateError);if(he&&!ne.PubidLiteral_match.test(he))throw new k("DocumentType publicId is not a valid PubidLiteral",xe.InvalidStateError);if(Y&&Y!=="."&&!ne.SystemLiteral_match.test(Y))throw new k("DocumentType systemId is not a valid SystemLiteral",xe.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new k('DocumentType internalSubset contains "]>"',xe.InvalidStateError)}return e.push(ne.DOCTYPE_DECL_START," ",u.name),he?(e.push(" ",ne.PUBLIC," ",he),Y&&Y!=="."&&e.push(" ",Y)):Y&&Y!=="."&&e.push(" ",ne.SYSTEM," ",Y),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Ao:if(s){if(!ne.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new k('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',xe.InvalidStateError);if(ne.InvalidChar.test(u.data))throw new k("The ProcessingInstruction data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new k('The ProcessingInstruction data contains "?>"',xe.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Fl:if(s&&!ne.Name_exact.test(u.nodeName))throw new k('The entity reference name "'+u.nodeName+'" is not a valid XML Name',xe.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 Ep(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=n,o.parentNode=null,s===null?r=o:s.appendChild(o);var a=i.nodeType===xr||t;return a?o:null}}),r}function Kl(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=new i.constructor(ke);for(var a in i)if(Er(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new ue),o.ownerDocument=n;var u=t;switch(o.nodeType){case Le:var c=i.attributes,d=o.attributes=new kr,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(Kl(n,c.item(h),!0));break;case xr:u=!0}return s!==null?s.appendChild(o):r=o,u?o:null}}),r}function Ql(n,e,t){n[e]=t}function xo(n){for(var e=[],t=n.firstChild;t;)t.nodeType===Le&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Je.prototype,"length",{get:function(){return Ui(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){if(this.nodeType===Le||this.nodeType===yt){var n=[];return ge(this,null,{enter:function(e){if(e.nodeType===Le||e.nodeType===yt)return!0;if(e.nodeType===Ao||e.nodeType===To)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case Le:case yt:for(;this.firstChild;)this.removeChild(this.firstChild);(n||String(n))&&this.appendChild(this.ownerDocument.createTextNode(n));break;default:this.data=n,this.value=n,this.nodeValue=n}}}),Object.defineProperty(Et.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(n){this._data=n,this.length=typeof n=="string"?n.length:0}}),Object.defineProperty(Et.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(at.prototype,"children",{get:function(){return new Je(this,xo)}}),Object.defineProperty(ot.prototype,"children",{get:function(){return new Je(this,xo)}}),Object.defineProperty(Tr.prototype,"children",{get:function(){return new Je(this,xo)}}),Ql=function(n,e,t){n["$$"+e]=t})}catch{}ie._updateLiveList=Ui;ie.Attr=Ht;ie.CDATASection=zi;ie.CharacterData=Et;ie.Comment=Vi;ie.Document=ot;ie.DocumentFragment=Tr;ie.DocumentType=Hi;ie.DOMImplementation=zl;ie.Element=at;ie.Entity=No;ie.EntityReference=Wi;ie.LiveNodeList=Je;ie.NamedNodeMap=kr;ie.Node=F;ie.NodeList=ue;ie.Notation=So;ie.Text=Tn;ie.ProcessingInstruction=Gi;ie.walkDOM=ge;ie.XMLSerializer=Zl});var tu=dt(Dn=>{"use strict";var eu=zt().freeze;Dn.XML_ENTITIES=eu({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Dn.HTML_ENTITIES=eu({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"});Dn.entityMap=Dn.HTML_ENTITIES});var cu=dt(Yi=>{"use strict";var Ir=zt(),M=Eo(),su=_n(),xp=Ir.isHTMLEscapableRawTextElement,kp=Ir.isHTMLMimeType,Ap=Ir.isHTMLRawTextElement,Nn=Ir.hasOwn,ru=Ir.NAMESPACE,Tp=su.ParseError,Dp=su.DOMException,Dr=0,xt=1,Cr=2,Cn=3,Sr=4,Nr=5,Sn=6,Xi=7;function ou(){}ou.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),Ip(e,e=Object.create(null)),Cp(n,e,t,r,this.errorHandler),r.endDocument()}};var Bo=/&#?\w+;?/g;function Cp(n,e,t,r,i){var s=kp(r.mimeType);n.indexOf(M.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(z){if(z>65535){z-=65536;var Me=55296+(z>>10),_i=56320+(z&1023);return String.fromCharCode(Me,_i)}else return String.fromCharCode(z)}function a(z){var Me=z[z.length-1]===";"?z:z+";";if(!s&&Me!==z)return i.error("EntityRef: expecting ;"),z;var _i=M.Reference.exec(Me);if(!_i||_i[0].length!==Me.length)return i.error("entity not matching Reference production: "+z),z;var wi=Me.slice(1,-1);return Nn(t,wi)?t[wi]:wi.charAt(0)==="#"?o(parseInt(wi.substring(1).replace("x","0x"))):(i.error("entity not found:"+z),z)}function l(z){if(z>b){var Me=n.substring(b,z).replace(Bo,a);f&&h(b),r.characters(Me,0,z-b),b=z}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(z,Me){for(;z>=c&&(Me=d.exec(n));)u=c,c=Me.index+Me[0].length,f.lineNumber++;f.columnNumber=z-u+1}for(var m=[{currentNSMap:e}],p=[],b=0;;){try{var g=n.indexOf("<",b);if(g<0){if(!s&&p.length>0)return i.fatalError("unclosed xml tag(s): "+p.join(", "));if(!n.substring(b).match(/^\s*$/)){var _=r.doc,w=_.createTextNode(n.substring(b));if(_.documentElement)return i.error("Extra content at the end of the document");_.appendChild(w),r.currentElement=w}return}if(g>b){var E=n.substring(b,g);!s&&p.length===0&&(E=E.replace(new RegExp(M.S_OPT.source,"g"),""),E&&i.error("Unexpected content outside root element: '"+E+"'")),l(g)}switch(n.charAt(g+1)){case"/":var L=n.indexOf(">",g+2),D=n.substring(g+2,L>0?L:void 0);if(!D)return i.fatalError("end tag name missing");var y=M.reg("^",M.QName_group,M.S_OPT,"$"),T=L>0&&y.exec(D);if(!T){var S=L>0&&M.reg("^",M.QName_group).exec(D);if(s&&S)i.warning('end tag name contains invalid trailing characters: "'+D+'"'),T=S;else if(S&&new RegExp(y.source,y.flags+"m").test(D))i.error('end tag name is followed by a line break and trailing content: "'+D+'"'),T=S;else return i.fatalError('end tag name contains invalid characters: "'+D+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var I=p[p.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(I!==T[1]){var W=T[1].toLowerCase();if(!s||I.toLowerCase()!==W)return i.fatalError('Opening and ending tag mismatch: "'+I+'" != "'+D+'"')}var ee=m.pop();p.pop();var se=ee.localNSMap;if(r.endElement(ee.uri,ee.localName,I),se)for(var he in se)Nn(se,he)&&r.endPrefixMapping(he);L++;break;case"?":f&&h(g),L=Bp(n,g,r,i);break;case"!":f&&h(g),L=lu(n,g,r,i,s);break;default:f&&h(g);var Y=new uu,ae=m[m.length-1].currentNSMap,L=Sp(n,g,Y,ae,a,i,s),Sa=Y.length;if(Y.closed||(s&&Ir.isHTMLVoidElement(Y.tagName)?Y.closed=!0:p.push(Y.tagName)),f&&Sa){for(var md=nu(f,{}),Ys=0;Ys<Sa;Ys++){var Na=Y[Ys];h(Na.offset),Na.locator=nu(f,{})}r.locator=md,iu(Y,r,ae)&&m.push(Y),r.locator=f}else iu(Y,r,ae)&&m.push(Y);s&&!Y.closed?L=Np(n,L,Y.tagName,a,r):L++}}catch(z){if(z instanceof Tp)throw z;if(z instanceof Dp)return i.fatalError("Error constructing the DOM: "+z.name+": "+z.message,z);i.error("element parse error: "+z),L=-1}L>b?b=L:l(Math.max(g,b)+1)}}function nu(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function Sp(n,e,t,r,i,s,o){function a(h,m,p){if(Nn(t.attributeNames,h))return s.fatalError("Attribute "+h+" redefined");if(!o&&m.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,m.replace(/[\t\n\r]/g," ").replace(Bo,i),p)}for(var l,u,c=++e,d=Dr;;){var f=n.charAt(c);if(d===Dr&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===xt)l=n.slice(e,c),d=Cn;else if(d===Cr)d=Cn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===Cn||d===xt)if(d===xt&&(s.warning('attribute value must after "="'),l=n.slice(e,c)),e=c+1,c=n.indexOf(f,e),c>0)u=n.slice(e,c),a(l,u,e-1),d=Nr;else throw new Error("attribute value no end '"+f+"' match");else if(d==Sr)u=n.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Nr;else throw new Error('attribute value must after "="');break;case"/":switch(d){case Dr:t.setTagName(n.slice(e,c));case Nr:case Sn:case Xi:d=Xi,t.closed=!0;case Sr:case xt:break;case Cr:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),d==Dr&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case Dr:t.setTagName(n.slice(e,c));case Nr:case Sn:case Xi:break;case Sr:case xt:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Cr:d===Cr&&(u=l),d==Sr?(s.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||s.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case Cn:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case Dr:t.setTagName(n.slice(e,c)),d=Sn;break;case xt:l=n.slice(e,c),d=Cr;break;case Sr:var u=n.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Nr:d=Sn;break}else switch(d){case Cr:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=xt;break;case Nr:s.warning('attribute space is required"'+l+'"!!');case Sn:d=xt,e=c;break;case Cn:d=Sr,e=c;break;case Xi:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function iu(n,e,t){for(var r=n.tagName,i=null,d=n.length;d--;){var s=n[d],o=s.qName,a=s.value,f=o.indexOf(":");if(f>0)var l=s.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),t=Object.create(t)),t[c]=i[c]=a,s.uri=ru.XMLNS,e.startPrefixMapping(c,a))}for(var d=n.length;d--;)s=n[d],s.prefix&&(s.prefix==="xml"&&(s.uri=ru.XML),s.prefix!=="xmlns"&&(s.uri=t[s.prefix]));var f=r.indexOf(":");f>0?(l=n.prefix=r.slice(0,f),u=n.localName=r.slice(f+1)):(l=null,u=n.localName=r);var h=n.uri=t[l||""];if(e.startElement(h,u,r,n),n.closed){if(e.endElement(h,u,r),i)for(l in i)Nn(i,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=i,!0}function Np(n,e,t,r,i){var s=xp(t);if(s||Ap(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(n),l=a?a.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return s&&(u=u.replace(Bo,r)),i.characters(u,0,u.length),l}return e+1}function Ip(n,e){for(var t in n)Nn(n,t)&&(e[t]=n[t])}function au(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function i(c){c=c||1,t+=c}function s(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
|
|
11
|
-
`&&d!==" "&&d!=="\r")return c;c++,i()}return-1}function o(){return n.substring(t)}function a(c){return n.substring(t,t+c.length)===c}function l(c){return n.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=M.reg("^",c),f=d.exec(o());return f?(i(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function
|
|
9
|
+
var yd=Object.create;var eo=Object.defineProperty;var vd=Object.getOwnPropertyDescriptor;var Ed=Object.getOwnPropertyNames;var xd=Object.getPrototypeOf,kd=Object.prototype.hasOwnProperty;var ft=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ad=(n,e)=>{for(var t in e)eo(n,t,{get:e[t],enumerable:!0})},Td=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ed(e))!kd.call(n,i)&&i!==t&&eo(n,i,{get:()=>e[i],enumerable:!(r=vd(e,i))||r.enumerable});return n};var $a=(n,e,t)=>(t=n!=null?yd(xd(n)):{},Td(e||!n||!n.__esModule?eo(t,"default",{value:n,enumerable:!0}):t,n));var Vt=ft(me=>{"use strict";function Jf(n,e,t){if(t===void 0&&(t=Array.prototype),n&&typeof t.find=="function")return t.find.call(n,e);for(var r=0;r<n.length;r++)if(Ut(n,r)){var i=n[r];if(e.call(void 0,i,r,n))return i}}function _r(n,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(n=e.create(null,e.getOwnPropertyDescriptors(n))),e&&typeof e.freeze=="function"?e.freeze(n):n}function Ut(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Kf(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Ut(e,t)&&(n[t]=e[t]);return n}var gl=_r({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 Qf(n){return Ut(gl,n.toLowerCase())}var bl=_r({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 eh(n){return Ut(bl,n.toLowerCase())}var hn=_r({script:!1,style:!1,textarea:!0,title:!0});function th(n){var e=n.toLowerCase();return Ut(hn,e)&&!hn[e]}function rh(n){var e=n.toLowerCase();return Ut(hn,e)&&hn[e]}function _l(n){return n===pn.HTML}function nh(n){return _l(n)||n===pn.XML_XHTML_APPLICATION}var pn=_r({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),ih=Object.keys(pn).map(function(n){return pn[n]});function sh(n){return ih.indexOf(n)>-1}var oh=_r({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/"});me.assign=Kf;me.find=Jf;me.freeze=_r;me.HTML_BOOLEAN_ATTRIBUTES=gl;me.HTML_RAW_TEXT_ELEMENTS=hn;me.HTML_VOID_ELEMENTS=bl;me.hasDefaultHTMLNamespace=nh;me.hasOwn=Ut;me.isHTMLBooleanAttribute=Qf;me.isHTMLRawTextElement=th;me.isHTMLEscapableRawTextElement=rh;me.isHTMLMimeType=_l;me.isHTMLVoidElement=eh;me.isValidMimeType=sh;me.MIME_TYPE=pn;me.NAMESPACE=oh});var wn=ft(_n=>{"use strict";var ah=Vt();function yl(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var gn=ah.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"}),vl=Object.keys(gn);function El(n){return typeof n=="number"&&n>=1&&n<=25}function lh(n){return typeof n=="string"&&n.substring(n.length-gn.Error.length)===gn.Error}function bn(n,e){El(n)?(this.name=vl[n],this.message=e||""):(this.message=n,this.name=lh(e)?e:gn.Error),Error.captureStackTrace&&Error.captureStackTrace(this,bn)}yl(bn,!0);Object.defineProperties(bn.prototype,{code:{enumerable:!0,get:function(){var n=vl.indexOf(this.name);return El(n)?n:0}}});var xl={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},_o=Object.entries(xl);for(mn=0;mn<_o.length;mn++)wl=_o[mn][0],bn[wl]=_o[mn][1];var wl,mn;function wo(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,wo)}yl(wo);_n.DOMException=bn;_n.DOMExceptionName=gn;_n.ExceptionCode=xl;_n.ParseError=wo});var To=ft($=>{"use strict";function Sl(n){try{typeof n!="function"&&(n=RegExp);var e=new n("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var vr=Sl();function wt(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function wr(n,e){if(n.source[0]!=="[")throw new Error("/"+n.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(n.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+n.source+"/");if(e==="-"&&n.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+n.source+"/");return new RegExp(n.source.replace(e,""),vr?"u":"")}function L(n){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var r=typeof t=="string";if(r&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?t:t.source}).join(""),vr?"u":"")}function B(n){if(arguments.length===0)throw new Error("no parameters provided");return L.apply(B,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var uh="\uFFFD",yt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;vr&&(yt=L("[",wt(yt),"\\u{10000}-\\u{10FFFF}","]"));var ch=new RegExp("[^"+wt(yt)+"]",vr?"u":""),Li=/[\x20\x09\x0D\x0A]/,dh=wt(Li),X=L(Li,"+"),te=L(Li,"*"),yn=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;vr&&(yn=L("[",wt(yn),"\\u{10000}-\\u{10FFFF}","]"));var fh=wt(yn),Eo=L("[",fh,wt(/[-.0-9\xB7]/),wt(/[\u0300-\u036F\u203F-\u2040]/),"]"),Be=L(yn,Eo,"*"),hh=L("^",Be,"$"),kl=L(Eo,"+"),ph=L("&",Be,";"),mh=B(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),vn=B(ph,"|",mh),En=L("%",Be,";"),xo=B(L('"',B(/[^%&"]/,"|",En,"|",vn),"*",'"'),"|",L("'",B(/[^%&']/,"|",En,"|",vn),"*","'")),gh=B('"',B(/[^<&"]/,"|",vn),"*",'"',"|","'",B(/[^<&']/,"|",vn),"*","'"),bh=wr(yn,":"),_h=wr(Eo,":"),yo=L(bh,_h,"*"),wh=L("^",yo,"$"),xn=L(yo,B(":",yo),"?"),yh=L("^",xn,"$"),vh=L("(",xn,")"),yr=B(/"[^"]*"|'[^']*'/),Eh=L(/^<\?/,"(",Be,")",B(X,"(?!",Li,")(",yt,"*?)"),"?",/\?>/),Al=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,kn=B('"',Al,'*"',"|","'",wr(Al,"'"),"*'"),Nl="<!--",Il="-->",xh=L(Nl,B(wr(yt,"-"),"|",L("-",wr(yt,"-"))),"*",Il),Tl="#PCDATA",kh=B(L(/\(/,te,Tl,B(te,/\|/,te,xn),"*",te,/\)\*/),"|",L(/\(/,te,Tl,te,/\)/)),Ah=/[?*+]?/,Th=L(/\([^>]+\)/,Ah),Dh=B("EMPTY","|","ANY","|",kh,"|",Th),Ch="<!ELEMENT",Sh=L(Ch,X,B(xn,"|",En),X,B(Dh,"|",En),te,">"),Nh=L("NOTATION",X,/\(/,te,Be,B(te,/\|/,te,Be),"*",te,/\)/),Ih=L(/\(/,te,kl,B(te,/\|/,te,kl),"*",te,/\)/),Oh=B(Nh,"|",Ih),Bh=B(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Oh),Rh=B(/#REQUIRED|#IMPLIED/,"|",B(B("#FIXED",X),"?",gh)),$h=B(X,Be,X,Bh,X,Rh),Mh="<!ATTLIST",Ph=L(Mh,X,Be,$h,"*",te,">"),vo="about:legacy-compat",Lh=B('"'+vo+'"',"|","'"+vo+"'"),ko="SYSTEM",ji="PUBLIC",Fi=B(B(ko,X,yr),"|",B(ji,X,kn,X,yr)),jh=L("^",B(B(ko,X,"(?<SystemLiteralOnly>",yr,")"),"|",B(ji,X,"(?<PubidLiteral>",kn,")",X,"(?<SystemLiteral>",yr,")"))),Fh=L("^",kn,"$"),qh=L("^",yr,"$"),Uh=B(X,"NDATA",X,Be),Vh=B(xo,"|",B(Fi,Uh,"?")),Ol="<!ENTITY",zh=L(Ol,X,Be,X,Vh,te,">"),Hh=B(xo,"|",Fi),Wh=L(Ol,X,"%",X,Be,X,Hh,te,">"),Gh=B(zh,"|",Wh),Xh=L(ji,X,kn),Yh=L("<!NOTATION",X,Be,X,B(Fi,"|",Xh),te,">"),Ao=L(te,"=",te),Dl=/1[.]\d+/,Zh=L(X,"version",Ao,B("'",Dl,"'","|",'"',Dl,'"')),Cl=/[A-Za-z][-A-Za-z0-9._]*/,Jh=B(X,"encoding",Ao,B('"',Cl,'"',"|","'",Cl,"'")),Kh=B(X,"standalone",Ao,B("'",B("yes","|","no"),"'","|",'"',B("yes","|","no"),'"')),Qh=L(/^<\?xml/,Zh,Jh,"?",Kh,"?",te,/\?>/),ep="<!DOCTYPE",tp="<![CDATA[",rp="]]>",np=/<!\[CDATA\[/,ip=/\]\]>/,sp=L(yt,"*?",ip),op=L(np,sp);$.chars=wt;$.chars_without=wr;$.detectUnicodeSupport=Sl;$.reg=L;$.regg=B;$.ABOUT_LEGACY_COMPAT=vo;$.ABOUT_LEGACY_COMPAT_SystemLiteral=Lh;$.AttlistDecl=Ph;$.CDATA_START=tp;$.CDATA_END=rp;$.CDSect=op;$.Char=yt;$.Comment=xh;$.COMMENT_START=Nl;$.COMMENT_END=Il;$.DOCTYPE_DECL_START=ep;$.elementdecl=Sh;$.EntityDecl=Gh;$.EntityValue=xo;$.ExternalID=Fi;$.ExternalID_match=jh;$.Name=Be;$.Name_exact=hh;$.NCName_exact=wh;$.NotationDecl=Yh;$.Reference=vn;$.PEReference=En;$.PI=Eh;$.PUBLIC=ji;$.PubidLiteral=kn;$.PubidLiteral_match=Fh;$.QName=xn;$.QName_exact=yh;$.QName_group=vh;$.S=X;$.SChar_s=dh;$.S_OPT=te;$.SYSTEM=ko;$.SystemLiteral=yr;$.SystemLiteral_match=qh;$.InvalidChar=ch;$.UNICODE_REPLACEMENT_CHARACTER=uh;$.UNICODE_SUPPORT=vr;$.XMLDecl=Qh});var Mo=ft(ie=>{"use strict";var Le=Vt(),Ke=Le.find,ap=Le.hasDefaultHTMLNamespace,xr=Le.hasOwn,lp=Le.isHTMLMimeType,up=Le.isHTMLRawTextElement,cp=Le.isHTMLVoidElement,An=Le.MIME_TYPE,Qe=Le.NAMESPACE,ke=Symbol(),jl=wn(),k=jl.DOMException,xe=jl.DOMExceptionName,ne=To();function Se(n){if(n!==ke)throw new TypeError("Illegal constructor")}function dp(n){return n!==""}function fp(n){return n?n.split(/[\t\n\f\r ]+/).filter(dp):[]}function hp(n,e){return xr(n,e)||(n[e]=!0),n}function Bl(n){if(!n)return[];var e=fp(n);return Object.keys(e.reduce(hp,{}))}function pp(n){return function(e){return n&&n.indexOf(e)!==-1}}function Fl(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function Co(n,e){Fl(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var i=e.split(":");t=i[0],r=i[1]}if(t!==null&&n===null)throw new k(k.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==Le.NAMESPACE.XML)throw new k(k.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==Le.NAMESPACE.XMLNS)throw new k(k.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===Le.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new k(k.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function Tr(n,e){for(var t in n)xr(n,t)&&(e[t]=n[t])}function Ne(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Tr(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var Ie={},Pe=Ie.ELEMENT_NODE=1,kr=Ie.ATTRIBUTE_NODE=2,Tn=Ie.TEXT_NODE=3,ql=Ie.CDATA_SECTION_NODE=4,Ul=Ie.ENTITY_REFERENCE_NODE=5,mp=Ie.ENTITY_NODE=6,So=Ie.PROCESSING_INSTRUCTION_NODE=7,No=Ie.COMMENT_NODE=8,Er=Ie.DOCUMENT_NODE=9,Vl=Ie.DOCUMENT_TYPE_NODE=10,vt=Ie.DOCUMENT_FRAGMENT_NODE=11,gp=Ie.NOTATION_NODE=12,re=Le.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 zl(n,e){if(e.length<n.length)return zl(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function Rl(n){return n.guid||(n.guid=Math.random()),n.guid}function ue(){}ue.prototype={length:0,item:function(n){return n>=0&&n<this.length?this[n]:null},toString:function(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],r=0;r<this.length;r++)$o(this[r],t,null,e);return t.join("")},filter:function(n){return Array.prototype.filter.call(this,n)},indexOf:function(n){return Array.prototype.indexOf.call(this,n)}};ue.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Je(n,e){this._node=n,this._refresh=e,zi(this)}function zi(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if(tu(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)xr(n,r)&&delete n[r];Tr(t,n),n._inc=e}}Je.prototype.item=function(n){return zi(this),this[n]||null};Ne(Je,ue);function Ar(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Hl(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function Io(n,e,t){if(!e)return n._noNsIndex;var r=n._nsIndex[e];return!r&&t&&(r=n._nsIndex[e]=Object.create(null)),r}function bp(n,e,t){var r=Io(n,e,!1),i=r&&r[t];return i||null}function _p(n,e){Io(n,e.namespaceURI,!0)[e.localName]=e}function wp(n,e){var t=Io(n,e.namespaceURI,!1);t&&delete t[e.localName]}function yp(n,e,t,r){if(r?e[Hl(e,r)]=t:(e[e.length]=t,e.length++),_p(e,t),n){t.ownerElement=n;var i=n.ownerDocument;i&&(r&&Xl(i,n,r),vp(i,n,t))}}function $l(n,e,t){var r=Hl(e,t);if(r>=0){for(var i=e.length-1;r<=i;)e[r]=e[++r];if(e.length=i,wp(e,t),n){var s=n.ownerDocument;s&&Xl(s,n,t),t.ownerElement=null}}}Ar.prototype={length:0,item:ue.prototype.item,getNamedItem:function(n){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===n)return t;e++}return null},setNamedItem:function(n){var e=n.ownerElement;if(e&&e!==this._ownerElement)throw new k(k.INUSE_ATTRIBUTE_ERR);var t=bp(this,n.namespaceURI,n.localName);return t===n?n:(yp(this._ownerElement,this,n,t),t)},setNamedItemNS:function(n){return this.setNamedItem(n)},removeNamedItem:function(n){var e=this.getNamedItem(n);if(!e)throw new k(k.NOT_FOUND_ERR,n);return $l(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new k(k.NOT_FOUND_ERR,n?n+" : "+e:e);return $l(this._ownerElement,this,t),t},getNamedItemNS:function(n,e){n||(n=null);for(var t=0;t<this.length;){var r=this[t];if(r.localName===e&&r.namespaceURI===n)return r;t++}return null}};Ar.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Wl(){}Wl.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=An.XML_APPLICATION;n===Qe.HTML?r=An.XML_XHTML_APPLICATION:n===Qe.SVG&&(r=An.XML_SVG_IMAGE);var i=new at(ke,{contentType:r});if(i.implementation=this,i.childNodes=new ue,i.doctype=t||null,t&&i.appendChild(t),e){var s=i.createElementNS(n,e);i.appendChild(s)}return i},createDocumentType:function(n,e,t,r){Fl(n);var i=new Gi(ke);return i.name=n,i.nodeName=n,i.publicId=e||"",i.systemId=t||"",i.internalSubset=r||"",i.childNodes=new ue,i},createHTMLDocument:function(n){var e=new at(ke,{contentType:An.HTML});if(e.implementation=this,e.childNodes=new ue,n!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var r=e.createElement("head");if(t.appendChild(r),typeof n=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(n)),r.appendChild(i)}t.appendChild(e.createElement("body"))}return e}};function q(n){Se(n)}q.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 n=this.getRootNode();return n&&n.nodeType===n.DOCUMENT_NODE},contains:function(n){if(!n)return!1;var e=n;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(n){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(n){if(!n)return!1;for(var e=[{node:this,other:n}];e.length>0;){var t=e.pop(),r=t.node,i=t.other;if(r.nodeType!==i.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==i.name||r.publicId!==i.publicId||r.systemId!==i.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==i.namespaceURI||r.prefix!==i.prefix||r.localName!==i.localName||r.attributes.length!==i.attributes.length)return!1;for(var s=0;s<r.attributes.length;s++){var o=r.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==i.namespaceURI||r.localName!==i.localName||r.value!==i.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==i.target||r.data!==i.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==i.data)return!1;break}if(r.childNodes.length!==i.childNodes.length)return!1;for(var s=r.childNodes.length-1;s>=0;s--)e.push({node:r.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return Vi(this,n,e)},replaceChild:function(n,e){Vi(this,n,e,Jl),e&&this.removeChild(e)},removeChild:function(n){return Yl(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return eu(this.ownerDocument||this,this,n)},normalize:function(){ge(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===Tn&&e.nodeType===Tn){for(var r=[],i=t;i!==null&&i.nodeType===Tn;)r.push(i.data),i=i.nextSibling;for(var s=e.nextSibling;s!==i;){var o=s.nextSibling;s.parentNode=null,s.previousSibling=null,s.nextSibling=null,s=o}e.nextSibling=i,i!==null?i.previousSibling=e:n.lastChild=e,e.appendData(r.join("")),Oo(n.ownerDocument,n),e=i}else e=t}return!0}})},isSupported:function(n,e){return this.ownerDocument.implementation.hasFeature(n,e)},lookupPrefix:function(n){for(var e=this;e;){var t=e._nsMap;if(t){for(var r in t)if(xr(t,r)&&t[r]===n)return r}e=e.nodeType==kr?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&xr(t,n))return t[n];e=e.nodeType==kr?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(n){var e=this.lookupPrefix(n);return e==null},compareDocumentPosition:function(n){if(this===n)return 0;var e=n,t=this,r=null,i=null;if(e instanceof zt&&(r=e,e=r.ownerElement),t instanceof zt&&(i=t,t=i.ownerElement,r&&e&&t===e))for(var s=0,o;o=t.attributes[s];s++){if(o===r)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_PRECEDING;if(o===i)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return re.DOCUMENT_POSITION_DISCONNECTED+re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Rl(t.ownerDocument)>Rl(e.ownerDocument)?re.DOCUMENT_POSITION_FOLLOWING:re.DOCUMENT_POSITION_PRECEDING);if(i&&e===t)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=zl(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return re.DOCUMENT_POSITION_FOLLOWING;if(h===e)return re.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return re.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return re.DOCUMENT_POSITION_PRECEDING}return 0}};function Gl(n){return n=="<"&&"<"||n==">"&&">"||n=="&"&&"&"||n=='"'&&"""||"&#"+n.charCodeAt()+";"}Tr(Ie,q);Tr(Ie,q.prototype);Tr(re,q);Tr(re,q.prototype);function Ui(n,e){ge(n,null,{enter:function(t){return e(t)?ge.STOP:!0}})}function ge(n,e,t){for(var r=[{node:n,context:e,phase:ge.ENTER}];r.length>0;){var i=r.pop();if(i.phase===ge.ENTER){var s=t.enter(i.node,i.context);if(s===ge.STOP)return ge.STOP;if(r.push({node:i.node,context:s,phase:ge.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)r.push({node:o,context:s,phase:ge.ENTER}),o=o.previousSibling}else t.exit&&t.exit(i.node,i.context)}}ge.STOP=Symbol("walkDOM.STOP");ge.ENTER=0;ge.EXIT=1;function at(n,e){Se(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||An.XML_APPLICATION,this.type=lp(this.contentType)?"html":"xml"}function vp(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===Qe.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Xl(n,e,t,r){n&&n._inc++;var i=t.namespaceURI;i===Qe.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function Oo(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var i=e.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s,delete r[r.length]}}}function Yl(n,e){if(n!==e.parentNode)throw new k(k.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,r=e.nextSibling;return t?t.nextSibling=r:n.firstChild=r,r?r.previousSibling=t:n.lastChild=t,Oo(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function Ep(n){return n&&(n.nodeType===q.DOCUMENT_NODE||n.nodeType===q.DOCUMENT_FRAGMENT_NODE||n.nodeType===q.ELEMENT_NODE)}function xp(n){return n&&(n.nodeType===q.CDATA_SECTION_NODE||n.nodeType===q.COMMENT_NODE||n.nodeType===q.DOCUMENT_FRAGMENT_NODE||n.nodeType===q.DOCUMENT_TYPE_NODE||n.nodeType===q.ELEMENT_NODE||n.nodeType===q.PROCESSING_INSTRUCTION_NODE||n.nodeType===q.TEXT_NODE)}function Et(n){return n&&n.nodeType===q.DOCUMENT_TYPE_NODE}function ot(n){return n&&n.nodeType===q.ELEMENT_NODE}function Zl(n){return n&&n.nodeType===q.TEXT_NODE}function Ml(n,e){var t=n.childNodes||[];if(Ke(t,ot)||Et(e))return!1;var r=Ke(t,Et);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function Pl(n,e){var t=n.childNodes||[];function r(s){return ot(s)&&s!==e}if(Ke(t,r))return!1;var i=Ke(t,Et);return!(e&&i&&t.indexOf(i)>t.indexOf(e))}function kp(n,e,t){if(!Ep(n))throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new k(k.NOT_FOUND_ERR,"child not in parent");if(!xp(e)||Et(e)&&n.nodeType!==q.DOCUMENT_NODE)throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function Ap(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=i.filter(ot);if(s.length>1||Ke(i,Zl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Ml(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(ot(e)&&!Ml(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(Et(e)){if(Ke(r,Et))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,ot);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function Jl(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=i.filter(ot);if(s.length>1||Ke(i,Zl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Pl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(ot(e)&&!Pl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(Et(e)){if(Ke(r,function(l){return Et(l)&&l!==t}))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,ot);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Vi(n,e,t,r){kp(n,e,t),n.nodeType===q.DOCUMENT_NODE&&(r||Ap)(n,e,t);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===vt){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=t?t.previousSibling:n.lastChild;s.previousSibling=a,o.nextSibling=t,a?a.nextSibling=s:n.firstChild=s,t==null?n.lastChild=o:t.previousSibling=o;do s.parentNode=n;while(s!==o&&(s=s.nextSibling));return Oo(n.ownerDocument||n,n,e),e.nodeType==vt&&(e.firstChild=e.lastChild=null),e}at.prototype={implementation:null,nodeName:"#document",nodeType:Er,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===vt){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return Vi(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===Pe&&(this.documentElement=n),n},removeChild:function(n){var e=Yl(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){Vi(this,n,e,Jl),n.ownerDocument=this,e&&this.removeChild(e),ot(n)&&(this.documentElement=n)},importNode:function(n,e){return Tp(this,n,e)},getElementById:function(n){var e=null;return Ui(this.documentElement,function(t){if(t.nodeType==Pe&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new lt(ke);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),ap(this.contentType)&&(e.namespaceURI=Qe.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new ue;var t=e.attributes=new Ar;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new Dr(ke);return n.ownerDocument=this,n.childNodes=new ue,n},createTextNode:function(n){var e=new Dn(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createComment:function(n){var e=new Hi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new k(k.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Wi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new Yi(ke);return t.ownerDocument=this,t.childNodes=new ue,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new zt(ke);return e.ownerDocument=this,e.childNodes=new ue,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!ne.Name_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new k("document is an html document",xe.NotSupportedError);var e=new Xi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.nodeName=n,e},createElementNS:function(n,e){var t=Co(n,e),r=new lt(ke),i=r.attributes=new Ar;return r.childNodes=new ue,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],i._ownerElement=r,r},createAttributeNS:function(n,e){var t=Co(n,e),r=new zt(ke);return r.ownerDocument=this,r.childNodes=new ue,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};Ne(at,q);function lt(n){Se(n),this._nsMap=Object.create(null)}lt.prototype={nodeType:Pe,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Qe.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(n){return!!this.getAttributeNode(n)},getAttribute:function(n){var e=this.getAttributeNode(n);return e?e.value:null},getAttributeNode:function(n){return this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase()),this.attributes.getNamedItem(n)},setAttribute:function(n,e){this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());var t=this.getAttributeNode(n);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(n),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(n){var e=this.getAttributeNode(n);e&&this.removeAttributeNode(e)},setAttributeNode:function(n){return this.attributes.setNamedItem(n)},setAttributeNodeNS:function(n){return this.attributes.setNamedItemNS(n)},removeAttributeNode:function(n){return this.attributes.removeNamedItem(n.nodeName)},removeAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(n,e){return this.getAttributeNodeNS(n,e)!=null},getAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);return t?t.value:null},setAttributeNS:function(n,e,t){var r=Co(n,e),i=r[2],s=this.getAttributeNodeNS(n,i);s?s.value=s.nodeValue=""+t:(s=this.ownerDocument.createAttributeNS(n,e),s.value=s.nodeValue=""+t,this.setAttributeNode(s))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=Bl(n);return new Je(this,function(t){var r=[];return e.length>0&&Ui(t,function(i){if(i!==t&&i.nodeType===Pe){var s=i.getAttribute("class");if(s){var o=n===s;if(!o){var a=Bl(s);o=e.every(pp(a))}o&&r.push(i)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===Er?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Je(this,function(r){var i=[];return Ui(r,function(s){if(!(s===r||s.nodeType!==Pe))if(n==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Qe.HTML?t:n;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(n,e){return new Je(this,function(t){var r=[];return Ui(t,function(i){i!==t&&i.nodeType===Pe&&(n==="*"||i.namespaceURI===n)&&(e==="*"||i.localName==e)&&r.push(i)}),r})}};at.prototype.getElementsByClassName=lt.prototype.getElementsByClassName;at.prototype.getElementsByTagName=lt.prototype.getElementsByTagName;at.prototype.getElementsByTagNameNS=lt.prototype.getElementsByTagNameNS;Ne(lt,q);function zt(n){Se(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}zt.prototype.nodeType=kr;Ne(zt,q);function xt(n){Se(n)}xt.prototype={data:"",substringData:function(n,e){return this.data.substring(n,n+e)},appendData:function(n){n=this.data+n,this.nodeValue=this.data=n,this.length=n.length},insertData:function(n,e){this.replaceData(n,0,e)},deleteData:function(n,e){this.replaceData(n,e,"")},replaceData:function(n,e,t){var r=this.data.substring(0,n),i=this.data.substring(n+e);t=r+t+i,this.nodeValue=this.data=t,this.length=t.length}};Ne(xt,q);function Dn(n){Se(n)}Dn.prototype={nodeName:"#text",nodeType:Tn,splitText:function(n){var e=this.data,t=e.substring(n);e=e.substring(0,n),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};Ne(Dn,xt);function Hi(n){Se(n)}Hi.prototype={nodeName:"#comment",nodeType:No};Ne(Hi,xt);function Wi(n){Se(n)}Wi.prototype={nodeName:"#cdata-section",nodeType:ql};Ne(Wi,Dn);function Gi(n){Se(n)}Gi.prototype.nodeType=Vl;Ne(Gi,q);function Bo(n){Se(n)}Bo.prototype.nodeType=gp;Ne(Bo,q);function Ro(n){Se(n)}Ro.prototype.nodeType=mp;Ne(Ro,q);function Xi(n){Se(n)}Xi.prototype.nodeType=Ul;Ne(Xi,q);function Dr(n){Se(n)}Dr.prototype.nodeName="#document-fragment";Dr.prototype.nodeType=vt;Ne(Dr,q);function Yi(n){Se(n)}Yi.prototype.nodeType=So;Ne(Yi,xt);function Kl(){}Kl.prototype.serializeToString=function(n,e){return Ql.call(n,e)};q.prototype.toString=Ql;function Ql(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n!=null?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],r=this.nodeType===Er&&this.documentElement||this,i=r.prefix,s=r.namespaceURI;if(s&&i==null){var i=r.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return $o(this,t,o,e),t.join("")}function Ll(n,e,t){var r=n.prefix||"",i=n.namespaceURI;if(!i||r==="xml"&&i===Qe.XML||i===Qe.XMLNS)return!1;for(var s=t.length;s--;){var o=t[s];if(o.prefix===r)return o.namespace!==i}return!0}function qi(n,e,t,r){if(r&&!ne.QName_exact.test(e))throw new k('The attribute name "'+e+'" is not a valid XML QName',xe.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Gl),'"')}function $o(n,e,t,r){t||(t=[]);var i=r.nodeFilter,s=r.requireWellFormed,o=r.splitCDATASections,a=n.nodeType===Er?n:n.ownerDocument,l=a.type==="html";ge(n,{ns:t},{enter:function(u,c){var d=c.ns;if(i)if(u=i(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case Pe:var f=u.attributes,h=f.length,m=u.tagName,p=m;if(!l&&!u.prefix&&u.namespaceURI){for(var b,g=0;g<f.length;g++)if(f.item(g).name==="xmlns"){b=f.item(g).value;break}if(!b)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.prefix===""&&w.namespace===u.namespaceURI){b=w.namespace;break}}if(b!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.namespace===u.namespaceURI){w.prefix&&(p=w.prefix+":"+m);break}}}if(s&&!ne.QName_exact.test(p))throw new k('The element name "'+p+'" is not a valid XML QName',xe.InvalidStateError);e.push("<",p);for(var E=d.slice(),D=0;D<h;D++){var y=f.item(D);y.prefix=="xmlns"?E.push({prefix:y.localName,namespace:y.value}):y.nodeName=="xmlns"&&E.push({prefix:"",namespace:y.value})}for(var D=0;D<h;D++){var y=f.item(D);if(Ll(y,l,E)){var T=y.prefix||"",S=y.namespaceURI;qi(e,T?"xmlns:"+T:"xmlns",S,s),E.push({prefix:T,namespace:S})}var I=i?i(y):y;I&&(typeof I=="string"?e.push(I):qi(e,I.name,I.value,s))}if(m===p&&Ll(u,l,E)){var W=u.prefix||"",S=u.namespaceURI;qi(e,W?"xmlns:"+W:"xmlns",S,s),E.push({prefix:W,namespace:S})}var ee=!u.firstChild;if(ee&&(l||u.namespaceURI===Qe.HTML)&&(ee=cp(m)),ee)return e.push("/>"),null;if(e.push(">"),l&&up(m)){for(var se=u.firstChild;se;)se.data?e.push(se.data):$o(se,e,E.slice(),r),se=se.nextSibling;return e.push("</",p,">"),null}return{ns:E,tag:p};case Er:case vt:if(s&&u.nodeType===Er&&u.documentElement==null)throw new k("The Document has no documentElement",xe.InvalidStateError);return{ns:d};case kr:return qi(e,u.name,u.value,s),null;case Tn:if(s&&ne.InvalidChar.test(u.data))throw new k("The Text node data contains characters outside the XML Char production",xe.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Gl)),null;case ql:if(s&&u.data.indexOf("]]>")!==-1)throw new k('The CDATASection data contains "]]>"',xe.InvalidStateError);return o?e.push(ne.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),ne.CDATA_END):e.push(ne.CDATA_START,u.data,ne.CDATA_END),null;case No:if(s){if(ne.InvalidChar.test(u.data))throw new k("The comment node data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new k('The comment node data contains "--" or ends with "-"',xe.InvalidStateError)}return e.push(ne.COMMENT_START,u.data,ne.COMMENT_END),null;case Vl:var he=u.publicId,Z=u.systemId;if(s){if(!ne.Name_exact.test(u.name))throw new k('The doctype name "'+u.name+'" is not a valid XML Name',xe.InvalidStateError);if(he&&!ne.PubidLiteral_match.test(he))throw new k("DocumentType publicId is not a valid PubidLiteral",xe.InvalidStateError);if(Z&&Z!=="."&&!ne.SystemLiteral_match.test(Z))throw new k("DocumentType systemId is not a valid SystemLiteral",xe.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new k('DocumentType internalSubset contains "]>"',xe.InvalidStateError)}return e.push(ne.DOCTYPE_DECL_START," ",u.name),he?(e.push(" ",ne.PUBLIC," ",he),Z&&Z!=="."&&e.push(" ",Z)):Z&&Z!=="."&&e.push(" ",ne.SYSTEM," ",Z),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case So:if(s){if(!ne.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new k('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',xe.InvalidStateError);if(ne.InvalidChar.test(u.data))throw new k("The ProcessingInstruction data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new k('The ProcessingInstruction data contains "?>"',xe.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Ul:if(s&&!ne.Name_exact.test(u.nodeName))throw new k('The entity reference name "'+u.nodeName+'" is not a valid XML Name',xe.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 Tp(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=n,o.parentNode=null,s===null?r=o:s.appendChild(o);var a=i.nodeType===kr||t;return a?o:null}}),r}function eu(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=new i.constructor(ke);for(var a in i)if(xr(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new ue),o.ownerDocument=n;var u=t;switch(o.nodeType){case Pe:var c=i.attributes,d=o.attributes=new Ar,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(eu(n,c.item(h),!0));break;case kr:u=!0}return s!==null?s.appendChild(o):r=o,u?o:null}}),r}function tu(n,e,t){n[e]=t}function Do(n){for(var e=[],t=n.firstChild;t;)t.nodeType===Pe&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Je.prototype,"length",{get:function(){return zi(this),this.$$length}}),Object.defineProperty(q.prototype,"textContent",{get:function(){if(this.nodeType===Pe||this.nodeType===vt){var n=[];return ge(this,null,{enter:function(e){if(e.nodeType===Pe||e.nodeType===vt)return!0;if(e.nodeType===So||e.nodeType===No)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case Pe:case vt:for(;this.firstChild;)this.removeChild(this.firstChild);(n||String(n))&&this.appendChild(this.ownerDocument.createTextNode(n));break;default:this.data=n,this.value=n,this.nodeValue=n}}}),Object.defineProperty(xt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(n){this._data=n,this.length=typeof n=="string"?n.length:0}}),Object.defineProperty(xt.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(lt.prototype,"children",{get:function(){return new Je(this,Do)}}),Object.defineProperty(at.prototype,"children",{get:function(){return new Je(this,Do)}}),Object.defineProperty(Dr.prototype,"children",{get:function(){return new Je(this,Do)}}),tu=function(n,e,t){n["$$"+e]=t})}catch{}ie._updateLiveList=zi;ie.Attr=zt;ie.CDATASection=Wi;ie.CharacterData=xt;ie.Comment=Hi;ie.Document=at;ie.DocumentFragment=Dr;ie.DocumentType=Gi;ie.DOMImplementation=Wl;ie.Element=lt;ie.Entity=Ro;ie.EntityReference=Xi;ie.LiveNodeList=Je;ie.NamedNodeMap=Ar;ie.Node=q;ie.NodeList=ue;ie.Notation=Bo;ie.Text=Dn;ie.ProcessingInstruction=Yi;ie.walkDOM=ge;ie.XMLSerializer=Kl});var nu=ft(Cn=>{"use strict";var ru=Vt().freeze;Cn.XML_ENTITIES=ru({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Cn.HTML_ENTITIES=ru({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"});Cn.entityMap=Cn.HTML_ENTITIES});var fu=ft(Ji=>{"use strict";var Or=Vt(),M=To(),au=wn(),Dp=Or.isHTMLEscapableRawTextElement,Cp=Or.isHTMLMimeType,Sp=Or.isHTMLRawTextElement,In=Or.hasOwn,iu=Or.NAMESPACE,Np=au.ParseError,Ip=au.DOMException,Cr=0,kt=1,Sr=2,Sn=3,Nr=4,Ir=5,Nn=6,Zi=7;function lu(){}lu.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),$p(e,e=Object.create(null)),Op(n,e,t,r,this.errorHandler),r.endDocument()}};var Po=/&#?\w+;?/g;function Op(n,e,t,r,i){var s=Cp(r.mimeType);n.indexOf(M.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(z){if(z>65535){z-=65536;var Me=55296+(z>>10),wi=56320+(z&1023);return String.fromCharCode(Me,wi)}else return String.fromCharCode(z)}function a(z){var Me=z[z.length-1]===";"?z:z+";";if(!s&&Me!==z)return i.error("EntityRef: expecting ;"),z;var wi=M.Reference.exec(Me);if(!wi||wi[0].length!==Me.length)return i.error("entity not matching Reference production: "+z),z;var yi=Me.slice(1,-1);return In(t,yi)?t[yi]:yi.charAt(0)==="#"?o(parseInt(yi.substring(1).replace("x","0x"))):(i.error("entity not found:"+z),z)}function l(z){if(z>b){var Me=n.substring(b,z).replace(Po,a);f&&h(b),r.characters(Me,0,z-b),b=z}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(z,Me){for(;z>=c&&(Me=d.exec(n));)u=c,c=Me.index+Me[0].length,f.lineNumber++;f.columnNumber=z-u+1}for(var m=[{currentNSMap:e}],p=[],b=0;;){try{var g=n.indexOf("<",b);if(g<0){if(!s&&p.length>0)return i.fatalError("unclosed xml tag(s): "+p.join(", "));if(!n.substring(b).match(/^\s*$/)){var _=r.doc,w=_.createTextNode(n.substring(b));if(_.documentElement)return i.error("Extra content at the end of the document");_.appendChild(w),r.currentElement=w}return}if(g>b){var E=n.substring(b,g);!s&&p.length===0&&(E=E.replace(new RegExp(M.S_OPT.source,"g"),""),E&&i.error("Unexpected content outside root element: '"+E+"'")),l(g)}switch(n.charAt(g+1)){case"/":var P=n.indexOf(">",g+2),D=n.substring(g+2,P>0?P:void 0);if(!D)return i.fatalError("end tag name missing");var y=M.reg("^",M.QName_group,M.S_OPT,"$"),T=P>0&&y.exec(D);if(!T){var S=P>0&&M.reg("^",M.QName_group).exec(D);if(s&&S)i.warning('end tag name contains invalid trailing characters: "'+D+'"'),T=S;else if(S&&new RegExp(y.source,y.flags+"m").test(D))i.error('end tag name is followed by a line break and trailing content: "'+D+'"'),T=S;else return i.fatalError('end tag name contains invalid characters: "'+D+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var I=p[p.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(I!==T[1]){var W=T[1].toLowerCase();if(!s||I.toLowerCase()!==W)return i.fatalError('Opening and ending tag mismatch: "'+I+'" != "'+D+'"')}var ee=m.pop();p.pop();var se=ee.localNSMap;if(r.endElement(ee.uri,ee.localName,I),se)for(var he in se)In(se,he)&&r.endPrefixMapping(he);P++;break;case"?":f&&h(g),P=Pp(n,g,r,i);break;case"!":f&&h(g),P=cu(n,g,r,i,s);break;default:f&&h(g);var Z=new du,ae=m[m.length-1].currentNSMap,P=Bp(n,g,Z,ae,a,i,s),Ba=Z.length;if(Z.closed||(s&&Or.isHTMLVoidElement(Z.tagName)?Z.closed=!0:p.push(Z.tagName)),f&&Ba){for(var wd=su(f,{}),Qs=0;Qs<Ba;Qs++){var Ra=Z[Qs];h(Ra.offset),Ra.locator=su(f,{})}r.locator=wd,ou(Z,r,ae)&&m.push(Z),r.locator=f}else ou(Z,r,ae)&&m.push(Z);s&&!Z.closed?P=Rp(n,P,Z.tagName,a,r):P++}}catch(z){if(z instanceof Np)throw z;if(z instanceof Ip)return i.fatalError("Error constructing the DOM: "+z.name+": "+z.message,z);i.error("element parse error: "+z),P=-1}P>b?b=P:l(Math.max(g,b)+1)}}function su(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function Bp(n,e,t,r,i,s,o){function a(h,m,p){if(In(t.attributeNames,h))return s.fatalError("Attribute "+h+" redefined");if(!o&&m.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,m.replace(/[\t\n\r]/g," ").replace(Po,i),p)}for(var l,u,c=++e,d=Cr;;){var f=n.charAt(c);if(d===Cr&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===kt)l=n.slice(e,c),d=Sn;else if(d===Sr)d=Sn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===Sn||d===kt)if(d===kt&&(s.warning('attribute value must after "="'),l=n.slice(e,c)),e=c+1,c=n.indexOf(f,e),c>0)u=n.slice(e,c),a(l,u,e-1),d=Ir;else throw new Error("attribute value no end '"+f+"' match");else if(d==Nr)u=n.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Ir;else throw new Error('attribute value must after "="');break;case"/":switch(d){case Cr:t.setTagName(n.slice(e,c));case Ir:case Nn:case Zi:d=Zi,t.closed=!0;case Nr:case kt:break;case Sr:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),d==Cr&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case Cr:t.setTagName(n.slice(e,c));case Ir:case Nn:case Zi:break;case Nr:case kt:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Sr:d===Sr&&(u=l),d==Nr?(s.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||s.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case Sn:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case Cr:t.setTagName(n.slice(e,c)),d=Nn;break;case kt:l=n.slice(e,c),d=Sr;break;case Nr:var u=n.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Ir:d=Nn;break}else switch(d){case Sr:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=kt;break;case Ir:s.warning('attribute space is required"'+l+'"!!');case Nn:d=kt,e=c;break;case Sn:d=Nr,e=c;break;case Zi:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function ou(n,e,t){for(var r=n.tagName,i=null,d=n.length;d--;){var s=n[d],o=s.qName,a=s.value,f=o.indexOf(":");if(f>0)var l=s.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),t=Object.create(t)),t[c]=i[c]=a,s.uri=iu.XMLNS,e.startPrefixMapping(c,a))}for(var d=n.length;d--;)s=n[d],s.prefix&&(s.prefix==="xml"&&(s.uri=iu.XML),s.prefix!=="xmlns"&&(s.uri=t[s.prefix]));var f=r.indexOf(":");f>0?(l=n.prefix=r.slice(0,f),u=n.localName=r.slice(f+1)):(l=null,u=n.localName=r);var h=n.uri=t[l||""];if(e.startElement(h,u,r,n),n.closed){if(e.endElement(h,u,r),i)for(l in i)In(i,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=i,!0}function Rp(n,e,t,r,i){var s=Dp(t);if(s||Sp(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(n),l=a?a.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return s&&(u=u.replace(Po,r)),i.characters(u,0,u.length),l}return e+1}function $p(n,e){for(var t in n)In(n,t)&&(e[t]=n[t])}function uu(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function i(c){c=c||1,t+=c}function s(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
|
|
11
|
+
`&&d!==" "&&d!=="\r")return c;c++,i()}return-1}function o(){return n.substring(t)}function a(c){return n.substring(t,t+c.length)===c}function l(c){return n.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=M.reg("^",c),f=d.exec(o());return f?(i(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function Mp(n,e){function t(a,l){var u=M.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 r=n.getSource();if(n.char()==="["){n.skip(1);for(var i=n.getIndex();n.getIndex()<r.length;){if(n.skipBlanks(),n.char()==="]"){var s=r.substring(i,n.getIndex());return n.skip(1),s}var o=null;if(n.char()==="<"&&n.char(1)==="!")switch(n.char(2)){case"E":n.char(3)==="L"?o=n.getMatch(M.elementdecl):n.char(3)==="N"&&(o=n.getMatch(M.EntityDecl));break;case"A":o=n.getMatch(M.AttlistDecl);break;case"N":o=n.getMatch(M.NotationDecl);break;case"-":o=n.getMatch(M.Comment);break}else if(n.char()==="<"&&n.char(1)==="?")o=t(n,e);else if(n.char()==="%")o=n.getMatch(M.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+n.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function cu(n,e,t,r,i){var s=uu(n,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(M.Comment);return o?(t.comment(o,M.COMMENT_START.length,o.length-M.COMMENT_START.length-M.COMMENT_END.length),s.getIndex()):r.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(M.CDSect);return a?!i&&!t.currentElement?r.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(a,M.CDATA_START.length,a.length-M.CDATA_START.length-M.CDATA_END.length),t.endCDATA(),s.getIndex()):r.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return r.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(M.DOCTYPE_DECL_START):!s.substringStartsWith(M.DOCTYPE_DECL_START))return r.fatalError("Expected "+M.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(M.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+M.DOCTYPE_DECL_START+" at position "+s.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=s.getMatch(M.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(M.PUBLIC)||s.substringStartsWith(M.SYSTEM)){var u=M.ExternalID_match.exec(s.substringFromIndex());if(!u)return r.fatalError("doctype external id is not well-formed at position "+s.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),s.skip(u[0].length)}else if(i&&s.substringStartsWithCaseInsensitive(M.SYSTEM)){if(s.skip(M.SYSTEM.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+M.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(M.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+M.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+M.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!M.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=Mp(s,r)),s.skipBlanks(),s.char()!==">"?r.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),s.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Pp(n,e,t,r){var i=n.substring(e).match(M.PI);if(!i)return r.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return r.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!M.XMLDecl.test(n.substring(e)))return r.fatalError("xml declaration is not well-formed")}return t.processingInstruction(i[1],i[2]),e+i[0].length}function du(){this.attributeNames=Object.create(null)}du.prototype={setTagName:function(n){if(!M.QName_exact.test(n))throw new Error("invalid tagName:"+n);this.tagName=n},addValue:function(n,e,t){if(!M.QName_exact.test(n))throw new Error("invalid attribute:"+n);this.attributeNames[n]=this.length,this[this.length++]={qName:n,value:e,offset:t}},length:0,getLocalName:function(n){return this[n].localName},getLocator:function(n){return this[n].locator},getQName:function(n){return this[n].qName},getURI:function(n){return this[n].uri},getValue:function(n){return this[n].value}};Ji.XMLReader=lu;Ji.parseUtils=uu;Ji.parseDoctypeCommentOrCData=cu});var wu=ft(Rr=>{"use strict";var Ht=Vt(),Lp=Mo(),jp=wn(),hu=nu(),Fp=fu(),qp=Lp.DOMImplementation,Up=Ht.hasDefaultHTMLNamespace,Vp=Ht.isHTMLMimeType,zp=Ht.isValidMimeType,gu=Ht.MIME_TYPE,Lo=Ht.NAMESPACE,pu=jp.ParseError,Hp=Fp.XMLReader;function bu(n){return n.replace(/\r[\n\u0085]/g,`
|
|
12
12
|
`).replace(/[\r\u0085\u2028\u2029]/g,`
|
|
13
|
-
`)}function
|
|
14
|
-
@#[line:`+n.lineNumber+",col:"+n.columnNumber+"]"}function
|
|
13
|
+
`)}function _u(n){if(n=n||{},n.locator===void 0&&(n.locator=!0),this.assign=n.assign||Ht.assign,this.domHandler=n.domHandler||Qi,this.onError=n.onError||n.errorHandler,n.errorHandler&&typeof n.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");n.errorHandler&&n.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=n.normalizeLineEndings||bu,this.locator=!!n.locator,this.xmlns=this.assign(Object.create(null),n.xmlns)}_u.prototype.parseFromString=function(n,e){if(!zp(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),r=hu.XML_ENTITIES,i=t[""]||null;Up(e)?(r=hu.HTML_ENTITIES,i=Lo.HTML):e===gu.XML_SVG_IMAGE&&(i=Lo.SVG),t[""]=i,t.xml=t.xml||Lo.XML;var s=new this.domHandler({mimeType:e,defaultNamespace:i,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&s.setDocumentLocator(o);var a=new Hp;a.errorHandler=s,a.domBuilder=s;var l=!Ht.isHTMLMimeType(e);return l&&typeof n!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(n)),t,r),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function Qi(n){var e=n||{};this.mimeType=e.mimeType||gu.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 Br(n,e){e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber}Qi.prototype={startDocument:function(){var n=new qp;this.doc=Vp(this.mimeType)?n.createHTMLDocument(!1):n.createDocument(this.defaultNamespace,"")},startElement:function(n,e,t,r){var i=this.doc,s=i.createElementNS(n,t||e),o=r.length;Ki(this,s),this.currentElement=s,this.locator&&Br(this.locator,s);for(var a=0;a<o;a++){var n=r.getURI(a),l=r.getValue(a),t=r.getQName(a),u=i.createAttributeNS(n,t);this.locator&&Br(r.getLocator(a),u),u.value=u.nodeValue=l,s.setAttributeNode(u)}},endElement:function(n,e,t){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(n,e){},endPrefixMapping:function(n){},processingInstruction:function(n,e){var t=this.doc.createProcessingInstruction(n,e);this.locator&&Br(this.locator,t),Ki(this,t)},ignorableWhitespace:function(n,e,t){},characters:function(n,e,t){if(n=mu.apply(this,arguments),n){if(this.cdata)var r=this.doc.createCDATASection(n);else var r=this.doc.createTextNode(n);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(n)&&this.doc.appendChild(r),this.locator&&Br(this.locator,r)}},skippedEntity:function(n){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(n){n&&(n.lineNumber=0),this.locator=n},comment:function(n,e,t){n=mu.apply(this,arguments);var r=this.doc.createComment(n);this.locator&&Br(this.locator,r),Ki(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(n,e,t,r){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(n,e,t,r);this.locator&&Br(this.locator,s),Ki(this,s),this.doc.doctype=s}},reportError:function(n,e){if(typeof this.onError=="function")try{this.onError(n,e,this)}catch(t){throw new pu("Reporting "+n+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+n+"] "+e,Wp(this.locator))},warning:function(n){this.reportError("warning",n)},error:function(n){this.reportError("error",n)},fatalError:function(n,e){throw this.reportError("fatalError",n),new pu(n,this.locator,e)}};function Wp(n){if(n)return`
|
|
14
|
+
@#[line:`+n.lineNumber+",col:"+n.columnNumber+"]"}function mu(n,e,t){return typeof n=="string"?n.substr(e,t):n.length>=e+t||e?new java.lang.String(n,e,t)+"":n}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(n){Qi.prototype[n]=function(){return null}});function Ki(n,e){n.currentElement?n.currentElement.appendChild(e):n.doc.appendChild(e)}function Gp(n){if(n==="error")throw"onErrorStopParsing"}function Xp(){throw"onWarningStopParsing"}Rr.__DOMHandler=Qi;Rr.DOMParser=_u;Rr.normalizeLineEndings=bu;Rr.onErrorStopParsing=Gp;Rr.onWarningStopParsing=Xp});var jo=ft(U=>{"use strict";var $r=Vt();U.assign=$r.assign;U.hasDefaultHTMLNamespace=$r.hasDefaultHTMLNamespace;U.isHTMLMimeType=$r.isHTMLMimeType;U.isValidMimeType=$r.isValidMimeType;U.MIME_TYPE=$r.MIME_TYPE;U.NAMESPACE=$r.NAMESPACE;var es=wn();U.DOMException=es.DOMException;U.DOMExceptionName=es.DOMExceptionName;U.ExceptionCode=es.ExceptionCode;U.ParseError=es.ParseError;var ce=Mo();U.Attr=ce.Attr;U.CDATASection=ce.CDATASection;U.CharacterData=ce.CharacterData;U.Comment=ce.Comment;U.Document=ce.Document;U.DocumentFragment=ce.DocumentFragment;U.DocumentType=ce.DocumentType;U.DOMImplementation=ce.DOMImplementation;U.Element=ce.Element;U.Entity=ce.Entity;U.EntityReference=ce.EntityReference;U.LiveNodeList=ce.LiveNodeList;U.NamedNodeMap=ce.NamedNodeMap;U.Node=ce.Node;U.NodeList=ce.NodeList;U.Notation=ce.Notation;U.ProcessingInstruction=ce.ProcessingInstruction;U.Text=ce.Text;U.XMLSerializer=ce.XMLSerializer;var ts=wu();U.DOMParser=ts.DOMParser;U.normalizeLineEndings=ts.normalizeLineEndings;U.onErrorStopParsing=ts.onErrorStopParsing;U.onWarningStopParsing=ts.onWarningStopParsing});var vi=new WeakMap,Ma=`
|
|
15
15
|
--gramlot-toolbar-thickness:56px; --gramlot-toolbar-control-size:44px; --gramlot-toolbar-padding:6px;
|
|
16
|
-
`,
|
|
16
|
+
`,Pa=`
|
|
17
17
|
box-sizing:border-box; height:100dvh; min-height:0; overflow:auto;
|
|
18
18
|
padding:env(safe-area-inset-top) max(12px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
|
|
19
19
|
background:var(--gramlot-chrome-background,color-mix(in srgb,var(--gramlot-surface-subtle,Canvas) 88%,var(--gramlot-ink,CanvasText) 12%)); color:var(--gramlot-ink,CanvasText);
|
|
20
|
-
`,
|
|
20
|
+
`,Dd=`
|
|
21
21
|
[data-gramlot-viewport]{--gramlot-toolbar-thickness:42px;--gramlot-toolbar-control-size:36px;--gramlot-toolbar-padding:2px 3px;}
|
|
22
|
-
:root[data-gramlot-touch="on"] [data-gramlot-viewport]{${
|
|
23
|
-
:root[data-gramlot-touch="on"] [data-gramlot-viewport="root"]{${
|
|
22
|
+
:root[data-gramlot-touch="on"] [data-gramlot-viewport]{${Ma}}
|
|
23
|
+
:root[data-gramlot-touch="on"] [data-gramlot-viewport="root"]{${Pa}}
|
|
24
24
|
:root[data-gramlot-touch="on"] [data-gramlot-viewport="root"] > *{max-height:100%;}
|
|
25
25
|
@media(pointer:coarse){
|
|
26
|
-
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport]{${
|
|
27
|
-
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"]{${
|
|
26
|
+
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport]{${Ma}}
|
|
27
|
+
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"]{${Pa}}
|
|
28
28
|
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"] > *{max-height:100%;}
|
|
29
29
|
}
|
|
30
|
-
`,en=class n{static install({document:e,root:t}){return yi.has(t)||yi.set(t,new n(e,t)),yi.get(t)}constructor(e,t){this.document=e,this.root=t,this.releases=[],this.closed=!1,t.setAttribute("data-gramlot-viewport",e.defaultView.parent===e.defaultView?"root":"child");let r=e.querySelector('meta[name="viewport"]');r||(r=e.createElement("meta"),r.name="viewport",r.content="width=device-width,initial-scale=1",e.head.append(r));let i=r.content.split(",").map(s=>s.trim()).filter(s=>!s.startsWith("viewport-fit="));r.content=[...i,"viewport-fit=cover"].join(","),this.style=e.createElement("style"),this.style.textContent=xd,e.head.append(this.style)}subscribeAppearance(e){let t=this.document.defaultView,r=t.matchMedia("(prefers-color-scheme: dark)"),i=()=>{let a=t.getComputedStyle(this.document.documentElement).colorScheme;e({dark:a==="dark"||!["light","dark"].includes(a)&&r.matches})},s=new t.MutationObserver(i);s.observe(this.document.documentElement,{attributes:!0,attributeFilter:["data-theme","style","class"]}),r.addEventListener("change",i),i();let o=()=>{s.disconnect(),r.removeEventListener("change",i)};return this.releases.push(o),o}dispose(){if(!this.closed){this.closed=!0;for(let e of this.releases)e();this.style.remove(),this.root.removeAttribute("data-gramlot-viewport"),yi.delete(this.root)}}};var tn=class{#e=new Map;registerGroup(e,t={}){if(typeof e!="string"||!e||e.includes(":"))throw new TypeError("Extension command namespace must be nonempty and unqualified");if(this.#e.has(e))throw new Error(`Duplicate command namespace: ${e}`);if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!["author","description"].includes(i))||Object.values(t).some(i=>typeof i!="string"))throw new TypeError(`Invalid command group metadata: ${e}`);let r=new Map;return this.#e.set(e,{metadata:{...t},commands:r}),Object.freeze({register(i,s){if(typeof i!="string"||!i||i.includes(":"))throw new TypeError("Invalid command name");if(r.has(i))throw new Error(`Duplicate command: ${e}:${i}`);if(!s||typeof s!="object"||Array.isArray(s)||!Object.hasOwn(s,"label")||!Object.hasOwn(s,"publish")||Object.keys(s).some(o=>!["label","publish","icon","iconSrc","tooltip"].includes(o))||Object.values(s).some(o=>typeof o!="string"))throw new TypeError(`Invalid command definition: ${e}:${i}`);r.set(i,Object.freeze({...s}))}})}get(e){let t=e.indexOf(":");return this.#e.get(e.slice(0,t))?.commands.get(e.slice(t+1))}toDocument(){return{document_format:{name:"gramlot_commands",version:"1.0"},groups:Object.fromEntries([...this.#e].map(([e,{metadata:t,commands:r}])=>[e,{...t,commands:Object.fromEntries(r)}]))}}};var rn=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:i=globalThis.navigator,XMLHttpRequest:s=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=i,this.XMLHttpRequest=s}get supportsCallSync(){return!0}async call(e,t){let r=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(r.status!==200)throw new Error(`rpc failed: HTTP ${r.status}`);return r.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){if(typeof this.closeUrl!="string"||!this.closeUrl.trim())throw new TypeError("HttpTransport.closeUrl must be nonempty text");if(typeof this.navigator?.sendBeacon!="function")throw new TypeError("HttpTransport requires navigator.sendBeacon");let t=new Blob([JSON.stringify({pageId:e})],{type:"application/json"});try{this.navigator.sendBeacon(this.closeUrl,t)}catch(r){if(r.name==="TypeError")throw r}}dispose(){}};var ft=class{createTransport({rpcUrl:e,closeUrl:t,document:r}){let i=r.defaultView;return new rn(e,{closeUrl:t,navigator:i.navigator,XMLHttpRequest:i.XMLHttpRequest})}};function H(n){if(typeof n!="string"||!["^","="].includes(n[0])||n.startsWith("=="))return null;let e=n.indexOf(":");if(e<0)return null;let t=n[e+1]==="=";return{pointer:n.slice(0,e),expression:t,body:n.slice(e+(t?2:1))}}var Ra=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Pt(n,e){let t="",r=!1;for(let i=0;i<n.length;){if(n[i]!=="{"&&n[i]!=="}"){t+=n[i++];continue}let s=n.slice(i).match(Ra);if(!s)throw new SyntaxError("Invalid pointer template placeholder");let o=s[1]??"",a=o.startsWith("?"),l=e(a?o.slice(1):o);l==null||l===""&&!a?r=!0:t+=String(l),i+=s[0].length}return r?null:t}function nn(n){let e=[],t=new Set,r="",i=!0;for(let s=0;s<n.length;){let o=s,a=n[s];if(a==='"'||a==="'"||a==="`"){for(s++;s<n.length;){if(n[s]==="\\"){s+=2;continue}if(n[s++]===a)break}r+=n.slice(o,s),i=!1;continue}if(n.startsWith("//",s)){s=n.indexOf(`
|
|
31
|
-
`,s),s<0&&(s=n.length),r+=n.slice(o,s);continue}if(n.startsWith("/*",s)){let c=n.indexOf("*/",s+2);s=c<0?n.length:c+2,r+=n.slice(o,s);continue}if(a==="/"&&i){let c=!1;for(s++;s<n.length;){let d=n[s++];if(d==="\\"){s++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[s]??"")&&s<n.length;)s++;r+=n.slice(o,s),i=!1;continue}let l=a==="{"?n.slice(s).match(Ra):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");r+=`_pointerValues[${e.length}]`,e.push(c),s+=l[0].length,i=!1;continue}let u=n.slice(s).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],s+=u[0].length,i=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=a,s++,/\s/.test(a)||(i=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:r,slots:e,identifiers:t}}function $a(n,e,t=()=>null){let r=new Map,i=[],s=o=>{if(r.has(o))return r.get(o);if(!n.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(i.includes(o))throw new Error(`Cyclic attribute dependency: ${[...i,o].join(" -> ")}`);i.push(o);try{let a=n.get(o),l=typeof o=="string"?H(a):null,u=e.get(o);if(l){let c=d=>d?s(d):e.get(o);if(l.expression){let d=nn(l.body);u=t(o,a,d,d.slots.map(c))}else u=Pt(l.body,c),e.get(o)==null&&(u=null)}return r.set(o,u),u}finally{i.pop()}};return new Map([...n.keys()].map(o=>[o,s(o)]))}function Ge(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,i=[],s=o=>{let a=H(o);if(!a)return;let l=[];a.expression?l.push(...nn(a.body).slots):Pt(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(i.includes(u))throw new Error(`Cyclic attribute dependency: ${[...i,u].join(" -> ")}`);r.has(u)||(i.push(u),s(t.get(u)),i.pop(),r.add(u))}};return s(e),r}var pr=9e15,gt=1e9,Js="0123456789abcdef",xi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ki="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ks={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-pr,maxE:pr,crypto:!1},ja,it,R=!0,Ti="[DecimalError] ",mt=Ti+"Invalid argument: ",Fa=Ti+"Precision limit exceeded",qa=Ti+"crypto unavailable",Ua="[object Decimal]",ve=Math.floor,le=Math.pow,kd=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ad=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Td=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Va=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,O=7,Dd=9007199254740991,Cd=xi.length-1,Qs=ki.length-1,v={toStringTag:Ua};v.absoluteValue=v.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),N(n)};v.ceil=function(){return N(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(n,e){var t,r=this,i=r.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(mt+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new i(r)};v.comparedTo=v.cmp=function(n){var e,t,r,i,s=this,o=s.d,a=(n=new s.constructor(n)).d,l=s.s,u=n.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(s.e!==n.e)return s.e>n.e^l<0?1:-1;for(r=o.length,i=a.length,e=0,t=r<i?r:i;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return r===i?0:r>i^l<0?1:-1};v.cosine=v.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=Sd(r,Xa(r,t)),r.precision=n,r.rounding=e,N(it==2||it==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};v.cubeRoot=v.cbrt=function(){var n,e,t,r,i,s,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(R=!1,s=c.s*le(c.s*c,1/3),!s||Math.abs(s)==1/0?(t=pe(c.d),n=c.e,(s=(n-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=le(t,1/3),n=ve((n+1)/3)-(n%3==(n<0?-1:2)),s==1/0?t="5e"+n:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(s.toString()),o=(n=d.precision)+3;;)if(a=r,l=a.times(a).times(a),u=l.plus(c),r=Z(u.plus(c).times(a),u.plus(l),o+2,1),pe(a.d).slice(0,o)===(t=pe(r.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(N(a,n+1,0),a.times(a).times(a).eq(c))){r=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(N(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return R=!0,N(r,n,d.rounding,e)};v.decimalPlaces=v.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-ve(this.e/O))*O,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(n){return Z(this,new this.constructor(n))};v.dividedToIntegerBy=v.divToInt=function(n){var e=this,t=e.constructor;return N(Z(e,new t(n),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(n){return this.cmp(n)===0};v.floor=function(){return N(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(n){return this.cmp(n)>0};v.greaterThanOrEqualTo=v.gte=function(n){var e=this.cmp(n);return e==1||e===0};v.hyperbolicCosine=v.cosh=function(){var n,e,t,r,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;t=o.precision,r=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(n=Math.ceil(i/3),e=(1/Ci(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),s=mr(o,1,s.times(e),new o(1),!0);for(var l,u=n,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return N(s,o.precision=t,o.rounding=r,!0)};v.hyperbolicSine=v.sinh=function(){var n,e,t,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,t=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=mr(s,2,i,i,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,i=i.times(1/Ci(5,n)),i=mr(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);n--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=t,N(i,e,t,!0)};v.hyperbolicTangent=v.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,Z(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};v.inverseCosine=v.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return t!==-1?t===0?n.isNeg()?Xe(e,r,i):new e(0):new e(NaN):n.isZero()?Xe(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=i,n.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,R=!1,t=t.times(t).minus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};v.inverseHyperbolicSine=v.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,R=!1,t=t.times(t).plus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var n,e,t,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=s.precision,e=s.rounding,r=i.sd(),Math.max(r,n)<2*-i.e-1?N(new s(i),n,e,!0):(s.precision=t=r-i.e,i=Z(i.plus(1),new s(1).minus(i),t+n,1),s.precision=n+4,s.rounding=1,i=i.ln(),s.precision=n,s.rounding=e,i.times(.5))):new s(NaN)};v.inverseSine=v.asin=function(){var n,e,t,r,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),t=s.precision,r=s.rounding,e!==-1?e===0?(n=Xe(s,t+4,r).times(.5),n.s=i.s,n):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,i.times(2)))};v.inverseTangent=v.atan=function(){var n,e,t,r,i,s,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<=Qs)return o=Xe(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=Qs)return o=Xe(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/O+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(R=!1,e=Math.ceil(a/O),r=1,l=u.times(u),o=new c(u),i=u;n!==-1;)if(i=i.times(l),s=o.minus(i.div(r+=2)),i=i.times(l),o=s.plus(i.div(r+=2)),o.d[e]!==void 0)for(n=e;o.d[n]===s.d[n]&&n--;);return t&&(o=o.times(2<<t-1)),R=!0,N(o,c.precision=d,c.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&ve(this.e/O)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(n){return this.cmp(n)<0};v.lessThanOrEqualTo=v.lte=function(n){return this.cmp(n)<1};v.logarithm=v.log=function(n){var e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.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)s=!0;else{for(i=t[0];i%10===0;)i/=10;s=i!==1}if(R=!1,a=d+h,o=pt(u,a),r=e?Ai(c,a+10):pt(n,a),l=Z(o,r,a,1),sn(l.d,i=d,f))do if(a+=10,o=pt(u,a),r=e?Ai(c,a+10):pt(n,a),l=Z(o,r,a,1),!s){+pe(l.d).slice(i+1,i+15)+1==1e14&&(l=N(l,d+1,0));break}while(sn(l.d,i+=10,f));return R=!0,N(l,d,f)};v.minus=v.sub=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.constructor;if(n=new m(n),!h.d||!n.d)return!h.s||!n.s?n=new m(NaN):h.d?n.s=-n.s:n=new m(n.d||h.s!==n.s?h:NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(u=h.d,f=n.d,a=m.precision,l=m.rounding,!u[0]||!f[0]){if(f[0])n.s=-n.s;else if(u[0])n=new m(h);else return new m(l===3?-0:0);return R?N(n,a,l):n}if(t=ve(n.e/O),c=ve(h.e/O),u=u.slice(),s=c-t,s){for(d=s<0,d?(e=u,s=-s,o=f.length):(e=f,t=c,o=u.length),r=Math.max(Math.ceil(a/O),o)+2,s>r&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for(r=u.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}s=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),o=u.length,r=f.length-o;r>0;--r)u[o++]=0;for(r=f.length;r>s;){if(u[--r]<f[r]){for(i=r;i&&u[--i]===0;)u[i]=qe-1;--u[i],u[r]+=qe}u[r]-=f[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=Di(u,t),R?N(n,a,l):n):new m(l===3?-0:0)};v.modulo=v.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?N(new r(t),r.precision,r.rounding):(R=!1,r.modulo==9?(e=Z(t,n.abs(),0,3,1),e.s*=n.s):e=Z(t,n,0,r.modulo,1),e=e.times(n),R=!0,t.minus(e))};v.naturalExponential=v.exp=function(){return eo(this)};v.naturalLogarithm=v.ln=function(){return pt(this)};v.negated=v.neg=function(){var n=new this.constructor(this);return n.s=-n.s,N(n)};v.plus=v.add=function(n){var e,t,r,i,s,o,a,l,u,c,d=this,f=d.constructor;if(n=new f(n),!d.d||!n.d)return!d.s||!n.s?n=new f(NaN):d.d||(n=new f(n.d||d.s===n.s?d:NaN)),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(u=d.d,c=n.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),R?N(n,a,l):n;if(s=ve(d.e/O),r=ve(n.e/O),u=u.slice(),i=s-r,i){for(i<0?(t=u,i=-i,o=c.length):(t=c,r=s,o=u.length),s=Math.ceil(a/O),o=s>o?s+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,t=c,c=u,u=t),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/qe|0,u[i]%=qe;for(e&&(u.unshift(e),++r),o=u.length;u[--o]==0;)u.pop();return n.d=u,n.e=Di(u,r),R?N(n,a,l):n};v.precision=v.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(mt+n);return t.d?(e=za(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};v.round=function(){var n=this,e=n.constructor;return N(new e(n),n.e+1,e.rounding)};v.sine=v.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=Id(r,Xa(r,t)),r.precision=n,r.rounding=e,N(it>2?t.neg():t,n,e,!0)):new r(NaN)};v.squareRoot=v.sqrt=function(){var n,e,t,r,i,s,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(R=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=pe(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ve((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),r=new c(e)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(s=r,r=s.plus(Z(o,s,t+2,1)).times(.5),pe(s.d).slice(0,t)===(e=pe(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(N(s,l+1,0),s.times(s).eq(o))){r=s;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(N(r,l+1,1),n=!r.times(r).eq(o));break}return R=!0,N(r,l,c.rounding,n)};v.tangent=v.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,t=t.sin(),t.s=1,t=Z(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,N(it==2||it==4?t.neg():t,n,e,!0)):new r(NaN)};v.times=v.mul=function(n){var e,t,r,i,s,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(n=new d(n)).d;if(n.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!n.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?n.s/0:n.s*0);for(t=ve(c.e/O)+ve(n.e/O),l=f.length,u=h.length,l<u&&(s=f,f=h,h=s,o=l,l=u,u=o),s=[],o=l+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)a=s[i]+h[r]*f[i-r-1]+e,s[i--]=a%qe|0,e=a/qe|0;s[i]=(s[i]+e)%qe|0}for(;!s[--o];)s.pop();return e?++t:s.shift(),n.d=s,n.e=Di(s,t),R?N(n,d.precision,d.rounding):n};v.toBinary=function(n,e){return to(this,2,n,e)};v.toDecimalPlaces=v.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(Ce(n,0,gt),e===void 0?e=r.rounding:Ce(e,0,8),N(t,n+t.e+1,e))};v.toExponential=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,!0):(Ce(n,0,gt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n+1,e),t=Ye(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toFixed=function(n,e){var t,r,i=this,s=i.constructor;return n===void 0?t=Ye(i):(Ce(n,0,gt),e===void 0?e=s.rounding:Ce(e,0,8),r=N(new s(i),n+i.e+1,e),t=Ye(r,!1,n+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.d,p=h.constructor;if(!m)return new p(h);if(u=t=new p(1),r=l=new p(0),e=new p(r),s=e.e=za(m)-h.e-1,o=s%O,e.d[0]=le(10,o<0?O+o:o),n==null)n=s>0?e:u;else{if(a=new p(n),!a.isInt()||a.lt(u))throw Error(mt+a);n=a.gt(e)?s>0?e:u:a}for(R=!1,a=new p(pe(m)),c=p.precision,p.precision=s=m.length*O*2;d=Z(a,e,0,1,1),i=t.plus(d.times(r)),i.cmp(n)!=1;)t=r,r=i,i=u,u=l.plus(d.times(i)),l=i,i=e,e=a.minus(d.times(i)),a=i;return i=Z(n.minus(t),r,0,1,1),l=l.plus(i.times(u)),t=t.plus(i.times(r)),l.s=u.s=h.s,f=Z(u,r,s,1).minus(h).abs().cmp(Z(l,t,s,1).minus(h).abs())<1?[u,r]:[l,t],p.precision=c,R=!0,f};v.toHexadecimal=v.toHex=function(n,e){return to(this,16,n,e)};v.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),n==null){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),e===void 0?e=r.rounding:Ce(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(R=!1,t=Z(t,n,0,e,1).times(n),R=!0,N(t)):(n.s=t.s,t=n),t};v.toNumber=function(){return+this};v.toOctal=function(n,e){return to(this,8,n,e)};v.toPower=v.pow=function(n){var e,t,r,i,s,o,a=this,l=a.constructor,u=+(n=new l(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new l(le(+a,u));if(a=new l(a),a.eq(1))return a;if(r=l.precision,s=l.rounding,n.eq(1))return N(a,r,s);if(e=ve(n.e/O),e>=n.d.length-1&&(t=u<0?-u:u)<=Dd)return i=Ha(l,a,t,r),n.s<0?new l(1).div(i):N(i,r,s);if(o=a.s,o<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=le(+a,u),e=t==0||!isFinite(t)?ve(u*(Math.log("0."+pe(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):(R=!1,l.rounding=a.s=1,t=Math.min(12,(e+"").length),i=eo(n.times(pt(a,r+t)),r),i.d&&(i=N(i,r+5,1),sn(i.d,r,s)&&(e=r+10,i=N(eo(n.times(pt(a,e+t)),e),e+5,1),+pe(i.d).slice(r+1,r+15)+1==1e14&&(i=N(i,r+1,0)))),i.s=o,R=!0,l.rounding=s,N(i,r,s))};v.toPrecision=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ce(n,1,gt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n,e),t=Ye(r,n<=r.e||r.e<=i.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(Ce(n,1,gt),e===void 0?e=r.rounding:Ce(e,0,8)),N(new r(t),n,e)};v.toString=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return N(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function pe(n){var e,t,r,i=n.length-1,s="",o=n[0];if(i>0){for(s+=o,e=1;e<i;e++)r=n[e]+"",t=O-r.length,t&&(s+=ht(t)),s+=r;o=n[e],r=o+"",t=O-r.length,t&&(s+=ht(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Ce(n,e,t){if(n!==~~n||n<e||n>t)throw Error(mt+n)}function sn(n,e,t,r){var i,s,o,a;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=O,i=0):(i=Math.ceil((e+1)/O),e%=O),s=le(10,O-e),a=n[i]%s|0,r==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==s||t>3&&a+1==s/2)&&(n[i+1]/s/100|0)==le(10,e-2)-1||(a==s/2||a==0)&&(n[i+1]/s/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(r||t<4)&&a==9999||!r&&t>3&&a==4999):o=((r||t<4)&&a+1==s||!r&&t>3&&a+1==s/2)&&(n[i+1]/s/1e3|0)==le(10,e-3)-1,o}function vi(n,e,t){for(var r,i=[0],s,o=0,a=n.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=Js.indexOf(n.charAt(o++)),r=0;r<i.length;r++)i[r]>t-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function Sd(n,e){var t,r,i;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),i=(1/Ci(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),n.precision+=t,e=mr(n,1,e.times(i),new n(1));for(var s=t;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}var Z=(function(){function n(r,i,s){var o,a=0,l=r.length;for(r=r.slice();l--;)o=r[l]*i+a,r[l]=o%s|0,a=o/s|0;return a&&r.unshift(a),r}function e(r,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(r[a]!=i[a]){l=r[a]>i[a]?1:-1;break}return l}function t(r,i,s,o){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,a,l){var u,c,d,f,h,m,p,b,g,_,w,E,D,y,T,S,I,W,ee,se,he=r.constructor,Y=r.s==i.s?1:-1,ae=r.d,L=i.d;if(!ae||!ae[0]||!L||!L[0])return new he(!r.s||!i.s||(ae?L&&ae[0]==L[0]:!L)?NaN:ae&&ae[0]==0||!L?Y*0:Y/0);for(l?(h=1,c=r.e-i.e):(l=qe,h=O,c=ve(r.e/h)-ve(i.e/h)),ee=L.length,I=ae.length,g=new he(Y),_=g.d=[],d=0;L[d]==(ae[d]||0);d++);if(L[d]>(ae[d]||0)&&c--,s==null?(y=s=he.precision,o=he.rounding):a?y=s+(r.e-i.e)+1:y=s,y<0)_.push(1),m=!0;else{if(y=y/h+2|0,d=0,ee==1){for(f=0,L=L[0],y++;(d<I||f)&&y--;d++)T=f*l+(ae[d]||0),_[d]=T/L|0,f=T%L|0;m=f||d<I}else{for(f=l/(L[0]+1)|0,f>1&&(L=n(L,f,l),ae=n(ae,f,l),ee=L.length,I=ae.length),S=ee,w=ae.slice(0,ee),E=w.length;E<ee;)w[E++]=0;se=L.slice(),se.unshift(0),W=L[0],L[1]>=l/2&&++W;do f=0,u=e(L,w,ee,E),u<0?(D=w[0],ee!=E&&(D=D*l+(w[1]||0)),f=D/W|0,f>1?(f>=l&&(f=l-1),p=n(L,f,l),b=p.length,E=w.length,u=e(p,w,b,E),u==1&&(f--,t(p,ee<b?se:L,b,l))):(f==0&&(u=f=1),p=L.slice()),b=p.length,b<E&&p.unshift(0),t(w,p,E,l),u==-1&&(E=w.length,u=e(L,w,ee,E),u<1&&(f++,t(w,ee<E?se:L,E,l))),E=w.length):u===0&&(f++,w=[0]),_[d++]=f,u&&w[0]?w[E++]=ae[S]||0:(w=[ae[S]],E=1);while((S++<I||w[0]!==void 0)&&y--);m=w[0]!==void 0}_[0]||_.shift()}if(h==1)g.e=c,ja=m;else{for(d=1,f=_[0];f>=10;f/=10)d++;g.e=d+c*h-1,N(g,a?s+g.e+1:s,o,m)}return g}})();function N(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(i=1,a=d[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=O,o=e,c=d[f=0],l=c/le(10,i-o-1)%10|0;else if(f=Math.ceil((s+1)/O),a=d.length,f>=a)if(r){for(;a++<=f;)d.push(0);c=l=0,i=1,s%=O,o=s-O+1}else break e;else{for(c=a=d[f],i=1;a>=10;a/=10)i++;s%=O,o=s-O+i,l=o<0?0:c/le(10,i-o-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(o<0?c:c%le(10,i-o-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(s>0?o>0?c/le(10,i-o):0:d[f-1])%10&1||t==(n.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=n.e+1,d[0]=le(10,(O-e%O)%O),n.e=-e||0):d[0]=n.e=0,n;if(s==0?(d.length=f,a=1,f--):(d.length=f+1,a=le(10,O-s),d[f]=o>0?(c/le(10,i-o)%le(10,o)|0)*a:0),u)for(;;)if(f==0){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(n.e++,d[0]==qe&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=qe)break;d[f--]=0,a=1}for(s=d.length;d[--s]===0;)d.pop()}return R&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function Ye(n,e,t){if(!n.isFinite())return Ga(n);var r,i=n.e,s=pe(n.d),o=s.length;return e?(t&&(r=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+ht(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):i<0?(s="0."+ht(-i-1)+s,t&&(r=t-o)>0&&(s+=ht(r))):i>=o?(s+=ht(i+1-o),t&&(r=t-i-1)>0&&(s=s+"."+ht(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-o)>0&&(i+1===o&&(s+="."),s+=ht(r))),s}function Di(n,e){var t=n[0];for(e*=O;t>=10;t/=10)e++;return e}function Ai(n,e,t){if(e>Cd)throw R=!0,t&&(n.precision=t),Error(Fa);return N(new n(xi),e,1,!0)}function Xe(n,e,t){if(e>Qs)throw Error(Fa);return N(new n(ki),e,t,!0)}function za(n){var e=n.length-1,t=e*O+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function ht(n){for(var e="";n--;)e+="0";return e}function Ha(n,e,t,r){var i,s=new n(1),o=Math.ceil(r/O+4);for(R=!1;;){if(t%2&&(s=s.times(e),La(s.d,o)&&(i=!0)),t=ve(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}e=e.times(e),La(e.d,o)}return R=!0,s}function Ma(n){return n.d[n.d.length-1]&1}function Wa(n,e,t){for(var r,i,s=new n(e[0]),o=0;++o<e.length;){if(i=new n(e[o]),!i.s){s=i;break}r=s.cmp(i),(r===t||r===0&&s.s===t)&&(s=i)}return s}function eo(n,e){var t,r,i,s,o,a,l,u=0,c=0,d=0,f=n.constructor,h=f.rounding,m=f.precision;if(!n.d||!n.d[0]||n.e>17)return new f(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(R=!1,l=m):l=e,a=new f(.03125);n.e>-2;)n=n.times(a),d+=5;for(r=Math.log(le(2,d))/Math.LN10*2+5|0,l+=r,t=s=o=new f(1),f.precision=l;;){if(s=N(s.times(n),l,1),t=t.times(++c),a=o.plus(Z(s,t,l,1)),pe(a.d).slice(0,l)===pe(o.d).slice(0,l)){for(i=d;i--;)o=N(o.times(o),l,1);if(e==null)if(u<3&&sn(o.d,l-r,h,u))f.precision=l+=10,t=s=a=new f(1),c=0,u++;else return N(o,f.precision=m,h,R=!0);else return f.precision=m,o}o=a}}function pt(n,e){var t,r,i,s,o,a,l,u,c,d,f,h=1,m=10,p=n,b=p.d,g=p.constructor,_=g.rounding,w=g.precision;if(p.s<0||!b||!b[0]||!p.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:p.s!=1?NaN:b?0:p);if(e==null?(R=!1,c=w):c=e,g.precision=c+=m,t=pe(b),r=t.charAt(0),Math.abs(s=p.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)p=p.times(n),t=pe(p.d),r=t.charAt(0),h++;s=p.e,r>1?(p=new g("0."+t),s++):p=new g(r+"."+t.slice(1))}else return u=Ai(g,c+2,w).times(s+""),p=pt(new g(r+"."+t.slice(1)),c-m).plus(u),g.precision=w,e==null?N(p,w,_,R=!0):p;for(d=p,l=o=p=Z(p.minus(1),p.plus(1),c,1),f=N(p.times(p),c,1),i=3;;){if(o=N(o.times(f),c,1),u=l.plus(Z(o,new g(i),c,1)),pe(u.d).slice(0,c)===pe(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(Ai(g,c+2,w).times(s+""))),l=Z(l,new g(h),c,1),e==null)if(sn(l.d,c-m,_,a))g.precision=c+=m,u=o=p=Z(d.minus(1),d.plus(1),c,1),f=N(p.times(p),c,1),i=a=1;else return N(l,g.precision=w,_,R=!0);else return g.precision=w,l;l=u,i+=2}}function Ga(n){return String(n.s*n.s/0)}function Ei(n,e){var t,r,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%O,t<0&&(r+=O),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=O;r<i;)n.d.push(+e.slice(r,r+=O));e=e.slice(r),r=O-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),R&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Nd(n,e){var t,r,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Va.test(e))return Ei(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Ad.test(e))t=16,e=e.toLowerCase();else if(kd.test(e))t=2;else if(Td.test(e))t=8;else throw Error(mt+e);for(s=e.search(/p/i),s>0?(l=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),s=e.indexOf("."),o=s>=0,r=n.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Ha(r,new r(t),s,s*2)),u=vi(e,t,qe),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new r(n.s*0):(n.e=Di(u,c),n.d=u,R=!1,o&&(n=Z(n,i,a*4)),l&&(n=n.times(Math.abs(l)<54?le(2,l):on.pow(2,l))),R=!0,n)}function Id(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:mr(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/Ci(5,t)),e=mr(n,2,e,e);for(var i,s=new n(5),o=new n(16),a=new n(20);t--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function mr(n,e,t,r,i){var s,o,a,l,u=1,c=n.precision,d=Math.ceil(c/O);for(R=!1,l=t.times(t),a=new n(r);;){if(o=Z(a.times(l),new n(e++*e++),c,1),a=i?r.plus(o):r.minus(o),r=Z(o.times(l),new n(e++*e++),c,1),o=a.plus(r),o.d[d]!==void 0){for(s=d;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=r,r=o,o=s,u++}return R=!0,o.d.length=d+1,o}function Ci(n,e){for(var t=n;--e;)t*=n;return t}function Xa(n,e){var t,r=e.s<0,i=Xe(n,n.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return it=r?4:1,e;if(t=e.divToInt(i),t.isZero())it=r?3:2;else{if(e=e.minus(t.times(i)),e.lte(s))return it=Ma(t)?r?2:3:r?4:1,e;it=Ma(t)?r?1:4:r?3:2}return e.minus(i).abs()}function to(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor,m=t!==void 0;if(m?(Ce(t,1,gt),r===void 0?r=h.rounding:Ce(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Ga(n);else{for(c=Ye(n),o=c.indexOf("."),m?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=vi(Ye(f),10,i),f.e=f.d.length),d=vi(c,10,i),s=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=m?"0p+0":"0";else{if(o<0?s--:(n=new h(n),n.d=d,n.e=s,n=Z(n,f,t,r,0,i),d=n.d,s=n.e,u=ja),o=d[t],a=i/2,u=u||d[t+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(n.s<0?3:2)):o>a||o===a&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>i-1;)d[t]=0,t||(++s,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=Js.charAt(d[o]);if(m){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(d=vi(c,i,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=Js.charAt(d[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)c="0"+c;c="0."+c}else if(++s>l)for(s-=l;s--;)c+="0";else s<l&&(c=c.slice(0,s)+"."+c.slice(s))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function La(n,e){if(n.length>e)return n.length=e,!0}function Od(n){return new this(n).abs()}function Bd(n){return new this(n).acos()}function Rd(n){return new this(n).acosh()}function $d(n,e){return new this(n).plus(e)}function Md(n){return new this(n).asin()}function Ld(n){return new this(n).asinh()}function Pd(n){return new this(n).atan()}function jd(n){return new this(n).atanh()}function Fd(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,s=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=Xe(this,s,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?Xe(this,r,i):new this(0),t.s=n.s):!n.d||e.isZero()?(t=Xe(this,s,1).times(.5),t.s=n.s):e.s<0?(this.precision=s,this.rounding=1,t=this.atan(Z(n,e,s,1)),e=Xe(this,s,1),this.precision=r,this.rounding=i,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(Z(n,e,s,1)),t}function qd(n){return new this(n).cbrt()}function Ud(n){return N(n=new this(n),n.e+1,2)}function Vd(n,e,t){return new this(n).clamp(e,t)}function zd(n){if(!n||typeof n!="object")throw Error(Ti+"Object expected");var e,t,r,i=n.defaults===!0,s=["precision",1,gt,"rounding",0,8,"toExpNeg",-pr,0,"toExpPos",0,pr,"maxE",0,pr,"minE",-pr,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(t=s[e],i&&(this[t]=Ks[t]),(r=n[t])!==void 0)if(ve(r)===r&&r>=s[e+1]&&r<=s[e+2])this[t]=r;else throw Error(mt+t+": "+r);if(t="crypto",i&&(this[t]=Ks[t]),(r=n[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(qa);else this[t]=!1;else throw Error(mt+t+": "+r);return this}function Hd(n){return new this(n).cos()}function Wd(n){return new this(n).cosh()}function Ya(n){var e,t,r;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Pa(s)){u.s=s.s,R?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;R?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return Ei(u,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),Va.test(s)?Ei(u,s):Nd(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,Ei(u,s.toString());throw Error(mt+s)}if(i.prototype=v,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=zd,i.clone=Ya,i.isDecimal=Pa,i.abs=Od,i.acos=Bd,i.acosh=Rd,i.add=$d,i.asin=Md,i.asinh=Ld,i.atan=Pd,i.atanh=jd,i.atan2=Fd,i.cbrt=qd,i.ceil=Ud,i.clamp=Vd,i.cos=Hd,i.cosh=Wd,i.div=Gd,i.exp=Xd,i.floor=Yd,i.hypot=Zd,i.ln=Jd,i.log=Kd,i.log10=ef,i.log2=Qd,i.max=tf,i.min=rf,i.mod=nf,i.mul=sf,i.pow=of,i.random=af,i.round=lf,i.sign=uf,i.sin=cf,i.sinh=df,i.sqrt=ff,i.sub=hf,i.sum=pf,i.tan=mf,i.tanh=gf,i.trunc=bf,n===void 0&&(n={}),n&&n.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)n.hasOwnProperty(t=r[e++])||(n[t]=this[t]);return i.config(n),i}function Gd(n,e){return new this(n).div(e)}function Xd(n){return new this(n).exp()}function Yd(n){return N(n=new this(n),n.e+1,3)}function Zd(){var n,e,t=new this(0);for(R=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return R=!0,new this(1/0);t=e}return R=!0,t.sqrt()}function Pa(n){return n instanceof on||n&&n.toStringTag===Ua||!1}function Jd(n){return new this(n).ln()}function Kd(n,e){return new this(n).log(e)}function Qd(n){return new this(n).log(2)}function ef(n){return new this(n).log(10)}function tf(){return Wa(this,arguments,-1)}function rf(){return Wa(this,arguments,1)}function nf(n,e){return new this(n).mod(e)}function sf(n,e){return new this(n).mul(e)}function of(n,e){return new this(n).pow(e)}function af(n){var e,t,r,i,s=0,o=new this(1),a=[];if(n===void 0?n=this.precision:Ce(n,1,gt),r=Math.ceil(n/O),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));s<r;)i=e[s],i>=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);s<r;)i=e[s]+(e[s+1]<<8)+(e[s+2]<<16)+((e[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,s):(a.push(i%1e7),s+=4);s=r/4}else throw Error(qa);else for(;s<r;)a[s++]=Math.random()*1e7|0;for(r=a[--s],n%=O,r&&n&&(i=le(10,O-n),a[s]=(r/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=O)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<O&&(t-=O-r)}return o.e=t,o.d=a,o}function lf(n){return N(n=new this(n),n.e+1,this.rounding)}function uf(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function cf(n){return new this(n).sin()}function df(n){return new this(n).sinh()}function ff(n){return new this(n).sqrt()}function hf(n,e){return new this(n).sub(e)}function pf(){var n=0,e=arguments,t=new this(e[n]);for(R=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return R=!0,N(t,this.precision,this.rounding)}function mf(n){return new this(n).tan()}function gf(n){return new this(n).tanh()}function bf(n){return N(n=new this(n),n.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var on=v.constructor=Ya(Ks);xi=new on(xi);ki=new on(ki);var Za=on;var _f=20,wf=1,jt=1e6,Ja=1e6,yf=-7,vf=21,Ef=!1,an="[big.js] ",Ft=an+"Invalid ",Si=Ft+"decimal places",xf=Ft+"rounding mode",Ka=an+"Division by zero",G={},Ze=void 0,kf=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Qa(){function n(e){var t=this;if(!(t instanceof n))return e===Ze?Qa():new n(e);if(e instanceof n)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(n.strict===!0&&typeof e!="bigint")throw TypeError(Ft+"value");e=e===0&&1/e<0?"-0":String(e)}Af(t,e)}t.constructor=n}return n.prototype=G,n.DP=_f,n.RM=wf,n.NE=yf,n.PE=vf,n.strict=Ef,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function Af(n,e){var t,r,i;if(!kf.test(e))throw Error(Ft+"number");for(n.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)n.c=[n.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=i;)n.c[t++]=+e.charAt(r++)}return n}function qt(n,e,t,r){var i=n.c;if(t===Ze&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(xf);if(e<1)r=t===3&&(r||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(r||i[1]!==Ze))),i.length=1,r?(n.e=n.e-e+1,i[0]=1):i[0]=n.e=0;else if(e<i.length){if(r=t===1&&i[e]>=5||t===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==Ze||i[e-1]&1))||t===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++n.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return n}function Ut(n,e,t){var r=n.e,i=n.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>s)for(r-=s;r--;)i+="0";else r<s&&(i=i.slice(0,r)+"."+i.slice(r));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return n.s<0&&t?"-"+i:i}G.abs=function(){var n=new this.constructor(this);return n.s=1,n};G.cmp=function(n){var e,t=this,r=t.c,i=(n=new t.constructor(n)).c,s=t.s,o=n.s,a=t.e,l=n.e;if(!r[0]||!i[0])return r[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=i.length)?a:l,s=-1;++s<o;)if(r[s]!=i[s])return r[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};G.div=function(n){var e=this,t=e.constructor,r=e.c,i=(n=new t(n)).c,s=e.s==n.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>jt)throw Error(Si);if(!i[0])throw Error(Ka);if(!r[0])return n.s=s,n.c=[n.e=0],n;var a,l,u,c,d,f=i.slice(),h=a=i.length,m=r.length,p=r.slice(0,a),b=p.length,g=n,_=g.c=[],w=0,E=o+(g.e=e.e-n.e)+1;for(g.s=s,s=E<0?0:E,f.unshift(0);b++<a;)p.push(0);do{for(u=0;u<10;u++){if(a!=(b=p.length))c=a>b?1:-1;else for(d=-1,c=0;++d<a;)if(i[d]!=p[d]){c=i[d]>p[d]?1:-1;break}if(c<0){for(l=b==a?i:f;b;){if(p[--b]<l[b]){for(d=b;d&&!p[--d];)p[d]=9;--p[d],p[b]+=10}p[b]-=l[b]}for(;!p[0];)p.shift()}else break}_[w++]=c?u:++u,p[0]&&c?p[b]=r[h]||0:p=[r[h]]}while((h++<m||p[0]!==Ze)&&s--);return!_[0]&&w!=1&&(_.shift(),g.e--,E--),w>E&&qt(g,E,t.RM,p[0]!==Ze),g};G.eq=function(n){return this.cmp(n)===0};G.gt=function(n){return this.cmp(n)>0};G.gte=function(n){return this.cmp(n)>-1};G.lt=function(n){return this.cmp(n)<0};G.lte=function(n){return this.cmp(n)<1};G.minus=G.sub=function(n){var e,t,r,i,s=this,o=s.constructor,a=s.s,l=(n=new o(n)).s;if(a!=l)return n.s=-l,s.plus(n);var u=s.c.slice(),c=s.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new o(s):n.s=1,n;if(a=c-f){for((i=a<0)?(a=-a,r=u):(f=c,r=d),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(t=((i=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){i=u[l]<d[l];break}if(i&&(r=u,u=d,d=r,n.s=-n.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]||(n.s=1,u=[f=0]),n.c=u,n.e=f,n};G.mod=function(n){var e,t=this,r=t.constructor,i=t.s,s=(n=new r(n)).s;if(!n.c[0])throw Error(Ka);return t.s=n.s=1,e=n.cmp(t)==1,t.s=i,n.s=s,e?new r(t):(i=r.DP,s=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=i,r.RM=s,this.minus(t.times(n)))};G.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};G.plus=G.add=function(n){var e,t,r,i=this,s=i.constructor;if(n=new s(n),i.s!=n.s)return n.s=-n.s,i.minus(n);var o=i.e,a=i.c,l=n.e,u=n.c;if(!a[0]||!u[0])return u[0]||(a[0]?n=new s(i):n.s=i.s),n;if(a=a.slice(),e=o-l){for(e>0?(l=o,r=u):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-u.length<0&&(r=u,u=a,a=r),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 n.c=a,n.e=l,n};G.pow=function(n){var e=this,t=new e.constructor("1"),r=t,i=n<0;if(n!==~~n||n<-Ja||n>Ja)throw Error(Ft+"exponent");for(i&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return i?t.div(r):r};G.prec=function(n,e){if(n!==~~n||n<1||n>jt)throw Error(Ft+"precision");return qt(new this.constructor(this),n,e)};G.round=function(n,e){if(n===Ze)n=0;else if(n!==~~n||n<-jt||n>jt)throw Error(Si);return qt(new this.constructor(this),n+this.e+1,e)};G.sqrt=function(){var n,e,t,r=this,i=r.constructor,s=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(s<0)throw Error(an+"No square root");s=Math.sqrt(+Ut(r,!0,!0)),s===0||s===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),n=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):n=new i(s+""),o=n.e+(i.DP+=4);do t=n,n=a.times(t.plus(r.div(t)));while(t.c.slice(0,o).join("")!==n.c.slice(0,o).join(""));return qt(n,(i.DP-=4)+n.e+1,i.RM)};G.times=G.mul=function(n){var e,t=this,r=t.constructor,i=t.c,s=(n=new r(n)).c,o=i.length,a=s.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!i[0]||!s[0])return n.c=[n.e=0],n;for(n.e=l+u,o<a&&(e=i,i=s,s=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]+s[l]*i[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};G.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>jt)throw Error(Si);for(t=qt(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return Ut(t,!0,!!r)};G.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>jt)throw Error(Si);for(t=qt(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return Ut(t,!1,!!r)};G[Symbol.for("nodejs.util.inspect.custom")]=G.toJSON=G.toString=function(){var n=this,e=n.constructor;return Ut(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};G.toNumber=function(){var n=+Ut(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(an+"Imprecise conversion");return n};G.toPrecision=function(n,e){var t=this,r=t.constructor,i=t.c[0];if(n!==Ze){if(n!==~~n||n<1||n>jt)throw Error(Ft+"precision");for(t=qt(new r(t),n,e);t.c.length<n;)t.c.push(0)}return Ut(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!i)};G.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(an+"valueOf disallowed");return Ut(n,n.e<=e.NE||n.e>=e.PE,!0)};var Tf=Qa(),el=Tf;var ho={};vd(ho,{DecodeError:()=>Ee,Decoder:()=>Ve,EXT_TIMESTAMP:()=>no,Encoder:()=>gr,ExtData:()=>Ue,ExtensionCodec:()=>bt,decode:()=>ul,decodeArrayStream:()=>fl,decodeAsync:()=>dl,decodeMulti:()=>cl,decodeMultiStream:()=>hl,decodeTimestampExtension:()=>lo,decodeTimestampToTimeSpec:()=>ao,encode:()=>Oi,encodeDateToTimeSpec:()=>so,encodeTimeSpecToTimestamp:()=>io,encodeTimestampExtension:()=>oo});function tl(n){let e=n.length,t=0,r=0;for(;r<e;){let i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){let s=n.charCodeAt(r);(s&64512)===56320&&(++r,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function Df(n,e,t){let r=n.length,i=t,s=0;for(;s<r;){let o=n.charCodeAt(s++);if((o&4294967168)===0){e[i++]=o;continue}else if((o&4294965248)===0)e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<r){let a=n.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128):(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128)}e[i++]=o&63|128}}var Cf=new TextEncoder,Sf=50;function Nf(n,e,t){Cf.encodeInto(n,e.subarray(t))}function rl(n,e,t){n.length>Sf?Nf(n,e,t):Df(n,e,t)}var If=4096;function ro(n,e,t){let r=e,i=r+t,s=[],o="";for(;r<i;){let a=n[r++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=n[r++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=n[r++]&63,u=n[r++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d)}else s.push(a);s.length>=If&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var Of=new TextDecoder,Bf=200;function Rf(n,e,t){let r=n.subarray(e,e+t);return Of.decode(r)}function nl(n,e,t){return t>Bf?Rf(n,e,t):ro(n,e,t)}var Ue=class{type;data;constructor(e,t){this.type=e,this.data=t}};var Ee=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};function il(n,e,t){let r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Ni(n,e,t){let r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Ii(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function sl(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var no=-1,$f=4294967296-1,Mf=17179869184-1;function io({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=Mf)if(e===0&&n<=$f){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,r),i}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),Ni(r,4,n),t}}function so(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function oo(n){if(n instanceof Date){let e=so(n);return io(e)}else return null}function ao(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),r=e.getUint32(4),i=(t&3)*4294967296+r,s=t>>>2;return{sec:i,nsec:s}}case 12:{let t=Ii(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Ee(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function lo(n){let e=ao(n);return new Date(e.sec*1e3+e.nsec/1e6)}var ol={type:no,encode:oo,decode:lo};var bt=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ol)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let i=this.builtInEncoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=-1-r;return new Ue(o,s)}}}for(let r=0;r<this.encoders.length;r++){let i=this.encoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=r;return new Ue(o,s)}}}return e instanceof Ue?e:null}decode(e,t,r){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Ue(t,e)}};function Lf(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function ln(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Lf(n)?new Uint8Array(n):Uint8Array.from(n)}var Pf=100,jf=2048,gr=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??bt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Pf,this.initialBufferSize=e?.initialBufferSize??jf,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 n({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),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r}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 r=tl(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),rl(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,t){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);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 r=ln(e);this.writeU8a(r)}encodeArray(e,t){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let r=0;for(let i of t)e[i]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let s of r){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),i=r.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(r);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),il(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Ni(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 Oi(n,e){return new gr(e).encodeSharedRef(n)}function Bi(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var Ff=16,qf=16,Ri=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ff,t=qf){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,r){let i=this.caches[r-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<r;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)}decode(e,t,r){let i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;let s=ro(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}};var uo="array",dn="map_key",ll="map_value",Uf=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new Ee("The type of key must be string or number but "+typeof n)},co=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=uo,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=dn,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===uo){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===dn||e.type===ll){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},cn=-1,fo=new DataView(new ArrayBuffer(0)),Vf=new Uint8Array(fo.buffer);try{fo.getInt8(0)}catch(n){if(!(n 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 al=new RangeError("Insufficient data"),zf=new Ri,Ve=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=fo;bytes=Vf;headByte=cn;stack=new co;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??bt.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:zf,this.mapKeyConverter=e?.mapKeyConverter??Uf}clone(){return new n({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=cn,this.stack.reset()}setBuffer(e){let t=ln(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===cn&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=ln(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:r}=this;return new RangeError(`Extra ${t.byteLength-r} 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,r;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{r=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 r}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Bi(i)} at ${o} (${s} 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 r=t,i=-1;for await(let s of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),r&&(i=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==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 i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,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 i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,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 i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new Ee(`Unrecognized type byte: ${Bi(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let i=r.top();if(i.type===uo)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,r.release(i);else continue e;else if(i.type===dn){if(t==="__proto__")throw new Ee("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=ll;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,r.release(i);else{i.key=null,i.type=dn;continue e}}return t}}readHeadByte(){return this.headByte===cn&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=cn}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 Ee(`Unrecognized array type byte: ${Bi(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Ee(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Ee(`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 Ee(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw al;let r=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,r,e):i=nl(this.bytes,r,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===dn:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Ee(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw al;let r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new Ee(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,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=sl(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Ii(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 ul(n,e){return new Ve(e).decode(n)}function cl(n,e){return new Ve(e).decodeMulti(n)}function Hf(n){return n[Symbol.asyncIterator]!=null}async function*Wf(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function $i(n){return Hf(n)?n:Wf(n)}async function dl(n,e){let t=$i(n);return new Ve(e).decodeAsync(t)}function fl(n,e){let t=$i(n);return new Ve(e).decodeArrayStream(t)}function hl(n,e){let t=$i(n);return new Ve(e).decodeStream(t)}var es=Ia($o(),1),Mo=Za,Lo=el,et=ho,_u=es.DOMParser,wu=es.XMLSerializer;var yu=et!==null;function vu(){if(!yu)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Eu=Hp();function Hp(){if(!yu)return null;let n=new TextEncoder,e=new TextDecoder,t=new et.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let i=kt(r);if(i==="D"||i==="H")return null}return et.encodeTimestampExtension(r)},decode:r=>et.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>be(r)?n.encode(r.toString()):null,decode:r=>At(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&kt(r)==="D"){let i=r.getUTCFullYear(),s=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${i}-${s}-${o}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&kt(r)==="H"){let i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${i}:${s}:${o}.${a}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+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:r=>{let i=Po(r);if(i!==null){let[s,o]=i;return n.encode(`${s}:${o(r)}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=Tt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function xu(n){return vu(),et.encode(n,{extensionCodec:Eu})}function ku(n){return vu(),et.decode(n,{extensionCodec:Eu})}function rs(n,e=!1){let t=ns(n);if(t===null)return[!1,String(n)];let[r,i,s]=t;return s&&!e?[!1,String(n)]:[!0,`${i(n)}::${r}`]}function jo(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),i=Tt[r];if(i===void 0)return[!1,n];let[,s]=i;return[!0,s(t)]}function ts(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[i,s]of Object.entries(n))r[i]=ts(s,e,t);return r}return Array.isArray(n)?n.map(r=>ts(r,e,t)):t(n)?e(n):n}function Fo(n){let e=ns(n);if(e!==null){let[t,r,i]=e;return i?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(i=>{let[s,o]=Fo(i);return o&&(t=!0),s}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[i,s]of Object.entries(n)){let[o,a]=Fo(s);a&&(t=!0),r[i]=o}return[r,t]}return[n,!1]}function Wp(n,e=!1){let[t,r]=rs(n,e);if(t)return r;let[i,s]=Fo(n),o=JSON.stringify(i);return s?`${o}::JS`:o}function Gp(n){return JSON.stringify(n)}function Xp(n){if(!et)throw new Error("@msgpack/msgpack is required for MessagePack support");return et.encode(n)}function U(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:i=!1}={}){if(r)return`${Tu(n)}::QS`;if(t){if(e===null||e==="json")return Gp(n);if(e==="msgpack")return Xp(n);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let s=Wp(n,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Au(n)}</tytx_root>`;if(e==="msgpack")return xu(n);throw new Error(`Unknown transport: ${e}`)}}var $r,qo;typeof window<"u"&&window.DOMParser?($r=window.DOMParser,qo=window.XMLSerializer):($r=_u,qo=wu);function Du(n){if(n===null||typeof n!="object"||Array.isArray(n))return!1;let e=Object.keys(n);if(e.length!==1)return!1;let t=n[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function Cu(n,e,t){let r=n.createElement(e),i=t.attrs||{},s=t.value;for(let[o,a]of Object.entries(i))r.setAttribute(o,U(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(Du(o)){let[a]=Object.keys(o),l=o[a],u=Cu(n,a,l);r.appendChild(u)}else{r.textContent=U(s);break}else r.textContent=U(s);return r}function Au(n){if(!$r)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(Du(n)){let[e]=Object.keys(n),t=n[e],r=new $r().parseFromString("<root/>","text/xml"),i=Cu(r,e,t);return new qo().serializeToString(i)}else return U(n)}function Uo(n){let e={};for(let r=0;r<n.attributes.length;r++){let i=n.attributes[r];e[i.name]=j(i.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];i.nodeType===1&&t.push(i)}if(t.length>0)if(t.length===1){let r=t[0],i=Uo(r);return{attrs:e,value:{[r.tagName]:i}}}else{let r=[];for(let i of t){let s=Uo(i);r.push({[i.tagName]:s})}return{attrs:e,value:r}}return{attrs:e,value:j(n.textContent)}}function Su(n){if(!$r)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new $r().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let s=null;for(let o=0;o<r.childNodes.length;o++)if(r.childNodes[o].nodeType===1){s=r.childNodes[o];break}if(!s)return j(r.textContent);r=s}let i=Uo(r);return{[r.tagName]:i}}function Yp(n){return typeof n=="string"}function Zp(n){let[e,t]=jo(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let i;try{i=JSON.parse(r)}catch{return n}return ts(i,Jp,Yp)}function Jp(n){return n.includes("::")?jo(n)[1]:n}function Kp(n){let e=Su(n);return typeof e=="string"?j(e):e}function Qp(n){return ku(n)}function j(n,e=null){if(n===null)return null;if(e===null||e==="json"){let t=n;return e==="json"&&n.startsWith('"')&&n.endsWith('"')&&(t=n.slice(1,-1)),Zp(t)}else{if(e==="xml")return Kp(n);if(e==="msgpack")return Qp(n);throw new Error(`Unknown transport: ${e}`)}}function Tu(n){if(Array.isArray(n))return n.map(e=>String(e)).join("&");if(n!==null&&typeof n=="object"){let e=[];for(let[t,r]of Object.entries(n)){let[i,s]=rs(r,!0);i?e.push(`${t}=${s}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function Nu(n){if(!n)return[];let e=n.split("&"),t=e.map(o=>o.includes("=")),r=t.every(Boolean),i=!t.some(Boolean);if(!r&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>j(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=j(u)}return s}var Ou=Mo||Lo||Number,Bu=Mo?"decimal.js":Lo?"big.js":"number";function zo(){return Bu}function At(n){return new Ou(n)}function be(n){return Bu==="number"?!1:n instanceof Ou}function kt(n){let e=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,t=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function em(n){return n.toString()}function tm(n){let e=n.getUTCFullYear(),t=String(n.getUTCMonth()+1).padStart(2,"0"),r=String(n.getUTCDate()).padStart(2,"0");return`${e}-${t}-${r}`}function rm(n){return n.toISOString()}function nm(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),i=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${i}`}function im(n){return n?"true":"false"}function sm(n){return n.toString()}function om(n){return n.toString()}function am(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode.apply(null,n.subarray(t,t+32768));return btoa(e)}var is=[],Vo=new Map;function Po(n){if(n===null||typeof n!="object")return null;for(let e=Object.getPrototypeOf(n);e!==null;e=Object.getPrototypeOf(e))for(let[t,r,i,s]of is)if(t.prototype===e)return[r,i,s];return null}function ns(n){if(n===null)return["NN",()=>"",!0];if(be(n))return["N",em,!1];if(n instanceof Uint8Array)return["RAW",am,!1];if(n instanceof Date){let e=kt(n);return e==="D"?["D",tm,!1]:e==="H"?["H",nm,!1]:["DHZ",rm,!1]}return typeof n=="boolean"?["B",im,!0]:typeof n=="number"?Number.isInteger(n)?["L",sm,!0]:["R",om,!0]:Po(n)}function lm(n){return At(n)}function um(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function Iu(n){return new Date(n)}function cm(n){let[e,t,r]=n.split(":"),[i,s]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(i),Number(s||0)))}function dm(n){return n.toLowerCase()==="true"}function fm(n){return parseInt(n,10)}function hm(n){return parseFloat(n)}function pm(n){return n}function mm(n){return null}var gm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function bm(n){if(!gm.test(n))throw new Error(`RAW payload is not standard padded base64: '${n}'`);let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function _m(n){return Nu(n)}var wm=/^[A-Z]+$/,Tt={N:[Object,lm],D:[Date,um],DH:[Date,Iu],DHZ:[Date,Iu],H:[Date,cm],L:[Number,fm],R:[Number,hm],T:[String,pm],B:[Boolean,dm],QS:[Object,_m],NN:[null,mm],RAW:[Uint8Array,bm]};function In(n){return Object.hasOwn(Tt,n)?Tt[n][0]:null}function Ho(n,e,t,r,i=!1){if(typeof e!="string"||!wm.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=Tt[e];if(s!==void 0&&s[0]!==n){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}is=is.filter(([o])=>o!==n),is.push([n,e,t,i]),Tt[e]=[n,r]}function Gt(n,e){Vo.set(n,e)}function je(n){return Vo.has(n)?Vo.get(n):{}}var Ru={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 vm(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?Ru[e]||null:e}function Em(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function xm(n){return new Promise(e=>setTimeout(e,n))}async function km(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=r*1e3;for(let u=0;u<t;u++)try{let c=n();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&Em(c,o)){let d=l;s&&(d*=1+Math.random()*.1),await xm(d),l*=i}else throw c}throw a}var K=class n{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let r={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(r,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=r.cacheTime,this._readOnly=r.readOnly,this._asBag=r.asBag,this._retryPolicy=r.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(r))i.has(s)||(this._kw[s]=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,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let i={...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)||(i[c]=d)}Object.assign(i,r);let s=this._computeEffectiveFingerprint(i);if(s===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=s;let o=vm(this),a=()=>this.load(i);if(o)return km(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=n._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){n._BagClass=e}load(e){return null}};K._BagClass=null;var Dt=class extends K{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 ze=class n{constructor(e,t,r=null,i=null,s=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,i&&this.setAttr(i,!1,!0,l),r!==null&&this.setValue(r,!1),s&&(this.resolver=s)}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,r={}){if(t!==null){let i=j(`${t}::QS`);if(Array.isArray(i)){let s=i.length?i:Object.keys(this._attr),o=s.map(l=>{let u=this.getAttr(l);return!e&&u instanceof K?u.resolve():u}),a=l=>i.length===0?Object.fromEntries(s.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");r={...r,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,i=null,s=!0,o=null,a=!1){e instanceof K?(this.resolver=e,e=null):e instanceof n&&(r=r||{},Object.assign(r,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(r!==null){let h={...this._attr};this.setAttr(r,!1,i,s);let m=this._buildAttrDiff(h,this._attr);d=Object.keys(m).length>0?m: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 m of Object.values(this._nodeSubscribers))m({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 n))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 r=null;e.resolver&&(r=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),r._node=null,r._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==t||o!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};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,i,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 r={},i=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of i){let o=s in e?e[s]:null,a=s in t?t[s]:null;o!==a&&(r[s]={old:o,new:a})}return r}setAttr(e=null,t=!0,r=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?Object.assign(this._attr,s):this._attr={...s},i)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 r of t.split(","))delete this._attr[r.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 r=this;if(t===null)for(;r&&!(e in r._attr);)r=r.parentNode;else for(;r&&r._attr[e]!==t;)r=r.parentNode;return r}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof n)||this.label!==e.label)return!1;let t=Object.keys(this._attr),r=Object.keys(e._attr);if(t.length!==r.length)return!1;for(let i of t)if(this._attr[i]!==e._attr[i])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),r=Object.keys(e._attr);return t.length!==r.length||t.some(i=>this._attr[i]!==e._attr[i])?`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 On=class n{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(r=>r.label===e);let t=e.match(/^#(\d+)$/);if(t){let r=parseInt(t[1],10);return r<this._list.length?r:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,r,i]=t,s=i.includes("::")?j(i):i;return r?this._list.findIndex(o=>o.getAttr(r)===s):this._list.findIndex(o=>o._value===s)}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 r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s+1,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i+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 r=parseInt(e,10);if(r<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return r}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,r=">",i=null,s=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 p=h.split("&");if(p.length===1)i={[p[0]]:t};else{if(!Array.isArray(t)||t.length!==p.length)throw new Error("Wrong attributes assignment");i={};for(let b=0;b<p.length;b++)i[p[b]]=t[b]}t=null}let m=this._dict[e];if(m)f&&(m.nodeTag=f),o!==null&&(o===!1?m.resolver=null:m.resolver=o),h?m.setAttr(i,c,!0,l):m.setValue(t,c,i,a,l,u,d);else{let p=s&&s.nodeClass?s.nodeClass:ze;m=new p(s,e,h?null:t,i,o,f,null,l);let b=this._parsePosition(r);this._dict[e]=m,this._list.splice(b,0,m),c&&s&&s.backref&&s._onNodeInserted(m,b,null,u,d)}return d&&m.setValue(null,!1),m}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let r=this._list.indexOf(t);return r>=0&&this._list.splice(r,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,r=!0){if(t<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||t>=this._list.length)return;let s=this._list[t].label;if(i.length>1){let o=[...i].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),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof n)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let r=this._list[t],i=e._list[t];if(!r.isEqual(i))return!1}return!0}};var Pu=Ia($o(),1);var Wo="::RSLV:",Am=new Map,Tm=new Map,ss=new WeakMap,oe=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Bn=class extends K{constructor(e){super({asBag:!1}),ss.set(this,e)}get payload(){return ss.get(this)}load(){throw new oe("This resolver is opaque; local execution is unavailable")}};function $u(n){if(!n||typeof n!="object"||Array.isArray(n)||typeof n.resolver_module!="string"||typeof n.resolver_class!="string"||!Array.isArray(n.args??[])||!n.kwargs||typeof n.kwargs!="object"||Array.isArray(n.kwargs))throw new oe("Invalid resolver description")}function Mu(n,e=new Set){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n)||!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new oe("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))Mu(t,e);e.delete(n)}}function Rn(n){if(ss.has(n))return ss.get(n);let e=Tm.get(n.constructor);if(!e)throw new oe(`Unregistered resolver: ${n.constructor.name}`);let t=e.encode(n),r={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return $u(r),Mu(r),Wo+JSON.stringify(r)}function os(n){if(typeof n!="string"||!n.startsWith(Wo))return null;let e=n.slice(Wo.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Bn(n);let t;try{t=JSON.parse(e)}catch{throw new oe("Invalid resolver JSON or signed token")}$u(t);let r=Am.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new Bn(n);let i=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(i instanceof r.cls))throw new oe("Resolver decoder returned an incompatible instance");return i}function as(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof K?Rn(t):t]))}function Go(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,os(t)??t]))}var He="__cls";function Mr(n,e){return n!==null&&n.tytxSuffix===e?n:In(e)}function Dm(n){let e=n.tytxSuffix,t=Object.entries(je(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new oe(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new oe(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Xo(n,e){let t=je(n);if(!Object.hasOwn(t,e))throw new oe(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function Yo(n,e){return n===e?null:Dm(n)}function*ju(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let i=t.getValue(!0);!t.resolver&&i instanceof x&&(yield*ju(i,r))}}function Cm(n){let e=n.toISOString(),t=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,r=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;if(r&&!t)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return t&&!r?i.slice(i.indexOf("T")+1):i}function Lr(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Ct(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(Ct):Lr(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Ct(t)])):n}function Zo(n){if(!Lr(n))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=n;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var Lu=!1,x=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new On,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Zo(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 ze}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=[],r=e;for(;r!==null;){if(r.parentBag===this)return t.push(r.label),t.reverse(),t.join(".");t.push(r.label),r=r.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,r;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),r=e.split(".").filter(i=>i)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!0){let[i,s]=this._htraverseBefore(e);if(i===null)return[null,null];if(s.length===0)return[i,""];for(;s.length>1&&i instanceof n;){let o=s[0];if(o==="#parent"){if(i.parent===null||i.parent===void 0)break;s.shift(),i=i.parent;continue}let a=i._nodes.get(o);if(!a)break;let l=a.getValue(r);if(l instanceof n)s.shift(),i=l;else if(t){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!t)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new $n("Not existing index in #n syntax");let a=i.createChildBag();i._nodes.set(o,a,">",null,i,null,!1,!0,"autocreate"),i=a}return[i,s[0]]}get(e,t=null,r=!0,i={}){if(!e)return this;if(e==="#parent")return this.parent;let s=null;e.includes("?")&&([e,s]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(r,s,i):t}getItem(e,t=null,r=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,r);return s instanceof n?s.get(o,t,r,i):t}setItem(e,t,r=null,i=">",s=!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,i,r,f,c,s,o,a,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let i=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(i,r,t),i}return null}pop(e,t=null,r=null){let i=this.popNode(e,r);return i?i.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,i]=this._htraverse(e,!1,!0);if(!r||!i)return null;let s=r._nodes.get(i);if(!s)return null;try{return r._pop(i,t)}finally{s.parentBag===r&&r._nodes._dict[s.label]!==s&&(s.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,r=!1,i=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[s,o]=this._htraverse(e,r,t);if(s instanceof n&&o){let a=s._nodes.get(o);if(a)return a;if(r)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,t=null){let r=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!r){this._nodes._parentBag=this;for(let i of this)i.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 n&&t.clearBackref()}}}_onNodeChanged(e,t,r,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:i,attrs_diff:s,evt:r,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,i,s,o,a)}_onNodeInserted(e,t,r=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof n&&a.setBackref(e,o),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],i,s)}_onNodeDeleted(e,t,r=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:r,ind:t,evt:"del",reason:i});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],i))}_subscribe(e,t,r){r!=null&&(t[e]=r)}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:r=null,insert:i=null,delete:s=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||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:r=!1,insert:i=!1,delete:s=!1,any:o=!1}=t;(r||o)&&delete this._updSubscribers[e],(i||o)&&delete this._insSubscribers[e],(s||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,r=!0){let i=n.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let i=this.getNode(e);return i?i.getAttr(t,r):r}delAttr(e=null,...t){let r=this.getNode(e);r&&r.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 r of this._nodes){let i=r.value;if(i instanceof n){if(i.getItem(e)===t)return r}else if(i&&i.get&&i.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,i=!1){let s=t===void 0,o=r&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=r&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||d==o)return c}if(c._value instanceof n)if(i){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 r of this._nodes){if(r._resolver!==null)return!1;let i=r.getValue(!0);if(i!=null&&!(e&&i===0)&&!(t&&i===""))return!1}return!0}query(e=null,t=null,r=!1,i=!1,s=!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,m]=e.split(":");u=this.getItem(h),e=m}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,m,p,b,g)=>{if(m==="#k")return h.label;if(m==="#p")return p;if(m==="#n")return h;if(typeof m=="function")return m(h);if(m==="#v"){let _=g();return b&&_ instanceof n?null:_}else if(m.startsWith("#v.")){let _=m.split(".").slice(1).join("."),w=g();return w&&w.getItem?w.getItem(_):null}else{if(m==="#__v")return h.getValue(!0);if(m.startsWith("#a")){let _=m.includes(".")?m.split(".").slice(1).join("."):null;return h.getAttr(_)}else{let _=g();return _&&_.getItem?_.getItem(m):null}}};function*f(){let h=0;function*m(p,b){for(let g of p._nodes){let _=b?`${b}.${g.label}`:g.label,w=!1,E,D=()=>(w||(E=g.getValue(l),w=!0),E);if((s&&o||(D()instanceof n?o:s))&&(t===null||t(g))&&(yield c.length===1?d(g,c[0],_,i,D):c.map(T=>d(g,T,_,i,D)),h++,a!==null&&h>=a))return;if(i){let T=D();if(T instanceof n&&(yield*m(T,_),a!==null&&h>=a))return}}}yield*m(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,i)=>{for(let s of r._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof n?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,r=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),r=t,t=null);let i=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){if(!i||i.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let s=[...i];if(s.length&&Array.isArray(s[0])){let o=s[0].length,a=[];for(let l=0;l<o;l++)a.push(s.map(u=>u[l]));return a}return[s]}return[...i]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",i=e.map(s=>`${r}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",t=!1,r=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(r!=null&&typeof r!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let i=s=>{let o=0,a=!1;for(let l of this.query(s,r)){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(s=>i(s.trim())):i(e)}sort(e="#k:a"){let t=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],r=(i,s)=>i[0]!==s[0]?i[0]-s[0]:i[1]<s[1]?-1:i[1]>s[1]?1:0;if(typeof e=="function")this._nodes._list.sort((i,s)=>{let o=e(i),a=e(s);return o<a?-1:o>a?1:0});else{let i=e.split(",");i.reverse();for(let s of i){let o,a;s.includes(":")?[o,a]=s.split(":",2):(o=s,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 n?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=r(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof n?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let r=this.getNode(e);return r===null?!1:t===null?!0:t.split("&").every(i=>i in r.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 r=this.getNode(e);r||(this.setItem(e,null),r=this.getNode(e)),r.resolver=t}setCallbackItem(e,t,r={}){let i=new Dt({callback:t,...r});this.setResolver(e,i)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!1,i=!1){let s={};for(let o of this._nodes){let a=o.value;if(i&&a==null)continue;let l=o.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),r&&a instanceof n&&(a=n.prototype.asDict.call(a,e,t,r,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,t=null){let r=this.getNode(e);return r?r.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let r of this._nodes){let i=r.getValue(!e);i instanceof n&&(i=i.deepcopy(e));let s=new t.nodeClass(t,r.label,i);s.setAttr({...r.attr},!1,!1,!1),s.nodeTag=r.nodeTag,s.xmlTag=r.xmlTag,t._nodes._list.push(s),t._nodes._dict[s.label]=s}return t}update(e,t=null,r=null,i=!1){if(!(e instanceof n)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,r,!1,r!==!1)}return}for(let s of[...e]){let o=s.label,a=t==="static"?s.resolver:null,l=a?null:s.getValue(),u=s.attr.__replace;delete s.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(s.attr,r===null?!0:r,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,r===null?!0:r,null,null,!1,r);else{s.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,i):(!i||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(o,a||l,s.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=s.nodeTag,d.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let r=new this.nodeClass(this,t.label);r.replace(t),r.nodeTag=t.nodeTag,r.xmlTag=t.xmlTag,this._nodes._list.push(r),this._nodes._dict[r.label]=r}}_appendLiteral(e,t,r=null,i=null,s=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,r,i,s,null,!1);return t instanceof K?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let r=Zo(t);if(e!=null&&!Lr(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let i=this.createChildBag(),s=new Set,o=(a,l,u)=>{if(s.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);s.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 m=h;r&&(Lr(m)||Array.isArray(m))&&(m=this.createChildBag(),o(m,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,m)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof n))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 r of this._nodes){r.parentBag=null;let i=r.getValue(!0);i instanceof n&&i.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 r of this._nodes)r.parentBag=this;for(let r of e._nodes)r._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:r=!1,kwargs:i={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let s=(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&&r){let f=u.getValue(t);if(f instanceof n){let h=s(f,c);if(h)return h}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof n&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let r of this._nodes){let i=t?`${t}.${r.label}`:r.label;yield[i,r];let s=r.getValue(e);s instanceof n&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of ju(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=Rn(a.resolver);else if(d instanceof n){let b=d.constructor,g=b.tytxSuffix;s.set(u,b),h=Yo(b,Mr(s.get(c),g)),f=`::${g}`}else d===null?f="::NN":f=Ct(d);if(a.attr&&Object.hasOwn(a.attr,He))throw new oe(`node '${o}': the attribute '${He}' is reserved for the Bag class name`);let m=as(Ct(a.attr));h!==null&&(m[He]=h);let p=a.nodeTag;t?(yield[l.length?r[c]:null,a.label,p,f,m],d instanceof n&&(r[u]=i,e[i]=o,i++)):yield[l,a.label,p,f,m]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),i=this.constructor.tytxSuffix;if(e==="json")return`${r}::${i}`;if(e==="msgpack")return Oi(new Ue(4,new TextEncoder().encode(`${i}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let s={};t={rows:[...this._nodeFlattener(s)],paths:s}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,i=Yo(r,Mr(null,r.tytxSuffix));return i!==null&&(t[He]=i),t.rows=t.rows.map(([s,o,a,l,u])=>[Ct(s),Ct(o),Ct(a),l,u]),t.paths&&(t.paths=Ct(t.paths)),U(t)}static fromTytx(e,t="json",r={}){if(Lr(t)&&(r=t,t="json"),Zo(r),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 i=j(e,t==="json"?null:t);if(i instanceof n)return i;if(!Lr(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Mr(null,t));let r=j(e);if(!r||!Array.isArray(r.rows))throw new oe("Invalid TYTX Bag: expected rows");let i=r.paths,s=i!=null,o=Object.hasOwn(r,He)?Xo(t,r[He]):Mr(null,t),a=new o,l=new Map([["[]",a]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new oe("Invalid TYTX Bag row");let[c,d,f,h,m]=u,p=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new oe(`Unknown TYTX parent reference: ${c}`);p=c===null?"":i[c]}if(typeof p=="string"&&(p=p?p.split("."):[]),!Array.isArray(p))throw new oe("Invalid TYTX parent path");let b=JSON.stringify(p);if(!l.has(b))throw new oe(`Missing or undecodable TYTX parent branch: ${p}`);let g=l.get(b),_=JSON.stringify([...p,d]),w=h,E=os(w),D=Go(m),y=Object.hasOwn(D,He)?D[He]:null;if(delete D[He],w instanceof n){let S=w.constructor.tytxSuffix,I=y!==null?Xo(S,y):Mr(g.constructor,S);w=new I,l.set(_,w)}else if(y!==null)throw new oe(`node '${_}': the attribute '${He}' is reserved for the Bag class name of a branch`);let T=g._appendLiteral(d,E?null:w,D,E);T.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,t);return i===!0?o=`<?xml version='1.0' encoding='${r}'?>
|
|
30
|
+
`,rn=class n{static install({document:e,root:t}){return vi.has(t)||vi.set(t,new n(e,t)),vi.get(t)}constructor(e,t){this.document=e,this.root=t,this.releases=[],this.closed=!1,t.setAttribute("data-gramlot-viewport",e.defaultView.parent===e.defaultView?"root":"child");let r=e.querySelector('meta[name="viewport"]');r||(r=e.createElement("meta"),r.name="viewport",r.content="width=device-width,initial-scale=1",e.head.append(r));let i=r.content.split(",").map(s=>s.trim()).filter(s=>!s.startsWith("viewport-fit="));r.content=[...i,"viewport-fit=cover"].join(","),this.style=e.createElement("style"),this.style.textContent=Dd,e.head.append(this.style)}subscribeAppearance(e){let t=this.document.defaultView,r=t.matchMedia("(prefers-color-scheme: dark)"),i=()=>{let a=t.getComputedStyle(this.document.documentElement).colorScheme;e({dark:a==="dark"||!["light","dark"].includes(a)&&r.matches})},s=new t.MutationObserver(i);s.observe(this.document.documentElement,{attributes:!0,attributeFilter:["data-theme","style","class"]}),r.addEventListener("change",i),i();let o=()=>{s.disconnect(),r.removeEventListener("change",i)};return this.releases.push(o),o}dispose(){if(!this.closed){this.closed=!0;for(let e of this.releases)e();this.style.remove(),this.root.removeAttribute("data-gramlot-viewport"),vi.delete(this.root)}}};var nn=class{#e=new Map;registerGroup(e,t={}){if(typeof e!="string"||!e||e.includes(":"))throw new TypeError("Extension command namespace must be nonempty and unqualified");if(this.#e.has(e))throw new Error(`Duplicate command namespace: ${e}`);if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!["author","description"].includes(i))||Object.values(t).some(i=>typeof i!="string"))throw new TypeError(`Invalid command group metadata: ${e}`);let r=new Map;return this.#e.set(e,{metadata:{...t},commands:r}),Object.freeze({register(i,s){if(typeof i!="string"||!i||i.includes(":"))throw new TypeError("Invalid command name");if(r.has(i))throw new Error(`Duplicate command: ${e}:${i}`);if(!s||typeof s!="object"||Array.isArray(s)||!Object.hasOwn(s,"label")||!Object.hasOwn(s,"publish")||Object.keys(s).some(o=>!["label","publish","icon","iconSrc","tooltip"].includes(o))||Object.values(s).some(o=>typeof o!="string"))throw new TypeError(`Invalid command definition: ${e}:${i}`);r.set(i,Object.freeze({...s}))}})}get(e){let t=e.indexOf(":");return this.#e.get(e.slice(0,t))?.commands.get(e.slice(t+1))}toDocument(){return{document_format:{name:"gramlot_commands",version:"1.0"},groups:Object.fromEntries([...this.#e].map(([e,{metadata:t,commands:r}])=>[e,{...t,commands:Object.fromEntries(r)}]))}}};var sn=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:i=globalThis.navigator,XMLHttpRequest:s=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=i,this.XMLHttpRequest=s}get supportsCallSync(){return!0}async call(e,t){let r=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(r.status!==200)throw new Error(`rpc failed: HTTP ${r.status}`);return r.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){if(typeof this.closeUrl!="string"||!this.closeUrl.trim())throw new TypeError("HttpTransport.closeUrl must be nonempty text");if(typeof this.navigator?.sendBeacon!="function")throw new TypeError("HttpTransport requires navigator.sendBeacon");let t=new Blob([JSON.stringify({pageId:e})],{type:"application/json"});try{this.navigator.sendBeacon(this.closeUrl,t)}catch(r){if(r.name==="TypeError")throw r}}dispose(){}};var Ei=class{constructor(e,t){this.channel=e,this.closeTransport=t}get supportsCallSync(){return!1}call(e,t){return this.channel.call(e,t)}close(e,t){this.closeTransport.close(e,t)}dispose(){this.closeTransport.dispose()}};var ht=class{createTransport({rpcUrl:e,closeUrl:t,document:r,channel:i=null}){let s=r.defaultView,o=new sn(e,{closeUrl:t,navigator:s.navigator,XMLHttpRequest:s.XMLHttpRequest});return i===null?o:new Ei(i,o)}};var mr=9e15,bt=1e9,to="0123456789abcdef",Ai="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ti="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ro={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-mr,maxE:mr,crypto:!1},qa,st,R=!0,Ci="[DecimalError] ",gt=Ci+"Invalid argument: ",Ua=Ci+"Precision limit exceeded",Va=Ci+"crypto unavailable",za="[object Decimal]",ve=Math.floor,le=Math.pow,Cd=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Sd=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Nd=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ha=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,O=7,Id=9007199254740991,Od=Ai.length-1,no=Ti.length-1,v={toStringTag:za};v.absoluteValue=v.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),N(n)};v.ceil=function(){return N(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(n,e){var t,r=this,i=r.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(gt+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new i(r)};v.comparedTo=v.cmp=function(n){var e,t,r,i,s=this,o=s.d,a=(n=new s.constructor(n)).d,l=s.s,u=n.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(s.e!==n.e)return s.e>n.e^l<0?1:-1;for(r=o.length,i=a.length,e=0,t=r<i?r:i;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return r===i?0:r>i^l<0?1:-1};v.cosine=v.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=Bd(r,Za(r,t)),r.precision=n,r.rounding=e,N(st==2||st==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};v.cubeRoot=v.cbrt=function(){var n,e,t,r,i,s,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(R=!1,s=c.s*le(c.s*c,1/3),!s||Math.abs(s)==1/0?(t=pe(c.d),n=c.e,(s=(n-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=le(t,1/3),n=ve((n+1)/3)-(n%3==(n<0?-1:2)),s==1/0?t="5e"+n:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(s.toString()),o=(n=d.precision)+3;;)if(a=r,l=a.times(a).times(a),u=l.plus(c),r=J(u.plus(c).times(a),u.plus(l),o+2,1),pe(a.d).slice(0,o)===(t=pe(r.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(N(a,n+1,0),a.times(a).times(a).eq(c))){r=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(N(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return R=!0,N(r,n,d.rounding,e)};v.decimalPlaces=v.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-ve(this.e/O))*O,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(n){return J(this,new this.constructor(n))};v.dividedToIntegerBy=v.divToInt=function(n){var e=this,t=e.constructor;return N(J(e,new t(n),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(n){return this.cmp(n)===0};v.floor=function(){return N(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(n){return this.cmp(n)>0};v.greaterThanOrEqualTo=v.gte=function(n){var e=this.cmp(n);return e==1||e===0};v.hyperbolicCosine=v.cosh=function(){var n,e,t,r,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;t=o.precision,r=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(n=Math.ceil(i/3),e=(1/Ni(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),s=gr(o,1,s.times(e),new o(1),!0);for(var l,u=n,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return N(s,o.precision=t,o.rounding=r,!0)};v.hyperbolicSine=v.sinh=function(){var n,e,t,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,t=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=gr(s,2,i,i,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,i=i.times(1/Ni(5,n)),i=gr(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);n--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=t,N(i,e,t,!0)};v.hyperbolicTangent=v.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,J(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};v.inverseCosine=v.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return t!==-1?t===0?n.isNeg()?Xe(e,r,i):new e(0):new e(NaN):n.isZero()?Xe(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=i,n.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,R=!1,t=t.times(t).minus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};v.inverseHyperbolicSine=v.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,R=!1,t=t.times(t).plus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var n,e,t,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=s.precision,e=s.rounding,r=i.sd(),Math.max(r,n)<2*-i.e-1?N(new s(i),n,e,!0):(s.precision=t=r-i.e,i=J(i.plus(1),new s(1).minus(i),t+n,1),s.precision=n+4,s.rounding=1,i=i.ln(),s.precision=n,s.rounding=e,i.times(.5))):new s(NaN)};v.inverseSine=v.asin=function(){var n,e,t,r,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),t=s.precision,r=s.rounding,e!==-1?e===0?(n=Xe(s,t+4,r).times(.5),n.s=i.s,n):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,i.times(2)))};v.inverseTangent=v.atan=function(){var n,e,t,r,i,s,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<=no)return o=Xe(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=no)return o=Xe(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/O+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(R=!1,e=Math.ceil(a/O),r=1,l=u.times(u),o=new c(u),i=u;n!==-1;)if(i=i.times(l),s=o.minus(i.div(r+=2)),i=i.times(l),o=s.plus(i.div(r+=2)),o.d[e]!==void 0)for(n=e;o.d[n]===s.d[n]&&n--;);return t&&(o=o.times(2<<t-1)),R=!0,N(o,c.precision=d,c.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&ve(this.e/O)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(n){return this.cmp(n)<0};v.lessThanOrEqualTo=v.lte=function(n){return this.cmp(n)<1};v.logarithm=v.log=function(n){var e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.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)s=!0;else{for(i=t[0];i%10===0;)i/=10;s=i!==1}if(R=!1,a=d+h,o=mt(u,a),r=e?Di(c,a+10):mt(n,a),l=J(o,r,a,1),on(l.d,i=d,f))do if(a+=10,o=mt(u,a),r=e?Di(c,a+10):mt(n,a),l=J(o,r,a,1),!s){+pe(l.d).slice(i+1,i+15)+1==1e14&&(l=N(l,d+1,0));break}while(on(l.d,i+=10,f));return R=!0,N(l,d,f)};v.minus=v.sub=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.constructor;if(n=new m(n),!h.d||!n.d)return!h.s||!n.s?n=new m(NaN):h.d?n.s=-n.s:n=new m(n.d||h.s!==n.s?h:NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(u=h.d,f=n.d,a=m.precision,l=m.rounding,!u[0]||!f[0]){if(f[0])n.s=-n.s;else if(u[0])n=new m(h);else return new m(l===3?-0:0);return R?N(n,a,l):n}if(t=ve(n.e/O),c=ve(h.e/O),u=u.slice(),s=c-t,s){for(d=s<0,d?(e=u,s=-s,o=f.length):(e=f,t=c,o=u.length),r=Math.max(Math.ceil(a/O),o)+2,s>r&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for(r=u.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}s=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),o=u.length,r=f.length-o;r>0;--r)u[o++]=0;for(r=f.length;r>s;){if(u[--r]<f[r]){for(i=r;i&&u[--i]===0;)u[i]=qe-1;--u[i],u[r]+=qe}u[r]-=f[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=Si(u,t),R?N(n,a,l):n):new m(l===3?-0:0)};v.modulo=v.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?N(new r(t),r.precision,r.rounding):(R=!1,r.modulo==9?(e=J(t,n.abs(),0,3,1),e.s*=n.s):e=J(t,n,0,r.modulo,1),e=e.times(n),R=!0,t.minus(e))};v.naturalExponential=v.exp=function(){return io(this)};v.naturalLogarithm=v.ln=function(){return mt(this)};v.negated=v.neg=function(){var n=new this.constructor(this);return n.s=-n.s,N(n)};v.plus=v.add=function(n){var e,t,r,i,s,o,a,l,u,c,d=this,f=d.constructor;if(n=new f(n),!d.d||!n.d)return!d.s||!n.s?n=new f(NaN):d.d||(n=new f(n.d||d.s===n.s?d:NaN)),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(u=d.d,c=n.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),R?N(n,a,l):n;if(s=ve(d.e/O),r=ve(n.e/O),u=u.slice(),i=s-r,i){for(i<0?(t=u,i=-i,o=c.length):(t=c,r=s,o=u.length),s=Math.ceil(a/O),o=s>o?s+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,t=c,c=u,u=t),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/qe|0,u[i]%=qe;for(e&&(u.unshift(e),++r),o=u.length;u[--o]==0;)u.pop();return n.d=u,n.e=Si(u,r),R?N(n,a,l):n};v.precision=v.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(gt+n);return t.d?(e=Wa(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};v.round=function(){var n=this,e=n.constructor;return N(new e(n),n.e+1,e.rounding)};v.sine=v.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=$d(r,Za(r,t)),r.precision=n,r.rounding=e,N(st>2?t.neg():t,n,e,!0)):new r(NaN)};v.squareRoot=v.sqrt=function(){var n,e,t,r,i,s,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(R=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=pe(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ve((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),r=new c(e)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(s=r,r=s.plus(J(o,s,t+2,1)).times(.5),pe(s.d).slice(0,t)===(e=pe(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(N(s,l+1,0),s.times(s).eq(o))){r=s;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(N(r,l+1,1),n=!r.times(r).eq(o));break}return R=!0,N(r,l,c.rounding,n)};v.tangent=v.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,t=t.sin(),t.s=1,t=J(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,N(st==2||st==4?t.neg():t,n,e,!0)):new r(NaN)};v.times=v.mul=function(n){var e,t,r,i,s,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(n=new d(n)).d;if(n.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!n.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?n.s/0:n.s*0);for(t=ve(c.e/O)+ve(n.e/O),l=f.length,u=h.length,l<u&&(s=f,f=h,h=s,o=l,l=u,u=o),s=[],o=l+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)a=s[i]+h[r]*f[i-r-1]+e,s[i--]=a%qe|0,e=a/qe|0;s[i]=(s[i]+e)%qe|0}for(;!s[--o];)s.pop();return e?++t:s.shift(),n.d=s,n.e=Si(s,t),R?N(n,d.precision,d.rounding):n};v.toBinary=function(n,e){return so(this,2,n,e)};v.toDecimalPlaces=v.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(Ce(n,0,bt),e===void 0?e=r.rounding:Ce(e,0,8),N(t,n+t.e+1,e))};v.toExponential=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,!0):(Ce(n,0,bt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n+1,e),t=Ye(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toFixed=function(n,e){var t,r,i=this,s=i.constructor;return n===void 0?t=Ye(i):(Ce(n,0,bt),e===void 0?e=s.rounding:Ce(e,0,8),r=N(new s(i),n+i.e+1,e),t=Ye(r,!1,n+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.d,p=h.constructor;if(!m)return new p(h);if(u=t=new p(1),r=l=new p(0),e=new p(r),s=e.e=Wa(m)-h.e-1,o=s%O,e.d[0]=le(10,o<0?O+o:o),n==null)n=s>0?e:u;else{if(a=new p(n),!a.isInt()||a.lt(u))throw Error(gt+a);n=a.gt(e)?s>0?e:u:a}for(R=!1,a=new p(pe(m)),c=p.precision,p.precision=s=m.length*O*2;d=J(a,e,0,1,1),i=t.plus(d.times(r)),i.cmp(n)!=1;)t=r,r=i,i=u,u=l.plus(d.times(i)),l=i,i=e,e=a.minus(d.times(i)),a=i;return i=J(n.minus(t),r,0,1,1),l=l.plus(i.times(u)),t=t.plus(i.times(r)),l.s=u.s=h.s,f=J(u,r,s,1).minus(h).abs().cmp(J(l,t,s,1).minus(h).abs())<1?[u,r]:[l,t],p.precision=c,R=!0,f};v.toHexadecimal=v.toHex=function(n,e){return so(this,16,n,e)};v.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),n==null){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),e===void 0?e=r.rounding:Ce(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(R=!1,t=J(t,n,0,e,1).times(n),R=!0,N(t)):(n.s=t.s,t=n),t};v.toNumber=function(){return+this};v.toOctal=function(n,e){return so(this,8,n,e)};v.toPower=v.pow=function(n){var e,t,r,i,s,o,a=this,l=a.constructor,u=+(n=new l(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new l(le(+a,u));if(a=new l(a),a.eq(1))return a;if(r=l.precision,s=l.rounding,n.eq(1))return N(a,r,s);if(e=ve(n.e/O),e>=n.d.length-1&&(t=u<0?-u:u)<=Id)return i=Ga(l,a,t,r),n.s<0?new l(1).div(i):N(i,r,s);if(o=a.s,o<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=le(+a,u),e=t==0||!isFinite(t)?ve(u*(Math.log("0."+pe(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):(R=!1,l.rounding=a.s=1,t=Math.min(12,(e+"").length),i=io(n.times(mt(a,r+t)),r),i.d&&(i=N(i,r+5,1),on(i.d,r,s)&&(e=r+10,i=N(io(n.times(mt(a,e+t)),e),e+5,1),+pe(i.d).slice(r+1,r+15)+1==1e14&&(i=N(i,r+1,0)))),i.s=o,R=!0,l.rounding=s,N(i,r,s))};v.toPrecision=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ce(n,1,bt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n,e),t=Ye(r,n<=r.e||r.e<=i.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(Ce(n,1,bt),e===void 0?e=r.rounding:Ce(e,0,8)),N(new r(t),n,e)};v.toString=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return N(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function pe(n){var e,t,r,i=n.length-1,s="",o=n[0];if(i>0){for(s+=o,e=1;e<i;e++)r=n[e]+"",t=O-r.length,t&&(s+=pt(t)),s+=r;o=n[e],r=o+"",t=O-r.length,t&&(s+=pt(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Ce(n,e,t){if(n!==~~n||n<e||n>t)throw Error(gt+n)}function on(n,e,t,r){var i,s,o,a;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=O,i=0):(i=Math.ceil((e+1)/O),e%=O),s=le(10,O-e),a=n[i]%s|0,r==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==s||t>3&&a+1==s/2)&&(n[i+1]/s/100|0)==le(10,e-2)-1||(a==s/2||a==0)&&(n[i+1]/s/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(r||t<4)&&a==9999||!r&&t>3&&a==4999):o=((r||t<4)&&a+1==s||!r&&t>3&&a+1==s/2)&&(n[i+1]/s/1e3|0)==le(10,e-3)-1,o}function xi(n,e,t){for(var r,i=[0],s,o=0,a=n.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=to.indexOf(n.charAt(o++)),r=0;r<i.length;r++)i[r]>t-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function Bd(n,e){var t,r,i;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),i=(1/Ni(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),n.precision+=t,e=gr(n,1,e.times(i),new n(1));for(var s=t;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}var J=(function(){function n(r,i,s){var o,a=0,l=r.length;for(r=r.slice();l--;)o=r[l]*i+a,r[l]=o%s|0,a=o/s|0;return a&&r.unshift(a),r}function e(r,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(r[a]!=i[a]){l=r[a]>i[a]?1:-1;break}return l}function t(r,i,s,o){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,a,l){var u,c,d,f,h,m,p,b,g,_,w,E,D,y,T,S,I,W,ee,se,he=r.constructor,Z=r.s==i.s?1:-1,ae=r.d,P=i.d;if(!ae||!ae[0]||!P||!P[0])return new he(!r.s||!i.s||(ae?P&&ae[0]==P[0]:!P)?NaN:ae&&ae[0]==0||!P?Z*0:Z/0);for(l?(h=1,c=r.e-i.e):(l=qe,h=O,c=ve(r.e/h)-ve(i.e/h)),ee=P.length,I=ae.length,g=new he(Z),_=g.d=[],d=0;P[d]==(ae[d]||0);d++);if(P[d]>(ae[d]||0)&&c--,s==null?(y=s=he.precision,o=he.rounding):a?y=s+(r.e-i.e)+1:y=s,y<0)_.push(1),m=!0;else{if(y=y/h+2|0,d=0,ee==1){for(f=0,P=P[0],y++;(d<I||f)&&y--;d++)T=f*l+(ae[d]||0),_[d]=T/P|0,f=T%P|0;m=f||d<I}else{for(f=l/(P[0]+1)|0,f>1&&(P=n(P,f,l),ae=n(ae,f,l),ee=P.length,I=ae.length),S=ee,w=ae.slice(0,ee),E=w.length;E<ee;)w[E++]=0;se=P.slice(),se.unshift(0),W=P[0],P[1]>=l/2&&++W;do f=0,u=e(P,w,ee,E),u<0?(D=w[0],ee!=E&&(D=D*l+(w[1]||0)),f=D/W|0,f>1?(f>=l&&(f=l-1),p=n(P,f,l),b=p.length,E=w.length,u=e(p,w,b,E),u==1&&(f--,t(p,ee<b?se:P,b,l))):(f==0&&(u=f=1),p=P.slice()),b=p.length,b<E&&p.unshift(0),t(w,p,E,l),u==-1&&(E=w.length,u=e(P,w,ee,E),u<1&&(f++,t(w,ee<E?se:P,E,l))),E=w.length):u===0&&(f++,w=[0]),_[d++]=f,u&&w[0]?w[E++]=ae[S]||0:(w=[ae[S]],E=1);while((S++<I||w[0]!==void 0)&&y--);m=w[0]!==void 0}_[0]||_.shift()}if(h==1)g.e=c,qa=m;else{for(d=1,f=_[0];f>=10;f/=10)d++;g.e=d+c*h-1,N(g,a?s+g.e+1:s,o,m)}return g}})();function N(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(i=1,a=d[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=O,o=e,c=d[f=0],l=c/le(10,i-o-1)%10|0;else if(f=Math.ceil((s+1)/O),a=d.length,f>=a)if(r){for(;a++<=f;)d.push(0);c=l=0,i=1,s%=O,o=s-O+1}else break e;else{for(c=a=d[f],i=1;a>=10;a/=10)i++;s%=O,o=s-O+i,l=o<0?0:c/le(10,i-o-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(o<0?c:c%le(10,i-o-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(s>0?o>0?c/le(10,i-o):0:d[f-1])%10&1||t==(n.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=n.e+1,d[0]=le(10,(O-e%O)%O),n.e=-e||0):d[0]=n.e=0,n;if(s==0?(d.length=f,a=1,f--):(d.length=f+1,a=le(10,O-s),d[f]=o>0?(c/le(10,i-o)%le(10,o)|0)*a:0),u)for(;;)if(f==0){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(n.e++,d[0]==qe&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=qe)break;d[f--]=0,a=1}for(s=d.length;d[--s]===0;)d.pop()}return R&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function Ye(n,e,t){if(!n.isFinite())return Ya(n);var r,i=n.e,s=pe(n.d),o=s.length;return e?(t&&(r=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+pt(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):i<0?(s="0."+pt(-i-1)+s,t&&(r=t-o)>0&&(s+=pt(r))):i>=o?(s+=pt(i+1-o),t&&(r=t-i-1)>0&&(s=s+"."+pt(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-o)>0&&(i+1===o&&(s+="."),s+=pt(r))),s}function Si(n,e){var t=n[0];for(e*=O;t>=10;t/=10)e++;return e}function Di(n,e,t){if(e>Od)throw R=!0,t&&(n.precision=t),Error(Ua);return N(new n(Ai),e,1,!0)}function Xe(n,e,t){if(e>no)throw Error(Ua);return N(new n(Ti),e,t,!0)}function Wa(n){var e=n.length-1,t=e*O+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function pt(n){for(var e="";n--;)e+="0";return e}function Ga(n,e,t,r){var i,s=new n(1),o=Math.ceil(r/O+4);for(R=!1;;){if(t%2&&(s=s.times(e),ja(s.d,o)&&(i=!0)),t=ve(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}e=e.times(e),ja(e.d,o)}return R=!0,s}function La(n){return n.d[n.d.length-1]&1}function Xa(n,e,t){for(var r,i,s=new n(e[0]),o=0;++o<e.length;){if(i=new n(e[o]),!i.s){s=i;break}r=s.cmp(i),(r===t||r===0&&s.s===t)&&(s=i)}return s}function io(n,e){var t,r,i,s,o,a,l,u=0,c=0,d=0,f=n.constructor,h=f.rounding,m=f.precision;if(!n.d||!n.d[0]||n.e>17)return new f(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(R=!1,l=m):l=e,a=new f(.03125);n.e>-2;)n=n.times(a),d+=5;for(r=Math.log(le(2,d))/Math.LN10*2+5|0,l+=r,t=s=o=new f(1),f.precision=l;;){if(s=N(s.times(n),l,1),t=t.times(++c),a=o.plus(J(s,t,l,1)),pe(a.d).slice(0,l)===pe(o.d).slice(0,l)){for(i=d;i--;)o=N(o.times(o),l,1);if(e==null)if(u<3&&on(o.d,l-r,h,u))f.precision=l+=10,t=s=a=new f(1),c=0,u++;else return N(o,f.precision=m,h,R=!0);else return f.precision=m,o}o=a}}function mt(n,e){var t,r,i,s,o,a,l,u,c,d,f,h=1,m=10,p=n,b=p.d,g=p.constructor,_=g.rounding,w=g.precision;if(p.s<0||!b||!b[0]||!p.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:p.s!=1?NaN:b?0:p);if(e==null?(R=!1,c=w):c=e,g.precision=c+=m,t=pe(b),r=t.charAt(0),Math.abs(s=p.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)p=p.times(n),t=pe(p.d),r=t.charAt(0),h++;s=p.e,r>1?(p=new g("0."+t),s++):p=new g(r+"."+t.slice(1))}else return u=Di(g,c+2,w).times(s+""),p=mt(new g(r+"."+t.slice(1)),c-m).plus(u),g.precision=w,e==null?N(p,w,_,R=!0):p;for(d=p,l=o=p=J(p.minus(1),p.plus(1),c,1),f=N(p.times(p),c,1),i=3;;){if(o=N(o.times(f),c,1),u=l.plus(J(o,new g(i),c,1)),pe(u.d).slice(0,c)===pe(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(Di(g,c+2,w).times(s+""))),l=J(l,new g(h),c,1),e==null)if(on(l.d,c-m,_,a))g.precision=c+=m,u=o=p=J(d.minus(1),d.plus(1),c,1),f=N(p.times(p),c,1),i=a=1;else return N(l,g.precision=w,_,R=!0);else return g.precision=w,l;l=u,i+=2}}function Ya(n){return String(n.s*n.s/0)}function ki(n,e){var t,r,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%O,t<0&&(r+=O),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=O;r<i;)n.d.push(+e.slice(r,r+=O));e=e.slice(r),r=O-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),R&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Rd(n,e){var t,r,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ha.test(e))return ki(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Sd.test(e))t=16,e=e.toLowerCase();else if(Cd.test(e))t=2;else if(Nd.test(e))t=8;else throw Error(gt+e);for(s=e.search(/p/i),s>0?(l=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),s=e.indexOf("."),o=s>=0,r=n.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Ga(r,new r(t),s,s*2)),u=xi(e,t,qe),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new r(n.s*0):(n.e=Si(u,c),n.d=u,R=!1,o&&(n=J(n,i,a*4)),l&&(n=n.times(Math.abs(l)<54?le(2,l):an.pow(2,l))),R=!0,n)}function $d(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:gr(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/Ni(5,t)),e=gr(n,2,e,e);for(var i,s=new n(5),o=new n(16),a=new n(20);t--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function gr(n,e,t,r,i){var s,o,a,l,u=1,c=n.precision,d=Math.ceil(c/O);for(R=!1,l=t.times(t),a=new n(r);;){if(o=J(a.times(l),new n(e++*e++),c,1),a=i?r.plus(o):r.minus(o),r=J(o.times(l),new n(e++*e++),c,1),o=a.plus(r),o.d[d]!==void 0){for(s=d;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=r,r=o,o=s,u++}return R=!0,o.d.length=d+1,o}function Ni(n,e){for(var t=n;--e;)t*=n;return t}function Za(n,e){var t,r=e.s<0,i=Xe(n,n.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return st=r?4:1,e;if(t=e.divToInt(i),t.isZero())st=r?3:2;else{if(e=e.minus(t.times(i)),e.lte(s))return st=La(t)?r?2:3:r?4:1,e;st=La(t)?r?1:4:r?3:2}return e.minus(i).abs()}function so(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor,m=t!==void 0;if(m?(Ce(t,1,bt),r===void 0?r=h.rounding:Ce(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Ya(n);else{for(c=Ye(n),o=c.indexOf("."),m?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=xi(Ye(f),10,i),f.e=f.d.length),d=xi(c,10,i),s=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=m?"0p+0":"0";else{if(o<0?s--:(n=new h(n),n.d=d,n.e=s,n=J(n,f,t,r,0,i),d=n.d,s=n.e,u=qa),o=d[t],a=i/2,u=u||d[t+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(n.s<0?3:2)):o>a||o===a&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>i-1;)d[t]=0,t||(++s,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=to.charAt(d[o]);if(m){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(d=xi(c,i,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=to.charAt(d[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)c="0"+c;c="0."+c}else if(++s>l)for(s-=l;s--;)c+="0";else s<l&&(c=c.slice(0,s)+"."+c.slice(s))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function ja(n,e){if(n.length>e)return n.length=e,!0}function Md(n){return new this(n).abs()}function Pd(n){return new this(n).acos()}function Ld(n){return new this(n).acosh()}function jd(n,e){return new this(n).plus(e)}function Fd(n){return new this(n).asin()}function qd(n){return new this(n).asinh()}function Ud(n){return new this(n).atan()}function Vd(n){return new this(n).atanh()}function zd(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,s=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=Xe(this,s,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?Xe(this,r,i):new this(0),t.s=n.s):!n.d||e.isZero()?(t=Xe(this,s,1).times(.5),t.s=n.s):e.s<0?(this.precision=s,this.rounding=1,t=this.atan(J(n,e,s,1)),e=Xe(this,s,1),this.precision=r,this.rounding=i,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(J(n,e,s,1)),t}function Hd(n){return new this(n).cbrt()}function Wd(n){return N(n=new this(n),n.e+1,2)}function Gd(n,e,t){return new this(n).clamp(e,t)}function Xd(n){if(!n||typeof n!="object")throw Error(Ci+"Object expected");var e,t,r,i=n.defaults===!0,s=["precision",1,bt,"rounding",0,8,"toExpNeg",-mr,0,"toExpPos",0,mr,"maxE",0,mr,"minE",-mr,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(t=s[e],i&&(this[t]=ro[t]),(r=n[t])!==void 0)if(ve(r)===r&&r>=s[e+1]&&r<=s[e+2])this[t]=r;else throw Error(gt+t+": "+r);if(t="crypto",i&&(this[t]=ro[t]),(r=n[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Va);else this[t]=!1;else throw Error(gt+t+": "+r);return this}function Yd(n){return new this(n).cos()}function Zd(n){return new this(n).cosh()}function Ja(n){var e,t,r;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Fa(s)){u.s=s.s,R?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;R?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return ki(u,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),Ha.test(s)?ki(u,s):Rd(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,ki(u,s.toString());throw Error(gt+s)}if(i.prototype=v,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Xd,i.clone=Ja,i.isDecimal=Fa,i.abs=Md,i.acos=Pd,i.acosh=Ld,i.add=jd,i.asin=Fd,i.asinh=qd,i.atan=Ud,i.atanh=Vd,i.atan2=zd,i.cbrt=Hd,i.ceil=Wd,i.clamp=Gd,i.cos=Yd,i.cosh=Zd,i.div=Jd,i.exp=Kd,i.floor=Qd,i.hypot=ef,i.ln=tf,i.log=rf,i.log10=sf,i.log2=nf,i.max=of,i.min=af,i.mod=lf,i.mul=uf,i.pow=cf,i.random=df,i.round=ff,i.sign=hf,i.sin=pf,i.sinh=mf,i.sqrt=gf,i.sub=bf,i.sum=_f,i.tan=wf,i.tanh=yf,i.trunc=vf,n===void 0&&(n={}),n&&n.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)n.hasOwnProperty(t=r[e++])||(n[t]=this[t]);return i.config(n),i}function Jd(n,e){return new this(n).div(e)}function Kd(n){return new this(n).exp()}function Qd(n){return N(n=new this(n),n.e+1,3)}function ef(){var n,e,t=new this(0);for(R=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return R=!0,new this(1/0);t=e}return R=!0,t.sqrt()}function Fa(n){return n instanceof an||n&&n.toStringTag===za||!1}function tf(n){return new this(n).ln()}function rf(n,e){return new this(n).log(e)}function nf(n){return new this(n).log(2)}function sf(n){return new this(n).log(10)}function of(){return Xa(this,arguments,-1)}function af(){return Xa(this,arguments,1)}function lf(n,e){return new this(n).mod(e)}function uf(n,e){return new this(n).mul(e)}function cf(n,e){return new this(n).pow(e)}function df(n){var e,t,r,i,s=0,o=new this(1),a=[];if(n===void 0?n=this.precision:Ce(n,1,bt),r=Math.ceil(n/O),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));s<r;)i=e[s],i>=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);s<r;)i=e[s]+(e[s+1]<<8)+(e[s+2]<<16)+((e[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,s):(a.push(i%1e7),s+=4);s=r/4}else throw Error(Va);else for(;s<r;)a[s++]=Math.random()*1e7|0;for(r=a[--s],n%=O,r&&n&&(i=le(10,O-n),a[s]=(r/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=O)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<O&&(t-=O-r)}return o.e=t,o.d=a,o}function ff(n){return N(n=new this(n),n.e+1,this.rounding)}function hf(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function pf(n){return new this(n).sin()}function mf(n){return new this(n).sinh()}function gf(n){return new this(n).sqrt()}function bf(n,e){return new this(n).sub(e)}function _f(){var n=0,e=arguments,t=new this(e[n]);for(R=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return R=!0,N(t,this.precision,this.rounding)}function wf(n){return new this(n).tan()}function yf(n){return new this(n).tanh()}function vf(n){return N(n=new this(n),n.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var an=v.constructor=Ja(ro);Ai=new an(Ai);Ti=new an(Ti);var Ka=an;var Ef=20,xf=1,Lt=1e6,Qa=1e6,kf=-7,Af=21,Tf=!1,ln="[big.js] ",jt=ln+"Invalid ",Ii=jt+"decimal places",Df=jt+"rounding mode",el=ln+"Division by zero",G={},Ze=void 0,Cf=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function tl(){function n(e){var t=this;if(!(t instanceof n))return e===Ze?tl():new n(e);if(e instanceof n)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(n.strict===!0&&typeof e!="bigint")throw TypeError(jt+"value");e=e===0&&1/e<0?"-0":String(e)}Sf(t,e)}t.constructor=n}return n.prototype=G,n.DP=Ef,n.RM=xf,n.NE=kf,n.PE=Af,n.strict=Tf,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function Sf(n,e){var t,r,i;if(!Cf.test(e))throw Error(jt+"number");for(n.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)n.c=[n.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=i;)n.c[t++]=+e.charAt(r++)}return n}function Ft(n,e,t,r){var i=n.c;if(t===Ze&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Df);if(e<1)r=t===3&&(r||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(r||i[1]!==Ze))),i.length=1,r?(n.e=n.e-e+1,i[0]=1):i[0]=n.e=0;else if(e<i.length){if(r=t===1&&i[e]>=5||t===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==Ze||i[e-1]&1))||t===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++n.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return n}function qt(n,e,t){var r=n.e,i=n.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>s)for(r-=s;r--;)i+="0";else r<s&&(i=i.slice(0,r)+"."+i.slice(r));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return n.s<0&&t?"-"+i:i}G.abs=function(){var n=new this.constructor(this);return n.s=1,n};G.cmp=function(n){var e,t=this,r=t.c,i=(n=new t.constructor(n)).c,s=t.s,o=n.s,a=t.e,l=n.e;if(!r[0]||!i[0])return r[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=i.length)?a:l,s=-1;++s<o;)if(r[s]!=i[s])return r[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};G.div=function(n){var e=this,t=e.constructor,r=e.c,i=(n=new t(n)).c,s=e.s==n.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>Lt)throw Error(Ii);if(!i[0])throw Error(el);if(!r[0])return n.s=s,n.c=[n.e=0],n;var a,l,u,c,d,f=i.slice(),h=a=i.length,m=r.length,p=r.slice(0,a),b=p.length,g=n,_=g.c=[],w=0,E=o+(g.e=e.e-n.e)+1;for(g.s=s,s=E<0?0:E,f.unshift(0);b++<a;)p.push(0);do{for(u=0;u<10;u++){if(a!=(b=p.length))c=a>b?1:-1;else for(d=-1,c=0;++d<a;)if(i[d]!=p[d]){c=i[d]>p[d]?1:-1;break}if(c<0){for(l=b==a?i:f;b;){if(p[--b]<l[b]){for(d=b;d&&!p[--d];)p[d]=9;--p[d],p[b]+=10}p[b]-=l[b]}for(;!p[0];)p.shift()}else break}_[w++]=c?u:++u,p[0]&&c?p[b]=r[h]||0:p=[r[h]]}while((h++<m||p[0]!==Ze)&&s--);return!_[0]&&w!=1&&(_.shift(),g.e--,E--),w>E&&Ft(g,E,t.RM,p[0]!==Ze),g};G.eq=function(n){return this.cmp(n)===0};G.gt=function(n){return this.cmp(n)>0};G.gte=function(n){return this.cmp(n)>-1};G.lt=function(n){return this.cmp(n)<0};G.lte=function(n){return this.cmp(n)<1};G.minus=G.sub=function(n){var e,t,r,i,s=this,o=s.constructor,a=s.s,l=(n=new o(n)).s;if(a!=l)return n.s=-l,s.plus(n);var u=s.c.slice(),c=s.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new o(s):n.s=1,n;if(a=c-f){for((i=a<0)?(a=-a,r=u):(f=c,r=d),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(t=((i=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){i=u[l]<d[l];break}if(i&&(r=u,u=d,d=r,n.s=-n.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]||(n.s=1,u=[f=0]),n.c=u,n.e=f,n};G.mod=function(n){var e,t=this,r=t.constructor,i=t.s,s=(n=new r(n)).s;if(!n.c[0])throw Error(el);return t.s=n.s=1,e=n.cmp(t)==1,t.s=i,n.s=s,e?new r(t):(i=r.DP,s=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=i,r.RM=s,this.minus(t.times(n)))};G.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};G.plus=G.add=function(n){var e,t,r,i=this,s=i.constructor;if(n=new s(n),i.s!=n.s)return n.s=-n.s,i.minus(n);var o=i.e,a=i.c,l=n.e,u=n.c;if(!a[0]||!u[0])return u[0]||(a[0]?n=new s(i):n.s=i.s),n;if(a=a.slice(),e=o-l){for(e>0?(l=o,r=u):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-u.length<0&&(r=u,u=a,a=r),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 n.c=a,n.e=l,n};G.pow=function(n){var e=this,t=new e.constructor("1"),r=t,i=n<0;if(n!==~~n||n<-Qa||n>Qa)throw Error(jt+"exponent");for(i&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return i?t.div(r):r};G.prec=function(n,e){if(n!==~~n||n<1||n>Lt)throw Error(jt+"precision");return Ft(new this.constructor(this),n,e)};G.round=function(n,e){if(n===Ze)n=0;else if(n!==~~n||n<-Lt||n>Lt)throw Error(Ii);return Ft(new this.constructor(this),n+this.e+1,e)};G.sqrt=function(){var n,e,t,r=this,i=r.constructor,s=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(s<0)throw Error(ln+"No square root");s=Math.sqrt(+qt(r,!0,!0)),s===0||s===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),n=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):n=new i(s+""),o=n.e+(i.DP+=4);do t=n,n=a.times(t.plus(r.div(t)));while(t.c.slice(0,o).join("")!==n.c.slice(0,o).join(""));return Ft(n,(i.DP-=4)+n.e+1,i.RM)};G.times=G.mul=function(n){var e,t=this,r=t.constructor,i=t.c,s=(n=new r(n)).c,o=i.length,a=s.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!i[0]||!s[0])return n.c=[n.e=0],n;for(n.e=l+u,o<a&&(e=i,i=s,s=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]+s[l]*i[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};G.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>Lt)throw Error(Ii);for(t=Ft(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return qt(t,!0,!!r)};G.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>Lt)throw Error(Ii);for(t=Ft(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return qt(t,!1,!!r)};G[Symbol.for("nodejs.util.inspect.custom")]=G.toJSON=G.toString=function(){var n=this,e=n.constructor;return qt(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};G.toNumber=function(){var n=+qt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(ln+"Imprecise conversion");return n};G.toPrecision=function(n,e){var t=this,r=t.constructor,i=t.c[0];if(n!==Ze){if(n!==~~n||n<1||n>Lt)throw Error(jt+"precision");for(t=Ft(new r(t),n,e);t.c.length<n;)t.c.push(0)}return qt(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!i)};G.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(ln+"valueOf disallowed");return qt(n,n.e<=e.NE||n.e>=e.PE,!0)};var Nf=tl(),rl=Nf;var bo={};Ad(bo,{DecodeError:()=>Ee,Decoder:()=>Ve,EXT_TIMESTAMP:()=>ao,Encoder:()=>br,ExtData:()=>Ue,ExtensionCodec:()=>_t,decode:()=>dl,decodeArrayStream:()=>pl,decodeAsync:()=>hl,decodeMulti:()=>fl,decodeMultiStream:()=>ml,decodeTimestampExtension:()=>ho,decodeTimestampToTimeSpec:()=>fo,encode:()=>Ri,encodeDateToTimeSpec:()=>uo,encodeTimeSpecToTimestamp:()=>lo,encodeTimestampExtension:()=>co});function nl(n){let e=n.length,t=0,r=0;for(;r<e;){let i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){let s=n.charCodeAt(r);(s&64512)===56320&&(++r,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function If(n,e,t){let r=n.length,i=t,s=0;for(;s<r;){let o=n.charCodeAt(s++);if((o&4294967168)===0){e[i++]=o;continue}else if((o&4294965248)===0)e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<r){let a=n.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128):(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128)}e[i++]=o&63|128}}var Of=new TextEncoder,Bf=50;function Rf(n,e,t){Of.encodeInto(n,e.subarray(t))}function il(n,e,t){n.length>Bf?Rf(n,e,t):If(n,e,t)}var $f=4096;function oo(n,e,t){let r=e,i=r+t,s=[],o="";for(;r<i;){let a=n[r++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=n[r++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=n[r++]&63,u=n[r++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d)}else s.push(a);s.length>=$f&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var Mf=new TextDecoder,Pf=200;function Lf(n,e,t){let r=n.subarray(e,e+t);return Mf.decode(r)}function sl(n,e,t){return t>Pf?Lf(n,e,t):oo(n,e,t)}var Ue=class{type;data;constructor(e,t){this.type=e,this.data=t}};var Ee=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};function ol(n,e,t){let r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Oi(n,e,t){let r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Bi(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function al(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var ao=-1,jf=4294967296-1,Ff=17179869184-1;function lo({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=Ff)if(e===0&&n<=jf){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,r),i}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),Oi(r,4,n),t}}function uo(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function co(n){if(n instanceof Date){let e=uo(n);return lo(e)}else return null}function fo(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),r=e.getUint32(4),i=(t&3)*4294967296+r,s=t>>>2;return{sec:i,nsec:s}}case 12:{let t=Bi(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Ee(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function ho(n){let e=fo(n);return new Date(e.sec*1e3+e.nsec/1e6)}var ll={type:ao,encode:co,decode:ho};var _t=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ll)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let i=this.builtInEncoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=-1-r;return new Ue(o,s)}}}for(let r=0;r<this.encoders.length;r++){let i=this.encoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=r;return new Ue(o,s)}}}return e instanceof Ue?e:null}decode(e,t,r){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Ue(t,e)}};function qf(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function un(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):qf(n)?new Uint8Array(n):Uint8Array.from(n)}var Uf=100,Vf=2048,br=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??_t.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Uf,this.initialBufferSize=e?.initialBufferSize??Vf,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 n({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),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r}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 r=nl(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),il(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,t){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);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 r=un(e);this.writeU8a(r)}encodeArray(e,t){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let r=0;for(let i of t)e[i]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let s of r){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),i=r.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(r);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),ol(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Oi(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 Ri(n,e){return new br(e).encodeSharedRef(n)}function $i(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var zf=16,Hf=16,Mi=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=zf,t=Hf){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,r){let i=this.caches[r-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<r;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)}decode(e,t,r){let i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;let s=oo(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}};var po="array",fn="map_key",cl="map_value",Wf=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new Ee("The type of key must be string or number but "+typeof n)},mo=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=po,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=fn,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===po){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===fn||e.type===cl){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},dn=-1,go=new DataView(new ArrayBuffer(0)),Gf=new Uint8Array(go.buffer);try{go.getInt8(0)}catch(n){if(!(n 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 ul=new RangeError("Insufficient data"),Xf=new Mi,Ve=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=go;bytes=Gf;headByte=dn;stack=new mo;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??_t.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:Xf,this.mapKeyConverter=e?.mapKeyConverter??Wf}clone(){return new n({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=dn,this.stack.reset()}setBuffer(e){let t=un(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===dn&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=un(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:r}=this;return new RangeError(`Extra ${t.byteLength-r} 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,r;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{r=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 r}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${$i(i)} at ${o} (${s} 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 r=t,i=-1;for await(let s of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),r&&(i=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==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 i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,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 i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,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 i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new Ee(`Unrecognized type byte: ${$i(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let i=r.top();if(i.type===po)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,r.release(i);else continue e;else if(i.type===fn){if(t==="__proto__")throw new Ee("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=cl;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,r.release(i);else{i.key=null,i.type=fn;continue e}}return t}}readHeadByte(){return this.headByte===dn&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=dn}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 Ee(`Unrecognized array type byte: ${$i(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Ee(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Ee(`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 Ee(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw ul;let r=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,r,e):i=sl(this.bytes,r,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===fn:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Ee(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw ul;let r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new Ee(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,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=al(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Bi(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 dl(n,e){return new Ve(e).decode(n)}function fl(n,e){return new Ve(e).decodeMulti(n)}function Yf(n){return n[Symbol.asyncIterator]!=null}async function*Zf(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function Pi(n){return Yf(n)?n:Zf(n)}async function hl(n,e){let t=Pi(n);return new Ve(e).decodeAsync(t)}function pl(n,e){let t=Pi(n);return new Ve(e).decodeArrayStream(t)}function ml(n,e){let t=Pi(n);return new Ve(e).decodeStream(t)}var rs=$a(jo(),1),Fo=Ka,qo=rl,et=bo,yu=rs.DOMParser,vu=rs.XMLSerializer;var Eu=et!==null;function xu(){if(!Eu)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var ku=Yp();function Yp(){if(!Eu)return null;let n=new TextEncoder,e=new TextDecoder,t=new et.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let i=At(r);if(i==="D"||i==="H")return null}return et.encodeTimestampExtension(r)},decode:r=>et.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>be(r)?n.encode(r.toString()):null,decode:r=>Tt(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&At(r)==="D"){let i=r.getUTCFullYear(),s=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${i}-${s}-${o}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&At(r)==="H"){let i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${i}:${s}:${o}.${a}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+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:r=>{let i=Uo(r);if(i!==null){let[s,o]=i;return n.encode(`${s}:${o(r)}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=Dt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function Au(n){return xu(),et.encode(n,{extensionCodec:ku})}function Tu(n){return xu(),et.decode(n,{extensionCodec:ku})}function is(n,e=!1){let t=ss(n);if(t===null)return[!1,String(n)];let[r,i,s]=t;return s&&!e?[!1,String(n)]:[!0,`${i(n)}::${r}`]}function Vo(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),i=Dt[r];if(i===void 0)return[!1,n];let[,s]=i;return[!0,s(t)]}function ns(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[i,s]of Object.entries(n))r[i]=ns(s,e,t);return r}return Array.isArray(n)?n.map(r=>ns(r,e,t)):t(n)?e(n):n}function zo(n){let e=ss(n);if(e!==null){let[t,r,i]=e;return i?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(i=>{let[s,o]=zo(i);return o&&(t=!0),s}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[i,s]of Object.entries(n)){let[o,a]=zo(s);a&&(t=!0),r[i]=o}return[r,t]}return[n,!1]}function Zp(n,e=!1){let[t,r]=is(n,e);if(t)return r;let[i,s]=zo(n),o=JSON.stringify(i);return s?`${o}::JS`:o}function Jp(n){return JSON.stringify(n)}function Kp(n){if(!et)throw new Error("@msgpack/msgpack is required for MessagePack support");return et.encode(n)}function F(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:i=!1}={}){if(r)return`${Cu(n)}::QS`;if(t){if(e===null||e==="json")return Jp(n);if(e==="msgpack")return Kp(n);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let s=Zp(n,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Du(n)}</tytx_root>`;if(e==="msgpack")return Au(n);throw new Error(`Unknown transport: ${e}`)}}var Mr,Ho;typeof window<"u"&&window.DOMParser?(Mr=window.DOMParser,Ho=window.XMLSerializer):(Mr=yu,Ho=vu);function Su(n){if(n===null||typeof n!="object"||Array.isArray(n))return!1;let e=Object.keys(n);if(e.length!==1)return!1;let t=n[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function Nu(n,e,t){let r=n.createElement(e),i=t.attrs||{},s=t.value;for(let[o,a]of Object.entries(i))r.setAttribute(o,F(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(Su(o)){let[a]=Object.keys(o),l=o[a],u=Nu(n,a,l);r.appendChild(u)}else{r.textContent=F(s);break}else r.textContent=F(s);return r}function Du(n){if(!Mr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(Su(n)){let[e]=Object.keys(n),t=n[e],r=new Mr().parseFromString("<root/>","text/xml"),i=Nu(r,e,t);return new Ho().serializeToString(i)}else return F(n)}function Wo(n){let e={};for(let r=0;r<n.attributes.length;r++){let i=n.attributes[r];e[i.name]=j(i.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];i.nodeType===1&&t.push(i)}if(t.length>0)if(t.length===1){let r=t[0],i=Wo(r);return{attrs:e,value:{[r.tagName]:i}}}else{let r=[];for(let i of t){let s=Wo(i);r.push({[i.tagName]:s})}return{attrs:e,value:r}}return{attrs:e,value:j(n.textContent)}}function Iu(n){if(!Mr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new Mr().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let s=null;for(let o=0;o<r.childNodes.length;o++)if(r.childNodes[o].nodeType===1){s=r.childNodes[o];break}if(!s)return j(r.textContent);r=s}let i=Wo(r);return{[r.tagName]:i}}function Qp(n){return typeof n=="string"}function em(n){let[e,t]=Vo(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let i;try{i=JSON.parse(r)}catch{return n}return ns(i,tm,Qp)}function tm(n){return n.includes("::")?Vo(n)[1]:n}function rm(n){let e=Iu(n);return typeof e=="string"?j(e):e}function nm(n){return Tu(n)}function j(n,e=null){if(n===null)return null;if(e===null||e==="json"){let t=n;return e==="json"&&n.startsWith('"')&&n.endsWith('"')&&(t=n.slice(1,-1)),em(t)}else{if(e==="xml")return rm(n);if(e==="msgpack")return nm(n);throw new Error(`Unknown transport: ${e}`)}}function Cu(n){if(Array.isArray(n))return n.map(e=>String(e)).join("&");if(n!==null&&typeof n=="object"){let e=[];for(let[t,r]of Object.entries(n)){let[i,s]=is(r,!0);i?e.push(`${t}=${s}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function Ou(n){if(!n)return[];let e=n.split("&"),t=e.map(o=>o.includes("=")),r=t.every(Boolean),i=!t.some(Boolean);if(!r&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>j(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=j(u)}return s}var Ru=Fo||qo||Number,$u=Fo?"decimal.js":qo?"big.js":"number";function Xo(){return $u}function Tt(n){return new Ru(n)}function be(n){return $u==="number"?!1:n instanceof Ru}function At(n){let e=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,t=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function im(n){return n.toString()}function sm(n){let e=n.getUTCFullYear(),t=String(n.getUTCMonth()+1).padStart(2,"0"),r=String(n.getUTCDate()).padStart(2,"0");return`${e}-${t}-${r}`}function om(n){return n.toISOString()}function am(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),i=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${i}`}function lm(n){return n?"true":"false"}function um(n){return n.toString()}function cm(n){return n.toString()}function dm(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode.apply(null,n.subarray(t,t+32768));return btoa(e)}var os=[],Go=new Map;function Uo(n){if(n===null||typeof n!="object")return null;for(let e=Object.getPrototypeOf(n);e!==null;e=Object.getPrototypeOf(e))for(let[t,r,i,s]of os)if(t.prototype===e)return[r,i,s];return null}function ss(n){if(n===null)return["NN",()=>"",!0];if(be(n))return["N",im,!1];if(n instanceof Uint8Array)return["RAW",dm,!1];if(n instanceof Date){let e=At(n);return e==="D"?["D",sm,!1]:e==="H"?["H",am,!1]:["DHZ",om,!1]}return typeof n=="boolean"?["B",lm,!0]:typeof n=="number"?Number.isInteger(n)?["L",um,!0]:["R",cm,!0]:Uo(n)}function fm(n){return Tt(n)}function hm(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function Bu(n){return new Date(n)}function pm(n){let[e,t,r]=n.split(":"),[i,s]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(i),Number(s||0)))}function mm(n){return n.toLowerCase()==="true"}function gm(n){return parseInt(n,10)}function bm(n){return parseFloat(n)}function _m(n){return n}function wm(n){return null}var ym=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function vm(n){if(!ym.test(n))throw new Error(`RAW payload is not standard padded base64: '${n}'`);let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function Em(n){return Ou(n)}var xm=/^[A-Z]+$/,Dt={N:[Object,fm],D:[Date,hm],DH:[Date,Bu],DHZ:[Date,Bu],H:[Date,pm],L:[Number,gm],R:[Number,bm],T:[String,_m],B:[Boolean,mm],QS:[Object,Em],NN:[null,wm],RAW:[Uint8Array,vm]};function On(n){return Object.hasOwn(Dt,n)?Dt[n][0]:null}function Yo(n,e,t,r,i=!1){if(typeof e!="string"||!xm.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=Dt[e];if(s!==void 0&&s[0]!==n){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}os=os.filter(([o])=>o!==n),os.push([n,e,t,i]),Dt[e]=[n,r]}function Wt(n,e){Go.set(n,e)}function je(n){return Go.has(n)?Go.get(n):{}}function H(n){if(typeof n!="string"||!["^","="].includes(n[0])||n.startsWith("=="))return null;let e=n.indexOf(":");if(e<0)return null;let t=n[e+1]==="=";return{pointer:n.slice(0,e),expression:t,body:n.slice(e+(t?2:1))}}var Mu=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Gt(n,e){let t="",r=!1;for(let i=0;i<n.length;){if(n[i]!=="{"&&n[i]!=="}"){t+=n[i++];continue}let s=n.slice(i).match(Mu);if(!s)throw new SyntaxError("Invalid pointer template placeholder");let o=s[1]??"",a=o.startsWith("?"),l=e(a?o.slice(1):o);l==null||l===""&&!a?r=!0:t+=String(l),i+=s[0].length}return r?null:t}function Bn(n){let e=[],t=new Set,r="",i=!0;for(let s=0;s<n.length;){let o=s,a=n[s];if(a==='"'||a==="'"||a==="`"){for(s++;s<n.length;){if(n[s]==="\\"){s+=2;continue}if(n[s++]===a)break}r+=n.slice(o,s),i=!1;continue}if(n.startsWith("//",s)){s=n.indexOf(`
|
|
31
|
+
`,s),s<0&&(s=n.length),r+=n.slice(o,s);continue}if(n.startsWith("/*",s)){let c=n.indexOf("*/",s+2);s=c<0?n.length:c+2,r+=n.slice(o,s);continue}if(a==="/"&&i){let c=!1;for(s++;s<n.length;){let d=n[s++];if(d==="\\"){s++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[s]??"")&&s<n.length;)s++;r+=n.slice(o,s),i=!1;continue}let l=a==="{"?n.slice(s).match(Mu):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");r+=`_pointerValues[${e.length}]`,e.push(c),s+=l[0].length,i=!1;continue}let u=n.slice(s).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],s+=u[0].length,i=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=a,s++,/\s/.test(a)||(i=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:r,slots:e,identifiers:t}}function Pu(n,e,t=()=>null){let r=new Map,i=[],s=o=>{if(r.has(o))return r.get(o);if(!n.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(i.includes(o))throw new Error(`Cyclic attribute dependency: ${[...i,o].join(" -> ")}`);i.push(o);try{let a=n.get(o),l=typeof o=="string"?H(a):null,u=e.get(o);if(l){let c=d=>d?s(d):e.get(o);if(l.expression){let d=Bn(l.body);u=t(o,a,d,d.slots.map(c))}else u=Gt(l.body,c),e.get(o)==null&&(u=null)}return r.set(o,u),u}finally{i.pop()}};return new Map([...n.keys()].map(o=>[o,s(o)]))}function tt(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,i=[],s=o=>{let a=H(o);if(!a)return;let l=[];a.expression?l.push(...Bn(a.body).slots):Gt(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(i.includes(u))throw new Error(`Cyclic attribute dependency: ${[...i,u].join(" -> ")}`);r.has(u)||(i.push(u),s(t.get(u)),i.pop(),r.add(u))}};return s(e),r}var Lu={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 Am(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?Lu[e]||null:e}function Tm(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function Dm(n){return new Promise(e=>setTimeout(e,n))}async function Cm(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=r*1e3;for(let u=0;u<t;u++)try{let c=n();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&Tm(c,o)){let d=l;s&&(d*=1+Math.random()*.1),await Dm(d),l*=i}else throw c}throw a}var Q=class n{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let r={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(r,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=r.cacheTime,this._readOnly=r.readOnly,this._asBag=r.asBag,this._retryPolicy=r.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(r))i.has(s)||(this._kw[s]=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,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let i={...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)||(i[c]=d)}Object.assign(i,r);let s=this._computeEffectiveFingerprint(i);if(s===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=s;let o=Am(this),a=()=>this.load(i);if(o)return Cm(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=n._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){n._BagClass=e}load(e){return null}};Q._BagClass=null;var Ct=class extends Q{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 ze=class n{constructor(e,t,r=null,i=null,s=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,i&&this.setAttr(i,!1,!0,l),r!==null&&this.setValue(r,!1),s&&(this.resolver=s)}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,r={}){if(t!==null){let i=j(`${t}::QS`);if(Array.isArray(i)){let s=i.length?i:Object.keys(this._attr),o=s.map(l=>{let u=this.getAttr(l);return!e&&u instanceof Q?u.resolve():u}),a=l=>i.length===0?Object.fromEntries(s.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");r={...r,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,i=null,s=!0,o=null,a=!1){e instanceof Q?(this.resolver=e,e=null):e instanceof n&&(r=r||{},Object.assign(r,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(r!==null){let h={...this._attr};this.setAttr(r,!1,i,s);let m=this._buildAttrDiff(h,this._attr);d=Object.keys(m).length>0?m: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 m of Object.values(this._nodeSubscribers))m({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 n))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 r=null;e.resolver&&(r=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),r._node=null,r._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==t||o!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};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,i,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 r={},i=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of i){let o=s in e?e[s]:null,a=s in t?t[s]:null;o!==a&&(r[s]={old:o,new:a})}return r}setAttr(e=null,t=!0,r=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?Object.assign(this._attr,s):this._attr={...s},i)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 r of t.split(","))delete this._attr[r.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 r=this;if(t===null)for(;r&&!(e in r._attr);)r=r.parentNode;else for(;r&&r._attr[e]!==t;)r=r.parentNode;return r}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof n)||this.label!==e.label)return!1;let t=Object.keys(this._attr),r=Object.keys(e._attr);if(t.length!==r.length)return!1;for(let i of t)if(this._attr[i]!==e._attr[i])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),r=Object.keys(e._attr);return t.length!==r.length||t.some(i=>this._attr[i]!==e._attr[i])?`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 Rn=class n{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(r=>r.label===e);let t=e.match(/^#(\d+)$/);if(t){let r=parseInt(t[1],10);return r<this._list.length?r:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,r,i]=t,s=i.includes("::")?j(i):i;return r?this._list.findIndex(o=>o.getAttr(r)===s):this._list.findIndex(o=>o._value===s)}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 r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s+1,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i+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 r=parseInt(e,10);if(r<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return r}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,r=">",i=null,s=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 p=h.split("&");if(p.length===1)i={[p[0]]:t};else{if(!Array.isArray(t)||t.length!==p.length)throw new Error("Wrong attributes assignment");i={};for(let b=0;b<p.length;b++)i[p[b]]=t[b]}t=null}let m=this._dict[e];if(m)f&&(m.nodeTag=f),o!==null&&(o===!1?m.resolver=null:m.resolver=o),h?m.setAttr(i,c,!0,l):m.setValue(t,c,i,a,l,u,d);else{let p=s&&s.nodeClass?s.nodeClass:ze;m=new p(s,e,h?null:t,i,o,f,null,l);let b=this._parsePosition(r);this._dict[e]=m,this._list.splice(b,0,m),c&&s&&s.backref&&s._onNodeInserted(m,b,null,u,d)}return d&&m.setValue(null,!1),m}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let r=this._list.indexOf(t);return r>=0&&this._list.splice(r,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,r=!0){if(t<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||t>=this._list.length)return;let s=this._list[t].label;if(i.length>1){let o=[...i].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),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof n)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let r=this._list[t],i=e._list[t];if(!r.isEqual(i))return!1}return!0}};var Uu=$a(jo(),1);var Zo="::RSLV:",Sm=new Map,Nm=new Map,as=new WeakMap,oe=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},$n=class extends Q{constructor(e){super({asBag:!1}),as.set(this,e)}get payload(){return as.get(this)}load(){throw new oe("This resolver is opaque; local execution is unavailable")}};function ju(n){if(!n||typeof n!="object"||Array.isArray(n)||typeof n.resolver_module!="string"||typeof n.resolver_class!="string"||!Array.isArray(n.args??[])||!n.kwargs||typeof n.kwargs!="object"||Array.isArray(n.kwargs))throw new oe("Invalid resolver description")}function Fu(n,e=new Set){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n)||!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new oe("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))Fu(t,e);e.delete(n)}}function Mn(n){if(as.has(n))return as.get(n);let e=Nm.get(n.constructor);if(!e)throw new oe(`Unregistered resolver: ${n.constructor.name}`);let t=e.encode(n),r={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return ju(r),Fu(r),Zo+JSON.stringify(r)}function ls(n){if(typeof n!="string"||!n.startsWith(Zo))return null;let e=n.slice(Zo.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new $n(n);let t;try{t=JSON.parse(e)}catch{throw new oe("Invalid resolver JSON or signed token")}ju(t);let r=Sm.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new $n(n);let i=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(i instanceof r.cls))throw new oe("Resolver decoder returned an incompatible instance");return i}function us(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof Q?Mn(t):t]))}function Jo(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,ls(t)??t]))}var He="__cls";function Pr(n,e){return n!==null&&n.tytxSuffix===e?n:On(e)}function Im(n){let e=n.tytxSuffix,t=Object.entries(je(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new oe(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new oe(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Ko(n,e){let t=je(n);if(!Object.hasOwn(t,e))throw new oe(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function Qo(n,e){return n===e?null:Im(n)}function*Vu(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let i=t.getValue(!0);!t.resolver&&i instanceof x&&(yield*Vu(i,r))}}function Om(n){let e=n.toISOString(),t=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,r=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;if(r&&!t)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return t&&!r?i.slice(i.indexOf("T")+1):i}function Lr(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function St(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(St):Lr(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,St(t)])):n}function ea(n){if(!Lr(n))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=n;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var qu=!1,x=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new Rn,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},ea(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 ze}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=[],r=e;for(;r!==null;){if(r.parentBag===this)return t.push(r.label),t.reverse(),t.join(".");t.push(r.label),r=r.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,r;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),r=e.split(".").filter(i=>i)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!0){let[i,s]=this._htraverseBefore(e);if(i===null)return[null,null];if(s.length===0)return[i,""];for(;s.length>1&&i instanceof n;){let o=s[0];if(o==="#parent"){if(i.parent===null||i.parent===void 0)break;s.shift(),i=i.parent;continue}let a=i._nodes.get(o);if(!a)break;let l=a.getValue(r);if(l instanceof n)s.shift(),i=l;else if(t){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!t)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new Pn("Not existing index in #n syntax");let a=i.createChildBag();i._nodes.set(o,a,">",null,i,null,!1,!0,"autocreate"),i=a}return[i,s[0]]}get(e,t=null,r=!0,i={}){if(!e)return this;if(e==="#parent")return this.parent;let s=null;e.includes("?")&&([e,s]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(r,s,i):t}getItem(e,t=null,r=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,r);return s instanceof n?s.get(o,t,r,i):t}setItem(e,t,r=null,i=">",s=!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,i,r,f,c,s,o,a,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let i=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(i,r,null,t),i}return null}pop(e,t=null,r=null){let i=this.popNode(e,r);return i?i.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,i]=this._htraverse(e,!1,!0);if(!r||!i)return null;let s=r._nodes.get(i);if(!s)return null;try{return r._pop(i,t)}finally{s.parentBag===r&&r._nodes._dict[s.label]!==s&&(s.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,r=!1,i=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[s,o]=this._htraverse(e,r,t);if(s instanceof n&&o){let a=s._nodes.get(o);if(a)return a;if(r)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,t=null){let r=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!r){this._nodes._parentBag=this;for(let i of this)i.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 n&&t.clearBackref()}}}_onNodeChanged(e,t,r,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:i,attrs_diff:s,evt:r,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,i,s,o,a)}_onNodeInserted(e,t,r=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof n&&a.setBackref(e,o),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],i,s)}_onNodeDeleted(e,t,r=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:r,ind:t,evt:"del",reason:i});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],i))}_subscribe(e,t,r){r!=null&&(t[e]=r)}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:r=null,insert:i=null,delete:s=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||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:r=!1,insert:i=!1,delete:s=!1,any:o=!1}=t;(r||o)&&delete this._updSubscribers[e],(i||o)&&delete this._insSubscribers[e],(s||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,r=!0){let i=n.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let i=this.getNode(e);return i?i.getAttr(t,r):r}delAttr(e=null,...t){let r=this.getNode(e);r&&r.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 r of this._nodes){let i=r.value;if(i instanceof n){if(i.getItem(e)===t)return r}else if(i&&i.get&&i.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,i=!1){let s=t===void 0,o=r&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=r&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||d==o)return c}if(c._value instanceof n)if(i){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 r of this._nodes){if(r._resolver!==null)return!1;let i=r.getValue(!0);if(i!=null&&!(e&&i===0)&&!(t&&i===""))return!1}return!0}query(e=null,t=null,r=!1,i=!1,s=!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,m]=e.split(":");u=this.getItem(h),e=m}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,m,p,b,g)=>{if(m==="#k")return h.label;if(m==="#p")return p;if(m==="#n")return h;if(typeof m=="function")return m(h);if(m==="#v"){let _=g();return b&&_ instanceof n?null:_}else if(m.startsWith("#v.")){let _=m.split(".").slice(1).join("."),w=g();return w&&w.getItem?w.getItem(_):null}else{if(m==="#__v")return h.getValue(!0);if(m.startsWith("#a")){let _=m.includes(".")?m.split(".").slice(1).join("."):null;return h.getAttr(_)}else{let _=g();return _&&_.getItem?_.getItem(m):null}}};function*f(){let h=0;function*m(p,b){for(let g of p._nodes){let _=b?`${b}.${g.label}`:g.label,w=!1,E,D=()=>(w||(E=g.getValue(l),w=!0),E);if((s&&o||(D()instanceof n?o:s))&&(t===null||t(g))&&(yield c.length===1?d(g,c[0],_,i,D):c.map(T=>d(g,T,_,i,D)),h++,a!==null&&h>=a))return;if(i){let T=D();if(T instanceof n&&(yield*m(T,_),a!==null&&h>=a))return}}}yield*m(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,i)=>{for(let s of r._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof n?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,r=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),r=t,t=null);let i=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){if(!i||i.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let s=[...i];if(s.length&&Array.isArray(s[0])){let o=s[0].length,a=[];for(let l=0;l<o;l++)a.push(s.map(u=>u[l]));return a}return[s]}return[...i]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",i=e.map(s=>`${r}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",t=!1,r=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(r!=null&&typeof r!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let i=s=>{let o=0,a=!1;for(let l of this.query(s,r)){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(s=>i(s.trim())):i(e)}sort(e="#k:a"){let t=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],r=(i,s)=>i[0]!==s[0]?i[0]-s[0]:i[1]<s[1]?-1:i[1]>s[1]?1:0;if(typeof e=="function")this._nodes._list.sort((i,s)=>{let o=e(i),a=e(s);return o<a?-1:o>a?1:0});else{let i=e.split(",");i.reverse();for(let s of i){let o,a;s.includes(":")?[o,a]=s.split(":",2):(o=s,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 n?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=r(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof n?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let r=this.getNode(e);return r===null?!1:t===null?!0:t.split("&").every(i=>i in r.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 r=this.getNode(e);r||(this.setItem(e,null),r=this.getNode(e)),r.resolver=t}setCallbackItem(e,t,r={}){let i=new Ct({callback:t,...r});this.setResolver(e,i)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!1,i=!1){let s={};for(let o of this._nodes){let a=o.value;if(i&&a==null)continue;let l=o.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),r&&a instanceof n&&(a=n.prototype.asDict.call(a,e,t,r,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,t=null){let r=this.getNode(e);return r?r.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let r of this._nodes){let i=r.getValue(!e);i instanceof n&&(i=i.deepcopy(e));let s=new t.nodeClass(t,r.label,i);s.setAttr({...r.attr},!1,!1,!1),s.nodeTag=r.nodeTag,s.xmlTag=r.xmlTag,t._nodes._list.push(s),t._nodes._dict[s.label]=s}return t}update(e,t=null,r=null,i=!1){if(!(e instanceof n)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,r,!1,r!==!1)}return}for(let s of[...e]){let o=s.label,a=t==="static"?s.resolver:null,l=a?null:s.getValue(),u=s.attr.__replace;delete s.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(s.attr,r===null?!0:r,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,r===null?!0:r,null,null,!1,r);else{s.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,i):(!i||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(o,a||l,s.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=s.nodeTag,d.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let r=new this.nodeClass(this,t.label);r.replace(t),r.nodeTag=t.nodeTag,r.xmlTag=t.xmlTag,this._nodes._list.push(r),this._nodes._dict[r.label]=r}}_appendLiteral(e,t,r=null,i=null,s=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,r,i,s,null,!1);return t instanceof Q?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let r=ea(t);if(e!=null&&!Lr(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let i=this.createChildBag(),s=new Set,o=(a,l,u)=>{if(s.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);s.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 m=h;r&&(Lr(m)||Array.isArray(m))&&(m=this.createChildBag(),o(m,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,m)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof n))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 r of this._nodes){r.parentBag=null;let i=r.getValue(!0);i instanceof n&&i.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 r of this._nodes)r.parentBag=this;for(let r of e._nodes)r._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:r=!1,kwargs:i={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let s=(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&&r){let f=u.getValue(t);if(f instanceof n){let h=s(f,c);if(h)return h}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof n&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let r of this._nodes){let i=t?`${t}.${r.label}`:r.label;yield[i,r];let s=r.getValue(e);s instanceof n&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of Vu(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=Mn(a.resolver);else if(d instanceof n){let b=d.constructor,g=b.tytxSuffix;s.set(u,b),h=Qo(b,Pr(s.get(c),g)),f=`::${g}`}else d===null?f="::NN":f=St(d);if(a.attr&&Object.hasOwn(a.attr,He))throw new oe(`node '${o}': the attribute '${He}' is reserved for the Bag class name`);let m=us(St(a.attr));h!==null&&(m[He]=h);let p=a.nodeTag;t?(yield[l.length?r[c]:null,a.label,p,f,m],d instanceof n&&(r[u]=i,e[i]=o,i++)):yield[l,a.label,p,f,m]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),i=this.constructor.tytxSuffix;if(e==="json")return`${r}::${i}`;if(e==="msgpack")return Ri(new Ue(4,new TextEncoder().encode(`${i}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let s={};t={rows:[...this._nodeFlattener(s)],paths:s}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,i=Qo(r,Pr(null,r.tytxSuffix));return i!==null&&(t[He]=i),t.rows=t.rows.map(([s,o,a,l,u])=>[St(s),St(o),St(a),l,u]),t.paths&&(t.paths=St(t.paths)),F(t)}static fromTytx(e,t="json",r={}){if(Lr(t)&&(r=t,t="json"),ea(r),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 i=j(e,t==="json"?null:t);if(i instanceof n)return i;if(!Lr(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Pr(null,t));let r=j(e);if(!r||!Array.isArray(r.rows))throw new oe("Invalid TYTX Bag: expected rows");let i=r.paths,s=i!=null,o=Object.hasOwn(r,He)?Ko(t,r[He]):Pr(null,t),a=new o,l=new Map([["[]",a]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new oe("Invalid TYTX Bag row");let[c,d,f,h,m]=u,p=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new oe(`Unknown TYTX parent reference: ${c}`);p=c===null?"":i[c]}if(typeof p=="string"&&(p=p?p.split("."):[]),!Array.isArray(p))throw new oe("Invalid TYTX parent path");let b=JSON.stringify(p);if(!l.has(b))throw new oe(`Missing or undecodable TYTX parent branch: ${p}`);let g=l.get(b),_=JSON.stringify([...p,d]),w=h,E=ls(w),D=Jo(m),y=Object.hasOwn(D,He)?D[He]:null;if(delete D[He],w instanceof n){let S=w.constructor.tytxSuffix,I=y!==null?Ko(S,y):Pr(g.constructor,S);w=new I,l.set(_,w)}else if(y!==null)throw new oe(`node '${_}': the attribute '${He}' is reserved for the Bag class name of a branch`);let T=g._appendLiteral(d,E?null:w,D,E);T.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,t);return i===!0?o=`<?xml version='1.0' encoding='${r}'?>
|
|
32
32
|
${o}`:typeof i=="string"&&(o=`${i}
|
|
33
33
|
${o}`),o}_bagToXml(e=null,t=!1,r=0){let i=[];for(let s of this._nodes)i.push((t?" ".repeat(r):"")+this._nodeToXml(s,e,t,r));return i.join(t?`
|
|
34
|
-
`:"")}_nodeToXml(e,t=null,r=!1,i=0){let s=e.xmlTag||e.nodeTag||e.label,o=this._sanitizeTag(s),a=[];if(o!==s&&a.push(`_tag="${this._escapeAttr(s)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(
|
|
34
|
+
`:"")}_nodeToXml(e,t=null,r=!1,i=0){let s=e.xmlTag||e.nodeTag||e.label,o=this._sanitizeTag(s),a=[];if(o!==s&&a.push(`_tag="${this._escapeAttr(s)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(Mn(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(us(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"){r=r&&e.attr?.["xml:space"]!=="preserve";let f=u._bagToXml(t,r,i+1);return f?r?`<${o}${l}>
|
|
35
35
|
${f}
|
|
36
|
-
${" ".repeat(i)}</${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())?
|
|
36
|
+
${" ".repeat(i)}</${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())?Om(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,"&").replace(/</g,"<").replace(/>/g,">")}_escapeAttr(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}static fromXml(e,t={}){let{tagAttribute:r=null}=t,i;if(typeof DOMParser<"u"){i=new DOMParser().parseFromString(e,"application/xml");let o=i.querySelector("parsererror");if(o)throw new Error(`XML parse error: ${o.textContent}`)}else i=new Uu.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,r)}static _xmlElementToBag(e,t=null){let r=new this,i=Array.from(e.childNodes).filter(s=>s.nodeType===1);for(let s of i){let o=s.tagName,a={};for(let p=0;p<s.attributes.length;p++){let b=s.attributes[p];a[b.name]=b.value}let l=ls(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,Jo(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(;r.getNode(c);)c=`${d}_${f++}`;let h=Array.from(s.childNodes).filter(p=>p.nodeType===1),m;if(h.length>0||u){let p=this._xmlElementToBag(s,t);m=r.setItem(c,p,Object.keys(a).length>0?a:null)}else{let p=s.textContent||"";m=r.setItem(c,p,Object.keys(a).length>0?a:null)}l&&(m.resolver=l),m.xmlTag=o}return r}static async fromUrl(e,t={}){let{timeout:r=30}=t,i={};r&&(i.signal=AbortSignal.timeout(r*1e3));let s=await fetch(e,i),o=s.headers.get("content-type")||"",a=await s.text();if(o.includes("json"))return n.fromTytx(a);if(o.includes("xml"))return n.fromXml(a);let l=a.trim();if(l.startsWith("<"))return n.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return n.fromTytx(a);throw new Pn(`Unsupported content-type: ${o}`)}toJson(e=!0){let t=[];for(let r of this._nodes)t.push(this._nodeToJsonDict(r,e));return e?F(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let r=e.resolver?null:e.getValue(!0);if(r&&typeof r._nodeToJsonDict=="function"){let s=[];for(let o of r._nodes)s.push(r._nodeToJsonDict(o,t));r=s}let i={label:e.label,value:r,attr:us(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Mn(e.resolver)),i}static fromJson(e,t={}){return qu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),qu=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,r="",i=!0){t===null&&(t=new Map);let s=[],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(g=>`${g}=${JSON.stringify(d[g])}`).join(", ")+"]");let m=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",p=r+(u?" ":"\u2502 ");if(c instanceof n){let b=l,g=c.backref?"(*)":"";if(t.has(b))s.push(`${r}${m}${l.label}${g}${f} \u2192 (circular ref)`);else{t.set(b,l.label),s.push(`${r}${m}${l.label}${g}${f}`);let _=c.toStringTree(e,t,p,u);_&&s.push(_)}}else{let b;if(c===null)b="null";else if(c===void 0)b="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let g=new TextDecoder("utf-8",{fatal:!1}),_=c instanceof ArrayBuffer?new Uint8Array(c):c;b=g.decode(_)}else typeof c=="string"?c.length>50?b=JSON.stringify(c.slice(0,47)+"..."):b=JSON.stringify(c):b=String(c);s.push(`${r}${m}${l.label}: ${b}${f}`)}}return s.join(`
|
|
37
37
|
`)}toString(e=!0,t=null,r=""){t||(t=new Set);let i=[],s=[...this._nodes];for(let o=0;o<s.length;o++){let a=s[o],l=o===s.length-1,u=a.getValue(e),c="",d=a.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([p,b])=>`${p}=${JSON.stringify(b)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=r+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let m=a;if(t.has(m))i.push(`${r}${f}${a.label}${c} \u2192 (circular ref)`);else{t.add(m),i.push(`${r}${f}${a.label}${c}`);let p=u.toString(e,t,h);p&&i.push(p)}}else{let m;u==null?m="null":typeof u=="string"&&u.length>50?m=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?m=JSON.stringify(u):m=String(u),i.push(`${r}${f}${a.label}: ${m}${c}`)}}return i.join(`
|
|
38
|
-
`)}},$n=class extends Error{constructor(e){super(e),this.name="BagException"}};K.registerBagClass(x);Ho(x,"X",n=>n._toTytxPayload(),n=>x._fromTytxPayload(n));Gt(x.tytxSuffix,{...je(x.tytxSuffix),Bag:x});var Fu=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 qu(n){return n.endsWith("_")&&Fu.has(n.slice(0,-1))?n.slice(0,-1):n}function Uu(n){let e=qu(n);return e!==n?e:n.startsWith("_")&&Fu.has(n.slice(1))?n.slice(1):n}function Mn(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let i=e||n;if(!i)return i;if(i=qu(i),t&&!e){let s=`${r}_`;i.startsWith(s)&&(i=i.slice(s.length)),i=`${t}:${i}`}return i}var Pr=Symbol("value"),Xt=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function _e(n){return Object.entries(n||{}).filter(([e])=>!Xt.has(e)).map(([e,t])=>[Uu(e),t])}var Ae=class extends ze{constructor(e,t,r=null,i=null,s=null,o=null,a=null){super(e,t,r,i,s,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")||{},r=e.split(",").map(i=>i.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(i=>t[i]!==void 0?t[i]: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,r]of Object.entries(this.getAttr()||{}))this.pointerType(r)==="^"&&e.push([t,r.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return _e(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(Pr,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(H(e)?.pointer??e).slice(1));let r=null;return e.includes("?")&&([e,r]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),r):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,r))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");i!=null&&(e=e==="."?i:i+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let i of e.split("."))if(i==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(i);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),i=r.indexOf("."),s=i===-1?r:r.slice(0,i),o=i===-1?"":r.slice(i+1),a;if(s==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(s==="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",s),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,r){let i=this;for(;i!=null;){let o=i.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return i;i=i.parentNode}let s=e?"FORM":"ANCHOR";throw new Error(`#${s}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let i=this.data,s=this.absDatapath(e);return r&&i.getItem(s)==null&&i.setItem(s,t),i.getItem(s,t)}setRelativeData(e,t,{attributes:r=null,fired:i=!1,reason:s=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,r,">",!1,!0,s===null?!0:s,i)}fireEvent(e,t=!0,{attributes:r=null,reason:i=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:i})}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})}},A=class n extends x{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return Ae}_setBuilderItem(e,t,r,...i){let s=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(r,...i)}catch(a){if(this.node(r)==null&&s)for(let[l,u]of s)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[r,i]of t)r._builder=i;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,i=(s,o)=>{if(r.has(s))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(s),t.push([s,o]);for(let a of s.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 n&&i(c,l)}};return i(this,e),t}};if((je(A.tytxSuffix).SourceBag??A)!==A)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Gt(A.tytxSuffix,{...je(A.tytxSuffix),SourceBag:A});function Om(n){if(n.length===0)return{value:null,attrs:{}};let e=n[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:n[1]||{}}}var Bm=new Set(["then","toJSON"]),zu=new WeakMap;function J(n){return zu.get(n)||n}function Ln(n){if(n==null)return n;n=J(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function Hu(n,e){let t=e instanceof x,r=new Proxy(e,{get(i,s){if(typeof s=="symbol"||s.startsWith("_")||Bm.has(s))return Reflect.get(i,s,i);let o=n.schemaTag(s);if(t&&o)return Vu(n,i,o,t);if(s in i){let l=Reflect.get(i,s,i);return typeof l=="function"?l.bind(i):l}if(o)return Vu(n,i,o,t);let a=n.containerMethod(s);if(a)return(...l)=>n[a](n.wrapSource(i),...l)}});return zu.set(r,e),r}function Vu(n,e,t,r){return(...i)=>{let{value:s,attrs:o}=Om(i),a=r?n.bagCall(e,t,s,o):n.commandOnNode(e,t,s,o);return a.builder.wrapSource(a)}}function Jo(n,e,{transport:t="json"}={}){let r=j(n,t==="json"?null:t);if(!(r instanceof A))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Gu=/^[A-Za-z_][A-Za-z0-9_]*$/,Rm=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),$m=new Set(["framework","value","attribute"]),Mm=new Map([["builtins.str",n=>typeof n=="string"],["builtins.int",n=>Number.isInteger(n)],["builtins.float",n=>typeof n=="number"&&Number.isFinite(n)],["builtins.bool",n=>typeof n=="boolean"],["builtins.list",n=>Array.isArray(n)],["builtins.dict",n=>n!==null&&typeof n=="object"&&!Array.isArray(n)],["builtins.tuple",n=>Array.isArray(n)],["builtins.set",n=>Array.isArray(n)||n instanceof Set],["builtins.NoneType",n=>n===null],["builtins.object",n=>!0]]);function Zt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function C(n,e){throw new TypeError(`${n}: ${e}`)}function tt(n,e,t,r){Zt(n)||C(r,"must be an object");for(let i of Object.keys(n))e.includes(i)||C(r,`unknown field '${i}'`);for(let i of t)Object.hasOwn(n,i)||C(r,`missing field '${i}'`)}function Jt(n,e){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n))return n.forEach((t,r)=>Jt(t,`${e}[${r}]`));if(Zt(n))return Object.entries(n).forEach(([t,r])=>Jt(r,`${e}.${t}`));C(e,"must be lossless JSON data")}}function Lm(n,e){let t="",r=!1;for(let i=0;i<n.length;i++){let s=n[i];if(s==="\\"){t+=s+(n[++i]??"");continue}s==="["&&(r=!0),!r&&s==="."&&!(e&16)?t+="[^\\n]":!r&&s==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&s==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=s,s==="]"&&(r=!1)}return t}function Yt(n,e,t=!1,r=null){if(n===null)return null;switch(tt(n,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),n.kind){case"custom":return tt(n,["kind","name"],["kind","name"],e),r||C(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{tt(n,["kind","dtype"],["kind","dtype"],e);let i=n.dtype;typeof i!="string"&&C(e,"dtype must be a string");let s=In(i);return!s&&i!=="NN"&&C(e,`unknown dtype '${i}'`),{...n,test:a=>i==="NN"?a===null:i==="N"?be(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):s===Number?typeof a=="number"&&Number.isFinite(a)&&(i!=="L"||Number.isInteger(a)):s===String?typeof a=="string":s===Boolean?typeof a=="boolean":s===Date?a instanceof Date&&Number.isFinite(a.getTime()):s===Object?Zt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof s}}case"any":return{...n,test:i=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&C(e,"type requires string module/name");let i=`${n.module}.${n.name}`;if(i==="collections.abc.Callable")return{...n,test:o=>typeof o=="function",portable:!1};let s=Mm.get(i);return s||C(e,`unsupported type '${i}'`),{...n,test:s}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&C(e,"union items must be non-empty");let i=n.items.map((s,o)=>Yt(s,`${e}.items[${o}]`,!0,r));return{...n,items:i,inputConstraint:i.some(s=>s.inputConstraint),test:s=>i.some(o=>o.test&&o.test(s))}}case"literal":return Array.isArray(n.values)||C(e,"literal values must be an array"),n.values.forEach((i,s)=>Jt(i,`${e}.values[${s}]`)),{...n,test:i=>n.values.some(s=>Object.is(s,i))};case"annotated":{Array.isArray(n.metadata)||C(e,"annotated metadata must be an array"),n.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&C(e,"unsupported annotation metadata kind");let i=Yt(n.base,`${e}.base`,!0,r),s=n.metadata.map((o,a)=>Yt(o,`${e}.metadata[${a}]`,!0,r));return{...n,base:i,metadata:s,inputConstraint:i.inputConstraint,test:o=>i.test(o)&&s.every(a=>!a.test||a.test(o))}}case"range":{for(let i of["ge","le","gt","lt"])Object.hasOwn(n,i)||C(e,`range missing '${i}'`);for(let i of["ge","le","gt","lt"])n[i]!==null&&(typeof n[i]!="number"||!Number.isFinite(n[i]))&&C(e,`${i} must be finite number or null`);return{...n,test:i=>typeof i=="number"&&(n.ge===null||i>=n.ge)&&(n.le===null||i<=n.le)&&(n.gt===null||i>n.gt)&&(n.lt===null||i<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&C(e,"regex requires pattern and non-negative integer flags");let i=n.flags&-59;i&&C(e,`unsupported Python regex flags ${i}`),n.flags&2&&C(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&C(e,"regex uses a non-portable construct or character class");let s="uy";n.flags&16&&(s+="s");let o;try{o=new RegExp(`(?:${Lm(n.pattern,n.flags)})(?![\\s\\S])`,s)}catch(a){C(e,`invalid portable regex: ${a.message}`)}return{...n,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Jt(n.value,`${e}.value`),{...n};case"generic":{let i=Yt(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&C(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||C(e,"generic arguments must be an array");let s=n.arguments.map((o,a)=>Yt(o,`${e}.arguments[${a}]`,!0,r));return{...n,origin:i,arguments:s,inputConstraint:s.some(o=>o.inputConstraint),test:o=>i.test(o)&&Pm(n.origin,s,o)}}case"arguments":C(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||C(e,"ellipsis is only valid as a nested descriptor"),{...n};default:C(e,`unknown annotation kind '${n.kind}'`)}}function Pm(n,e,t){let r=`${n.module}.${n.name}`;return r==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((i,s)=>e[s].test(i)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(i=>!e[0]?.test||e[0].test(i)):r==="builtins.dict"?Object.entries(t).every(([i,s])=>(!e[0]?.test||e[0].test(i))&&(!e[1]?.test||e[1].test(s))):!1}function Xu(n,e){if(n===null)return null;if(typeof n!="string"&&C(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let i=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(i)&&C(e,`invalid cardinality item '${r}'`);let s=i.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);s||C(e,`invalid cardinality item '${r}'`);let[,o,a,l,u]=s;t.has(o)&&C(e,`duplicate tag '${o}'`);let c=0,d=1/0;i.includes("[")&&(i.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(a)),d<c&&C(e,`maximum ${d} is below minimum ${c}`),t.set(o,{min:c,max:d})}return t.has("*")&&t.size>1&&C(e,"wildcard '*' cannot be combined with named tags"),t}function Yu(n,e){if(n===null)return null;typeof n!="string"&&C(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let i=r.trim();i&&((!Gu.test(i)||t.has(i))&&C(e,`invalid or duplicate parent '${r}'`),t.add(i))}return t}function jm(n,e,t){if(n===null)return null;tt(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||C(e,"parameters must be an array"),n={parameters:r,accepts_var_keyword:r.some(l=>l.kind==="var_keyword"),accepts_var_positional:r.some(l=>l.kind==="var_positional"),...n},(!Array.isArray(n.parameters)||typeof n.accepts_var_keyword!="boolean"||typeof n.accepts_var_positional!="boolean")&&C(e,"invalid signature descriptor");let i=new Set,s=!1,o=!1,a=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return tt(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Gu.test(l.name)||i.has(l.name))&&C(c,"invalid or duplicate parameter name"),i.add(l.name),(!Rm.has(l.kind)||!$m.has(l.role)||typeof l.has_default!="boolean")&&C(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&C(c,"default presence must equal has_default"),l.has_default&&Jt(l.default,`${c}.default`),s||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:Yt(l.annotation,`${c}.annotation`,!1,t)}});return(s!==n.accepts_var_keyword||o!==n.accepts_var_positional)&&C(e,"variadic summary flags do not match parameters"),{...n,parameters:a}}function Wu(n,e,t,r){let i=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];tt(n,i,[],e),n={...Object.fromEntries(i.map(s=>[s,null])),...n};for(let s of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[s]!==null&&typeof n[s]!="string"&&C(e,`${s} must be string or null`);return n._meta!==null&&(Zt(n._meta)||C(e,"_meta must be object or null"),Jt(n._meta,`${e}._meta`)),Xu(n.sub_tags,`${e}.sub_tags`),Yu(n.parent_tags,`${e}.parent_tags`),{...n,attributes:jm(n.attributes,`${e}.attributes`,r)}}function Zu(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function Ju(n,e){let t={...e};for(let[r,i]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=i);return t._meta={...n._meta||{},...e._meta||{}},t}function Ku(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?Xu(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Yu(e.parent_tags,"resolved.parent_tags"):null,e}function Qu(n,e,t,r){if(t.get(n)===1&&C(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let i=e[n];i||C(r,`unknown abstract '${n}'`),t.set(n,1);let s={...i};for(let o of Zu(i.inherits_from))s=Ju(Qu(o,e,t,r),s);return s=Ku(s),t.set(n,2),e[n]=s,s}function Ko({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let s of Object.keys(t))Qu(s,t,r,`abstracts.${s}.inherits_from`);let i={};for(let[s,o]of Object.entries(e)){let a={...o};for(let l of Zu(o.inherits_from)){let u=t[l];u||C(`elements.${s}.inherits_from`,`unknown abstract '${l}'`),a=Ju(u,a)}i[s]=Ku(a)}return{abstracts:t,elements:i}}function Qo(n){tt(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),tt(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&C("document_format","expected builder_grammar version 1.1 or 1.2"),tt(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&C("grammar.name","must be non-empty string");for(let i of["version","title","description"])n.grammar[i]!==null&&typeof n.grammar[i]!="string"&&C(`grammar.${i}`,"must be string or null");(!Zt(n.abstracts)||!Zt(n.elements))&&C("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&C("custom_types","requires version 1.2");let e=jr.fromJSON(n.custom_types??{}),t={};for(let[i,s]of Object.entries(n.abstracts))(!i||i.startsWith("_"))&&C("abstracts",`invalid public name '${i}'`),t[i]=Wu(s,`abstracts.${i}`,!1,e);let r={};for(let[i,s]of Object.entries(n.elements))(!i||i.startsWith("_"))&&C("elements",`invalid public name '${i}'`),r[i]=Wu(s,`elements.${i}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function ec(n,e,t,r){let i=e.attributes;if(!i)return;let s={...r};t!=null&&(s.node_value=t);let o=new Set(i.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(!i.accepts_var_keyword)for(let u of Object.keys(r))!o.has(u)&&!a.has(u)&&C(n,`unknown attribute '${u}'`);let l=e._meta?.component?i.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of i.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(s,u.name);!c&&!u.has_default&&C(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(s[u.name]))&&C(n,`invalid value for ${u.role} '${u.name}'`)}}var jr=class n{#e=new Map;#t=new Map;register(e,t,r){let i=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),s=i.has(t)?{kind:"type",module:"builtins",name:i.get(t)}:t;return this.#r(e,{kind:"annotated",base:s,metadata:[r]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||Fm.has(e))&&C("custom_types",`invalid, reserved or duplicate name '${e}'`),tt(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))&&C(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let r=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!r.includes(t.base.name))&&C(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Jt(t,`custom_types.${e}`);let i=structuredClone(t),s=Yt(i,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,i),this.#t.set(e,{...o,inputConstraint:!0,test:s.test}),o}resolve(e,t="custom_types"){return this.#t.has(e)||C(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||C(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Zt(e)||C("custom_types","must be an object");let t=new n;for(let[r,i]of Object.entries(e))t.#r(r,i);return t}},Fm=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 tc(n,e,t,r){let i=e?.attributes;if(i)for(let s of i.parameters){if(!s.annotation?.inputConstraint||s.role==="framework"||["var_keyword","var_positional"].includes(s.kind))continue;let o=s.role==="value"?t:r[s.name];o!==void 0&&(s.annotation.test(o)||C(n,`invalid input for '${s.name}' (custom type)`))}}function rc(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!ea(n,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(n)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(lt(n)&<(e)){let r=structuredClone(n);for(let[i,s]of Object.entries(e))s!==null&&Object.defineProperty(r,i,{value:rc(r[i],s,[...t,i]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function ea(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>ea(t,e[r])):lt(n)&<(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&ea(n[t],e[t])):!1}function lt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function ta(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(ta);return}if(lt(n)){Object.values(n).forEach(ta);return}throw new TypeError("collection must contain only finite JSON values")}}var ut=class n{#e;constructor(e){ta(e);let t=["document_format","grammar","abstracts","elements"];if(!lt(e)||Object.keys(e).some(i=>![...t,"custom_types"].includes(i))||t.some(i=>!Object.hasOwn(e,i)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!lt(r)||Object.keys(r).length!==2||r.name!=="builder_grammar"||!["1.1","1.2"].includes(r.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let i of["grammar","abstracts","elements"])if(!lt(e[i]))throw new TypeError(`${i} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!lt(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 n(e),r=rc(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(r.document_format.version="1.2"),this.#e=r,this}toDocument(){return structuredClone(this.#e)}};var Kt=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 r=e.getRenderer();return this.renders.set(e,r),r}render(e,t={}){let r=e.builder,[i,s]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,s,t);let o=this.getRender(r),a;return[a,s]=o._handleMeta(e,s),e._getMeta("subbuilder")||(s=o.adaptAttrs(s)),e.value instanceof A&&(i=this.renderChildren(e.value,t)),o.renderedItem(e,i,s,{tag:a,...t})}renderChildren(e,t={}){let r=[];for(let i of e.getNodes()){let s=this.render(i,t);s!==null&&(Array.isArray(s)?r.push(...s):r.push(s))}return r}_renderComponent(e,t,r){let[i,s,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,i,o,a,r);if(s==null)return[];if(!(s instanceof x))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${s?.constructor?.name||typeof s}`);return s.getNodes().map(l=>this._expandBlock(e,i,o,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,i=r.componentMethod(e.nodeTag),s=i&&r[i];if(typeof s!="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[s,o,a,t]}_expandBlock(e,t,r,i,s){let o=e.builder._expansionRoot(r);t.call(e.builder,Ln(o),i);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={...s,depthOffset:this._nodeDepth(e,s.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,r,i){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,i]=e._getMeta("render_tag,render_attributes"),s=Mn(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!s)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return i&&(t={...t,...i}),[s,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,r={}){let i=this._composeStringFragments(e);if(t==null)return i;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(i),null;if(typeof t.write=="function")return t.write(i),null;if(typeof t=="function")return t(i),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("&","&").replaceAll("<","<").replaceAll(">",">")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',""")}_nodeDepth(e,t=0){let i=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(i-1,0)+t}};var Qt=class extends Kt{static mode="xml";renderedItem(e,t,r,{tag:i,pretty:s=!1,depthOffset:o=0}={}){let a=this._formatAttrs(r),l=s?" ".repeat(this._nodeDepth(e,o)):"",u=s?`
|
|
39
|
-
`:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${i}${a}>${u}${c}${l}</${i}>${u}`}return t==null?`${l}<${i}${a}></${i}>${u}`:`${l}<${i}${a}>${this._escapeText(t)}</${i}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let i=this._composeStringFragments(e);return r===!0?i=`<?xml version='1.0' encoding='UTF-8'?>${i}`:typeof r=="string"&&(i=r+i),super.finalize(i,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var nc={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 ic(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function Um(n){let e=Object.create(null),t=(r,i)=>{let s=r.toLowerCase(),o=e[s];if(o!==void 0&&o!==i)throw new Error(`container '${r}' is already tied to implementation method '${o}' (cannot rebind to '${i}')`);e[s]=i};for(let r of ic(n))if(Object.hasOwn(r,"containers"))for(let i of r.containers||[])t(i,i);return e}function Pn(n){let e=Object.create(null);for(let t of Object.keys(n)){let r=t.toLowerCase();if(Object.hasOwn(e,r))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[r]}'`);e[r]=t}return e}var jn="_root_",Fn="_root_",sc=new Set(["destination","func","value","_on_start"]),Te=class n{static _sourceClass=A;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof n))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 r=n._registry.get(t);if(r&&r!==e)throw new Error(`Builder name '${t}' is already registered to ${r.name}; cannot register ${e.name}`);return n._registry.set(t,e),e}static getBuilderClass(e){let t=n._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 x,this._dataroot.setBackref(),this._dataroot.setItem(Fn,new x),this.data=this._dataroot.getItem(Fn),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(jn,new t(null,this)),this.source=this._sourceroot.getItem(jn)}wrapSource(e){if(e=J(e),!(e instanceof A)&&!(e instanceof Ae))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=Hu(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 r=n.getBuilderClass(e);t=new r,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,r){if(typeof e!="string"||!e)throw new Error(`'${r}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${r}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,r=t?new ut(t.toDocument()).update(e):new ut(e),i=Qo(r.toDocument()),s=Ko(i),o=Pn(s.elements);this._classCollection=r,this._classSchema=s.elements,this._abstracts=s.abstracts,this._tagNames=o}static{this.defineGrammar(nc)}get _containers(){return Um(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??=Pn(this.schema):this.constructor._tagNames??=Pn(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let i=`${this.constructor._name}_`;return t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,i=t?new ut(e):new ut(r.toDocument()).update(e),s=Qo(i.toDocument()),o=Ko(s),a=Pn(o.elements);return this._collection=i,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;tc(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);return ec(i,this.schema[i],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:i}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let s=t!==void 0?t:e.value instanceof A?null:e.value;this.validateNodeValues(e.nodeTag,s,r||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=i||(e.value instanceof A?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(s=>typeof s!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(i,this.schema[i],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let i=this.schema[r];if(!this._countsForGrammar(i))return!0;let s=i._parentSpec;if(s==null||s.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,i,o),!0}bagCall(e,t,r,i){return this.setChild(e,t,r,i)}commandOnNode(e,t,r,i){if(e=J(e),e.value instanceof A)return this.setChild(e.value,t,r,i);let s=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,r,i,e);return this.promoteNodeValue(e,s,o),a}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,i,s=null){let o={...i},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=r instanceof A?r._builderBindingPlan(c):null,f=s?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);r instanceof A&&this._validateChildren(t,a,r.getNodes().map(w=>w.nodeTag),!1);let h=s||e.parentNode,m=h?.nodeTag?this.schema[h.nodeTag]:null;if(m&&!h._getMeta("subbuilder")&&this._countsForGrammar(a))this._validateParent(t,a,h.nodeTag),this._validateChildren(h.nodeTag,m,[...e.getNodes().map(w=>w.nodeTag),t],!1);else if(!m&&!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 p=o.node_position;delete o.node_position;let b=o.node_label;delete o.node_label;let g;if(m?.collection_key){if(b!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);g=this._collectionLabel(m.collection_key,t,o)}else{let w=m?._subSpec?.get(t);if(w&&w.max===1){if(b!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);g=t}else g=b||a.node_label||this._autoLabel(e,t)}if(e.node(g)!=null)throw new Error(`duplicate node label '${g}'`);return e._setBuilderItem(c,d,g,r,o,p||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,r){let i=t._parentSpec;if(!(i==null||i.has("*")||!this._countsForGrammar(t))&&!i.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,i){let s=t._subSpec;if(s==null||s.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of r){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=s.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 i?[...s].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,r){let i=s=>{if(r[s]===null||r[s]===void 0)throw new Error(`'${t}': collection key needs attribute '${s}'`);return String(r[s])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(s,o)=>i(o)):i(e)}validateSource(){let e=[],t=(r,i="")=>{for(let s of r.getNodes()){let o=i?`${i}.${s.label}`:s.label,a=s.builder;a.validateCustomTypes(s);let l=a.schema[s.nodeTag];if(l&&!s._getMeta("data_element,subbuilder,component").some(Boolean)){let u=s.value instanceof A?s.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(s.nodeTag,l,u,!0);c.length&&e.push([o,c])}s.value instanceof A&&t(s.value,o)}};return t(this.source),e}_autoLabel(e,t){let r=0;for(;e.node(`${t}_${r}`)!==null&&e.node(`${t}_${r}`)!==void 0;)r+=1;return`${t}_${r}`}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,r={},i=e.runtimeToEvaluate(),s=new Set(i.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...i])if(!(typeof c!="string"||!H(d)))for(let f of Ge(e,d))i.has(f)||i.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of i){if(d instanceof K){t.set(c,d.resolve());continue}let f=typeof c=="string"?H(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===Pr){let m=this.data.getNode(h);m&&Object.assign(r,m.getAttr("_wdg"))}}let l=$a(i,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Pr);l.delete(Pr);for(let c of l.keys())s.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,i,s){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 i=(typeof t=="function"?t:t.constructor)[e];if(typeof i=="function")return i}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[i,s]of Object.entries(t))sc.has(i)||(r[i]=s);return r}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let r={};for(let[i,s]of Object.entries(t))i!=="destination"&&i!=="value"&&!i.startsWith("_")&&(r[i]=s);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(r).length?r:null})}else if(e.nodeTag==="dataFormula"){let r=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,r(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=r=>{for(let i of r.getNodes())i._getMeta("data_element")&&e.push(i),i.value instanceof A&&t(i.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 ic(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},r={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},r[a.toLowerCase()]=l;let i=Pn(t),s=this._collection||this.constructor._classCollection,o=s.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ut(s.toDocument()).update(o),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=i}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(jn,new t(null,this),e?{datapath:e}:null),r.getItem(jn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Qt(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 r=this.getRenderer(e),i=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=i,i}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...r}={}){e??=this.constructor._defaultRenderMode;let i=this.getRenderer(e);if(t===!1&&i.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let s=t===!1?null:t||this._defaultTargets.get(i.mode)||null,o={...s?.renderOpts,...r};return i.finalize(this.materialize(e,o),s,o)}};Te._registry=new Map;var Vm=new Set(["short","medium","long","full"]),zm=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Hm(n,e){if(!(n instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(n.getTime()))throw new RangeError("Invalid date");let t=e||U(n).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Wm(n,e,t,r){let i=e.match(zm)||[];if(i.join("")!==e)throw new RangeError("Unclosed format literal");let s=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>s(n.getUTCFullYear()%100),yyyy:()=>s(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>s(n.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>s(n.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>s(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>s(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>s(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>s(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return i.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 oc(n,{format:e,mask:t,locale:r,dtype:i,places:s}={}){let o=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||s!=null))if(typeof n=="number"||be(n))o=Xm(n,{format:e,locale:r,places:s});else{let a=Hm(n,i);if(Vm.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(r||void 0,l).format(n)}else o=Wm(n,String(e),r||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Gm({format:n="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!n||n==="decimal")t.style="decimal";else if(n==="percent")t.style="percent";else if(n==="scientific")t.notation="scientific";else{let r=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(n);if(!r||n.includes(".")&&!r[2]&&!r[3])throw new RangeError(`Unsupported number format: ${n}`);t.useGrouping=r[1].includes(","),t.minimumFractionDigits=(r[2]||"").length,t.maximumFractionDigits=(r[2]||"").length+(r[3]||"").length}if(e!=null&&e!==""){let r=Number(e);if(!Number.isInteger(r)||r<0||r>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=r,t.maximumFractionDigits=r}return t}function Xm(n,e={}){if(typeof n!="number"&&!be(n))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(n)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Gm(e));if(be(n)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(be(n)?n.toString():n)}var Ym=new Set(["style","script"]),Zm=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"]),ac=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"]),qn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),lc=n=>n===!0?"true":n===!1?"false":String(n),ls=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function Jm(n){if(ac.has(n))return!0;for(let e of ac)if(n.startsWith(`${e}_`))return!0;return!1}function Km(n){let e=new Map;if(!n)return e;let t=[],r=0,i=null,s=!1,o=!1,a=0,l=String(n);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(s){s=!1;continue}if(c==="\\"){s=!0;continue}if(i){c===i&&(i=null);continue}c==='"'||c==="'"?i=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(r,u)),r=u+1)}t.push(l.slice(r));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 er=class extends Kt{static mode="html";renderedItem(e,t,r,{tag:i,xml:s=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(r={xmlns:"http://www.w3.org/1999/xhtml",...r});let{format:c,mask:d,locale:f,places:h,dtype:m,...p}=r;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=oc(t,{format:c,mask:d,places:h,dtype:m,locale:this._displayLocale(e,f)}));let b=this._formatAttrs(p);if(l){if(!Object.hasOwn(r,"id")){let E=this.builder.targetId(e);E!==null&&(b+=` id="${this._htmlAttrValue(E)}"`)}for(let[E,D]of Object.entries(e.getAttr()))e.pointerType(D)&&(b+=` data-${this.adapt(E)}-pointer="${this._htmlAttrValue(e.absDatapath(D))}"`)}let g=o?" ".repeat(this._nodeDepth(e,a)):"",_=o?`
|
|
40
|
-
`:"";if(e._getMeta("void"))return`${g}<${i}${b}${s?"/":""}>${_}`;if(Array.isArray(t)){let E=this._composeStringFragments(t);return`${g}<${i}${b}>${_}${E}${g}</${i}>${_}`}if(t==null)return`${g}<${i}${b}></${i}>${_}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Ym.has(i)?String(t):this._escapeText(t);return`${g}<${i}${b}>${w}</${i}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let i=r.getAttr("locale");if(i==null)continue;let s=r.pointerType(i)?r.data.getItem(r.absDatapath(i)):i;if(s)return s}}adaptAttrs(e){let t={},r={};for(let[s,o]of Object.entries(e||{}))if(s.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(s)]=o;else if(s==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>s.startsWith(a)))continue;this._isStyleContribution(s)?r[s]=o:t[s]=o}let i=this._adaptStyle(r);return i&&(t.style=i),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||qn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&qn.has(t)||Jm(e)}_adaptStyle(e){let t=Km(e.style),r=new Map,i=new Map;for(let[s,o]of Object.entries(e))if(s!=="style")if(s.startsWith("style_"))t.set(s.slice(6).replaceAll("_","-"),lc(o));else if(qn.has(s))r.set(s,o);else{let a=s.indexOf("_"),l=a<0?s:s.slice(0,a);a>=0&&qn.has(l)?(i.has(l)||i.set(l,{}),i.get(l)[s.slice(a+1)]=o):t.set(s.replaceAll("_","-"),lc(o))}for(let s of qn)(r.has(s)||i.has(s))&&this[`_macro_${s}`](r.get(s),i.get(s)||{},t);return[...t].map(([s,o])=>`${s}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,i]of Object.entries(e||{}))Zm.has(r)?i&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(i)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_macro_rounded(e,t,r){let i=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[s,o]of Object.entries(t))if(s==="top"||s==="bottom")i[`${s}_left`]=o,i[`${s}_right`]=o;else if(s==="left"||s==="right")i[`top_${s}`]=o,i[`bottom_${s}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(s))i[s]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${s}'`);for(let[s,o]of Object.entries(i))r.set(`border-${s.replaceAll("_","-")}-radius`,ls(o))}_macro_transform(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`rotate(${o}deg)`):s==="scale"||s==="translate"?i.push(`${s}(${o})`):s==="translate_x"?i.push(`translateX(${ls(o)})`):s==="translate_y"?i.push(`translateY(${ls(o)})`):s==="skew_x"?i.push(`skewX(${o}deg)`):s==="skew_y"?i.push(`skewY(${o}deg)`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("transform",i.join(" "))}_macro_filter(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`hue-rotate(${o}deg)`):s==="blur"?i.push(`blur(${ls(o)})`):s==="drop_shadow"?i.push(`drop-shadow(${o})`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("filter",i.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[i,s]of Object.entries(t))r.set(`transition-${i.replaceAll("_","-")}`,String(s))}_macro_zoom(e,t,r){e!==void 0&&r.set("zoom",String(e))}_macro_shadow(e,t,r){e!==void 0&&r.set("box-shadow",String(e));for(let[i,s]of Object.entries(t))r.set(`box-shadow-${i.replaceAll("_","-")}`,String(s))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var Qm=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 us(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[Qm.has(e)?e.replaceAll("_","-"):e,t]))}var tr=class extends Qt{static mode="svg";adaptAttrs(e){return us(e)}};var uc={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 St=class extends Te{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(uc)}get renderer_html(){return new er(this)}};Te.registerBuilder(St);var cc={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 Nt=class extends Te{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(cc)}get renderer_svg(){return new tr(this)}};Te.registerBuilder(Nt);var rr=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=jr.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 n(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Un=new rr(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var De=class{constructor(e){this.gramlot=e}};var ra=["TL","TC","TR","L","R","BL","BC","BR"],dc=`.gramlot-labelbox[hidden]{display:none!important}
|
|
38
|
+
`)}},Pn=class extends Error{constructor(e){super(e),this.name="BagException"}};Q.registerBagClass(x);Yo(x,"X",n=>n._toTytxPayload(),n=>x._fromTytxPayload(n));Wt(x.tytxSuffix,{...je(x.tytxSuffix),Bag:x});var zu=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 Hu(n){return n.endsWith("_")&&zu.has(n.slice(0,-1))?n.slice(0,-1):n}function Wu(n){let e=Hu(n);return e!==n?e:n.startsWith("_")&&zu.has(n.slice(1))?n.slice(1):n}function Ln(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let i=e||n;if(!i)return i;if(i=Hu(i),t&&!e){let s=`${r}_`;i.startsWith(s)&&(i=i.slice(s.length)),i=`${t}:${i}`}return i}var jr=Symbol("value"),Xt=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function _e(n){return Object.entries(n||{}).filter(([e])=>!Xt.has(e)).map(([e,t])=>[Wu(e),t])}var Ae=class extends ze{constructor(e,t,r=null,i=null,s=null,o=null,a=null){super(e,t,r,i,s,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")||{},r=e.split(",").map(i=>i.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(i=>t[i]!==void 0?t[i]: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,r]of Object.entries(this.getAttr()||{}))this.pointerType(r)==="^"&&e.push([t,r.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return _e(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(jr,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(H(e)?.pointer??e).slice(1));let r=null;return e.includes("?")&&([e,r]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),r):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,r))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");i!=null&&(e=e==="."?i:i+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let i of e.split("."))if(i==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(i);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),i=r.indexOf("."),s=i===-1?r:r.slice(0,i),o=i===-1?"":r.slice(i+1),a;if(s==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(s==="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",s),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,r){let i=this;for(;i!=null;){let o=i.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return i;i=i.parentNode}let s=e?"FORM":"ANCHOR";throw new Error(`#${s}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let i=this.data,s=this.absDatapath(e);return r&&i.getItem(s)==null&&i.setItem(s,t),i.getItem(s,t)}setRelativeData(e,t,{attributes:r=null,fired:i=!1,reason:s=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,r,">",!1,!0,s===null?!0:s,i)}fireEvent(e,t=!0,{attributes:r=null,reason:i=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:i})}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})}},A=class n extends x{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return Ae}_setBuilderItem(e,t,r,...i){let s=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(r,...i)}catch(a){if(this.node(r)==null&&s)for(let[l,u]of s)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[r,i]of t)r._builder=i;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,i=(s,o)=>{if(r.has(s))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(s),t.push([s,o]);for(let a of s.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 n&&i(c,l)}};return i(this,e),t}};if((je(A.tytxSuffix).SourceBag??A)!==A)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Wt(A.tytxSuffix,{...je(A.tytxSuffix),SourceBag:A});function Mm(n){if(n.length===0)return{value:null,attrs:{}};let e=n[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:n[1]||{}}}var Pm=new Set(["then","toJSON"]),Xu=new WeakMap;function K(n){return Xu.get(n)||n}function jn(n){if(n==null)return n;n=K(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function Yu(n,e){let t=e instanceof x,r=new Proxy(e,{get(i,s){if(typeof s=="symbol"||s.startsWith("_")||Pm.has(s))return Reflect.get(i,s,i);let o=n.schemaTag(s);if(t&&o)return Gu(n,i,o,t);if(s in i){let l=Reflect.get(i,s,i);return typeof l=="function"?l.bind(i):l}if(o)return Gu(n,i,o,t);let a=n.containerMethod(s);if(a)return(...l)=>n[a](n.wrapSource(i),...l)}});return Xu.set(r,e),r}function Gu(n,e,t,r){return(...i)=>{let{value:s,attrs:o}=Mm(i),a=r?n.bagCall(e,t,s,o):n.commandOnNode(e,t,s,o);return a.builder.wrapSource(a)}}function ta(n,e,{transport:t="json"}={}){let r=j(n,t==="json"?null:t);if(!(r instanceof A))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Ju=/^[A-Za-z_][A-Za-z0-9_]*$/,Lm=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),jm=new Set(["framework","value","attribute"]),Fm=new Map([["builtins.str",n=>typeof n=="string"],["builtins.int",n=>Number.isInteger(n)],["builtins.float",n=>typeof n=="number"&&Number.isFinite(n)],["builtins.bool",n=>typeof n=="boolean"],["builtins.list",n=>Array.isArray(n)],["builtins.dict",n=>n!==null&&typeof n=="object"&&!Array.isArray(n)],["builtins.tuple",n=>Array.isArray(n)],["builtins.set",n=>Array.isArray(n)||n instanceof Set],["builtins.NoneType",n=>n===null],["builtins.object",n=>!0]]);function Zt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function C(n,e){throw new TypeError(`${n}: ${e}`)}function rt(n,e,t,r){Zt(n)||C(r,"must be an object");for(let i of Object.keys(n))e.includes(i)||C(r,`unknown field '${i}'`);for(let i of t)Object.hasOwn(n,i)||C(r,`missing field '${i}'`)}function Jt(n,e){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n))return n.forEach((t,r)=>Jt(t,`${e}[${r}]`));if(Zt(n))return Object.entries(n).forEach(([t,r])=>Jt(r,`${e}.${t}`));C(e,"must be lossless JSON data")}}function qm(n,e){let t="",r=!1;for(let i=0;i<n.length;i++){let s=n[i];if(s==="\\"){t+=s+(n[++i]??"");continue}s==="["&&(r=!0),!r&&s==="."&&!(e&16)?t+="[^\\n]":!r&&s==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&s==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=s,s==="]"&&(r=!1)}return t}function Yt(n,e,t=!1,r=null){if(n===null)return null;switch(rt(n,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),n.kind){case"custom":return rt(n,["kind","name"],["kind","name"],e),r||C(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{rt(n,["kind","dtype"],["kind","dtype"],e);let i=n.dtype;typeof i!="string"&&C(e,"dtype must be a string");let s=On(i);return!s&&i!=="NN"&&C(e,`unknown dtype '${i}'`),{...n,test:a=>i==="NN"?a===null:i==="N"?be(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):s===Number?typeof a=="number"&&Number.isFinite(a)&&(i!=="L"||Number.isInteger(a)):s===String?typeof a=="string":s===Boolean?typeof a=="boolean":s===Date?a instanceof Date&&Number.isFinite(a.getTime()):s===Object?Zt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof s}}case"any":return{...n,test:i=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&C(e,"type requires string module/name");let i=`${n.module}.${n.name}`;if(i==="collections.abc.Callable")return{...n,test:o=>typeof o=="function",portable:!1};let s=Fm.get(i);return s||C(e,`unsupported type '${i}'`),{...n,test:s}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&C(e,"union items must be non-empty");let i=n.items.map((s,o)=>Yt(s,`${e}.items[${o}]`,!0,r));return{...n,items:i,inputConstraint:i.some(s=>s.inputConstraint),test:s=>i.some(o=>o.test&&o.test(s))}}case"literal":return Array.isArray(n.values)||C(e,"literal values must be an array"),n.values.forEach((i,s)=>Jt(i,`${e}.values[${s}]`)),{...n,test:i=>n.values.some(s=>Object.is(s,i))};case"annotated":{Array.isArray(n.metadata)||C(e,"annotated metadata must be an array"),n.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&C(e,"unsupported annotation metadata kind");let i=Yt(n.base,`${e}.base`,!0,r),s=n.metadata.map((o,a)=>Yt(o,`${e}.metadata[${a}]`,!0,r));return{...n,base:i,metadata:s,inputConstraint:i.inputConstraint,test:o=>i.test(o)&&s.every(a=>!a.test||a.test(o))}}case"range":{for(let i of["ge","le","gt","lt"])Object.hasOwn(n,i)||C(e,`range missing '${i}'`);for(let i of["ge","le","gt","lt"])n[i]!==null&&(typeof n[i]!="number"||!Number.isFinite(n[i]))&&C(e,`${i} must be finite number or null`);return{...n,test:i=>typeof i=="number"&&(n.ge===null||i>=n.ge)&&(n.le===null||i<=n.le)&&(n.gt===null||i>n.gt)&&(n.lt===null||i<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&C(e,"regex requires pattern and non-negative integer flags");let i=n.flags&-59;i&&C(e,`unsupported Python regex flags ${i}`),n.flags&2&&C(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&C(e,"regex uses a non-portable construct or character class");let s="uy";n.flags&16&&(s+="s");let o;try{o=new RegExp(`(?:${qm(n.pattern,n.flags)})(?![\\s\\S])`,s)}catch(a){C(e,`invalid portable regex: ${a.message}`)}return{...n,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Jt(n.value,`${e}.value`),{...n};case"generic":{let i=Yt(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&C(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||C(e,"generic arguments must be an array");let s=n.arguments.map((o,a)=>Yt(o,`${e}.arguments[${a}]`,!0,r));return{...n,origin:i,arguments:s,inputConstraint:s.some(o=>o.inputConstraint),test:o=>i.test(o)&&Um(n.origin,s,o)}}case"arguments":C(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||C(e,"ellipsis is only valid as a nested descriptor"),{...n};default:C(e,`unknown annotation kind '${n.kind}'`)}}function Um(n,e,t){let r=`${n.module}.${n.name}`;return r==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((i,s)=>e[s].test(i)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(i=>!e[0]?.test||e[0].test(i)):r==="builtins.dict"?Object.entries(t).every(([i,s])=>(!e[0]?.test||e[0].test(i))&&(!e[1]?.test||e[1].test(s))):!1}function Ku(n,e){if(n===null)return null;if(typeof n!="string"&&C(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let i=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(i)&&C(e,`invalid cardinality item '${r}'`);let s=i.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);s||C(e,`invalid cardinality item '${r}'`);let[,o,a,l,u]=s;t.has(o)&&C(e,`duplicate tag '${o}'`);let c=0,d=1/0;i.includes("[")&&(i.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(a)),d<c&&C(e,`maximum ${d} is below minimum ${c}`),t.set(o,{min:c,max:d})}return t.has("*")&&t.size>1&&C(e,"wildcard '*' cannot be combined with named tags"),t}function Qu(n,e){if(n===null)return null;typeof n!="string"&&C(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let i=r.trim();i&&((!Ju.test(i)||t.has(i))&&C(e,`invalid or duplicate parent '${r}'`),t.add(i))}return t}function Vm(n,e,t){if(n===null)return null;rt(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||C(e,"parameters must be an array"),n={parameters:r,accepts_var_keyword:r.some(l=>l.kind==="var_keyword"),accepts_var_positional:r.some(l=>l.kind==="var_positional"),...n},(!Array.isArray(n.parameters)||typeof n.accepts_var_keyword!="boolean"||typeof n.accepts_var_positional!="boolean")&&C(e,"invalid signature descriptor");let i=new Set,s=!1,o=!1,a=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return rt(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Ju.test(l.name)||i.has(l.name))&&C(c,"invalid or duplicate parameter name"),i.add(l.name),(!Lm.has(l.kind)||!jm.has(l.role)||typeof l.has_default!="boolean")&&C(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&C(c,"default presence must equal has_default"),l.has_default&&Jt(l.default,`${c}.default`),s||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:Yt(l.annotation,`${c}.annotation`,!1,t)}});return(s!==n.accepts_var_keyword||o!==n.accepts_var_positional)&&C(e,"variadic summary flags do not match parameters"),{...n,parameters:a}}function Zu(n,e,t,r){let i=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];rt(n,i,[],e),n={...Object.fromEntries(i.map(s=>[s,null])),...n};for(let s of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[s]!==null&&typeof n[s]!="string"&&C(e,`${s} must be string or null`);return n._meta!==null&&(Zt(n._meta)||C(e,"_meta must be object or null"),Jt(n._meta,`${e}._meta`)),Ku(n.sub_tags,`${e}.sub_tags`),Qu(n.parent_tags,`${e}.parent_tags`),{...n,attributes:Vm(n.attributes,`${e}.attributes`,r)}}function ec(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function tc(n,e){let t={...e};for(let[r,i]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=i);return t._meta={...n._meta||{},...e._meta||{}},t}function rc(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?Ku(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Qu(e.parent_tags,"resolved.parent_tags"):null,e}function nc(n,e,t,r){if(t.get(n)===1&&C(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let i=e[n];i||C(r,`unknown abstract '${n}'`),t.set(n,1);let s={...i};for(let o of ec(i.inherits_from))s=tc(nc(o,e,t,r),s);return s=rc(s),t.set(n,2),e[n]=s,s}function ra({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let s of Object.keys(t))nc(s,t,r,`abstracts.${s}.inherits_from`);let i={};for(let[s,o]of Object.entries(e)){let a={...o};for(let l of ec(o.inherits_from)){let u=t[l];u||C(`elements.${s}.inherits_from`,`unknown abstract '${l}'`),a=tc(u,a)}i[s]=rc(a)}return{abstracts:t,elements:i}}function na(n){rt(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),rt(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&C("document_format","expected builder_grammar version 1.1 or 1.2"),rt(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&C("grammar.name","must be non-empty string");for(let i of["version","title","description"])n.grammar[i]!==null&&typeof n.grammar[i]!="string"&&C(`grammar.${i}`,"must be string or null");(!Zt(n.abstracts)||!Zt(n.elements))&&C("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&C("custom_types","requires version 1.2");let e=Fr.fromJSON(n.custom_types??{}),t={};for(let[i,s]of Object.entries(n.abstracts))(!i||i.startsWith("_"))&&C("abstracts",`invalid public name '${i}'`),t[i]=Zu(s,`abstracts.${i}`,!1,e);let r={};for(let[i,s]of Object.entries(n.elements))(!i||i.startsWith("_"))&&C("elements",`invalid public name '${i}'`),r[i]=Zu(s,`elements.${i}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function ic(n,e,t,r){let i=e.attributes;if(!i)return;let s={...r};t!=null&&(s.node_value=t);let o=new Set(i.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(!i.accepts_var_keyword)for(let u of Object.keys(r))!o.has(u)&&!a.has(u)&&C(n,`unknown attribute '${u}'`);let l=e._meta?.component?i.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of i.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(s,u.name);!c&&!u.has_default&&C(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(s[u.name]))&&C(n,`invalid value for ${u.role} '${u.name}'`)}}var Fr=class n{#e=new Map;#t=new Map;register(e,t,r){let i=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),s=i.has(t)?{kind:"type",module:"builtins",name:i.get(t)}:t;return this.#r(e,{kind:"annotated",base:s,metadata:[r]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||zm.has(e))&&C("custom_types",`invalid, reserved or duplicate name '${e}'`),rt(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))&&C(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let r=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!r.includes(t.base.name))&&C(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Jt(t,`custom_types.${e}`);let i=structuredClone(t),s=Yt(i,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,i),this.#t.set(e,{...o,inputConstraint:!0,test:s.test}),o}resolve(e,t="custom_types"){return this.#t.has(e)||C(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||C(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Zt(e)||C("custom_types","must be an object");let t=new n;for(let[r,i]of Object.entries(e))t.#r(r,i);return t}},zm=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 sc(n,e,t,r){let i=e?.attributes;if(i)for(let s of i.parameters){if(!s.annotation?.inputConstraint||s.role==="framework"||["var_keyword","var_positional"].includes(s.kind))continue;let o=s.role==="value"?t:r[s.name];o!==void 0&&(s.annotation.test(o)||C(n,`invalid input for '${s.name}' (custom type)`))}}function oc(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!ia(n,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(n)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(ut(n)&&ut(e)){let r=structuredClone(n);for(let[i,s]of Object.entries(e))s!==null&&Object.defineProperty(r,i,{value:oc(r[i],s,[...t,i]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function ia(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>ia(t,e[r])):ut(n)&&ut(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&ia(n[t],e[t])):!1}function ut(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function sa(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(sa);return}if(ut(n)){Object.values(n).forEach(sa);return}throw new TypeError("collection must contain only finite JSON values")}}var ct=class n{#e;constructor(e){sa(e);let t=["document_format","grammar","abstracts","elements"];if(!ut(e)||Object.keys(e).some(i=>![...t,"custom_types"].includes(i))||t.some(i=>!Object.hasOwn(e,i)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!ut(r)||Object.keys(r).length!==2||r.name!=="builder_grammar"||!["1.1","1.2"].includes(r.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let i of["grammar","abstracts","elements"])if(!ut(e[i]))throw new TypeError(`${i} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!ut(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 n(e),r=oc(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(r.document_format.version="1.2"),this.#e=r,this}toDocument(){return structuredClone(this.#e)}};var Kt=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 r=e.getRenderer();return this.renders.set(e,r),r}render(e,t={}){let r=e.builder,[i,s]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,s,t);let o=this.getRender(r),a;return[a,s]=o._handleMeta(e,s),e._getMeta("subbuilder")||(s=o.adaptAttrs(s)),e.value instanceof A&&(i=this.renderChildren(e.value,t)),o.renderedItem(e,i,s,{tag:a,...t})}renderChildren(e,t={}){let r=[];for(let i of e.getNodes()){let s=this.render(i,t);s!==null&&(Array.isArray(s)?r.push(...s):r.push(s))}return r}_renderComponent(e,t,r){let[i,s,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,i,o,a,r);if(s==null)return[];if(!(s instanceof x))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${s?.constructor?.name||typeof s}`);return s.getNodes().map(l=>this._expandBlock(e,i,o,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,i=r.componentMethod(e.nodeTag),s=i&&r[i];if(typeof s!="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[s,o,a,t]}_expandBlock(e,t,r,i,s){let o=e.builder._expansionRoot(r);t.call(e.builder,jn(o),i);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={...s,depthOffset:this._nodeDepth(e,s.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,r,i){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,i]=e._getMeta("render_tag,render_attributes"),s=Ln(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!s)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return i&&(t={...t,...i}),[s,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,r={}){let i=this._composeStringFragments(e);if(t==null)return i;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(i),null;if(typeof t.write=="function")return t.write(i),null;if(typeof t=="function")return t(i),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("&","&").replaceAll("<","<").replaceAll(">",">")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',""")}_nodeDepth(e,t=0){let i=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(i-1,0)+t}};var Qt=class extends Kt{static mode="xml";renderedItem(e,t,r,{tag:i,pretty:s=!1,depthOffset:o=0}={}){let a=this._formatAttrs(r),l=s?" ".repeat(this._nodeDepth(e,o)):"",u=s?`
|
|
39
|
+
`:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${i}${a}>${u}${c}${l}</${i}>${u}`}return t==null?`${l}<${i}${a}></${i}>${u}`:`${l}<${i}${a}>${this._escapeText(t)}</${i}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let i=this._composeStringFragments(e);return r===!0?i=`<?xml version='1.0' encoding='UTF-8'?>${i}`:typeof r=="string"&&(i=r+i),super.finalize(i,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var ac={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 lc(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function Wm(n){let e=Object.create(null),t=(r,i)=>{let s=r.toLowerCase(),o=e[s];if(o!==void 0&&o!==i)throw new Error(`container '${r}' is already tied to implementation method '${o}' (cannot rebind to '${i}')`);e[s]=i};for(let r of lc(n))if(Object.hasOwn(r,"containers"))for(let i of r.containers||[])t(i,i);return e}function Fn(n){let e=Object.create(null);for(let t of Object.keys(n)){let r=t.toLowerCase();if(Object.hasOwn(e,r))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[r]}'`);e[r]=t}return e}var qn="_root_",Un="_root_",uc=new Set(["destination","func","value","_on_start"]),Te=class n{static _sourceClass=A;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof n))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 r=n._registry.get(t);if(r&&r!==e)throw new Error(`Builder name '${t}' is already registered to ${r.name}; cannot register ${e.name}`);return n._registry.set(t,e),e}static getBuilderClass(e){let t=n._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 x,this._dataroot.setBackref(),this._dataroot.setItem(Un,new x),this.data=this._dataroot.getItem(Un),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(qn,new t(null,this)),this.source=this._sourceroot.getItem(qn)}wrapSource(e){if(e=K(e),!(e instanceof A)&&!(e instanceof Ae))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=Yu(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 r=n.getBuilderClass(e);t=new r,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,r){if(typeof e!="string"||!e)throw new Error(`'${r}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${r}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,r=t?new ct(t.toDocument()).update(e):new ct(e),i=na(r.toDocument()),s=ra(i),o=Fn(s.elements);this._classCollection=r,this._classSchema=s.elements,this._abstracts=s.abstracts,this._tagNames=o}static{this.defineGrammar(ac)}get _containers(){return Wm(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??=Fn(this.schema):this.constructor._tagNames??=Fn(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let i=`${this.constructor._name}_`;return t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,i=t?new ct(e):new ct(r.toDocument()).update(e),s=na(i.toDocument()),o=ra(s),a=Fn(o.elements);return this._collection=i,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;sc(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);return ic(i,this.schema[i],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:i}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let s=t!==void 0?t:e.value instanceof A?null:e.value;this.validateNodeValues(e.nodeTag,s,r||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=i||(e.value instanceof A?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(s=>typeof s!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(i,this.schema[i],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let i=this.schema[r];if(!this._countsForGrammar(i))return!0;let s=i._parentSpec;if(s==null||s.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,i,o),!0}bagCall(e,t,r,i){return this.setChild(e,t,r,i)}commandOnNode(e,t,r,i){if(e=K(e),e.value instanceof A)return this.setChild(e.value,t,r,i);let s=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,r,i,e);return this.promoteNodeValue(e,s,o),a}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,i,s=null){let o={...i},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=r instanceof A?r._builderBindingPlan(c):null,f=s?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);r instanceof A&&this._validateChildren(t,a,r.getNodes().map(w=>w.nodeTag),!1);let h=s||e.parentNode,m=h?.nodeTag?this.schema[h.nodeTag]:null;if(m&&!h._getMeta("subbuilder")&&this._countsForGrammar(a))this._validateParent(t,a,h.nodeTag),this._validateChildren(h.nodeTag,m,[...e.getNodes().map(w=>w.nodeTag),t],!1);else if(!m&&!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 p=o.node_position;delete o.node_position;let b=o.node_label;delete o.node_label;let g;if(m?.collection_key){if(b!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);g=this._collectionLabel(m.collection_key,t,o)}else{let w=m?._subSpec?.get(t);if(w&&w.max===1){if(b!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);g=t}else g=b||a.node_label||this._autoLabel(e,t)}if(e.node(g)!=null)throw new Error(`duplicate node label '${g}'`);return e._setBuilderItem(c,d,g,r,o,p||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,r){let i=t._parentSpec;if(!(i==null||i.has("*")||!this._countsForGrammar(t))&&!i.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,i){let s=t._subSpec;if(s==null||s.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of r){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=s.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 i?[...s].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,r){let i=s=>{if(r[s]===null||r[s]===void 0)throw new Error(`'${t}': collection key needs attribute '${s}'`);return String(r[s])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(s,o)=>i(o)):i(e)}validateSource(){let e=[],t=(r,i="")=>{for(let s of r.getNodes()){let o=i?`${i}.${s.label}`:s.label,a=s.builder;a.validateCustomTypes(s);let l=a.schema[s.nodeTag];if(l&&!s._getMeta("data_element,subbuilder,component").some(Boolean)){let u=s.value instanceof A?s.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(s.nodeTag,l,u,!0);c.length&&e.push([o,c])}s.value instanceof A&&t(s.value,o)}};return t(this.source),e}_autoLabel(e,t){let r=0;for(;e.node(`${t}_${r}`)!==null&&e.node(`${t}_${r}`)!==void 0;)r+=1;return`${t}_${r}`}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,r={},i=e.runtimeToEvaluate(),s=new Set(i.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...i])if(!(typeof c!="string"||!H(d)))for(let f of tt(e,d))i.has(f)||i.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of i){if(d instanceof Q){t.set(c,d.resolve());continue}let f=typeof c=="string"?H(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===jr){let m=this.data.getNode(h);m&&Object.assign(r,m.getAttr("_wdg"))}}let l=Pu(i,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(jr);l.delete(jr);for(let c of l.keys())s.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,i,s){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 i=(typeof t=="function"?t:t.constructor)[e];if(typeof i=="function")return i}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[i,s]of Object.entries(t))uc.has(i)||(r[i]=s);return r}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let r={};for(let[i,s]of Object.entries(t))i!=="destination"&&i!=="value"&&!i.startsWith("_")&&(r[i]=s);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(r).length?r:null})}else if(e.nodeTag==="dataFormula"){let r=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,r(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=r=>{for(let i of r.getNodes())i._getMeta("data_element")&&e.push(i),i.value instanceof A&&t(i.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 lc(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},r={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},r[a.toLowerCase()]=l;let i=Fn(t),s=this._collection||this.constructor._classCollection,o=s.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ct(s.toDocument()).update(o),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=i}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(qn,new t(null,this),e?{datapath:e}:null),r.getItem(qn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Qt(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 r=this.getRenderer(e),i=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=i,i}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...r}={}){e??=this.constructor._defaultRenderMode;let i=this.getRenderer(e);if(t===!1&&i.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let s=t===!1?null:t||this._defaultTargets.get(i.mode)||null,o={...s?.renderOpts,...r};return i.finalize(this.materialize(e,o),s,o)}};Te._registry=new Map;var Gm=new Set(["short","medium","long","full"]),Xm=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Ym(n,e){if(!(n instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(n.getTime()))throw new RangeError("Invalid date");let t=e||F(n).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Zm(n,e,t,r){let i=e.match(Xm)||[];if(i.join("")!==e)throw new RangeError("Unclosed format literal");let s=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>s(n.getUTCFullYear()%100),yyyy:()=>s(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>s(n.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>s(n.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>s(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>s(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>s(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>s(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return i.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 cc(n,{format:e,mask:t,locale:r,dtype:i,places:s}={}){let o=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||s!=null))if(typeof n=="number"||be(n))o=Km(n,{format:e,locale:r,places:s});else{let a=Ym(n,i);if(Gm.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(r||void 0,l).format(n)}else o=Zm(n,String(e),r||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Jm({format:n="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!n||n==="decimal")t.style="decimal";else if(n==="percent")t.style="percent";else if(n==="scientific")t.notation="scientific";else{let r=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(n);if(!r||n.includes(".")&&!r[2]&&!r[3])throw new RangeError(`Unsupported number format: ${n}`);t.useGrouping=r[1].includes(","),t.minimumFractionDigits=(r[2]||"").length,t.maximumFractionDigits=(r[2]||"").length+(r[3]||"").length}if(e!=null&&e!==""){let r=Number(e);if(!Number.isInteger(r)||r<0||r>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=r,t.maximumFractionDigits=r}return t}function Km(n,e={}){if(typeof n!="number"&&!be(n))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(n)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Jm(e));if(be(n)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(be(n)?n.toString():n)}var Qm=new Set(["style","script"]),eg=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"]),dc=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"]),Vn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),fc=n=>n===!0?"true":n===!1?"false":String(n),cs=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function tg(n){if(dc.has(n))return!0;for(let e of dc)if(n.startsWith(`${e}_`))return!0;return!1}function rg(n){let e=new Map;if(!n)return e;let t=[],r=0,i=null,s=!1,o=!1,a=0,l=String(n);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(s){s=!1;continue}if(c==="\\"){s=!0;continue}if(i){c===i&&(i=null);continue}c==='"'||c==="'"?i=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(r,u)),r=u+1)}t.push(l.slice(r));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 er=class extends Kt{static mode="html";renderedItem(e,t,r,{tag:i,xml:s=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(r={xmlns:"http://www.w3.org/1999/xhtml",...r});let{format:c,mask:d,locale:f,places:h,dtype:m,...p}=r;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=cc(t,{format:c,mask:d,places:h,dtype:m,locale:this._displayLocale(e,f)}));let b=this._formatAttrs(p);if(l){if(!Object.hasOwn(r,"id")){let E=this.builder.targetId(e);E!==null&&(b+=` id="${this._htmlAttrValue(E)}"`)}for(let[E,D]of Object.entries(e.getAttr()))e.pointerType(D)&&(b+=` data-${this.adapt(E)}-pointer="${this._htmlAttrValue(e.absDatapath(D))}"`)}let g=o?" ".repeat(this._nodeDepth(e,a)):"",_=o?`
|
|
40
|
+
`:"";if(e._getMeta("void"))return`${g}<${i}${b}${s?"/":""}>${_}`;if(Array.isArray(t)){let E=this._composeStringFragments(t);return`${g}<${i}${b}>${_}${E}${g}</${i}>${_}`}if(t==null)return`${g}<${i}${b}></${i}>${_}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Qm.has(i)?String(t):this._escapeText(t);return`${g}<${i}${b}>${w}</${i}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let i=r.getAttr("locale");if(i==null)continue;let s=r.pointerType(i)?r.data.getItem(r.absDatapath(i)):i;if(s)return s}}adaptAttrs(e){let t={},r={};for(let[s,o]of Object.entries(e||{}))if(s.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(s)]=o;else if(s==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>s.startsWith(a)))continue;this._isStyleContribution(s)?r[s]=o:t[s]=o}let i=this._adaptStyle(r);return i&&(t.style=i),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||Vn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&Vn.has(t)||tg(e)}_adaptStyle(e){let t=rg(e.style),r=new Map,i=new Map;for(let[s,o]of Object.entries(e))if(s!=="style")if(s.startsWith("style_"))t.set(s.slice(6).replaceAll("_","-"),fc(o));else if(Vn.has(s))r.set(s,o);else{let a=s.indexOf("_"),l=a<0?s:s.slice(0,a);a>=0&&Vn.has(l)?(i.has(l)||i.set(l,{}),i.get(l)[s.slice(a+1)]=o):t.set(s.replaceAll("_","-"),fc(o))}for(let s of Vn)(r.has(s)||i.has(s))&&this[`_macro_${s}`](r.get(s),i.get(s)||{},t);return[...t].map(([s,o])=>`${s}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,i]of Object.entries(e||{}))eg.has(r)?i&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(i)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_macro_rounded(e,t,r){let i=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[s,o]of Object.entries(t))if(s==="top"||s==="bottom")i[`${s}_left`]=o,i[`${s}_right`]=o;else if(s==="left"||s==="right")i[`top_${s}`]=o,i[`bottom_${s}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(s))i[s]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${s}'`);for(let[s,o]of Object.entries(i))r.set(`border-${s.replaceAll("_","-")}-radius`,cs(o))}_macro_transform(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`rotate(${o}deg)`):s==="scale"||s==="translate"?i.push(`${s}(${o})`):s==="translate_x"?i.push(`translateX(${cs(o)})`):s==="translate_y"?i.push(`translateY(${cs(o)})`):s==="skew_x"?i.push(`skewX(${o}deg)`):s==="skew_y"?i.push(`skewY(${o}deg)`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("transform",i.join(" "))}_macro_filter(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`hue-rotate(${o}deg)`):s==="blur"?i.push(`blur(${cs(o)})`):s==="drop_shadow"?i.push(`drop-shadow(${o})`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("filter",i.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[i,s]of Object.entries(t))r.set(`transition-${i.replaceAll("_","-")}`,String(s))}_macro_zoom(e,t,r){e!==void 0&&r.set("zoom",String(e))}_macro_shadow(e,t,r){e!==void 0&&r.set("box-shadow",String(e));for(let[i,s]of Object.entries(t))r.set(`box-shadow-${i.replaceAll("_","-")}`,String(s))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var ng=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 ds(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[ng.has(e)?e.replaceAll("_","-"):e,t]))}var tr=class extends Qt{static mode="svg";adaptAttrs(e){return ds(e)}};var hc={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 Nt=class extends Te{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(hc)}get renderer_html(){return new er(this)}};Te.registerBuilder(Nt);var pc={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 It=class extends Te{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(pc)}get renderer_svg(){return new tr(this)}};Te.registerBuilder(It);function We(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(K(n)instanceof Ae||t&&n instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(n))throw new TypeError("Transport data cannot contain circular references");e.add(n);let r=n instanceof x?n.getNodes().flatMap(i=>[i.staticValue,i.getAttr()]):Object.values(n);for(let i of r)We(i,e);e.delete(n)}var zn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,i=s=>{for(let o of s.getNodes()){let a=o.getAttr("__ref");if(a){if(r.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");r.set(a,o)}o.value instanceof A&&i(o.value)}};i(e)}register(e,t){let r=e.getAttr("__ref");if(r){if(this.entries.has(r))throw new Error(`Duplicate Source reference: ${r}`);this.entries.set(r,{node:e,dom:t})}}remove(e){for(let[t,r]of this.entries)r.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r&&typeof r=="object"&&Object.hasOwn(r,"$gramlotRef")?this.resolve(r):r]))}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]}};function Y(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var De=class{constructor(e){this.gramlot=e}};var rr=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:i}){super(r),this.code=e,this.remoteName=t,i!==void 0&&(this.details=i)}},Hn=class extends De{constructor(e,{rpcUrl:t,closeUrl:r,document:i,transport:s}){super(e),this.transport=s===!1?null:s??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:i,channel:e._pageStore}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,r={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(We(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let i=Y(),s=j(this.transport.callSync(F({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(s.id!==i)throw new Error("rpc response id mismatch");if(s.error)throw new rr(s.error);return s.value}async call(e,t,r={},i={}){return(await this.callEnvelope(e,t,r,i)).value}async callEnvelope(e,t,r={},{signal:i=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);We(r);let s=Y(),o=F({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),a=i?[this.gramlot.abort.signal,i]:[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(s),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(s,u);try{let f=j(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==s)throw new Error("rpc response id mismatch");if(f.error)throw new rr(f.error);return f}finally{this.remoteRequests.delete(s);for(let f of a)f.removeEventListener("abort",c)}}};var fs=class{constructor(e,t,r){this.gramlot=e,this.window=r.defaultView,this.frames=e._frames,this.binders=new Map,this.calls=new Map,this.routes=new Map,this.error=null,this.closed=!1,this.ready=!1,this.socket=null;let i=new URL(t,r.baseURI);i.protocol=i.protocol==="https:"?"wss:":"ws:",this.endpoint=i.href,this.origin=this.window.location.origin,this.parent=this.frames.parent?.window??null,this.frames.registerChannel("server",{changed:s=>this.peerChanged(s),disconnected:s=>{s.parent?this.fail(new Error("PageStore parent disconnected")):this.forget(s.window)},receive:(s,o)=>{try{this.receive(s,o)}catch(a){this.fail(a)}}},{endpoint:this.endpoint,ready:!1}),!this.parent&&(i.searchParams.set("pageId",e.pageId),this.socket=new this.window.WebSocket(i.href),this.socket.addEventListener("open",()=>this.connected()),this.socket.addEventListener("message",s=>{try{this.deliver(s.data)}catch(o){this.fail(o)}}),this.socket.addEventListener("error",()=>this.fail(new Error("PageStore WebSocket failed"))),this.socket.addEventListener("close",s=>{this.closed||this.fail(new Error("PageStore disconnected ("+s.code+")"))}))}peerChanged(e){if(this.closed||!e.parent)return;let t=e.channels.server;e.origin!==this.origin||t?.endpoint!==this.endpoint?this.fail(new Error("Parent does not provide the same PageStore endpoint")):t.ready?this.connected():this.ready&&this.fail(new Error("PageStore parent channel closed"))}connected(){if(!(this.closed||this.ready)){this.ready=!0,this.parent&&this.upstream({op:"attach",pageId:this.gramlot.pageId});for(let e of this.binders.values())this.subscribe(e);for(let e of this.calls.values())this.sendCall(e);this.frames.setChannelState("server",{endpoint:this.endpoint,ready:!0})}}receive(e,t){if(this.closed||e.origin!==this.origin||e.channels.server?.endpoint!==this.endpoint)return;if(e.parent){this.deliver(F(t));return}if(!this.ready)return;let r=t?.pageId;if(!(typeof r!="string"||!r||r===this.gramlot.pageId)){if(t.op==="attach"){if(this.routes.has(r))return;this.routes.set(r,e.window)}else if(this.routes.get(r)!==e.window)return;t.op==="detach"&&this.routes.delete(r),this.upstream(t)}}forget(e){for(let[t,r]of this.routes)r===e&&(this.routes.delete(t),this.ready&&!this.closed&&this.upstream({op:"detach",pageId:t}))}upstream(e){if(this.closed||!this.ready)throw new Error("PageStore is not connected");this.parent?this.frames.send(this.parent,"server",e):this.socket.send(F(e))}deliver(e){if(this.closed)return;let t=j(e);if(t.pageId===this.gramlot.pageId){if(t.op==="closed"){this.fail(new Error("PageStore page closed on the server"));return}if(!Object.hasOwn(t,"op")&&Object.hasOwn(t,"id")){this.calls.get(t.id)?.finish(null,e);return}if(t.op==="publish"){try{this.gramlot._subscriptions.publish(t.topic,t.payload,t.metadata)}catch(i){this.window.console.error("PageStore publication subscriber failed",i)}return}let r=this.binders.get(t.binderId);r&&r.apply(t)}else{let r=this.routes.get(t.pageId);r&&this.frames.send(r,"server",t)}}register(e){if(this.closed)throw new Error("PageStore connection is closed");this.binders.set(e.id,e),this.ready&&this.subscribe(e)}subscribe(e){this.send({op:"subscribe",binderId:e.id,path:e.serverPath})}unregister(e){this.binders.delete(e.id)&&!this.closed&&this.ready&&this.send({op:"unsubscribe",binderId:e.id})}send(e){this.upstream({...e,pageId:this.gramlot.pageId})}preparePublish(e,t){if(this.closed||!this.ready)throw new Error("PageStore is not connected");We(t);let r={op:"publish",id:Y(),pageId:this.gramlot.pageId,topic:e.topic,payload:t};e.pageId!==void 0&&(r.targetPageId=e.pageId);let i=F(r);return async()=>{let s=j(await this.call(i));if(s.error)throw new rr(s.error);return s.value}}call(e,t){if(this.closed)return Promise.reject(this.error??new Error("PageStore connection is closed"));if(t?.aborted)return Promise.reject(t.reason);let r=j(e);return r.pageId!==this.gramlot.pageId||typeof r.id!="string"||!r.id||Object.hasOwn(r,"op")&&r.op!=="publish"||this.calls.has(r.id)?Promise.reject(new Error("Invalid or duplicate RPC identity")):new Promise((i,s)=>{let o={message:r,sent:!1,finish:(l,u)=>{this.calls.delete(r.id)&&(t?.removeEventListener("abort",a),u===void 0?s(l):i(u))}},a=()=>{if(o.finish(t.reason),o.sent&&this.ready&&!this.closed)try{this.send({op:"cancel",id:r.id})}catch(l){this.fail(l)}};this.calls.set(r.id,o),t?.addEventListener("abort",a,{once:!0}),this.ready&&this.sendCall(o)})}sendCall(e){try{this.upstream(e.message),e.sent=!0}catch(t){e.finish(t),this.fail(t)}}fail(e){this.error=e,this.close(),this.window.console.error("PageStore channel failed",e)}close(){if(!this.closed){if(this.closed=!0,this.parent&&this.ready&&this.frames.isConnected(this.parent))for(let e of[...this.routes.keys(),this.gramlot.pageId])this.frames.send(this.parent,"server",{op:"detach",pageId:e});this.ready=!1;for(let e of this.calls.values())e.finish(this.error??new Error("PageStore connection is closed"));this.binders.clear(),this.routes.clear(),this.frames.unregisterChannel("server"),this.socket?.close()}}};var mc="gramlot:message",hs=class{#e;#t;#r;#n=Y();#i=new Map;#s=new Map;#o=!1;#a;#l;#c;#u;#d;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#a=r=>this.#g(r),this.#l=r=>{if(r.target?.localName!=="iframe")return;let i=this.#y(r.target);i&&this.#_(i)},this.#c=r=>{r.persisted||this.#e.dispose({beacon:!0})},this.#u=()=>this.ready(),this.#t.addEventListener("message",this.#a),this.#t.addEventListener("pagehide",this.#c),this.#t.addEventListener("pageshow",this.#u),t.addEventListener("load",this.#l,!0)}#f(){this.#d===void 0&&(this.#d=this.#t.setInterval(()=>{if(this.parent?.window.closed){this.#p();return}for(let e of this.children)e.window.closed?this.#h(e.window):e.node&&!this.#y(this.#e.dom.getDomNode(e.node))&&this.#h(e.window,!0)},500))}get parent(){let e=this.#t.parent!==this.#t,t=e?this.#t.parent:this.#t.opener;return t?{window:t,parent:!0,kind:e?"iframe":"popup",origin:this.#E(this.#r.referrer||this.#r.baseURI)}:null}get children(){return[...this.#i.values()].filter(e=>!e.parent)}isConnected(e){return!this.#o&&this.#i.has(e)}connect(){this.parent&&(this.#f(),this.#_(this.parent));for(let e of this.#r.getElementsByTagName("iframe")){let t=this.#y(e);t&&this.#_(t)}}ready(){if(!this.#o){this.connect();for(let e of this.#i.values())this.#v(e)}}registerChannel(e,t,r){if(this.#o||e==="publish"||this.#s.has(e))throw new Error("Invalid family channel");this.#s.set(e,{handler:t,state:r});for(let i of this.#i.values())t.changed(i)}setChannelState(e,t){this.#s.get(e).state=t;for(let r of this.#i.values())this.#v(r)}unregisterChannel(e){if(this.#s.delete(e),this.#e.state!=="disposed")for(let t of this.#i.values())this.#v(t)}send(e,t,r){let i=this.#i.get(e);if(this.#o||!i)throw new Error("Destination page is not connected");We(r),this.#w(i,{kind:"message",recipient:i.session,channel:t,wire:F(r)})}prepare(e,t){let r=[];if(e.parent){if(!this.parent)throw new Error("This page has no parent frame or opener");r.push(this.parent)}if(e.iframe!==void 0){let o=e.iframe,a=K(o),l=typeof o=="string"?this.#r.getElementById(o):a instanceof Ae?this.#e.dom.getDomNode(a):null,u=this.#y(l);if(!u)throw new Error("iframe destination must be an active Gramlot iframe ID or Source reference");r.push(u)}if(e.pageId!==void 0){let o=this.children.find(a=>a.pageId===e.pageId);if(!o)throw new Error("pageId destination must be a registered direct Gramlot child");r.push(o)}let i=r.map(o=>{let a=this.#i.get(o.window);if(!a?.ready||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});We(t);let s=F({topic:e.topic,payload:t});return()=>{if(!this.#o)for(let o of i){let a=this.#k(o.window);if(!a||a.origin!==o.origin||this.#i.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#w(o,{kind:"message",recipient:o.session,channel:"publish",wire:s})}}}dispose(){if(this.#o)return;for(let t of this.children)this.#h(t.window,!0);let e=this.parent;e&&this.#i.has(e.window)&&(this.#w(this.#i.get(e.window),{kind:"close"}),this.#h(e.window)),this.#o=!0,this.#s.clear(),this.#t.removeEventListener("message",this.#a),this.#t.removeEventListener("pagehide",this.#c),this.#t.removeEventListener("pageshow",this.#u),this.#t.clearInterval(this.#d),this.#r.removeEventListener("load",this.#l,!0)}#p(){this.#e.dispose({beacon:!0}),this.#t.parent===this.#t&&this.#t.opener&&this.#t.close()}#h(e,t=!1){let r=this.#i.get(e);if(r){t&&this.#w(r,{kind:"close"}),this.#i.delete(e),r.release?.();for(let{handler:i}of this.#s.values())i.disconnected(r);t&&r.kind==="popup"&&!r.parent&&e.close()}}#m(e,t){let r=this.#i.get(e.window),i=r?.session!==t.session;i&&this.#h(e.window);let s=i?{...e,session:t.session}:r;Object.assign(s,{ready:t.ready===!0,pageId:t.pageId,channels:t.channels}),this.#i.set(e.window,s),this.#f(),i&&e.node&&(s.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#h(e.window,!0)}));for(let{handler:o}of this.#s.values())o.changed(s);return i}#g(e){if(this.#o||e.data?.type!==mc)return;let t=this.#k(e.source);if(!t||e.origin!==t.origin)return;let r=e.data;if(typeof r.session!="string"||!r.session)return;if(r.kind==="hello"||r.kind==="ready"){if(r.kind==="ready"&&r.recipient!==this.#n||!r.channels||typeof r.channels!="object"||Array.isArray(r.channels))return;let s=this.#m(t,r);(r.kind==="hello"||s)&&this.#v(this.#i.get(t.window));return}let i=this.#i.get(t.window);if(!(!i||i.session!==r.session||r.recipient!==this.#n)){if(r.kind==="close")t.parent?this.#p():this.#h(t.window);else if(r.kind==="message"&&typeof r.wire=="string"){let s=j(r.wire);if(r.channel==="publish"){if(this.#e.state!=="started"||!i.ready||typeof s.topic!="string"||!s.topic)return;this.#e.publish(s.topic,s.payload)}else this.#s.get(r.channel)?.handler.receive(i,s)}}}#b(){return{pageId:this.#e.pageId,ready:this.#e.state==="started",channels:Object.fromEntries([...this.#s].map(([e,t])=>[e,t.state]))}}#_(e){this.#w(e,{kind:"hello",...this.#b()})}#v(e){this.#w(e,{kind:"ready",recipient:e.session,...this.#b()})}#w(e,t){e.window.postMessage({type:mc,session:this.#n,recipient:e.session,...t},e.origin==="null"?"*":e.origin)}#y(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 r=e.getAttribute("sandbox"),s=r!==null&&!r.split(/\s+/).includes("allow-same-origin")?"null":this.#E(e.hasAttribute("srcdoc")?this.#r.baseURI:e.getAttribute("src")||this.#r.baseURI);return{window:e.contentWindow,origin:s,node:t,parent:!1,kind:"iframe"}}#E(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#k(e){let t=this.parent;if(t?.window===e)return t;for(let r of this.#r.getElementsByTagName("iframe")){let i=this.#y(r);if(i?.window===e)return i}try{if(e&&e!==this.#t&&e.opener===this.#t&&e.location.origin===this.#t.location.origin)return{window:e,origin:this.#E(this.#r.baseURI),parent:!1,kind:"popup"}}catch{}return null}};var nr=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=Fr.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 n(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Wn=new nr(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var oa=["TL","TC","TR","L","R","BL","BC","BR"],gc=`.gramlot-labelbox[hidden]{display:none!important}
|
|
41
41
|
.gramlot-labelbox{box-sizing:border-box;min-width:0;min-height:0;--gramlot-label-width:initial;--gramlot-formlet-label-width:initial;display:grid;gap:var(--gramlot-label-gap,.25em);grid-template-areas:'label' 'control';grid-template-columns:minmax(0,1fr);grid-template-rows:max-content minmax(0,1fr)}
|
|
42
42
|
.gramlot-labelbox>.label-box{grid-area:label;color:var(--gramlot-label-color,var(--gramlot-text-secondary,inherit));font-size:var(--gramlot-label-size,1em)} .gramlot-labelbox>.control-box{box-sizing:border-box;grid-area:control;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
|
|
43
43
|
.gramlot-labelbox>.control-box>*{max-width:100%;box-sizing:border-box}
|
|
@@ -80,7 +80,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
80
80
|
.gramlot-labelbox>.tray-resize[hidden]{display:none}
|
|
81
81
|
.gramlot-labelbox>.tray-resize svg{width:16px;height:16px;pointer-events:none}
|
|
82
82
|
.gramlot-labelbox>.tray-resize:hover,.gramlot-labelbox>.tray-resize:focus-visible{opacity:1}
|
|
83
|
-
.gramlot-labelbox>.tray-resize:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}`;function
|
|
83
|
+
.gramlot-labelbox>.tray-resize:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}`;function bc(n,e){let t=n.createElement("div"),r=n.createElement("div"),i=n.createElement("label");r.append(i),t.append(r,e);let s={box:t,labelBox:r,fieldLabel:i,controlBox:e,previous:{box:{},label:{},labelBox:{},controlBox:{}}};return t.labelbox=s,s}function _c(n,e,t){let{lbl:r,lbl_variant:i,lbl_position:s=i==="card"?"TC":"TL",...o}=e;if(!oa.includes(s))throw new TypeError(`Invalid lbl_position: ${s}`);let a={box:{},label:{},labelBox:{},controlBox:{}},l=[["box_l_","labelBox"],["box_c_","controlBox"],["lbl_","label"],["box_","box"]];for(let[c,d]of Object.entries(o)){let f=l.find(([h])=>c.startsWith(h));f&&(a[f[1]][c.slice(f[0].length)]=d,delete o[c])}let u={box:n.box,label:n.fieldLabel,labelBox:n.labelBox,controlBox:n.controlBox};for(let[c,d]of Object.entries(u)){let f=t(a[c]),h=n.previous[c];for(let m of new Set([...Object.keys(h),...Object.keys(f)]))f[m]==null?d.removeAttribute(m):d.setAttribute(m,String(f[m]));n.previous[c]=f}return e.lbl_width==null?n.box.style.removeProperty("--gramlot-label-width"):n.box.style.setProperty("--gramlot-label-width",e.lbl_width),n.box.classList.add("labelbox","gramlot-labelbox"),n.labelBox.classList.add("label-box"),n.controlBox.classList.add("control-box"),n.box.dataset.position=s,i==null?delete n.box.dataset.variant:n.box.dataset.variant=i,n.fieldLabel.textContent=r??"",n.labelBox.hidden=r==null||r==="",n.box.dispatchEvent(new n.box.ownerDocument.defaultView.Event("gramlot-label-layout",{bubbles:!0})),o}function fe(n){return n?.labelbox?n.labelbox.controlBox.firstElementChild:n}function qr(n){let e=n?.parentElement?.parentElement;return e?.labelbox&&fe(e)===n?e:n}var og=/^[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,ag=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function dt(n){let e=n.code;if(typeof e!="string"||og.exec(e)?.[0]!==e||!e.includes("-")||ag.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function aa(n){for(let e of Object.values(n))e&&typeof e=="object"&&aa(e);return Object.freeze(n)}function wc(n){if(!n.annotation&&typeof n.dtype!="string"&&!Array.isArray(n.dtype))throw new TypeError("Component parameter requires dtype");let e=n.annotation?[structuredClone(n.annotation)]:(Array.isArray(n.dtype)?n.dtype:[n.dtype]).map(t=>({kind:"dtype",dtype:t}));return n.nullable&&e.push({kind:"dtype",dtype:"NN"}),n.binding&&n.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 Bt({name:n,tag:e,base:t,mixins:r=[],parameters:i={},subTags:s="",presentationDefaults:o=[],dataScope:a=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,dragSource:f=!1,implementation:h}){if(dt({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n))throw new TypeError("Invalid component authoring name");let m={...t.parameters};for(let p of r)for(let[b,g]of Object.entries(p.parameters)){if(Object.hasOwn(m,b))throw new Error(`Duplicate mixin parameter: ${b}`);m[b]=g}Object.assign(m,i);for(let p of Object.values(m))wc(p);return Object.freeze({name:n,tag:e,base:t,subTags:s,presentationDefaults:Object.freeze([...o]),dataScope:a,command:l,bagStore:d,mixins:Object.freeze([...r]),labelbox:r.some(p=>p.labelbox===!0),parameters:aa(structuredClone(m)),childParameters:aa(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var Ot=class n{#e=new WeakMap;constructor({name:e,components:t,dependencies:r=[],css:i=[],assets:s={},registerCommands:o=()=>{}}){if(typeof e!="string"||!e)throw new TypeError("Collection name must be nonempty");if(!Array.isArray(r)||r.some(u=>!(u instanceof n)))throw new TypeError("Collection dependencies must be collection objects");if(!Array.isArray(i)||i.some(u=>!(u instanceof URL))||!s||typeof s!="object"||Array.isArray(s)||Object.values(s).some(u=>!(u instanceof URL)))throw new TypeError("Collection css/assets require URL objects");if(typeof o!="function")throw new TypeError("registerCommands must be a function");this.dependencies=Object.freeze([...r]),this.css=Object.freeze([...i]),this.assets=Object.freeze({...s}),this.registerCommands=o,this.name=e,this.components=Object.freeze([...t]);let a=new Set,l=new Set;for(let u of t){if(a.has(u.name.toLowerCase())||l.has(u.tag))throw new Error(`Duplicate component: ${u.name}`);a.add(u.name.toLowerCase()),l.add(u.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,r])=>({name:t,kind:"keyword_only",role:"attribute",annotation:wc(r),has_default:!0,default:r.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.labelbox?{labelbox:!0}:{},...e.dragSource?{dragSource:!0}:{},...e.bagStore?{bagStore:!0}:{}}}}]))}}register(e){if(this.#e.has(e))return;let t=[];for(let r of this.components){if(e.customElements.get(r.tag))throw new Error(`Custom element already registered: ${r.tag}`);let i=r.base(e.HTMLElement);for(let o of r.mixins)i=o(i);let s=r.implementation(i);Object.defineProperty(s,"gramlotComponent",{value:r}),t.push([r.tag,s])}for(let[r,i]of t)e.customElements.define(r,i);this.#e.set(e,t)}};function la(n){return new Ot(n)}function Ur(n,e){return n.parameters=Object.fromEntries(Object.entries(n.constructor.gramlotComponent.parameters).map(([t,r])=>[t,Object.hasOwn(e,t)?e[t]:r.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(n.parameters,t)))}function yc(n,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(n==="")return[];let t=new Set;return n.split(e).map(r=>{let i=r.indexOf(":"),s=i<0?r:r.slice(0,i),o=i<0?r:r.slice(i+1);if(!s||t.has(s))throw new Error("Invalid or duplicate choice code");return t.add(s),{id:s,caption:o}})}function ps(n){return class extends n{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}
|
|
84
84
|
input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
|
|
85
85
|
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
|
|
86
86
|
appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
@@ -95,7 +95,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
95
95
|
input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
|
|
96
96
|
input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
|
|
97
97
|
.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)}
|
|
98
|
-
.caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return qr(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 gc(n){return class extends cs(n){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 r=super.projectAttributes(e,t),{disabled:i,readonly:s}=this.parameters;this.control.disabled=!!i,this.control.readOnly=!!s;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 r}}}gc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function bc(n){return class extends cs(n){#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)")],r=t.indexOf(e.target);if(r<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,r+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[i].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.values??"";if(i!==this.#t){let o=mc(i),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 m=this.ownerDocument.createElement("input");m.type=this.choiceType,m.name="choice",m.value=u;let p=this.ownerDocument.createElement("span");h.append(m,p),d={label:h,input:m,text:p},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=i}let s=this.parameters.cols;if(!Number.isInteger(s)||s<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${s}, 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 r}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(r=>!this.#e.has(r)||this.#e.get(r).input.checked);for(let[r,{input:i}]of this.#e)i.checked&&!t.includes(r)&&t.push(r);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[r,{input:i}]of this.#e)i.checked=this.multiple?t.has(r):r===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:r})=>r.checked&&!r.disabled)??t.find(({input:r})=>!r.disabled))?.input.focus(e)}}}bc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Ur(n,e,{align:t="start",matchWidth:r=!1,inset:i=0,placement:s="bottom",point:o=null}={}){let a=e.ownerDocument.defaultView,l=o?{left:o.x,right:o.x,top:o.y,bottom:o.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,a.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*i),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(s==="side"){let g=Math.max(0,a.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),w=c.width>g&&_>g;n.style.setProperty("--gramlot-popup-available-width",`${w?_:g}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,a.innerHeight-16)}px`);let E=n.getBoundingClientRect(),D=w?l.left-E.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(D,a.innerWidth-E.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,a.innerHeight-E.height-8))}px`;return}let d=Math.max(0,a.innerHeight-8-l.bottom-3),f=Math.max(0,l.top-8-3),h=c.height>d&&f>d;n.style.setProperty("--gramlot-popup-available-height",`${h?f:d}px`);let m=n.getBoundingClientRect(),p=t==="end"?l.right-m.width-i:l.left+i,b=h?l.top-m.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(p,a.innerWidth-m.width-8))}px`,n.style.top=`${Math.max(8,Math.min(b,a.innerHeight-m.height-8))}px`}function _c(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function fs(n,e){return _c(e),e==null?n:e.replaceAll("{}",()=>n)}function ig(n){if(n instanceof Date)return kt(n);if(be(n))return"N";if(typeof n=="number")return Number.isInteger(n)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function sg(n,e,{pattern:t="short",locale:r,timeZone:i}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof i!="string"||!i))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let s={timeZone:e==="DHZ"?i:"UTC"};return e!=="H"&&(s.dateStyle=t),e!=="D"&&(s.timeStyle=t),new Intl.DateTimeFormat(r,s).format(n)}function ds(n){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(n);if(!e||e[1]==="("!=(e[4]===")")||n.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${n}`);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 og(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=ds(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let r=e.length===3?e[1]:null;r!==null&&r!==""&&r!=="-"&&ds(r);let i=e.length>1?ds(e.at(-1)):null;return{positive:t,zero:r,negative:i}}function wc(n,e={},t={}){if(n===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 b of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(b))throw new RangeError(`Unsupported format option: ${b}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?ig(n):e.dtype,i=["D","H","DHZ"].includes(r);if(!i&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(i){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError(`${r} requires a valid Date object`)}else if(!(typeof n=="number"&&Number.isFinite(n))&&!(be(n)&&!["NaN","Infinity","-Infinity"].includes(n.toString())))throw new TypeError(`${r} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(r==="L"&&!Number.isInteger(n))throw new TypeError("L formatting requires an integer");let{pattern:s,locale:o,mask:a}=e;if(!i&&typeof s!="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(!(i?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(_c(a),i){let b=sg(n,r,e);return fs(b,a)}let{positive:u,zero:c,negative:d}=og(s),f=be(n),h=f?n.eq(0):n===0,m=f?n.lt(0):n<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let p;if(h&&c!==null){if(c==="")return"";if(c==="-")p="-";else{let b=ds(c);p=b.prefix+new Intl.NumberFormat(o,b.intl).format(0)+b.suffix}}else{let b=m&&d?d:u,g=f?(m&&d?n.abs():n).toString():m&&d?-n:n===0?0:n;p=b.prefix+new Intl.NumberFormat(o,u.intl).format(g)+b.suffix}return fs(p,a)}var we="http://www.w3.org/1999/xhtml",Bt="http://www.w3.org/2000/svg",ag=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","onEnd","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),lg=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],ug={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},cg=["format","mask","locale","timeZone","places","dtype"],dg=new Set(["href","src","data","action","formaction","xlink:href","xlink_href"]);function Rt(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!ag.has(e)&&!lg.some(r=>e.startsWith(r))))}function zr(n,e,t=[]){for(let[r,i]of Object.entries(e)){let s=t.find(a=>r.startsWith(a))??"",o=r.slice(s.length);if(["style","class","_class"].includes(o)&&i!=null&&typeof i!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function Hr(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],..._e(n.getAttr()).filter(([i])=>["src","href","xlink:href","xlink_href","_text"].includes(i.slice((t.find(s=>i.startsWith(s))??"").length).toLowerCase()))];for(let[i,s]of r)if(n.pointerType(s)||Fe(s))throw new Error(`script '${n.label}': '${i}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onEnd!=null&&(n.nodeTag.toLowerCase()!=="transformpane"||!n._getMeta("gramlot_component")?.parameters?.onEnd))throw new Error("onEnd is only supported on transformPane");if(e.onClose!=null&&!n.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[r,i]of Object.entries(Wr(Rt(e)))){let s=t.find(a=>r.startsWith(a)),o=s?r.slice(s.length):r;if(/^on./i.test(o))throw new Error(`${n.nodeTag} '${n.label}': '${r}' 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(dg.has(o.toLowerCase())&&fg(i))throw new Error(`${n.nodeTag} '${n.label}': '${r}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function fg(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function yc(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},i=Object.fromEntries(_e(n.getAttr())),s=[...Object.keys(i),...Object.keys(e)].find(a=>r(a)[1]==="srcdoc");if(s===void 0||Object.keys(i).some(a=>r(a)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(i,s)&&(n.pointerType(i[s])!==null||Fe(i[s]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>r(a)[1]!=="sandbox"));return{[`${r(s)[0]}sandbox`]:"",...o}}function Wr(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function Vn(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function hs(n){let{_meta:e,...t}=n;return Vn(Wr(Rt(t)))}function vc(n,e){let t=ug[String(n).toLowerCase()]??[],r={},i={};for(let[s,o]of Object.entries(e))t.includes(s)?i[s]=o:r[s]=o;return[r,i]}function Vr(n){return String(n)}function zn(n,e,t=null){let r={...e},{mask:i,format:s,locale:o,timeZone:a,dtype:l,places:u}=r;for(let d of cg)delete r[d];let c=d=>{if(t&&s!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:s,mask:i,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=Vr(d)),i==null)return d;let f=d==null?"":Vr(d);return f===""?f:fs(f,i)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function Fe(n){return typeof n=="string"&&n.startsWith("==")}var ps=class{#e;#t;#r;#n;#i;#s;#o;#a=null;#l=!1;#c=[];#u=new Set;constructor(e,t){this.#e=e;let r=e.ownerDocument;this.#t=r.createElement("div"),this.#t.className="toolbar-viewport",this.#t.append(t),this.#n=r.createElement("button"),this.#n.type="button",this.#n.className="toolbar-more",this.#n.hidden=!0,this.#n.title="More commands";let i=r.createElementNS(Bt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");let s=r.createElementNS(Bt,"path");s.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),s.setAttribute("fill","none"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width","1.8"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.append(s),this.#n.append(i),this.#n.setAttribute("aria-label","More commands"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.#r=r.createElement("div"),this.#r.className="toolbar-overflow",this.#r.setAttribute("popover","manual"),this.#r.setAttribute("role","menu"),this.#r.tabIndex=-1;let o=r.createElement("slot");o.name="overflow",this.#r.append(o),this.#n.addEventListener("click",()=>this.#l?this.close():this.open()),this.#n.addEventListener("keydown",l=>{["ArrowDown","ArrowRight"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.open())}),this.#r.addEventListener("keydown",l=>{l.key==="Escape"&&!l.composedPath().some(u=>u.localName==="gramlot-menu"&&u!==e)&&(l.preventDefault(),l.stopPropagation(),this.close())});let a=r.createElement("style");a.textContent=`
|
|
98
|
+
.caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return Ur(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 vc(n){return class extends ps(n){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 r=super.projectAttributes(e,t),{disabled:i,readonly:s}=this.parameters;this.control.disabled=!!i,this.control.readOnly=!!s;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 r}}}vc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function Ec(n){return class extends ps(n){#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)")],r=t.indexOf(e.target);if(r<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,r+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[i].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.values??"";if(i!==this.#t){let o=yc(i),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 m=this.ownerDocument.createElement("input");m.type=this.choiceType,m.name="choice",m.value=u;let p=this.ownerDocument.createElement("span");h.append(m,p),d={label:h,input:m,text:p},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=i}let s=this.parameters.cols;if(!Number.isInteger(s)||s<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${s}, 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 r}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(r=>!this.#e.has(r)||this.#e.get(r).input.checked);for(let[r,{input:i}]of this.#e)i.checked&&!t.includes(r)&&t.push(r);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[r,{input:i}]of this.#e)i.checked=this.multiple?t.has(r):r===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:r})=>r.checked&&!r.disabled)??t.find(({input:r})=>!r.disabled))?.input.focus(e)}}}Ec.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Vr(n,e,{align:t="start",matchWidth:r=!1,inset:i=0,placement:s="bottom",point:o=null}={}){let a=e.ownerDocument.defaultView,l=o?{left:o.x,right:o.x,top:o.y,bottom:o.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,a.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*i),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(s==="side"){let g=Math.max(0,a.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),w=c.width>g&&_>g;n.style.setProperty("--gramlot-popup-available-width",`${w?_:g}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,a.innerHeight-16)}px`);let E=n.getBoundingClientRect(),D=w?l.left-E.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(D,a.innerWidth-E.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,a.innerHeight-E.height-8))}px`;return}let d=Math.max(0,a.innerHeight-8-l.bottom-3),f=Math.max(0,l.top-8-3),h=c.height>d&&f>d;n.style.setProperty("--gramlot-popup-available-height",`${h?f:d}px`);let m=n.getBoundingClientRect(),p=t==="end"?l.right-m.width-i:l.left+i,b=h?l.top-m.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(p,a.innerWidth-m.width-8))}px`,n.style.top=`${Math.max(8,Math.min(b,a.innerHeight-m.height-8))}px`}function xc(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function gs(n,e){return xc(e),e==null?n:e.replaceAll("{}",()=>n)}function lg(n){if(n instanceof Date)return At(n);if(be(n))return"N";if(typeof n=="number")return Number.isInteger(n)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function ug(n,e,{pattern:t="short",locale:r,timeZone:i}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof i!="string"||!i))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let s={timeZone:e==="DHZ"?i:"UTC"};return e!=="H"&&(s.dateStyle=t),e!=="D"&&(s.timeStyle=t),new Intl.DateTimeFormat(r,s).format(n)}function ms(n){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(n);if(!e||e[1]==="("!=(e[4]===")")||n.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${n}`);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 cg(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=ms(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let r=e.length===3?e[1]:null;r!==null&&r!==""&&r!=="-"&&ms(r);let i=e.length>1?ms(e.at(-1)):null;return{positive:t,zero:r,negative:i}}function kc(n,e={},t={}){if(n===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 b of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(b))throw new RangeError(`Unsupported format option: ${b}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?lg(n):e.dtype,i=["D","H","DHZ"].includes(r);if(!i&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(i){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError(`${r} requires a valid Date object`)}else if(!(typeof n=="number"&&Number.isFinite(n))&&!(be(n)&&!["NaN","Infinity","-Infinity"].includes(n.toString())))throw new TypeError(`${r} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(r==="L"&&!Number.isInteger(n))throw new TypeError("L formatting requires an integer");let{pattern:s,locale:o,mask:a}=e;if(!i&&typeof s!="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(!(i?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(xc(a),i){let b=ug(n,r,e);return gs(b,a)}let{positive:u,zero:c,negative:d}=cg(s),f=be(n),h=f?n.eq(0):n===0,m=f?n.lt(0):n<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let p;if(h&&c!==null){if(c==="")return"";if(c==="-")p="-";else{let b=ms(c);p=b.prefix+new Intl.NumberFormat(o,b.intl).format(0)+b.suffix}}else{let b=m&&d?d:u,g=f?(m&&d?n.abs():n).toString():m&&d?-n:n===0?0:n;p=b.prefix+new Intl.NumberFormat(o,u.intl).format(g)+b.suffix}return gs(p,a)}var we="http://www.w3.org/1999/xhtml",Rt="http://www.w3.org/2000/svg",dg=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","onEnd","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),fg=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],hg={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},pg=["format","mask","locale","timeZone","places","dtype"],mg=new Set(["href","src","data","action","formaction","xlink:href","xlink_href"]);function $t(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!dg.has(e)&&!fg.some(r=>e.startsWith(r))))}function Hr(n,e,t=[]){for(let[r,i]of Object.entries(e)){let s=t.find(a=>r.startsWith(a))??"",o=r.slice(s.length);if(["style","class","_class"].includes(o)&&i!=null&&typeof i!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function Wr(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],..._e(n.getAttr()).filter(([i])=>["src","href","xlink:href","xlink_href","_text"].includes(i.slice((t.find(s=>i.startsWith(s))??"").length).toLowerCase()))];for(let[i,s]of r)if(n.pointerType(s)||Fe(s))throw new Error(`script '${n.label}': '${i}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onEnd!=null&&(n.nodeTag.toLowerCase()!=="transformpane"||!n._getMeta("gramlot_component")?.parameters?.onEnd))throw new Error("onEnd is only supported on transformPane");if(e.onClose!=null&&!n.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[r,i]of Object.entries(Gr($t(e)))){let s=t.find(a=>r.startsWith(a)),o=s?r.slice(s.length):r;if(/^on./i.test(o))throw new Error(`${n.nodeTag} '${n.label}': '${r}' 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(mg.has(o.toLowerCase())&&gg(i))throw new Error(`${n.nodeTag} '${n.label}': '${r}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function gg(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function Ac(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},i=Object.fromEntries(_e(n.getAttr())),s=[...Object.keys(i),...Object.keys(e)].find(a=>r(a)[1]==="srcdoc");if(s===void 0||Object.keys(i).some(a=>r(a)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(i,s)&&(n.pointerType(i[s])!==null||Fe(i[s]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>r(a)[1]!=="sandbox"));return{[`${r(s)[0]}sandbox`]:"",...o}}function Gr(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function Gn(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function bs(n){let{_meta:e,...t}=n;return Gn(Gr($t(t)))}function Tc(n,e){let t=hg[String(n).toLowerCase()]??[],r={},i={};for(let[s,o]of Object.entries(e))t.includes(s)?i[s]=o:r[s]=o;return[r,i]}function zr(n){return String(n)}function Xn(n,e,t=null){let r={...e},{mask:i,format:s,locale:o,timeZone:a,dtype:l,places:u}=r;for(let d of pg)delete r[d];let c=d=>{if(t&&s!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:s,mask:i,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=zr(d)),i==null)return d;let f=d==null?"":zr(d);return f===""?f:gs(f,i)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function Fe(n){return typeof n=="string"&&n.startsWith("==")}var _s=class{#e;#t;#r;#n;#i;#s;#o;#a=null;#l=!1;#c=[];#u=new Set;constructor(e,t){this.#e=e;let r=e.ownerDocument;this.#t=r.createElement("div"),this.#t.className="toolbar-viewport",this.#t.append(t),this.#n=r.createElement("button"),this.#n.type="button",this.#n.className="toolbar-more",this.#n.hidden=!0,this.#n.title="More commands";let i=r.createElementNS(Rt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");let s=r.createElementNS(Rt,"path");s.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),s.setAttribute("fill","none"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width","1.8"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.append(s),this.#n.append(i),this.#n.setAttribute("aria-label","More commands"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.#r=r.createElement("div"),this.#r.className="toolbar-overflow",this.#r.setAttribute("popover","manual"),this.#r.setAttribute("role","menu"),this.#r.tabIndex=-1;let o=r.createElement("slot");o.name="overflow",this.#r.append(o),this.#n.addEventListener("click",()=>this.#l?this.close():this.open()),this.#n.addEventListener("keydown",l=>{["ArrowDown","ArrowRight"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.open())}),this.#r.addEventListener("keydown",l=>{l.key==="Escape"&&!l.composedPath().some(u=>u.localName==="gramlot-menu"&&u!==e)&&(l.preventDefault(),l.stopPropagation(),this.close())});let a=r.createElement("style");a.textContent=`
|
|
99
99
|
:host([role=toolbar]){min-width:0;min-height:0;max-width:100%;width:100%;flex-shrink:1;gap:0}
|
|
100
100
|
:host([role=toolbar][aria-orientation=vertical]){width:auto;height:100%;max-height:100%}
|
|
101
101
|
.toolbar-viewport{display:contents}
|
|
@@ -111,7 +111,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
111
111
|
max-width:var(--gramlot-popup-available-width);max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
112
112
|
background:var(--gramlot-field-background,Canvas);color:var(--gramlot-ink,CanvasText);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-lg,9px);box-shadow:0 8px 28px #0004}
|
|
113
113
|
.toolbar-overflow ::slotted([role=separator]){margin:5px 7px;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
114
|
-
`,e.shadowRoot.append(a,this.#t,this.#n,this.#r)}get opened(){return this.#l}get button(){return this.#n}get panel(){return this.#r}contains(e){let t=e;for(;t&&t.parentElement!==this.#e;)t=t.parentElement;return this.#u.has(t)}connect(){if(!this.#e.permanent||this.#i)return;let e=this.#e.ownerDocument.defaultView;this.#s=new e.AbortController,this.#i=new e.ResizeObserver(()=>this.schedule()),this.#i.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#s.signal}),this.schedule()}disconnect(){this.close(!1),this.#i?.disconnect(),this.#i=null,this.#s?.abort(),this.#a!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#a),this.#a=null,this.#c=[]}schedule(){if(this.#e.isConnected){if(!this.#e.permanent){this.disconnect();for(let e of this.#e.children)e.removeAttribute("slot"),e.removeAttribute("data-menu-overflow");this.#u.clear(),this.#n.hidden=!0;return}this.#i||this.connect(),this.#a===null&&(this.#a=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#a=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",i=r?"height":"width",s=t.getComputedStyle(e),o=(r?e.clientHeight:e.clientWidth)-parseFloat(s[r?"paddingTop":"paddingLeft"]||0)-parseFloat(s[r?"paddingBottom":"paddingRight"]||0);if(o<=0)return;let a=e.ownerDocument.activeElement;for(;a?.shadowRoot?.activeElement;)a=a.shadowRoot.activeElement;let l=[...e.children].filter(g=>!g.hidden&&(fe(g).localName!=="gramlot-menu"||fe(g).permanent));for(let g of this.#c)l.includes(g)||(this.#i.unobserve(g),g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow"));for(let g of l)this.#c.includes(g)||this.#i.observe(g);this.#c=l;for(let g of l)g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow");this.#u.clear(),e.refreshItems();for(let g of e.items)g.refreshAvailability();let u=parseFloat(t.getComputedStyle(this.#t).gap)||0,c=new Map(l.map(g=>{let _=t.getComputedStyle(g),w=fe(g).localName==="gramlot-spacer"?fe(g).parameters.size??0:g.getBoundingClientRect()[i];return[g,w+(parseFloat(_[r?"marginTop":"marginLeft"])||0)+(parseFloat(_[r?"marginBottom":"marginRight"])||0)]})),d=g=>fe(g).getAttribute("role")==="separator",f=g=>g.filter((_,w)=>!d(_)||g.slice(0,w).some(E=>fe(E).localName!=="gramlot-spacer"&&!d(E))&&g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer")&&!d(g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer"))),h=g=>g.reduce((_,w)=>_+c.get(w),0)+Math.max(0,g.length-1)*u,m=f(l);if(h(m)>o){let g=l.map((_,w)=>({unit:_,index:w})).filter(({unit:_})=>fe(_).localName==="gramlot-menu-line"&&!d(_)&&fe(_).parameters.overflowable).sort((_,w)=>fe(_.unit).parameters.priority-fe(w.unit).parameters.priority||w.index-_.index);for(let{unit:_}of g){if(h(m)<=o-32)break;this.#u.add(_),m=f(m.filter(w=>w!==_))}}let p=f(l.filter(g=>this.#u.has(g)||d(g)&&!m.includes(g)));for(let g of p)this.#u.add(g);for(let g of l)d(g)&&!m.includes(g)&&!this.#u.has(g)&&(g.slot="suppressed");for(let g of this.#u)g.slot="overflow",g.setAttribute("data-menu-overflow","");this.#n.hidden=this.#u.size===0;for(let g of e.items)g.refreshAvailability();e.refreshItems();let b=l.find(g=>{let _=a;for(;_;){if(_===g)return!0;_=_.parentNode??_.host}return!1});this.#u.size===0?this.close(!1):b&&this.#u.has(b)?this.open(!1):this.#l&&this.#d(),b&&a?.isConnected&&a.focus({preventScroll:!0}),e.refreshItems()}#d(){
|
|
114
|
+
`,e.shadowRoot.append(a,this.#t,this.#n,this.#r)}get opened(){return this.#l}get button(){return this.#n}get panel(){return this.#r}contains(e){let t=e;for(;t&&t.parentElement!==this.#e;)t=t.parentElement;return this.#u.has(t)}connect(){if(!this.#e.permanent||this.#i)return;let e=this.#e.ownerDocument.defaultView;this.#s=new e.AbortController,this.#i=new e.ResizeObserver(()=>this.schedule()),this.#i.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#s.signal}),this.schedule()}disconnect(){this.close(!1),this.#i?.disconnect(),this.#i=null,this.#s?.abort(),this.#a!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#a),this.#a=null,this.#c=[]}schedule(){if(this.#e.isConnected){if(!this.#e.permanent){this.disconnect();for(let e of this.#e.children)e.removeAttribute("slot"),e.removeAttribute("data-menu-overflow");this.#u.clear(),this.#n.hidden=!0;return}this.#i||this.connect(),this.#a===null&&(this.#a=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#a=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",i=r?"height":"width",s=t.getComputedStyle(e),o=(r?e.clientHeight:e.clientWidth)-parseFloat(s[r?"paddingTop":"paddingLeft"]||0)-parseFloat(s[r?"paddingBottom":"paddingRight"]||0);if(o<=0)return;let a=e.ownerDocument.activeElement;for(;a?.shadowRoot?.activeElement;)a=a.shadowRoot.activeElement;let l=[...e.children].filter(g=>!g.hidden&&(fe(g).localName!=="gramlot-menu"||fe(g).permanent));for(let g of this.#c)l.includes(g)||(this.#i.unobserve(g),g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow"));for(let g of l)this.#c.includes(g)||this.#i.observe(g);this.#c=l;for(let g of l)g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow");this.#u.clear(),e.refreshItems();for(let g of e.items)g.refreshAvailability();let u=parseFloat(t.getComputedStyle(this.#t).gap)||0,c=new Map(l.map(g=>{let _=t.getComputedStyle(g),w=fe(g).localName==="gramlot-spacer"?fe(g).parameters.size??0:g.getBoundingClientRect()[i];return[g,w+(parseFloat(_[r?"marginTop":"marginLeft"])||0)+(parseFloat(_[r?"marginBottom":"marginRight"])||0)]})),d=g=>fe(g).getAttribute("role")==="separator",f=g=>g.filter((_,w)=>!d(_)||g.slice(0,w).some(E=>fe(E).localName!=="gramlot-spacer"&&!d(E))&&g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer")&&!d(g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer"))),h=g=>g.reduce((_,w)=>_+c.get(w),0)+Math.max(0,g.length-1)*u,m=f(l);if(h(m)>o){let g=l.map((_,w)=>({unit:_,index:w})).filter(({unit:_})=>fe(_).localName==="gramlot-menu-line"&&!d(_)&&fe(_).parameters.overflowable).sort((_,w)=>fe(_.unit).parameters.priority-fe(w.unit).parameters.priority||w.index-_.index);for(let{unit:_}of g){if(h(m)<=o-32)break;this.#u.add(_),m=f(m.filter(w=>w!==_))}}let p=f(l.filter(g=>this.#u.has(g)||d(g)&&!m.includes(g)));for(let g of p)this.#u.add(g);for(let g of l)d(g)&&!m.includes(g)&&!this.#u.has(g)&&(g.slot="suppressed");for(let g of this.#u)g.slot="overflow",g.setAttribute("data-menu-overflow","");this.#n.hidden=this.#u.size===0;for(let g of e.items)g.refreshAvailability();e.refreshItems();let b=l.find(g=>{let _=a;for(;_;){if(_===g)return!0;_=_.parentNode??_.host}return!1});this.#u.size===0?this.close(!1):b&&this.#u.has(b)?this.open(!1):this.#l&&this.#d(),b&&a?.isConnected&&a.focus({preventScroll:!0}),e.refreshItems()}#d(){Vr(this.#r,this.#n,{placement:this.#e.parameters.orientation==="vertical"?"side":"bottom"})}open(e=!0){if(this.#u.size){if(!this.#l){this.#r.showPopover(),this.#l=!0,this.#n.setAttribute("aria-expanded","true"),this.#o=new this.#e.ownerDocument.defaultView.AbortController;let t={signal:this.#o.signal};this.#e.ownerDocument.addEventListener("pointerdown",r=>{!r.composedPath().includes(this.#r)&&!r.composedPath().includes(this.#n)&&this.close(!1)},t),this.#e.ownerDocument.addEventListener("scroll",()=>this.#d(),{...t,capture:!0})}if(this.#e.refreshItems(),this.#d(),e){let t=i=>{if(i.hidden||i.disabled)return null;if(i.localName==="gramlot-menu-line"&&!i.parameters.group)return i.getAttribute("role")==="separator"?null:i;if(i.matches('input:not([type=hidden]),textarea,select,button,[tabindex="0"]'))return i;for(let s of i.children){let o=t(s);if(o)return o}return null};([...this.#e.children].filter(i=>this.#u.has(i)).map(t).find(Boolean)??this.#r).focus()}}}close(e=!0){if(this.#l){for(let t of this.#u)for(let r of t.querySelectorAll("gramlot-menu"))r.permanent||r.close(!1);this.#r.hidePopover(),this.#l=!1,this.#o?.abort(),this.#n.setAttribute("aria-expanded","false"),e&&!this.#n.hidden&&this.#n.focus()}}};function Dc(n){return class extends n{#e;#t;#r=null;#n=[];#i=null;#s;#o;#a;#l;#c=!1;#u;#d;constructor(){super();let e=this.ownerDocument,t=this.attachShadow({mode:"open"}),r=e.createElement("style");r.textContent=`:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
|
|
115
115
|
:host([role=menu]){position:fixed;inset:auto;margin:0;padding:5px;min-width:min(16rem,var(--gramlot-popup-available-width));width:max-content;font:inherit;
|
|
116
116
|
max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
117
117
|
background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-lg,9px);box-shadow:0 8px 28px #0004}
|
|
@@ -120,7 +120,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
120
120
|
:host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
121
121
|
:host([role=toolbar][aria-orientation=horizontal]) ::slotted([role=separator]){border-top:0;border-left:1px solid var(--gramlot-border-control,#888);align-self:stretch;margin:4px}
|
|
122
122
|
:host([hidden]){display:none!important} slot{display:contents} .status{padding:.4em;opacity:.75}
|
|
123
|
-
.status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#o=e.createElement("span"),this.#o.className="status",this.#o.setAttribute("role","status"),this.#a=e.createElement("button"),this.#a.textContent="Riprova",this.#a.hidden=!0,this.#a.addEventListener("click",i=>{i.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#o,this.#a),this.#s=new
|
|
123
|
+
.status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#o=e.createElement("span"),this.#o.className="status",this.#o.setAttribute("role","status"),this.#a=e.createElement("button"),this.#a.textContent="Riprova",this.#a.hidden=!0,this.#a.addEventListener("click",i=>{i.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#o,this.#a),this.#s=new _s(this,this.#l),this.addEventListener("keydown",i=>this.#h(i)),this.addEventListener("focusin",i=>{let s=i.composedPath().find(o=>this.items.includes(o));s&&(this.#r=s,this.refreshItems())})}get permanent(){return this.parameters.presentation==="bar"}get opened(){return this.permanent||this.#c}get items(){return[...this.querySelectorAll("gramlot-menu-line")].filter(e=>e.menuOwner===this&&!e.parameters.group)}get overflow(){return this.#s}isOverflowed(e){return this.#s.contains(e)}get usableItems(){return this.items.filter(e=>qr(e).slot!=="suppressed"&&!e.disabled&&!e.hidden&&!e.closest("[hidden]")&&e.getAttribute("role")!=="separator")}get parentMenu(){return this.parentElement?.closest("gramlot-menu")??null}connectedCallback(){this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>{this.refreshItems(),this.#s.schedule()}),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["hidden","disabled"]}),this.refreshItems(),this.#p(),this.#s.connect(),this.permanent&&this.menuBinding?.load()}disconnectedCallback(){this.#s.disconnect(),this.#t?.disconnect(),this.#e?.abort(),this.#d?.abort(),this.#u=null,this.#c=!1}projectAttributes(e){let t=Ur(this,e);if(this.#f(),!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0)throw new TypeError("menu iconSize must be positive");return this.setAttribute("role",this.permanent?"toolbar":"menu"),this.setAttribute("aria-orientation",this.permanent?this.parameters.orientation:"vertical"),this.tabIndex=-1,this.permanent?this.removeAttribute("popover"):this.setAttribute("popover","manual"),this.refreshItems(),this.#s.schedule(),t}#f(){let e=this.parameters.modifiers;if(e==null)return null;if(e==="*")return[];let t=e.trim().toLowerCase().split(/[,\s]+/);if(!t.length||t.some(r=>!["shift","ctrl","alt","meta"].includes(r))||new Set(t).size!==t.length)throw new TypeError("Menu modifiers require *, or a combination of Shift, Ctrl, Alt and Meta");return t}#p(){let e=qr(this).parentElement;if(this.permanent||!e)return;if(["gramlot-menu-line","gramlot-drop-down-button"].includes(e.localName)){qr(this).slot="menu";return}if(qr(this).removeAttribute("slot"),e.localName==="gramlot-menu")return;this.#u=e,this.#d=new this.ownerDocument.defaultView.AbortController;let t={signal:this.#d.signal},r=s=>!s.composedPath().some(o=>o.localName==="gramlot-menu"),i=s=>{if(this.hidden||this.permanent||!r(s)||s.composedPath().some(u=>u instanceof this.ownerDocument.defaultView.Element&&(u.disabled===!0||u.getAttribute("aria-disabled")==="true")))return;let o=this.#f();if(s.type==="click"){if(o===null||s.button!==0||["shift","ctrl","alt","meta"].some(u=>!!s[u+"Key"]!==o.includes(u)))return}else if(o!==null)return;s.preventDefault(),s.stopPropagation();let a=s.type==="keydown",l=a?e.getBoundingClientRect():null;this.open(e,!1,a?{x:l.left+8,y:l.top+8}:{x:s.clientX,y:s.clientY})};e.addEventListener("click",i,t),e.addEventListener("contextmenu",i,t),e.addEventListener("keydown",s=>{(s.key==="ContextMenu"||s.key==="F10"&&s.shiftKey&&!s.ctrlKey&&!s.altKey&&!s.metaKey)&&i(s)},t)}setStatus(e){this.status=e,this.#o.textContent={loading:"Caricamento\u2026",empty:"Nessuna voce",error:"Impossibile caricare"}[e]??"",this.#a.hidden=e!=="error",this.setAttribute("aria-busy",String(e==="loading"));for(let t of this.items)t.refreshAvailability();this.refreshItems()}refreshItems(){for(let r of this.querySelectorAll("gramlot-menu-line"))r.menuOwner===this&&r.parameters.group&&r.refreshAvailability();for(let r of this.items)r.refreshAvailability();let e=this.usableItems;if(this.#r&&!e.includes(this.#r)){let r=this.#n.indexOf(this.#r),i=this.#n.slice(r+1).find(s=>e.includes(s))??this.#n.slice(0,r).reverse().find(s=>e.includes(s));this.#r=i??null,this.opened&&this.status!=="loading"&&(i?i.focus():this.permanent?this.focus():this.close())}let t=e.filter(r=>!this.isOverflowed(r));for(let r of this.items)r.control.tabIndex=this.permanent&&r===(t.includes(this.#r)?this.#r:t[0])?0:-1;this.#n=this.items}open(e,t=!1,r=null){if(this.permanent)return;this.#i=e,this.#c||(this.showPopover(),this.#c=!0),e.setAttribute("aria-expanded","true"),this.#e?.abort(),this.#e=new this.ownerDocument.defaultView.AbortController;let i={signal:this.#e.signal},s=()=>Vr(this,e,{point:r,placement:this.parentMenu&&(!this.parentMenu.permanent||this.parentMenu.parameters.orientation==="vertical"||this.parentMenu.isOverflowed(this.parentElement))?"side":"bottom"});s(),this.ownerDocument.defaultView.addEventListener("resize",s,i),this.ownerDocument.addEventListener("scroll",s,{...i,capture:!0}),this.ownerDocument.addEventListener("pointerdown",o=>{!o.composedPath().includes(this)&&(e===this.#u||!o.composedPath().includes(e))&&this.closeChain(!1)},i),this.menuBinding?.load().then(()=>{this.#c&&(this.ownerDocument.activeElement===this||!this.contains(this.ownerDocument.activeElement))&&this.focusEntry(t),this.#c&&s()}),this.focusEntry(t)}focusEntry(e=!1){let t=this.usableItems,r=t[e?t.length-1:0];r?(this.#r=r,r.focus()):this.focus()}close(e=!0){for(let t of this.querySelectorAll("gramlot-menu"))t.permanent||t.close(!1);if(this.permanent){this.#s.close(e);return}this.#c&&(this.hidePopover(),this.#c=!1,this.#e?.abort(),this.#i?.setAttribute("aria-expanded","false"),e&&this.#i?.isConnected&&this.#i.focus())}closeChain(e=!0){let t=this.parentMenu;this.close(e&&!t),t&&!t.permanent?t.closeChain(e):t?.isOverflowed(this.parentElement)?t.overflow.close(e):e&&this.#i?.isConnected&&this.#i.focus()}#h(e){if(e.defaultPrevented||e.composedPath().find(u=>u.localName==="gramlot-menu")!==this)return;let t=e.composedPath().find(u=>this.items.includes(u));if(!t&&e.target!==this)return;let r=t&&this.isOverflowed(t),i=this.usableItems.filter(u=>this.isOverflowed(u)===!!r),s=i.indexOf(t),o=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowRight":"ArrowDown",a=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowLeft":"ArrowUp",l;if(e.key===o&&(l=Math.min(i.length-1,s+1)),e.key===a&&(l=Math.max(0,s-1)),e.key==="Home"&&(l=0),e.key==="End"&&(l=i.length-1),l!==void 0){e.preventDefault(),e.stopPropagation(),i[l]?.focus();return}(!this.permanent||r)&&e.key==="ArrowRight"&&t?.submenu?(e.preventDefault(),e.stopPropagation(),t.openSubmenu()):e.key==="Escape"&&(!this.permanent||this.overflow.opened||this.items.some(u=>u.submenu?.opened))||!this.permanent&&e.key==="ArrowLeft"&&this.parentMenu?(e.preventDefault(),e.stopPropagation(),this.close()):e.key==="Tab"&&this.closeChain(!1)}}}function Cc(n){return class extends n{#e;#t;#r;#n;#i;#s;#o=null;#a=!1;constructor(){super();let e=this.ownerDocument;this.#r=e.createElement("span"),this.#n=e.createElement("span"),this.#r.className="menu-caption",this.#n.className="menu-check",this.#i=e.createElement("span"),this.#i.className="menu-arrow",this.#i.setAttribute("aria-hidden","true"),this.#n.setAttribute("aria-hidden","true"),this.control.prepend(this.#n),this.control.append(this.#r,this.#i);let t=e.createElement("style");t.textContent=`:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
|
|
124
124
|
.menu-check:empty,.menu-arrow:empty{display:none}
|
|
125
125
|
button.menu-row{display:grid;grid-template-columns:1em 1.15em minmax(0,1fr) .7em;column-gap:.5em;
|
|
126
126
|
align-items:center;width:100%;min-height:max(min(var(--gramlot-field-height,28px),28px),var(--gramlot-touch-target,0px));padding:var(--gramlot-button-padding,3px 8px);
|
|
@@ -156,7 +156,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
156
156
|
:host([data-menu-overflow]) .menu-group,:host([data-menu-group-rows]) .menu-group{flex-direction:column;align-items:stretch;padding:3px 0}
|
|
157
157
|
:host([data-menu-overflow][role=group]){border-block-end:1px solid var(--gramlot-border-control,#888);margin-block-end:4px}
|
|
158
158
|
:host([role=group][aria-disabled=true]) .menu-group{opacity:.45;pointer-events:none}
|
|
159
|
-
:host([hidden]){display:none!important}`,this.caption.name="command-caption",this.#t=e.createElement("div"),this.#t.className="menu-group",this.#t.append(e.createElement("slot")),this.#t.hidden=!0,this.shadowRoot.append(t,this.#t);let r=e.createElement("slot");r.name="menu",this.shadowRoot.append(r),this.addEventListener("pointerenter",()=>{this.menuOwner&&(!this.menuOwner.permanent||this.menuOwner.isOverflowed(this))&&!this.disabled&&(clearTimeout(this.#s),this.#s=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let i of this.menuOwner.items)i.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#s))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")??null}get entryCaption(){return this.parameters.caption??this.#o?.label??""}get entryIcon(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.icon:this.#o?.icon}get entryIconSrc(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.iconSrc:this.#o?.iconSrc}get occurrence(){return this.parameters.code??this.sourceLabel}setCommandDefinition(e,t){this.#o=e,this.sourceLabel=t,this.#l()}projectAttributes(e,t){let r=super.projectAttributes(e,t);if(this.#e=e["aria-label"],this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError("menuline iconSize must be positive");if(!Number.isFinite(this.parameters.priority))throw new TypeError("menuline priority must be finite");return this.#a=!!this.parameters.disabled,this.#l(),this.menuOwner?.overflow.schedule(),r}#l(){let e=[...this.childNodes].filter(r=>r.nodeType===3).map(r=>r.textContent).join("").trim()==="-"&&!this.parameters.command;this.setAttribute("role",this.parameters.group?"group":e?"separator":this.parameters.checked==null?"menuitem":"menuitemcheckbox"),this.#t.hidden=!this.parameters.group,this.setAttribute("aria-disabled",String(this.#a)),this.parameters.checked!=null?(this.setAttribute("aria-checked",String(this.parameters.checked)),this.control.setAttribute("aria-checked",String(this.parameters.checked))):(this.removeAttribute("aria-checked"),this.control.removeAttribute("aria-checked")),this.#n.textContent=this.parameters.checked?"\u2713":"",this.#r.textContent=this.parameters.command&&!this.#o?"???":this.entryCaption,this.caption.hidden=!0,this.renderIcon(this.entryIcon,this.entryIconSrc);let t=this.parameters.tooltip??this.#o?.tooltip??this.entryCaption;this.control.title=t,this.control.setAttribute("aria-label",this.#e??(this.entryCaption||t)),this.submenu?this.control.setAttribute("aria-haspopup","menu"):this.control.removeAttribute("aria-haspopup"),this.refreshAvailability()}refreshAvailability(){let e=this.menuOwner,t=e&&(!e.permanent||e.isOverflowed(this)),r=a=>{for(let l=this;l&&l!==e;l=l.parentElement)if(l.localName==="gramlot-menu-line"&&l.parameters[a]!=null)return l.parameters[a];return e?.parameters[a]},i=!!(e?.permanent&&!t),s=r("labelPosition");this.control.classList.toggle("toolbar-button",i),this.control.classList.toggle("toolbar-below",i&&s==="below"),this.control.classList.toggle("toolbar-tooltip",i&&s==="tooltip"),i?this.control.style.setProperty("--gramlot-toolbar-icon-size",`${r("iconSize")}px`):this.control.style.removeProperty("--gramlot-toolbar-icon-size"),this.toggleAttribute("data-menu-group-rows",!!(t||e?.parameters.orientation==="vertical")),this.control.classList.toggle("menu-row",t),this.#i.textContent=this.submenu?t||e?.parameters.orientation==="vertical"?"\u203A":"\u25BE":"";let o=this.#a||this.getAttribute("role")==="separator"||!!(this.parameters.command&&!this.#o)||["loading","error"].includes(e?.status)||!!this.closest("gramlot-drop-down-button")?.parameters.disabled;this.control.disabled!==o&&(this.control.disabled=o)}get disabled(){for(let e=this.parentElement;e&&e!==this.menuOwner;e=e.parentElement)if(e.localName==="gramlot-menu-line"&&e.parameters.disabled)return!0;return this.control.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){this.control.disabled=!!e}attachCommand(){this.#l()}releaseCommand(){clearTimeout(this.#s),this.submenu?.close(!1)}openSubmenu(){if(!(this.disabled||!this.submenu)){for(let e of this.menuOwner.items)e!==this&&e.submenu?.close(!1);this.submenu.open(this.control)}}prepareCommand(e){if(this.parameters.group||this.disabled||this.hidden)return!1;if(this.submenu)return e.stopPropagation(),this.submenu.opened?this.submenu.close():this.openSubmenu(),!1;let t=
|
|
159
|
+
:host([hidden]){display:none!important}`,this.caption.name="command-caption",this.#t=e.createElement("div"),this.#t.className="menu-group",this.#t.append(e.createElement("slot")),this.#t.hidden=!0,this.shadowRoot.append(t,this.#t);let r=e.createElement("slot");r.name="menu",this.shadowRoot.append(r),this.addEventListener("pointerenter",()=>{this.menuOwner&&(!this.menuOwner.permanent||this.menuOwner.isOverflowed(this))&&!this.disabled&&(clearTimeout(this.#s),this.#s=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let i of this.menuOwner.items)i.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#s))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")??null}get entryCaption(){return this.parameters.caption??this.#o?.label??""}get entryIcon(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.icon:this.#o?.icon}get entryIconSrc(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.iconSrc:this.#o?.iconSrc}get occurrence(){return this.parameters.code??this.sourceLabel}setCommandDefinition(e,t){this.#o=e,this.sourceLabel=t,this.#l()}projectAttributes(e,t){let r=super.projectAttributes(e,t);if(this.#e=e["aria-label"],this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError("menuline iconSize must be positive");if(!Number.isFinite(this.parameters.priority))throw new TypeError("menuline priority must be finite");return this.#a=!!this.parameters.disabled,this.#l(),this.menuOwner?.overflow.schedule(),r}#l(){let e=[...this.childNodes].filter(r=>r.nodeType===3).map(r=>r.textContent).join("").trim()==="-"&&!this.parameters.command;this.setAttribute("role",this.parameters.group?"group":e?"separator":this.parameters.checked==null?"menuitem":"menuitemcheckbox"),this.#t.hidden=!this.parameters.group,this.setAttribute("aria-disabled",String(this.#a)),this.parameters.checked!=null?(this.setAttribute("aria-checked",String(this.parameters.checked)),this.control.setAttribute("aria-checked",String(this.parameters.checked))):(this.removeAttribute("aria-checked"),this.control.removeAttribute("aria-checked")),this.#n.textContent=this.parameters.checked?"\u2713":"",this.#r.textContent=this.parameters.command&&!this.#o?"???":this.entryCaption,this.caption.hidden=!0,this.renderIcon(this.entryIcon,this.entryIconSrc);let t=this.parameters.tooltip??this.#o?.tooltip??this.entryCaption;this.control.title=t,this.control.setAttribute("aria-label",this.#e??(this.entryCaption||t)),this.submenu?this.control.setAttribute("aria-haspopup","menu"):this.control.removeAttribute("aria-haspopup"),this.refreshAvailability()}refreshAvailability(){let e=this.menuOwner,t=e&&(!e.permanent||e.isOverflowed(this)),r=a=>{for(let l=this;l&&l!==e;l=l.parentElement)if(l.localName==="gramlot-menu-line"&&l.parameters[a]!=null)return l.parameters[a];return e?.parameters[a]},i=!!(e?.permanent&&!t),s=r("labelPosition");this.control.classList.toggle("toolbar-button",i),this.control.classList.toggle("toolbar-below",i&&s==="below"),this.control.classList.toggle("toolbar-tooltip",i&&s==="tooltip"),i?this.control.style.setProperty("--gramlot-toolbar-icon-size",`${r("iconSize")}px`):this.control.style.removeProperty("--gramlot-toolbar-icon-size"),this.toggleAttribute("data-menu-group-rows",!!(t||e?.parameters.orientation==="vertical")),this.control.classList.toggle("menu-row",t),this.#i.textContent=this.submenu?t||e?.parameters.orientation==="vertical"?"\u203A":"\u25BE":"";let o=this.#a||this.getAttribute("role")==="separator"||!!(this.parameters.command&&!this.#o)||["loading","error"].includes(e?.status)||!!this.closest("gramlot-drop-down-button")?.parameters.disabled;this.control.disabled!==o&&(this.control.disabled=o)}get disabled(){for(let e=this.parentElement;e&&e!==this.menuOwner;e=e.parentElement)if(e.localName==="gramlot-menu-line"&&e.parameters.disabled)return!0;return this.control.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){this.control.disabled=!!e}attachCommand(){this.#l()}releaseCommand(){clearTimeout(this.#s),this.submenu?.close(!1)}openSubmenu(){if(!(this.disabled||!this.submenu)){for(let e of this.menuOwner.items)e!==this&&e.submenu?.close(!1);this.submenu.open(this.control)}}prepareCommand(e){if(this.parameters.group||this.disabled||this.hidden)return!1;if(this.submenu)return e.stopPropagation(),this.submenu.opened?this.submenu.close():this.openSubmenu(),!1;let t=qr(this.menuOwner)?.parentElement;return t?.localName==="gramlot-drop-down-button"?t.selectCommand(this,e.shiftKey):this.menuOwner.closeChain(),!0}}}function Yn(n){return class extends ps(n){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}
|
|
160
160
|
button{display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,.35em);font:inherit;
|
|
161
161
|
color:var(--gramlot-button-color,var(--gramlot-ink,CanvasText));background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
|
|
162
162
|
border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
|
|
@@ -183,28 +183,28 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
183
183
|
:host([role=separator]){display:block;border-top:1px solid var(--gramlot-border-control,#888);margin:.25em}
|
|
184
184
|
:host([role=separator]) button{display:none}
|
|
185
185
|
@media(forced-colors:active){button,:host(.button--secondary) button,:host(.button--quiet) button{background:ButtonFace;color:ButtonText;border-color:ButtonText;filter:none}}
|
|
186
|
-
`,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.renderIcon(this.parameters.icon,this.parameters.iconSrc),e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),r}renderIcon(e,t){if(!t){this.icon.textContent=e??"";return}let r=this.icon.firstElementChild;r||(r=this.ownerDocument.createElement("img"),r.alt="",r.draggable=!1,this.icon.replaceChildren(r)),r.getAttribute("src")!==t&&r.setAttribute("src",t)}get entryIcon(){return this.parameters.icon}get entryIconSrc(){return this.parameters.iconSrc}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}Hn.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var hg=Ot({name:"button",tag:"gramlot-button",base:Hn,command:!0,subTags:"*",implementation:n=>class extends n{}}),pg=Ot({name:"toggleButton",tag:"gramlot-toggle-button",base:Hn,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:n=>class extends n{#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)}}}),mg=Ot({name:"menu",tag:"gramlot-menu",base:Ec,subTags:"menuline,spacer,contentPane",parameters:{presentation:{dtype:"T",default:"popup",enum:["popup","bar"]},orientation:{dtype:"T",default:"horizontal",enum:["horizontal","vertical"]},modifiers:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",default:"beside",enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",default:24},resolver:{dtype:"T",nullable:!0},cacheTime:{dtype:"R",default:-1},sync:{dtype:"B",default:!1}},implementation:n=>class extends n{}}),gg=Ot({name:"menuline",tag:"gramlot-menu-line",base:Hn,command:!0,subTags:"*",parameters:{command:{dtype:"T",nullable:!0},caption:{dtype:"T",nullable:!0},code:{dtype:"T",nullable:!0},checked:{dtype:"B",nullable:!0,binding:"read"},tooltip:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",nullable:!0,enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",nullable:!0},group:{dtype:"B",default:!1},priority:{dtype:"R",default:0},overflowable:{dtype:"B",default:!0},parameters:{annotation:{kind:"type",module:"builtins",name:"dict"},nullable:!0},favorite:{dtype:"B",default:!1}},implementation:xc}),bg=Ot({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=qr(this,e),{size:r,flex:i}=this.parameters;if(r!=null&&i!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||i!=null&&(!Number.isFinite(i)||i<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=i!=null?`${i} 1 0px`:`0 0 ${r??0}px`,this.setAttribute("aria-hidden","true"),t}},parameters:{size:{dtype:"R",nullable:!0},flex:{dtype:"R",nullable:!0}},implementation:n=>class extends n{}}),_g=Ot({name:"dropDownButton",tag:"gramlot-drop-down-button",base:Hn,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#i;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#i=e.createElement("span"),this.#i.hidden=!0,this.control.append(this.#i),this.#n=e.createElement("button"),this.#n.type="button",this.#n.className="arrow",this.#n.textContent="\u25BE",this.#n.setAttribute("aria-label","Open menu"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.controlBox.append(this.#n);let t=e.createElement("slot");t.name="menu",this.shadowRoot.append(t),this.#n.addEventListener("click",r=>{r.stopPropagation(),this.menu.opened?this.closeMenu():this.openMenu()}),this.#n.addEventListener("keydown",r=>{["ArrowDown","ArrowUp"].includes(r.key)&&(r.preventDefault(),this.openMenu(r.key==="ArrowUp"))})}get menu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")}get menuItems(){return this.menu?.items??[]}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#n.disabled=this.disabled,this.disabled&&this.menu?.close(!1),this.#s(),r}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#r=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#r)}catch{}}this.#s(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#s()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.menu?.close(!1)}commandTarget(e){return e?.composedPath().includes(this.menu)?null:this.menuItems.find(t=>t.occurrence===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.occurrence,this.#r)try{this.ownerDocument.defaultView.localStorage.setItem(this.#r,this.#e)}catch{}this.#s()}this.closeMenu()}#s(){let e=this.menuItems.map(i=>i.occurrence).filter(Boolean);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),r=t!==this;this.caption.hidden=r,this.#i.hidden=!r,this.#i.textContent=r?t.entryCaption:"",this.renderIcon(t.entryIcon,t.entryIconSrc)}openMenu(e=!1){this.disabled||this.menu?.open(this.#n,e)}closeMenu(){this.menu?.close()}}}),ms=ia({name:"buttons",components:[hg,pg,_g,mg,gg,bg]});function wg(n,e,t=n){let r=new Map,i=new Set,s=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=H(l)?.pointer??l;s.set(a,u instanceof K?u.resolve():n.pointerType(u)?t.getRelativeData(u):Fe(u)?null:u)}let o=a=>{if(r.has(a))return r.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(i.has(a))throw new Error(`cyclic attribute dependency: ${[...i,a].join(" -> ")}`);i.add(a);let l=e.get(a),u=H(l),c=u?s.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=nn(u.body),m=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,a,l,h,m)}else d=Pt(u.body,f),c==null&&(d=null);else d=s.get(a);return r.set(a,d),d}finally{i.delete(a)}};return{resolve:o}}function $t(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),..._e(n.getAttr())]);return wg(n,r,t).resolve(e)}var yg={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"]},sa=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],vg=["_if","_else","_onRemote","_onCalling"],oa=class{#e;#t=null;#r=null;#n=!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 j(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,r=this.#n;this.#n=!0;try{t=e()!==!1}finally{this.#n=r,!t&&!this.#t&&this.#i()}return t}submit(e,t,r){try{let i=U(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((s,o)=>{this.#r={method:e,text:i,perform:r,resolve:s,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#s(e,t,i,r))}catch(i){return Promise.reject(i)}}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()}#i(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#s(e.method,j(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#s(e,t,r,i){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let s=new AbortController,o={method:e,params:t,text:r,controller:s,ignored:!1};o.view=Object.freeze({method:e,get params(){return j(r)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,s.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(i(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.#i())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#i())}};function kc(n){return typeof n=="string"&&n.startsWith("==")}var nr=class extends Ae{get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof A?this.value.getNodes():[];if(e.length){if(e.length!==1||e[0].nodeTag!=="framePane")throw new TypeError("A window requires exactly one framePane");return this.builder.wrapSource(e[0])}return this.builder.wrapSource(this.builder.commandOnNode(this,"framePane",null,{node_label:"frame"}))}requestClose(e="application"){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("requestClose requires a window");return this.rootBuilder.binding.gramlot.dom.getDomNode(this).requestClose(e)}get top(){return this.frameRegion("top")}get bottom(){return this.frameRegion("bottom")}get left(){return this.frameRegion("left")}get right(){return this.frameRegion("right")}get center(){return this.frameRegion("center")}frameRegion(e){if(this.nodeTag!=="framePane")throw new TypeError("Region accessors require framePane");let t=this.value instanceof A?this.value.getNodes().find(i=>i.getAttr("region")===e):null;if(t)return this.builder.wrapSource(t);let r={region:e,node_label:e};return e!=="center"&&Object.assign(r,{display:"flex",flex_direction:["top","bottom"].includes(e)?"column":"row"}),this.builder.wrapSource(this.builder.commandOnNode(this,"contentPane",null,r))}#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new oa(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...yg[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,r])=>r.inline).map(([r])=>r),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?vg:[]],t=[];for(let[r,i]of Object.entries(this.getAttr()??{}))typeof i=="string"&&(e.includes(r)||r==="validate_call"||r==="validate__onResult"||r==="validate_onAccept"||r==="validate_onReject"||/^validate_\w+_if$/.test(r)||r.startsWith("connect_on")||r.startsWith("subscribe_")||r.startsWith("selfsubscribe_"))&&t.push([r,i]);for(let r of["ask","_ask"]){let i=this.getAttr(r);if(i&&typeof i=="object")for(let s of["_if","askIf"])typeof i[s]=="string"&&t.push([`${r}.${s}`,i[s]])}for(let[r,i]of _e(this.getAttr()))if(kc(i)&&t.push([r,i]),this.nodeTag==="script"&&typeof i=="string"){let s=this.builder.constructor.dialectPrefixes.find(o=>r.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(s.length).toLowerCase())&&t.push([r,i])}return(kc(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,r]of this.codeAttributes()){if(this.pointerType(r))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${r}'; inline code is never read from Data`);e.set(t,r)}for(let[t,r]of[..._e(this.getAttr()),["datapath",this.getAttr("datapath")]])H(r)?.expression&&e.set(t,r);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let r=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||r.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${r.pattern}, not ${JSON.stringify(e)}`);let i=Object.keys(t).find(o=>o.startsWith("_")&&!sa.includes(o));if(i)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${i}' is not accepted; the control attributes are ${sa.join(", ")}`);let s={remote:e};for(let[o,a]of Object.entries(t))s[sa.includes(o)?o:`remote_${o}`]=a;return this.setAttr(s),Ln(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=H(e)?Ge(this,e):new Set,r=super.pointers().filter(([i,s])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(i))&&!t.has(i)&&!this.#s(i,s)).map(([i,s])=>[i,H(s)?.pointer??s]);for(let i of t){let s=this.getAttr(i);this.pointerType(s)==="^"&&r.push(["datapath",H(s)?.pointer??s])}return r}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,r]of e){if(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(t)){e.set(t,new Dt(()=>r));continue}if(this.pointerType(r)){if(H(r)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(r)===null&&e.set(t,new Dt(()=>$t(this,t)));continue}this.#s(t,r)?e.set(t,r.slice(1)):this.absDatapath(r)===null&&e.set(t,null)}}return e}pathAttribute(e){let t=this.getAttr(e);return H(t)?$t(this,e):this.pointerType(t)&&this.#s(e,t)?t.slice(1):t}getRelativeData(e,t=null,r={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,r)}setRelativeData(e,t,r={}){this.#o(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,r=null){t===null&&(t=!0),this.#o(e);let i=this.absDatapath(e);if(i.includes("?")){this.#n(i,t);return}this.data.getNode(i)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(i)?.setValue(null,!1)}}#n(e,t){let[r,i]=e.split("?",2),s=this.data;s.getNode(r)?.setAttr({[i]:null},!1);try{let o=s.getNode(r);o?o.setValue(o.staticValue,!0,{[i]:t},!0,!0,!0,!0):s.setItem(r,null,{[i]:t},">",!0,!0,!0,!0)}finally{s.getNode(r)?.setAttr({[i]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#o(e);let i=this.rootBuilder?.binding?.bindingFor(this)??null,s=null,o=setTimeout(()=>{s?.(),this.FIRE(e,t)},r);return s=i?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),s?.()}}absDatapath(e){e=H(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,i]=t.split("?",2),s=super.absDatapath(r);return s===null?null:`${s}?${i}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");if(this.pointerType(i)&&(i=this.#i(r,i),i===null))return null;if(i!=null&&(e=e==="."?i:i+e),e.startsWith("#"))return r.parentNode._resolveSymbolicDatapath(e,t);r=r.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 r=e.slice(1).split(".",1)[0];if(r==="FORM"||r==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let i=this.rootBuilder?.binding;if(!i)return super._resolveSymbolicDatapath(e,t);let s=i.nodeIds.get(r);if(!s)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(r.length+2);return s.absDatapath(o?`.${o}`:".")}#i(e,t){if(H(t)){let s=$t(e,"datapath",e.parentNode);return s==null||s===""?null:s}let r=e.parentNode.absDatapath(t);if(r===null)return null;let i=this.data.getItem(r);return i==null||i===""?null:i}#s(e,t){return H(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}'`)}},de=class n extends A{get nodeClass(){return nr}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let i=r.getAttr("auth")??null;if(i!==null){if(typeof i!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof i}`);if(e(i)!==null)continue}let s=r.staticValue;s instanceof n&&(s=s.authorizedCopy(e));let{auth:o,...a}=r.getAttr(),l=t.setItem(r.label,s,a,">",!1,!1,null,!1,!0,null,r.nodeTag);l.xmlTag=r.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof n&&e.staticValue.activateCode();return this}};if((je(de.tytxSuffix).GramlotBuilderBag??de)!==de)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Gt(de.tytxSuffix,{...je(de.tytxSuffix),GramlotBuilderBag:de});var Eg=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"]),Wn=class extends tr{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);Hr(e,r);let[i,s]=super._handleMeta(e,r);return zr(e,s),e._getMeta("subbuilder")?[i,us(hs(s))]:[i,s]}adaptAttrs(e){let{_meta:t,...r}=e;return Vn(super.adaptAttrs(Wr(Rt(r))))}renderedItem(e,t,r,i={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,i);let{_text:s,...o}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&s!=null&&(t=[this._escapeText(Vr(s)),...t]),Eg.has(i.tag)?`${i.pretty?" ".repeat(this._nodeDepth(e,i.depthOffset??0)):""}<${i.tag}${this._formatAttrs(o)} />${i.pretty?`
|
|
187
|
-
`:""}`:super.renderedItem(e,t,o,i)}};var ir=class extends er{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof St?this.addRender(e,this):e instanceof Nt&&this.addRender(e,new Wn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,i]=e.rootBuilder.runtimeValues(e),s=this.getRender(e.builder),[o,a]=s._handleMeta(e,i);return e._getMeta("subbuilder")||(a=s.adaptAttrs(a)),s.renderedItem(e,e.value instanceof A?this.renderChildren(e.value,t):r,a,{tag:o,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,i=this.evaluateExpressions(e,t);Hr(e,i,r);let[s,o]=super._handleMeta(e,yc(e,i,r));if(zr(e,o,r),e.nodeTag==="webcomponent"){s=ct(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=hs(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Bt),[s,u]}let[a,l]=vc(s,o);return Object.keys(l).length&&this.#e.set(e,l),[s,a]}evaluateExpressions(e,t){let r=this.inlineCompiler,i=(o,a)=>r?r.compileExpression(e,o,a)(t):null,s={...t};for(let[o,a]of _e(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o)||Fe(a)&&Object.hasOwn(s,o)&&(s[o]=i(o,a));return Fe(e.value)&&this.#t.set(e,i("",e.value)),s}expressionValue(e,t){return Fe(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...Wr(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,i=`${this.builder.constructor._name}_`,s=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries(Rt(r))){if(u==null)continue;if(l.startsWith(i))throw new Error(`${l}: the attribute prefix '${i}' is not accepted; use the prefix '${s[0]}'`);let c=s.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Vn({...super.adaptAttrs(a),...o})}renderedItem(e,t,r,i={}){let s;[t,s]=zn(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:o,...a}=s;Array.isArray(t)&&o!=null&&(t=[this._escapeText(Vr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:we,...a}:a;return super.renderedItem(e,t,l,i)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let i=this._composeStringFragments(e),s=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return s.length===1&&s[0].nodeTag==="html"||(i=`<html>${i}</html>`),super.finalize(`<!doctype html>${i}`,t,r)}};var Ac={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"}},html_dialog:{doc:"Native HTML dialog, distinct from the layout window component.",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:{render_tag:"dialog"}}}};var Tc={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 Q(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var Ag="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Tg=new Set,Dg=new Set(["serverpath","dbenv","shared_id"]),Cg=["formsubscribe_"],Sg={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Ng={dataFormula:"formula",dataController:"script"};function Dc(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&H(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(i=>["action","ask","_delay","fire"].includes(i)||i.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(n))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(n))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(n)&&Object.keys(e).some(i=>i.startsWith("subscribe_")||i.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=Sg[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=Ng[n];return r&&e[r]!=null&&e.func!=null?`'func' and '${r}' cannot be declared on the same node`:r&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function Cc(n){return Object.keys(n).find(e=>Dg.has(e)||Cg.some(t=>e.startsWith(t)))}var Oe=class n extends St{static _name="gramlot";static _sourceClass=de;static{this.defineGrammar(Ac)}static{this.defineGrammar(Tc)}static{this.defineGrammar(ms.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(n);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:r=null,nameSyntax:i=Un}={}){if(!(i instanceof rr))throw new TypeError(`nameSyntax must be a NameSyntax, not ${i}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=i;for(let s of t)this.loadCollection(s)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,i,s){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,i.text)(s):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 It?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),r=n.dialectPrefixes;if(t.startsWith(`${n._name}_`))throw new Error(`${e}: the tag prefix '${n._name}_' is not accepted; use the prefix '${r[0]}'`);if(Tg.has(t))throw new Error(`${e}: excluded from Gramlot`);let i=this.schemaTagNames[t];if(i)return i;for(let s of r)if(t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)])return t;return null}bagCall(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.bagCall(e,t,r,i)}commandOnNode(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.commandOnNode(e,t,r,i)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new de(null,this),r];if(e==="menuline"&&t!=null&&t!=="-"){if(Object.hasOwn(r,"command"))throw new TypeError("menuline command must be declared once");return[null,{...r,command:t}]}return[t,r]}validateNodeValues(e,t,r={}){if(this.schema[e]?._meta?.gramlot_component&&H(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&ct(r);let i=Cc(r);if(i)throw new Error(`${e}: attribute '${i}' is excluded from Gramlot`);let s=Dc(e,r);if(s)throw new Error(`${e}: ${s}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&H((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&ct(t.attrs??e.getAttr());let r=Cc(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let i=Dc(e.nodeTag,t.attrs??e.getAttr());if(i)throw new Error(`${e.nodeTag} '${e.label}': ${i}`);return super.validateNode(e,t)}_validateChildren(e,t,r,i){return super._validateChildren(e,t,r.map(s=>s==="html_button"?"button":s==="html_dialog"?"dialog":s),i)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,i,s=null){i=Object.fromEntries(Object.entries(i??{}).map(([l,u])=>[l,J(u)instanceof Ae?this.reference(u):u]));let a=t==="dataSetter"&&i?.value!==null&&typeof i?.value=="object"&&Object.getPrototypeOf(i.value)===Object.prototype?{...i,value:new x(i.value)}:i;return super.setChild(e,t,r,a,s)}#e(e){if(e==="data")throw new Error(Ag);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=n.dialectPrefixes.find(r=>e.startsWith(r));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new ir(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let i=t!=null?{_text:t}:null;e.setValue(r,!0,i,!0)}reference(e,t="node"){if(e=J(e),!(e instanceof Ae)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=Q(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return U(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function Gn(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function sr(n,e,t,r){let{group:i,method:s}=n.logicRegistry.resolve(t,e);return s.call(i,e,r)}function rt(n,e,t,r,i,s=Object.keys(i)){return Gn(r)?sr(n,e,r,i):n.inlineCompiler.compile(e,t,r,s)(i)}var Ig=new Set(["input","select","textarea"]),Og=["type","multiple"];function Sc(n,e){let t=n.node,r=t.getAttr(e);return t.pointerType(r)?t.getRelativeData(r):n.resolved[e]}var ye=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#i=!1;#s=!1;#o=!1;static for(e,t){let r=n.classFor(t.element,t.attrs);return r?new r(e,t):null}static classFor(e,t){if(e.namespaceURI!==we)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?da:aa;if(e.localName==="textarea")return nt;if(e.localName==="select")return Xn;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(Nc,r)?Nc[r]:nt}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([]):e?.namespaceURI!==we||!Ig.has(e.localName)?null:JSON.stringify(Og.filter(r=>(r!=="type"||e.localName!=="input")&&(r!=="multiple"||!["input","select"].includes(e.localName))).map(r=>t[r]??null))}constructor(e,t){this.#r=e,this.#n=t}get binding(){return this.#r}get element(){return this.#n.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#n.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#s){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)&&(!this.#i||this.same(this.read(),e))||(this.#e=e,this.#t=!0,!(this.#i&&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.#n.text.data!==t&&(this.#n.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.#i=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#i=!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.#s=!0;return}if(e.type==="compositionend"){this.#s=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#s||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},aa=class extends ye{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Ic(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||Oc(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}))}}},nt=class extends ye{static liveWrites=!0},la=class extends ye{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},ua=class extends ye{static liveWrites=!0;read(){return Number(this.element.value)}},Xn=class extends ye{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 r=new Set((e??[]).map(String));for(let i of t.options){let s=r.has(i.value);i.selected!==s&&(i.selected=s)}}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((r,i)=>Object.is(r,e[i])):super.same(e,t)}},or=class extends ye{read(){return this.element.value===""?null:this.element.value}},ca=class extends ye{},gs=class extends ye{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()}},Gr=class extends gs{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,r=fa(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,r)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(e=this.resolved.group){let t=this.resolved.group??null,r=fa(this.node);if(!Object.is(e??null,t)){let i=new Set([this,...this.groups.peers(this),...t===null?[]:this.groups.peersOf(t,r)]);this.groups.leave(this),this.#e=t===null?null:this.groups.join(this,t,r),this.#e===null?this.element.removeAttribute("name"):this.element.setAttribute("name",this.#e);for(let s of i){if(this.binding.closed||!this.binding.runtime.renderer.attached(this.node))return;s.binding.closed||!s.binding.runtime.renderer.attached(s.node)||s.binding.runtime.renderer.html.writeParameter(s.node,"value",!1)}return}this.#e!==null&&this.groups.nameOf(t,r)!==this.#e&&(this.#r(t,r),this.groups.leave(this),this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}#r(e,t){let r=this.node;if(Sc(this,"value")&&this.groups.peersOf(e,t).some(i=>!i.binding.closed&&i.read()))throw new Error(`${r.nodeTag} '${r.label}': several true values in radio group '${e}'`)}project(e,t){let r=!this.#t;this.#t=!0;let i=this.read();super.project(e,t),!r&&!i&&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),Sc(e,"value")&&e.commit(null))}}},da=class extends Gr{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||Oc(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Ic(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,fa(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let i=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,s=t[(r+i+t.length)%t.length];s.element.focus(),s.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}))}}}},bs=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#i=0;constructor(e){this.#e=e}join(e,t,r){let i=this.nameOf(t,r);return this.#t.has(i)||this.#t.set(i,new Set),this.#t.get(i).add(e),this.#r.set(e,i),i}leave(e){let t=this.#r.get(e);this.#r.delete(e);let r=this.#t.get(t);r?.delete(e),r?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(r=>r!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#n.has(t)&&this.#n.set(t,this.#i++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function fa(n){for(let e=n;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var Nc={text:nt,password:nt,email:nt,url:nt,tel:nt,search:nt,number:la,range:ua,color:ca,date:or,time:or,month:or,week:or,"datetime-local":or,checkbox:gs,radio:Gr,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Ic(n){let{binding:e,node:t}=n,r=e.runtime.gramlot,i=(s,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,s,o,Object.keys(a),`return (${o});`)(a):rt(e.runtime,t,s,o,a);return{locale:r.locale,timeZone:r.timeZone,createDecimal:At,isDecimal:be,getDecimalLibrary:zo,publish:(s,o)=>t.publish(s,o),isActive:()=>!e.closed,reportError:(s,o)=>{e.closed||e.runtime.reportError(s,o)},callLogic:(s,o)=>sr(e.runtime,t,s,o),format:(s,o)=>r.format(s,o),invoke:i,remote:(s,o,a)=>r.rpc.call("data",s,o,{signal:a}),selectionOutputs:({selectedCaption:s,selectedRecord:o,fields:a},l)=>{if(!e.closed){s&&t.setRelativeData(s,l?.caption??null),o&&t.setRelativeData(o,l?new x(l.record):null);for(let[u,c]of Object.entries(a))t.setRelativeData(c,l?.record[u.slice(9)]??null)}},validationCurrent:()=>{let s=t.getAttr("value"),o=t.pointerType(s)?t.absDatapath(s):null;return()=>!e.closed&&t.getAttr("value")===s&&(o===null||t.absDatapath(s)===o)},finishValidation:({ok:s,result:o,rules:a})=>{if(e.closed)return;if(s)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=s?"validate_onAccept":"validate_onReject";if(a[l]){let u=c=>{e.closed||e.runtime.reportError(c,"Validation callback failed")};try{let c=Object.fromEntries(Object.entries(a).map(([f,h])=>[f.slice(9),h])),d=i(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:s=>{if(!(s instanceof x))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof x))throw new TypeError("Validation data changes require a Bag datapath.")}}}function Oc(n,e,t){let r=n.pageContext,i=s=>{s.ok&&s.isCurrent()&&(t(s),n.finishValidation(s))};if(e instanceof Promise)e.then(i).catch(s=>r.reportError(s,"Field update failed"));else try{i(e)}catch(s){r.reportError(s,"Field update failed")}}var ha=Symbol("source text"),Bc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Bg=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"]),Rg=new Set(["checked","muted","selected","value"]),$g=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Mg(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return $g.get(e.toLowerCase())??e}var _s=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:r=null,reportError:i=null}={}){this.invokeScript=t,this.callLogic=r,this.reportError=i,this.metadataAttributes=new Set([...Xt,"_text",...e])}definition(e){let t=e.builder,i={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},s=e.nodeTag==="webcomponent"?ct(e.getAttr()):Mn(e.nodeTag,{renderTag:i.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=s==="foreignObject"?Bt:i.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof Nt?Bt:we);return{meta:i,namespace:o,tag:s}}validate(e,t=e.builder){this.validateLabelbox(e);let r=e.value instanceof A,i=r?e.getAttr("_text"):e.value;if(i!=null&&!["string","number","boolean"].includes(typeof i))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)&&!(e.nodeTag==="menuline"&&a==="parameters")&&!(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 s=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=r?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:i,attrs:s,childTags:o})}hasLabelbox(e){let t=this.definition(e).meta.gramlot_component;return t?.labelbox?!0:t?.presentationDefaults.length?Object.hasOwn(e.attr,"lbl"):Object.keys(e.attr).some(r=>r==="lbl"||r.startsWith("lbl_")||r.startsWith("box_"))}validateLabelbox(e){if(!this.hasLabelbox(e))return;let{tag:t,namespace:r}=this.definition(e);if(r!==we&&t!=="svg"||["html","head","body","style","script","link","meta","title","base","tr","td","th","thead","tbody","tfoot","col","colgroup","caption","option","optgroup","li","dt","dd","source","track","param","area"].includes(t))throw new TypeError("Labelbox requires content that can be placed in an HTML flow container");let i=e.parentNode;if(i?.nodeTag){let s=this.definition(i);if(s.namespace!==we&&s.tag!=="foreignObject"||["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","ul","ol","dl","p","button","label"].includes(s.tag))throw new TypeError("Labelbox requires an HTML flow container")}}create(e,t,r=null,i=e.attr,s=null){let{tag:o,namespace:a,meta:l}=this.definition(e);r??=o;let u=a===we?t.createElement(r):t.createElementNS(a,r);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==r)throw new Error(`Component collection must be activated before rendering ${r}`);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({reportError:(f,h)=>this.reportError(e,f,h),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!==we||!l.void)&&u.append(c);let d={element:u,text:c,tag:r,presentation:u};if(this.hasLabelbox(e)){this.validateLabelbox(e);let f=t.createElement("div");f.append(u),d.labelbox=fc(t,f),d.presentation=d.labelbox.box,d.labelId=`gramlot-label-${Q()}`,d.controlId=`gramlot-control-${Q()}`;let h=t.createElement("style");h.textContent=dc,d.presentation.prepend(h),l.gramlot_component?.labelbox&&u.setLabelbox(d.labelbox)}return this.update(d,e,i,ha,s),d}matches(e,t){let{tag:r,namespace:i}=this.definition(t);return(i===we?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===i}writeParameter(e,t,r){let i=e.getAttr(t);e.pointerType(i)==="^"&&!H(i)&&!Object.is(e.getRelativeData(i.slice(1)),r)&&e.setRelativeData(i.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let i of r)e.element.append(i)}update(e,t,r=t.attr,i=ha,s=null){if(t.nodeTag==="script"){for(let[b,g]of t.codeAttributes())if(t.activatedCode(b)!==g)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:o,text:a}=e;if(this.hasLabelbox(t)&&!e.labelbox)throw new TypeError("Declare lbl or box_* when creating an experimental HTML labelbox");let l=o.namespaceURI===we,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=b=>(Hr(t,b,t.builder.constructor.dialectPrefixes),zr(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(r=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(e.presentation,r,{label:t.label,adapt:d,invoke:(g,_,w)=>this.invokeScript(t,g,_,w),reportError:(g,_)=>this.reportError(t,g,_),publish:(g,_)=>t.publish(g,_),publishParent:(g,_)=>f.publish(g,_),writeParameter:(g,_)=>this.writeParameter(t,g,_),remove:()=>t.parentBag.popNode(t.label)})),e.labelbox&&(e.labelbox.box.style.visibility="",hc(e.labelbox,r,d)),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&o.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),r=o.projectAttributes(r,d)),e.labelbox&&(r=Object.fromEntries(Object.entries(r).filter(([b])=>b!=="lbl"&&!b.startsWith("lbl_")&&!b.startsWith("box_"))),r.slot!=null?e.presentation.setAttribute("slot",r.slot):e.presentationSlot!=null&&e.presentation.removeAttribute("slot"),e.presentationSlot=r.slot,delete r.slot),r=Object.fromEntries(_e({...r,...u}));let h=ye.classFor(o,r)!==null;i===ha&&(i=this.text(t));let m=i==null?"":String(i);a.data!==m&&(a.data=m);let p=[...new Set([...Object.keys(c),...Object.keys(r)])];p.sort((b,g)=>(g==="sandbox")-(b==="sandbox")||(l&&o.localName==="input"?(g==="type")-(b==="type"):0));for(let b of p){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||h&&b==="value")continue;let g=r[b];if(l&&b==="multiple"&&["input","select"].includes(o.localName)){o.multiple!==!!g&&(o.multiple=!!g);continue}if(l&&o.localName==="input"&&b==="type"){Object.is(c.type,g)||(g==null?o.removeAttribute("type"):o.type=String(g));continue}let _=b,w=Mg(_),E=l&&Bg.has(w)&&typeof o[w]=="boolean",D=_==="xmlns"?"xmlns":_.includes(":")?_.split(":")[0]:"",y=Object.hasOwn(Bc,D)?Bc[D]:null;if(Object.is(c[b],g)||(g==null||E&&!g?y?o.removeAttributeNS(y,_.split(":").at(-1)):o.removeAttribute(_):y?o.setAttributeNS(y,_,String(g)):o.setAttribute(_,E?"":String(g))),l&&(E||Rg.has(w))&&w in o){let T=w==="value"?g==null?"":String(g):!!g;o[w]!==T&&(o[w]=T)}}if(s===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(r.style==null?o.removeAttribute("style"):o.setAttribute("style",String(r.style))),e.visible=s,e.labelbox){let{fieldLabel:b,labelBox:g,box:_}=e.labelbox;["input","textarea","select","button","output","meter","progress"].includes(e.tag)?(o.id||(o.id=e.controlId),b.htmlFor=o.id):(b.id=e.labelId,this.definition(t).meta.gramlot_component?.labelbox||(_.setAttribute("role","group"),g.hidden?_.removeAttribute("aria-labelledby"):_.setAttribute("aria-labelledby",b.id))),_.hidden=!!r.hidden,s===!1&&(_.style.visibility="hidden")}e.attrs=r}text(e){return e.value instanceof A?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};function Lg(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function Rc(n){if(!n||!(n.value instanceof A))return null;let e=n.value.getNodes().find(i=>i.getAttr("region")==="center"),t=[];function r(i){if(i.nodeTag!=="framePane"&&(i.getAttr("frameTarget")===!0&&t.push(i),i.value instanceof A))for(let s of i.value.getNodes())r(s)}return e&&r(e),t.length===1?t[0]:null}function Pg(n){if(n.closed||!n.runtime.renderer.attached(n.node))return!1;for(let e=n.node;e;e=e.parentNode){let[,t]=e.rootBuilder.runtimeValues(e);if(t.hidden===!0||t.disabled===!0)return!1}return!0}function $c(n){if(n&&typeof n=="object"){for(let e of Object.values(n))$c(e);Object.freeze(n)}return n}function Mc(n,e){let t=n.node,r=t.getAttr("command"),i=n.runtime.gramlot.commands.get(r),s=Lg(t),o=Rc(s);if(!i||!o)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let a=t.getAttr("parameters")??{};if(typeof a!="object"||Array.isArray(a))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(a).map(([p,b])=>[p,t.pointerType(b)?t.getRelativeData(b):b])),u=$c(j(U(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(p=>[p,!!e[`${p}Key`]]))),d=Object.freeze({sender:t,target:o,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(o).track(()=>{f=!0}),m=()=>!f&&Pg(n)&&Rc(s)===o&&n.runtime.renderer.attached(o)&&t.getAttr("command")===r;return{message:d,current:m,release:h,cancel(){f=!0},deliver(){m()&&o.publish(i.publish,d)}}}var ws=class n{#e;#t;#r=null;#n=0;#i=new Set;#s=null;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new n(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 r=e.getAttr()??{},i=[];if(t.length&&i.push("controller"),r.action!=null&&i.push("action"),e.nodeTag==="menuline"&&r.command!=null&&i.push("registered"),Lc(r).length&&i.push("fire"),e.nodeTag==="menuline"&&e.value instanceof A&&e.value.getNodes().some(s=>s.nodeTag==="menu")&&i.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&i.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(i.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${i.join(" and ")} together; a button has one click mechanism`);return i[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){if(this.node.nodeTag==="menuline"){let t=this.node.getAttr("command"),r=t?this.binding.runtime.gramlot.commands.get(t):null;this.element.setCommandDefinition(r,this.node.label),t&&!r&&this.#s!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#s=t)}for(let t of this.#i)t.current()||t.cancel();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?.();for(let e of this.#i)e.cancel(),e.release();this.#i.clear()}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))return;let r=this.mechanism;if(!r||(e.stopPropagation(),this.element.disabled))return;let i=r==="registered"?Mc(this.binding,e):null;if(r==="registered"&&!i)return;i&&this.#i.add(i);let s=this.binding.countClick(),o=this.node;for(;o&&o.getAttr("_delay")==null;)o=o.parentNode;let a=o?o.rootBuilder.runtimeValues(o)[1]._delay:0;if(a>0){let l=this.#n+1;this.#r?.(),this.#n=l;let u=setTimeout(()=>{c(),this.#r=null,this.#n=0,this.#a(e,l,i)},a),c=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(u),i&&(i.cancel(),i.release(),this.#i.delete(i)),c(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#a(e,s,i)}async#o(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,i={...e.message.parameters};if(t&&r.required(this.binding,t,i,"ask")&&await r.show(this.binding,t,i)===null)return;e.deliver()}finally{e.release(),this.#i.delete(e)}}#a(e,t,r=null){if(r)return this.#o(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let s=this.node,o=jg(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(i==="action"){let a=()=>{let[,d]=s.rootBuilder.runtimeValues(s),f=Object.fromEntries(Object.entries(d).filter(([h])=>h!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(f),event:e,_counter:t,modifiers:o}},l=d=>{if(this.binding.closed||this.element.disabled||d===null)return;let f={...a(),...d};d&&(f._askResult=d),rt(this.binding.runtime,s,"action",s.getAttr("action"),f)},u=s.getAttr("ask"),c=this.binding.runtime.askDialog;if(u&&c.required(this.binding,u,a(),"ask"))return c.show(this.binding,u,a()).then(l);l(void 0)}else{let a={modifier:o,_counter:t},l=s.getAttr("fire");if(l!=null){s.FIRE(l,o||!0,a);return}for(let[u,c]of Lc(s.getAttr())){if(this.binding.closed)return;s.FIRE(c,u.slice(5),a)}}}};function Lc(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function jg(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var We=class extends K{static classKwargs={...K.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(r=>this.#t(r));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(r=>{r?.name!=="AbortError"&&this.onError(r)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,r]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=r);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let i=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(i,this.cacheTime!==0):this.cachedValue=i}finally{this.writing=!1}return i}};var Xr=class extends We{static internalParams=new Set([...We.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:i,onCalling:s=null,onError:o,sync:a=!1}){super({cacheTime:i,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=r,this.onCalling=s}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 Pc=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function jc(n,e=new Set){if(!(n instanceof x)||e.has(n))throw new TypeError("Menu resolver must return an acyclic Bag");let t=new Set([...e,n]);return n.getNodes().map(r=>{let i=r.attr,s=i.kind,o=r.staticValue;if(Object.keys(i).some(l=>!Pc.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(s))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(i[l]!=null&&typeof i[l]!="boolean"&&!(typeof i[l]=="string"&&i[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(i.favorite!=null&&typeof i.favorite!="boolean")throw new TypeError("favorite must be boolean");if(i.caption!=null&&typeof i.caption!="string")throw new TypeError("Menu caption must be text");if(i.parameters!=null&&(typeof i.parameters!="object"||Array.isArray(i.parameters)))throw new TypeError("Menu parameters must be a mapping");if(s==="command"&&(typeof i.command!="string"||!i.command||o!=null||i.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(s==="separator"&&(o!=null||Object.keys(i).length!==1))throw new TypeError("Separator record accepts kind only");if(s==="submenu"&&(typeof i.caption!="string"||i.command!=null||o instanceof x==(i.resolver!=null)||!(o instanceof x)&&o!=null))throw new TypeError("Submenu requires caption and exactly one content source");let a=o instanceof x?jc(o,t):null;return{label:r.label,attrs:{...i},children:a}})}function Fc(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof A?n.value.getNodes():[],i=new Set(e.map(s=>s.label));for(let s of r)i.has(s.label)||n.value.popNode(s.label);for(let[s,o]of e.entries()){let{kind:a,...l}=o.attrs,u=Object.fromEntries(Object.entries(l).filter(([m])=>m==="resolver"||m==="cacheTime"||m==="sync"||m.startsWith("resolver_")));for(let m of Object.keys(u))delete l[m];let c=a==="separator"?"-":null,d=n.value instanceof A?n.value.getNodes().find(m=>m.label===o.label):null,f=d?.value instanceof A;if(d&&(f!==(a==="submenu")||d.value==="-"!=(a==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=J(t.menuline(c,{...l,node_label:o.label}));else{let m=Object.keys(d.attr).filter(p=>Pc.has(p)&&!Object.hasOwn(l,p));d.setAttr({...Object.fromEntries(m.map(p=>[p,null])),...l})}if(a==="submenu"){let m=d.value instanceof A?d.value.getNodes().find(p=>p.nodeTag==="menu"):null;m?m.setAttr({...Object.fromEntries(Object.keys(m.attr).filter(p=>p==="resolver"||p==="cacheTime"||p==="sync"||p.startsWith("resolver_")).map(p=>[p,null])),...u}):m=J(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),o.children&&Fc(m,o.children)}let h=n.value.getNodes().indexOf(d);h!==s&&n.value.move(h,s)}}var ys=class{#e=null;#t=null;#r=0;#n=!1;#i=null;constructor(e,t){this.binding=e,this.element=t}get node(){return this.binding.node}attach(){this.element.menuBinding=this,this.refresh()}detach(){this.#n=!0,this.#r++,this.node.requests.inflight?.cancel(),delete this.element.menuBinding,this.element.close(!1)}refresh(){let[,e]=this.node.rootBuilder.runtimeValues(this.node),t=Object.fromEntries(Object.entries(e).filter(([i])=>i.startsWith("resolver_")).map(([i,s])=>[i.slice(9),s])),r=U([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#i=null,this.#t=e.resolver?new Xr({binding:this.binding,method:e.resolver,params:t,cacheTime:e.cacheTime??-1,sync:e.sync??!1,onError:()=>{}}):null,this.#t?(this.element.setStatus("loading"),this.element.opened&&this.element.isConnected&&this.load()):this.element.setStatus(null))}async load(e=!1){if(this.#n||!this.#t)return;let t=this.#t,r=this.#r;try{if(e?t.refresh():t.resolve(),t.loading&&(this.element.setStatus("loading"),await t.loading),this.#n||r!==this.#r)return;let i=t.cachedValue,s=jc(i),o=U(i);this.#i!==o&&(Fc(this.node,s),this.#i=o),this.element.setStatus(s.length?null:"empty")}catch(i){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,i)}}};var vs="connect_on",Yn=class{#e;#t;#r;#n;#i;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(vs)&&t.length>vs.length&&r!=null).map(([t,r])=>[t,t.slice(vs.length).toLowerCase(),r])}constructor(e,t,r,i,s=`${vs}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s}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.#n}get attribute(){return this.#i}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,r=this.binding.runtime;if(Gn(this.handler))return sr(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function Mt(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(J(n)instanceof Ae||t&&n instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(n))throw new TypeError("Transport data cannot contain circular references");e.add(n);let r=n instanceof x?n.getNodes().flatMap(i=>[i.staticValue,i.getAttr()]):Object.values(n);for(let i of r)Mt(i,e);e.delete(n)}var Zn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,i=s=>{for(let o of s.getNodes()){let a=o.getAttr("__ref");if(a){if(r.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");r.set(a,o)}o.value instanceof A&&i(o.value)}};i(e)}register(e,t){let r=e.getAttr("__ref");if(r){if(this.entries.has(r))throw new Error(`Duplicate Source reference: ${r}`);this.entries.set(r,{node:e,dom:t})}}remove(e){for(let[t,r]of this.entries)r.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r&&typeof r=="object"&&Object.hasOwn(r,"$gramlotRef")?this.resolve(r):r]))}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 Es=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},pa=class{#e;#t;#r;#n;#i;#s=!0;#o;constructor(e,{path:t,attr:r,recipient:i,order:s,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#o}get active(){return this.#s}get order(){return this.#i}close(){this.active&&(this.#s=!1,this.router.unregister(this))}},ma=class{constructor({evt:e,node:t,path:r,oldvalue:i,attrsDiff:s,reason:o,fired:a,level:l,registration:u}){this.evt=e,this.node=t,this.path=r,this.oldvalue=i,this.attrsDiff=s,this.reason=o,this.fired=a,this.level=l,this.registration=u}},xs=class{#e;#t=new Es;#r=new Map;#n=0;#i=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#n}register({path:e,attr:t=null,recipient:r,subtree:i=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let s=this.#t;for(let a of e.split(".")){let l=s.children.get(a);l||(l=new Es(s,a),s.children.set(a,l)),s=l}this.#i+=1;let o=new pa(this,{path:e,attr:t,recipient:r,order:this.#i,subtree:i});return s.registrations.add(o),this.#r.set(o,s),this.#n+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#n-=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]!==Fn||e.reason==="autocreate")return;let r=t.slice(1),i=e.evt==="ins"||e.evt==="del";for(let s of Array.isArray(e.node)?e.node:[e.node]){let o=i?[...r,s.label]:r,a=o.join(".");for(let[l,u]of this.#s(o,e))l.active&&l.recipient.receive(new ma({evt:e.evt,node:s,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#s(e,t){let r=[],i=this.#t;for(let o of e){for(let a of i.registrations)i!==this.#t&&this.#o(a,"child",t)&&r.push([a,"child"]);if(i=i.children.get(o),!i)return r.sort(([a],[l])=>a.order-l.order)}for(let o of i.registrations)this.#o(o,"node",t)&&r.push([o,"node"]);let s=[...i.children.values()];for(;s.length;){let o=s.pop();for(let a of o.registrations)this.#o(a,"container",t)&&r.push([a,"container"]);s.push(...o.children.values())}return r.sort(([o],[a])=>o.order-a.order)}#o(e,t,r){let{evt:i}=r;return e.subtree?t!=="container"||i!=="upd_attrs":e.attr===null?i==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?i!=="upd_attrs":i==="ins"||i==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var ks=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=Jn(e),r=this.setterNodes(e);ba(e);for(let i of r)this.applySetter(i),this.runtime.closeBranch(i),i.parentBag&&i.parentBag.popNode(i.label);this.applyDefaults(t.filter(i=>i.nodeTag&&!i._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 r=e.getAttr("value")??null,i=qg(e.getAttr()),s=this.runtime.data;if(r!==null)s.setItem(t,r,i,">",!1,!0,e),r instanceof x&&e.setAttr({value:null},!1);else{let o=s.getNode(t);o?i&&o.setAttr(i,!0):s.setItem(t,null,i,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[i,s]of Object.entries(r)){if(!Fg(t,i,s))continue;let o=i==="value"?r.default_value??r.default:r[`default_${i}`];o!=null&&this.#t(t,s,o)}this.#r(t,r)}}#t(e,t,r){let i=e.absDatapath(t);if(i===null)return;let[s,o=null]=i.split("?",2),a=this.runtime.data,l=a.getNode(s);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(s,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:r},!0)}else a.setItem(s,null,{[o]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(r[o.slice(5)]=H(a)?$t(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(r).length)return;let i=[t.value,t.src].find(o=>e.pointerType(o));if(!i)return;let s=e.absDatapath(i);s!==null&&this.runtime.data.getNode(s.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function Fg(n,e,t){return e==="_meta"||Xt.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function qg(n){let e={};for(let[t,r]of Object.entries(Rt(n??{})))Xt.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function Ug(n){let e=n.builder;if(!(e instanceof Oe))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function ba(n){for(let e of Jn(n))e.nodeTag==="dataSetter"&&Ug(e),Gg(e)}var Vg=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],zg=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Hg=["_onCalling","_onResult","_onError"],Wg=["_delay","_timing","_userChanges"],ga=["_init","_onBuilt","_onStart"];function Gg(n){let e=s=>n.getAttr(s)!==null&&n.getAttr(s)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let s=Hg.find(o=>e(o)&&!(o==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(s){let o=s==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${s}' is allowed only on ${o}`)}}if(zg.has(n.nodeTag)){let s=Object.entries(n.getAttr()).find(([,a])=>Fe(a));if(s)throw new Error(`${n.nodeTag} '${n.label}': '${s[0]}' is a == expression, not accepted on ${n.nodeTag}`);let o=n.nodeTag==="dataRemote"?ga.find(e):null;if(o)throw new Error(`dataRemote '${n.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of ga){let l=n.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Vg.find(s=>e(s)&&!(s==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&Wg.includes(s)));if(!r)return;let i=ga.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${i}`)}function Jn(n){if(n instanceof A)return n.getNodes().flatMap(t=>Jn(t));let e=[n];return n.value instanceof A&&e.push(...Jn(n.value)),e}var Xg=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"]),Kn=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,i=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(i)),this.#r=()=>{clearTimeout(i),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),i=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),i(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},Yr=class{#e;#t=[];#r=new Set;#n;#i=null;#s=!1;constructor(e){this.#e=e,this.#n=new Kn(e),e.track(()=>{this.cancel(),this.#p(),this.#f()})}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.#p();let r=this.binding.runtime.router,i=Ge(e,e.getAttr("_timing"));for(let[s,o]of e.pointers()){if(s==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(s==="_timing"||i.has(s))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(s,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.#n.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},r=this.#a("_delay");r>0?this.#n.debounce(r,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,r=this.kind==="formula",i=this.kind==="rpc",s=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(m=>{if(!this.binding.closed){if(m===null){let p=t.getAttr("_ask_onCancel");p&&this.#l("_ask_onCancel",p,p,o,!0);return}return this.invoke({...e,askDone:!0,askResult:m})}});let[u,c]=[r?"formula":"script",t.getAttr(r?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(s&&this.#f(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(i||s){this.#l(u,c,c,o,!0);return}}if(i)return this.#c(o);if(s)return this.#d(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,o,!0);else if(f==null){if(!r)return;h=new x(As(o))}else{let{group:m,method:p}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?p.call(m,o):p.call(m,t,o)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),i=Object.fromEntries(Object.entries(r).filter(([l])=>!Xg.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(i)};e.kind==="subscription"&&(s._subscription_kwargs=e.payload);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return s._node=o?o.node:null,s._triggerpars={kw:o,trigger_reason:a},s._reason=a,e.kind==="click"&&Object.assign(s,Yg(e)),s}cancel(){this.#n.cancel()}#o(){this.#n.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,r=t.getAttr(e);return H(r)?$t(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,i,s){let o=[...s?["_kwargs"]:[],...qc,...Uc,...Object.keys(As(i))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?rt(this.binding.runtime,this.node,e,t,{...i,_kwargs:i},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,r)({...i,_kwargs:i})}async#c(e){let t=this.node,[r,i,s]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return o.submit(this.#a("method"),As(e),a=>this.#u(a,e,i,s))}async#u(e,t,r,i){if(this.binding.closed)return;let s=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${s.nodeTag} '${s.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(!i)throw l.error;this.#l("_onError",i,i,{...t,error:l.error},!0);return}let{result:u}=l;s.getAttr("result_path")!=null&&s.setRelativeData(s.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#f();let t=this.#s;this.#s=!1;let r=this.node,i=r.absDatapath(r.pathAttribute("destination_path"));if(i===null)return;let s=r.getAttr("_onCalling"),o=new Xr({binding:this.binding,method:this.#a("method"),params:As(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:s?()=>this.#l("_onCalling",s,s,e,!0):null,onError:a=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(i,o),this.#i={path:i,resolver:o},t&&o.refresh()}#f(){if(!this.#i)return;let{path:e,resolver:t}=this.#i;this.#i=null,this.#s=t.loaded||t.loading!==null;let r=this.binding.runtime.data.getNode(e);r?.resolver===t&&(r.resolver=null)}#p(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},Ts=class extends Yr{get kind(){return"formula"}},Ds=class extends Yr{get kind(){return"controller"}},Cs=class extends Yr{get kind(){return"rpc"}},Ss=class extends Yr{get kind(){return"remote"}},qc=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],Uc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function As(n){let e={...n};for(let t of[...qc,...Uc])delete e[t];return e}function Yg({event:n,counter:e}){return{_evt:n,button_counter:e,button_shift:!!n.shiftKey,button_ctrl:!!n.ctrlKey,button_alt:!!n.altKey,button_meta:!!n.metaKey}}var Zg=[[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 "]],Jg=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,Kg=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"]),Ns=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,r){let i=r.trim();if(Jg.test(i))throw new Error(`${Qn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let s=i.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of Zg)o&&(s=s.replace(o,`; ${o.source.slice(1)}`)),s=s.replace(a,l);return s!==i&&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`),s}compile(e,t,r,i,s=r){if(e.activatedCode(t)!==r)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!==s&&(a={source:s,text:this.preprocess(e,t,s),key:null,run:null},o.set(t,a));let l=i.filter(Qg),u=l.join(",");if(a.key!==u){let c=eb(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,r){let i=r.slice(2).trim(),s=_e(e.getAttr()).filter(([,a])=>!Fe(a)),o=this.compile(e,t,r,[...s.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${i}`);return a=>{let l={};for(let[u,c]of s)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,r,i){let s=this.compile(e,t,r,["_pointerValues","_F"],`return (${i}
|
|
188
|
-
)`);return o=>s({_pointerValues:o,_F:(a,l)=>this.runtime.gramlot.format(a,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let i of t){r.delete(i);for(let[s]of _e({[i]:null}))r.delete(s)}}};function
|
|
186
|
+
`,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.renderIcon(this.parameters.icon,this.parameters.iconSrc),e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),r}renderIcon(e,t){if(!t){this.icon.textContent=e??"";return}let r=this.icon.firstElementChild;r||(r=this.ownerDocument.createElement("img"),r.alt="",r.draggable=!1,this.icon.replaceChildren(r)),r.getAttribute("src")!==t&&r.setAttribute("src",t)}get entryIcon(){return this.parameters.icon}get entryIconSrc(){return this.parameters.iconSrc}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}Yn.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var bg=Bt({name:"button",tag:"gramlot-button",base:Yn,command:!0,subTags:"*",implementation:n=>class extends n{}}),_g=Bt({name:"toggleButton",tag:"gramlot-toggle-button",base:Yn,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:n=>class extends n{#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)}}}),wg=Bt({name:"menu",tag:"gramlot-menu",base:Dc,subTags:"menuline,spacer,contentPane",parameters:{presentation:{dtype:"T",default:"popup",enum:["popup","bar"]},orientation:{dtype:"T",default:"horizontal",enum:["horizontal","vertical"]},modifiers:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",default:"beside",enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",default:24},resolver:{dtype:"T",nullable:!0},cacheTime:{dtype:"R",default:-1},sync:{dtype:"B",default:!1}},implementation:n=>class extends n{}}),yg=Bt({name:"menuline",tag:"gramlot-menu-line",base:Yn,command:!0,subTags:"*",parameters:{command:{dtype:"T",nullable:!0},caption:{dtype:"T",nullable:!0},code:{dtype:"T",nullable:!0},checked:{dtype:"B",nullable:!0,binding:"read"},tooltip:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",nullable:!0,enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",nullable:!0},group:{dtype:"B",default:!1},priority:{dtype:"R",default:0},overflowable:{dtype:"B",default:!0},parameters:{annotation:{kind:"type",module:"builtins",name:"dict"},nullable:!0},favorite:{dtype:"B",default:!1}},implementation:Cc}),vg=Bt({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=Ur(this,e),{size:r,flex:i}=this.parameters;if(r!=null&&i!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||i!=null&&(!Number.isFinite(i)||i<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=i!=null?`${i} 1 0px`:`0 0 ${r??0}px`,this.setAttribute("aria-hidden","true"),t}},parameters:{size:{dtype:"R",nullable:!0},flex:{dtype:"R",nullable:!0}},implementation:n=>class extends n{}}),Eg=Bt({name:"dropDownButton",tag:"gramlot-drop-down-button",base:Yn,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#i;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#i=e.createElement("span"),this.#i.hidden=!0,this.control.append(this.#i),this.#n=e.createElement("button"),this.#n.type="button",this.#n.className="arrow",this.#n.textContent="\u25BE",this.#n.setAttribute("aria-label","Open menu"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.controlBox.append(this.#n);let t=e.createElement("slot");t.name="menu",this.shadowRoot.append(t),this.#n.addEventListener("click",r=>{r.stopPropagation(),this.menu.opened?this.closeMenu():this.openMenu()}),this.#n.addEventListener("keydown",r=>{["ArrowDown","ArrowUp"].includes(r.key)&&(r.preventDefault(),this.openMenu(r.key==="ArrowUp"))})}get menu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")}get menuItems(){return this.menu?.items??[]}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#n.disabled=this.disabled,this.disabled&&this.menu?.close(!1),this.#s(),r}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#r=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#r)}catch{}}this.#s(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#s()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.menu?.close(!1)}commandTarget(e){return e?.composedPath().includes(this.menu)?null:this.menuItems.find(t=>t.occurrence===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.occurrence,this.#r)try{this.ownerDocument.defaultView.localStorage.setItem(this.#r,this.#e)}catch{}this.#s()}this.closeMenu()}#s(){let e=this.menuItems.map(i=>i.occurrence).filter(Boolean);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),r=t!==this;this.caption.hidden=r,this.#i.hidden=!r,this.#i.textContent=r?t.entryCaption:"",this.renderIcon(t.entryIcon,t.entryIconSrc)}openMenu(e=!1){this.disabled||this.menu?.open(this.#n,e)}closeMenu(){this.menu?.close()}}}),ws=la({name:"buttons",components:[bg,_g,Eg,wg,yg,vg]});function xg(n,e,t=n){let r=new Map,i=new Set,s=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=H(l)?.pointer??l;s.set(a,u instanceof Q?u.resolve():n.pointerType(u)?t.getRelativeData(u):Fe(u)?null:u)}let o=a=>{if(r.has(a))return r.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(i.has(a))throw new Error(`cyclic attribute dependency: ${[...i,a].join(" -> ")}`);i.add(a);let l=e.get(a),u=H(l),c=u?s.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=Bn(u.body),m=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,a,l,h,m)}else d=Gt(u.body,f),c==null&&(d=null);else d=s.get(a);return r.set(a,d),d}finally{i.delete(a)}};return{resolve:o}}function Mt(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),..._e(n.getAttr())]);return xg(n,r,t).resolve(e)}var kg={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"]},ua=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],Ag=["_if","_else","_onRemote","_onCalling"],ca=class{#e;#t=null;#r=null;#n=!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 j(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,r=this.#n;this.#n=!0;try{t=e()!==!1}finally{this.#n=r,!t&&!this.#t&&this.#i()}return t}submit(e,t,r){try{let i=F(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((s,o)=>{this.#r={method:e,text:i,perform:r,resolve:s,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#s(e,t,i,r))}catch(i){return Promise.reject(i)}}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()}#i(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#s(e.method,j(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#s(e,t,r,i){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let s=new AbortController,o={method:e,params:t,text:r,controller:s,ignored:!1};o.view=Object.freeze({method:e,get params(){return j(r)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,s.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(i(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.#i())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#i())}};function Sc(n){return typeof n=="string"&&n.startsWith("==")}var ir=class extends Ae{get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof A?this.value.getNodes():[];if(e.length){if(e.length!==1||e[0].nodeTag!=="framePane")throw new TypeError("A window requires exactly one framePane");return this.builder.wrapSource(e[0])}return this.builder.wrapSource(this.builder.commandOnNode(this,"framePane",null,{node_label:"frame"}))}requestClose(e="application"){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("requestClose requires a window");return this.rootBuilder.binding.gramlot.dom.getDomNode(this).requestClose(e)}get top(){return this.frameRegion("top")}get bottom(){return this.frameRegion("bottom")}get left(){return this.frameRegion("left")}get right(){return this.frameRegion("right")}get center(){return this.frameRegion("center")}frameRegion(e){if(this.nodeTag!=="framePane")throw new TypeError("Region accessors require framePane");let t=this.value instanceof A?this.value.getNodes().find(i=>i.getAttr("region")===e):null;if(t)return this.builder.wrapSource(t);let r={region:e,node_label:e};return e!=="center"&&Object.assign(r,{display:"flex",flex_direction:["top","bottom"].includes(e)?"column":"row"}),this.builder.wrapSource(this.builder.commandOnNode(this,"contentPane",null,r))}#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new ca(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...kg[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,r])=>r.inline).map(([r])=>r),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?Ag:[]],t=[];for(let[r,i]of Object.entries(this.getAttr()??{}))typeof i=="string"&&(e.includes(r)||r==="validate_call"||r==="validate__onResult"||r==="validate_onAccept"||r==="validate_onReject"||/^validate_\w+_if$/.test(r)||r.startsWith("connect_on")||r.startsWith("subscribe_")||r.startsWith("selfsubscribe_"))&&t.push([r,i]);for(let r of["ask","_ask"]){let i=this.getAttr(r);if(i&&typeof i=="object")for(let s of["_if","askIf"])typeof i[s]=="string"&&t.push([`${r}.${s}`,i[s]])}for(let[r,i]of _e(this.getAttr()))if(Sc(i)&&t.push([r,i]),this.nodeTag==="script"&&typeof i=="string"){let s=this.builder.constructor.dialectPrefixes.find(o=>r.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(s.length).toLowerCase())&&t.push([r,i])}return(Sc(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,r]of this.codeAttributes()){if(this.pointerType(r))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${r}'; inline code is never read from Data`);e.set(t,r)}for(let[t,r]of[..._e(this.getAttr()),["datapath",this.getAttr("datapath")]])H(r)?.expression&&e.set(t,r);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let r=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||r.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${r.pattern}, not ${JSON.stringify(e)}`);let i=Object.keys(t).find(o=>o.startsWith("_")&&!ua.includes(o));if(i)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${i}' is not accepted; the control attributes are ${ua.join(", ")}`);let s={remote:e};for(let[o,a]of Object.entries(t))s[ua.includes(o)?o:`remote_${o}`]=a;return this.setAttr(s),jn(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=H(e)?tt(this,e):new Set,r=super.pointers().filter(([i,s])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(i))&&!t.has(i)&&!this.#s(i,s)).map(([i,s])=>[i,H(s)?.pointer??s]);for(let i of t){let s=this.getAttr(i);this.pointerType(s)==="^"&&r.push(["datapath",H(s)?.pointer??s])}return r}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,r]of e){if(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(t)){e.set(t,new Ct(()=>r));continue}if(this.pointerType(r)){if(H(r)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(r)===null&&e.set(t,new Ct(()=>Mt(this,t)));continue}this.#s(t,r)?e.set(t,r.slice(1)):this.absDatapath(r)===null&&e.set(t,null)}}return e}pathAttribute(e){let t=this.getAttr(e);return H(t)?Mt(this,e):this.pointerType(t)&&this.#s(e,t)?t.slice(1):t}getRelativeData(e,t=null,r={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,r)}setRelativeData(e,t,r={}){this.#o(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,r=null){t===null&&(t=!0),this.#o(e);let i=this.absDatapath(e);if(i.includes("?")){this.#n(i,t);return}this.data.getNode(i)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(i)?.setValue(null,!1)}}#n(e,t){let[r,i]=e.split("?",2),s=this.data;s.getNode(r)?.setAttr({[i]:null},!1);try{let o=s.getNode(r);o?o.setValue(o.staticValue,!0,{[i]:t},!0,!0,!0,!0):s.setItem(r,null,{[i]:t},">",!0,!0,!0,!0)}finally{s.getNode(r)?.setAttr({[i]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#o(e);let i=this.rootBuilder?.binding?.bindingFor(this)??null,s=null,o=setTimeout(()=>{s?.(),this.FIRE(e,t)},r);return s=i?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),s?.()}}absDatapath(e){e=H(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,i]=t.split("?",2),s=super.absDatapath(r);return s===null?null:`${s}?${i}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");if(this.pointerType(i)&&(i=this.#i(r,i),i===null))return null;if(i!=null&&(e=e==="."?i:i+e),e.startsWith("#"))return r.parentNode._resolveSymbolicDatapath(e,t);r=r.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 r=e.slice(1).split(".",1)[0];if(r==="FORM"||r==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let i=this.rootBuilder?.binding;if(!i)return super._resolveSymbolicDatapath(e,t);let s=i.nodeIds.get(r);if(!s)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(r.length+2);return s.absDatapath(o?`.${o}`:".")}#i(e,t){if(H(t)){let s=Mt(e,"datapath",e.parentNode);return s==null||s===""?null:s}let r=e.parentNode.absDatapath(t);if(r===null)return null;let i=this.data.getItem(r);return i==null||i===""?null:i}#s(e,t){return H(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}'`)}},de=class n extends A{get nodeClass(){return ir}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let i=r.getAttr("auth")??null;if(i!==null){if(typeof i!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof i}`);if(e(i)!==null)continue}let s=r.staticValue;s instanceof n&&(s=s.authorizedCopy(e));let{auth:o,...a}=r.getAttr(),l=t.setItem(r.label,s,a,">",!1,!1,null,!1,!0,null,r.nodeTag);l.xmlTag=r.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof n&&e.staticValue.activateCode();return this}};if((je(de.tytxSuffix).GramlotBuilderBag??de)!==de)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Wt(de.tytxSuffix,{...je(de.tytxSuffix),GramlotBuilderBag:de});var Tg=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"]),Zn=class extends tr{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);Wr(e,r);let[i,s]=super._handleMeta(e,r);return Hr(e,s),e._getMeta("subbuilder")?[i,ds(bs(s))]:[i,s]}adaptAttrs(e){let{_meta:t,...r}=e;return Gn(super.adaptAttrs(Gr($t(r))))}renderedItem(e,t,r,i={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,i);let{_text:s,...o}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&s!=null&&(t=[this._escapeText(zr(s)),...t]),Tg.has(i.tag)?`${i.pretty?" ".repeat(this._nodeDepth(e,i.depthOffset??0)):""}<${i.tag}${this._formatAttrs(o)} />${i.pretty?`
|
|
187
|
+
`:""}`:super.renderedItem(e,t,o,i)}};var sr=class extends er{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof Nt?this.addRender(e,this):e instanceof It&&this.addRender(e,new Zn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,i]=e.rootBuilder.runtimeValues(e),s=this.getRender(e.builder),[o,a]=s._handleMeta(e,i);return e._getMeta("subbuilder")||(a=s.adaptAttrs(a)),s.renderedItem(e,e.value instanceof A?this.renderChildren(e.value,t):r,a,{tag:o,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,i=this.evaluateExpressions(e,t);Wr(e,i,r);let[s,o]=super._handleMeta(e,Ac(e,i,r));if(Hr(e,o,r),e.nodeTag==="webcomponent"){s=dt(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=bs(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Rt),[s,u]}let[a,l]=Tc(s,o);return Object.keys(l).length&&this.#e.set(e,l),[s,a]}evaluateExpressions(e,t){let r=this.inlineCompiler,i=(o,a)=>r?r.compileExpression(e,o,a)(t):null,s={...t};for(let[o,a]of _e(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o)||Fe(a)&&Object.hasOwn(s,o)&&(s[o]=i(o,a));return Fe(e.value)&&this.#t.set(e,i("",e.value)),s}expressionValue(e,t){return Fe(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...Gr(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,i=`${this.builder.constructor._name}_`,s=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries($t(r))){if(u==null)continue;if(l.startsWith(i))throw new Error(`${l}: the attribute prefix '${i}' is not accepted; use the prefix '${s[0]}'`);let c=s.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Gn({...super.adaptAttrs(a),...o})}renderedItem(e,t,r,i={}){let s;[t,s]=Xn(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:o,...a}=s;Array.isArray(t)&&o!=null&&(t=[this._escapeText(zr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:we,...a}:a;return super.renderedItem(e,t,l,i)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let i=this._composeStringFragments(e),s=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return s.length===1&&s[0].nodeTag==="html"||(i=`<html>${i}</html>`),super.finalize(`<!doctype html>${i}`,t,r)}};var Nc={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:{dataBinder:{doc:"Bidirectional subscription between a client Data branch and its page's server store.",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:"server_path",kind:"positional_or_keyword",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:{data_element:!0}},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"}},html_dialog:{doc:"Native HTML dialog, distinct from the layout window component.",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:{render_tag:"dialog"}}}};var Ic={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}}};var Sg="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Ng=new Set,Ig=new Set(["serverpath","dbenv","shared_id"]),Og=["formsubscribe_"],Bg={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Rg={dataFormula:"formula",dataController:"script"};function Oc(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&H(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(i=>["action","ask","_delay","fire"].includes(i)||i.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(n))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(n))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(n)&&Object.keys(e).some(i=>i.startsWith("subscribe_")||i.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=Bg[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=Rg[n];return r&&e[r]!=null&&e.func!=null?`'func' and '${r}' cannot be declared on the same node`:r&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function Bc(n){return Object.keys(n).find(e=>Ig.has(e)||Og.some(t=>e.startsWith(t)))}var Oe=class n extends Nt{static _name="gramlot";static _sourceClass=de;static{this.defineGrammar(Nc)}static{this.defineGrammar(Ic)}static{this.defineGrammar(ws.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(n);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:r=null,nameSyntax:i=Wn}={}){if(!(i instanceof nr))throw new TypeError(`nameSyntax must be a NameSyntax, not ${i}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=i;for(let s of t)this.loadCollection(s)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,i,s){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,i.text)(s):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 Ot?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),r=n.dialectPrefixes;if(t.startsWith(`${n._name}_`))throw new Error(`${e}: the tag prefix '${n._name}_' is not accepted; use the prefix '${r[0]}'`);if(Ng.has(t))throw new Error(`${e}: excluded from Gramlot`);let i=this.schemaTagNames[t];if(i)return i;for(let s of r)if(t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)])return t;return null}bagCall(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.bagCall(e,t,r,i)}commandOnNode(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.commandOnNode(e,t,r,i)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new de(null,this),r];if(e==="menuline"&&t!=null&&t!=="-"){if(Object.hasOwn(r,"command"))throw new TypeError("menuline command must be declared once");return[null,{...r,command:t}]}return[t,r]}validateNodeValues(e,t,r={}){if(this.schema[e]?._meta?.gramlot_component&&H(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&dt(r);let i=Bc(r);if(i)throw new Error(`${e}: attribute '${i}' is excluded from Gramlot`);let s=Oc(e,r);if(s)throw new Error(`${e}: ${s}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&H((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&dt(t.attrs??e.getAttr());let r=Bc(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let i=Oc(e.nodeTag,t.attrs??e.getAttr());if(i)throw new Error(`${e.nodeTag} '${e.label}': ${i}`);return super.validateNode(e,t)}_validateChildren(e,t,r,i){return super._validateChildren(e,t,r.map(s=>s==="html_button"?"button":s==="html_dialog"?"dialog":s),i)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,i,s=null){i=Object.fromEntries(Object.entries(i??{}).map(([l,u])=>[l,K(u)instanceof Ae?this.reference(u):u]));let a=t==="dataSetter"&&i?.value!==null&&typeof i?.value=="object"&&Object.getPrototypeOf(i.value)===Object.prototype?{...i,value:new x(i.value)}:i;return super.setChild(e,t,r,a,s)}#e(e){if(e==="data")throw new Error(Sg);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=n.dialectPrefixes.find(r=>e.startsWith(r));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new sr(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let i=t!=null?{_text:t}:null;e.setValue(r,!0,i,!0)}reference(e,t="node"){if(e=K(e),!(e instanceof Ae)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=Y(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return F(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function Jn(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function or(n,e,t,r){let{group:i,method:s}=n.logicRegistry.resolve(t,e);return s.call(i,e,r)}function nt(n,e,t,r,i,s=Object.keys(i)){return Jn(r)?or(n,e,r,i):n.inlineCompiler.compile(e,t,r,s)(i)}var $g=new Set(["input","select","textarea"]),Mg=["type","multiple"];function Rc(n,e){let t=n.node,r=t.getAttr(e);return t.pointerType(r)?t.getRelativeData(r):n.resolved[e]}var ye=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#i=!1;#s=!1;#o=!1;static for(e,t){let r=n.classFor(t.element,t.attrs);return r?new r(e,t):null}static classFor(e,t){if(e.namespaceURI!==we)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?ma:da;if(e.localName==="textarea")return it;if(e.localName==="select")return Kn;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn($c,r)?$c[r]:it}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([]):e?.namespaceURI!==we||!$g.has(e.localName)?null:JSON.stringify(Mg.filter(r=>(r!=="type"||e.localName!=="input")&&(r!=="multiple"||!["input","select"].includes(e.localName))).map(r=>t[r]??null))}constructor(e,t){this.#r=e,this.#n=t}get binding(){return this.#r}get element(){return this.#n.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#n.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#s){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)&&(!this.#i||this.same(this.read(),e))||(this.#e=e,this.#t=!0,!(this.#i&&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.#n.text.data!==t&&(this.#n.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.#i=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#i=!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.#s=!0;return}if(e.type==="compositionend"){this.#s=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#s||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},da=class extends ye{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Mc(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||Pc(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}))}}},it=class extends ye{static liveWrites=!0},fa=class extends ye{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},ha=class extends ye{static liveWrites=!0;read(){return Number(this.element.value)}},Kn=class extends ye{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 r=new Set((e??[]).map(String));for(let i of t.options){let s=r.has(i.value);i.selected!==s&&(i.selected=s)}}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((r,i)=>Object.is(r,e[i])):super.same(e,t)}},ar=class extends ye{read(){return this.element.value===""?null:this.element.value}},pa=class extends ye{},ys=class extends ye{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()}},Xr=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,r=ga(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,r)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(e=this.resolved.group){let t=this.resolved.group??null,r=ga(this.node);if(!Object.is(e??null,t)){let i=new Set([this,...this.groups.peers(this),...t===null?[]:this.groups.peersOf(t,r)]);this.groups.leave(this),this.#e=t===null?null:this.groups.join(this,t,r),this.#e===null?this.element.removeAttribute("name"):this.element.setAttribute("name",this.#e);for(let s of i){if(this.binding.closed||!this.binding.runtime.renderer.attached(this.node))return;s.binding.closed||!s.binding.runtime.renderer.attached(s.node)||s.binding.runtime.renderer.html.writeParameter(s.node,"value",!1)}return}this.#e!==null&&this.groups.nameOf(t,r)!==this.#e&&(this.#r(t,r),this.groups.leave(this),this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}#r(e,t){let r=this.node;if(Rc(this,"value")&&this.groups.peersOf(e,t).some(i=>!i.binding.closed&&i.read()))throw new Error(`${r.nodeTag} '${r.label}': several true values in radio group '${e}'`)}project(e,t){let r=!this.#t;this.#t=!0;let i=this.read();super.project(e,t),!r&&!i&&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),Rc(e,"value")&&e.commit(null))}}},ma=class extends Xr{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||Pc(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Mc(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,ga(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let i=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,s=t[(r+i+t.length)%t.length];s.element.focus(),s.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}))}}}},vs=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#i=0;constructor(e){this.#e=e}join(e,t,r){let i=this.nameOf(t,r);return this.#t.has(i)||this.#t.set(i,new Set),this.#t.get(i).add(e),this.#r.set(e,i),i}leave(e){let t=this.#r.get(e);this.#r.delete(e);let r=this.#t.get(t);r?.delete(e),r?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(r=>r!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#n.has(t)&&this.#n.set(t,this.#i++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function ga(n){for(let e=n;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var $c={text:it,password:it,email:it,url:it,tel:it,search:it,number:fa,range:ha,color:pa,date:ar,time:ar,month:ar,week:ar,"datetime-local":ar,checkbox:ys,radio:Xr,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Mc(n){let{binding:e,node:t}=n,r=e.runtime.gramlot,i=(s,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,s,o,Object.keys(a),`return (${o});`)(a):nt(e.runtime,t,s,o,a);return{locale:r.locale,timeZone:r.timeZone,createDecimal:Tt,isDecimal:be,getDecimalLibrary:Xo,publish:(s,o)=>t.publish(s,o),isActive:()=>!e.closed,reportError:(s,o)=>{e.closed||e.runtime.reportError(s,o)},callLogic:(s,o)=>or(e.runtime,t,s,o),format:(s,o)=>r.format(s,o),invoke:i,remote:(s,o,a)=>r.rpc.call("data",s,o,{signal:a}),selectionOutputs:({selectedCaption:s,selectedRecord:o,fields:a},l)=>{if(!e.closed){s&&t.setRelativeData(s,l?.caption??null),o&&t.setRelativeData(o,l?new x(l.record):null);for(let[u,c]of Object.entries(a))t.setRelativeData(c,l?.record[u.slice(9)]??null)}},validationCurrent:()=>{let s=t.getAttr("value"),o=t.pointerType(s)?t.absDatapath(s):null;return()=>!e.closed&&t.getAttr("value")===s&&(o===null||t.absDatapath(s)===o)},finishValidation:({ok:s,result:o,rules:a})=>{if(e.closed)return;if(s)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=s?"validate_onAccept":"validate_onReject";if(a[l]){let u=c=>{e.closed||e.runtime.reportError(c,"Validation callback failed")};try{let c=Object.fromEntries(Object.entries(a).map(([f,h])=>[f.slice(9),h])),d=i(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:s=>{if(!(s instanceof x))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof x))throw new TypeError("Validation data changes require a Bag datapath.")}}}function Pc(n,e,t){let r=n.pageContext,i=s=>{s.ok&&s.isCurrent()&&(t(s),n.finishValidation(s))};if(e instanceof Promise)e.then(i).catch(s=>r.reportError(s,"Field update failed"));else try{i(e)}catch(s){r.reportError(s,"Field update failed")}}var ba=Symbol("source text"),Lc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Pg=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"]),Lg=new Set(["checked","muted","selected","value"]),jg=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Fg(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return jg.get(e.toLowerCase())??e}var Es=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:r=null,reportError:i=null}={}){this.invokeScript=t,this.callLogic=r,this.reportError=i,this.metadataAttributes=new Set([...Xt,"_text",...e])}definition(e){let t=e.builder,i={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},s=e.nodeTag==="webcomponent"?dt(e.getAttr()):Ln(e.nodeTag,{renderTag:i.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=s==="foreignObject"?Rt:i.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof It?Rt:we);return{meta:i,namespace:o,tag:s}}validate(e,t=e.builder){this.validateLabelbox(e);let r=e.value instanceof A,i=r?e.getAttr("_text"):e.value;if(i!=null&&!["string","number","boolean"].includes(typeof i))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)&&!(e.nodeTag==="menuline"&&a==="parameters")&&!(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 s=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=r?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:i,attrs:s,childTags:o})}hasLabelbox(e){let t=this.definition(e).meta.gramlot_component;return t?.labelbox?!0:t?.presentationDefaults.length?Object.hasOwn(e.attr,"lbl"):Object.keys(e.attr).some(r=>r==="lbl"||r.startsWith("lbl_")||r.startsWith("box_"))}validateLabelbox(e){if(!this.hasLabelbox(e))return;let{tag:t,namespace:r}=this.definition(e);if(r!==we&&t!=="svg"||["html","head","body","style","script","link","meta","title","base","tr","td","th","thead","tbody","tfoot","col","colgroup","caption","option","optgroup","li","dt","dd","source","track","param","area"].includes(t))throw new TypeError("Labelbox requires content that can be placed in an HTML flow container");let i=e.parentNode;if(i?.nodeTag){let s=this.definition(i);if(s.namespace!==we&&s.tag!=="foreignObject"||["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","ul","ol","dl","p","button","label"].includes(s.tag))throw new TypeError("Labelbox requires an HTML flow container")}}create(e,t,r=null,i=e.attr,s=null){let{tag:o,namespace:a,meta:l}=this.definition(e);r??=o;let u=a===we?t.createElement(r):t.createElementNS(a,r);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==r)throw new Error(`Component collection must be activated before rendering ${r}`);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({reportError:(f,h)=>this.reportError(e,f,h),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!==we||!l.void)&&u.append(c);let d={element:u,text:c,tag:r,presentation:u};if(this.hasLabelbox(e)){this.validateLabelbox(e);let f=t.createElement("div");f.append(u),d.labelbox=bc(t,f),d.presentation=d.labelbox.box,d.labelId=`gramlot-label-${Y()}`,d.controlId=`gramlot-control-${Y()}`;let h=t.createElement("style");h.textContent=gc,d.presentation.prepend(h),l.gramlot_component?.labelbox&&u.setLabelbox(d.labelbox)}return this.update(d,e,i,ba,s),d}matches(e,t){let{tag:r,namespace:i}=this.definition(t);return(i===we?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===i}writeParameter(e,t,r){let i=e.getAttr(t);e.pointerType(i)==="^"&&!H(i)&&!Object.is(e.getRelativeData(i.slice(1)),r)&&e.setRelativeData(i.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let i of r)e.element.append(i)}update(e,t,r=t.attr,i=ba,s=null){if(t.nodeTag==="script"){for(let[b,g]of t.codeAttributes())if(t.activatedCode(b)!==g)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:o,text:a}=e;if(this.hasLabelbox(t)&&!e.labelbox)throw new TypeError("Declare lbl or box_* when creating an experimental HTML labelbox");let l=o.namespaceURI===we,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=b=>(Wr(t,b,t.builder.constructor.dialectPrefixes),Hr(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(r=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(e.presentation,r,{label:t.label,adapt:d,invoke:(g,_,w)=>this.invokeScript(t,g,_,w),reportError:(g,_)=>this.reportError(t,g,_),publish:(g,_)=>t.publish(g,_),publishParent:(g,_)=>f.publish(g,_),writeParameter:(g,_)=>this.writeParameter(t,g,_),remove:()=>t.parentBag.popNode(t.label)})),e.labelbox&&(e.labelbox.box.style.visibility="",_c(e.labelbox,r,d)),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&o.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),r=o.projectAttributes(r,d)),e.labelbox&&(r=Object.fromEntries(Object.entries(r).filter(([b])=>b!=="lbl"&&!b.startsWith("lbl_")&&!b.startsWith("box_"))),r.slot!=null?e.presentation.setAttribute("slot",r.slot):e.presentationSlot!=null&&e.presentation.removeAttribute("slot"),e.presentationSlot=r.slot,delete r.slot),r=Object.fromEntries(_e({...r,...u}));let h=ye.classFor(o,r)!==null;i===ba&&(i=this.text(t));let m=i==null?"":String(i);a.data!==m&&(a.data=m);let p=[...new Set([...Object.keys(c),...Object.keys(r)])];p.sort((b,g)=>(g==="sandbox")-(b==="sandbox")||(l&&o.localName==="input"?(g==="type")-(b==="type"):0));for(let b of p){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||h&&b==="value")continue;let g=r[b];if(l&&b==="multiple"&&["input","select"].includes(o.localName)){o.multiple!==!!g&&(o.multiple=!!g);continue}if(l&&o.localName==="input"&&b==="type"){Object.is(c.type,g)||(g==null?o.removeAttribute("type"):o.type=String(g));continue}let _=b,w=Fg(_),E=l&&Pg.has(w)&&typeof o[w]=="boolean",D=_==="xmlns"?"xmlns":_.includes(":")?_.split(":")[0]:"",y=Object.hasOwn(Lc,D)?Lc[D]:null;if(Object.is(c[b],g)||(g==null||E&&!g?y?o.removeAttributeNS(y,_.split(":").at(-1)):o.removeAttribute(_):y?o.setAttributeNS(y,_,String(g)):o.setAttribute(_,E?"":String(g))),l&&(E||Lg.has(w))&&w in o){let T=w==="value"?g==null?"":String(g):!!g;o[w]!==T&&(o[w]=T)}}if(s===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(r.style==null?o.removeAttribute("style"):o.setAttribute("style",String(r.style))),e.visible=s,e.labelbox){let{fieldLabel:b,labelBox:g,box:_}=e.labelbox;["input","textarea","select","button","output","meter","progress"].includes(e.tag)?(o.id||(o.id=e.controlId),b.htmlFor=o.id):(b.id=e.labelId,this.definition(t).meta.gramlot_component?.labelbox||(_.setAttribute("role","group"),g.hidden?_.removeAttribute("aria-labelledby"):_.setAttribute("aria-labelledby",b.id))),_.hidden=!!r.hidden,s===!1&&(_.style.visibility="hidden")}e.attrs=r}text(e){return e.value instanceof A?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};function qg(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function jc(n){if(!n||!(n.value instanceof A))return null;let e=n.value.getNodes().find(i=>i.getAttr("region")==="center"),t=[];function r(i){if(i.nodeTag!=="framePane"&&(i.getAttr("frameTarget")===!0&&t.push(i),i.value instanceof A))for(let s of i.value.getNodes())r(s)}return e&&r(e),t.length===1?t[0]:null}function Ug(n){if(n.closed||!n.runtime.renderer.attached(n.node))return!1;for(let e=n.node;e;e=e.parentNode){let[,t]=e.rootBuilder.runtimeValues(e);if(t.hidden===!0||t.disabled===!0)return!1}return!0}function Fc(n){if(n&&typeof n=="object"){for(let e of Object.values(n))Fc(e);Object.freeze(n)}return n}function qc(n,e){let t=n.node,r=t.getAttr("command"),i=n.runtime.gramlot.commands.get(r),s=qg(t),o=jc(s);if(!i||!o)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let a=t.getAttr("parameters")??{};if(typeof a!="object"||Array.isArray(a))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(a).map(([p,b])=>[p,t.pointerType(b)?t.getRelativeData(b):b])),u=Fc(j(F(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(p=>[p,!!e[`${p}Key`]]))),d=Object.freeze({sender:t,target:o,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(o).track(()=>{f=!0}),m=()=>!f&&Ug(n)&&jc(s)===o&&n.runtime.renderer.attached(o)&&t.getAttr("command")===r;return{message:d,current:m,release:h,cancel(){f=!0},deliver(){m()&&o.publish(i.publish,d)}}}var xs=class n{#e;#t;#r=null;#n=0;#i=new Set;#s=null;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new n(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 r=e.getAttr()??{},i=[];if(t.length&&i.push("controller"),r.action!=null&&i.push("action"),e.nodeTag==="menuline"&&r.command!=null&&i.push("registered"),Uc(r).length&&i.push("fire"),e.nodeTag==="menuline"&&e.value instanceof A&&e.value.getNodes().some(s=>s.nodeTag==="menu")&&i.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&i.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(i.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${i.join(" and ")} together; a button has one click mechanism`);return i[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){if(this.node.nodeTag==="menuline"){let t=this.node.getAttr("command"),r=t?this.binding.runtime.gramlot.commands.get(t):null;this.element.setCommandDefinition(r,this.node.label),t&&!r&&this.#s!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#s=t)}for(let t of this.#i)t.current()||t.cancel();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?.();for(let e of this.#i)e.cancel(),e.release();this.#i.clear()}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))return;let r=this.mechanism;if(!r||(e.stopPropagation(),this.element.disabled))return;let i=r==="registered"?qc(this.binding,e):null;if(r==="registered"&&!i)return;i&&this.#i.add(i);let s=this.binding.countClick(),o=this.node;for(;o&&o.getAttr("_delay")==null;)o=o.parentNode;let a=o?o.rootBuilder.runtimeValues(o)[1]._delay:0;if(a>0){let l=this.#n+1;this.#r?.(),this.#n=l;let u=setTimeout(()=>{c(),this.#r=null,this.#n=0,this.#a(e,l,i)},a),c=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(u),i&&(i.cancel(),i.release(),this.#i.delete(i)),c(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#a(e,s,i)}async#o(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,i={...e.message.parameters};if(t&&r.required(this.binding,t,i,"ask")&&await r.show(this.binding,t,i)===null)return;e.deliver()}finally{e.release(),this.#i.delete(e)}}#a(e,t,r=null){if(r)return this.#o(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let s=this.node,o=Vg(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(i==="action"){let a=()=>{let[,d]=s.rootBuilder.runtimeValues(s),f=Object.fromEntries(Object.entries(d).filter(([h])=>h!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(f),event:e,_counter:t,modifiers:o}},l=d=>{if(this.binding.closed||this.element.disabled||d===null)return;let f={...a(),...d};d&&(f._askResult=d),nt(this.binding.runtime,s,"action",s.getAttr("action"),f)},u=s.getAttr("ask"),c=this.binding.runtime.askDialog;if(u&&c.required(this.binding,u,a(),"ask"))return c.show(this.binding,u,a()).then(l);l(void 0)}else{let a={modifier:o,_counter:t},l=s.getAttr("fire");if(l!=null){s.FIRE(l,o||!0,a);return}for(let[u,c]of Uc(s.getAttr())){if(this.binding.closed)return;s.FIRE(c,u.slice(5),a)}}}};function Uc(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function Vg(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var Ge=class extends Q{static classKwargs={...Q.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(r=>this.#t(r));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(r=>{r?.name!=="AbortError"&&this.onError(r)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,r]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=r);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let i=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(i,this.cacheTime!==0):this.cachedValue=i}finally{this.writing=!1}return i}};var Yr=class extends Ge{static internalParams=new Set([...Ge.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:i,onCalling:s=null,onError:o,sync:a=!1}){super({cacheTime:i,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=r,this.onCalling=s}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 Vc=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function zc(n,e=new Set){if(!(n instanceof x)||e.has(n))throw new TypeError("Menu resolver must return an acyclic Bag");let t=new Set([...e,n]);return n.getNodes().map(r=>{let i=r.attr,s=i.kind,o=r.staticValue;if(Object.keys(i).some(l=>!Vc.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(s))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(i[l]!=null&&typeof i[l]!="boolean"&&!(typeof i[l]=="string"&&i[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(i.favorite!=null&&typeof i.favorite!="boolean")throw new TypeError("favorite must be boolean");if(i.caption!=null&&typeof i.caption!="string")throw new TypeError("Menu caption must be text");if(i.parameters!=null&&(typeof i.parameters!="object"||Array.isArray(i.parameters)))throw new TypeError("Menu parameters must be a mapping");if(s==="command"&&(typeof i.command!="string"||!i.command||o!=null||i.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(s==="separator"&&(o!=null||Object.keys(i).length!==1))throw new TypeError("Separator record accepts kind only");if(s==="submenu"&&(typeof i.caption!="string"||i.command!=null||o instanceof x==(i.resolver!=null)||!(o instanceof x)&&o!=null))throw new TypeError("Submenu requires caption and exactly one content source");let a=o instanceof x?zc(o,t):null;return{label:r.label,attrs:{...i},children:a}})}function Hc(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof A?n.value.getNodes():[],i=new Set(e.map(s=>s.label));for(let s of r)i.has(s.label)||n.value.popNode(s.label);for(let[s,o]of e.entries()){let{kind:a,...l}=o.attrs,u=Object.fromEntries(Object.entries(l).filter(([m])=>m==="resolver"||m==="cacheTime"||m==="sync"||m.startsWith("resolver_")));for(let m of Object.keys(u))delete l[m];let c=a==="separator"?"-":null,d=n.value instanceof A?n.value.getNodes().find(m=>m.label===o.label):null,f=d?.value instanceof A;if(d&&(f!==(a==="submenu")||d.value==="-"!=(a==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=K(t.menuline(c,{...l,node_label:o.label}));else{let m=Object.keys(d.attr).filter(p=>Vc.has(p)&&!Object.hasOwn(l,p));d.setAttr({...Object.fromEntries(m.map(p=>[p,null])),...l})}if(a==="submenu"){let m=d.value instanceof A?d.value.getNodes().find(p=>p.nodeTag==="menu"):null;m?m.setAttr({...Object.fromEntries(Object.keys(m.attr).filter(p=>p==="resolver"||p==="cacheTime"||p==="sync"||p.startsWith("resolver_")).map(p=>[p,null])),...u}):m=K(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),o.children&&Hc(m,o.children)}let h=n.value.getNodes().indexOf(d);h!==s&&n.value.move(h,s)}}var ks=class{#e=null;#t=null;#r=0;#n=!1;#i=null;constructor(e,t){this.binding=e,this.element=t}get node(){return this.binding.node}attach(){this.element.menuBinding=this,this.refresh()}detach(){this.#n=!0,this.#r++,this.node.requests.inflight?.cancel(),delete this.element.menuBinding,this.element.close(!1)}refresh(){let[,e]=this.node.rootBuilder.runtimeValues(this.node),t=Object.fromEntries(Object.entries(e).filter(([i])=>i.startsWith("resolver_")).map(([i,s])=>[i.slice(9),s])),r=F([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#i=null,this.#t=e.resolver?new Yr({binding:this.binding,method:e.resolver,params:t,cacheTime:e.cacheTime??-1,sync:e.sync??!1,onError:()=>{}}):null,this.#t?(this.element.setStatus("loading"),this.element.opened&&this.element.isConnected&&this.load()):this.element.setStatus(null))}async load(e=!1){if(this.#n||!this.#t)return;let t=this.#t,r=this.#r;try{if(e?t.refresh():t.resolve(),t.loading&&(this.element.setStatus("loading"),await t.loading),this.#n||r!==this.#r)return;let i=t.cachedValue,s=zc(i),o=F(i);this.#i!==o&&(Hc(this.node,s),this.#i=o),this.element.setStatus(s.length?null:"empty")}catch(i){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,i)}}};var As="connect_on",Qn=class{#e;#t;#r;#n;#i;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(As)&&t.length>As.length&&r!=null).map(([t,r])=>[t,t.slice(As.length).toLowerCase(),r])}constructor(e,t,r,i,s=`${As}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s}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.#n}get attribute(){return this.#i}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,r=this.binding.runtime;if(Jn(this.handler))return or(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};var Ts=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;#n;#i;#s=!0;#o;constructor(e,{path:t,attr:r,recipient:i,order:s,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#o}get active(){return this.#s}get order(){return this.#i}close(){this.active&&(this.#s=!1,this.router.unregister(this))}},wa=class{constructor({evt:e,node:t,path:r,oldvalue:i,attrsDiff:s,reason:o,fired:a,level:l,registration:u,index:c}){this.evt=e,this.node=t,this.path=r,this.oldvalue=i,this.attrsDiff=s,this.reason=o,this.fired=a,this.level=l,this.registration=u,this.index=c}},Ds=class{#e;#t=new Ts;#r=new Map;#n=0;#i=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#n}register({path:e,attr:t=null,recipient:r,subtree:i=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let s=this.#t;for(let a of e.split(".")){let l=s.children.get(a);l||(l=new Ts(s,a),s.children.set(a,l)),s=l}this.#i+=1;let o=new _a(this,{path:e,attr:t,recipient:r,order:this.#i,subtree:i});return s.registrations.add(o),this.#r.set(o,s),this.#n+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#n-=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]!==Un||e.reason==="autocreate")return;let r=t.slice(1),i=e.evt==="ins"||e.evt==="del";for(let s of Array.isArray(e.node)?e.node:[e.node]){let o=i?[...r,s.label]:r,a=o.join(".");for(let[l,u]of this.#s(o,e))l.active&&l.recipient.receive(new wa({evt:e.evt,node:s,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l,index:e.ind??null}))}}#s(e,t){let r=[],i=this.#t;for(let o of e){for(let a of i.registrations)i!==this.#t&&this.#o(a,"child",t)&&r.push([a,"child"]);if(i=i.children.get(o),!i)return r.sort(([a],[l])=>a.order-l.order)}for(let o of i.registrations)this.#o(o,"node",t)&&r.push([o,"node"]);let s=[...i.children.values()];for(;s.length;){let o=s.pop();for(let a of o.registrations)this.#o(a,"container",t)&&r.push([a,"container"]);s.push(...o.children.values())}return r.sort(([o],[a])=>o.order-a.order)}#o(e,t,r){let{evt:i}=r;return e.subtree?t!=="container"||i!=="upd_attrs":e.attr===null?i==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?i!=="upd_attrs":i==="ins"||i==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var Cs=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=ei(e),r=this.setterNodes(e);va(e);for(let i of r)this.applySetter(i),this.runtime.closeBranch(i),i.parentBag&&i.parentBag.popNode(i.label);this.applyDefaults(t.filter(i=>i.nodeTag&&!i._getMeta("data_element")))}setterNodes(e){return ei(e).filter(t=>t.nodeTag==="dataSetter")}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let r=e.getAttr("value")??null,i=Hg(e.getAttr()),s=this.runtime.data;if(r!==null)s.setItem(t,r,i,">",!1,!0,e),r instanceof x&&e.setAttr({value:null},!1);else{let o=s.getNode(t);o?i&&o.setAttr(i,!0):s.setItem(t,null,i,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[i,s]of Object.entries(r)){if(!zg(t,i,s))continue;let o=i==="value"?r.default_value??r.default:r[`default_${i}`];o!=null&&this.#t(t,s,o)}this.#r(t,r)}}#t(e,t,r){let i=e.absDatapath(t);if(i===null)return;let[s,o=null]=i.split("?",2),a=this.runtime.data,l=a.getNode(s);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(s,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:r},!0)}else a.setItem(s,null,{[o]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(r[o.slice(5)]=H(a)?Mt(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(r).length)return;let i=[t.value,t.src].find(o=>e.pointerType(o));if(!i)return;let s=e.absDatapath(i);s!==null&&this.runtime.data.getNode(s.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function zg(n,e,t){return e==="_meta"||Xt.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function Hg(n){let e={};for(let[t,r]of Object.entries($t(n??{})))Xt.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function Wg(n){let e=n.builder;if(!(e instanceof Oe))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function va(n){for(let e of ei(n))e.nodeTag==="dataSetter"&&Wg(e),Jg(e)}var Gg=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Xg=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Yg=["_onCalling","_onResult","_onError"],Zg=["_delay","_timing","_userChanges"],ya=["_init","_onBuilt","_onStart"];function Jg(n){let e=s=>n.getAttr(s)!==null&&n.getAttr(s)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let s=Yg.find(o=>e(o)&&!(o==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(s){let o=s==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${s}' is allowed only on ${o}`)}}if(Xg.has(n.nodeTag)){let s=Object.entries(n.getAttr()).find(([,a])=>Fe(a));if(s)throw new Error(`${n.nodeTag} '${n.label}': '${s[0]}' is a == expression, not accepted on ${n.nodeTag}`);let o=n.nodeTag==="dataRemote"?ya.find(e):null;if(o)throw new Error(`dataRemote '${n.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of ya){let l=n.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Gg.find(s=>e(s)&&!(s==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&Zg.includes(s)));if(!r)return;let i=ya.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${i}`)}function ei(n){if(n instanceof A)return n.getNodes().flatMap(t=>ei(t));let e=[n];return n.value instanceof A&&e.push(...ei(n.value)),e}var Kg=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"]),ti=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,i=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(i)),this.#r=()=>{clearTimeout(i),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),i=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),i(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},Zr=class{#e;#t=[];#r=new Set;#n;#i=null;#s=!1;constructor(e){this.#e=e,this.#n=new ti(e),e.track(()=>{this.cancel(),this.#p(),this.#f()})}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.#p();let r=this.binding.runtime.router,i=tt(e,e.getAttr("_timing"));for(let[s,o]of e.pointers()){if(s==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(s==="_timing"||i.has(s))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(s,o,a)=>(l,u)=>{let c={kind:"subscription",topic:a,payload:l,metadata:u};if(this.#a("_userChanges")&&a!=="node")return;let d=this.#a("_delay");d>0?this.#n.debounce(d,()=>this.invoke(c)):this.invoke(c)})),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},r=this.#a("_delay");r>0?this.#n.debounce(r,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,r=this.kind==="formula",i=this.kind==="rpc",s=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(m=>{if(!this.binding.closed){if(m===null){let p=t.getAttr("_ask_onCancel");p&&this.#l("_ask_onCancel",p,p,o,!0);return}return this.invoke({...e,askDone:!0,askResult:m})}});let[u,c]=[r?"formula":"script",t.getAttr(r?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(s&&this.#f(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(i||s){this.#l(u,c,c,o,!0);return}}if(i)return this.#c(o);if(s)return this.#d(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,o,!0);else if(f==null){if(!r)return;h=new x(Ss(o))}else{let{group:m,method:p}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?p.call(m,o):p.call(m,t,o)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),i=Object.fromEntries(Object.entries(r).filter(([l])=>!Kg.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(i)};e.kind==="subscription"&&(s._subscription_kwargs=e.payload,s._subscription_metadata=e.metadata);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return s._node=o?o.node:null,s._triggerpars={kw:o,trigger_reason:a},s._reason=a,e.kind==="click"&&Object.assign(s,Qg(e)),s}cancel(){this.#n.cancel()}#o(){this.#n.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,r=t.getAttr(e);return H(r)?Mt(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,i,s){let o=[...s?["_kwargs"]:[],...Wc,...Gc,...Object.keys(Ss(i))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?nt(this.binding.runtime,this.node,e,t,{...i,_kwargs:i},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,r)({...i,_kwargs:i})}async#c(e){let t=this.node,[r,i,s]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return o.submit(this.#a("method"),Ss(e),a=>this.#u(a,e,i,s))}async#u(e,t,r,i){if(this.binding.closed)return;let s=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${s.nodeTag} '${s.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(!i)throw l.error;this.#l("_onError",i,i,{...t,error:l.error},!0);return}let{result:u}=l;s.getAttr("result_path")!=null&&s.setRelativeData(s.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#f();let t=this.#s;this.#s=!1;let r=this.node,i=r.absDatapath(r.pathAttribute("destination_path"));if(i===null)return;let s=r.getAttr("_onCalling"),o=new Yr({binding:this.binding,method:this.#a("method"),params:Ss(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:s?()=>this.#l("_onCalling",s,s,e,!0):null,onError:a=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(i,o),this.#i={path:i,resolver:o},t&&o.refresh()}#f(){if(!this.#i)return;let{path:e,resolver:t}=this.#i;this.#i=null,this.#s=t.loaded||t.loading!==null;let r=this.binding.runtime.data.getNode(e);r?.resolver===t&&(r.resolver=null)}#p(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},Ns=class extends Zr{get kind(){return"formula"}},Is=class extends Zr{get kind(){return"controller"}},Os=class extends Zr{get kind(){return"rpc"}},Bs=class extends Zr{get kind(){return"remote"}},Wc=["_node","_triggerpars","_reason","_subscription_kwargs","_subscription_metadata","_askResult"],Gc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function Ss(n){let e={...n};for(let t of[...Wc,...Gc])delete e[t];return e}function Qg({event:n,counter:e}){return{_evt:n,button_counter:e,button_shift:!!n.shiftKey,button_ctrl:!!n.ctrlKey,button_alt:!!n.altKey,button_meta:!!n.metaKey}}var eb=[[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 "]],tb=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,rb=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"]),Rs=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,r){let i=r.trim();if(tb.test(i))throw new Error(`${ri(e,t)}: the PUBLISH macro is excluded from Gramlot`);let s=i.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of eb)o&&(s=s.replace(o,`; ${o.source.slice(1)}`)),s=s.replace(a,l);return s!==i&&console.warn(`${ri(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`),s}compile(e,t,r,i,s=r){if(e.activatedCode(t)!==r)throw new Error(`${ri(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!==s&&(a={source:s,text:this.preprocess(e,t,s),key:null,run:null},o.set(t,a));let l=i.filter(nb),u=l.join(",");if(a.key!==u){let c=ib(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,r){let i=r.slice(2).trim(),s=_e(e.getAttr()).filter(([,a])=>!Fe(a)),o=this.compile(e,t,r,[...s.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${i}`);return a=>{let l={};for(let[u,c]of s)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,r,i){let s=this.compile(e,t,r,["_pointerValues","_F"],`return (${i}
|
|
188
|
+
)`);return o=>s({_pointerValues:o,_F:(a,l)=>this.runtime.gramlot.format(a,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let i of t){r.delete(i);for(let[s]of _e({[i]:null}))r.delete(s)}}};function nb(n){return/^[A-Za-z_$][\w$]*$/.test(n)&&!rb.has(n)}function ri(n,e){return`${n.nodeTag} '${n.label}' ${e?`'${e}'`:"node value"}`}function ib(n,e,t,r){try{return t.startsWith("function")?new Function(`return (${t}
|
|
189
189
|
)`)():new Function(...r,`${t}
|
|
190
|
-
`)}catch(i){throw i instanceof EvalError?new EvalError(`${
|
|
191
|
-
${t}`,{cause:i})}}var
|
|
190
|
+
`)}catch(i){throw i instanceof EvalError?new EvalError(`${ri(n,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:i}):new SyntaxError(`${ri(n,e)}: ${i.message} in the inline code:
|
|
191
|
+
${t}`,{cause:i})}}var $s=class{#e;#t;#r=!1;#n=null;#i=null;constructor(e){this.#e=e,this.#t=new ti(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.trigger())}receive(e){if(this.#o("_userChanges")&&e.level!=="node")return;let t=this.#o("_delay");t>0?this.#t.debounce(t,()=>this.trigger()):this.trigger()}trigger(){this.update().catch(e=>{this.closed||this.binding.runtime.reportError(e,"Content could not be loaded")})}async update(){if(this.closed||!this.binding.hasStamp("start"))return;let e=this.node,[,t]=e.rootBuilder.runtimeValues(e),r=t.remote,i={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(i[l.slice(7)]=u);let s=e.getAttr("_if");if(s&&!this.#a("_if",s,`return (${s})`,i)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,i);return}let o;try{let l=F(i);if(t._cachedRemote&&this.#s(r,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,i):null))return;o=await this.binding.runtime.gramlot.src.remoteSource(e,r,i)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${r}' failed: ${l.message}`,{cause:l})}let a=e.getAttr("_onRemote");!this.closed&&o&&a&&await this.#a("_onRemote",a,a,i)}fragmentMounted(e,t){this.#n=e,this.#i=t}#s(e,t){let r=this.node.requests.inflight;return r?r.method===e&&F(r.params)===t:e===this.#n&&t===this.#i}#o(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,r,i){return e==="_onRemote"?nt(this.binding.runtime,this.node,e,t,i):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(i),r)(i)}};var Jr="gramlot-page-store-remote",Ms=class{constructor(e){this.binding=e,this.registration=null,this.ready=!1}register(){let{runtime:e,node:t}=this.binding;if(this.connection=e.gramlot._pageStore,!this.connection)throw new Error("dataBinder requires a PageStore WebSocket");if(this.clientPath=t.absDatapath(t.pathAttribute("destination_path")),this.serverPath=t.getAttr("server_path"),typeof this.clientPath!="string"||!this.clientPath||this.clientPath.includes("?"))throw new TypeError("dataBinder requires a nonempty client Data path");if(typeof this.serverPath!="string"||!/^[^.?#\[\]!:]+(?:\.[^.?#\[\]!:]+)*$/.test(this.serverPath))throw new TypeError("dataBinder requires a literal server path");this.id=Y(),this.ready=!1,this.registration=e.router.register({path:this.clientPath,recipient:this,subtree:!0});try{this.connection.register(this)}catch(r){throw this.registration.close(),this.registration=null,r}}receive(e){if(!this.ready||e.reason===Jr)return;if(e.fired)throw new Error("Fired events are outside the first PageStore PoC");let{data:t}=this.binding.runtime,r=e.level==="container",i=r?t.getNode(this.clientPath):e.node;this.connection.send({op:"change",binderId:this.id,path:r||e.path===this.clientPath?"":e.path.slice(this.clientPath.length+1),evt:r?i?"upd_value":"del":e.evt,value:i?.value??null,attr:{...i?.attr},index:e.index,fired:!1})}apply(e){if(!this.registration?.active)return;let{data:t}=this.binding.runtime,r=e.path?this.clientPath+"."+e.path:this.clientPath;if(this.ready=!0,e.op==="snapshot")e.exists?t.setItem(this.clientPath,e.value,e.attr,">",!1,!1,Jr):t.popNode(this.clientPath,Jr);else if(e.op==="change")e.evt==="del"?t.popNode(r,Jr):e.evt==="upd_attrs"?t.getNode(r).setAttr(e.attr,Jr,!1,!1):t.setItem(r,e.value,e.attr,e.index??">",!1,!1,Jr);else throw new Error("Unknown PageStore delivery")}unregister(){this.ready=!1,this.registration?.close(),this.registration=null,this.connection?.unregister(this)}};var sb=new Set(["title","msg","fields","_if","askIf"]),ob=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),Ps=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,r,i){let s=(o,a)=>typeof a=="boolean"?a:e.runtime.inlineCompiler.compile(e.node,o,a,Object.keys(r),`return (${a});`)(r);if(typeof t=="string"){let o=e.node.getAttr("_ask_if");return!o||!!s("_ask_if",o)}return t?.askIf&&s(`${i}.askIf`,t.askIf),!t?._if||!!s(`${i}._if`,t._if)}show(e,t,r,i="Parameters"){let s=typeof t=="string"?{msg:t,title:i}:t;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(s))if(!sb.has(d))throw new Error(`Unsupported ask option: ${d}`);let o=s.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(!ob.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.#n(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${Y()}`,m=!1,p=()=>{},b=(g,_=null)=>{if(m)return;m=!0;let w=g?Object.fromEntries(o.map(E=>[E.name,l.data.getItem(`${h}.${E.name}`)])):null;c.delete(h),p();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),_?f(_):d(w)}catch(E){f(E)}};c.set(h,{finish:b}),p=e.track(()=>b(!1));try{let g=new Oe,_=g.root.html_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;"});_.h2(s.title??i,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),s.msg&&_.p(s.msg);let w=_.form({request:h,connect_onsubmit:`${u}.confirm`});for(let y of o){w.dataSetter({destination_path:`.${y.name}`,value:Object.hasOwn(r,y.name)?r[y.name]:y.default_value??(y.type==="checkbox"?!1:"")});let T=w.div({style:"margin:8px 0;"});T.html_label(y.lbl??y.name,{for:`${h}_${y.name}`,style:"display:block;margin-bottom:4px;"});let S={id:`${h}_${y.name}`,value:`^.${y.name}`,live:!0};for(let I of["required","min","max","step","placeholder"])y[I]!==void 0&&(S[I]=y[I]);y.tag==="textarea"?T.textarea(S):T.input({...S,type:y.type??"text"})}let E=w.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});E.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),E.html_button("Confirm",{type:"submit",autofocus:o.length===0}),l.src.source.setItem(h,l.src.prepareSource(g.source));let D=l.src.binding.nodeIds.get(h);l.dom.getDomNode(D).showModal()}catch(g){b(!1,g)}})}#n(){if(this.#t===null){let e=`ask_${Y()}`,t=this.#r;class r{confirm(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!0)}cancel(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(r,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var Ls=class{#e;#t=`errors_${Y()}`;#r=null;#n=new Map;#i=new Set;#s=0;constructor(e){this.#e=e}show(e,t){let r=new Set,i=[];for(let o=e;o!==null&&typeof o=="object"&&!r.has(o);o=o.cause){if(o.name==="AbortError")return;r.add(o),i.push(o.stack??o.message)}let s=typeof e?.message=="string"?e.message:String(e);queueMicrotask(()=>{this.#e.disposed||this.#o(s,t,i.join(`
|
|
192
192
|
Caused by:
|
|
193
|
-
`))})}#o(e,t,r){let i=this.#e.gramlot,s=JSON.stringify([t,e]);if(this.#i.has(s))return;let o=this.#e.nodeIds.get(this.#t);if(!o){if(this.#n.clear(),this.#s=0,this.#r===null){let m=this;class p{close(g){m.#a(g.getAttr("notice"))}}this.#r=`errors_${Q()}`,this.#e.logicRegistry.register(p,{group:this.#r,resource:"gramlot:error-notifications"})}let h=new Oe;h.root.aside({nodeId:this.#t,class:"gramlot-error-notifications",popover:"manual","aria-label":"Error notifications",style:"position:fixed;inset:auto max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) auto;margin:0;width:360px;max-width:calc(100vw - 24px);max-height:50vh;overflow:auto;box-sizing:border-box;padding:0;border:1px solid var(--gramlot-border-control,#aab4c2);border-radius:8px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#222);font:13px/1.4 system-ui;box-shadow:0 6px 24px #0003;"}),i.src.source.setItem(this.#t,i.src.prepareSource(h.source)),o=this.#e.nodeIds.get(this.#t)}if(this.#n.has(s))return;if(this.#n.size===5){let h=`${++this.#s} additional errors`,m=o.value.getNode("overflow");m?m.setValue(h):i.src.builder.wrapSource(o).p(h,{node_label:"overflow",role:"status",style:"margin:0;padding:12px;"});return}let a=`notice_${Q()}`,l=new Oe,u=l.root.article({role:"alert",style:"color:inherit;padding:12px;border-bottom:1px solid var(--gramlot-border,#ddd);"}),c=u.div({style:"display:flex;align-items:start;gap:12px;"});c.strong(`==${JSON.stringify(t)}`,{style:"flex:1;color:var(--gramlot-error,#b13d48);"}),c.html_button("\xD7",{type:"button",notice:a,connect_onclick:`${this.#r}.close`,"aria-label":"Dismiss notification",title:"Dismiss notification",style:"border:0;background:transparent;color:inherit;font:18px/1 system-ui;width:24px;height:24px;flex:0 0 24px;padding:0;cursor:pointer;"}),u.p(`==${JSON.stringify(e)}`,{style:"margin:6px 0;overflow-wrap:anywhere;"});let d=u.details({style:"border:0;padding:0;margin:8px 0 0;background:transparent;"});d.summary("Details",{style:"cursor:pointer;"}),d.pre(`==${JSON.stringify(r)}`,{style:"font:11px/1.4 monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0 0;padding:8px;border:0;border-radius:4px;background:var(--gramlot-surface-subtle,#f2f4f6);"});let f=i.src.builder.wrapSource(o).div({node_label:a});J(f).setValue(i.src.prepareSource(l.source)),this.#n.set(s,a),i.dom.getDomNode(o).showPopover()}#a(e){this.#e.nodeIds.get(this.#t).value.popNode(e);for(let[r,i]of this.#n)i===e&&(this.#n.delete(r),this.#i.add(r));this.#n.size||this.#e.gramlot.src.source.popNode(this.#t)}};var Vc={dataFormula:Ts,dataController:Ds,dataRpc:Cs,dataRemote:Ss},nb=["datapath","_anchor","nodeId","form","formId"],Zr=class{#e;#t=new Map;#r=new Map;#n;#i;#s;#o;#a;#l;#c=`gramlot-data-${Q()}`;#u=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#l=t,this.#n=new xs(this),this.#i=new ks(this),this.#s=new Ns(this),this.#o=new Os(this),this.#a=new Bs(this)}get gramlot(){return this.#e}reportError(e,t){this.disposed||this.#a.show(e,t)}get subscriptions(){return this.#l}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.#u}get router(){return this.#n}get installer(){return this.#i}get inlineCompiler(){return this.#s}get askDialog(){return this.#o}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#c,{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 _a(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof A)for(let i of e.value.getNodes())try{this.closeBranch(i)}catch(s){t.push(s)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let i=e.getAttr("nodeId");this.nodeIds.get(i)===e&&this.nodeIds.delete(i);try{r.close()}catch(s){t.push(s)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#g(e);for(let r of t)this.bindingFor(r)?.rebind();for(let r of t)this.renderer.project(r);for(let r of t)this.bindingFor(r)?.remote?.trigger()}handleSourceEvent(e){let{evt:t,node:r}=e,i=[],s=o=>{try{this.closeBranch(o)}catch(a){i.push(a)}};try{if(t==="ins")this.#d(r);else if(t==="del")for(let o of Array.isArray(r)?r:[r])s(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof A)for(let o of e.oldvalue.getNodes())s(o);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#h(r,e.attrs_diff):this.#m(r).rebind(),r.value instanceof A&&this.#d(r.value)}else if(t==="upd_attrs")this.#h(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw i.length?new AggregateError([...i,o],"Source event failed"):o}return i}branchBuilt(e){let t=[];for(let r of this.#g(e)){let i=this.bindingFor(r);!i||i.hasStamp("built")||!this.renderer.attached(r)||(i.stamp("built"),t.push(i))}for(let r of t)this.renderer.attached(r.node)&&this.#p(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#f(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#f(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#c,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(i){e.push(i)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#d(e){if(!(e instanceof A)&&this.bindingFor(e))return;let t=e instanceof A?e.getNodes().flatMap(s=>this.#g(s)):this.#g(e),r=new Set(t.filter(s=>this.bindingFor(s))),i=new Map;for(let s of t){let o=s.getAttr("nodeId");if(o!=null){if(i.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==s)throw new Error(`Duplicate nodeId '${o}'`);i.set(o,s)}}for(let[s,o]of i)this.nodeIds.set(s,o);try{for(let s of t)this.openBinding(s);this.installer.install(e);for(let s of t)this.renderer.attached(s)&&this.bindingFor(s).registerPointers()}catch(s){let o=[s];for(let a of t.filter(l=>!r.has(l)).reverse()){let l=a.getAttr("nodeId");i.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"):s}for(let s of t){let o=this.bindingFor(s);if(!(!o||o.hasStamp("init")||!this.renderer.attached(s))&&(o.stamp("init"),zc(s.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#f(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.trigger())}#p(e,t,r){let i=e.node.getAttr(r);if(zc(i))for(let s of e.providers){if(typeof i!="number"||i<=0){s.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),s.invoke({kind:t,change:null})},i);o=e.track(()=>clearTimeout(a))}}#h(e,t){let r=this.#m(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:i,new:s}=t.nodeId;if(s!=null&&this.nodeIds.has(s)&&this.nodeIds.get(s)!==e)throw new Error(`Duplicate nodeId '${s}'`);this.nodeIds.get(i)===e&&this.nodeIds.delete(i),s!=null&&this.nodeIds.set(s,e)}nb.some(i=>Object.hasOwn(t,i))?this.rebindBranch(e):r.rebind()}#m(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}#g(e){let t=[e];if(e.value instanceof A)for(let r of e.value.getNodes())t.push(...this.#g(r));return t}};function zc(n){return n===!0||typeof n=="number"}var _a=class{#e;#t;#r=!1;#n=[];#i=[];#s=new Set;#o=null;#a=null;#l=new Set;#c=new Set;#u=0;#d=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.#i]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#a}get clickCount(){return this.#u}countClick(){return++this.#u}hasStamp(e){return this.#s.has(e)}stamp(e){this.#s.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&&!Vc[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"?this.#a??=new Is(this):this.#a&&(this.#a.close(),this.#a=null);let r=new Set;if(e._getMeta("gramlot_component")?.bagStore){let s=e.getAttr("storepath");if(typeof s!="string"||!s||/^[\^=]/.test(s)||s.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(s);this.#i.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let i=this.remote?Ge(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[s,o]of Object.entries(e.getAttr()))if(s.startsWith("remote_"))for(let a of Ge(e,o))r.add(a)}for(let[s,o]of e.pointers()){if(t&&s!=="datapath")continue;let l=(s==="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.#i.push(d),s==="datapath"&&this.#d.add(d),this.remote&&(s==="remote"||s.startsWith("remote_")||r.has(s))&&this.#l.add(d),this.remote&&(s==="_timing"||i.has(s))&&this.#c.add(d)}if(!t){this.#f(),this.remote?.register();return}this.#o??=new Vc[e.nodeTag](this),this.#o.register()}#f(){let e=this.node;this.#i.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return i=>{if(this.closed)return;if(Gn(r))return sr(this.runtime,e,r,i);let[,s]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(s).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:i};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(a))(a)}}))}rebind(){this.#p(),this.registerPointers()}receive(e){if(this.#d.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#c.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.#n.push(e),()=>{let t=this.#n.indexOf(e);t!==-1&&this.#n.splice(t,1)}}async call(e,t){let{controller:r}=t,i=this.track(()=>r.abort());try{let s=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return s}finally{i()}}callSync(e,t,r){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,r))}close(){if(this.closed)return;this.#r=!0,this.#a?.close(),this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#p();let e=[];for(let t of this.#n.splice(0).reverse())try{t()}catch(r){e.push(r)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#p(){for(let e of this.#i.splice(0))e.close();this.#d.clear(),this.#l.clear(),this.#c.clear()}};var Rs=class{constructor(e){this.renderer=e}prepare(e,t){let r=this.renderer.records.get(e);if(!r||r.resolved.draggable!==!0)return null;let i=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(i===null)return null;let{dragValues:s,item:o,path:a}=i;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:s,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Mt(s),{dragValues:Object.fromEntries(Object.entries(s).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,j(U(c))]})),item:o,path:a}}};var Lt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,r])=>t.startsWith("dropTargetCb_")&&!!r)}static acceptedTypes(e,t="",r=[]){let i=t.split(",").map(s=>s.trim()).filter(Boolean).map(s=>{let o=s.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(s=>s!=="dragTags"&&(r.includes(s)||i.some(o=>o.test(s))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(i=>i.trim()).filter(Boolean));return r.size?t.split(",").some(i=>i.split(" AND ").every(s=>(s=s.trim(),!s||s==="!"?!1:s.startsWith("!")?!r.has(s.slice(1)):r.has(s)))):!1}static acceptsEffect(e="all",t="move"){let r={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(r,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return r[e].includes(t)}static evaluate(e,t,r,i,s=[]){let o=this.acceptedTypes(e,i.dropTypes,s),a=i.dropEffect??"move",l=this.isTarget(i)&&o.length>0&&this.acceptsTags(t,i.dropTags)&&this.acceptsEffect(r,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var Hc=["dragstart","dragover","dragleave","drop","dragend"],$s=class{#e;#t;#r=null;#n=null;#i=null;#s;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Hc)this.#t.addEventListener(t,this);this.#s=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#s)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#h():e.type==="dragover"?this.#d(e):e.type==="drop"&&this.#f(e)}#o(e,t){for(let r of e.composedPath()){let i=this.#e.elements.get(r);if(i&&t(i.resolved))return i}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,r=>r.draggable===!0);if(t){this.#b("none");try{let r=this.#e.prepareDrag(t.node,e);if(!r||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let i=this.#a(t,e);if(!i){e.preventDefault();return}let s=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:U(c)]));if(!s.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Lt.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:s,effectAllowed:o,phase:"active",tags:[a,r.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:r.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of s)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#i=this.#t.createElement("style"),this.#i.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.#i),this.#c(l,i.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#_(r)}}}#c(e,t,r){let i=t.cloneNode(!0);i.removeAttribute("id");for(let s of i.querySelectorAll("[id]"))s.removeAttribute("id");i.setAttribute("aria-hidden","true"),i.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(i.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(i),e.preview=i,r.setDragImage(i,0,0)}#u(e){let t=this.#r,r=this.#o(e,u=>Lt.isTarget(u));if(!r)return null;let i=this.#a(r,e);if(!i)return{record:r,element:r.element,accepted:!1};let s=Lt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),a={dropValues:Object.fromEntries(s.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):j(t.wires.get(u))])),item:i.item,path:i.path,source:{...t.source},selfdrop:r===t.record,dropEffect:s.dropEffect,dataAvailable:!0},l=s.accepted&&this.#e.checkDropTarget(r.node,a)&&this.#e.records.get(r.node)===r&&i.element.isConnected;return{record:r,element:i.element,accepted:l,context:a}}#d(e){if(!this.#r){this.#o(e,t=>Lt.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,r=this.#u(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r?.accepted?r.context.dropEffect:"none",this.#h(),r&&this.#p(r.element,r.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#m(),this.#_(t)}}async#f(e){if(!this.#r){this.#o(e,i=>Lt.isTarget(i))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r,r;try{if(r=this.#u(e),this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#m(),!r?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r.context.dropEffect,r.record.node.publish("onDrop",r.context),await this.#e.invokeDrop(r.record.node,r.context)}catch(i){this.#r===t&&(t.phase="rejected",this.#m()),(!r||this.#e.records.has(r.record.node))&&this.#_(i)}}#p(e,t){let r=t?"canBeDropped":"cannotBeDropped",i=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:i.includes(r)},e.classList.add(r),i.includes(r)||e.setAttribute("part",[...i,r].join(" "))}#h(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:i}=this.#n;r||e.classList.remove(t),i||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(s=>s!==t).join(" ")),this.#n=null}#m(){this.#h(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#m(),this.#r=null,e?.release?.(),this.#i?.remove(),this.#i=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(r=>this.#_(r))}#_(e){this.#e.binding.reportError(e,"Drag and drop failed")}dispose(){this.#g();for(let e of Hc)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#s)}};var ei=class extends ir{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#n=new WeakMap;constructor(e,t,r,{binding:i}={}){if(super(e),!(e instanceof Te)||!(t instanceof de)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(i instanceof Zr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");this._binding=i,this.source=t,this.destination=r,this.html=new _s({metadataAttributes:["__ref"],reportError:(s,o,a)=>{this.records.has(s)&&i.reportError(o,a)},callLogic:(s,o,a)=>{let{group:l,method:u}=i.gramlot.src.logicRegistry.resolve(o,s);return u.call(l,s,a)},invokeScript:(s,o,a,l)=>rt(i,s,o,a,l,s.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new Zn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new Rs(this),this.instanceId=Q(),this.radioGroups=new bs(this),this.dragDrop=new $s(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:s=>this.receive(s)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:i,source:s,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:r,path:i,source:s,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:r,path:i,source:s,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:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},i){let s={source:t,dropEffect:r},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,s)}catch(l){o.push(l)}try{this.binding.gramlot.publish(i,s)}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 r=this.#r.get(e)??super.evaluateExpressions(e,t),i=e._getMeta("gramlot_component");if(i?.presentationDefaults.length){let s=e.getAttr();this.#n.set(e,Object.fromEntries(Object.entries(r).filter(([o])=>Object.hasOwn(s,o)&&i.presentationDefaults.some(a=>o.startsWith(a)))))}if(this.html.hasLabelbox(e)||i?.presentationDefaults.length){let s=[];for(let o=e.parentNode;o;o=o.parentNode)this.#n.has(o)&&s.unshift(this.#n.get(o));r=Object.assign({},...s,r)}return this.#r.delete(e),this.#t.set(e,r),r}render(e,t={}){if(!(e instanceof nr))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 A))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,...r}={}){let i=t.createDocumentFragment(),s={node:e,binding:this.#h(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,s),this.elements.set(i,s),i.append(s.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...r});if(a===null)continue;i.append(a);let l=this.elements.get(a);l&&(l.parent=s,s.children.add(o))}return i.append(s.end),i}renderedItem(e,t,r,{tag:i,document:s=this.destination.ownerDocument}={}){let o=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,o]=zn(t,o,(h,m)=>this._binding.gramlot.format(h,m)))),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.#h(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,s,i,o,u.visible??null)};this.html.compose(c,l,a),c.shape=ye.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c),this.elements.set(c.presentation,c);let d=ye.for(c.binding,c);(d||c.element.namespaceURI===we&&c.element.localName==="input")&&c.cleanup.push(()=>c.control?.detach()),d&&(c.control=d,d.attach(),this.#d(c,e,o,null));let f=ws.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new ys(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),this.#f(c),this.references?.register(e,c.element);for(let h of a){let m=this.elements.get(h);m&&(m.parent=c,m.container=c.element,c.children.add(m.node))}return c.presentation}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,i=s=>{if(!r.has(s)){r.add(s);for(let o of this.records.get(s)?.children??[])i(o);if(s.value instanceof A)for(let o of s.value.getNodes())i(o)}};for(let s of this.records.get(t)?.children??[])i(s);if(t?.value instanceof A)for(let s of t.value.getNodes())i(s);return this.#i(e,t?t.nodeTag:null),ba(e),this.references?.validate(e,r),e}#i(e,t=null){let r=new Set,i=(s,o=null)=>{if(!(s instanceof de)||r.has(s))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(s._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");r.add(s);for(let a of s.getNodes()){if(!(a instanceof nr))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(a.builder instanceof Te))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")?s._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof A))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 A&&i(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};i(e,t)}freeze(e){e=J(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=J(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=i=>{delete i.frozen;for(let s of i.children)r(this.records.get(s))};r(t),!this.#s(e)&&(this.attached(e)?this.#m(e):this.remove(e))}#s(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)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(i=>!t(i));if(!r.length)return;e={...e,node:r}}else if(t(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let r=this.pending.shift();if(r.evt!=="del"&&!this.attached(r.node))continue;r.evt!=="del"&&r.evt!=="upd_attrs"&&this.#l(r);let i=this.binding.handleSourceEvent(r);try{this.#o(r,i)}catch(s){if(!i.length)throw s;i.push(s)}if(i.length)throw i.length===1?i[0]:new AggregateError(i,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#o(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#s(r))continue;let i=this.records.get(r)?.parent??null;try{this.remove(r)}catch(s){t.push(s)}this.#p(i)}return}if(!this.#s(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(r=>Array.isArray(r.node)?r.node:[r.node]));for(let r=e;r;r=r.parentBag?.parentNode)if(t.has(r))return!0;return!1}#l(e){let t=r=>{if(!(r instanceof nr))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof A){if(!(r.value instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");for(let i of r.value.getNodes())t(i)}};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),r=t?.element??t?.container??this.destination,i=e.parentBag.getNodes(),s=t?.end??null;for(let o=i.indexOf(e)+1;o<i.length;o++){let a=this.records.get(i[o]);if(a){s=a.presentation??a.start;break}}this.buildNode(e,r,s,t)}buildNode(e,t,r=null,i=null){this.#e.add(e);let s;try{s=this.render(e,{document:t.ownerDocument})}catch(a){this.#c(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(s,r),o.parent=i,this.assignContainer(o,t),i?.children.add(e),this.#p(i),this.binding.branchBuilt(e),o}#c(e,t){let r=[t],i=[],s=o=>{if(i.push(o),o.value instanceof A)for(let a of o.value.getNodes())s(a)};s(e);for(let o of i.reverse())try{this.remove(o)}catch(a){r.push(a)}throw r.length===1?t:new AggregateError(r,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let r=e.element??t;for(let i of e.children){let s=this.records.get(i);s&&this.assignContainer(s,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let i=e.value==null||["string","number","boolean"].includes(typeof e.value),s=t==="upd_value"&&i&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||s)&&r.element&&this.html.matches(r,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)===r&&(this.references?.remove(e),this.references?.register(e,r.element))):this.#m(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element||!this.attached(e))return;let i=this.getRender(e.builder),s=this.#n.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=i._handleMeta(e,a),u=this.#t.get(e),c=r.element.namespaceURI===we&&r.element.localName==="input"&&!Object.is(r.resolved.type,u.type),d=r.element.namespaceURI===we&&["input","select"].includes(r.element.localName)&&!!r.resolved.multiple!=!!u.multiple,f=r.resolved.group,h=r.control instanceof Gr&&!Object.is(f??null,u.group??null);if((c||d||h)&&this.#s(e))return;if(r.shape!==ye.shape(r.element,u)){if(this.#s(e))return;this.#r.set(e,u);try{this.#m(e)}finally{this.#r.delete(e)}return}let m=c?ye.classFor(r.element,u):null,p=c&&(r.control?.constructor??null)!==m,b=(c||d&&r.element.localName==="input")&&!p&&r.control&&Object.is(r.resolved.value,u.value);if(p&&(r.control?.detach(),r.control=null),h&&!p&&u.group!=null&&e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);r.resolved=u;let g=e._getMeta("subbuilder")?l:i.adaptAttrs(l),_=e.value instanceof A,w=_?[]:this.expressionValue(e,o);if(i===this&&(g=this.restoreNativeAttributes(e,g),e._getMeta("gramlot_component")||([w,g]=zn(w,g,(D,y)=>this._binding.gramlot.format(D,y)))),g=this.componentAttributes(e,g),this.html.update(r,e,g,_?g._text:w,u.visible??null),p&&m&&(r.control=new m(r.binding,r),r.control.attach()),h&&!p){r.control.refresh(f??null),this.records.get(e)===r&&!r.binding.closed&&this.project(e);return}b||this.#d(r,e,g,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#f(r);let E=this.#n.get(e);if(E){let D=new Set([...Object.keys(s??{}),...Object.keys(E)].filter(y=>!Object.is(s?.[y],E[y])));D.size&&this.#u(e,D)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#p(r.parent)}#u(e,t){if(e.value instanceof A)for(let r of e.value.getNodes()){let i=r._getMeta("gramlot_component"),s=r.getAttr(),o=t;i?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(s,a))):this.html.hasLabelbox(r)&&[...t].some(a=>!Object.hasOwn(s,a))&&this.project(r),o.size&&this.#u(r,o)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),i=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!i)return t;let s=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(i??{}),...Object.keys(s).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(s,a)).map(a=>[a,s[a]]));return{...t,...o}}#d(e,t,r,i){if(!e.control)return;let s=t.getAttr("value")!=null;(s||e.valueDeclared)&&e.control.project(r.value??null,i),e.valueDeclared=s}#f(e){let t=new Map(Yn.declared(e.node).map(r=>[r[0],r]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let r of e.events.values())r.detach();e.events.clear()})}for(let[r,i]of[...e.events])t.get(r)?.[2]!==i.handler&&(i.detach(),e.events.delete(r));for(let[r,[,i,s]]of t){if(e.events.has(r))continue;let o=new Yn(e.binding,e,i,s,r);o.attach(),e.events.set(r,o)}}#p(e){for(let t=e;t;t=t.parent){if(t.control instanceof Xn){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=J(e),r=this.records.get(t);return r&&this.attached(t)?r.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let r=t.nodeType===1?this.elements.get(t):null;if(r)return this.attached(r.node)?r.node:null}return null}#h(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#m(e){let t=this.records.get(e),r=t.presentation?.nextSibling??t.end?.nextSibling??null,i=t.container,s=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,i,r,s)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let r=this.records.get(e);if(!r)throw new Error("Source node is not mounted");return r.cleanup.push(t),()=>{let i=r.cleanup.indexOf(t);i!==-1&&r.cleanup.splice(i,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let i of[...t.children])try{this.remove(i)}catch(s){r.push(s)}for(let i of t.cleanup.splice(0).reverse())try{i()}catch(s){r.push(s)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.presentation&&this.elements.delete(t.presentation),t.presentation?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#n.delete(e),r.length)throw new AggregateError(r,"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(([,r])=>!r.parent).map(([r])=>r);for(let r of t)try{this.remove(r)}catch(i){e.push(i)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var ib=new Set(["page","constructor"]);function Wc(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(ib.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var sb=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function ob(n){return/^[\w$]/.test(n)?sb.has(n):n!==")"&&n!=="]"}function ab(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let i=n[r];if(i===`
|
|
194
|
-
`)return-1;if(i==="\\"){r++;continue}if(i==="[")t=!0;else if(i==="]")t=!1;else if(i==="/"&&!t)return r}return-1}function
|
|
195
|
-
`,i),i<0)break;continue}if(s==="/"&&n[i+1]==="*"){let o=n.indexOf("*/",i+2);if(o>=0){i=o+1;continue}}if(s==="/"&&ob(r)){let o=ab(n,i);if(o>=0){i=o,r=")";continue}}if(s==='"'||s==="'"||s==="`"){let o=i+1;for(;o<n.length&&n[o]!==s;)o+=n[o]==="\\"?2:1;e===1&&(t+=n.slice(i+1,o)==="constructor"?" constructor":' ""'),i=o,r=")";continue}if(/[\w$]/.test(s)){let o=i+1;for(;o<n.length&&/[\w$]/.test(n[o]);)o++;e===1&&(t+=n.slice(i,o)),r=n.slice(i,o),i=o-1;continue}if(/\s/.test(s)||(r=s),s==="{"){++e===2&&(t+=" {}");continue}if(s==="}"){e--;continue}e===1&&(t+=s)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function Gc(n,e){if(n===void 0)return[];if(typeof n!="function"||!/^class\b/.test(Function.prototype.toString.call(n)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(n)!==Function.prototype||Object.getPrototypeOf(n.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(lb(Function.prototype.toString.call(n)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let r of Reflect.ownKeys(n.prototype)){if(r==="constructor")continue;if(typeof r=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(r)})`);let i=Object.getOwnPropertyDescriptor(n.prototype,r);if(i.get||i.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof i.value!="function")throw new Error(`${e}: Logic.prototype.${r} is not a method`);if(r==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([r,i.value])}return t}function Xc(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var ar=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Jr=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new ar(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:i}of e){let s=Wc(r,i);for(let o=0;o<s.length;o++){let a=s.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(s[o])}}for(let{logicClass:r,group:i,resource:s}of e){let o=t.get(i??"")??new Set;for(let[a]of Gc(r,s))if(o.has(a))throw new Error(`${s}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let i=Wc(t,r),s=Gc(e,r),o=this.#e.logic;for(let a of i){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new ar(this,this.#e);Xc(o,a,u),o=u}else if(l instanceof ar)o=l;else throw new Error(`${r}: the group '${a}' has the name of a logic method`)}for(let[a,l]of s){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof ar)throw new Error(`${r}: the logic method '${a}' has the name of a child group`);Xc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(r)}resolve(e,t){let r=e.split("."),i=r.pop(),s=this.#e.logic;for(let a=0;a<r.length;a++)if(s=Object.getOwnPropertyDescriptor(s,r[a])?.value,!(s instanceof ar))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(s,i)?.value;if(typeof o!="function"){let a=this.#t.get(s)??[],l=r.length?`the group '${r.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${i}' (resources: ${a.join(", ")||"none"})`)}return{group:s,method:o}}};var ti=class extends De{constructor(e,{collections:t,destination:r,subscriptions:i,nameSyntax:s}){super(e),e.src=this,this.logicRegistry=new Jr(e),this.builder=new Oe(null,{collections:t,nameSyntax:s}),this.binding=new Zr(e,{subscriptions:i}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new ei(this.builder,this.source,r,{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,t=null){let r=this.prepareSource(e);if(this.renderer.validateCandidate(r),t!==null){if(!(t instanceof x)||t instanceof A)throw new TypeError("Initial page data must be a Data Bag");for(let i of t.getNodes())this.builder.data.setItem([i.label],i.getValue(),i.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(i){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),i}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof A){if(!(e instanceof de))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 r=Jo(e,t);if(!(r instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");return r.activateCode()}async remoteSource(e,t,r={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let s=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!s)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,o=>this.#e(e,s,o))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let i=!1,s=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let o=await t.call("source",r);if(!s())return!1;let a=this.prepareSource(o,e.builder);return s()?(this.renderer.validateCandidate(a,{replacingNode:e}),i=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(o){if(!i&&!s())return!1;throw o}}};var ri=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:i}){super(r),this.code=e,this.remoteName=t,i!==void 0&&(this.details=i)}},ni=class extends De{constructor(e,{rpcUrl:t,closeUrl:r,document:i,transport:s}){super(e),this.transport=s===!1?null:s??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:i}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,r={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(Mt(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let i=Q(),s=j(this.transport.callSync(U({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(s.id!==i)throw new Error("rpc response id mismatch");if(s.error)throw new ri(s.error);return s.value}async call(e,t,r={},i={}){return(await this.callEnvelope(e,t,r,i)).value}async callEnvelope(e,t,r={},{signal:i=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Mt(r);let s=Q(),o=U({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),a=i?[this.gramlot.abort.signal,i]:[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(s),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(s,u);try{let f=j(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==s)throw new Error("rpc response id mismatch");if(f.error)throw new ri(f.error);return f}finally{this.remoteRequests.delete(s);for(let f of a)f.removeEventListener("abort",c)}}};var ii=class extends De{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)}navigate(e){if(typeof e!="string"||!e)throw new TypeError("Navigation requires an absolute HTTP(S) URL");let t=new URL(e);if(!["http:","https:"].includes(t.protocol)||t.username||t.password)throw new TypeError("Navigation requires an HTTP(S) URL without credentials");this.gramlot.src.renderer.destination.ownerDocument.defaultView.location.assign(t.href)}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 Yc="gramlot:publish",Ms=class{#e;#t;#r;#n=Q();#i=new Map;#s=!1;#o;#a;#l;#c;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#o=i=>this.#p(i),this.#a=i=>{if(i.target?.localName!=="iframe")return;let s=this.#g(i.target);s&&(this.#d(s.window),this.#h(s,{kind:"hello"}))},this.#t.addEventListener("message",this.#o),this.#l=()=>this.#u(),this.#c=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#c),t.addEventListener("load",this.#a,!0);let r=this.#m();r&&this.#h(r,{kind:"hello"})}ready(){if(this.#s||this.#e.state!=="started")return;let e=this.#m();e&&this.#h(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let r=this.#g(t);r&&this.#h(r,{kind:"hello"})}}prepare(e,t){let r=[];if(e.parent){let o=this.#m();if(!o)throw new Error("This page has no parent frame");r.push(o)}if(e.iframe!==void 0){let o=e.iframe,a=J(o),l=typeof o=="string"?this.#r.getElementById(o):a instanceof Ae?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");r.push(u)}let i=r.map(o=>{let a=this.#i.get(o.window);if(!a||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});Mt(t);let s=U(t);return()=>{if(!this.#s)for(let o of i){let a=this.#_(o.window);if(!a||a.origin!==o.origin||this.#i.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#h(o,{kind:"publish",recipient:o.session,topic:e.topic,wire:s})}}}dispose(){this.#s||(this.#u(),this.#s=!0,this.#t.removeEventListener("message",this.#o),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#c),this.#r.removeEventListener("load",this.#a,!0))}#u(){for(let[e,t]of this.#i)this.#h({window:e,origin:t.origin},{kind:"close"});for(let e of this.#i.keys())this.#d(e)}#d(e){this.#i.get(e)?.release?.(),this.#i.delete(e)}#f(e,t){this.#d(e.window);let r={session:t,origin:e.origin};e.node&&(r.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#h(e,{kind:"close"}),this.#d(e.window)})),this.#i.set(e.window,r)}#p(e){if(this.#s||e.data?.type!==Yc)return;let t=this.#_(e.source);if(!t||e.origin!==t.origin)return;let r=e.data;if(!(typeof r.session!="string"||!r.session)){if(r.kind==="hello")this.#d(t.window),r.ready===!0&&this.#f(t,r.session),this.#e.state==="started"&&this.#h(t,{kind:"ready"});else if(r.kind==="ready"){let i=this.#i.get(t.window)?.session!==r.session;this.#f(t,r.session),i&&this.#e.state==="started"&&this.#h(t,{kind:"ready"})}else if(r.kind==="close")this.#i.get(t.window)?.session===r.session&&this.#d(t.window);else if(r.kind==="publish"){if(this.#e.state!=="started"||r.recipient!==this.#n||this.#i.get(t.window)?.session!==r.session||typeof r.topic!="string"||!r.topic||typeof r.wire!="string")return;this.#e.publish(r.topic,j(r.wire))}}}#h(e,t){e.window.postMessage({type:Yc,session:this.#n,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#m(){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 r=e.getAttribute("sandbox"),s=r!==null&&!r.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:s,node:t}}#b(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#_(e){let t=this.#m();if(t?.window===e)return t;for(let r of this.#r.getElementsByTagName("iframe")){let i=this.#g(r);if(i?.window===e)return i}return null}};var Ls=class extends De{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#i=!1;#s;attach(e){this.#s=new Ms(this.gramlot,e)}ready(){this.#s.ready()}subscribe(e,t){if(this.#l(),this.#a(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let r=Object.freeze({});return this.#t.add(r),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(r,t),r}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,r]of this.#e)r.delete(e)&&!r.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(s=>!["topic","nodeId","parent","iframe"].includes(s)))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 i=e.parent||e.iframe!==void 0?this.#s.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let s=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!s)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(s,e.topic,t)}this.#o(e.topic,t),i?.()}topicFor(e,t){this.#a(t),e=J(e);let r=this.gramlot.src.binding.bindingFor(e);if(!r||r.closed)throw new Error("Topic target is not an active Source node of this page");let i=e.getAttr("nodeId");return i==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),i=this.#r.get(e)),`${i}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[i,s]of Object.entries(e.getAttr())){let o=i.startsWith("selfsubscribe_")?"selfsubscribe_":i.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,i.slice(o.length)):i.slice(o.length);this.#a(a),r.push([a,t(i,s,a)])}return this.#l(),r.map(([i,s])=>{let o=this.subscribe(i,s);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#i=!0,this.#s.dispose(),this.#e.clear()}#o(e,t){this.#a(e);let r=this.#e.get(e);if(r)for(let[i,s]of[...r]){if(this.#i)break;r.has(i)&&s(t)}}#a(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#i)throw new Error("Gramlot subscriptions are disposed")}};var Ps=class extends K{constructor(e,t,r){super({cacheTime:r}),this.handler=e,this.name=t,this.failed=!1,this.writing=!1,this.request=null,this.revision=0,this.received=0}resolve({static:e=!1}={}){return!e&&!this.handler.disposed&&!this.writing&&!this.request&&!this.failed&&!this._node.attr.watching&&this.expired&&this.handler.refresh(this.name),this.cachedValue}reset(){super.reset(),this.failed=!1,this.revision++}};var Zc=["appinfo","location"],Jc={UNAVAILABLE:"unavailable",PERMISSION_DENIED:"denied",TIMEOUT:"error",FAILED:"error",CANCELLED:"cancelled"};function V(n){let e=Object.hasOwn(Jc,n?.code)?n.code:"FAILED";return{status:Jc[e],error:e==="CANCELLED"?null:{code:e,message:String(n?.message??"Device operation failed")}}}var si=class extends De{#e=null;#t=null;#r=null;#n=null;#i=null;#s=null;#o=new Map;#a=new Map;#l=null;#c=null;#u=null;#d=null;#f=null;#p=null;#h=null;constructor(e){super(e),this.provider=null,this.disposed=!1,this.monitor=null,this.retiring=null,this.resolvers=new Map,this.cleanup=Promise.resolve()}installData(){let{gramlot:e}=this;e.data.setItem("gramlot.device.database",null,{status:"idle",error:null}),e.data.setItem("gramlot.device.orientation",null,{status:"idle",error:null,listening:!1});for(let p of["gyroscope","accelerometer"])e.data.setItem(`gramlot.device.${p}`,null,{enabled:!1,watching:!1,status:"idle",error:null}),e.data.getNode(`gramlot.device.${p}`).setAttr({error:null},!1,!0,!1),this.#a.set(p,{node:e.data.getNode(`gramlot.device.${p}`),stream:null,cleanup:Promise.resolve()});for(let p of Zc){let b=`gramlot.device.${p}`,g={status:"idle",error:null,cacheTime:p==="appinfo"?-1:5};p==="location"&&Object.assign(g,{enabled:!1,watching:!1}),e.data.setItem(b,null);let _=e.data.getNode(b);_.setAttr(g,!1,!0,!1);let w=new Ps(this,p,g.cacheTime);_.resolver=w,this.resolvers.set(p,w)}e.data.setItem("gramlot.device.clipboard",null,{status:"idle",error:null,text:"",copy:null,paste:null,operation:null});let t=e.data.getNode("gramlot.device.clipboard");e.data.setItem("gramlot.device.camera",null,{status:"idle",error:null,capture:null,choose:null});let r=e.data.getNode("gramlot.device.camera");e.data.setItem("gramlot.device.barcode",null,{status:"idle",error:null,scan:null});let i=e.data.getNode("gramlot.device.barcode");e.data.setItem("gramlot.device.biometrics",null,{status:"idle",error:null,verify:null});let s=e.data.getNode("gramlot.device.biometrics"),o=new x;o.setItem("request",new x);for(let p of["scheduled","received","action"])o.setItem(p,null);e.data.setItem("gramlot.device.notifications",o,{status:"idle",error:null,schedule:null,listening:!1,listenerError:null});let a=e.data.getNode("gramlot.device.notifications"),l=new x;for(let p of["registration","received","action"])l.setItem(p,null);e.data.setItem("gramlot.device.push",l,{status:"idle",error:null,register:null,listening:!1,listenerError:null});let u=e.data.getNode("gramlot.device.push"),c=new x;c.setItem("request",null),e.data.setItem("gramlot.device.links",c,{listening:!1,listenerError:null});let d=new x;d.setItem("request",null),e.data.setItem("gramlot.device.shortcuts",d,{listening:!1,listenerError:null}),e.data.setItem("gramlot.device.network",null,{status:"idle",error:null,listening:!1});let f=new x;f.setItem("active",null),f.setItem("event",null),f.setItem("sequence",0),e.data.setItem("gramlot.device.lifecycle",f,{status:"idle",error:null,listening:!1}),e.data.setItem("gramlot.device.haptics",null,{status:"idle",error:null,impact:null,style:"medium",vibrate:null,duration:600});let h=e.data.getNode("gramlot.device.haptics");e.data.setItem("gramlot.device.audio",null,{status:"idle",error:null,recording:!1,start:null,stop:null,cancel:null,share:null,shareStatus:"idle",shareError:null,shareActivity:null});let m=e.data.getNode("gramlot.device.audio");e.data.subscribe("gramlot.device",{update:p=>{if(!this.disposed){for(let[b,g]of this.#a)if(p.node===g.node&&p.attrs_diff?.enabled){if(typeof g.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.#g(b,g)}p.node===t&&p.fired&&(p.attrs_diff?.copy?.new===!0&&this.#v(t,"copy"),p.attrs_diff?.paste?.new===!0&&this.#v(t,"paste")),p.node===m&&p.fired&&(p.attrs_diff?.start?.new===!0&&this.#b(m),p.attrs_diff?.stop?.new===!0&&this.#_(m),p.attrs_diff?.cancel?.new===!0&&this.#y(m),p.attrs_diff?.share?.new===!0&&this.#A(m)),p.node===h&&p.fired&&p.attrs_diff?.impact?.new===!0&&this.#D(h),p.node===h&&p.fired&&p.attrs_diff?.vibrate?.new===!0&&this.#T(h),p.node===i&&p.fired&&p.attrs_diff?.scan?.new===!0&&this.#C(i),p.node===r&&p.fired&&p.attrs_diff?.choose?.new===!0&&this.#E(r,"choose"),p.node===r&&p.fired&&p.attrs_diff?.capture?.new===!0&&this.#E(r,"capture"),p.node===s&&p.fired&&p.attrs_diff?.verify?.new===!0&&this.#S(s),p.node===a&&p.fired&&p.attrs_diff?.schedule?.new===!0&&this.#N(a),p.node===u&&p.fired&&p.attrs_diff?.register?.new===!0&&this.#O(u);for(let b of this.resolvers.values()){if(p.node!==b._node)continue;let{cacheTime:g}=p.node.attr;if(typeof g!="number"||!Number.isFinite(g)||g<0&&g!==-1)throw new TypeError("Device cacheTime must be -1 or a nonnegative number of seconds");if(b.cacheTime=g,b.name==="location"){if(typeof p.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.reconcile()}}}}})}attach(e,{dispose:t=null}={}){if(this.assertLive(),this.provider)throw new Error("A device provider is already attached");if(!Array.isArray(e.capabilities)||e.capabilities.some(r=>![...Zc,"camera","biometrics","notifications","push","shortcuts","barcode","network","lifecycle","haptics","audio","clipboard","links","orientation","gyroscope","accelerometer","database"].includes(r)))throw new TypeError("Unknown device provider capability");if(t!==null&&typeof t!="function")throw new TypeError("Device attachment dispose must be a function");this.releaseProvider=t,this.provider=e,this.installData(),this.reconcile(),this.#m("orientation",(r,i)=>e.startOrientationEvents(r,i),(r,i)=>{if(!["portrait","landscape"].includes(i?.type)||!["primary","secondary"].includes(i.direction)||!Number.isFinite(i.timestamp))throw new TypeError("Invalid screen orientation from device provider");let s=new x;for(let o of["type","direction","timestamp"])s.setItem(o,i[o]);r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("network",(r,i)=>e.startNetworkEvents(r,i),(r,i)=>{if(typeof i?.connected!="boolean"||!["none","unknown","wifi","cellular"].includes(i.type))throw new TypeError("Invalid network state from device provider");let s=new x;s.setItem("connected",i.connected),s.setItem("type",i.type),r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("lifecycle",(r,i)=>e.startLifecycleEvents(r,i),(r,i)=>{if(i?.kind==="state"&&typeof i.active=="boolean")r.staticValue.setItem("active",i.active);else if(i?.kind==="pause"||i?.kind==="resume")r.staticValue.setItem("event",i.kind),r.staticValue.setItem("sequence",r.staticValue.getItem("sequence")+1);else throw new TypeError("Invalid lifecycle event from device provider");r.setAttr({status:"success",error:null},!0,!0,!1)}),e.capabilities.includes("links")&&this.#R(this.gramlot.data.getNode("gramlot.device.links")),e.capabilities.includes("shortcuts")&&this.#B(this.gramlot.data.getNode("gramlot.device.shortcuts")),e.capabilities.includes("push")&&this.#k(this.gramlot.data.getNode("gramlot.device.push")),e.capabilities.includes("notifications")&&this.#x(this.gramlot.data.getNode("gramlot.device.notifications"))}assertLive(){if(this.disposed)throw new Error("DeviceHandler is disposed")}resolver(e){if(this.assertLive(),!this.resolvers.has(e))throw new TypeError(`Unknown device value: ${e}`);return this.resolvers.get(e)}invalidate(e){this.resolver(e).reset()}refresh(e){let t=this.resolver(e);if(t.request)return;let r={revision:t.revision,received:t.received};t.request=r,this.attributes(t,{status:"pending",error:null}),Promise.resolve().then(()=>{if(!(this.disposed||t.request!==r))return this.requireCapability(e),e==="appinfo"?this.provider.readAppInfo():this.provider.readLocation()}).then(i=>{this.disposed||t.request!==r||(this.accept(t,i),t.revision!==r.revision&&(t._lastUpdate=null))}).catch(i=>{!this.disposed&&t.request===r&&t.received===r.received&&this.failure(t,i)}).finally(()=>{t.request===r&&(t.request=null)})}#m(e,t,r){let i=this.gramlot.data.getNode(`gramlot.device.${e}`);if(!this.provider.capabilities.includes(e)){i.setAttr(V({code:"UNAVAILABLE",message:`${e} is unavailable`}),!0,!0,!1);return}let s={controller:new AbortController};this.#o.set(e,s),i.setAttr({status:"pending",error:null},!0,!0,!1),s.start=Promise.resolve().then(()=>s.controller.signal.aborted?async()=>{}:t(o=>{if(!s.controller.signal.aborted)try{r(i,o)}catch(a){i.setAttr(V(a),!0,!0,!1)}},s.controller.signal)).then(o=>(s.controller.signal.aborted||i.setAttr({listening:!0},!0,!0,!1),o)),s.start.catch(o=>{let a=s.controller.signal.aborted;s.controller.abort(),a||i.setAttr({...V(o),listening:!1},!0,!0,!1)})}#g(e,t){let{node:r}=t;if(!r.attr.enabled){let s=t.stream;if(!s)return;t.stream=null,s.controller.abort(),t.cleanup=s.start.then(o=>o(),()=>{}).then(()=>{!this.disposed&&!t.stream&&r.setAttr({watching:!1,status:"idle",error:null},!0,!0,!1)}),t.cleanup.catch(o=>{this.disposed||r.setAttr(V(o),!0,!0,!1)});return}if(t.stream)return;let i={controller:new AbortController};t.stream=i,i.start=t.cleanup.then(()=>{if(i.controller.signal.aborted)return async()=>{};this.requireCapability(e);let s=o=>{if(!(this.disposed||i.controller.signal.aborted))try{if(o?.kind==="state"&&typeof o.watching=="boolean")r.setAttr({watching:o.watching,status:o.watching?"pending":"idle",error:null},!0,!0,!1);else if(o?.kind==="sample"){for(let l of["x","y","z","timestamp"])if(!Number.isFinite(o[l]))throw new TypeError(`Invalid ${e}.${l}`);if(!r.attr.watching||r.staticValue&&o.timestamp<r.staticValue.getItem("timestamp"))return;let a=new x;for(let l of["x","y","z","timestamp"])a.setItem(l,o[l]);r.setValue(a,!0,{status:"success",error:null},!0,!1)}else if(o?.kind==="error"&&o.error instanceof Error)r.setAttr({...V(o.error),watching:!1},!0,!0,!1);else throw new TypeError(`Invalid ${e} event`)}catch(a){r.setAttr(V(a),!0,!0,!1)}};return e==="gyroscope"?this.provider.startGyroscopeUpdates(s,i.controller.signal):this.provider.startAccelerometerUpdates(s,i.controller.signal)}),i.start.catch(s=>{!this.disposed&&!i.controller.signal.aborted&&r.setAttr({...V(s),watching:!1},!0,!0,!1)}),r.setAttr({status:"pending",error:null},!0,!0,!1)}#b(e){let t=this.#n;if(t){if(t.phase!=="complete")return;t.phase="replacing",e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),t.close=t.start.then(i=>i.dispose()).then(()=>{this.disposed||t.controller.signal.aborted||this.#n!==t||(this.#n=null,this.#b(e))}).catch(i=>{!this.disposed&&this.#n===t&&(t.phase="failed",e.setAttr(V(i),!0,!0,!1))});return}let r={controller:new AbortController,phase:"starting"};this.#n=r,e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.start=Promise.resolve().then(async()=>r.controller.signal.aborted?null:(this.requireCapability("audio"),this.provider.startAudioRecording(i=>{this.#n===r&&!r.controller.signal.aborted&&this.#y(e,i)},r.controller.signal))),r.start.then(i=>{!i||r.controller.signal.aborted||this.disposed||(r.phase="recording",e.setAttr({status:"recording",error:null,recording:!0},!0,!0,!1))}).catch(i=>{r.controller.signal.aborted||this.disposed||(this.#n===r&&(this.#n=null),e.setAttr({...V(i),recording:!1},!0,!0,!1))})}#_(e){let t=this.#n;!t||t.phase!=="recording"||(t.phase="stopping",e.setAttr({status:"pending",error:null},!0,!0,!1),t.stop=t.start.then(r=>r.stop()).then(r=>{if(t.controller.signal.aborted||this.disposed)return;if(typeof r?.url!="string"||!r.url||typeof r.mimeType!="string"||!r.mimeType.startsWith("audio/")||!Number.isFinite(r.duration)||r.duration<0)throw new TypeError("Invalid audio result from device provider");let i=new x;for(let s of["url","mimeType","duration"])i.setItem(s,r[s]);t.phase="complete",e.setValue(i,!0,{status:"success",error:null,recording:!1},!0,!1)}).catch(r=>{!t.controller.signal.aborted&&!this.disposed&&this.#y(e,r)}))}#A(e){let t=this.#n;if(t?.phase!=="sharing"){if(!t||t.phase!=="complete"){let r=V(new Error("Record and stop audio before sharing"));e.setAttr({shareStatus:r.status,shareError:r.error,shareActivity:null},!0,!0,!1);return}t.phase="sharing",e.setAttr({shareStatus:"pending",shareError:null,shareActivity:null},!0,!0,!1),t.share=t.start.then(r=>r.share(t.controller.signal)).then(r=>{if(!(t.controller.signal.aborted||this.disposed)){if(typeof r?.activity!="string")throw new TypeError("Invalid audio share result from device provider");e.setAttr({shareStatus:"success",shareError:null,shareActivity:r.activity},!0,!0,!1)}}).catch(r=>{if(t.controller.signal.aborted||this.disposed)return;let i=V(r);e.setAttr({shareStatus:i.status,shareError:i.error,shareActivity:null},!0,!0,!1)}).finally(()=>{this.#n===t&&!t.controller.signal.aborted&&(t.phase="complete")})}}#y(e,t={code:"CANCELLED",message:"Audio recording cancelled"}){let r=this.#n;!r||r.phase==="closing"||r.phase==="sharing"||(r.phase="closing",r.controller.abort(),e.setValue(null,!0,{status:"pending",error:null,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.close=r.start.then(i=>i===null?void 0:i.dispose(),i=>{if(i?.code!=="CANCELLED")throw i}).then(()=>{this.disposed||this.#n!==r||(this.#n=null,e.setAttr({...V(t),recording:!1},!0,!0,!1))}).catch(i=>{!this.disposed&&this.#n===r&&(r.phase="failed",e.setAttr(V(i),!0,!0,!1))}))}#v(e,t){if(this.#t)return;let r=new AbortController;this.#t=r;let i=e.attr.text;e.setValue(null,!0,{status:"pending",error:null,operation:t},!0,!1),Promise.resolve().then(async()=>{if(r.signal.aborted)return;this.requireCapability("clipboard");let s;if(t==="copy"){if(typeof i!="string")throw new TypeError("Clipboard text must be a string");await this.provider.copyText(i,r.signal),s={text:i}}else s=await this.provider.pasteText(r.signal);if(r.signal.aborted)return;if(typeof s?.text!="string")throw new TypeError("Invalid clipboard text from device provider");let o=new x;o.setItem("text",s.text),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(s=>{r.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#t===r&&(this.#t=null)})}#T(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{duration:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!Number.isInteger(r)||r<1||r>5e3)throw new TypeError("Vibration duration must be an integer from 1 to 5000 milliseconds");if(await this.provider.vibrate(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("duration",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#D(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{style:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!["light","medium","heavy"].includes(r))throw new TypeError("Invalid haptic style");if(await this.provider.impact(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("style",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#C(e){if(this.#i)return;let t=new AbortController;this.#i=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("barcode"),this.provider.scanBarcode(t.signal)}).then(r=>{if(t.signal.aborted)return;if(typeof r?.text!="string"||!r.text||typeof r.format!="string"||!r.format)throw new TypeError("Invalid barcode result from device provider");let i=new x;i.setItem("text",r.text),i.setItem("format",r.format),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setAttr(V(r),!0,!0,!1)}).finally(()=>{this.#i===t&&(this.#i=null)})}#E(e,t){if(this.#r)return;let r=new AbortController;this.#r=r,e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(()=>{if(!r.signal.aborted)return this.requireCapability("camera"),t==="choose"?this.provider.choosePhoto(r.signal):this.provider.takePhoto(r.signal)}).then(i=>{if(r.signal.aborted)return;if(typeof i?.url!="string"||!i.url||typeof i.format!="string"||!i.format)throw new TypeError("Invalid camera photo from device provider");let s=new x;s.setItem("url",i.url),s.setItem("format",i.format),e.setValue(s,!0,{status:"success",error:null},!0,!1)}).catch(i=>{r.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#r===r&&(this.#r=null)})}#S(e){if(this.#l)return;let t=new AbortController;this.#l=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("biometrics"),this.provider.verifyBiometrics(t.signal)}).then(()=>{if(t.signal.aborted)return;let r=new x;r.setItem("verified",!0),e.setValue(r,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setValue(null,!0,V(r),!0,!1)}).finally(()=>{this.#l===t&&(this.#l=null)})}#x(e){if(this.#u)return this.#u.start;let t={controller:new AbortController};return this.#u=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startNotificationEvents(r=>{if(!t.controller.signal.aborted)try{if(!["received","action"].includes(r.kind)||!Number.isInteger(r.id)||typeof r.title!="string"||typeof r.body!="string"||r.kind==="action"&&typeof r.actionId!="string")throw new TypeError("Invalid notification event from device provider");let i=new x;for(let s of["id","title","body"])i.setItem(s,r[s]);r.kind==="action"&&i.setItem("actionId",r.actionId),e.staticValue.setItem(r.kind,i)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#u===t&&(this.#u=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#N(e){if(this.#c)return;let t=new AbortController;this.#c=t;let r=e.staticValue.getItem("request"),i=r instanceof x?Object.fromEntries(["id","title","body","delay"].map(s=>[s,r.getItem(s)])):null;e.staticValue.setItem("scheduled",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{if(!t.signal.aborted){if(this.requireCapability("notifications"),!i||!Number.isInteger(i.id)||i.id<1||i.id>2147483647||typeof i.title!="string"||!i.title.trim()||typeof i.body!="string"||!i.body.trim()||typeof i.delay!="number"||!Number.isFinite(i.delay)||i.delay<=0)throw new TypeError("Notification requires a positive 32-bit id, title, body and positive delay in seconds");if(await this.#x(e),!t.signal.aborted)return this.provider.scheduleNotification(i,t.signal)}}).then(s=>{if(t.signal.aborted)return;if(s?.id!==i.id||typeof s.at!="number"||!Number.isFinite(s.at))throw new TypeError("Invalid notification scheduling acknowledgement");let o=new x;o.setItem("id",s.id),o.setItem("at",s.at),e.staticValue.setItem("scheduled",o),e.setAttr({status:"success",error:null},!0,!0,!1)}).catch(s=>{t.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#c===t&&(this.#c=null)})}#w(){let e=this.#d;return this.#d=null,e&&clearTimeout(e.timer),e}#I(e,t){if(t.kind==="registration"){if(typeof t.token!="string"||!t.token)throw new TypeError("Invalid push registration token");this.#w();let r=new x;r.setItem("token",t.token),e.staticValue.setItem("registration",r),e.setAttr({status:"success",error:null},!0,!0,!1)}else if(t.kind==="registrationError")this.#w(),e.staticValue.setItem("registration",null),e.setAttr(V(t.error),!0,!0,!1);else{if(!["received","action"].includes(t.kind))throw new TypeError("Invalid push event kind");let r=["id","title","body","messageId","destination"];t.kind==="action"&&r.push("actionId");let i=new x;for(let s of r){if(typeof t[s]!="string")throw new TypeError(`Invalid push event ${s}`);i.setItem(s,t[s])}e.staticValue.setItem(t.kind,i)}}#k(e){if(this.#f)return this.#f.start;let t={controller:new AbortController};return this.#f=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startPushEvents(r=>{if(!t.controller.signal.aborted)try{this.#I(e,r)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#f===t&&(this.#f=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#O(e){if(this.#d)return;let t={controller:new AbortController,timer:null};this.#d=t,t.timer=setTimeout(()=>{this.disposed||this.#d!==t||(this.#w(),t.controller.abort(),e.setAttr(V({code:"TIMEOUT",message:"Push registration has not returned a token"}),!0,!0,!1))},3e4),e.staticValue.setItem("registration",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{t.controller.signal.aborted||(this.requireCapability("push"),await this.#k(e),!(t.controller.signal.aborted||this.#d!==t)&&await this.provider.registerPush(t.controller.signal))}).catch(r=>{this.disposed||this.#d!==t||(this.#w(),t.controller.abort(),e.setAttr(V(r),!0,!0,!1))})}#B(e){let t={controller:new AbortController};this.#p=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startShortcutEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","destination"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid shortcut request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("destination",r.destination),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}#R(e){let t={controller:new AbortController};this.#h=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startLinkEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","url"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid link request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("url",r.url),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}requireCapability(e){if(!this.provider||!this.provider.capabilities.includes(e))throw Object.assign(new Error(`${e} is unavailable in this environment`),{code:"UNAVAILABLE"})}attributes(e,t){let r=e.writing;e.writing=!0;try{e._node.setAttr(t,!0,!0,!1)}finally{e.writing=r}}accept(e,t){let r=e.name==="appinfo"?["id","name","version","build"]:["latitude","longitude","accuracy","timestamp"],i=e.name==="appinfo"?"string":"number";for(let l of r)if(typeof t[l]!==i||i==="number"&&!Number.isFinite(t[l]))throw new TypeError(`Invalid ${e.name}.${l} from device provider`);let s=e.cachedValue;if(e.name==="location"&&s&&t.timestamp<s.getItem("timestamp")){this.attributes(e,{status:"success",error:null});return}let o=new x;for(let l of r)o.setItem(l,t[l]);e._lastUpdate=Date.now(),e.failed=!1,e.received++;let a=e.writing;e.writing=!0;try{e._node.setValue(o,!0,{status:"success",error:null},!0,!1)}finally{e.writing=a}}failure(e,t){e.failed=!0,this.attributes(e,V(t))}reconcile(){let e=this.resolvers.get("location");if(e._node.attr.enabled){if(this.monitor)return;let t={stop:null,controller:new AbortController};this.monitor=t,t.start=Promise.resolve(this.cleanup).then(()=>this.disposed||this.monitor!==t?null:(this.requireCapability("location"),this.provider.startLocationUpdates((r,i)=>{if(!(this.disposed||this.monitor!==t))if(i)this.failure(e,i);else try{this.accept(e,r)}catch(s){this.failure(e,s)}},t.controller.signal))),t.start.then(r=>{r===null||this.disposed||this.monitor!==t||(t.stop=r,this.attributes(e,{watching:!0}))}).catch(r=>{!this.disposed&&this.monitor===t&&(this.attributes(e,{watching:!1}),this.failure(e,r))}),this.attributes(e,{status:"pending",error:null})}else if(this.monitor){let t=this.monitor;this.monitor=null,t.controller.abort(),this.retiring=t,this.cleanup=t.start.then(r=>r===null?void 0:r(),()=>{}).then(()=>{if(this.retiring===t&&(this.retiring=null),!this.disposed){let r={watching:!1};!this.monitor&&!e.request&&e._node.attr.status==="pending"&&Object.assign(r,{status:"cancelled",error:null}),this.attributes(e,r)}}),this.cleanup.catch(r=>{this.disposed||this.failure(e,r)})}}async openDatabase(e){if(this.assertLive(),!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(e)||typeof e!="string")throw new TypeError("Invalid database name");if(this.#e)throw new Error("This page already owns a database connection");let t=this.gramlot.data.getNode("gramlot.device.database"),r=(s,o=null)=>{this.disposed||t.setAttr({status:s,error:o},!0,!0,!1)};if(!this.provider.capabilities.includes("database")){let s=Object.assign(new Error("Native database unavailable"),{code:"UNAVAILABLE"});throw r("unavailable",{code:s.code,message:s.message}),s}let i={controller:new AbortController,close:null,start:null};this.#e=i,r("pending"),i.start=this.provider.openDatabase(e,i.controller.signal);try{let s=await i.start,o=!1,a=null,l=()=>a||(o=!0,a=s.close().then(()=>{r("closed")},c=>{throw r("error",{code:"FAILED",message:c.message}),c}).finally(()=>{this.#e===i&&(this.#e=null)}),a);if(i.close=l,this.disposed||i.controller.signal.aborted)throw await l(),Object.assign(new Error("Page closed"),{code:"CANCELLED"});let u=async(c,d,f)=>{if(this.assertLive(),o)throw new Error("Database connection is closed");r("pending");try{let h=await s[c](d,f);return r("success"),h}catch(h){throw r("error",{code:"FAILED",message:h.message}),h}};return r("success"),{query:(c,d=[])=>u("query",c,d),execute:(c,d=[])=>u("execute",c,d),close:l}}catch(s){throw this.#e===i&&(this.#e=null),this.disposed||t.setAttr(V(s),!0,!0,!1),s}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.#e;e?.controller.abort(),e&&(this.cleanup=Promise.all([this.cleanup,e.start.then(()=>e.close?.(),()=>{})]).then(()=>{}));let t=[...this.#a.values()].map(c=>{let d=c.stream;return c.stream=null,d?.controller.abort(),d?d.start.then(f=>f(),()=>{}):c.cleanup});this.#t?.abort(),this.#t=null;let r=this.#n;this.#n=null,r?.controller.abort(),this.#s?.abort(),this.#s=null;let i=[...this.#o.values()];this.#o.clear();for(let c of i)c.controller.abort();let s=this.#h;this.#h=null,s?.controller.abort();let o=this.#p;this.#p=null,o?.controller.abort(),this.#w()?.controller.abort();let a=this.#f;this.#f=null,a?.controller.abort(),this.#i?.abort(),this.#i=null,this.#r?.abort(),this.#r=null,this.#l?.abort(),this.#l=null,this.#c?.abort(),this.#c=null;let l=this.#u;this.#u=null,l?.controller.abort(),this.gramlot.data.unsubscribe("gramlot.device",{any:!0});let u=this.monitor;if(this.monitor=null,u?.controller.abort(),u)this.cleanup=u.start.then(c=>c===null?void 0:c(),()=>{});else if(this.retiring?.stop){let c=this.retiring;this.cleanup=this.cleanup.catch(()=>c.stop())}l&&(this.cleanup=Promise.all([this.cleanup,l.start.then(c=>c(),()=>{})]).then(()=>{})),a&&(this.cleanup=Promise.all([this.cleanup,a.start.then(c=>c(),()=>{})]).then(()=>{})),s&&(this.cleanup=Promise.all([this.cleanup,s.start.then(c=>c(),()=>{})]).then(()=>{})),o&&(this.cleanup=Promise.all([this.cleanup,o.start.then(c=>c(),()=>{})]).then(()=>{})),this.cleanup=Promise.all([this.cleanup,...t,...i.map(c=>c.start.then(d=>d(),()=>{}))]).then(()=>{}),r&&(this.cleanup=Promise.all([this.cleanup,r.start.then(c=>c===null?void 0:c.dispose(),c=>{if(c?.code!=="CANCELLED")throw c})]).then(()=>{})),this.cleanup=this.cleanup.finally(()=>this.releaseProvider?.()),this.cleanup.catch(c=>{this.cleanupError=c});for(let c of this.resolvers.values())c.request=null}};var Kc=2e3;function ub(n){if(!(n instanceof Date))return String(n??"");let e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var oi=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof x))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],r=(i,s)=>{for(let o of i.getNodes()){let a=s+o.label;o.value instanceof x?r(o.value,`${a}.`):t.push(`${a}: ${ub(o.value)}`)}};return r(this.branch(e),""),t.join(`
|
|
196
|
-
`)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>
|
|
197
|
-
<${s}>${i.toXml()}</${s}>`,t,"application/xml")}}saveText(e,t,r){let i=this.document.defaultView,s=i.URL.createObjectURL(new i.Blob([e],{type:r}));this.open(s,t),i.setTimeout(()=>i.URL.revokeObjectURL(s),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var ai=class extends De{constructor(e,t){super(e),this.inout=new oi(e,t)}};var li=class{#e;constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:r="/gramlot/close",rootId:i="gramlot-root",capabilities:s=[],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 ft,nameSyntax:m=null}={}){ms.register(a.defaultView);for(let b of u)b instanceof It&&b.register(a.defaultView);this.commands=new tn,this.pageId=e;let p=c==null||d==null?a.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??p.locale,this.timeZone=d??p.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Ls(this)}),this.capabilities=Object.freeze([...s]),this.serverAdapter=h,this.src=new ti(this,{collections:u,destination:o??a.getElementById(i),subscriptions:this._subscriptions,nameSyntax:m===null?Un:rr.fromJSON(m)}),this.#e=en.install({document:a,root:this.src.renderer.destination}),this.data=this.src.builder.data,this.dvc=new si(this),this.rpc=new ni(this,{rpcUrl:t,closeUrl:r,document:a,transport:l}),this.dom=new ii(this),this.utl=new ai(this,a),this.state="ready",this._subscriptions.attach(a),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=b=>{b.persisted||this.dispose()},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 wc(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.callEnvelope("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.value,e.data)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose(){if(this.state!=="disposed"){this.state="disposed",this.dvc.dispose(),this.#e.dispose(),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{if(this.rpc.transport)try{this.rpc.transport.close(this.pageId)}finally{this.rpc.transport.dispose()}}}}};var wa=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new ft}async run(){let{config:e,resources:t,document:r}=this,i=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let s=!1,o,a,l=[],u=new Promise(d=>{o=d}),c=d=>{if(!(d.persisted||s)){s=!0;try{this.closePage()}finally{o(null)}}};i.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((w,E)=>{let D=r.createElement("link");D.rel="stylesheet",D.href=_;let y=()=>{D.removeEventListener("load",T),D.removeEventListener("error",S)};l.push(y);let T=()=>{y(),w()},S=()=>{y(),E(new Error(`${_}: stylesheet load failed`))};D.addEventListener("load",T),D.addEventListener("error",S),r.head.append(D)})),f=t.js.map(async({url:_,group:w})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:w,resource:_}}catch(E){throw new Error(`${_}: import failed: ${E.message}`,{cause:E})}}),h=new Set,m=(t.collections??[]).map(async _=>{if(!_||typeof _!="object"||Object.keys(_).sort().join(",")!=="buildId,name,url"||typeof _.name!="string"||typeof _.url!="string"||typeof _.buildId!="string"||!/^sha256:[0-9a-f]{64}$/.test(_.buildId)||h.has(_.name))throw new TypeError("Invalid or duplicate collection bootstrap record");h.add(_.name);let{name:w,url:E,buildId:D}=_,y;try{y=await import(new URL(E,r.baseURI).href)}catch(T){throw new Error(`${w}: collection import failed: ${T.message}`,{cause:T})}if(y.default?.name!==w||y.buildId!==D)throw new Error(`${w}: collection identity mismatch; expected ${D}, received ${y.buildId}`);return y.default}),p=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(m)]),u]);if(s)return null;let[,b,g]=p;Jr.check(b);for(let _ of g)_.register(i);a=new li({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...g.map(_=>_.toDocument())]}),i.removeEventListener("pagehide",c);for(let _ of g)_.registerCommands(a);for(let{logicClass:_,group:w,resource:E}of b)a.src.logicRegistry.register(_,{group:w,resource:E});return i.gramlot=a,await a.start(),a}catch(d){throw a?a.dispose():s||this.closePage(),d}finally{for(let d of l)d();i.removeEventListener("pagehide",c)}}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(r){throw new Error(`${e}: server adapter import failed: ${r.message}`,{cause:r})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});try{e.close(this.config.pageId)}finally{e.dispose()}}};var js=Symbol("gramlot.source"),ya=Symbol("gramlot.endpoint"),cb=new Map([[js,"registerSource"],[ya,"registerEndpoint"]]);function Qc(n,e,t,r){let i=cb.get(t);if(e==="main")throw new TypeError(`${i} cannot declare main`);let s=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof s!="function")throw new TypeError(`${i} requires an own method of ${n.name}: ${String(e)}`);if(s[t])throw new TypeError(`${t===js?"Source method":"Endpoint"} already registered: ${e}`);if(s[js]||s[ya])throw new TypeError(`${e} is declared both as Source method and endpoint`);s[t]={auth:r}}var Fs=class{static registerSource(e,{auth:t=null}={}){Qc(this,e,js,t)}static registerEndpoint(e,{auth:t=null}={}){Qc(this,e,ya,t)}},ui=class extends Fs{static gramlots=[];static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:r}=this.constructor;if(typeof r!="string"||!r)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+r.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=Oe;main(e){throw new Error("Page.main(root) must be implemented")}};var Kr=class extends ui{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}),r=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let i of["top","bottom","left","right","center"])if(this[i]!==void 0){let s=r.contentPane({region:i,node_label:i});this[i](s)}this.behavior(t)}center(e){}behavior(e){}};var ci=class extends Kr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:r}=this.constructor;if(!(t instanceof x))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${r}.navigation`,value:t}),e.dataSetter({destination_path:`${r}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${r}.active`,value:null}),e.dataSetter({destination_path:`${r}.opened`,value:new x}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:".navigation",labelAttribute:"title",hideValues:!0,selectedPath:"^.navigationSelection"})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:"^.active"})}behavior(e){e.dataController({func:"indexMount",_onStart:!0})}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})}};ci.registerSource("index_panel");function va(n,e,t=()=>{},r=()=>{},{state:i=e.getRelativeData("."),createEntry:s=null,onLoad:o=()=>{}}={}){let a=i.getItem("navigation");if(!(a instanceof x))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d={entries:c,disposed:!1,selecting:!1,sequence:0,requested:null};Object.defineProperty(e,"indexContext",{value:d,configurable:!0});let f=i.getItem("opened");for(let y of f.getNodes()){let{url:T,path:S,title:I}=y.attr,W=l.value.getNode(y.label),ee={url:T,path:S,title:I,pane:W,node:a.getNode(S),loading:!1};r(ee),c.set(T,ee),d.sequence++}let h=(y,T,S)=>{try{o(y.url,T,S)}catch(I){n.binding.reportError(I,"Page load callback failed")}},m=(y,T,S)=>{y.loading&&(y.loading=!1,h(y,T,S))},p=y=>{if(!d.disposed){d.selecting=!0;try{i.setItem("active",y.url),i.setItem("navigationSelection",y.path),t(c,y.url)}finally{d.selecting=!1}}};function b(y){g(y).catch(T=>{d.disposed||n.binding.reportError(T,"Page could not be opened")})}async function g(y){let T=a.getNode(y);if(!T)throw new Error(`Unknown index navigation path: ${y}`);let S=T.attr.url;if(S==null)return;if(typeof S!="string"||!S)throw new TypeError("IndexPage URL must be nonempty text");d.requested=S;let I=c.get(S);if(I){I.path=y,p(I);return}for(;l.value!==null&&l.value.getNode(`page${d.sequence}`);)d.sequence++;let W=J(u.wrapSource(l).contentPane({node_label:`page${d.sequence++}`,title:T.attr.title??T.label,pageName:S,height:"100%",closable:!0})),ee=i.getItem("active");I={url:S,path:y,node:T,pane:W,title:T.attr.title??T.label,loading:!0},c.set(S,I);try{if(h(I,"loading"),d.disposed||c.get(S)!==I||(p(I),d.disposed||c.get(S)!==I))return;if(s)await s(I);else{let se=new x;if(se.setItem(T.label,null,{...T.attr}),!await n.binding.gramlot.src.remoteSource(W,"index_panel",{selection:se}))throw new Error("Panel loading was cancelled")}if(d.disposed||c.get(S)!==I)return;f.setItem(W.label,null,{url:S,path:I.path,title:I.title}),r(I)}catch(se){if(d.disposed||c.get(S)!==I)return;try{if(n.binding.reportError(se,"Page could not be opened"),c.delete(S),f.getNode(W.label)&&f.popNode(W.label),W.parentBag&&W.parentBag.popNode(W.label),!d.disposed&&d.requested===S){let he=c.get(ee);if(d.requested=he?.url??null,he)p(he);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}}finally{m(I,"error",se)}return}d.disposed||c.get(S)!==I||(m(I,"ready"),!d.disposed&&c.get(S)===I&&d.requested===S&&p(I))}let _=`${e.getAttr("id")}-page-close`;e.value.subscribe(_,{any:y=>{if(y.evt!=="del")return;let T=[...c.values()].find(W=>W.pane===y.node);if(!T)return;let{url:S,pane:I}=T;if(!(d.disposed||n.disposed||c.get(S)!==T)){c.delete(S),f.getNode(I.label)&&f.popNode(I.label);try{if(i.getItem("active")===S){let W=[...c.values()].at(-1);if(d.requested=W?.url??null,W)p(W);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}else t(c,i.getItem("active"))}finally{m(T,"cancelled")}}}});let w=`${e.getAttr("id")}-selection`;i.subscribe(w,{any:y=>{if(!(d.selecting||d.disposed)){if(y.node===i.getNode("navigationSelection")){let T=i.getItem("navigationSelection");T!==null&&b(T)}else if(y.node===i.getNode("active")){let T=c.get(i.getItem("active"));T&&(d.requested=T.url,p(T))}}}});let E=()=>{if(!d.disposed){d.disposed=!0,i.unsubscribe(w,{any:!0}),e.value.unsubscribe(_,{any:!0});for(let y of c.values())y.loading&&(y.pane.parentBag&&y.pane.parentBag.popNode(y.pane.label),m(y,"cancelled"));c.clear(),e.indexContext===d&&delete e.indexContext}};d.dispose=E,n.onDispose(e,E);let D=c.get(i.getItem("active"));return D?p(D):i.getItem("navigationSelection")!==null&&b(i.getItem("navigationSelection")),d}var qs=class{indexMount(e){va(this.page.src.renderer,e.parentNode)}};function Us(n,{datapath:e,value:t,language:r="text",height:i="420px",...s}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=n.borderContainer({datapath:e,height:i,class:"gramlot-editor-options"}),a={language:r,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({...s,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var di=class n extends We{static internalParams=new Set([...We.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:r},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:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))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 r=new n({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},fi=class{constructor(e,t){this.gramlot=e,this.source=t,this.request=null,this.resolver=null,this.disposed=!1}get state(){return this.source.getRelativeData(".")}async open(e){this.request?.abort();let t=this.request=new AbortController;this.state.setItem("status","Opening directory\u2026");try{let r=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let i=new di({gramlot:this.gramlot,root:r.root,onError:o=>this.state.setItem("status",o.message)}),s=i.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=i,this.state.setItem("selectedPath",null),this.state.setItem("store",s),this.state.setItem("writable",r.writable),this.state.setItem("root",r.root),this.state.setItem("status",""),r.root}catch(r){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",r.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},lr=class{fileSystemMount(e){let t=e.parentNode,r=new fi(this.page,t);Object.defineProperty(t,"fileSystemController",{value:r,configurable:!0}),this.page.src.renderer.onDispose(t,()=>r.dispose())}fileSystemOpen(e,{root:t}){if(t)return e.parentNode.fileSystemController.open(t)}};function ed(n,{datapath:e,...t}){let r=n.div({datapath:e,class:"gramlot-filesystem",...t});return r.dataSetter({destination_path:".store",value:new x}),r.dataSetter({destination_path:".root",value:null}),r.dataSetter({destination_path:".requestedRoot",value:null}),r.dataSetter({destination_path:".selectedPath",value:null}),r.dataSetter({destination_path:".status",value:""}),r.dataController({func:"fileSystemMount",_onBuilt:!0}),r.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),r.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),r.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),r}var db=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Vs=class{constructor(e,t){this.gramlot=e,this.source=t,this.pending=new Map,this.disposed=!1}get state(){return this.source.getRelativeData(".")}get documents(){return this.state.getItem("documents")}async open(e,t){let r=db(e,t),i=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(i)return i.label;if(this.pending.has(r))return this.pending.get(r).promise;let s=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:s.signal}).then(a=>{if(this.disposed||s.signal.aborted)return null;let l=new x;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(r,l),r}).finally(()=>this.pending.delete(r));return this.pending.set(r,{request:s,promise:o}),o}newDocument(e,t,r=""){let i=`new_${Q()}`,s=new x;for(let[o,a]of Object.entries({language:e,root:r,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:r,savePath:`Untitled${t}`}))s.setItem(o,a);return this.documents.setItem(i,s),i}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("saveRoot"),i=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==i.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let s=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:r,path:i,content:s},{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",s),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 r=t.getItem("content"),i=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 s=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!i.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:i,promise:s}),s}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 r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:i,promise:s}),s}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()}},zs=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(r=>typeof r!="string"||!r))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(r=>r!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new x;return e.forEach((r,i)=>t.setItem(`r${i}`,r,{caption:r})),t}};function Re(n){for(let e=n;e;e=e.parentNode){let t=e.ideContext;if(t)return t}throw new Error("IDE operation requires a node inside a mounted IDE")}var Hs=class{fileSystemMount(e){return lr.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return lr.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){let t=e.parentNode,r={scope:t,documents:new Vs(this.page,t),requested:0,editorPrefix:`ide_${Q()}`,recent:new zs(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage)};Object.defineProperty(t,"ideContext",{value:r,configurable:!0});let{documents:i,recent:s}=r,o=t.getRelativeData("."),a=s.read();o.setItem("recent",s.choices(a)),o.setItem("workspace",a[0]??"");let l=o.getItem("browser");l.subscribe("ide-browser",{any:c=>{if(c.node===l.getNode("root")){let d=l.getItem("root");o.setItem("workspace",d),o.setItem("recent",s.choices(s.remember(d))),o.setItem("status",`Workspace: ${d}`)}else if(c.node===l.getNode("selectedPath")){let d=l.getItem("selectedPath"),f=d===null?null:l.getItem("store").getNode(d);f&&!f.attr.is_directory&&this.ideOpenDocument(t,l.getItem("root"),f.attr.path)}}});let u=i.documents;u.subscribe("ide-documents",{any:c=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(c.node.label))for(let d of t.value.getNode("frame.center.tabs").value?.getNodes()??[]){let f=d.getAttr("documentKey"),h=i.documents.getItem(f);h&&(c.node===h.getNode("content")&&i.invalidateRecipe(f),this.ideDocumentState(t,f),d.setAttr({title:`${i.dirty(f)?"\u25CF ":""}${h.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(r.scope,()=>{l.unsubscribe("ide-browser",{any:!0}),u.unsubscribe("ide-documents",{any:!0}),i.dispose()})}ideOpenWorkspace(e){let r=Re(e).scope.getRelativeData("."),i=r.getItem("workspace");i&&i!==r.getItem("browser.root")&&r.setItem("browser.requestedRoot",i)}ideDocumentState(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t),o=!i.dirty(t)&&!s.getItem("isNew")||s.getItem("busy");s.setItem("saveDisabled",!!(o||!s.getItem("writable"))),s.setItem("revertDisabled",!!(!i.dirty(t)||s.getItem("busy"))),s.setItem("displayPath",s.getItem("isNew")?s.getItem("path"):`${s.getItem("root")}/${s.getItem("path")}`),s.setItem("pdfFilename",s.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),s.setItem("renderDisabled",!!(s.getItem("busy")||!s.getItem("writable"))),this.ideHistoryState(s)}async ideOpenDocument(e,t,r){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=++i.requested;try{let l=await s.open(t,r);if(l===null||s.disposed)return;this.ideShowDocument(e,l),a===i.requested&&(o.setItem("active",l),o.setItem("status",`${r}${s.documents.getItem(l).getItem("writable")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}catch(l){s.disposed||o.setItem("status",l.message)}}ideNew(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=i.getItem("newType"),o=s==="typstRecipe"?"python":s,a={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"},l=r.newDocument(o,a[s],i.getItem("workspace"));r.documents.getItem(l).setItem("writable",i.getItem("browser.writable")===!0),++t.requested,this.ideShowDocument(e,l),i.setItem("active",l),i.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e,t){let r=Re(e),{documents:i}=r,o=i.documents.getItem(t).getItem("path"),a=r.scope.value.getNode("frame.center.tabs");if(!a.value?.getNode(t)){let l=i.documents.getItem(t),u=o.endsWith(".typ.py");u&&i.invalidateRecipe(t),l.setItem("readonly",!1),this.ideDocumentState(e,t),l.setItem("view","code"),l.setItem("createHidden",!0),l.setItem("undoDisabled",!0),l.setItem("redoDisabled",!0);let c=J(a.builder.wrapSource(a).contentPane({node_label:t,title:o,pageName:t,documentKey:t,closable:!0,onClose:"ideClose",height:"100%"})),d=c.builder.wrapSource(c).div({display:"flex",flex_direction:"column",height:"100%"}),f=d.div({datapath:`.documents.${t}`,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 ${o}`});for(let[y,T,S,I]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 W=f.button({title:S,"aria-label":S,disabled:`^.${y}Disabled`,class:`button--quiet gramlot-ide-${y}`});W.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:T}),W.dataController({func:I,documentKey:t})}u&&f.button("Generate preview",{disabled:"^.renderDisabled",class:"button--quiet"}).dataController({func:"ideRenderRecipe",documentKey:t}),f.div("^.displayPath",{class:"gramlot-ide-document-path",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap",min_width:0,flex:"1"});let h=d.div({datapath:`.documents.${t}`,hidden:"^.createHidden",padding:"8px 12px",display:"flex",gap:"8px",align_items:"end",flex_shrink:0});h.textbox({value:"^.saveRoot",lbl:"Directory",flex:"1",disabled:"^.busy"}),h.textbox({value:"^.savePath",lbl:"File name",flex:"1",disabled:"^.busy"}),h.button("Create file",{disabled:"^.busy"}).dataController({func:"ideCreate",documentKey:t}),h.button("Cancel",{disabled:"^.busy",class:"button--quiet"}).dataController({func:"ideCancelCreate",documentKey:t});let m=d.div({flex:"1",min_height:0}),p=l.getItem("language")==="html",b=l.getItem("language")==="markdown",g=p||b,_=l.getItem("language")==="typst",w=g||_||u,E=w?m.tabContainer({height:"100%",selectedPage:`^.documents.${t}.view`}):null,D=w?E.contentPane({title:"Code",pageName:"code",height:"100%"}):m;if(Us(D,{datapath:`.documents.${t}`,value:"^.content",language:l.getItem("language"),height:"100%",readonly:"^.readonly",nodeId:`${r.editorPrefix}_editor_${t}`,editorView:"code",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_editor_${t}_save`]:!0}),_&&E.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${t}.content`,filename:`^.documents.${t}.pdfFilename`,height:"100%"}),u){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});y.div(`^.documents.${t}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),y.typstPreview({value:`^.documents.${t}.typstSource`,filename:`^.documents.${t}.pdfFilename`,hidden:`^.documents.${t}.previewHidden`,flex:"1",min_height:0}),E.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${t}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(g){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});b&&(l.setItem("allowHtml",!1),y.checkbox({value:`^.documents.${t}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),y[p?"htmlPreview":"markdownPreview"]({value:`^.documents.${t}.content`,flex:"1",min_height:0,...b?{allowHtml:`^.documents.${t}.allowHtml`}:{}}),E.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[p?"htmlEditor":"markdownEditor"]({datapath:`.documents.${t}`,value:"^.content",readonly:"^.readonly",height:"100%",nodeId:`${r.editorPrefix}_rich_editor_${t}`,editorView:"rich",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_rich_editor_${t}_save`]:!0})}}}async ideRenderRecipe(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("view","preview"),await i.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");s.setItem("status","Creating file\u2026");try{let o=await i.create(t);if(!i.disposed&&o){s.setItem("status","File created.");let a=s.getItem("browser");a.getItem("root")&&await r.scope.value.getNode("frame.left.browser").fileSystemController.open(a.getItem("root"))}}catch(o){i.disposed||s.setItem("status",o.message)}}async ideSave(e,{documentKey:t=null}={}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData("."),o=t??s.getItem("active");if(!o||i.documents.getItem(o).getItem("saveDisabled"))return;let a=i.documents.getItem(o);if(a.getItem("isNew")){a.setItem("createHidden",!1);return}s.setItem("status","Saving\u2026");try{let l=await i.save(o);i.disposed||s.setItem("status",l?"Saved.":"Document is read only or a request is pending.")}catch(l){i.disposed||s.setItem("status",l.message)}}ideRevert(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");i.revert(t)&&s.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let i=e.getRelativeData("."),s=e.getAttr("editorView");i.setItem(`${s}CanUndo`,t),i.setItem(`${s}CanRedo`,r),this.ideHistoryState(i)}ideHistoryState(e){let t=e.getItem("view");e.setItem("undoDisabled",!e.getItem(`${t}CanUndo`)),e.setItem("redoDisabled",!e.getItem(`${t}CanRedo`))}ideEditor(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t).getItem("view")==="rich",o=this.page.src.binding.nodeIds.get(`${r.editorPrefix}_${s?"rich_":""}editor_${t}`);return this.page.src.renderer.records.get(o).element}ideUndo(e,{documentKey:t}){this.ideEditor(e,t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(e,t).redo()}ideClose(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=e.getAttr("documentKey");return r.canClose(s)?!0:(i.setItem("status","Save or revert your changes before closing. Pending operations must finish first."),!1)}ideClosed(e,{pageName:t}){this.ideForgetDocument(e,t)}ideForgetDocument(e,t,r=!1){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=s.documents.getItem(t),l=o.getItem("browser"),u=l.getItem("selectedPath"),c=u===null?null:l.getItem("store").getNode(u);a&&l.getItem("root")===a.getItem("root")&&c?.attr.path===a.getItem("path")&&l.setItem("selectedPath",null),s.close(t,r)}};var Ea=class n extends We{static internalParams=new Set([...We.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:r,onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method=t,this.params={directory:r},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:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))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 r=new n({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function ur(n,e){return e===2?n%4===0&&(n%100!==0||n%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function $e(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>ur(n,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(n).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function cr(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=n.split("-").map(Number);return $e(...e),e}function hi(n,e,t){let r=n-1,i=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let s=1;s<e;s++)i+=ur(n,s);return i}function pi(n,e){let t=hi(...cr(n))+e;if(!Number.isSafeInteger(t)||t<0||t>hi(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,i=1e4;for(;i-r>1;){let o=Math.floor((r+i)/2);hi(o,1,1)<=t?r=o:i=o}t-=hi(r,1,1);let s=1;for(;t>=ur(r,s);)t-=ur(r,s++);return $e(r,s,t+1)}function xa(n){return pi(n,-(hi(...cr(n))%7))}function td(n,e,t=0,r=1){let i=n*12+e-1+t,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+r-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:$e(s,o,1),end:$e(l,u,ur(l,u))}}var Ws={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"}},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"}}};function rd(n){if(typeof n!="string")throw new RangeError("A supported locale is required.");let e=n.replaceAll("-","_"),t=e.indexOf("_"),r=(t<0?e:e.slice(0,t)).toLowerCase(),i=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(Ws,r))throw new RangeError(`Unsupported locale: ${n}`);let s=Ws[r];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...Ws.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var dr=/^(?:\d{4}|\d{2})$/,nd=/^\d{1,2}$/,mi=(n,e)=>({ok:!1,error:{code:n,message:e}}),hr=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},od=(n,e)=>Object.hasOwn(n,e);function fr(n,e){if(n.length===4)return Number(n);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(n)-t)%100+100)%100}function fb(n,e){if(n.includes(";")){let i=n.split(";").map(s=>s.trim());return i.length!==2?hr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let i of t)if(n.startsWith(`${i} `))return{bounds:["",n.slice(i.length+1).trim()],range:!0};for(let i of t){let s=` ${i} `;if(!n.includes(s))continue;for(let a of r)if(n.startsWith(`${a} `)){n=n.slice(a.length+1);break}let o=n.split(s).map(a=>a.trim());return o.length!==2?hr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of r)if(n.startsWith(`${i} `))return{bounds:[n.slice(i.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function hb(n,e,t){let r=[[n,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);i&&r.push([i[1],Number(i[2]+i[3])]);let s={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 r)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return pi(xa(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=td(e.year,e.month,u+a);return t?c.end:c.start}return pi(e.workdate,u+a)}return null}function pb(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of r){let o;if(n===i)o=null;else if(n.startsWith(i)&&dr.test(n.slice(i.length).trim()))o=fr(n.slice(i.length).trim(),e);else if(n.endsWith(i)&&dr.test(n.slice(0,-i.length).trim()))o=fr(n.slice(0,-i.length).trim(),e);else continue;return{year:o,month:t?s*3:s*3-2}}return null}function id(n,e){if(od(e.months,n))return e.months[n];let t=/^m(\d{1,2})$/.exec(n);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function mb(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>id(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return hr();let i=r[0],s=id(t[i],e.dictionary),o=t.slice(0,i),a=t.slice(i+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(s>e.month?1:0),month:s};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(s<e.month?1:0),month:s};if(!l.length)return{year:null,month:s};if(!o.length&&a.length===1&&dr.test(a[0]))return{year:fr(a[0],e),month:s};if(o.length===1&&nd.test(o[0])){if(!a.length)return $e(e.year,s,Number(o[0]));if(a.length===1&&dr.test(a[0]))return $e(fr(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&nd.test(a[0])&&dr.test(a[1])?$e(fr(a[1],e),s,Number(a[0])):hr()}function gb(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return $e(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),i={};if(r)e.order.split("").forEach((a,l)=>{i[a]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let a=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!dr.test(i.Y)||i.D.length>2||i.M.length>2)return hr();let s=Number(i.D),o=Number(i.M);return r&&o>12&&s<=12&&([s,o]=[o,s]),$e(fr(i.Y,e),o,s)}function sd(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(s=>!r.includes(s)).join(" "),!n)return hr();if(dr.test(n))return $e(fr(n,e),t?12:1,t?31:1);let i=hb(n,e,t)??pb(n,e,t)??mb(n,e);return i!==null?i:od(e.dictionary.weekdays,n)?pi(xa(e.workdate),e.dictionary.weekdays[n]):gb(n,e)??hr()}function bb(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,i=typeof e=="string"?cr(e)[0]:e?.year,s=typeof e=="string"?cr(e)[1]:e?.month;return i&&(r>i&&(r=i),r===i&&n.month>s&&r--),$e(r,n.month,1)}function _b(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[i,s]=cr(e);r<i&&(r=i),r===i&&s>n.month&&r++}return $e(r,n.month,ur(r,n.month))}function ad(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return mi("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=cr(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...rd(r),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(r){return mi("INVALID_CONTEXT",r.message)}if(typeof n!="string")return mi("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=fb(r,t),o=sd(i[1],t,!0),a=sd(i[0],t,!1),l=bb(a,o,t),u=_b(o,l,t);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return mi("INVALID_DATE",r.message);if(r instanceof SyntaxError)return mi(r.code,r.message);throw r}}function ka(n){return class extends n{setLabelbox(e){let{box:t,labelBox:r,fieldLabel:i}=e;Object.assign(this,{box:t,labelBox:r,fieldLabel:i}),i.addEventListener("click",()=>{this.control.focus(),this.control.localName==="input"&&["checkbox","radio"].includes(this.control.type)&&this.control.click()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.lbl??"";return i?this.control.setAttribute("aria-label",i):this.control.removeAttribute("aria-label"),r}}}ka.labelbox=!0;ka.parameters={lbl:{dtype:"T",qualification:"intl_str",nullable:!0,binding:"read"},lbl_position:{dtype:"T",default:"TL",binding:"read",enum:ra}};var Da=["select","notnull","empty","case","len","min","max","email","regex","call","remote"],wb=["nodup","exist","gridnodup"],Gs=n=>n==null||n==="",Aa=(n,e)=>n instanceof Promise?n.then(e):e(n);function ld(n,e,t={}){let r={value:n,modified:!1,error:null,warnings:[],issues:[],datachanges:[]},i=Object.fromEntries(Object.entries(e).map(([u,c])=>[u.slice(9),c])),s=u=>Object.hasOwn(e,`validate_${u}`)&&e[`validate_${u}`]!=null;for(let u of wb)if(s(u))throw new Error(`validate_${u} requires the DB/grid integration.`);let o=(u,c,d=!1)=>t.invoke(u,e[u],{...i,value:c,result:r,validations:i,userChange:!0,signal:t.signal},d),a=(u,c)=>{if(c==null||c===!0)return;if(typeof c!="boolean"&&typeof c!="string"&&(typeof c!="object"||Array.isArray(c)))throw new TypeError("A validator returns true, false, null, an error code, or a result object/Bag.");let d=`validate_${u}`,f=c instanceof x?Object.fromEntries(c.getNodes().map(g=>[g.label,g.value])):typeof c=="object"?c:{errorcode:c===!1?"error":c};if(Object.hasOwn(f,"value")&&(r.modified||=!Object.is(r.value,f.value),r.value=f.value),f.data!=null&&(t.checkDataPatch(f.data),r.datachanges.push(f.data)),!f.errorcode)return;let h=e[`${d}_iswarning`]??f.iswarning??!!(e[`${d}_warning`]&&!e[`${d}_error`]),m=e[`${d}_${f.errorcode}`]||e[`${d}_${h?"warning":"error"}`]||f.message||e[`${d}_${h?"error":"warning"}`]||String(f.errorcode),p=Pt(m,g=>g?{...i,...f,value:r.value}[g]:r.value);if(p==null)throw new Error("A validation message references a missing value.");let b={rule:u,code:f.errorcode,severity:h?"warning":"error",message:p};r.issues.push(b),h?r.warnings.push(p):(r.error=p,r.required=!!f.required)},l=u=>{if(t.signal?.aborted)throw t.signal.reason;if(r.error||u===Da.length)return r;let c=Da[u],d=`validate_${c}`,f=e[d];if(!s(c)||f===!1&&c!=="empty")return l(u+1);let h=p=>{if(!p)return l(u+1);let b;return c==="remote"&&r.value==null?l(u+1):(c==="call"?b=o(d,r.value):c==="remote"?b=t.remote(f,{...yb(e),value:r.value},t.signal):b=vb(c,f,r.value,t),Aa(b,g=>{if(t.signal?.aborted)throw t.signal.reason;let _=()=>(a(c,g),l(u+1));return c==="remote"&&e.validate__onResult?Aa(t.invoke("validate__onResult",e.validate__onResult,{result:g,value:r.value,validations:i,signal:t.signal}),_):_()}))},m=e[`${d}_if`];return Aa(m==null?!0:typeof m=="boolean"?m:o(`${d}_if`,r.value,!0),h)};return l(0)}function yb(n){let e=new Set(["if","error","warning","iswarning"]);return Object.fromEntries(Object.entries(n).filter(([t])=>t.startsWith("validate_remote_")&&!e.has(t.slice(16))).map(([t,r])=>[t.slice(16),r]))}function gi(n,e,t={}){return{errorcode:n,message:e,...t}}function vb(n,e,t,r){if(n==="select")return r.selection(t);if(n==="notnull")return Gs(t)&&e?gi("notnull","A value is required.",{required:!0}):null;if(n==="empty")return Gs(t)?{value:e}:null;if(n==="len"){if(typeof e!="string"||!/^(?:\d+|\d+:\d*|:\d+)$/.test(e))throw new Error("Invalid validate_len: use a length or min:max.");let[i,s]=e.split(":"),o=Number(i||0),a=s===void 0?o:s===""?1/0:Number(s);if(o>a)throw new Error("Invalid validate_len: minimum exceeds maximum.");if(Gs(t))return;if(typeof t!="string")throw new TypeError("validate_len requires a text value.");return t.length<o||t.length>a?gi(o===a?"wrong length":t.length<o?"too short":"too long",o===a?`Enter exactly ${o} characters.`:a===1/0?`Enter at least ${o} characters.`:o===0?`Enter no more than ${a} characters.`:`Enter between ${o} and ${a} characters.`):void 0}if(!Gs(t)){if(n==="case"){if(typeof t!="string")throw new TypeError("validate_case requires a text value.");switch(e){case"upper":case"u":return{value:t.toUpperCase()};case"lower":case"l":return{value:t.toLowerCase()};case"title":case"t":return{value:t.replace(/\p{L}[\p{L}\p{M}]*/gu,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())};case"capitalize":case"c":return{value:t[0].toUpperCase()+t.slice(1).toLowerCase()};default:throw new Error("Invalid validate_case: use upper, lower, title or capitalize.")}}if(n==="min"||n==="max"){let i;if(r.isDecimal?.(t))i=t.comparedTo(e);else if(t instanceof Date&&e instanceof Date)i=t.getTime()-e.getTime();else if(typeof t=="number"&&Number.isFinite(t)&&typeof e=="number"&&Number.isFinite(e))i=t-e;else throw new TypeError(`validate_${n} requires matching numeric or date/time values.`);return(n==="min"?i<0:i>0)?gi(n,`Value must be ${n==="min"?"at least":"at most"} ${e}.`):void 0}if(n==="email"){if(typeof t!="string")throw new TypeError("validate_email requires a text value.");return/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(t)?null:gi("email","Check email format.",{iswarning:!0})}if(n==="regex"){if(typeof t!="string"||typeof e!="string")throw new TypeError("validate_regex requires text.");let i=e.trim(),s=i.startsWith("!");return new RegExp(s?i.slice(1):i,"u").test(t)!==s?null:gi("regex","The value does not match the required pattern.")}}}var bi={dtype:"T",nullable:!0,binding:"read"},Xs={dtype:"B",nullable:!0,binding:"read"},Ta={dtype:["T","L","N","R","B","D","H","DH","DHZ"],nullable:!0,binding:"read"},ud={validate_select:Xs,validate_notnull:{...Xs,default:!1},validate_empty:Ta,validate_case:{...bi,enum:["upper","lower","title","capitalize","u","l","t","c"]},validate_len:bi,validate_min:Ta,validate_max:Ta,validate_email:Xs,validate_regex:bi,validate_call:{dtype:"T",nullable:!0},validate_remote:bi,validate_onAccept:{dtype:"T",nullable:!0},validate_onReject:{dtype:"T",nullable:!0},validate__onResult:{dtype:"T",nullable:!0},validate_timeout:{dtype:"L",nullable:!0,binding:"read"},...Object.fromEntries(Da.flatMap(n=>[[`validate_${n}_if`,{dtype:["T","B"],nullable:!0}],[`validate_${n}_iswarning`,Xs],...["error","warning"].map(e=>[`validate_${n}_${e}`,{...bi,qualification:"intl_str"}])]))};var Eb=1800,cd=200;function dd(n){return class extends n{#e=!1;#t;#r;#n;#i;#s=0;#o;#a={};validationResult=null;constructor(){super(),this.message=this.ownerDocument.createElement("small"),this.message.id="field-message",this.message.hidden=!0,this.message.setAttribute("aria-live","polite"),this.message.setAttribute("popover","manual"),this.message.setAttribute("role","tooltip");let e=this.ownerDocument.createElement("style");e.textContent=`#control[aria-invalid="true"]{background:var(--gramlot-error-background,#fff1f0)}
|
|
193
|
+
`))})}#o(e,t,r){let i=this.#e.gramlot,s=JSON.stringify([t,e]);if(this.#i.has(s))return;let o=this.#e.nodeIds.get(this.#t);if(!o){if(this.#n.clear(),this.#s=0,this.#r===null){let m=this;class p{close(g){m.#a(g.getAttr("notice"))}}this.#r=`errors_${Y()}`,this.#e.logicRegistry.register(p,{group:this.#r,resource:"gramlot:error-notifications"})}let h=new Oe;h.root.aside({nodeId:this.#t,class:"gramlot-error-notifications",popover:"manual","aria-label":"Error notifications",style:"position:fixed;inset:auto max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) auto;margin:0;width:360px;max-width:calc(100vw - 24px);max-height:50vh;overflow:auto;box-sizing:border-box;padding:0;border:1px solid var(--gramlot-border-control,#aab4c2);border-radius:8px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#222);font:13px/1.4 system-ui;box-shadow:0 6px 24px #0003;"}),i.src.source.setItem(this.#t,i.src.prepareSource(h.source)),o=this.#e.nodeIds.get(this.#t)}if(this.#n.has(s))return;if(this.#n.size===5){let h=`${++this.#s} additional errors`,m=o.value.getNode("overflow");m?m.setValue(h):i.src.builder.wrapSource(o).p(h,{node_label:"overflow",role:"status",style:"margin:0;padding:12px;"});return}let a=`notice_${Y()}`,l=new Oe,u=l.root.article({role:"alert",style:"color:inherit;padding:12px;border-bottom:1px solid var(--gramlot-border,#ddd);"}),c=u.div({style:"display:flex;align-items:start;gap:12px;"});c.strong(`==${JSON.stringify(t)}`,{style:"flex:1;color:var(--gramlot-error,#b13d48);"}),c.html_button("\xD7",{type:"button",notice:a,connect_onclick:`${this.#r}.close`,"aria-label":"Dismiss notification",title:"Dismiss notification",style:"border:0;background:transparent;color:inherit;font:18px/1 system-ui;width:24px;height:24px;flex:0 0 24px;padding:0;cursor:pointer;"}),u.p(`==${JSON.stringify(e)}`,{style:"margin:6px 0;overflow-wrap:anywhere;"});let d=u.details({style:"border:0;padding:0;margin:8px 0 0;background:transparent;"});d.summary("Details",{style:"cursor:pointer;"}),d.pre(`==${JSON.stringify(r)}`,{style:"font:11px/1.4 monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0 0;padding:8px;border:0;border-radius:4px;background:var(--gramlot-surface-subtle,#f2f4f6);"});let f=i.src.builder.wrapSource(o).div({node_label:a});K(f).setValue(i.src.prepareSource(l.source)),this.#n.set(s,a),i.dom.getDomNode(o).showPopover()}#a(e){this.#e.nodeIds.get(this.#t).value.popNode(e);for(let[r,i]of this.#n)i===e&&(this.#n.delete(r),this.#i.add(r));this.#n.size||this.#e.gramlot.src.source.popNode(this.#t)}};var Xc={dataFormula:Ns,dataController:Is,dataRpc:Os,dataRemote:Bs},ab=["datapath","_anchor","nodeId","form","formId"],Kr=class{#e;#t=new Map;#r=new Map;#n;#i;#s;#o;#a;#l;#c=`gramlot-data-${Y()}`;#u=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#l=t,this.#n=new Ds(this),this.#i=new Cs(this),this.#s=new Rs(this),this.#o=new Ps(this),this.#a=new Ls(this)}get gramlot(){return this.#e}reportError(e,t){this.disposed||this.#a.show(e,t)}get subscriptions(){return this.#l}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.#u}get router(){return this.#n}get installer(){return this.#i}get inlineCompiler(){return this.#s}get askDialog(){return this.#o}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#c,{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 Ea(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof A)for(let i of e.value.getNodes())try{this.closeBranch(i)}catch(s){t.push(s)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let i=e.getAttr("nodeId");this.nodeIds.get(i)===e&&this.nodeIds.delete(i);try{r.close()}catch(s){t.push(s)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#g(e);for(let r of t)this.bindingFor(r)?.rebind();for(let r of t)this.renderer.project(r);for(let r of t)this.bindingFor(r)?.remote?.trigger()}handleSourceEvent(e){let{evt:t,node:r}=e,i=[],s=o=>{try{this.closeBranch(o)}catch(a){i.push(a)}};try{if(t==="ins")this.#d(r);else if(t==="del")for(let o of Array.isArray(r)?r:[r])s(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof A)for(let o of e.oldvalue.getNodes())s(o);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#h(r,e.attrs_diff):this.#m(r).rebind(),r.value instanceof A&&this.#d(r.value)}else if(t==="upd_attrs")this.#h(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw i.length?new AggregateError([...i,o],"Source event failed"):o}return i}branchBuilt(e){let t=[];for(let r of this.#g(e)){let i=this.bindingFor(r);!i||i.hasStamp("built")||!this.renderer.attached(r)||(i.stamp("built"),t.push(i))}for(let r of t)this.renderer.attached(r.node)&&this.#p(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#f(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#f(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#c,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(i){e.push(i)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#d(e){if(!(e instanceof A)&&this.bindingFor(e))return;let t=e instanceof A?e.getNodes().flatMap(s=>this.#g(s)):this.#g(e),r=new Set(t.filter(s=>this.bindingFor(s))),i=new Map;for(let s of t){let o=s.getAttr("nodeId");if(o!=null){if(i.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==s)throw new Error(`Duplicate nodeId '${o}'`);i.set(o,s)}}for(let[s,o]of i)this.nodeIds.set(s,o);try{for(let s of t)this.openBinding(s);this.installer.install(e);for(let s of t)this.renderer.attached(s)&&this.bindingFor(s).registerPointers()}catch(s){let o=[s];for(let a of t.filter(l=>!r.has(l)).reverse()){let l=a.getAttr("nodeId");i.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"):s}for(let s of t){let o=this.bindingFor(s);if(!(!o||o.hasStamp("init")||!this.renderer.attached(s))&&(o.stamp("init"),Yc(s.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#f(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.trigger())}#p(e,t,r){let i=e.node.getAttr(r);if(Yc(i))for(let s of e.providers){if(typeof i!="number"||i<=0){s.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),s.invoke({kind:t,change:null})},i);o=e.track(()=>clearTimeout(a))}}#h(e,t){let r=this.#m(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:i,new:s}=t.nodeId;if(s!=null&&this.nodeIds.has(s)&&this.nodeIds.get(s)!==e)throw new Error(`Duplicate nodeId '${s}'`);this.nodeIds.get(i)===e&&this.nodeIds.delete(i),s!=null&&this.nodeIds.set(s,e)}ab.some(i=>Object.hasOwn(t,i))?this.rebindBranch(e):r.rebind()}#m(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}#g(e){let t=[e];if(e.value instanceof A)for(let r of e.value.getNodes())t.push(...this.#g(r));return t}};function Yc(n){return n===!0||typeof n=="number"}var Ea=class{#e;#t;#r=!1;#n=[];#i=[];#s=new Set;#o=null;#a=null;#l=null;#c=new Set;#u=new Set;#d=0;#f=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.#i]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#l}get clickCount(){return this.#d}countClick(){return++this.#d}hasStamp(e){return this.#s.has(e)}stamp(e){this.#s.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&&!Xc[e.nodeTag]&&e.nodeTag!=="dataBinder")return;!t&&typeof e.getAttr("remote")=="string"?this.#l??=new $s(this):this.#l&&(this.#l.close(),this.#l=null);let r=new Set;if(e._getMeta("gramlot_component")?.bagStore){let s=e.getAttr("storepath");if(typeof s!="string"||!s||/^[\^=]/.test(s)||s.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(s);this.#i.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let i=this.remote?tt(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[s,o]of Object.entries(e.getAttr()))if(s.startsWith("remote_"))for(let a of tt(e,o))r.add(a)}for(let[s,o]of e.pointers()){if(t&&s!=="datapath")continue;let l=(s==="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.#i.push(d),s==="datapath"&&this.#f.add(d),this.remote&&(s==="remote"||s.startsWith("remote_")||r.has(s))&&this.#c.add(d),this.remote&&(s==="_timing"||i.has(s))&&this.#u.add(d)}if(!t){this.#p(),this.remote?.register();return}if(e.nodeTag==="dataBinder"){this.#a??=new Ms(this),this.#a.register();return}this.#o??=new Xc[e.nodeTag](this),this.#o.register()}#p(){let e=this.node;this.#i.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return i=>{if(this.closed)return;if(Jn(r))return or(this.runtime,e,r,i);let[,s]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(s).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:i};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(a))(a)}}))}rebind(){this.#h(),this.registerPointers()}receive(e){if(this.#f.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#c.has(e.registration)&&this.remote.receive(e),this.#u.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.#n.push(e),()=>{let t=this.#n.indexOf(e);t!==-1&&this.#n.splice(t,1)}}async call(e,t){let{controller:r}=t,i=this.track(()=>r.abort());try{let s=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return s}finally{i()}}callSync(e,t,r){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,r))}close(){if(this.closed)return;this.#r=!0,this.#l?.close(),this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#h();let e=[];for(let t of this.#n.splice(0).reverse())try{t()}catch(r){e.push(r)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#h(){this.#a?.unregister();for(let e of this.#i.splice(0))e.close();this.#f.clear(),this.#c.clear(),this.#u.clear()}};var js=class{constructor(e){this.renderer=e}prepare(e,t){let r=this.renderer.records.get(e);if(!r||r.resolved.draggable!==!0)return null;let i=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(i===null)return null;let{dragValues:s,item:o,path:a}=i;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:s,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return We(s),{dragValues:Object.fromEntries(Object.entries(s).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,j(F(c))]})),item:o,path:a}}};var Pt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,r])=>t.startsWith("dropTargetCb_")&&!!r)}static acceptedTypes(e,t="",r=[]){let i=t.split(",").map(s=>s.trim()).filter(Boolean).map(s=>{let o=s.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(s=>s!=="dragTags"&&(r.includes(s)||i.some(o=>o.test(s))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(i=>i.trim()).filter(Boolean));return r.size?t.split(",").some(i=>i.split(" AND ").every(s=>(s=s.trim(),!s||s==="!"?!1:s.startsWith("!")?!r.has(s.slice(1)):r.has(s)))):!1}static acceptsEffect(e="all",t="move"){let r={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(r,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return r[e].includes(t)}static evaluate(e,t,r,i,s=[]){let o=this.acceptedTypes(e,i.dropTypes,s),a=i.dropEffect??"move",l=this.isTarget(i)&&o.length>0&&this.acceptsTags(t,i.dropTags)&&this.acceptsEffect(r,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var Zc=["dragstart","dragover","dragleave","drop","dragend"],Fs=class{#e;#t;#r=null;#n=null;#i=null;#s;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Zc)this.#t.addEventListener(t,this);this.#s=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#s)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#h():e.type==="dragover"?this.#d(e):e.type==="drop"&&this.#f(e)}#o(e,t){for(let r of e.composedPath()){let i=this.#e.elements.get(r);if(i&&t(i.resolved))return i}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,r=>r.draggable===!0);if(t){this.#b("none");try{let r=this.#e.prepareDrag(t.node,e);if(!r||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let i=this.#a(t,e);if(!i){e.preventDefault();return}let s=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:F(c)]));if(!s.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Pt.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:s,effectAllowed:o,phase:"active",tags:[a,r.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:r.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of s)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#i=this.#t.createElement("style"),this.#i.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.#i),this.#c(l,i.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#_(r)}}}#c(e,t,r){let i=t.cloneNode(!0);i.removeAttribute("id");for(let s of i.querySelectorAll("[id]"))s.removeAttribute("id");i.setAttribute("aria-hidden","true"),i.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(i.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(i),e.preview=i,r.setDragImage(i,0,0)}#u(e){let t=this.#r,r=this.#o(e,u=>Pt.isTarget(u));if(!r)return null;let i=this.#a(r,e);if(!i)return{record:r,element:r.element,accepted:!1};let s=Pt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),a={dropValues:Object.fromEntries(s.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):j(t.wires.get(u))])),item:i.item,path:i.path,source:{...t.source},selfdrop:r===t.record,dropEffect:s.dropEffect,dataAvailable:!0},l=s.accepted&&this.#e.checkDropTarget(r.node,a)&&this.#e.records.get(r.node)===r&&i.element.isConnected;return{record:r,element:i.element,accepted:l,context:a}}#d(e){if(!this.#r){this.#o(e,t=>Pt.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,r=this.#u(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r?.accepted?r.context.dropEffect:"none",this.#h(),r&&this.#p(r.element,r.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#m(),this.#_(t)}}async#f(e){if(!this.#r){this.#o(e,i=>Pt.isTarget(i))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r,r;try{if(r=this.#u(e),this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#m(),!r?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r.context.dropEffect,r.record.node.publish("onDrop",r.context),await this.#e.invokeDrop(r.record.node,r.context)}catch(i){this.#r===t&&(t.phase="rejected",this.#m()),(!r||this.#e.records.has(r.record.node))&&this.#_(i)}}#p(e,t){let r=t?"canBeDropped":"cannotBeDropped",i=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:i.includes(r)},e.classList.add(r),i.includes(r)||e.setAttribute("part",[...i,r].join(" "))}#h(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:i}=this.#n;r||e.classList.remove(t),i||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(s=>s!==t).join(" ")),this.#n=null}#m(){this.#h(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#m(),this.#r=null,e?.release?.(),this.#i?.remove(),this.#i=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(r=>this.#_(r))}#_(e){this.#e.binding.reportError(e,"Drag and drop failed")}dispose(){this.#g();for(let e of Zc)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#s)}};var ni=class extends sr{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#n=new WeakMap;constructor(e,t,r,{binding:i}={}){if(super(e),!(e instanceof Te)||!(t instanceof de)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(i instanceof Kr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");this._binding=i,this.source=t,this.destination=r,this.html=new Es({metadataAttributes:["__ref"],reportError:(s,o,a)=>{this.records.has(s)&&i.reportError(o,a)},callLogic:(s,o,a)=>{let{group:l,method:u}=i.gramlot.src.logicRegistry.resolve(o,s);return u.call(l,s,a)},invokeScript:(s,o,a,l)=>nt(i,s,o,a,l,s.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new zn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new js(this),this.instanceId=Y(),this.radioGroups=new vs(this),this.dragDrop=new Fs(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:s=>this.receive(s)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:i,source:s,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:r,path:i,source:s,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:r,path:i,source:s,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:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},i){let s={source:t,dropEffect:r},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,s)}catch(l){o.push(l)}try{this.binding.gramlot.publish(i,s)}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 r=this.#r.get(e)??super.evaluateExpressions(e,t),i=e._getMeta("gramlot_component");if(i?.presentationDefaults.length){let s=e.getAttr();this.#n.set(e,Object.fromEntries(Object.entries(r).filter(([o])=>Object.hasOwn(s,o)&&i.presentationDefaults.some(a=>o.startsWith(a)))))}if(this.html.hasLabelbox(e)||i?.presentationDefaults.length){let s=[];for(let o=e.parentNode;o;o=o.parentNode)this.#n.has(o)&&s.unshift(this.#n.get(o));r=Object.assign({},...s,r)}return this.#r.delete(e),this.#t.set(e,r),r}render(e,t={}){if(!(e instanceof ir))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 A))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,...r}={}){let i=t.createDocumentFragment(),s={node:e,binding:this.#h(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,s),this.elements.set(i,s),i.append(s.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...r});if(a===null)continue;i.append(a);let l=this.elements.get(a);l&&(l.parent=s,s.children.add(o))}return i.append(s.end),i}renderedItem(e,t,r,{tag:i,document:s=this.destination.ownerDocument}={}){let o=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,o]=Xn(t,o,(h,m)=>this._binding.gramlot.format(h,m)))),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.#h(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,s,i,o,u.visible??null)};this.html.compose(c,l,a),c.shape=ye.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c),this.elements.set(c.presentation,c);let d=ye.for(c.binding,c);(d||c.element.namespaceURI===we&&c.element.localName==="input")&&c.cleanup.push(()=>c.control?.detach()),d&&(c.control=d,d.attach(),this.#d(c,e,o,null));let f=xs.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new ks(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),this.#f(c),this.references?.register(e,c.element);for(let h of a){let m=this.elements.get(h);m&&(m.parent=c,m.container=c.element,c.children.add(m.node))}return c.presentation}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,i=s=>{if(!r.has(s)){r.add(s);for(let o of this.records.get(s)?.children??[])i(o);if(s.value instanceof A)for(let o of s.value.getNodes())i(o)}};for(let s of this.records.get(t)?.children??[])i(s);if(t?.value instanceof A)for(let s of t.value.getNodes())i(s);return this.#i(e,t?t.nodeTag:null),va(e),this.references?.validate(e,r),e}#i(e,t=null){let r=new Set,i=(s,o=null)=>{if(!(s instanceof de)||r.has(s))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(s._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");r.add(s);for(let a of s.getNodes()){if(!(a instanceof ir))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(a.builder instanceof Te))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")?s._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof A))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 A&&i(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};i(e,t)}freeze(e){e=K(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=K(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=i=>{delete i.frozen;for(let s of i.children)r(this.records.get(s))};r(t),!this.#s(e)&&(this.attached(e)?this.#m(e):this.remove(e))}#s(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)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(i=>!t(i));if(!r.length)return;e={...e,node:r}}else if(t(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let r=this.pending.shift();if(r.evt!=="del"&&!this.attached(r.node))continue;r.evt!=="del"&&r.evt!=="upd_attrs"&&this.#l(r);let i=this.binding.handleSourceEvent(r);try{this.#o(r,i)}catch(s){if(!i.length)throw s;i.push(s)}if(i.length)throw i.length===1?i[0]:new AggregateError(i,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#o(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#s(r))continue;let i=this.records.get(r)?.parent??null;try{this.remove(r)}catch(s){t.push(s)}this.#p(i)}return}if(!this.#s(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(r=>Array.isArray(r.node)?r.node:[r.node]));for(let r=e;r;r=r.parentBag?.parentNode)if(t.has(r))return!0;return!1}#l(e){let t=r=>{if(!(r instanceof ir))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof A){if(!(r.value instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");for(let i of r.value.getNodes())t(i)}};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),r=t?.element??t?.container??this.destination,i=e.parentBag.getNodes(),s=t?.end??null;for(let o=i.indexOf(e)+1;o<i.length;o++){let a=this.records.get(i[o]);if(a){s=a.presentation??a.start;break}}this.buildNode(e,r,s,t)}buildNode(e,t,r=null,i=null){this.#e.add(e);let s;try{s=this.render(e,{document:t.ownerDocument})}catch(a){this.#c(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(s,r),o.parent=i,this.assignContainer(o,t),i?.children.add(e),this.#p(i),this.binding.branchBuilt(e),o}#c(e,t){let r=[t],i=[],s=o=>{if(i.push(o),o.value instanceof A)for(let a of o.value.getNodes())s(a)};s(e);for(let o of i.reverse())try{this.remove(o)}catch(a){r.push(a)}throw r.length===1?t:new AggregateError(r,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let r=e.element??t;for(let i of e.children){let s=this.records.get(i);s&&this.assignContainer(s,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let i=e.value==null||["string","number","boolean"].includes(typeof e.value),s=t==="upd_value"&&i&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||s)&&r.element&&this.html.matches(r,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)===r&&(this.references?.remove(e),this.references?.register(e,r.element))):this.#m(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element||!this.attached(e))return;let i=this.getRender(e.builder),s=this.#n.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=i._handleMeta(e,a),u=this.#t.get(e),c=r.element.namespaceURI===we&&r.element.localName==="input"&&!Object.is(r.resolved.type,u.type),d=r.element.namespaceURI===we&&["input","select"].includes(r.element.localName)&&!!r.resolved.multiple!=!!u.multiple,f=r.resolved.group,h=r.control instanceof Xr&&!Object.is(f??null,u.group??null);if((c||d||h)&&this.#s(e))return;if(r.shape!==ye.shape(r.element,u)){if(this.#s(e))return;this.#r.set(e,u);try{this.#m(e)}finally{this.#r.delete(e)}return}let m=c?ye.classFor(r.element,u):null,p=c&&(r.control?.constructor??null)!==m,b=(c||d&&r.element.localName==="input")&&!p&&r.control&&Object.is(r.resolved.value,u.value);if(p&&(r.control?.detach(),r.control=null),h&&!p&&u.group!=null&&e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);r.resolved=u;let g=e._getMeta("subbuilder")?l:i.adaptAttrs(l),_=e.value instanceof A,w=_?[]:this.expressionValue(e,o);if(i===this&&(g=this.restoreNativeAttributes(e,g),e._getMeta("gramlot_component")||([w,g]=Xn(w,g,(D,y)=>this._binding.gramlot.format(D,y)))),g=this.componentAttributes(e,g),this.html.update(r,e,g,_?g._text:w,u.visible??null),p&&m&&(r.control=new m(r.binding,r),r.control.attach()),h&&!p){r.control.refresh(f??null),this.records.get(e)===r&&!r.binding.closed&&this.project(e);return}b||this.#d(r,e,g,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#f(r);let E=this.#n.get(e);if(E){let D=new Set([...Object.keys(s??{}),...Object.keys(E)].filter(y=>!Object.is(s?.[y],E[y])));D.size&&this.#u(e,D)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#p(r.parent)}#u(e,t){if(e.value instanceof A)for(let r of e.value.getNodes()){let i=r._getMeta("gramlot_component"),s=r.getAttr(),o=t;i?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(s,a))):this.html.hasLabelbox(r)&&[...t].some(a=>!Object.hasOwn(s,a))&&this.project(r),o.size&&this.#u(r,o)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),i=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!i)return t;let s=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(i??{}),...Object.keys(s).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(s,a)).map(a=>[a,s[a]]));return{...t,...o}}#d(e,t,r,i){if(!e.control)return;let s=t.getAttr("value")!=null;(s||e.valueDeclared)&&e.control.project(r.value??null,i),e.valueDeclared=s}#f(e){let t=new Map(Qn.declared(e.node).map(r=>[r[0],r]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let r of e.events.values())r.detach();e.events.clear()})}for(let[r,i]of[...e.events])t.get(r)?.[2]!==i.handler&&(i.detach(),e.events.delete(r));for(let[r,[,i,s]]of t){if(e.events.has(r))continue;let o=new Qn(e.binding,e,i,s,r);o.attach(),e.events.set(r,o)}}#p(e){for(let t=e;t;t=t.parent){if(t.control instanceof Kn){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=K(e),r=this.records.get(t);return r&&this.attached(t)?r.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let r=t.nodeType===1?this.elements.get(t):null;if(r)return this.attached(r.node)?r.node:null}return null}#h(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#m(e){let t=this.records.get(e),r=t.presentation?.nextSibling??t.end?.nextSibling??null,i=t.container,s=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,i,r,s)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let r=this.records.get(e);if(!r)throw new Error("Source node is not mounted");return r.cleanup.push(t),()=>{let i=r.cleanup.indexOf(t);i!==-1&&r.cleanup.splice(i,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let i of[...t.children])try{this.remove(i)}catch(s){r.push(s)}for(let i of t.cleanup.splice(0).reverse())try{i()}catch(s){r.push(s)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.presentation&&this.elements.delete(t.presentation),t.presentation?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#n.delete(e),r.length)throw new AggregateError(r,"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(([,r])=>!r.parent).map(([r])=>r);for(let r of t)try{this.remove(r)}catch(i){e.push(i)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var lb=new Set(["page","constructor"]);function Jc(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(lb.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var ub=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function cb(n){return/^[\w$]/.test(n)?ub.has(n):n!==")"&&n!=="]"}function db(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let i=n[r];if(i===`
|
|
194
|
+
`)return-1;if(i==="\\"){r++;continue}if(i==="[")t=!0;else if(i==="]")t=!1;else if(i==="/"&&!t)return r}return-1}function fb(n){let e=0,t="",r="";for(let i=n.indexOf("{");i<n.length;i++){let s=n[i];if(s==="/"&&n[i+1]==="/"){if(i=n.indexOf(`
|
|
195
|
+
`,i),i<0)break;continue}if(s==="/"&&n[i+1]==="*"){let o=n.indexOf("*/",i+2);if(o>=0){i=o+1;continue}}if(s==="/"&&cb(r)){let o=db(n,i);if(o>=0){i=o,r=")";continue}}if(s==='"'||s==="'"||s==="`"){let o=i+1;for(;o<n.length&&n[o]!==s;)o+=n[o]==="\\"?2:1;e===1&&(t+=n.slice(i+1,o)==="constructor"?" constructor":' ""'),i=o,r=")";continue}if(/[\w$]/.test(s)){let o=i+1;for(;o<n.length&&/[\w$]/.test(n[o]);)o++;e===1&&(t+=n.slice(i,o)),r=n.slice(i,o),i=o-1;continue}if(/\s/.test(s)||(r=s),s==="{"){++e===2&&(t+=" {}");continue}if(s==="}"){e--;continue}e===1&&(t+=s)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function Kc(n,e){if(n===void 0)return[];if(typeof n!="function"||!/^class\b/.test(Function.prototype.toString.call(n)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(n)!==Function.prototype||Object.getPrototypeOf(n.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(fb(Function.prototype.toString.call(n)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let r of Reflect.ownKeys(n.prototype)){if(r==="constructor")continue;if(typeof r=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(r)})`);let i=Object.getOwnPropertyDescriptor(n.prototype,r);if(i.get||i.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof i.value!="function")throw new Error(`${e}: Logic.prototype.${r} is not a method`);if(r==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([r,i.value])}return t}function Qc(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var lr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Qr=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new lr(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:i}of e){let s=Jc(r,i);for(let o=0;o<s.length;o++){let a=s.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(s[o])}}for(let{logicClass:r,group:i,resource:s}of e){let o=t.get(i??"")??new Set;for(let[a]of Kc(r,s))if(o.has(a))throw new Error(`${s}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let i=Jc(t,r),s=Kc(e,r),o=this.#e.logic;for(let a of i){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new lr(this,this.#e);Qc(o,a,u),o=u}else if(l instanceof lr)o=l;else throw new Error(`${r}: the group '${a}' has the name of a logic method`)}for(let[a,l]of s){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof lr)throw new Error(`${r}: the logic method '${a}' has the name of a child group`);Qc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(r)}resolve(e,t){let r=e.split("."),i=r.pop(),s=this.#e.logic;for(let a=0;a<r.length;a++)if(s=Object.getOwnPropertyDescriptor(s,r[a])?.value,!(s instanceof lr))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(s,i)?.value;if(typeof o!="function"){let a=this.#t.get(s)??[],l=r.length?`the group '${r.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${i}' (resources: ${a.join(", ")||"none"})`)}return{group:s,method:o}}};var ii=class extends De{constructor(e,{collections:t,destination:r,subscriptions:i,nameSyntax:s}){super(e),e.src=this,this.logicRegistry=new Qr(e),this.builder=new Oe(null,{collections:t,nameSyntax:s}),this.binding=new Kr(e,{subscriptions:i}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new ni(this.builder,this.source,r,{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,t=null){let r=this.prepareSource(e);if(this.renderer.validateCandidate(r),t!==null){if(!(t instanceof x)||t instanceof A)throw new TypeError("Initial page data must be a Data Bag");for(let i of t.getNodes())this.builder.data.setItem([i.label],i.getValue(),i.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(i){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),i}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof A){if(!(e instanceof de))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 r=ta(e,t);if(!(r instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");return r.activateCode()}async remoteSource(e,t,r={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let s=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!s)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,o=>this.#e(e,s,o))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let i=!1,s=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let o=await t.call("source",r);if(!s())return!1;let a=this.prepareSource(o,e.builder);return s()?(this.renderer.validateCandidate(a,{replacingNode:e}),i=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(o){if(!i&&!s())return!1;throw o}}};var si=class extends De{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)}navigate(e){if(typeof e!="string"||!e)throw new TypeError("Navigation requires an absolute HTTP(S) URL");let t=new URL(e);if(!["http:","https:"].includes(t.protocol)||t.username||t.password)throw new TypeError("Navigation requires an HTTP(S) URL without credentials");this.gramlot.src.renderer.destination.ownerDocument.defaultView.location.assign(t.href)}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 qs=class extends De{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#i=!1;ready(){this.gramlot._frames.ready()}subscribe(e,t){if(this.#a(),this.#o(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let r=Object.freeze({});return this.#t.add(r),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(r,t),r}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,r]of this.#e)r.delete(e)&&!r.size&&this.#e.delete(t)}publish(e,t={},r={}){if(this.#a(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#s(e,t,r);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(o=>!["topic","nodeId","parent","iframe","pageId","server"].includes(o)))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.server!==void 0&&typeof e.server!="boolean")throw new TypeError("server must be boolean");if(e.iframe==="*")throw new Error("Recursive iframe broadcast is not implemented yet");if(e.pageId!==void 0&&(typeof e.pageId!="string"||!e.pageId))throw new TypeError("pageId must be a nonempty string");if((e.parent||e.iframe!==void 0||e.pageId!==void 0)&&Object.hasOwn(e,"nodeId"))throw new Error("Interframe node addressing is not implemented yet");let s=null;if(e.server===!0){if(["parent","iframe","nodeId"].some(o=>Object.hasOwn(e,o)))throw new Error("Server publication cannot combine window or node selectors");if(!this.gramlot._pageStore)throw new Error("Server publication requires a WebSocket channel");s=this.gramlot._pageStore.preparePublish(e,t)}else(e.parent||e.iframe!==void 0||e.pageId!==void 0)&&(s=this.gramlot._frames.prepare(e,t));if(Object.hasOwn(e,"nodeId")){let o=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!o)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(o,e.topic,t)}return this.#s(e.topic,t),s?.()}topicFor(e,t){this.#o(t),e=K(e);let r=this.gramlot.src.binding.bindingFor(e);if(!r||r.closed)throw new Error("Topic target is not an active Source node of this page");let i=e.getAttr("nodeId");return i==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),i=this.#r.get(e)),`${i}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[i,s]of Object.entries(e.getAttr())){let o=i.startsWith("selfsubscribe_")?"selfsubscribe_":i.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,i.slice(o.length)):i.slice(o.length);this.#o(a),r.push([a,t(i,s,a)])}return this.#a(),r.map(([i,s])=>{let o=this.subscribe(i,s);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#i=!0,this.#e.clear()}#s(e,t,r={}){this.#o(e);let i=this.#e.get(e);if(i)for(let[s,o]of[...i]){if(this.#i)break;i.has(s)&&o(t,{...r})}}#o(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#a(){if(this.#i)throw new Error("Gramlot subscriptions are disposed")}};var Us=class extends Q{constructor(e,t,r){super({cacheTime:r}),this.handler=e,this.name=t,this.failed=!1,this.writing=!1,this.request=null,this.revision=0,this.received=0}resolve({static:e=!1}={}){return!e&&!this.handler.disposed&&!this.writing&&!this.request&&!this.failed&&!this._node.attr.watching&&this.expired&&this.handler.refresh(this.name),this.cachedValue}reset(){super.reset(),this.failed=!1,this.revision++}};var ed=["appinfo","location"],td={UNAVAILABLE:"unavailable",PERMISSION_DENIED:"denied",TIMEOUT:"error",FAILED:"error",CANCELLED:"cancelled"};function V(n){let e=Object.hasOwn(td,n?.code)?n.code:"FAILED";return{status:td[e],error:e==="CANCELLED"?null:{code:e,message:String(n?.message??"Device operation failed")}}}var oi=class extends De{#e=null;#t=null;#r=null;#n=null;#i=null;#s=null;#o=new Map;#a=new Map;#l=null;#c=null;#u=null;#d=null;#f=null;#p=null;#h=null;constructor(e){super(e),this.provider=null,this.disposed=!1,this.monitor=null,this.retiring=null,this.resolvers=new Map,this.cleanup=Promise.resolve()}installData(){let{gramlot:e}=this;e.data.setItem("gramlot.device.database",null,{status:"idle",error:null}),e.data.setItem("gramlot.device.orientation",null,{status:"idle",error:null,listening:!1});for(let p of["gyroscope","accelerometer"])e.data.setItem(`gramlot.device.${p}`,null,{enabled:!1,watching:!1,status:"idle",error:null}),e.data.getNode(`gramlot.device.${p}`).setAttr({error:null},!1,!0,!1),this.#a.set(p,{node:e.data.getNode(`gramlot.device.${p}`),stream:null,cleanup:Promise.resolve()});for(let p of ed){let b=`gramlot.device.${p}`,g={status:"idle",error:null,cacheTime:p==="appinfo"?-1:5};p==="location"&&Object.assign(g,{enabled:!1,watching:!1}),e.data.setItem(b,null);let _=e.data.getNode(b);_.setAttr(g,!1,!0,!1);let w=new Us(this,p,g.cacheTime);_.resolver=w,this.resolvers.set(p,w)}e.data.setItem("gramlot.device.clipboard",null,{status:"idle",error:null,text:"",copy:null,paste:null,operation:null});let t=e.data.getNode("gramlot.device.clipboard");e.data.setItem("gramlot.device.camera",null,{status:"idle",error:null,capture:null,choose:null});let r=e.data.getNode("gramlot.device.camera");e.data.setItem("gramlot.device.barcode",null,{status:"idle",error:null,scan:null});let i=e.data.getNode("gramlot.device.barcode");e.data.setItem("gramlot.device.biometrics",null,{status:"idle",error:null,verify:null});let s=e.data.getNode("gramlot.device.biometrics"),o=new x;o.setItem("request",new x);for(let p of["scheduled","received","action"])o.setItem(p,null);e.data.setItem("gramlot.device.notifications",o,{status:"idle",error:null,schedule:null,listening:!1,listenerError:null});let a=e.data.getNode("gramlot.device.notifications"),l=new x;for(let p of["registration","received","action"])l.setItem(p,null);e.data.setItem("gramlot.device.push",l,{status:"idle",error:null,register:null,listening:!1,listenerError:null});let u=e.data.getNode("gramlot.device.push"),c=new x;c.setItem("request",null),e.data.setItem("gramlot.device.links",c,{listening:!1,listenerError:null});let d=new x;d.setItem("request",null),e.data.setItem("gramlot.device.shortcuts",d,{listening:!1,listenerError:null}),e.data.setItem("gramlot.device.network",null,{status:"idle",error:null,listening:!1});let f=new x;f.setItem("active",null),f.setItem("event",null),f.setItem("sequence",0),e.data.setItem("gramlot.device.lifecycle",f,{status:"idle",error:null,listening:!1}),e.data.setItem("gramlot.device.haptics",null,{status:"idle",error:null,impact:null,style:"medium",vibrate:null,duration:600});let h=e.data.getNode("gramlot.device.haptics");e.data.setItem("gramlot.device.audio",null,{status:"idle",error:null,recording:!1,start:null,stop:null,cancel:null,share:null,shareStatus:"idle",shareError:null,shareActivity:null});let m=e.data.getNode("gramlot.device.audio");e.data.subscribe("gramlot.device",{update:p=>{if(!this.disposed){for(let[b,g]of this.#a)if(p.node===g.node&&p.attrs_diff?.enabled){if(typeof g.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.#g(b,g)}p.node===t&&p.fired&&(p.attrs_diff?.copy?.new===!0&&this.#y(t,"copy"),p.attrs_diff?.paste?.new===!0&&this.#y(t,"paste")),p.node===m&&p.fired&&(p.attrs_diff?.start?.new===!0&&this.#b(m),p.attrs_diff?.stop?.new===!0&&this.#_(m),p.attrs_diff?.cancel?.new===!0&&this.#w(m),p.attrs_diff?.share?.new===!0&&this.#v(m)),p.node===h&&p.fired&&p.attrs_diff?.impact?.new===!0&&this.#k(h),p.node===h&&p.fired&&p.attrs_diff?.vibrate?.new===!0&&this.#E(h),p.node===i&&p.fired&&p.attrs_diff?.scan?.new===!0&&this.#C(i),p.node===r&&p.fired&&p.attrs_diff?.choose?.new===!0&&this.#A(r,"choose"),p.node===r&&p.fired&&p.attrs_diff?.capture?.new===!0&&this.#A(r,"capture"),p.node===s&&p.fired&&p.attrs_diff?.verify?.new===!0&&this.#S(s),p.node===a&&p.fired&&p.attrs_diff?.schedule?.new===!0&&this.#N(a),p.node===u&&p.fired&&p.attrs_diff?.register?.new===!0&&this.#O(u);for(let b of this.resolvers.values()){if(p.node!==b._node)continue;let{cacheTime:g}=p.node.attr;if(typeof g!="number"||!Number.isFinite(g)||g<0&&g!==-1)throw new TypeError("Device cacheTime must be -1 or a nonnegative number of seconds");if(b.cacheTime=g,b.name==="location"){if(typeof p.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.reconcile()}}}}})}attach(e,{dispose:t=null}={}){if(this.assertLive(),this.provider)throw new Error("A device provider is already attached");if(!Array.isArray(e.capabilities)||e.capabilities.some(r=>![...ed,"camera","biometrics","notifications","push","shortcuts","barcode","network","lifecycle","haptics","audio","clipboard","links","orientation","gyroscope","accelerometer","database"].includes(r)))throw new TypeError("Unknown device provider capability");if(t!==null&&typeof t!="function")throw new TypeError("Device attachment dispose must be a function");this.releaseProvider=t,this.provider=e,this.installData(),this.reconcile(),this.#m("orientation",(r,i)=>e.startOrientationEvents(r,i),(r,i)=>{if(!["portrait","landscape"].includes(i?.type)||!["primary","secondary"].includes(i.direction)||!Number.isFinite(i.timestamp))throw new TypeError("Invalid screen orientation from device provider");let s=new x;for(let o of["type","direction","timestamp"])s.setItem(o,i[o]);r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("network",(r,i)=>e.startNetworkEvents(r,i),(r,i)=>{if(typeof i?.connected!="boolean"||!["none","unknown","wifi","cellular"].includes(i.type))throw new TypeError("Invalid network state from device provider");let s=new x;s.setItem("connected",i.connected),s.setItem("type",i.type),r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("lifecycle",(r,i)=>e.startLifecycleEvents(r,i),(r,i)=>{if(i?.kind==="state"&&typeof i.active=="boolean")r.staticValue.setItem("active",i.active);else if(i?.kind==="pause"||i?.kind==="resume")r.staticValue.setItem("event",i.kind),r.staticValue.setItem("sequence",r.staticValue.getItem("sequence")+1);else throw new TypeError("Invalid lifecycle event from device provider");r.setAttr({status:"success",error:null},!0,!0,!1)}),e.capabilities.includes("links")&&this.#R(this.gramlot.data.getNode("gramlot.device.links")),e.capabilities.includes("shortcuts")&&this.#B(this.gramlot.data.getNode("gramlot.device.shortcuts")),e.capabilities.includes("push")&&this.#D(this.gramlot.data.getNode("gramlot.device.push")),e.capabilities.includes("notifications")&&this.#T(this.gramlot.data.getNode("gramlot.device.notifications"))}assertLive(){if(this.disposed)throw new Error("DeviceHandler is disposed")}resolver(e){if(this.assertLive(),!this.resolvers.has(e))throw new TypeError(`Unknown device value: ${e}`);return this.resolvers.get(e)}invalidate(e){this.resolver(e).reset()}refresh(e){let t=this.resolver(e);if(t.request)return;let r={revision:t.revision,received:t.received};t.request=r,this.attributes(t,{status:"pending",error:null}),Promise.resolve().then(()=>{if(!(this.disposed||t.request!==r))return this.requireCapability(e),e==="appinfo"?this.provider.readAppInfo():this.provider.readLocation()}).then(i=>{this.disposed||t.request!==r||(this.accept(t,i),t.revision!==r.revision&&(t._lastUpdate=null))}).catch(i=>{!this.disposed&&t.request===r&&t.received===r.received&&this.failure(t,i)}).finally(()=>{t.request===r&&(t.request=null)})}#m(e,t,r){let i=this.gramlot.data.getNode(`gramlot.device.${e}`);if(!this.provider.capabilities.includes(e)){i.setAttr(V({code:"UNAVAILABLE",message:`${e} is unavailable`}),!0,!0,!1);return}let s={controller:new AbortController};this.#o.set(e,s),i.setAttr({status:"pending",error:null},!0,!0,!1),s.start=Promise.resolve().then(()=>s.controller.signal.aborted?async()=>{}:t(o=>{if(!s.controller.signal.aborted)try{r(i,o)}catch(a){i.setAttr(V(a),!0,!0,!1)}},s.controller.signal)).then(o=>(s.controller.signal.aborted||i.setAttr({listening:!0},!0,!0,!1),o)),s.start.catch(o=>{let a=s.controller.signal.aborted;s.controller.abort(),a||i.setAttr({...V(o),listening:!1},!0,!0,!1)})}#g(e,t){let{node:r}=t;if(!r.attr.enabled){let s=t.stream;if(!s)return;t.stream=null,s.controller.abort(),t.cleanup=s.start.then(o=>o(),()=>{}).then(()=>{!this.disposed&&!t.stream&&r.setAttr({watching:!1,status:"idle",error:null},!0,!0,!1)}),t.cleanup.catch(o=>{this.disposed||r.setAttr(V(o),!0,!0,!1)});return}if(t.stream)return;let i={controller:new AbortController};t.stream=i,i.start=t.cleanup.then(()=>{if(i.controller.signal.aborted)return async()=>{};this.requireCapability(e);let s=o=>{if(!(this.disposed||i.controller.signal.aborted))try{if(o?.kind==="state"&&typeof o.watching=="boolean")r.setAttr({watching:o.watching,status:o.watching?"pending":"idle",error:null},!0,!0,!1);else if(o?.kind==="sample"){for(let l of["x","y","z","timestamp"])if(!Number.isFinite(o[l]))throw new TypeError(`Invalid ${e}.${l}`);if(!r.attr.watching||r.staticValue&&o.timestamp<r.staticValue.getItem("timestamp"))return;let a=new x;for(let l of["x","y","z","timestamp"])a.setItem(l,o[l]);r.setValue(a,!0,{status:"success",error:null},!0,!1)}else if(o?.kind==="error"&&o.error instanceof Error)r.setAttr({...V(o.error),watching:!1},!0,!0,!1);else throw new TypeError(`Invalid ${e} event`)}catch(a){r.setAttr(V(a),!0,!0,!1)}};return e==="gyroscope"?this.provider.startGyroscopeUpdates(s,i.controller.signal):this.provider.startAccelerometerUpdates(s,i.controller.signal)}),i.start.catch(s=>{!this.disposed&&!i.controller.signal.aborted&&r.setAttr({...V(s),watching:!1},!0,!0,!1)}),r.setAttr({status:"pending",error:null},!0,!0,!1)}#b(e){let t=this.#n;if(t){if(t.phase!=="complete")return;t.phase="replacing",e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),t.close=t.start.then(i=>i.dispose()).then(()=>{this.disposed||t.controller.signal.aborted||this.#n!==t||(this.#n=null,this.#b(e))}).catch(i=>{!this.disposed&&this.#n===t&&(t.phase="failed",e.setAttr(V(i),!0,!0,!1))});return}let r={controller:new AbortController,phase:"starting"};this.#n=r,e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.start=Promise.resolve().then(async()=>r.controller.signal.aborted?null:(this.requireCapability("audio"),this.provider.startAudioRecording(i=>{this.#n===r&&!r.controller.signal.aborted&&this.#w(e,i)},r.controller.signal))),r.start.then(i=>{!i||r.controller.signal.aborted||this.disposed||(r.phase="recording",e.setAttr({status:"recording",error:null,recording:!0},!0,!0,!1))}).catch(i=>{r.controller.signal.aborted||this.disposed||(this.#n===r&&(this.#n=null),e.setAttr({...V(i),recording:!1},!0,!0,!1))})}#_(e){let t=this.#n;!t||t.phase!=="recording"||(t.phase="stopping",e.setAttr({status:"pending",error:null},!0,!0,!1),t.stop=t.start.then(r=>r.stop()).then(r=>{if(t.controller.signal.aborted||this.disposed)return;if(typeof r?.url!="string"||!r.url||typeof r.mimeType!="string"||!r.mimeType.startsWith("audio/")||!Number.isFinite(r.duration)||r.duration<0)throw new TypeError("Invalid audio result from device provider");let i=new x;for(let s of["url","mimeType","duration"])i.setItem(s,r[s]);t.phase="complete",e.setValue(i,!0,{status:"success",error:null,recording:!1},!0,!1)}).catch(r=>{!t.controller.signal.aborted&&!this.disposed&&this.#w(e,r)}))}#v(e){let t=this.#n;if(t?.phase!=="sharing"){if(!t||t.phase!=="complete"){let r=V(new Error("Record and stop audio before sharing"));e.setAttr({shareStatus:r.status,shareError:r.error,shareActivity:null},!0,!0,!1);return}t.phase="sharing",e.setAttr({shareStatus:"pending",shareError:null,shareActivity:null},!0,!0,!1),t.share=t.start.then(r=>r.share(t.controller.signal)).then(r=>{if(!(t.controller.signal.aborted||this.disposed)){if(typeof r?.activity!="string")throw new TypeError("Invalid audio share result from device provider");e.setAttr({shareStatus:"success",shareError:null,shareActivity:r.activity},!0,!0,!1)}}).catch(r=>{if(t.controller.signal.aborted||this.disposed)return;let i=V(r);e.setAttr({shareStatus:i.status,shareError:i.error,shareActivity:null},!0,!0,!1)}).finally(()=>{this.#n===t&&!t.controller.signal.aborted&&(t.phase="complete")})}}#w(e,t={code:"CANCELLED",message:"Audio recording cancelled"}){let r=this.#n;!r||r.phase==="closing"||r.phase==="sharing"||(r.phase="closing",r.controller.abort(),e.setValue(null,!0,{status:"pending",error:null,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.close=r.start.then(i=>i===null?void 0:i.dispose(),i=>{if(i?.code!=="CANCELLED")throw i}).then(()=>{this.disposed||this.#n!==r||(this.#n=null,e.setAttr({...V(t),recording:!1},!0,!0,!1))}).catch(i=>{!this.disposed&&this.#n===r&&(r.phase="failed",e.setAttr(V(i),!0,!0,!1))}))}#y(e,t){if(this.#t)return;let r=new AbortController;this.#t=r;let i=e.attr.text;e.setValue(null,!0,{status:"pending",error:null,operation:t},!0,!1),Promise.resolve().then(async()=>{if(r.signal.aborted)return;this.requireCapability("clipboard");let s;if(t==="copy"){if(typeof i!="string")throw new TypeError("Clipboard text must be a string");await this.provider.copyText(i,r.signal),s={text:i}}else s=await this.provider.pasteText(r.signal);if(r.signal.aborted)return;if(typeof s?.text!="string")throw new TypeError("Invalid clipboard text from device provider");let o=new x;o.setItem("text",s.text),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(s=>{r.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#t===r&&(this.#t=null)})}#E(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{duration:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!Number.isInteger(r)||r<1||r>5e3)throw new TypeError("Vibration duration must be an integer from 1 to 5000 milliseconds");if(await this.provider.vibrate(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("duration",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#k(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{style:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!["light","medium","heavy"].includes(r))throw new TypeError("Invalid haptic style");if(await this.provider.impact(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("style",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#C(e){if(this.#i)return;let t=new AbortController;this.#i=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("barcode"),this.provider.scanBarcode(t.signal)}).then(r=>{if(t.signal.aborted)return;if(typeof r?.text!="string"||!r.text||typeof r.format!="string"||!r.format)throw new TypeError("Invalid barcode result from device provider");let i=new x;i.setItem("text",r.text),i.setItem("format",r.format),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setAttr(V(r),!0,!0,!1)}).finally(()=>{this.#i===t&&(this.#i=null)})}#A(e,t){if(this.#r)return;let r=new AbortController;this.#r=r,e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(()=>{if(!r.signal.aborted)return this.requireCapability("camera"),t==="choose"?this.provider.choosePhoto(r.signal):this.provider.takePhoto(r.signal)}).then(i=>{if(r.signal.aborted)return;if(typeof i?.url!="string"||!i.url||typeof i.format!="string"||!i.format)throw new TypeError("Invalid camera photo from device provider");let s=new x;s.setItem("url",i.url),s.setItem("format",i.format),e.setValue(s,!0,{status:"success",error:null},!0,!1)}).catch(i=>{r.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#r===r&&(this.#r=null)})}#S(e){if(this.#l)return;let t=new AbortController;this.#l=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("biometrics"),this.provider.verifyBiometrics(t.signal)}).then(()=>{if(t.signal.aborted)return;let r=new x;r.setItem("verified",!0),e.setValue(r,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setValue(null,!0,V(r),!0,!1)}).finally(()=>{this.#l===t&&(this.#l=null)})}#T(e){if(this.#u)return this.#u.start;let t={controller:new AbortController};return this.#u=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startNotificationEvents(r=>{if(!t.controller.signal.aborted)try{if(!["received","action"].includes(r.kind)||!Number.isInteger(r.id)||typeof r.title!="string"||typeof r.body!="string"||r.kind==="action"&&typeof r.actionId!="string")throw new TypeError("Invalid notification event from device provider");let i=new x;for(let s of["id","title","body"])i.setItem(s,r[s]);r.kind==="action"&&i.setItem("actionId",r.actionId),e.staticValue.setItem(r.kind,i)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#u===t&&(this.#u=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#N(e){if(this.#c)return;let t=new AbortController;this.#c=t;let r=e.staticValue.getItem("request"),i=r instanceof x?Object.fromEntries(["id","title","body","delay"].map(s=>[s,r.getItem(s)])):null;e.staticValue.setItem("scheduled",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{if(!t.signal.aborted){if(this.requireCapability("notifications"),!i||!Number.isInteger(i.id)||i.id<1||i.id>2147483647||typeof i.title!="string"||!i.title.trim()||typeof i.body!="string"||!i.body.trim()||typeof i.delay!="number"||!Number.isFinite(i.delay)||i.delay<=0)throw new TypeError("Notification requires a positive 32-bit id, title, body and positive delay in seconds");if(await this.#T(e),!t.signal.aborted)return this.provider.scheduleNotification(i,t.signal)}}).then(s=>{if(t.signal.aborted)return;if(s?.id!==i.id||typeof s.at!="number"||!Number.isFinite(s.at))throw new TypeError("Invalid notification scheduling acknowledgement");let o=new x;o.setItem("id",s.id),o.setItem("at",s.at),e.staticValue.setItem("scheduled",o),e.setAttr({status:"success",error:null},!0,!0,!1)}).catch(s=>{t.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#c===t&&(this.#c=null)})}#x(){let e=this.#d;return this.#d=null,e&&clearTimeout(e.timer),e}#I(e,t){if(t.kind==="registration"){if(typeof t.token!="string"||!t.token)throw new TypeError("Invalid push registration token");this.#x();let r=new x;r.setItem("token",t.token),e.staticValue.setItem("registration",r),e.setAttr({status:"success",error:null},!0,!0,!1)}else if(t.kind==="registrationError")this.#x(),e.staticValue.setItem("registration",null),e.setAttr(V(t.error),!0,!0,!1);else{if(!["received","action"].includes(t.kind))throw new TypeError("Invalid push event kind");let r=["id","title","body","messageId","destination"];t.kind==="action"&&r.push("actionId");let i=new x;for(let s of r){if(typeof t[s]!="string")throw new TypeError(`Invalid push event ${s}`);i.setItem(s,t[s])}e.staticValue.setItem(t.kind,i)}}#D(e){if(this.#f)return this.#f.start;let t={controller:new AbortController};return this.#f=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startPushEvents(r=>{if(!t.controller.signal.aborted)try{this.#I(e,r)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#f===t&&(this.#f=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#O(e){if(this.#d)return;let t={controller:new AbortController,timer:null};this.#d=t,t.timer=setTimeout(()=>{this.disposed||this.#d!==t||(this.#x(),t.controller.abort(),e.setAttr(V({code:"TIMEOUT",message:"Push registration has not returned a token"}),!0,!0,!1))},3e4),e.staticValue.setItem("registration",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{t.controller.signal.aborted||(this.requireCapability("push"),await this.#D(e),!(t.controller.signal.aborted||this.#d!==t)&&await this.provider.registerPush(t.controller.signal))}).catch(r=>{this.disposed||this.#d!==t||(this.#x(),t.controller.abort(),e.setAttr(V(r),!0,!0,!1))})}#B(e){let t={controller:new AbortController};this.#p=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startShortcutEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","destination"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid shortcut request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("destination",r.destination),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}#R(e){let t={controller:new AbortController};this.#h=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startLinkEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","url"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid link request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("url",r.url),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}requireCapability(e){if(!this.provider||!this.provider.capabilities.includes(e))throw Object.assign(new Error(`${e} is unavailable in this environment`),{code:"UNAVAILABLE"})}attributes(e,t){let r=e.writing;e.writing=!0;try{e._node.setAttr(t,!0,!0,!1)}finally{e.writing=r}}accept(e,t){let r=e.name==="appinfo"?["id","name","version","build"]:["latitude","longitude","accuracy","timestamp"],i=e.name==="appinfo"?"string":"number";for(let l of r)if(typeof t[l]!==i||i==="number"&&!Number.isFinite(t[l]))throw new TypeError(`Invalid ${e.name}.${l} from device provider`);let s=e.cachedValue;if(e.name==="location"&&s&&t.timestamp<s.getItem("timestamp")){this.attributes(e,{status:"success",error:null});return}let o=new x;for(let l of r)o.setItem(l,t[l]);e._lastUpdate=Date.now(),e.failed=!1,e.received++;let a=e.writing;e.writing=!0;try{e._node.setValue(o,!0,{status:"success",error:null},!0,!1)}finally{e.writing=a}}failure(e,t){e.failed=!0,this.attributes(e,V(t))}reconcile(){let e=this.resolvers.get("location");if(e._node.attr.enabled){if(this.monitor)return;let t={stop:null,controller:new AbortController};this.monitor=t,t.start=Promise.resolve(this.cleanup).then(()=>this.disposed||this.monitor!==t?null:(this.requireCapability("location"),this.provider.startLocationUpdates((r,i)=>{if(!(this.disposed||this.monitor!==t))if(i)this.failure(e,i);else try{this.accept(e,r)}catch(s){this.failure(e,s)}},t.controller.signal))),t.start.then(r=>{r===null||this.disposed||this.monitor!==t||(t.stop=r,this.attributes(e,{watching:!0}))}).catch(r=>{!this.disposed&&this.monitor===t&&(this.attributes(e,{watching:!1}),this.failure(e,r))}),this.attributes(e,{status:"pending",error:null})}else if(this.monitor){let t=this.monitor;this.monitor=null,t.controller.abort(),this.retiring=t,this.cleanup=t.start.then(r=>r===null?void 0:r(),()=>{}).then(()=>{if(this.retiring===t&&(this.retiring=null),!this.disposed){let r={watching:!1};!this.monitor&&!e.request&&e._node.attr.status==="pending"&&Object.assign(r,{status:"cancelled",error:null}),this.attributes(e,r)}}),this.cleanup.catch(r=>{this.disposed||this.failure(e,r)})}}async openDatabase(e){if(this.assertLive(),!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(e)||typeof e!="string")throw new TypeError("Invalid database name");if(this.#e)throw new Error("This page already owns a database connection");let t=this.gramlot.data.getNode("gramlot.device.database"),r=(s,o=null)=>{this.disposed||t.setAttr({status:s,error:o},!0,!0,!1)};if(!this.provider.capabilities.includes("database")){let s=Object.assign(new Error("Native database unavailable"),{code:"UNAVAILABLE"});throw r("unavailable",{code:s.code,message:s.message}),s}let i={controller:new AbortController,close:null,start:null};this.#e=i,r("pending"),i.start=this.provider.openDatabase(e,i.controller.signal);try{let s=await i.start,o=!1,a=null,l=()=>a||(o=!0,a=s.close().then(()=>{r("closed")},c=>{throw r("error",{code:"FAILED",message:c.message}),c}).finally(()=>{this.#e===i&&(this.#e=null)}),a);if(i.close=l,this.disposed||i.controller.signal.aborted)throw await l(),Object.assign(new Error("Page closed"),{code:"CANCELLED"});let u=async(c,d,f)=>{if(this.assertLive(),o)throw new Error("Database connection is closed");r("pending");try{let h=await s[c](d,f);return r("success"),h}catch(h){throw r("error",{code:"FAILED",message:h.message}),h}};return r("success"),{query:(c,d=[])=>u("query",c,d),execute:(c,d=[])=>u("execute",c,d),close:l}}catch(s){throw this.#e===i&&(this.#e=null),this.disposed||t.setAttr(V(s),!0,!0,!1),s}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.#e;e?.controller.abort(),e&&(this.cleanup=Promise.all([this.cleanup,e.start.then(()=>e.close?.(),()=>{})]).then(()=>{}));let t=[...this.#a.values()].map(c=>{let d=c.stream;return c.stream=null,d?.controller.abort(),d?d.start.then(f=>f(),()=>{}):c.cleanup});this.#t?.abort(),this.#t=null;let r=this.#n;this.#n=null,r?.controller.abort(),this.#s?.abort(),this.#s=null;let i=[...this.#o.values()];this.#o.clear();for(let c of i)c.controller.abort();let s=this.#h;this.#h=null,s?.controller.abort();let o=this.#p;this.#p=null,o?.controller.abort(),this.#x()?.controller.abort();let a=this.#f;this.#f=null,a?.controller.abort(),this.#i?.abort(),this.#i=null,this.#r?.abort(),this.#r=null,this.#l?.abort(),this.#l=null,this.#c?.abort(),this.#c=null;let l=this.#u;this.#u=null,l?.controller.abort(),this.gramlot.data.unsubscribe("gramlot.device",{any:!0});let u=this.monitor;if(this.monitor=null,u?.controller.abort(),u)this.cleanup=u.start.then(c=>c===null?void 0:c(),()=>{});else if(this.retiring?.stop){let c=this.retiring;this.cleanup=this.cleanup.catch(()=>c.stop())}l&&(this.cleanup=Promise.all([this.cleanup,l.start.then(c=>c(),()=>{})]).then(()=>{})),a&&(this.cleanup=Promise.all([this.cleanup,a.start.then(c=>c(),()=>{})]).then(()=>{})),s&&(this.cleanup=Promise.all([this.cleanup,s.start.then(c=>c(),()=>{})]).then(()=>{})),o&&(this.cleanup=Promise.all([this.cleanup,o.start.then(c=>c(),()=>{})]).then(()=>{})),this.cleanup=Promise.all([this.cleanup,...t,...i.map(c=>c.start.then(d=>d(),()=>{}))]).then(()=>{}),r&&(this.cleanup=Promise.all([this.cleanup,r.start.then(c=>c===null?void 0:c.dispose(),c=>{if(c?.code!=="CANCELLED")throw c})]).then(()=>{})),this.cleanup=this.cleanup.finally(()=>this.releaseProvider?.()),this.cleanup.catch(c=>{this.cleanupError=c});for(let c of this.resolvers.values())c.request=null}};var rd=2e3;function hb(n){if(!(n instanceof Date))return String(n??"");let e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var ai=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof x))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],r=(i,s)=>{for(let o of i.getNodes()){let a=s+o.label;o.value instanceof x?r(o.value,`${a}.`):t.push(`${a}: ${hb(o.value)}`)}};return r(this.branch(e),""),t.join(`
|
|
196
|
+
`)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>rd)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${r.length} characters long, over the mailto: limit of ${rd}; send it with sendHttp or save it as a file`);return r}sendMail(e,t){this.open(this.mailtoUrl(e,t))}async sendHttp(e,t){let r=JSON.stringify(this.branch(e).asDict(!1,!1,!0)),i=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(!i.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${i.status}`);return i}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((r,i)=>{let s=()=>i(new this.document.defaultView.DOMException("File selection cancelled","AbortError"));t.addEventListener("cancel",s,{once:!0}),t.addEventListener("change",async()=>{if(t.removeEventListener("cancel",s),!t.files.length){s();return}try{let o=j(await t.files[0].text());if(!(o instanceof x))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,o),r(o)}catch(o){i(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${o.message}`,{cause:o}))}},{once:!0}),t.click()})}download(e,t,r){if(!["json","xml"].includes(r))throw new Error(`gramlot.utl.inout.download: format '${r}' is not 'json' or 'xml'`);let i=this.branch(e);if(r==="json")this.saveText(i.toJson(!1),t,"application/json");else{let s=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
|
|
197
|
+
<${s}>${i.toXml()}</${s}>`,t,"application/xml")}}saveText(e,t,r){let i=this.document.defaultView,s=i.URL.createObjectURL(new i.Blob([e],{type:r}));this.open(s,t),i.setTimeout(()=>i.URL.revokeObjectURL(s),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var li=class extends De{constructor(e,t){super(e),this.inout=new ai(e,t)}};var ui=class{#e;constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:r="/gramlot/close",rootId:i="gramlot-root",capabilities:s=[],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 ht,nameSyntax:m=null,websocketUrl:p=null}={}){ws.register(a.defaultView);for(let g of u)g instanceof Ot&&g.register(a.defaultView);this.commands=new nn,this.pageId=e;let b=c==null||d==null?a.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??b.locale,this.timeZone=d??b.timeZone,Object.defineProperty(this,"_subscriptions",{value:new qs(this)}),this.capabilities=Object.freeze([...s]),this.serverAdapter=h,this.src=new ii(this,{collections:u,destination:o??a.getElementById(i),subscriptions:this._subscriptions,nameSyntax:m===null?Wn:nr.fromJSON(m)}),this.#e=rn.install({document:a,root:this.src.renderer.destination}),this.data=this.src.builder.data,this.dvc=new oi(this),this.dom=new si(this),this.utl=new li(this,a),this.state="ready",this.abort=new AbortController,Object.defineProperty(this,"_frames",{value:new hs(this,a)}),p!==null&&(this._pageStore=new fs(this,p,a)),this.rpc=new Hn(this,{rpcUrl:t,closeUrl:r,document:a,transport:l}),this._frames.connect(),this.rpc.transport&&(this.pagehide=g=>{g.persisted||this.dispose()},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 kc(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.callEnvelope("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.value,e.data)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose(){if(this.state!=="disposed"){this.state="disposed",this.dvc.dispose(),this.#e.dispose(),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{if(this._pageStore?.close(),this._frames.dispose(),this.rpc.transport)try{this.rpc.transport.close(this.pageId)}finally{this.rpc.transport.dispose()}}}}};var xa=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new ht}async run(){let{config:e,resources:t,document:r}=this,i=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let s=!1,o,a,l=[],u=new Promise(d=>{o=d}),c=d=>{if(!(d.persisted||s)){s=!0;try{this.closePage()}finally{o(null)}}};i.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((w,E)=>{let D=r.createElement("link");D.rel="stylesheet",D.href=_;let y=()=>{D.removeEventListener("load",T),D.removeEventListener("error",S)};l.push(y);let T=()=>{y(),w()},S=()=>{y(),E(new Error(`${_}: stylesheet load failed`))};D.addEventListener("load",T),D.addEventListener("error",S),r.head.append(D)})),f=t.js.map(async({url:_,group:w})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:w,resource:_}}catch(E){throw new Error(`${_}: import failed: ${E.message}`,{cause:E})}}),h=new Set,m=(t.collections??[]).map(async _=>{if(!_||typeof _!="object"||Object.keys(_).sort().join(",")!=="buildId,name,url"||typeof _.name!="string"||typeof _.url!="string"||typeof _.buildId!="string"||!/^sha256:[0-9a-f]{64}$/.test(_.buildId)||h.has(_.name))throw new TypeError("Invalid or duplicate collection bootstrap record");h.add(_.name);let{name:w,url:E,buildId:D}=_,y;try{y=await import(new URL(E,r.baseURI).href)}catch(T){throw new Error(`${w}: collection import failed: ${T.message}`,{cause:T})}if(y.default?.name!==w||y.buildId!==D)throw new Error(`${w}: collection identity mismatch; expected ${D}, received ${y.buildId}`);return y.default}),p=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(m)]),u]);if(s)return null;let[,b,g]=p;Qr.check(b);for(let _ of g)_.register(i);a=new ui({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...g.map(_=>_.toDocument())]}),i.removeEventListener("pagehide",c);for(let _ of g)_.registerCommands(a);for(let{logicClass:_,group:w,resource:E}of b)a.src.logicRegistry.register(_,{group:w,resource:E});return i.gramlot=a,await a.start(),a}catch(d){throw a?a.dispose():s||this.closePage(),d}finally{for(let d of l)d();i.removeEventListener("pagehide",c)}}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(r){throw new Error(`${e}: server adapter import failed: ${r.message}`,{cause:r})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});try{e.close(this.config.pageId)}finally{e.dispose()}}};var Vs=Symbol("gramlot.source"),ka=Symbol("gramlot.endpoint"),pb=new Map([[Vs,"registerSource"],[ka,"registerEndpoint"]]);function nd(n,e,t,r){let i=pb.get(t);if(e==="main")throw new TypeError(`${i} cannot declare main`);let s=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof s!="function")throw new TypeError(`${i} requires an own method of ${n.name}: ${String(e)}`);if(s[t])throw new TypeError(`${t===Vs?"Source method":"Endpoint"} already registered: ${e}`);if(s[Vs]||s[ka])throw new TypeError(`${e} is declared both as Source method and endpoint`);s[t]={auth:r}}var zs=class{static registerSource(e,{auth:t=null}={}){nd(this,e,Vs,t)}static registerEndpoint(e,{auth:t=null}={}){nd(this,e,ka,t)}},ci=class extends zs{static gramlots=[];static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:r}=this.constructor;if(typeof r!="string"||!r)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+r.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=Oe;main(e){throw new Error("Page.main(root) must be implemented")}};var en=class extends ci{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}),r=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let i of["top","bottom","left","right","center"])if(this[i]!==void 0){let s=r.contentPane({region:i,node_label:i});this[i](s)}this.behavior(t)}center(e){}behavior(e){}};var di=class extends en{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:r}=this.constructor;if(!(t instanceof x))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${r}.navigation`,value:t}),e.dataSetter({destination_path:`${r}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${r}.active`,value:null}),e.dataSetter({destination_path:`${r}.opened`,value:new x}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:".navigation",labelAttribute:"title",hideValues:!0,selectedPath:"^.navigationSelection"})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:"^.active"})}behavior(e){e.dataController({func:"indexMount",_onStart:!0})}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})}};di.registerSource("index_panel");function Aa(n,e,t=()=>{},r=()=>{},{state:i=e.getRelativeData("."),createEntry:s=null,onLoad:o=()=>{}}={}){let a=i.getItem("navigation");if(!(a instanceof x))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d={entries:c,disposed:!1,selecting:!1,sequence:0,requested:null};Object.defineProperty(e,"indexContext",{value:d,configurable:!0});let f=i.getItem("opened");for(let y of f.getNodes()){let{url:T,path:S,title:I}=y.attr,W=l.value.getNode(y.label),ee={url:T,path:S,title:I,pane:W,node:a.getNode(S),loading:!1};r(ee),c.set(T,ee),d.sequence++}let h=(y,T,S)=>{try{o(y.url,T,S)}catch(I){n.binding.reportError(I,"Page load callback failed")}},m=(y,T,S)=>{y.loading&&(y.loading=!1,h(y,T,S))},p=y=>{if(!d.disposed){d.selecting=!0;try{i.setItem("active",y.url),i.setItem("navigationSelection",y.path),t(c,y.url)}finally{d.selecting=!1}}};function b(y){g(y).catch(T=>{d.disposed||n.binding.reportError(T,"Page could not be opened")})}async function g(y){let T=a.getNode(y);if(!T)throw new Error(`Unknown index navigation path: ${y}`);let S=T.attr.url;if(S==null)return;if(typeof S!="string"||!S)throw new TypeError("IndexPage URL must be nonempty text");d.requested=S;let I=c.get(S);if(I){I.path=y,p(I);return}for(;l.value!==null&&l.value.getNode(`page${d.sequence}`);)d.sequence++;let W=K(u.wrapSource(l).contentPane({node_label:`page${d.sequence++}`,title:T.attr.title??T.label,pageName:S,height:"100%",closable:!0})),ee=i.getItem("active");I={url:S,path:y,node:T,pane:W,title:T.attr.title??T.label,loading:!0},c.set(S,I);try{if(h(I,"loading"),d.disposed||c.get(S)!==I||(p(I),d.disposed||c.get(S)!==I))return;if(s)await s(I);else{let se=new x;if(se.setItem(T.label,null,{...T.attr}),!await n.binding.gramlot.src.remoteSource(W,"index_panel",{selection:se}))throw new Error("Panel loading was cancelled")}if(d.disposed||c.get(S)!==I)return;f.setItem(W.label,null,{url:S,path:I.path,title:I.title}),r(I)}catch(se){if(d.disposed||c.get(S)!==I)return;try{if(n.binding.reportError(se,"Page could not be opened"),c.delete(S),f.getNode(W.label)&&f.popNode(W.label),W.parentBag&&W.parentBag.popNode(W.label),!d.disposed&&d.requested===S){let he=c.get(ee);if(d.requested=he?.url??null,he)p(he);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}}finally{m(I,"error",se)}return}d.disposed||c.get(S)!==I||(m(I,"ready"),!d.disposed&&c.get(S)===I&&d.requested===S&&p(I))}let _=`${e.getAttr("id")}-page-close`;e.value.subscribe(_,{any:y=>{if(y.evt!=="del")return;let T=[...c.values()].find(W=>W.pane===y.node);if(!T)return;let{url:S,pane:I}=T;if(!(d.disposed||n.disposed||c.get(S)!==T)){c.delete(S),f.getNode(I.label)&&f.popNode(I.label);try{if(i.getItem("active")===S){let W=[...c.values()].at(-1);if(d.requested=W?.url??null,W)p(W);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}else t(c,i.getItem("active"))}finally{m(T,"cancelled")}}}});let w=`${e.getAttr("id")}-selection`;i.subscribe(w,{any:y=>{if(!(d.selecting||d.disposed)){if(y.node===i.getNode("navigationSelection")){let T=i.getItem("navigationSelection");T!==null&&b(T)}else if(y.node===i.getNode("active")){let T=c.get(i.getItem("active"));T&&(d.requested=T.url,p(T))}}}});let E=()=>{if(!d.disposed){d.disposed=!0,i.unsubscribe(w,{any:!0}),e.value.unsubscribe(_,{any:!0});for(let y of c.values())y.loading&&(y.pane.parentBag&&y.pane.parentBag.popNode(y.pane.label),m(y,"cancelled"));c.clear(),e.indexContext===d&&delete e.indexContext}};d.dispose=E,n.onDispose(e,E);let D=c.get(i.getItem("active"));return D?p(D):i.getItem("navigationSelection")!==null&&b(i.getItem("navigationSelection")),d}var Hs=class{indexMount(e){Aa(this.page.src.renderer,e.parentNode)}};function Ws(n,{datapath:e,value:t,language:r="text",height:i="420px",...s}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=n.borderContainer({datapath:e,height:i,class:"gramlot-editor-options"}),a={language:r,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({...s,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var fi=class n extends Ge{static internalParams=new Set([...Ge.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:r},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:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))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 r=new n({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},hi=class{constructor(e,t){this.gramlot=e,this.source=t,this.request=null,this.resolver=null,this.disposed=!1}get state(){return this.source.getRelativeData(".")}async open(e){this.request?.abort();let t=this.request=new AbortController;this.state.setItem("status","Opening directory\u2026");try{let r=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let i=new fi({gramlot:this.gramlot,root:r.root,onError:o=>this.state.setItem("status",o.message)}),s=i.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=i,this.state.setItem("selectedPath",null),this.state.setItem("store",s),this.state.setItem("writable",r.writable),this.state.setItem("root",r.root),this.state.setItem("status",""),r.root}catch(r){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",r.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},ur=class{fileSystemMount(e){let t=e.parentNode,r=new hi(this.page,t);Object.defineProperty(t,"fileSystemController",{value:r,configurable:!0}),this.page.src.renderer.onDispose(t,()=>r.dispose())}fileSystemOpen(e,{root:t}){if(t)return e.parentNode.fileSystemController.open(t)}};function id(n,{datapath:e,...t}){let r=n.div({datapath:e,class:"gramlot-filesystem",...t});return r.dataSetter({destination_path:".store",value:new x}),r.dataSetter({destination_path:".root",value:null}),r.dataSetter({destination_path:".requestedRoot",value:null}),r.dataSetter({destination_path:".selectedPath",value:null}),r.dataSetter({destination_path:".status",value:""}),r.dataController({func:"fileSystemMount",_onBuilt:!0}),r.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),r.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),r.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),r}var mb=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Gs=class{constructor(e,t){this.gramlot=e,this.source=t,this.pending=new Map,this.disposed=!1}get state(){return this.source.getRelativeData(".")}get documents(){return this.state.getItem("documents")}async open(e,t){let r=mb(e,t),i=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(i)return i.label;if(this.pending.has(r))return this.pending.get(r).promise;let s=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:s.signal}).then(a=>{if(this.disposed||s.signal.aborted)return null;let l=new x;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(r,l),r}).finally(()=>this.pending.delete(r));return this.pending.set(r,{request:s,promise:o}),o}newDocument(e,t,r=""){let i=`new_${Y()}`,s=new x;for(let[o,a]of Object.entries({language:e,root:r,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:r,savePath:`Untitled${t}`}))s.setItem(o,a);return this.documents.setItem(i,s),i}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("saveRoot"),i=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==i.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let s=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:r,path:i,content:s},{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",s),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 r=t.getItem("content"),i=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 s=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!i.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:i,promise:s}),s}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 r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:i,promise:s}),s}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()}},Xs=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(r=>typeof r!="string"||!r))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(r=>r!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new x;return e.forEach((r,i)=>t.setItem(`r${i}`,r,{caption:r})),t}};function Re(n){for(let e=n;e;e=e.parentNode){let t=e.ideContext;if(t)return t}throw new Error("IDE operation requires a node inside a mounted IDE")}var Ys=class{fileSystemMount(e){return ur.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return ur.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){let t=e.parentNode,r={scope:t,documents:new Gs(this.page,t),requested:0,editorPrefix:`ide_${Y()}`,recent:new Xs(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage)};Object.defineProperty(t,"ideContext",{value:r,configurable:!0});let{documents:i,recent:s}=r,o=t.getRelativeData("."),a=s.read();o.setItem("recent",s.choices(a)),o.setItem("workspace",a[0]??"");let l=o.getItem("browser");l.subscribe("ide-browser",{any:c=>{if(c.node===l.getNode("root")){let d=l.getItem("root");o.setItem("workspace",d),o.setItem("recent",s.choices(s.remember(d))),o.setItem("status",`Workspace: ${d}`)}else if(c.node===l.getNode("selectedPath")){let d=l.getItem("selectedPath"),f=d===null?null:l.getItem("store").getNode(d);f&&!f.attr.is_directory&&this.ideOpenDocument(t,l.getItem("root"),f.attr.path)}}});let u=i.documents;u.subscribe("ide-documents",{any:c=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(c.node.label))for(let d of t.value.getNode("frame.center.tabs").value?.getNodes()??[]){let f=d.getAttr("documentKey"),h=i.documents.getItem(f);h&&(c.node===h.getNode("content")&&i.invalidateRecipe(f),this.ideDocumentState(t,f),d.setAttr({title:`${i.dirty(f)?"\u25CF ":""}${h.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(r.scope,()=>{l.unsubscribe("ide-browser",{any:!0}),u.unsubscribe("ide-documents",{any:!0}),i.dispose()})}ideOpenWorkspace(e){let r=Re(e).scope.getRelativeData("."),i=r.getItem("workspace");i&&i!==r.getItem("browser.root")&&r.setItem("browser.requestedRoot",i)}ideDocumentState(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t),o=!i.dirty(t)&&!s.getItem("isNew")||s.getItem("busy");s.setItem("saveDisabled",!!(o||!s.getItem("writable"))),s.setItem("revertDisabled",!!(!i.dirty(t)||s.getItem("busy"))),s.setItem("displayPath",s.getItem("isNew")?s.getItem("path"):`${s.getItem("root")}/${s.getItem("path")}`),s.setItem("pdfFilename",s.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),s.setItem("renderDisabled",!!(s.getItem("busy")||!s.getItem("writable"))),this.ideHistoryState(s)}async ideOpenDocument(e,t,r){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=++i.requested;try{let l=await s.open(t,r);if(l===null||s.disposed)return;this.ideShowDocument(e,l),a===i.requested&&(o.setItem("active",l),o.setItem("status",`${r}${s.documents.getItem(l).getItem("writable")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}catch(l){s.disposed||o.setItem("status",l.message)}}ideNew(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=i.getItem("newType"),o=s==="typstRecipe"?"python":s,a={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"},l=r.newDocument(o,a[s],i.getItem("workspace"));r.documents.getItem(l).setItem("writable",i.getItem("browser.writable")===!0),++t.requested,this.ideShowDocument(e,l),i.setItem("active",l),i.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e,t){let r=Re(e),{documents:i}=r,o=i.documents.getItem(t).getItem("path"),a=r.scope.value.getNode("frame.center.tabs");if(!a.value?.getNode(t)){let l=i.documents.getItem(t),u=o.endsWith(".typ.py");u&&i.invalidateRecipe(t),l.setItem("readonly",!1),this.ideDocumentState(e,t),l.setItem("view","code"),l.setItem("createHidden",!0),l.setItem("undoDisabled",!0),l.setItem("redoDisabled",!0);let c=K(a.builder.wrapSource(a).contentPane({node_label:t,title:o,pageName:t,documentKey:t,closable:!0,onClose:"ideClose",height:"100%"})),d=c.builder.wrapSource(c).div({display:"flex",flex_direction:"column",height:"100%"}),f=d.div({datapath:`.documents.${t}`,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 ${o}`});for(let[y,T,S,I]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 W=f.button({title:S,"aria-label":S,disabled:`^.${y}Disabled`,class:`button--quiet gramlot-ide-${y}`});W.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:T}),W.dataController({func:I,documentKey:t})}u&&f.button("Generate preview",{disabled:"^.renderDisabled",class:"button--quiet"}).dataController({func:"ideRenderRecipe",documentKey:t}),f.div("^.displayPath",{class:"gramlot-ide-document-path",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap",min_width:0,flex:"1"});let h=d.div({datapath:`.documents.${t}`,hidden:"^.createHidden",padding:"8px 12px",display:"flex",gap:"8px",align_items:"end",flex_shrink:0});h.textbox({value:"^.saveRoot",lbl:"Directory",flex:"1",disabled:"^.busy"}),h.textbox({value:"^.savePath",lbl:"File name",flex:"1",disabled:"^.busy"}),h.button("Create file",{disabled:"^.busy"}).dataController({func:"ideCreate",documentKey:t}),h.button("Cancel",{disabled:"^.busy",class:"button--quiet"}).dataController({func:"ideCancelCreate",documentKey:t});let m=d.div({flex:"1",min_height:0}),p=l.getItem("language")==="html",b=l.getItem("language")==="markdown",g=p||b,_=l.getItem("language")==="typst",w=g||_||u,E=w?m.tabContainer({height:"100%",selectedPage:`^.documents.${t}.view`}):null,D=w?E.contentPane({title:"Code",pageName:"code",height:"100%"}):m;if(Ws(D,{datapath:`.documents.${t}`,value:"^.content",language:l.getItem("language"),height:"100%",readonly:"^.readonly",nodeId:`${r.editorPrefix}_editor_${t}`,editorView:"code",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_editor_${t}_save`]:!0}),_&&E.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${t}.content`,filename:`^.documents.${t}.pdfFilename`,height:"100%"}),u){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});y.div(`^.documents.${t}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),y.typstPreview({value:`^.documents.${t}.typstSource`,filename:`^.documents.${t}.pdfFilename`,hidden:`^.documents.${t}.previewHidden`,flex:"1",min_height:0}),E.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${t}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(g){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});b&&(l.setItem("allowHtml",!1),y.checkbox({value:`^.documents.${t}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),y[p?"htmlPreview":"markdownPreview"]({value:`^.documents.${t}.content`,flex:"1",min_height:0,...b?{allowHtml:`^.documents.${t}.allowHtml`}:{}}),E.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[p?"htmlEditor":"markdownEditor"]({datapath:`.documents.${t}`,value:"^.content",readonly:"^.readonly",height:"100%",nodeId:`${r.editorPrefix}_rich_editor_${t}`,editorView:"rich",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_rich_editor_${t}_save`]:!0})}}}async ideRenderRecipe(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("view","preview"),await i.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");s.setItem("status","Creating file\u2026");try{let o=await i.create(t);if(!i.disposed&&o){s.setItem("status","File created.");let a=s.getItem("browser");a.getItem("root")&&await r.scope.value.getNode("frame.left.browser").fileSystemController.open(a.getItem("root"))}}catch(o){i.disposed||s.setItem("status",o.message)}}async ideSave(e,{documentKey:t=null}={}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData("."),o=t??s.getItem("active");if(!o||i.documents.getItem(o).getItem("saveDisabled"))return;let a=i.documents.getItem(o);if(a.getItem("isNew")){a.setItem("createHidden",!1);return}s.setItem("status","Saving\u2026");try{let l=await i.save(o);i.disposed||s.setItem("status",l?"Saved.":"Document is read only or a request is pending.")}catch(l){i.disposed||s.setItem("status",l.message)}}ideRevert(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");i.revert(t)&&s.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let i=e.getRelativeData("."),s=e.getAttr("editorView");i.setItem(`${s}CanUndo`,t),i.setItem(`${s}CanRedo`,r),this.ideHistoryState(i)}ideHistoryState(e){let t=e.getItem("view");e.setItem("undoDisabled",!e.getItem(`${t}CanUndo`)),e.setItem("redoDisabled",!e.getItem(`${t}CanRedo`))}ideEditor(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t).getItem("view")==="rich",o=this.page.src.binding.nodeIds.get(`${r.editorPrefix}_${s?"rich_":""}editor_${t}`);return this.page.src.renderer.records.get(o).element}ideUndo(e,{documentKey:t}){this.ideEditor(e,t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(e,t).redo()}ideClose(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=e.getAttr("documentKey");return r.canClose(s)?!0:(i.setItem("status","Save or revert your changes before closing. Pending operations must finish first."),!1)}ideClosed(e,{pageName:t}){this.ideForgetDocument(e,t)}ideForgetDocument(e,t,r=!1){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=s.documents.getItem(t),l=o.getItem("browser"),u=l.getItem("selectedPath"),c=u===null?null:l.getItem("store").getNode(u);a&&l.getItem("root")===a.getItem("root")&&c?.attr.path===a.getItem("path")&&l.setItem("selectedPath",null),s.close(t,r)}};var Ta=class n extends Ge{static internalParams=new Set([...Ge.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:r,onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method=t,this.params={directory:r},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:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))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 r=new n({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function cr(n,e){return e===2?n%4===0&&(n%100!==0||n%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function $e(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>cr(n,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(n).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function dr(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=n.split("-").map(Number);return $e(...e),e}function pi(n,e,t){let r=n-1,i=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let s=1;s<e;s++)i+=cr(n,s);return i}function mi(n,e){let t=pi(...dr(n))+e;if(!Number.isSafeInteger(t)||t<0||t>pi(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,i=1e4;for(;i-r>1;){let o=Math.floor((r+i)/2);pi(o,1,1)<=t?r=o:i=o}t-=pi(r,1,1);let s=1;for(;t>=cr(r,s);)t-=cr(r,s++);return $e(r,s,t+1)}function Da(n){return mi(n,-(pi(...dr(n))%7))}function sd(n,e,t=0,r=1){let i=n*12+e-1+t,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+r-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:$e(s,o,1),end:$e(l,u,cr(l,u))}}var Zs={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"}},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"}}};function od(n){if(typeof n!="string")throw new RangeError("A supported locale is required.");let e=n.replaceAll("-","_"),t=e.indexOf("_"),r=(t<0?e:e.slice(0,t)).toLowerCase(),i=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(Zs,r))throw new RangeError(`Unsupported locale: ${n}`);let s=Zs[r];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...Zs.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var fr=/^(?:\d{4}|\d{2})$/,ad=/^\d{1,2}$/,gi=(n,e)=>({ok:!1,error:{code:n,message:e}}),pr=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},cd=(n,e)=>Object.hasOwn(n,e);function hr(n,e){if(n.length===4)return Number(n);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(n)-t)%100+100)%100}function gb(n,e){if(n.includes(";")){let i=n.split(";").map(s=>s.trim());return i.length!==2?pr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let i of t)if(n.startsWith(`${i} `))return{bounds:["",n.slice(i.length+1).trim()],range:!0};for(let i of t){let s=` ${i} `;if(!n.includes(s))continue;for(let a of r)if(n.startsWith(`${a} `)){n=n.slice(a.length+1);break}let o=n.split(s).map(a=>a.trim());return o.length!==2?pr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of r)if(n.startsWith(`${i} `))return{bounds:[n.slice(i.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function bb(n,e,t){let r=[[n,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);i&&r.push([i[1],Number(i[2]+i[3])]);let s={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 r)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return mi(Da(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=sd(e.year,e.month,u+a);return t?c.end:c.start}return mi(e.workdate,u+a)}return null}function _b(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of r){let o;if(n===i)o=null;else if(n.startsWith(i)&&fr.test(n.slice(i.length).trim()))o=hr(n.slice(i.length).trim(),e);else if(n.endsWith(i)&&fr.test(n.slice(0,-i.length).trim()))o=hr(n.slice(0,-i.length).trim(),e);else continue;return{year:o,month:t?s*3:s*3-2}}return null}function ld(n,e){if(cd(e.months,n))return e.months[n];let t=/^m(\d{1,2})$/.exec(n);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function wb(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>ld(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return pr();let i=r[0],s=ld(t[i],e.dictionary),o=t.slice(0,i),a=t.slice(i+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(s>e.month?1:0),month:s};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(s<e.month?1:0),month:s};if(!l.length)return{year:null,month:s};if(!o.length&&a.length===1&&fr.test(a[0]))return{year:hr(a[0],e),month:s};if(o.length===1&&ad.test(o[0])){if(!a.length)return $e(e.year,s,Number(o[0]));if(a.length===1&&fr.test(a[0]))return $e(hr(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&ad.test(a[0])&&fr.test(a[1])?$e(hr(a[1],e),s,Number(a[0])):pr()}function yb(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return $e(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),i={};if(r)e.order.split("").forEach((a,l)=>{i[a]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let a=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!fr.test(i.Y)||i.D.length>2||i.M.length>2)return pr();let s=Number(i.D),o=Number(i.M);return r&&o>12&&s<=12&&([s,o]=[o,s]),$e(hr(i.Y,e),o,s)}function ud(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(s=>!r.includes(s)).join(" "),!n)return pr();if(fr.test(n))return $e(hr(n,e),t?12:1,t?31:1);let i=bb(n,e,t)??_b(n,e,t)??wb(n,e);return i!==null?i:cd(e.dictionary.weekdays,n)?mi(Da(e.workdate),e.dictionary.weekdays[n]):yb(n,e)??pr()}function vb(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,i=typeof e=="string"?dr(e)[0]:e?.year,s=typeof e=="string"?dr(e)[1]:e?.month;return i&&(r>i&&(r=i),r===i&&n.month>s&&r--),$e(r,n.month,1)}function Eb(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[i,s]=dr(e);r<i&&(r=i),r===i&&s>n.month&&r++}return $e(r,n.month,cr(r,n.month))}function dd(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return gi("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=dr(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...od(r),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(r){return gi("INVALID_CONTEXT",r.message)}if(typeof n!="string")return gi("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=gb(r,t),o=ud(i[1],t,!0),a=ud(i[0],t,!1),l=vb(a,o,t),u=Eb(o,l,t);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return gi("INVALID_DATE",r.message);if(r instanceof SyntaxError)return gi(r.code,r.message);throw r}}function Ca(n){return class extends n{setLabelbox(e){let{box:t,labelBox:r,fieldLabel:i}=e;Object.assign(this,{box:t,labelBox:r,fieldLabel:i}),i.addEventListener("click",()=>{this.control.focus(),this.control.localName==="input"&&["checkbox","radio"].includes(this.control.type)&&this.control.click()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.lbl??"";return i?this.control.setAttribute("aria-label",i):this.control.removeAttribute("aria-label"),r}}}Ca.labelbox=!0;Ca.parameters={lbl:{dtype:"T",qualification:"intl_str",nullable:!0,binding:"read"},lbl_position:{dtype:"T",default:"TL",binding:"read",enum:oa}};var Ia=["select","notnull","empty","case","len","min","max","email","regex","call","remote"],xb=["nodup","exist","gridnodup"],Js=n=>n==null||n==="",Sa=(n,e)=>n instanceof Promise?n.then(e):e(n);function fd(n,e,t={}){let r={value:n,modified:!1,error:null,warnings:[],issues:[],datachanges:[]},i=Object.fromEntries(Object.entries(e).map(([u,c])=>[u.slice(9),c])),s=u=>Object.hasOwn(e,`validate_${u}`)&&e[`validate_${u}`]!=null;for(let u of xb)if(s(u))throw new Error(`validate_${u} requires the DB/grid integration.`);let o=(u,c,d=!1)=>t.invoke(u,e[u],{...i,value:c,result:r,validations:i,userChange:!0,signal:t.signal},d),a=(u,c)=>{if(c==null||c===!0)return;if(typeof c!="boolean"&&typeof c!="string"&&(typeof c!="object"||Array.isArray(c)))throw new TypeError("A validator returns true, false, null, an error code, or a result object/Bag.");let d=`validate_${u}`,f=c instanceof x?Object.fromEntries(c.getNodes().map(g=>[g.label,g.value])):typeof c=="object"?c:{errorcode:c===!1?"error":c};if(Object.hasOwn(f,"value")&&(r.modified||=!Object.is(r.value,f.value),r.value=f.value),f.data!=null&&(t.checkDataPatch(f.data),r.datachanges.push(f.data)),!f.errorcode)return;let h=e[`${d}_iswarning`]??f.iswarning??!!(e[`${d}_warning`]&&!e[`${d}_error`]),m=e[`${d}_${f.errorcode}`]||e[`${d}_${h?"warning":"error"}`]||f.message||e[`${d}_${h?"error":"warning"}`]||String(f.errorcode),p=Gt(m,g=>g?{...i,...f,value:r.value}[g]:r.value);if(p==null)throw new Error("A validation message references a missing value.");let b={rule:u,code:f.errorcode,severity:h?"warning":"error",message:p};r.issues.push(b),h?r.warnings.push(p):(r.error=p,r.required=!!f.required)},l=u=>{if(t.signal?.aborted)throw t.signal.reason;if(r.error||u===Ia.length)return r;let c=Ia[u],d=`validate_${c}`,f=e[d];if(!s(c)||f===!1&&c!=="empty")return l(u+1);let h=p=>{if(!p)return l(u+1);let b;return c==="remote"&&r.value==null?l(u+1):(c==="call"?b=o(d,r.value):c==="remote"?b=t.remote(f,{...kb(e),value:r.value},t.signal):b=Ab(c,f,r.value,t),Sa(b,g=>{if(t.signal?.aborted)throw t.signal.reason;let _=()=>(a(c,g),l(u+1));return c==="remote"&&e.validate__onResult?Sa(t.invoke("validate__onResult",e.validate__onResult,{result:g,value:r.value,validations:i,signal:t.signal}),_):_()}))},m=e[`${d}_if`];return Sa(m==null?!0:typeof m=="boolean"?m:o(`${d}_if`,r.value,!0),h)};return l(0)}function kb(n){let e=new Set(["if","error","warning","iswarning"]);return Object.fromEntries(Object.entries(n).filter(([t])=>t.startsWith("validate_remote_")&&!e.has(t.slice(16))).map(([t,r])=>[t.slice(16),r]))}function bi(n,e,t={}){return{errorcode:n,message:e,...t}}function Ab(n,e,t,r){if(n==="select")return r.selection(t);if(n==="notnull")return Js(t)&&e?bi("notnull","A value is required.",{required:!0}):null;if(n==="empty")return Js(t)?{value:e}:null;if(n==="len"){if(typeof e!="string"||!/^(?:\d+|\d+:\d*|:\d+)$/.test(e))throw new Error("Invalid validate_len: use a length or min:max.");let[i,s]=e.split(":"),o=Number(i||0),a=s===void 0?o:s===""?1/0:Number(s);if(o>a)throw new Error("Invalid validate_len: minimum exceeds maximum.");if(Js(t))return;if(typeof t!="string")throw new TypeError("validate_len requires a text value.");return t.length<o||t.length>a?bi(o===a?"wrong length":t.length<o?"too short":"too long",o===a?`Enter exactly ${o} characters.`:a===1/0?`Enter at least ${o} characters.`:o===0?`Enter no more than ${a} characters.`:`Enter between ${o} and ${a} characters.`):void 0}if(!Js(t)){if(n==="case"){if(typeof t!="string")throw new TypeError("validate_case requires a text value.");switch(e){case"upper":case"u":return{value:t.toUpperCase()};case"lower":case"l":return{value:t.toLowerCase()};case"title":case"t":return{value:t.replace(/\p{L}[\p{L}\p{M}]*/gu,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())};case"capitalize":case"c":return{value:t[0].toUpperCase()+t.slice(1).toLowerCase()};default:throw new Error("Invalid validate_case: use upper, lower, title or capitalize.")}}if(n==="min"||n==="max"){let i;if(r.isDecimal?.(t))i=t.comparedTo(e);else if(t instanceof Date&&e instanceof Date)i=t.getTime()-e.getTime();else if(typeof t=="number"&&Number.isFinite(t)&&typeof e=="number"&&Number.isFinite(e))i=t-e;else throw new TypeError(`validate_${n} requires matching numeric or date/time values.`);return(n==="min"?i<0:i>0)?bi(n,`Value must be ${n==="min"?"at least":"at most"} ${e}.`):void 0}if(n==="email"){if(typeof t!="string")throw new TypeError("validate_email requires a text value.");return/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(t)?null:bi("email","Check email format.",{iswarning:!0})}if(n==="regex"){if(typeof t!="string"||typeof e!="string")throw new TypeError("validate_regex requires text.");let i=e.trim(),s=i.startsWith("!");return new RegExp(s?i.slice(1):i,"u").test(t)!==s?null:bi("regex","The value does not match the required pattern.")}}}var _i={dtype:"T",nullable:!0,binding:"read"},Ks={dtype:"B",nullable:!0,binding:"read"},Na={dtype:["T","L","N","R","B","D","H","DH","DHZ"],nullable:!0,binding:"read"},hd={validate_select:Ks,validate_notnull:{...Ks,default:!1},validate_empty:Na,validate_case:{..._i,enum:["upper","lower","title","capitalize","u","l","t","c"]},validate_len:_i,validate_min:Na,validate_max:Na,validate_email:Ks,validate_regex:_i,validate_call:{dtype:"T",nullable:!0},validate_remote:_i,validate_onAccept:{dtype:"T",nullable:!0},validate_onReject:{dtype:"T",nullable:!0},validate__onResult:{dtype:"T",nullable:!0},validate_timeout:{dtype:"L",nullable:!0,binding:"read"},...Object.fromEntries(Ia.flatMap(n=>[[`validate_${n}_if`,{dtype:["T","B"],nullable:!0}],[`validate_${n}_iswarning`,Ks],...["error","warning"].map(e=>[`validate_${n}_${e}`,{..._i,qualification:"intl_str"}])]))};var Tb=1800,pd=200;function md(n){return class extends n{#e=!1;#t;#r;#n;#i;#s=0;#o;#a={};validationResult=null;constructor(){super(),this.message=this.ownerDocument.createElement("small"),this.message.id="field-message",this.message.hidden=!0,this.message.setAttribute("aria-live","polite"),this.message.setAttribute("popover","manual"),this.message.setAttribute("role","tooltip");let e=this.ownerDocument.createElement("style");e.textContent=`#control[aria-invalid="true"]{background:var(--gramlot-error-background,#fff1f0)}
|
|
198
198
|
input#control[aria-invalid="true"],textarea#control[aria-invalid="true"]{color:var(--gramlot-error,#8c1d18)}
|
|
199
199
|
#field-message{position:fixed;inset:auto;margin:0;padding:.4em .65em;border:1px solid var(--gramlot-error,#b3261e);border-radius:var(--gramlot-radius-sm,4px);
|
|
200
200
|
color:var(--gramlot-error,#8c1d18);background:var(--gramlot-error-background,#fff1f0);font:inherit;font-size:.85em;box-shadow:var(--gramlot-shadow,0 2px 8px #0003);
|
|
201
|
-
max-width:min(28em,var(--gramlot-popup-available-width,100vw));max-height:var(--gramlot-popup-available-height,100vh);overflow:auto;overflow-wrap:anywhere;opacity:1;transition:opacity ${
|
|
201
|
+
max-width:min(28em,var(--gramlot-popup-available-width,100vw));max-height:var(--gramlot-popup-available-height,100vh);overflow:auto;overflow-wrap:anywhere;opacity:1;transition:opacity ${pd}ms ease-out}
|
|
202
202
|
#field-message[data-severity="warning"]{color:var(--gramlot-warning,#805600);border-color:var(--gramlot-warning,#805600);background:var(--gramlot-warning-background,#fff8df)}
|
|
203
203
|
#field-message[data-fading]{opacity:0}
|
|
204
|
-
@media(prefers-reduced-motion:reduce){#field-message{transition:none}}`,this.shadowRoot.append(e),this.control.setAttribute("aria-describedby",this.message.id),this.controlBox.append(this.message),this.control.addEventListener("input",()=>this.cancelValidation()),this.control.addEventListener("compositionstart",()=>this.cancelValidation()),this.control.addEventListener("focusin",()=>this.#c()),this.control.addEventListener("mouseenter",()=>this.#c()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#l())})}#l(){this.ownerDocument.defaultView.clearTimeout(this.#r),this.#n?.abort(),this.#n=null,this.message.hidden||this.message.hidePopover(),this.message.hidden=!0,this.message.removeAttribute("data-fading")}#c(){if(!this.message.textContent||!this.isConnected)return;this.#l();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),
|
|
205
|
-
`),this.#c());let f={ok:!d.error,value:d.value,result:d,rules:s,isCurrent:a};return f.ok||this.finishValidation(f),f},c;try{if(s.validate_timeout!=null&&(!Number.isInteger(s.validate_timeout)||s.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");c=
|
|
204
|
+
@media(prefers-reduced-motion:reduce){#field-message{transition:none}}`,this.shadowRoot.append(e),this.control.setAttribute("aria-describedby",this.message.id),this.controlBox.append(this.message),this.control.addEventListener("input",()=>this.cancelValidation()),this.control.addEventListener("compositionstart",()=>this.cancelValidation()),this.control.addEventListener("focusin",()=>this.#c()),this.control.addEventListener("mouseenter",()=>this.#c()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#l())})}#l(){this.ownerDocument.defaultView.clearTimeout(this.#r),this.#n?.abort(),this.#n=null,this.message.hidden||this.message.hidePopover(),this.message.hidden=!0,this.message.removeAttribute("data-fading")}#c(){if(!this.message.textContent||!this.isConnected)return;this.#l();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),Vr(this.message,this.control),this.#r=e.setTimeout(()=>{this.message.hidden||(this.message.setAttribute("data-fading",""),this.#r=e.setTimeout(()=>this.#l(),pd))},Tb),this.#n=new e.AbortController;let t={capture:!0,signal:this.#n.signal};e.addEventListener("scroll",()=>this.#l(),t),e.addEventListener("resize",()=>this.#l(),t)}releaseControl(){this.cancelValidation(),this.#l(),super.releaseControl()}disconnectedCallback(){this.releaseControl()}setFieldState({invalid:e=!1,pending:t=!1}={}){this.control.setAttribute("aria-invalid",String(e)),this.control.setAttribute("aria-busy",String(t))}error(e){this.#e=!1,["input","textarea"].includes(this.control.localName)&&this.control.setCustomValidity(e),this.control.setAttribute("aria-invalid",String(!!e)),this.message.textContent=e,e?this.#c():this.#l()}cancelValidation(){this.#s++,this.#i?.abort(),this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false")}validateCandidate(e,t){this.cancelValidation();let r=new AbortController;this.#i=r;let i=this.#s,s=this.#a,o=this.pageContext.validationCurrent();this.#o=o;let a=()=>this.#s===i&&!r.signal.aborted&&o(),l=d=>({value:e,modified:!1,error:d.message,warnings:[],issues:[],datachanges:[]}),u=d=>{if(!a())return this.#i===r&&this.cancelValidation(),{ok:!1};this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false");try{d.error||t(d.value)}catch(h){d=l(h)}this.validationResult=d,this.error(d.error||""),this.message.dataset.severity=d.error?"error":"warning",this.#e=!!d.error,!d.error&&d.warnings.length&&(this.message.textContent=d.warnings.join(`
|
|
205
|
+
`),this.#c());let f={ok:!d.error,value:d.value,result:d,rules:s,isCurrent:a};return f.ok||this.finishValidation(f),f},c;try{if(s.validate_timeout!=null&&(!Number.isInteger(s.validate_timeout)||s.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");c=fd(e,s,{...this.pageContext,signal:r.signal,selection:d=>this.validateSelection(d)})}catch(d){return u(l(d))}return c instanceof Promise?(this.control.setAttribute("aria-busy","true"),new Promise(d=>{let f,h=()=>{clearTimeout(f),d({ok:!1})};r.signal.addEventListener("abort",h,{once:!0});let m=p=>{clearTimeout(f),r.signal.removeEventListener("abort",h),d(u(p))};s.validate_timeout!=null&&(f=setTimeout(()=>{m(l(new Error("Validation timed out."))),r.abort()},s.validate_timeout)),c.then(m,p=>m(l(p)))})):u(c)}finishValidation(e){e.result&&this.pageContext.finishValidation(e)}shouldProjectControlValue(e){this.#o&&!this.#o()&&this.cancelValidation();let t=this.sameControlValue(e,this.#t);return t&&this.#e?!1:(t||this.cancelValidation(),this.#t=e,!t&&this.#e&&this.error(""),!0)}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=Object.fromEntries(Object.entries(e).filter(([a])=>a.startsWith("validate_")));([...new Set([...Object.keys(i),...Object.keys(this.#a)])].some(a=>!Object.is(i[a],this.#a[a]))||e.disabled||e.readonly)&&this.cancelValidation(),this.#a=i;for(let a of Object.keys(i))delete r[a];let o=!!this.parameters.validate_notnull;return this.control.setAttribute("aria-required",String(o)),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.required=o),r}}}md.parameters=hd;var tn=new TextEncoder,gd=n=>`export {default} from "./collection.js";
|
|
206
206
|
export const buildId = "${n}";
|
|
207
|
-
`,
|
|
207
|
+
`,Oa=n=>typeof n=="string"&&n.length>0&&!/[\\\x00-\x1f:?#%]/.test(n)&&!n.split("/").some(e=>!e||e==="."||e==="..");function bd(n,e){if(!n||typeof n.name!="string"||!n.name||!["grammar","commands","module"].every(t=>Oa(n[t]))||!Array.isArray(n.css)||!n.css.every(Oa)||!Array.isArray(n.dependencies)||!n.dependencies.every(t=>typeof t=="string"&&t.length>0)||!Array.isArray(n.files)||!n.files.every(Oa)||new Set(n.files).size!==n.files.length||!(e instanceof Map)||e.size!==n.files.length||n.files.some(t=>!(e.get(t)instanceof Uint8Array))||[n.grammar,n.commands,n.module,...n.css].some(t=>!e.has(t)))throw new TypeError("Invalid collection artifact metadata or file inventory")}async function _d(n,e){bd(n,e);let t=[tn.encode("gramlot-build-v1\0")],r=(l,u)=>{let c=typeof u=="string"?tn.encode(u):u;t.push(tn.encode(`${l}\0${c.length}\0`),c)};for(let l of["name","grammar","commands","module"])r(l,n[l]);for(let l of n.css)r("css",l);for(let l of n.dependencies)r("dependency",l);let i=(l,u)=>{let c=tn.encode(l),d=tn.encode(u);for(let f=0;f<Math.min(c.length,d.length);f++)if(c[f]!==d[f])return c[f]-d[f];return c.length-d.length};for(let l of[...n.files].sort(i))r("path",l),r("content",l===n.module?gd("__GRAMLOT_BUILD_ID__"):e.get(l));let s=new Uint8Array(t.reduce((l,u)=>l+u.length,0)),o=0;for(let l of t)s.set(l,o),o+=l.length;let a=await crypto.subtle.digest("SHA-256",s);return"sha256:"+[...new Uint8Array(a)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function Db(n,e){if(bd(n,e),typeof n.buildId!="string"||!/^sha256:[a-f0-9]{64}$/.test(n.buildId))throw new TypeError("Invalid collection buildId");let t=tn.encode(gd(n.buildId)),r=e.get(n.module);if(r.length!==t.length||r.some((i,s)=>i!==t[s]))throw new Error("Invalid collection wrapper");if(await _d(n,e)!==n.buildId)throw new Error(`Collection fingerprint mismatch: ${n.name}`)}export{x as Bag,ze as BagNode,Ec as ChoiceGroup,nn as CommandRegistry,Ot as ComponentCollection,oi as DeviceHandler,fi as DirectoryResolver,si as DomHandler,zs as Exposed,md as FieldState,hi as FileSystemController,ur as FileSystemLogic,en as FramePage,ui as Gramlot,Oe as GramlotBuilder,sr as GramlotHtmlRenderer,ni as GramlotRenderer,Zn as GramlotSvgRenderer,De as Handler,sn as HttpTransport,Ys as IdeLogic,ai as InOut,Hs as IndexLogic,di as IndexPage,Ca as Labelbox,rn as MobileEnvironment,vc as NativeControl,Ta as NavigationResolver,ci as Page,xa as PageBootstrap,zn as References,rr as RpcError,Hn as RpcHandler,ht as ServerAdapter,ii as SourceHandler,li as UtilitiesHandler,Ws as codeMirrorWithOptions,_d as collectionBuildId,Tt as createDecimal,la as defineCollection,Bt as defineComponent,id as fileSystemTree,Aa as mountIndexPage,dd as parseDateExpression,Db as verifyCollectionArtifact};
|
|
208
208
|
/*! Bundled license information:
|
|
209
209
|
|
|
210
210
|
decimal.js/decimal.mjs:
|