@gramlot/gramlot 0.3.26 → 0.3.27
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/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +16 -16
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/collection.js +28 -19
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +21 -0
- package/dist/components/grouplets/__init__.py +1 -1
- package/dist/components/grouplets/assets/collection.js +2 -2
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +21 -21
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +15 -15
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +11 -11
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +8 -8
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/gramlot.js +624 -86
- package/dist/gramlot.min.js +47 -46
- package/package.json +1 -1
- package/src/binding/grid-struct.js +1 -1
- package/src/binding/validation-context.js +2 -1
- package/src/components/bases.js +5 -3
- package/src/components/choice-editor.js +28 -13
- package/src/components/database-choices.js +9 -6
- package/src/components/field-state.js +8 -1
- package/src/components/grid-cell-editor.js +83 -19
- package/src/components/grid-grammar.json +21 -0
- package/src/components/grid-structure.js +4 -1
- package/src/components/grid-styles.js +11 -2
- package/src/components/grid.js +16 -1
- package/src/components/inputs.js +2 -2
- package/src/components/parameters.js +6 -2
- package/src/components/tree.js +1 -0
- package/src/components/typed-editor.js +4 -4
- package/src/components/validation.js +1 -1
- package/src/editing-session.d.ts +1 -0
- package/src/editing-session.js +113 -15
- package/src/editor-values.js +57 -0
- package/src/gramlot.d.ts +1 -0
- package/src/gramlot.js +7 -4
- package/src/index.d.ts +1 -1
- package/src/renderer/gramlot-renderer.d.ts +1 -0
- package/src/renderer/gramlot-renderer.js +11 -0
- package/src/server/source-import.d.ts +1 -1
- package/src/server/source-import.js +5 -1
- package/src/server/visual-editor.d.ts +1 -1
- package/src/server/visual-editor.js +30 -20
- package/src/source-picker.d.ts +1 -1
- package/src/source-picker.js +1 -2
- package/src/visual-editor-canvas.js +29 -0
- package/src/visual-editor-catalogue.js +34 -0
- package/src/visual-editor.d.ts +5 -0
- package/src/visual-editor.js +244 -26
- package/themes/gramlot-base/theme.css +78 -36
- package/tools/gramlot-tools-inspector.js +1 -1
- package/tools/inspector-agent.js +1 -1
package/dist/gramlot.min.js
CHANGED
|
@@ -6,38 +6,38 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
var ng=Object.create;var Dl=Object.defineProperty;var og=Object.getOwnPropertyDescriptor;var ig=Object.getOwnPropertyNames;var ag=Object.getPrototypeOf,sg=Object.prototype.hasOwnProperty;var rr=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},lg=(n,e)=>{for(var t in e)Dl(n,t,{get:e[t],enumerable:!0})},ug=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ig(e))!sg.call(n,o)&&o!==t&&Dl(n,o,{get:()=>e[o],enumerable:!(r=og(e,o))||r.enumerable});return n};var pd=(n,e,t)=>(t=n!=null?ng(ag(n)):{},ug(e||!n||!n.__esModule?Dl(t,"default",{value:n,enumerable:!0}):t,n));var Vr=rr($e=>{"use strict";function Rb(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(Ur(n,r)){var o=n[r];if(e.call(void 0,o,r,n))return o}}function Nn(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 Ur(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Bb(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Ur(e,t)&&(n[t]=e[t]);return n}var Xd=Nn({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 $b(n){return Ur(Xd,n.toLowerCase())}var Zd=Nn({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 Mb(n){return Ur(Zd,n.toLowerCase())}var Mo=Nn({script:!1,style:!1,textarea:!0,title:!0});function Pb(n){var e=n.toLowerCase();return Ur(Mo,e)&&!Mo[e]}function Lb(n){var e=n.toLowerCase();return Ur(Mo,e)&&Mo[e]}function Kd(n){return n===Po.HTML}function Fb(n){return Kd(n)||n===Po.XML_XHTML_APPLICATION}var Po=Nn({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),jb=Object.keys(Po).map(function(n){return Po[n]});function qb(n){return jb.indexOf(n)>-1}var Ub=Nn({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/"});$e.assign=Bb;$e.find=Rb;$e.freeze=Nn;$e.HTML_BOOLEAN_ATTRIBUTES=Xd;$e.HTML_RAW_TEXT_ELEMENTS=Mo;$e.HTML_VOID_ELEMENTS=Zd;$e.hasDefaultHTMLNamespace=Fb;$e.hasOwn=Ur;$e.isHTMLBooleanAttribute=$b;$e.isHTMLRawTextElement=Pb;$e.isHTMLEscapableRawTextElement=Lb;$e.isHTMLMimeType=Kd;$e.isHTMLVoidElement=Mb;$e.isValidMimeType=qb;$e.MIME_TYPE=Po;$e.NAMESPACE=Ub});var Uo=rr(qo=>{"use strict";var Vb=Vr();function Qd(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var Fo=Vb.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"}),ef=Object.keys(Fo);function tf(n){return typeof n=="number"&&n>=1&&n<=25}function zb(n){return typeof n=="string"&&n.substring(n.length-Fo.Error.length)===Fo.Error}function jo(n,e){tf(n)?(this.name=ef[n],this.message=e||""):(this.message=n,this.name=zb(e)?e:Fo.Error),Error.captureStackTrace&&Error.captureStackTrace(this,jo)}Qd(jo,!0);Object.defineProperties(jo.prototype,{code:{enumerable:!0,get:function(){var n=ef.indexOf(this.name);return tf(n)?n:0}}});var rf={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},zl=Object.entries(rf);for(Lo=0;Lo<zl.length;Lo++)Jd=zl[Lo][0],jo[Jd]=zl[Lo][1];var Jd,Lo;function Hl(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,Hl)}Qd(Hl);qo.DOMException=jo;qo.DOMExceptionName=Fo;qo.ExceptionCode=rf;qo.ParseError=Hl});var Jl=rr(H=>{"use strict";function uf(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 Rn=uf();function ur(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function In(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,""),Rn?"u":"")}function Y(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(""),Rn?"u":"")}function U(n){if(arguments.length===0)throw new Error("no parameters provided");return Y.apply(U,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var Hb="\uFFFD",cr=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;Rn&&(cr=Y("[",ur(cr),"\\u{10000}-\\u{10FFFF}","]"));var Gb=new RegExp("[^"+ur(cr)+"]",Rn?"u":""),xa=/[\x20\x09\x0D\x0A]/,Wb=ur(xa),ue=Y(xa,"+"),_e=Y(xa,"*"),Vo=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;Rn&&(Vo=Y("[",ur(Vo),"\\u{10000}-\\u{10FFFF}","]"));var Yb=ur(Vo),Yl=Y("[",Yb,ur(/[-.0-9\xB7]/),ur(/[\u0300-\u036F\u203F-\u2040]/),"]"),st=Y(Vo,Yl,"*"),Xb=Y("^",st,"$"),nf=Y(Yl,"+"),Zb=Y("&",st,";"),Kb=U(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),zo=U(Zb,"|",Kb),Ho=Y("%",st,";"),Xl=U(Y('"',U(/[^%&"]/,"|",Ho,"|",zo),"*",'"'),"|",Y("'",U(/[^%&']/,"|",Ho,"|",zo),"*","'")),Jb=U('"',U(/[^<&"]/,"|",zo),"*",'"',"|","'",U(/[^<&']/,"|",zo),"*","'"),Qb=In(Vo,":"),ew=In(Yl,":"),Gl=Y(Qb,ew,"*"),tw=Y("^",Gl,"$"),Go=Y(Gl,U(":",Gl),"?"),rw=Y("^",Go,"$"),nw=Y("(",Go,")"),On=U(/"[^"]*"|'[^']*'/),ow=Y(/^<\?/,"(",st,")",U(ue,"(?!",xa,")(",cr,"*?)"),"?",/\?>/),of=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,Wo=U('"',of,'*"',"|","'",In(of,"'"),"*'"),cf="<!--",df="-->",iw=Y(cf,U(In(cr,"-"),"|",Y("-",In(cr,"-"))),"*",df),af="#PCDATA",aw=U(Y(/\(/,_e,af,U(_e,/\|/,_e,Go),"*",_e,/\)\*/),"|",Y(/\(/,_e,af,_e,/\)/)),sw=/[?*+]?/,lw=Y(/\([^>]+\)/,sw),uw=U("EMPTY","|","ANY","|",aw,"|",lw),cw="<!ELEMENT",dw=Y(cw,ue,U(Go,"|",Ho),ue,U(uw,"|",Ho),_e,">"),fw=Y("NOTATION",ue,/\(/,_e,st,U(_e,/\|/,_e,st),"*",_e,/\)/),hw=Y(/\(/,_e,nf,U(_e,/\|/,_e,nf),"*",_e,/\)/),pw=U(fw,"|",hw),mw=U(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",pw),gw=U(/#REQUIRED|#IMPLIED/,"|",U(U("#FIXED",ue),"?",Jb)),bw=U(ue,st,ue,mw,ue,gw),ww="<!ATTLIST",_w=Y(ww,ue,st,bw,"*",_e,">"),Wl="about:legacy-compat",yw=U('"'+Wl+'"',"|","'"+Wl+"'"),Zl="SYSTEM",ka="PUBLIC",Ta=U(U(Zl,ue,On),"|",U(ka,ue,Wo,ue,On)),vw=Y("^",U(U(Zl,ue,"(?<SystemLiteralOnly>",On,")"),"|",U(ka,ue,"(?<PubidLiteral>",Wo,")",ue,"(?<SystemLiteral>",On,")"))),Ew=Y("^",Wo,"$"),xw=Y("^",On,"$"),kw=U(ue,"NDATA",ue,st),Tw=U(Xl,"|",U(Ta,kw,"?")),ff="<!ENTITY",Aw=Y(ff,ue,st,ue,Tw,_e,">"),Dw=U(Xl,"|",Ta),Sw=Y(ff,ue,"%",ue,st,ue,Dw,_e,">"),Cw=U(Aw,"|",Sw),Nw=Y(ka,ue,Wo),Iw=Y("<!NOTATION",ue,st,ue,U(Ta,"|",Nw),_e,">"),Kl=Y(_e,"=",_e),sf=/1[.]\d+/,Ow=Y(ue,"version",Kl,U("'",sf,"'","|",'"',sf,'"')),lf=/[A-Za-z][-A-Za-z0-9._]*/,Rw=U(ue,"encoding",Kl,U('"',lf,'"',"|","'",lf,"'")),Bw=U(ue,"standalone",Kl,U("'",U("yes","|","no"),"'","|",'"',U("yes","|","no"),'"')),$w=Y(/^<\?xml/,Ow,Rw,"?",Bw,"?",_e,/\?>/),Mw="<!DOCTYPE",Pw="<![CDATA[",Lw="]]>",Fw=/<!\[CDATA\[/,jw=/\]\]>/,qw=Y(cr,"*?",jw),Uw=Y(Fw,qw);H.chars=ur;H.chars_without=In;H.detectUnicodeSupport=uf;H.reg=Y;H.regg=U;H.ABOUT_LEGACY_COMPAT=Wl;H.ABOUT_LEGACY_COMPAT_SystemLiteral=yw;H.AttlistDecl=_w;H.CDATA_START=Pw;H.CDATA_END=Lw;H.CDSect=Uw;H.Char=cr;H.Comment=iw;H.COMMENT_START=cf;H.COMMENT_END=df;H.DOCTYPE_DECL_START=Mw;H.elementdecl=dw;H.EntityDecl=Cw;H.EntityValue=Xl;H.ExternalID=Ta;H.ExternalID_match=vw;H.Name=st;H.Name_exact=Xb;H.NCName_exact=tw;H.NotationDecl=Iw;H.Reference=zo;H.PEReference=Ho;H.PI=ow;H.PUBLIC=ka;H.PubidLiteral=Wo;H.PubidLiteral_match=Ew;H.QName=Go;H.QName_exact=rw;H.QName_group=nw;H.S=ue;H.SChar_s=Wb;H.S_OPT=_e;H.SYSTEM=Zl;H.SystemLiteral=On;H.SystemLiteral_match=xw;H.InvalidChar=Gb;H.UNICODE_REPLACEMENT_CHARACTER=Hb;H.UNICODE_SUPPORT=Rn;H.XMLDecl=$w});var lu=rr(Ee=>{"use strict";var ft=Vr(),Bt=ft.find,Vw=ft.hasDefaultHTMLNamespace,$n=ft.hasOwn,zw=ft.isHTMLMimeType,Hw=ft.isHTMLRawTextElement,Gw=ft.isHTMLVoidElement,Yo=ft.MIME_TYPE,$t=ft.NAMESPACE,Ye=Symbol(),_f=Uo(),R=_f.DOMException,ze=_f.DOMExceptionName,ve=Jl();function tt(n){if(n!==Ye)throw new TypeError("Illegal constructor")}function Ww(n){return n!==""}function Yw(n){return n?n.split(/[\t\n\f\r ]+/).filter(Ww):[]}function Xw(n,e){return $n(n,e)||(n[e]=!0),n}function hf(n){if(!n)return[];var e=Yw(n);return Object.keys(e.reduce(Xw,{}))}function Zw(n){return function(e){return n&&n.indexOf(e)!==-1}}function yf(n){if(!ve.QName_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function eu(n,e){yf(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var o=e.split(":");t=o[0],r=o[1]}if(t!==null&&n===null)throw new R(R.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==ft.NAMESPACE.XML)throw new R(R.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==ft.NAMESPACE.XMLNS)throw new R(R.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===ft.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new R(R.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function Ln(n,e){for(var t in n)$n(n,t)&&(e[t]=n[t])}function rt(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Ln(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var nt={},dt=nt.ELEMENT_NODE=1,Mn=nt.ATTRIBUTE_NODE=2,Xo=nt.TEXT_NODE=3,vf=nt.CDATA_SECTION_NODE=4,Ef=nt.ENTITY_REFERENCE_NODE=5,Kw=nt.ENTITY_NODE=6,tu=nt.PROCESSING_INSTRUCTION_NODE=7,ru=nt.COMMENT_NODE=8,Bn=nt.DOCUMENT_NODE=9,xf=nt.DOCUMENT_TYPE_NODE=10,dr=nt.DOCUMENT_FRAGMENT_NODE=11,Jw=nt.NOTATION_NODE=12,ye=ft.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 kf(n,e){if(e.length<n.length)return kf(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function pf(n){return n.guid||(n.guid=Math.random()),n.guid}function Ce(){}Ce.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++)su(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)}};Ce.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 Rt(n,e){this._node=n,this._refresh=e,Ca(this)}function Ca(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if($f(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)$n(n,r)&&delete n[r];Ln(t,n),n._inc=e}}Rt.prototype.item=function(n){return Ca(this),this[n]||null};rt(Rt,Ce);function Pn(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Tf(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function nu(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 Qw(n,e,t){var r=nu(n,e,!1),o=r&&r[t];return o||null}function e_(n,e){nu(n,e.namespaceURI,!0)[e.localName]=e}function t_(n,e){var t=nu(n,e.namespaceURI,!1);t&&delete t[e.localName]}function r_(n,e,t,r){if(r?e[Tf(e,r)]=t:(e[e.length]=t,e.length++),e_(e,t),n){t.ownerElement=n;var o=n.ownerDocument;o&&(r&&Sf(o,n,r),n_(o,n,t))}}function mf(n,e,t){var r=Tf(e,t);if(r>=0){for(var o=e.length-1;r<=o;)e[r]=e[++r];if(e.length=o,t_(e,t),n){var i=n.ownerDocument;i&&Sf(i,n,t),t.ownerElement=null}}}Pn.prototype={length:0,item:Ce.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 R(R.INUSE_ATTRIBUTE_ERR);var t=Qw(this,n.namespaceURI,n.localName);return t===n?n:(r_(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 R(R.NOT_FOUND_ERR,n);return mf(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new R(R.NOT_FOUND_ERR,n?n+" : "+e:e);return mf(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}};Pn.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 Af(){}Af.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=Yo.XML_APPLICATION;n===$t.HTML?r=Yo.XML_XHTML_APPLICATION:n===$t.SVG&&(r=Yo.XML_SVG_IMAGE);var o=new Ht(Ye,{contentType:r});if(o.implementation=this,o.childNodes=new Ce,o.doctype=t||null,t&&o.appendChild(t),e){var i=o.createElementNS(n,e);o.appendChild(i)}return o},createDocumentType:function(n,e,t,r){yf(n);var o=new Oa(Ye);return o.name=n,o.nodeName=n,o.publicId=e||"",o.systemId=t||"",o.internalSubset=r||"",o.childNodes=new Ce,o},createHTMLDocument:function(n){var e=new Ht(Ye,{contentType:Yo.HTML});if(e.implementation=this,e.childNodes=new Ce,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 o=e.createElement("title");o.appendChild(e.createTextNode(n)),r.appendChild(o)}t.appendChild(e.createElement("body"))}return e}};function J(n){tt(n)}J.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,o=t.other;if(r.nodeType!==o.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==o.name||r.publicId!==o.publicId||r.systemId!==o.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==o.namespaceURI||r.prefix!==o.prefix||r.localName!==o.localName||r.attributes.length!==o.attributes.length)return!1;for(var i=0;i<r.attributes.length;i++){var a=r.attributes.item(i),s=o.getAttributeNodeNS(a.namespaceURI,a.localName);if(!s)return!1;e.push({node:a,other:s})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==o.namespaceURI||r.localName!==o.localName||r.value!==o.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==o.target||r.data!==o.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==o.data)return!1;break}if(r.childNodes.length!==o.childNodes.length)return!1;for(var i=r.childNodes.length-1;i>=0;i--)e.push({node:r.childNodes[i],other:o.childNodes[i]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return Sa(this,n,e)},replaceChild:function(n,e){Sa(this,n,e,If),e&&this.removeChild(e)},removeChild:function(n){return Cf(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return Bf(this.ownerDocument||this,this,n)},normalize:function(){Me(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===Xo&&e.nodeType===Xo){for(var r=[],o=t;o!==null&&o.nodeType===Xo;)r.push(o.data),o=o.nextSibling;for(var i=e.nextSibling;i!==o;){var a=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=a}e.nextSibling=o,o!==null?o.previousSibling=e:n.lastChild=e,e.appendData(r.join("")),ou(n.ownerDocument,n),e=o}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($n(t,r)&&t[r]===n)return r}e=e.nodeType==Mn?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&$n(t,n))return t[n];e=e.nodeType==Mn?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,o=null;if(e instanceof zr&&(r=e,e=r.ownerElement),t instanceof zr&&(o=t,t=o.ownerElement,r&&e&&t===e))for(var i=0,a;a=t.attributes[i];i++){if(a===r)return ye.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ye.DOCUMENT_POSITION_PRECEDING;if(a===o)return ye.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ye.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return ye.DOCUMENT_POSITION_DISCONNECTED+ye.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(pf(t.ownerDocument)>pf(e.ownerDocument)?ye.DOCUMENT_POSITION_FOLLOWING:ye.DOCUMENT_POSITION_PRECEDING);if(o&&e===t)return ye.DOCUMENT_POSITION_CONTAINS+ye.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return ye.DOCUMENT_POSITION_CONTAINED_BY+ye.DOCUMENT_POSITION_FOLLOWING;for(var s=[],l=e.parentNode;l;){if(!o&&l===t)return ye.DOCUMENT_POSITION_CONTAINED_BY+ye.DOCUMENT_POSITION_FOLLOWING;s.push(l),l=l.parentNode}s.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return ye.DOCUMENT_POSITION_CONTAINS+ye.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=kf(s,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return ye.DOCUMENT_POSITION_FOLLOWING;if(h===e)return ye.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return ye.DOCUMENT_POSITION_FOLLOWING;if(s.indexOf(h)>=0)return ye.DOCUMENT_POSITION_PRECEDING}return 0}};function Df(n){return n=="<"&&"<"||n==">"&&">"||n=="&"&&"&"||n=='"'&&"""||"&#"+n.charCodeAt()+";"}Ln(nt,J);Ln(nt,J.prototype);Ln(ye,J);Ln(ye,J.prototype);function Da(n,e){Me(n,null,{enter:function(t){return e(t)?Me.STOP:!0}})}function Me(n,e,t){for(var r=[{node:n,context:e,phase:Me.ENTER}];r.length>0;){var o=r.pop();if(o.phase===Me.ENTER){var i=t.enter(o.node,o.context);if(i===Me.STOP)return Me.STOP;if(r.push({node:o.node,context:i,phase:Me.EXIT}),i==null)continue;for(var a=o.node.lastChild;a;)r.push({node:a,context:i,phase:Me.ENTER}),a=a.previousSibling}else t.exit&&t.exit(o.node,o.context)}}Me.STOP=Symbol("walkDOM.STOP");Me.ENTER=0;Me.EXIT=1;function Ht(n,e){tt(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||Yo.XML_APPLICATION,this.type=zw(this.contentType)?"html":"xml"}function n_(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===$t.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Sf(n,e,t,r){n&&n._inc++;var o=t.namespaceURI;o===$t.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function ou(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var o=e.firstChild,i=0;o;)r[i++]=o,o=o.nextSibling;r.length=i,delete r[r.length]}}}function Cf(n,e){if(n!==e.parentNode)throw new R(R.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,ou(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function o_(n){return n&&(n.nodeType===J.DOCUMENT_NODE||n.nodeType===J.DOCUMENT_FRAGMENT_NODE||n.nodeType===J.ELEMENT_NODE)}function i_(n){return n&&(n.nodeType===J.CDATA_SECTION_NODE||n.nodeType===J.COMMENT_NODE||n.nodeType===J.DOCUMENT_FRAGMENT_NODE||n.nodeType===J.DOCUMENT_TYPE_NODE||n.nodeType===J.ELEMENT_NODE||n.nodeType===J.PROCESSING_INSTRUCTION_NODE||n.nodeType===J.TEXT_NODE)}function fr(n){return n&&n.nodeType===J.DOCUMENT_TYPE_NODE}function zt(n){return n&&n.nodeType===J.ELEMENT_NODE}function Nf(n){return n&&n.nodeType===J.TEXT_NODE}function gf(n,e){var t=n.childNodes||[];if(Bt(t,zt)||fr(e))return!1;var r=Bt(t,fr);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function bf(n,e){var t=n.childNodes||[];function r(i){return zt(i)&&i!==e}if(Bt(t,r))return!1;var o=Bt(t,fr);return!(e&&o&&t.indexOf(o)>t.indexOf(e))}function a_(n,e,t){if(!o_(n))throw new R(R.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new R(R.NOT_FOUND_ERR,"child not in parent");if(!i_(e)||fr(e)&&n.nodeType!==J.DOCUMENT_NODE)throw new R(R.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function s_(n,e,t){var r=n.childNodes||[],o=e.childNodes||[];if(e.nodeType===J.DOCUMENT_FRAGMENT_NODE){var i=o.filter(zt);if(i.length>1||Bt(o,Nf))throw new R(R.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!gf(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(zt(e)&&!gf(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(fr(e)){if(Bt(r,fr))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=Bt(r,zt);if(t&&r.indexOf(a)<r.indexOf(t))throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&a)throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function If(n,e,t){var r=n.childNodes||[],o=e.childNodes||[];if(e.nodeType===J.DOCUMENT_FRAGMENT_NODE){var i=o.filter(zt);if(i.length>1||Bt(o,Nf))throw new R(R.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!bf(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(zt(e)&&!bf(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(fr(e)){if(Bt(r,function(l){return fr(l)&&l!==t}))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=Bt(r,zt);if(t&&r.indexOf(a)<r.indexOf(t))throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Sa(n,e,t,r){a_(n,e,t),n.nodeType===J.DOCUMENT_NODE&&(r||s_)(n,e,t);var o=e.parentNode;if(o&&o.removeChild(e),e.nodeType===dr){var i=e.firstChild;if(i==null)return e;var a=e.lastChild}else i=a=e;var s=t?t.previousSibling:n.lastChild;i.previousSibling=s,a.nextSibling=t,s?s.nextSibling=i:n.firstChild=i,t==null?n.lastChild=a:t.previousSibling=a;do i.parentNode=n;while(i!==a&&(i=i.nextSibling));return ou(n.ownerDocument||n,n,e),e.nodeType==dr&&(e.firstChild=e.lastChild=null),e}Ht.prototype={implementation:null,nodeName:"#document",nodeType:Bn,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===dr){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return Sa(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===dt&&(this.documentElement=n),n},removeChild:function(n){var e=Cf(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){Sa(this,n,e,If),n.ownerDocument=this,e&&this.removeChild(e),zt(n)&&(this.documentElement=n)},importNode:function(n,e){return l_(this,n,e)},getElementById:function(n){var e=null;return Da(this.documentElement,function(t){if(t.nodeType==dt&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new Gt(Ye);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),Vw(this.contentType)&&(e.namespaceURI=$t.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new Ce;var t=e.attributes=new Pn;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new Fn(Ye);return n.ownerDocument=this,n.childNodes=new Ce,n},createTextNode:function(n){var e=new Zo(Ye);return e.ownerDocument=this,e.childNodes=new Ce,e.appendData(n),e},createComment:function(n){var e=new Na(Ye);return e.ownerDocument=this,e.childNodes=new Ce,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new R(R.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Ia(Ye);return e.ownerDocument=this,e.childNodes=new Ce,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new Ba(Ye);return t.ownerDocument=this,t.childNodes=new Ce,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!ve.QName_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new zr(Ye);return e.ownerDocument=this,e.childNodes=new Ce,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!ve.Name_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new R("document is an html document",ze.NotSupportedError);var e=new Ra(Ye);return e.ownerDocument=this,e.childNodes=new Ce,e.nodeName=n,e},createElementNS:function(n,e){var t=eu(n,e),r=new Gt(Ye),o=r.attributes=new Pn;return r.childNodes=new Ce,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],o._ownerElement=r,r},createAttributeNS:function(n,e){var t=eu(n,e),r=new zr(Ye);return r.ownerDocument=this,r.childNodes=new Ce,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};rt(Ht,J);function Gt(n){tt(n),this._nsMap=Object.create(null)}Gt.prototype={nodeType:dt,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===$t.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=eu(n,e),o=r[2],i=this.getAttributeNodeNS(n,o);i?i.value=i.nodeValue=""+t:(i=this.ownerDocument.createAttributeNS(n,e),i.value=i.nodeValue=""+t,this.setAttributeNode(i))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=hf(n);return new Rt(this,function(t){var r=[];return e.length>0&&Da(t,function(o){if(o!==t&&o.nodeType===dt){var i=o.getAttribute("class");if(i){var a=n===i;if(!a){var s=hf(i);a=e.every(Zw(s))}a&&r.push(o)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===Bn?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Rt(this,function(r){var o=[];return Da(r,function(i){if(!(i===r||i.nodeType!==dt))if(n==="*")o.push(i);else{var a=i.getQualifiedName(),s=e&&i.namespaceURI===$t.HTML?t:n;a===s&&o.push(i)}}),o})},getElementsByTagNameNS:function(n,e){return new Rt(this,function(t){var r=[];return Da(t,function(o){o!==t&&o.nodeType===dt&&(n==="*"||o.namespaceURI===n)&&(e==="*"||o.localName==e)&&r.push(o)}),r})}};Ht.prototype.getElementsByClassName=Gt.prototype.getElementsByClassName;Ht.prototype.getElementsByTagName=Gt.prototype.getElementsByTagName;Ht.prototype.getElementsByTagNameNS=Gt.prototype.getElementsByTagNameNS;rt(Gt,J);function zr(n){tt(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}zr.prototype.nodeType=Mn;rt(zr,J);function hr(n){tt(n)}hr.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),o=this.data.substring(n+e);t=r+t+o,this.nodeValue=this.data=t,this.length=t.length}};rt(hr,J);function Zo(n){tt(n)}Zo.prototype={nodeName:"#text",nodeType:Xo,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}};rt(Zo,hr);function Na(n){tt(n)}Na.prototype={nodeName:"#comment",nodeType:ru};rt(Na,hr);function Ia(n){tt(n)}Ia.prototype={nodeName:"#cdata-section",nodeType:vf};rt(Ia,Zo);function Oa(n){tt(n)}Oa.prototype.nodeType=xf;rt(Oa,J);function iu(n){tt(n)}iu.prototype.nodeType=Jw;rt(iu,J);function au(n){tt(n)}au.prototype.nodeType=Kw;rt(au,J);function Ra(n){tt(n)}Ra.prototype.nodeType=Ef;rt(Ra,J);function Fn(n){tt(n)}Fn.prototype.nodeName="#document-fragment";Fn.prototype.nodeType=dr;rt(Fn,J);function Ba(n){tt(n)}Ba.prototype.nodeType=tu;rt(Ba,hr);function Of(){}Of.prototype.serializeToString=function(n,e){return Rf.call(n,e)};J.prototype.toString=Rf;function Rf(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===Bn&&this.documentElement||this,o=r.prefix,i=r.namespaceURI;if(i&&o==null){var o=r.lookupPrefix(i);if(o==null)var a=[{namespace:i,prefix:null}]}return su(this,t,a,e),t.join("")}function wf(n,e,t){var r=n.prefix||"",o=n.namespaceURI;if(!o||r==="xml"&&o===$t.XML||o===$t.XMLNS)return!1;for(var i=t.length;i--;){var a=t[i];if(a.prefix===r)return a.namespace!==o}return!0}function Aa(n,e,t,r){if(r&&!ve.QName_exact.test(e))throw new R('The attribute name "'+e+'" is not a valid XML QName',ze.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Df),'"')}function su(n,e,t,r){t||(t=[]);var o=r.nodeFilter,i=r.requireWellFormed,a=r.splitCDATASections,s=n.nodeType===Bn?n:n.ownerDocument,l=s.type==="html";Me(n,{ns:t},{enter:function(u,c){var d=c.ns;if(o)if(u=o(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case dt:var f=u.attributes,h=f.length,m=u.tagName,p=m;if(!l&&!u.prefix&&u.namespaceURI){for(var w,b=0;b<f.length;b++)if(f.item(b).name==="xmlns"){w=f.item(b).value;break}if(!w)for(var _=d.length-1;_>=0;_--){var y=d[_];if(y.prefix===""&&y.namespace===u.namespaceURI){w=y.namespace;break}}if(w!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var y=d[_];if(y.namespace===u.namespaceURI){y.prefix&&(p=y.prefix+":"+m);break}}}if(i&&!ve.QName_exact.test(p))throw new R('The element name "'+p+'" is not a valid XML QName',ze.InvalidStateError);e.push("<",p);for(var E=d.slice(),N=0;N<h;N++){var k=f.item(N);k.prefix=="xmlns"?E.push({prefix:k.localName,namespace:k.value}):k.nodeName=="xmlns"&&E.push({prefix:"",namespace:k.value})}for(var N=0;N<h;N++){var k=f.item(N);if(wf(k,l,E)){var C=k.prefix||"",O=k.namespaceURI;Aa(e,C?"xmlns:"+C:"xmlns",O,i),E.push({prefix:C,namespace:O})}var $=o?o(k):k;$&&(typeof $=="string"?e.push($):Aa(e,$.name,$.value,i))}if(m===p&&wf(u,l,E)){var Z=u.prefix||"",O=u.namespaceURI;Aa(e,Z?"xmlns:"+Z:"xmlns",O,i),E.push({prefix:Z,namespace:O})}var W=!u.firstChild;if(W&&(l||u.namespaceURI===$t.HTML)&&(W=Gw(m)),W)return e.push("/>"),null;if(e.push(">"),l&&Hw(m)){for(var ie=u.firstChild;ie;)ie.data?e.push(ie.data):su(ie,e,E.slice(),r),ie=ie.nextSibling;return e.push("</",p,">"),null}return{ns:E,tag:p};case Bn:case dr:if(i&&u.nodeType===Bn&&u.documentElement==null)throw new R("The Document has no documentElement",ze.InvalidStateError);return{ns:d};case Mn:return Aa(e,u.name,u.value,i),null;case Xo:if(i&&ve.InvalidChar.test(u.data))throw new R("The Text node data contains characters outside the XML Char production",ze.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Df)),null;case vf:if(i&&u.data.indexOf("]]>")!==-1)throw new R('The CDATASection data contains "]]>"',ze.InvalidStateError);return a?e.push(ve.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),ve.CDATA_END):e.push(ve.CDATA_START,u.data,ve.CDATA_END),null;case ru:if(i){if(ve.InvalidChar.test(u.data))throw new R("The comment node data contains characters outside the XML Char production",ze.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new R('The comment node data contains "--" or ends with "-"',ze.InvalidStateError)}return e.push(ve.COMMENT_START,u.data,ve.COMMENT_END),null;case xf:var he=u.publicId,te=u.systemId;if(i){if(!ve.Name_exact.test(u.name))throw new R('The doctype name "'+u.name+'" is not a valid XML Name',ze.InvalidStateError);if(he&&!ve.PubidLiteral_match.test(he))throw new R("DocumentType publicId is not a valid PubidLiteral",ze.InvalidStateError);if(te&&te!=="."&&!ve.SystemLiteral_match.test(te))throw new R("DocumentType systemId is not a valid SystemLiteral",ze.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new R('DocumentType internalSubset contains "]>"',ze.InvalidStateError)}return e.push(ve.DOCTYPE_DECL_START," ",u.name),he?(e.push(" ",ve.PUBLIC," ",he),te&&te!=="."&&e.push(" ",te)):te&&te!=="."&&e.push(" ",ve.SYSTEM," ",te),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case tu:if(i){if(!ve.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new R('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',ze.InvalidStateError);if(ve.InvalidChar.test(u.data))throw new R("The ProcessingInstruction data contains characters outside the XML Char production",ze.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new R('The ProcessingInstruction data contains "?>"',ze.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Ef:if(i&&!ve.Name_exact.test(u.nodeName))throw new R('The entity reference name "'+u.nodeName+'" is not a valid XML Name',ze.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 l_(n,e,t){var r;return Me(e,null,{enter:function(o,i){var a=o.cloneNode(!1);a.ownerDocument=n,a.parentNode=null,i===null?r=a:i.appendChild(a);var s=o.nodeType===Mn||t;return s?a:null}}),r}function Bf(n,e,t){var r;return Me(e,null,{enter:function(o,i){var a=new o.constructor(Ye);for(var s in o)if($n(o,s)){var l=o[s];typeof l!="object"&&l!=a[s]&&(a[s]=l)}o.childNodes&&(a.childNodes=new Ce),a.ownerDocument=n;var u=t;switch(a.nodeType){case dt:var c=o.attributes,d=a.attributes=new Pn,f=c.length;d._ownerElement=a;for(var h=0;h<f;h++)a.setAttributeNode(Bf(n,c.item(h),!0));break;case Mn:u=!0}return i!==null?i.appendChild(a):r=a,u?a:null}}),r}function $f(n,e,t){n[e]=t}function Ql(n){for(var e=[],t=n.firstChild;t;)t.nodeType===dt&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Rt.prototype,"length",{get:function(){return Ca(this),this.$$length}}),Object.defineProperty(J.prototype,"textContent",{get:function(){if(this.nodeType===dt||this.nodeType===dr){var n=[];return Me(this,null,{enter:function(e){if(e.nodeType===dt||e.nodeType===dr)return!0;if(e.nodeType===tu||e.nodeType===ru)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case dt:case dr: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(hr.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(hr.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(Gt.prototype,"children",{get:function(){return new Rt(this,Ql)}}),Object.defineProperty(Ht.prototype,"children",{get:function(){return new Rt(this,Ql)}}),Object.defineProperty(Fn.prototype,"children",{get:function(){return new Rt(this,Ql)}}),$f=function(n,e,t){n["$$"+e]=t})}catch{}Ee._updateLiveList=Ca;Ee.Attr=zr;Ee.CDATASection=Ia;Ee.CharacterData=hr;Ee.Comment=Na;Ee.Document=Ht;Ee.DocumentFragment=Fn;Ee.DocumentType=Oa;Ee.DOMImplementation=Af;Ee.Element=Gt;Ee.Entity=au;Ee.EntityReference=Ra;Ee.LiveNodeList=Rt;Ee.NamedNodeMap=Pn;Ee.Node=J;Ee.NodeList=Ce;Ee.Notation=iu;Ee.Text=Zo;Ee.ProcessingInstruction=Ba;Ee.walkDOM=Me;Ee.XMLSerializer=Of});var Pf=rr(Ko=>{"use strict";var Mf=Vr().freeze;Ko.XML_ENTITIES=Mf({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Ko.HTML_ENTITIES=Mf({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"});Ko.entityMap=Ko.HTML_ENTITIES});var Gf=rr(Ma=>{"use strict";var zn=Vr(),G=Jl(),qf=Uo(),u_=zn.isHTMLEscapableRawTextElement,c_=zn.isHTMLMimeType,d_=zn.isHTMLRawTextElement,ei=zn.hasOwn,Lf=zn.NAMESPACE,f_=qf.ParseError,h_=qf.DOMException,jn=0,pr=1,qn=2,Jo=3,Un=4,Vn=5,Qo=6,$a=7;function Uf(){}Uf.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),b_(e,e=Object.create(null)),p_(n,e,t,r,this.errorHandler),r.endDocument()}};var uu=/&#?\w+;?/g;function p_(n,e,t,r,o){var i=c_(r.mimeType);n.indexOf(G.UNICODE_REPLACEMENT_CHARACTER)>=0&&o.warning("Unicode replacement character detected, source encoding issues?");function a(K){if(K>65535){K-=65536;var Ge=55296+(K>>10),wn=56320+(K&1023);return String.fromCharCode(Ge,wn)}else return String.fromCharCode(K)}function s(K){var Ge=K[K.length-1]===";"?K:K+";";if(!i&&Ge!==K)return o.error("EntityRef: expecting ;"),K;var wn=G.Reference.exec(Ge);if(!wn||wn[0].length!==Ge.length)return o.error("entity not matching Reference production: "+K),K;var _n=Ge.slice(1,-1);return ei(t,_n)?t[_n]:_n.charAt(0)==="#"?a(parseInt(_n.substring(1).replace("x","0x"))):(o.error("entity not found:"+K),K)}function l(K){if(K>w){var Ge=n.substring(w,K).replace(uu,s);f&&h(w),r.characters(Ge,0,K-w),w=K}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(K,Ge){for(;K>=c&&(Ge=d.exec(n));)u=c,c=Ge.index+Ge[0].length,f.lineNumber++;f.columnNumber=K-u+1}for(var m=[{currentNSMap:e}],p=[],w=0;;){try{var b=n.indexOf("<",w);if(b<0){if(!i&&p.length>0)return o.fatalError("unclosed xml tag(s): "+p.join(", "));if(!n.substring(w).match(/^\s*$/)){var _=r.doc,y=_.createTextNode(n.substring(w));if(_.documentElement)return o.error("Extra content at the end of the document");_.appendChild(y),r.currentElement=y}return}if(b>w){var E=n.substring(w,b);!i&&p.length===0&&(E=E.replace(new RegExp(G.S_OPT.source,"g"),""),E&&o.error("Unexpected content outside root element: '"+E+"'")),l(b)}switch(n.charAt(b+1)){case"/":var z=n.indexOf(">",b+2),N=n.substring(b+2,z>0?z:void 0);if(!N)return o.fatalError("end tag name missing");var k=G.reg("^",G.QName_group,G.S_OPT,"$"),C=z>0&&k.exec(N);if(!C){var O=z>0&&G.reg("^",G.QName_group).exec(N);if(i&&O)o.warning('end tag name contains invalid trailing characters: "'+N+'"'),C=O;else if(O&&new RegExp(k.source,k.flags+"m").test(N))o.error('end tag name is followed by a line break and trailing content: "'+N+'"'),C=O;else return o.fatalError('end tag name contains invalid characters: "'+N+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var $=p[p.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if($!==C[1]){var Z=C[1].toLowerCase();if(!i||$.toLowerCase()!==Z)return o.fatalError('Opening and ending tag mismatch: "'+$+'" != "'+N+'"')}var W=m.pop();p.pop();var ie=W.localNSMap;if(r.endElement(W.uri,W.localName,$),ie)for(var he in ie)ei(ie,he)&&r.endPrefixMapping(he);z++;break;case"?":f&&h(b),z=__(n,b,r,o);break;case"!":f&&h(b),z=zf(n,b,r,o,i);break;default:f&&h(b);var te=new Hf,se=m[m.length-1].currentNSMap,z=m_(n,b,te,se,s,o,i),at=te.length;if(te.closed||(i&&zn.isHTMLVoidElement(te.tagName)?te.closed=!0:p.push(te.tagName)),f&&at){for(var vo=Ff(f,{}),Rr=0;Rr<at;Rr++){var At=te[Rr];h(At.offset),At.locator=Ff(f,{})}r.locator=vo,jf(te,r,se)&&m.push(te),r.locator=f}else jf(te,r,se)&&m.push(te);i&&!te.closed?z=g_(n,z,te.tagName,s,r):z++}}catch(K){if(K instanceof f_)throw K;if(K instanceof h_)return o.fatalError("Error constructing the DOM: "+K.name+": "+K.message,K);o.error("element parse error: "+K),z=-1}z>w?w=z:l(Math.max(b,w)+1)}}function Ff(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function m_(n,e,t,r,o,i,a){function s(h,m,p){if(ei(t.attributeNames,h))return i.fatalError("Attribute "+h+" redefined");if(!a&&m.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,m.replace(/[\t\n\r]/g," ").replace(uu,o),p)}for(var l,u,c=++e,d=jn;;){var f=n.charAt(c);if(d===jn&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===pr)l=n.slice(e,c),d=Jo;else if(d===qn)d=Jo;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===Jo||d===pr)if(d===pr&&(i.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),s(l,u,e-1),d=Vn;else throw new Error("attribute value no end '"+f+"' match");else if(d==Un)u=n.slice(e,c),s(l,u,e),i.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Vn;else throw new Error('attribute value must after "="');break;case"/":switch(d){case jn:t.setTagName(n.slice(e,c));case Vn:case Qo:case $a:d=$a,t.closed=!0;case Un:case pr:break;case qn:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==jn&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case jn:t.setTagName(n.slice(e,c));case Vn:case Qo:case $a:break;case Un:case pr:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case qn:d===qn&&(u=l),d==Un?(i.warning('attribute "'+u+'" missed quot(")!'),s(l,u,e)):(a||i.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),s(u,u,e));break;case Jo:if(!a)return i.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case jn:t.setTagName(n.slice(e,c)),d=Qo;break;case pr:l=n.slice(e,c),d=qn;break;case Un:var u=n.slice(e,c);i.warning('attribute "'+u+'" missed quot(")!!'),s(l,u,e);case Vn:d=Qo;break}else switch(d){case qn:a||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),s(l,l,e),e=c,d=pr;break;case Vn:i.warning('attribute space is required"'+l+'"!!');case Qo:d=pr,e=c;break;case Jo:d=Un,e=c;break;case $a:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function jf(n,e,t){for(var r=n.tagName,o=null,d=n.length;d--;){var i=n[d],a=i.qName,s=i.value,f=a.indexOf(":");if(f>0)var l=i.prefix=a.slice(0,f),u=a.slice(f+1),c=l==="xmlns"&&u;else u=a,l=null,c=a==="xmlns"&&"";i.localName=u,c!==!1&&(o==null&&(o=Object.create(null),t=Object.create(t)),t[c]=o[c]=s,i.uri=Lf.XMLNS,e.startPrefixMapping(c,s))}for(var d=n.length;d--;)i=n[d],i.prefix&&(i.prefix==="xml"&&(i.uri=Lf.XML),i.prefix!=="xmlns"&&(i.uri=t[i.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),o)for(l in o)ei(o,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=o,!0}function g_(n,e,t,r,o){var i=u_(t);if(i||d_(t)){var a=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");a.lastIndex=e;var s=a.exec(n),l=s?s.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return i&&(u=u.replace(uu,r)),o.characters(u,0,u.length),l}return e+1}function b_(n,e){for(var t in n)ei(n,t)&&(e[t]=n[t])}function Vf(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function o(c){c=c||1,t+=c}function i(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
|
|
11
|
-
`&&d!==" "&&d!=="\r")return c;c++,o()}return-1}function a(){return n.substring(t)}function s(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=G.reg("^",c),f=d.exec(a());return f?(o(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:o,skipBlanks:i,substringFromIndex:a,substringStartsWith:s,substringStartsWithCaseInsensitive:l}}function
|
|
9
|
+
var hg=Object.create;var $l=Object.defineProperty;var pg=Object.getOwnPropertyDescriptor;var mg=Object.getOwnPropertyNames;var gg=Object.getPrototypeOf,bg=Object.prototype.hasOwnProperty;var sr=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},wg=(n,e)=>{for(var t in e)$l(n,t,{get:e[t],enumerable:!0})},_g=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of mg(e))!bg.call(n,o)&&o!==t&&$l(n,o,{get:()=>e[o],enumerable:!(r=pg(e,o))||r.enumerable});return n};var kd=(n,e,t)=>(t=n!=null?hg(gg(n)):{},_g(e||!n||!n.__esModule?$l(t,"default",{value:n,enumerable:!0}):t,n));var zr=sr(Pe=>{"use strict";function Vb(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(Vr(n,r)){var o=n[r];if(e.call(void 0,o,r,n))return o}}function On(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 Vr(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function zb(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Vr(e,t)&&(n[t]=e[t]);return n}var af=On({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 Hb(n){return Vr(af,n.toLowerCase())}var sf=On({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 Gb(n){return Vr(sf,n.toLowerCase())}var Fo=On({script:!1,style:!1,textarea:!0,title:!0});function Wb(n){var e=n.toLowerCase();return Vr(Fo,e)&&!Fo[e]}function Yb(n){var e=n.toLowerCase();return Vr(Fo,e)&&Fo[e]}function lf(n){return n===jo.HTML}function Xb(n){return lf(n)||n===jo.XML_XHTML_APPLICATION}var jo=On({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),Zb=Object.keys(jo).map(function(n){return jo[n]});function Kb(n){return Zb.indexOf(n)>-1}var Jb=On({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/"});Pe.assign=zb;Pe.find=Vb;Pe.freeze=On;Pe.HTML_BOOLEAN_ATTRIBUTES=af;Pe.HTML_RAW_TEXT_ELEMENTS=Fo;Pe.HTML_VOID_ELEMENTS=sf;Pe.hasDefaultHTMLNamespace=Xb;Pe.hasOwn=Vr;Pe.isHTMLBooleanAttribute=Hb;Pe.isHTMLRawTextElement=Wb;Pe.isHTMLEscapableRawTextElement=Yb;Pe.isHTMLMimeType=lf;Pe.isHTMLVoidElement=Gb;Pe.isValidMimeType=Kb;Pe.MIME_TYPE=jo;Pe.NAMESPACE=Jb});var Ho=sr(zo=>{"use strict";var Qb=zr();function cf(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var Uo=Qb.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"}),df=Object.keys(Uo);function ff(n){return typeof n=="number"&&n>=1&&n<=25}function ew(n){return typeof n=="string"&&n.substring(n.length-Uo.Error.length)===Uo.Error}function Vo(n,e){ff(n)?(this.name=df[n],this.message=e||""):(this.message=n,this.name=ew(e)?e:Uo.Error),Error.captureStackTrace&&Error.captureStackTrace(this,Vo)}cf(Vo,!0);Object.defineProperties(Vo.prototype,{code:{enumerable:!0,get:function(){var n=df.indexOf(this.name);return ff(n)?n:0}}});var hf={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},Jl=Object.entries(hf);for(qo=0;qo<Jl.length;qo++)uf=Jl[qo][0],Vo[uf]=Jl[qo][1];var uf,qo;function Ql(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,Ql)}cf(Ql);zo.DOMException=Vo;zo.DOMExceptionName=Uo;zo.ExceptionCode=hf;zo.ParseError=Ql});var au=sr(H=>{"use strict";function _f(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 $n=_f();function pr(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function Rn(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,""),$n?"u":"")}function Y(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(""),$n?"u":"")}function V(n){if(arguments.length===0)throw new Error("no parameters provided");return Y.apply(V,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var tw="\uFFFD",mr=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;$n&&(mr=Y("[",pr(mr),"\\u{10000}-\\u{10FFFF}","]"));var rw=new RegExp("[^"+pr(mr)+"]",$n?"u":""),Da=/[\x20\x09\x0D\x0A]/,nw=pr(Da),ce=Y(Da,"+"),ye=Y(Da,"*"),Go=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;$n&&(Go=Y("[",pr(Go),"\\u{10000}-\\u{10FFFF}","]"));var ow=pr(Go),ru=Y("[",ow,pr(/[-.0-9\xB7]/),pr(/[\u0300-\u036F\u203F-\u2040]/),"]"),st=Y(Go,ru,"*"),iw=Y("^",st,"$"),pf=Y(ru,"+"),aw=Y("&",st,";"),sw=V(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),Wo=V(aw,"|",sw),Yo=Y("%",st,";"),nu=V(Y('"',V(/[^%&"]/,"|",Yo,"|",Wo),"*",'"'),"|",Y("'",V(/[^%&']/,"|",Yo,"|",Wo),"*","'")),lw=V('"',V(/[^<&"]/,"|",Wo),"*",'"',"|","'",V(/[^<&']/,"|",Wo),"*","'"),uw=Rn(Go,":"),cw=Rn(ru,":"),eu=Y(uw,cw,"*"),dw=Y("^",eu,"$"),Xo=Y(eu,V(":",eu),"?"),fw=Y("^",Xo,"$"),hw=Y("(",Xo,")"),Bn=V(/"[^"]*"|'[^']*'/),pw=Y(/^<\?/,"(",st,")",V(ce,"(?!",Da,")(",mr,"*?)"),"?",/\?>/),mf=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,Zo=V('"',mf,'*"',"|","'",Rn(mf,"'"),"*'"),yf="<!--",vf="-->",mw=Y(yf,V(Rn(mr,"-"),"|",Y("-",Rn(mr,"-"))),"*",vf),gf="#PCDATA",gw=V(Y(/\(/,ye,gf,V(ye,/\|/,ye,Xo),"*",ye,/\)\*/),"|",Y(/\(/,ye,gf,ye,/\)/)),bw=/[?*+]?/,ww=Y(/\([^>]+\)/,bw),_w=V("EMPTY","|","ANY","|",gw,"|",ww),yw="<!ELEMENT",vw=Y(yw,ce,V(Xo,"|",Yo),ce,V(_w,"|",Yo),ye,">"),Ew=Y("NOTATION",ce,/\(/,ye,st,V(ye,/\|/,ye,st),"*",ye,/\)/),xw=Y(/\(/,ye,pf,V(ye,/\|/,ye,pf),"*",ye,/\)/),kw=V(Ew,"|",xw),Tw=V(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",kw),Aw=V(/#REQUIRED|#IMPLIED/,"|",V(V("#FIXED",ce),"?",lw)),Dw=V(ce,st,ce,Tw,ce,Aw),Sw="<!ATTLIST",Cw=Y(Sw,ce,st,Dw,"*",ye,">"),tu="about:legacy-compat",Nw=V('"'+tu+'"',"|","'"+tu+"'"),ou="SYSTEM",Sa="PUBLIC",Ca=V(V(ou,ce,Bn),"|",V(Sa,ce,Zo,ce,Bn)),Iw=Y("^",V(V(ou,ce,"(?<SystemLiteralOnly>",Bn,")"),"|",V(Sa,ce,"(?<PubidLiteral>",Zo,")",ce,"(?<SystemLiteral>",Bn,")"))),Ow=Y("^",Zo,"$"),Rw=Y("^",Bn,"$"),Bw=V(ce,"NDATA",ce,st),$w=V(nu,"|",V(Ca,Bw,"?")),Ef="<!ENTITY",Mw=Y(Ef,ce,st,ce,$w,ye,">"),Pw=V(nu,"|",Ca),Lw=Y(Ef,ce,"%",ce,st,ce,Pw,ye,">"),Fw=V(Mw,"|",Lw),jw=Y(Sa,ce,Zo),qw=Y("<!NOTATION",ce,st,ce,V(Ca,"|",jw),ye,">"),iu=Y(ye,"=",ye),bf=/1[.]\d+/,Uw=Y(ce,"version",iu,V("'",bf,"'","|",'"',bf,'"')),wf=/[A-Za-z][-A-Za-z0-9._]*/,Vw=V(ce,"encoding",iu,V('"',wf,'"',"|","'",wf,"'")),zw=V(ce,"standalone",iu,V("'",V("yes","|","no"),"'","|",'"',V("yes","|","no"),'"')),Hw=Y(/^<\?xml/,Uw,Vw,"?",zw,"?",ye,/\?>/),Gw="<!DOCTYPE",Ww="<![CDATA[",Yw="]]>",Xw=/<!\[CDATA\[/,Zw=/\]\]>/,Kw=Y(mr,"*?",Zw),Jw=Y(Xw,Kw);H.chars=pr;H.chars_without=Rn;H.detectUnicodeSupport=_f;H.reg=Y;H.regg=V;H.ABOUT_LEGACY_COMPAT=tu;H.ABOUT_LEGACY_COMPAT_SystemLiteral=Nw;H.AttlistDecl=Cw;H.CDATA_START=Ww;H.CDATA_END=Yw;H.CDSect=Jw;H.Char=mr;H.Comment=mw;H.COMMENT_START=yf;H.COMMENT_END=vf;H.DOCTYPE_DECL_START=Gw;H.elementdecl=vw;H.EntityDecl=Fw;H.EntityValue=nu;H.ExternalID=Ca;H.ExternalID_match=Iw;H.Name=st;H.Name_exact=iw;H.NCName_exact=dw;H.NotationDecl=qw;H.Reference=Wo;H.PEReference=Yo;H.PI=pw;H.PUBLIC=Sa;H.PubidLiteral=Zo;H.PubidLiteral_match=Ow;H.QName=Xo;H.QName_exact=fw;H.QName_group=hw;H.S=ce;H.SChar_s=nw;H.S_OPT=ye;H.SYSTEM=ou;H.SystemLiteral=Bn;H.SystemLiteral_match=Rw;H.InvalidChar=rw;H.UNICODE_REPLACEMENT_CHARACTER=tw;H.UNICODE_SUPPORT=$n;H.XMLDecl=Hw});var gu=sr(xe=>{"use strict";var ht=zr(),$t=ht.find,Qw=ht.hasDefaultHTMLNamespace,Pn=ht.hasOwn,e_=ht.isHTMLMimeType,t_=ht.isHTMLRawTextElement,r_=ht.isHTMLVoidElement,Ko=ht.MIME_TYPE,Mt=ht.NAMESPACE,Xe=Symbol(),Cf=Ho(),R=Cf.DOMException,Ge=Cf.DOMExceptionName,Ee=au();function nt(n){if(n!==Xe)throw new TypeError("Illegal constructor")}function n_(n){return n!==""}function o_(n){return n?n.split(/[\t\n\f\r ]+/).filter(n_):[]}function i_(n,e){return Pn(n,e)||(n[e]=!0),n}function xf(n){if(!n)return[];var e=o_(n);return Object.keys(e.reduce(i_,{}))}function a_(n){return function(e){return n&&n.indexOf(e)!==-1}}function Nf(n){if(!Ee.QName_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function lu(n,e){Nf(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var o=e.split(":");t=o[0],r=o[1]}if(t!==null&&n===null)throw new R(R.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==ht.NAMESPACE.XML)throw new R(R.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==ht.NAMESPACE.XMLNS)throw new R(R.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===ht.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new R(R.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function jn(n,e){for(var t in n)Pn(n,t)&&(e[t]=n[t])}function ot(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,jn(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var it={},ft=it.ELEMENT_NODE=1,Ln=it.ATTRIBUTE_NODE=2,Jo=it.TEXT_NODE=3,If=it.CDATA_SECTION_NODE=4,Of=it.ENTITY_REFERENCE_NODE=5,s_=it.ENTITY_NODE=6,uu=it.PROCESSING_INSTRUCTION_NODE=7,cu=it.COMMENT_NODE=8,Mn=it.DOCUMENT_NODE=9,Rf=it.DOCUMENT_TYPE_NODE=10,gr=it.DOCUMENT_FRAGMENT_NODE=11,l_=it.NOTATION_NODE=12,ve=ht.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 Bf(n,e){if(e.length<n.length)return Bf(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function kf(n){return n.guid||(n.guid=Math.random()),n.guid}function Ne(){}Ne.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++)mu(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)}};Ne.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 Bt(n,e){this._node=n,this._refresh=e,Ra(this)}function Ra(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if(Hf(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)Pn(n,r)&&delete n[r];jn(t,n),n._inc=e}}Bt.prototype.item=function(n){return Ra(this),this[n]||null};ot(Bt,Ne);function Fn(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function $f(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function du(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 u_(n,e,t){var r=du(n,e,!1),o=r&&r[t];return o||null}function c_(n,e){du(n,e.namespaceURI,!0)[e.localName]=e}function d_(n,e){var t=du(n,e.namespaceURI,!1);t&&delete t[e.localName]}function f_(n,e,t,r){if(r?e[$f(e,r)]=t:(e[e.length]=t,e.length++),c_(e,t),n){t.ownerElement=n;var o=n.ownerDocument;o&&(r&&Lf(o,n,r),h_(o,n,t))}}function Tf(n,e,t){var r=$f(e,t);if(r>=0){for(var o=e.length-1;r<=o;)e[r]=e[++r];if(e.length=o,d_(e,t),n){var i=n.ownerDocument;i&&Lf(i,n,t),t.ownerElement=null}}}Fn.prototype={length:0,item:Ne.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 R(R.INUSE_ATTRIBUTE_ERR);var t=u_(this,n.namespaceURI,n.localName);return t===n?n:(f_(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 R(R.NOT_FOUND_ERR,n);return Tf(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new R(R.NOT_FOUND_ERR,n?n+" : "+e:e);return Tf(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}};Fn.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 Mf(){}Mf.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=Ko.XML_APPLICATION;n===Mt.HTML?r=Ko.XML_XHTML_APPLICATION:n===Mt.SVG&&(r=Ko.XML_SVG_IMAGE);var o=new Yt(Xe,{contentType:r});if(o.implementation=this,o.childNodes=new Ne,o.doctype=t||null,t&&o.appendChild(t),e){var i=o.createElementNS(n,e);o.appendChild(i)}return o},createDocumentType:function(n,e,t,r){Nf(n);var o=new Ma(Xe);return o.name=n,o.nodeName=n,o.publicId=e||"",o.systemId=t||"",o.internalSubset=r||"",o.childNodes=new Ne,o},createHTMLDocument:function(n){var e=new Yt(Xe,{contentType:Ko.HTML});if(e.implementation=this,e.childNodes=new Ne,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 o=e.createElement("title");o.appendChild(e.createTextNode(n)),r.appendChild(o)}t.appendChild(e.createElement("body"))}return e}};function J(n){nt(n)}J.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,o=t.other;if(r.nodeType!==o.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==o.name||r.publicId!==o.publicId||r.systemId!==o.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==o.namespaceURI||r.prefix!==o.prefix||r.localName!==o.localName||r.attributes.length!==o.attributes.length)return!1;for(var i=0;i<r.attributes.length;i++){var a=r.attributes.item(i),s=o.getAttributeNodeNS(a.namespaceURI,a.localName);if(!s)return!1;e.push({node:a,other:s})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==o.namespaceURI||r.localName!==o.localName||r.value!==o.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==o.target||r.data!==o.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==o.data)return!1;break}if(r.childNodes.length!==o.childNodes.length)return!1;for(var i=r.childNodes.length-1;i>=0;i--)e.push({node:r.childNodes[i],other:o.childNodes[i]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return Oa(this,n,e)},replaceChild:function(n,e){Oa(this,n,e,qf),e&&this.removeChild(e)},removeChild:function(n){return Ff(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return zf(this.ownerDocument||this,this,n)},normalize:function(){Le(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===Jo&&e.nodeType===Jo){for(var r=[],o=t;o!==null&&o.nodeType===Jo;)r.push(o.data),o=o.nextSibling;for(var i=e.nextSibling;i!==o;){var a=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=a}e.nextSibling=o,o!==null?o.previousSibling=e:n.lastChild=e,e.appendData(r.join("")),fu(n.ownerDocument,n),e=o}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(Pn(t,r)&&t[r]===n)return r}e=e.nodeType==Ln?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&Pn(t,n))return t[n];e=e.nodeType==Ln?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,o=null;if(e instanceof Hr&&(r=e,e=r.ownerElement),t instanceof Hr&&(o=t,t=o.ownerElement,r&&e&&t===e))for(var i=0,a;a=t.attributes[i];i++){if(a===r)return ve.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ve.DOCUMENT_POSITION_PRECEDING;if(a===o)return ve.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+ve.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return ve.DOCUMENT_POSITION_DISCONNECTED+ve.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(kf(t.ownerDocument)>kf(e.ownerDocument)?ve.DOCUMENT_POSITION_FOLLOWING:ve.DOCUMENT_POSITION_PRECEDING);if(o&&e===t)return ve.DOCUMENT_POSITION_CONTAINS+ve.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return ve.DOCUMENT_POSITION_CONTAINED_BY+ve.DOCUMENT_POSITION_FOLLOWING;for(var s=[],l=e.parentNode;l;){if(!o&&l===t)return ve.DOCUMENT_POSITION_CONTAINED_BY+ve.DOCUMENT_POSITION_FOLLOWING;s.push(l),l=l.parentNode}s.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return ve.DOCUMENT_POSITION_CONTAINS+ve.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=Bf(s,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return ve.DOCUMENT_POSITION_FOLLOWING;if(h===e)return ve.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return ve.DOCUMENT_POSITION_FOLLOWING;if(s.indexOf(h)>=0)return ve.DOCUMENT_POSITION_PRECEDING}return 0}};function Pf(n){return n=="<"&&"<"||n==">"&&">"||n=="&"&&"&"||n=='"'&&"""||"&#"+n.charCodeAt()+";"}jn(it,J);jn(it,J.prototype);jn(ve,J);jn(ve,J.prototype);function Ia(n,e){Le(n,null,{enter:function(t){return e(t)?Le.STOP:!0}})}function Le(n,e,t){for(var r=[{node:n,context:e,phase:Le.ENTER}];r.length>0;){var o=r.pop();if(o.phase===Le.ENTER){var i=t.enter(o.node,o.context);if(i===Le.STOP)return Le.STOP;if(r.push({node:o.node,context:i,phase:Le.EXIT}),i==null)continue;for(var a=o.node.lastChild;a;)r.push({node:a,context:i,phase:Le.ENTER}),a=a.previousSibling}else t.exit&&t.exit(o.node,o.context)}}Le.STOP=Symbol("walkDOM.STOP");Le.ENTER=0;Le.EXIT=1;function Yt(n,e){nt(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||Ko.XML_APPLICATION,this.type=e_(this.contentType)?"html":"xml"}function h_(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===Mt.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Lf(n,e,t,r){n&&n._inc++;var o=t.namespaceURI;o===Mt.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function fu(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var o=e.firstChild,i=0;o;)r[i++]=o,o=o.nextSibling;r.length=i,delete r[r.length]}}}function Ff(n,e){if(n!==e.parentNode)throw new R(R.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,fu(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function p_(n){return n&&(n.nodeType===J.DOCUMENT_NODE||n.nodeType===J.DOCUMENT_FRAGMENT_NODE||n.nodeType===J.ELEMENT_NODE)}function m_(n){return n&&(n.nodeType===J.CDATA_SECTION_NODE||n.nodeType===J.COMMENT_NODE||n.nodeType===J.DOCUMENT_FRAGMENT_NODE||n.nodeType===J.DOCUMENT_TYPE_NODE||n.nodeType===J.ELEMENT_NODE||n.nodeType===J.PROCESSING_INSTRUCTION_NODE||n.nodeType===J.TEXT_NODE)}function br(n){return n&&n.nodeType===J.DOCUMENT_TYPE_NODE}function Wt(n){return n&&n.nodeType===J.ELEMENT_NODE}function jf(n){return n&&n.nodeType===J.TEXT_NODE}function Af(n,e){var t=n.childNodes||[];if($t(t,Wt)||br(e))return!1;var r=$t(t,br);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function Df(n,e){var t=n.childNodes||[];function r(i){return Wt(i)&&i!==e}if($t(t,r))return!1;var o=$t(t,br);return!(e&&o&&t.indexOf(o)>t.indexOf(e))}function g_(n,e,t){if(!p_(n))throw new R(R.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new R(R.NOT_FOUND_ERR,"child not in parent");if(!m_(e)||br(e)&&n.nodeType!==J.DOCUMENT_NODE)throw new R(R.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function b_(n,e,t){var r=n.childNodes||[],o=e.childNodes||[];if(e.nodeType===J.DOCUMENT_FRAGMENT_NODE){var i=o.filter(Wt);if(i.length>1||$t(o,jf))throw new R(R.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Af(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Wt(e)&&!Af(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(br(e)){if($t(r,br))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=$t(r,Wt);if(t&&r.indexOf(a)<r.indexOf(t))throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&a)throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function qf(n,e,t){var r=n.childNodes||[],o=e.childNodes||[];if(e.nodeType===J.DOCUMENT_FRAGMENT_NODE){var i=o.filter(Wt);if(i.length>1||$t(o,jf))throw new R(R.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Df(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Wt(e)&&!Df(n,t))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(br(e)){if($t(r,function(l){return br(l)&&l!==t}))throw new R(R.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=$t(r,Wt);if(t&&r.indexOf(a)<r.indexOf(t))throw new R(R.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Oa(n,e,t,r){g_(n,e,t),n.nodeType===J.DOCUMENT_NODE&&(r||b_)(n,e,t);var o=e.parentNode;if(o&&o.removeChild(e),e.nodeType===gr){var i=e.firstChild;if(i==null)return e;var a=e.lastChild}else i=a=e;var s=t?t.previousSibling:n.lastChild;i.previousSibling=s,a.nextSibling=t,s?s.nextSibling=i:n.firstChild=i,t==null?n.lastChild=a:t.previousSibling=a;do i.parentNode=n;while(i!==a&&(i=i.nextSibling));return fu(n.ownerDocument||n,n,e),e.nodeType==gr&&(e.firstChild=e.lastChild=null),e}Yt.prototype={implementation:null,nodeName:"#document",nodeType:Mn,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===gr){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return Oa(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===ft&&(this.documentElement=n),n},removeChild:function(n){var e=Ff(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){Oa(this,n,e,qf),n.ownerDocument=this,e&&this.removeChild(e),Wt(n)&&(this.documentElement=n)},importNode:function(n,e){return w_(this,n,e)},getElementById:function(n){var e=null;return Ia(this.documentElement,function(t){if(t.nodeType==ft&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new Xt(Xe);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),Qw(this.contentType)&&(e.namespaceURI=Mt.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new Ne;var t=e.attributes=new Fn;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new qn(Xe);return n.ownerDocument=this,n.childNodes=new Ne,n},createTextNode:function(n){var e=new Qo(Xe);return e.ownerDocument=this,e.childNodes=new Ne,e.appendData(n),e},createComment:function(n){var e=new Ba(Xe);return e.ownerDocument=this,e.childNodes=new Ne,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new R(R.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new $a(Xe);return e.ownerDocument=this,e.childNodes=new Ne,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new La(Xe);return t.ownerDocument=this,t.childNodes=new Ne,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!Ee.QName_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new Hr(Xe);return e.ownerDocument=this,e.childNodes=new Ne,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!Ee.Name_exact.test(n))throw new R(R.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new R("document is an html document",Ge.NotSupportedError);var e=new Pa(Xe);return e.ownerDocument=this,e.childNodes=new Ne,e.nodeName=n,e},createElementNS:function(n,e){var t=lu(n,e),r=new Xt(Xe),o=r.attributes=new Fn;return r.childNodes=new Ne,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],o._ownerElement=r,r},createAttributeNS:function(n,e){var t=lu(n,e),r=new Hr(Xe);return r.ownerDocument=this,r.childNodes=new Ne,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};ot(Yt,J);function Xt(n){nt(n),this._nsMap=Object.create(null)}Xt.prototype={nodeType:ft,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Mt.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=lu(n,e),o=r[2],i=this.getAttributeNodeNS(n,o);i?i.value=i.nodeValue=""+t:(i=this.ownerDocument.createAttributeNS(n,e),i.value=i.nodeValue=""+t,this.setAttributeNode(i))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=xf(n);return new Bt(this,function(t){var r=[];return e.length>0&&Ia(t,function(o){if(o!==t&&o.nodeType===ft){var i=o.getAttribute("class");if(i){var a=n===i;if(!a){var s=xf(i);a=e.every(a_(s))}a&&r.push(o)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===Mn?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Bt(this,function(r){var o=[];return Ia(r,function(i){if(!(i===r||i.nodeType!==ft))if(n==="*")o.push(i);else{var a=i.getQualifiedName(),s=e&&i.namespaceURI===Mt.HTML?t:n;a===s&&o.push(i)}}),o})},getElementsByTagNameNS:function(n,e){return new Bt(this,function(t){var r=[];return Ia(t,function(o){o!==t&&o.nodeType===ft&&(n==="*"||o.namespaceURI===n)&&(e==="*"||o.localName==e)&&r.push(o)}),r})}};Yt.prototype.getElementsByClassName=Xt.prototype.getElementsByClassName;Yt.prototype.getElementsByTagName=Xt.prototype.getElementsByTagName;Yt.prototype.getElementsByTagNameNS=Xt.prototype.getElementsByTagNameNS;ot(Xt,J);function Hr(n){nt(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Hr.prototype.nodeType=Ln;ot(Hr,J);function wr(n){nt(n)}wr.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),o=this.data.substring(n+e);t=r+t+o,this.nodeValue=this.data=t,this.length=t.length}};ot(wr,J);function Qo(n){nt(n)}Qo.prototype={nodeName:"#text",nodeType:Jo,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}};ot(Qo,wr);function Ba(n){nt(n)}Ba.prototype={nodeName:"#comment",nodeType:cu};ot(Ba,wr);function $a(n){nt(n)}$a.prototype={nodeName:"#cdata-section",nodeType:If};ot($a,Qo);function Ma(n){nt(n)}Ma.prototype.nodeType=Rf;ot(Ma,J);function hu(n){nt(n)}hu.prototype.nodeType=l_;ot(hu,J);function pu(n){nt(n)}pu.prototype.nodeType=s_;ot(pu,J);function Pa(n){nt(n)}Pa.prototype.nodeType=Of;ot(Pa,J);function qn(n){nt(n)}qn.prototype.nodeName="#document-fragment";qn.prototype.nodeType=gr;ot(qn,J);function La(n){nt(n)}La.prototype.nodeType=uu;ot(La,wr);function Uf(){}Uf.prototype.serializeToString=function(n,e){return Vf.call(n,e)};J.prototype.toString=Vf;function Vf(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===Mn&&this.documentElement||this,o=r.prefix,i=r.namespaceURI;if(i&&o==null){var o=r.lookupPrefix(i);if(o==null)var a=[{namespace:i,prefix:null}]}return mu(this,t,a,e),t.join("")}function Sf(n,e,t){var r=n.prefix||"",o=n.namespaceURI;if(!o||r==="xml"&&o===Mt.XML||o===Mt.XMLNS)return!1;for(var i=t.length;i--;){var a=t[i];if(a.prefix===r)return a.namespace!==o}return!0}function Na(n,e,t,r){if(r&&!Ee.QName_exact.test(e))throw new R('The attribute name "'+e+'" is not a valid XML QName',Ge.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Pf),'"')}function mu(n,e,t,r){t||(t=[]);var o=r.nodeFilter,i=r.requireWellFormed,a=r.splitCDATASections,s=n.nodeType===Mn?n:n.ownerDocument,l=s.type==="html";Le(n,{ns:t},{enter:function(u,c){var d=c.ns;if(o)if(u=o(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case ft:var f=u.attributes,h=f.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var w,b=0;b<f.length;b++)if(f.item(b).name==="xmlns"){w=f.item(b).value;break}if(!w)for(var _=d.length-1;_>=0;_--){var y=d[_];if(y.prefix===""&&y.namespace===u.namespaceURI){w=y.namespace;break}}if(w!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var y=d[_];if(y.namespace===u.namespaceURI){y.prefix&&(m=y.prefix+":"+p);break}}}if(i&&!Ee.QName_exact.test(m))throw new R('The element name "'+m+'" is not a valid XML QName',Ge.InvalidStateError);e.push("<",m);for(var E=d.slice(),S=0;S<h;S++){var x=f.item(S);x.prefix=="xmlns"?E.push({prefix:x.localName,namespace:x.value}):x.nodeName=="xmlns"&&E.push({prefix:"",namespace:x.value})}for(var S=0;S<h;S++){var x=f.item(S);if(Sf(x,l,E)){var N=x.prefix||"",O=x.namespaceURI;Na(e,N?"xmlns:"+N:"xmlns",O,i),E.push({prefix:N,namespace:O})}var $=o?o(x):x;$&&(typeof $=="string"?e.push($):Na(e,$.name,$.value,i))}if(p===m&&Sf(u,l,E)){var K=u.prefix||"",O=u.namespaceURI;Na(e,K?"xmlns:"+K:"xmlns",O,i),E.push({prefix:K,namespace:O})}var W=!u.firstChild;if(W&&(l||u.namespaceURI===Mt.HTML)&&(W=r_(p)),W)return e.push("/>"),null;if(e.push(">"),l&&t_(p)){for(var se=u.firstChild;se;)se.data?e.push(se.data):mu(se,e,E.slice(),r),se=se.nextSibling;return e.push("</",m,">"),null}return{ns:E,tag:m};case Mn:case gr:if(i&&u.nodeType===Mn&&u.documentElement==null)throw new R("The Document has no documentElement",Ge.InvalidStateError);return{ns:d};case Ln:return Na(e,u.name,u.value,i),null;case Jo:if(i&&Ee.InvalidChar.test(u.data))throw new R("The Text node data contains characters outside the XML Char production",Ge.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Pf)),null;case If:if(i&&u.data.indexOf("]]>")!==-1)throw new R('The CDATASection data contains "]]>"',Ge.InvalidStateError);return a?e.push(Ee.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Ee.CDATA_END):e.push(Ee.CDATA_START,u.data,Ee.CDATA_END),null;case cu:if(i){if(Ee.InvalidChar.test(u.data))throw new R("The comment node data contains characters outside the XML Char production",Ge.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new R('The comment node data contains "--" or ends with "-"',Ge.InvalidStateError)}return e.push(Ee.COMMENT_START,u.data,Ee.COMMENT_END),null;case Rf:var me=u.publicId,te=u.systemId;if(i){if(!Ee.Name_exact.test(u.name))throw new R('The doctype name "'+u.name+'" is not a valid XML Name',Ge.InvalidStateError);if(me&&!Ee.PubidLiteral_match.test(me))throw new R("DocumentType publicId is not a valid PubidLiteral",Ge.InvalidStateError);if(te&&te!=="."&&!Ee.SystemLiteral_match.test(te))throw new R("DocumentType systemId is not a valid SystemLiteral",Ge.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new R('DocumentType internalSubset contains "]>"',Ge.InvalidStateError)}return e.push(Ee.DOCTYPE_DECL_START," ",u.name),me?(e.push(" ",Ee.PUBLIC," ",me),te&&te!=="."&&e.push(" ",te)):te&&te!=="."&&e.push(" ",Ee.SYSTEM," ",te),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case uu:if(i){if(!Ee.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new R('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',Ge.InvalidStateError);if(Ee.InvalidChar.test(u.data))throw new R("The ProcessingInstruction data contains characters outside the XML Char production",Ge.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new R('The ProcessingInstruction data contains "?>"',Ge.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Of:if(i&&!Ee.Name_exact.test(u.nodeName))throw new R('The entity reference name "'+u.nodeName+'" is not a valid XML Name',Ge.InvalidStateError);return e.push("&",u.nodeName,";"),null;default:return e.push("??",u.nodeName),null}},exit:function(u,c){c&&c.tag&&e.push("</",c.tag,">")}})}function w_(n,e,t){var r;return Le(e,null,{enter:function(o,i){var a=o.cloneNode(!1);a.ownerDocument=n,a.parentNode=null,i===null?r=a:i.appendChild(a);var s=o.nodeType===Ln||t;return s?a:null}}),r}function zf(n,e,t){var r;return Le(e,null,{enter:function(o,i){var a=new o.constructor(Xe);for(var s in o)if(Pn(o,s)){var l=o[s];typeof l!="object"&&l!=a[s]&&(a[s]=l)}o.childNodes&&(a.childNodes=new Ne),a.ownerDocument=n;var u=t;switch(a.nodeType){case ft:var c=o.attributes,d=a.attributes=new Fn,f=c.length;d._ownerElement=a;for(var h=0;h<f;h++)a.setAttributeNode(zf(n,c.item(h),!0));break;case Ln:u=!0}return i!==null?i.appendChild(a):r=a,u?a:null}}),r}function Hf(n,e,t){n[e]=t}function su(n){for(var e=[],t=n.firstChild;t;)t.nodeType===ft&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Bt.prototype,"length",{get:function(){return Ra(this),this.$$length}}),Object.defineProperty(J.prototype,"textContent",{get:function(){if(this.nodeType===ft||this.nodeType===gr){var n=[];return Le(this,null,{enter:function(e){if(e.nodeType===ft||e.nodeType===gr)return!0;if(e.nodeType===uu||e.nodeType===cu)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case ft:case gr: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(wr.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(wr.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(Xt.prototype,"children",{get:function(){return new Bt(this,su)}}),Object.defineProperty(Yt.prototype,"children",{get:function(){return new Bt(this,su)}}),Object.defineProperty(qn.prototype,"children",{get:function(){return new Bt(this,su)}}),Hf=function(n,e,t){n["$$"+e]=t})}catch{}xe._updateLiveList=Ra;xe.Attr=Hr;xe.CDATASection=$a;xe.CharacterData=wr;xe.Comment=Ba;xe.Document=Yt;xe.DocumentFragment=qn;xe.DocumentType=Ma;xe.DOMImplementation=Mf;xe.Element=Xt;xe.Entity=pu;xe.EntityReference=Pa;xe.LiveNodeList=Bt;xe.NamedNodeMap=Fn;xe.Node=J;xe.NodeList=Ne;xe.Notation=hu;xe.Text=Qo;xe.ProcessingInstruction=La;xe.walkDOM=Le;xe.XMLSerializer=Uf});var Wf=sr(ei=>{"use strict";var Gf=zr().freeze;ei.XML_ENTITIES=Gf({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});ei.HTML_ENTITIES=Gf({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"});ei.entityMap=ei.HTML_ENTITIES});var rh=sr(ja=>{"use strict";var Gn=zr(),G=au(),Kf=Ho(),__=Gn.isHTMLEscapableRawTextElement,y_=Gn.isHTMLMimeType,v_=Gn.isHTMLRawTextElement,ni=Gn.hasOwn,Yf=Gn.NAMESPACE,E_=Kf.ParseError,x_=Kf.DOMException,Un=0,_r=1,Vn=2,ti=3,zn=4,Hn=5,ri=6,Fa=7;function Jf(){}Jf.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),D_(e,e=Object.create(null)),k_(n,e,t,r,this.errorHandler),r.endDocument()}};var bu=/&#?\w+;?/g;function k_(n,e,t,r,o){var i=y_(r.mimeType);n.indexOf(G.UNICODE_REPLACEMENT_CHARACTER)>=0&&o.warning("Unicode replacement character detected, source encoding issues?");function a(X){if(X>65535){X-=65536;var $e=55296+(X>>10),zt=56320+(X&1023);return String.fromCharCode($e,zt)}else return String.fromCharCode(X)}function s(X){var $e=X[X.length-1]===";"?X:X+";";if(!i&&$e!==X)return o.error("EntityRef: expecting ;"),X;var zt=G.Reference.exec($e);if(!zt||zt[0].length!==$e.length)return o.error("entity not matching Reference production: "+X),X;var vn=$e.slice(1,-1);return ni(t,vn)?t[vn]:vn.charAt(0)==="#"?a(parseInt(vn.substring(1).replace("x","0x"))):(o.error("entity not found:"+X),X)}function l(X){if(X>w){var $e=n.substring(w,X).replace(bu,s);f&&h(w),r.characters($e,0,X-w),w=X}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(X,$e){for(;X>=c&&($e=d.exec(n));)u=c,c=$e.index+$e[0].length,f.lineNumber++;f.columnNumber=X-u+1}for(var p=[{currentNSMap:e}],m=[],w=0;;){try{var b=n.indexOf("<",w);if(b<0){if(!i&&m.length>0)return o.fatalError("unclosed xml tag(s): "+m.join(", "));if(!n.substring(w).match(/^\s*$/)){var _=r.doc,y=_.createTextNode(n.substring(w));if(_.documentElement)return o.error("Extra content at the end of the document");_.appendChild(y),r.currentElement=y}return}if(b>w){var E=n.substring(w,b);!i&&m.length===0&&(E=E.replace(new RegExp(G.S_OPT.source,"g"),""),E&&o.error("Unexpected content outside root element: '"+E+"'")),l(b)}switch(n.charAt(b+1)){case"/":var q=n.indexOf(">",b+2),S=n.substring(b+2,q>0?q:void 0);if(!S)return o.fatalError("end tag name missing");var x=G.reg("^",G.QName_group,G.S_OPT,"$"),N=q>0&&x.exec(S);if(!N){var O=q>0&&G.reg("^",G.QName_group).exec(S);if(i&&O)o.warning('end tag name contains invalid trailing characters: "'+S+'"'),N=O;else if(O&&new RegExp(x.source,x.flags+"m").test(S))o.error('end tag name is followed by a line break and trailing content: "'+S+'"'),N=O;else return o.fatalError('end tag name contains invalid characters: "'+S+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var $=m[m.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if($!==N[1]){var K=N[1].toLowerCase();if(!i||$.toLowerCase()!==K)return o.fatalError('Opening and ending tag mismatch: "'+$+'" != "'+S+'"')}var W=p.pop();m.pop();var se=W.localNSMap;if(r.endElement(W.uri,W.localName,$),se)for(var me in se)ni(se,me)&&r.endPrefixMapping(me);q++;break;case"?":f&&h(b),q=C_(n,b,r,o);break;case"!":f&&h(b),q=eh(n,b,r,o,i);break;default:f&&h(b);var te=new th,le=p[p.length-1].currentNSMap,q=T_(n,b,te,le,s,o,i),dt=te.length;if(te.closed||(i&&Gn.isHTMLVoidElement(te.tagName)?te.closed=!0:m.push(te.tagName)),f&&dt){for(var _n=Xf(f,{}),yn=0;yn<dt;yn++){var wt=te[yn];h(wt.offset),wt.locator=Xf(f,{})}r.locator=_n,Zf(te,r,le)&&p.push(te),r.locator=f}else Zf(te,r,le)&&p.push(te);i&&!te.closed?q=A_(n,q,te.tagName,s,r):q++}}catch(X){if(X instanceof E_)throw X;if(X instanceof x_)return o.fatalError("Error constructing the DOM: "+X.name+": "+X.message,X);o.error("element parse error: "+X),q=-1}q>w?w=q:l(Math.max(b,w)+1)}}function Xf(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function T_(n,e,t,r,o,i,a){function s(h,p,m){if(ni(t.attributeNames,h))return i.fatalError("Attribute "+h+" redefined");if(!a&&p.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,p.replace(/[\t\n\r]/g," ").replace(bu,o),m)}for(var l,u,c=++e,d=Un;;){var f=n.charAt(c);if(d===Un&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===_r)l=n.slice(e,c),d=ti;else if(d===Vn)d=ti;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===ti||d===_r)if(d===_r&&(i.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),s(l,u,e-1),d=Hn;else throw new Error("attribute value no end '"+f+"' match");else if(d==zn)u=n.slice(e,c),s(l,u,e),i.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Hn;else throw new Error('attribute value must after "="');break;case"/":switch(d){case Un:t.setTagName(n.slice(e,c));case Hn:case ri:case Fa:d=Fa,t.closed=!0;case zn:case _r:break;case Vn:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==Un&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case Un:t.setTagName(n.slice(e,c));case Hn:case ri:case Fa:break;case zn:case _r:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Vn:d===Vn&&(u=l),d==zn?(i.warning('attribute "'+u+'" missed quot(")!'),s(l,u,e)):(a||i.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),s(u,u,e));break;case ti:if(!a)return i.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case Un:t.setTagName(n.slice(e,c)),d=ri;break;case _r:l=n.slice(e,c),d=Vn;break;case zn:var u=n.slice(e,c);i.warning('attribute "'+u+'" missed quot(")!!'),s(l,u,e);case Hn:d=ri;break}else switch(d){case Vn:a||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),s(l,l,e),e=c,d=_r;break;case Hn:i.warning('attribute space is required"'+l+'"!!');case ri:d=_r,e=c;break;case ti:d=zn,e=c;break;case Fa:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function Zf(n,e,t){for(var r=n.tagName,o=null,d=n.length;d--;){var i=n[d],a=i.qName,s=i.value,f=a.indexOf(":");if(f>0)var l=i.prefix=a.slice(0,f),u=a.slice(f+1),c=l==="xmlns"&&u;else u=a,l=null,c=a==="xmlns"&&"";i.localName=u,c!==!1&&(o==null&&(o=Object.create(null),t=Object.create(t)),t[c]=o[c]=s,i.uri=Yf.XMLNS,e.startPrefixMapping(c,s))}for(var d=n.length;d--;)i=n[d],i.prefix&&(i.prefix==="xml"&&(i.uri=Yf.XML),i.prefix!=="xmlns"&&(i.uri=t[i.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),o)for(l in o)ni(o,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=o,!0}function A_(n,e,t,r,o){var i=__(t);if(i||v_(t)){var a=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");a.lastIndex=e;var s=a.exec(n),l=s?s.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return i&&(u=u.replace(bu,r)),o.characters(u,0,u.length),l}return e+1}function D_(n,e){for(var t in n)ni(n,t)&&(e[t]=n[t])}function Qf(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function o(c){c=c||1,t+=c}function i(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
|
|
11
|
+
`&&d!==" "&&d!=="\r")return c;c++,o()}return-1}function a(){return n.substring(t)}function s(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=G.reg("^",c),f=d.exec(a());return f?(o(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:o,skipBlanks:i,substringFromIndex:a,substringStartsWith:s,substringStartsWithCaseInsensitive:l}}function S_(n,e){function t(s,l){var u=G.PI.exec(s.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+s.getIndex()):(s.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+s.getIndex())}var r=n.getSource();if(n.char()==="["){n.skip(1);for(var o=n.getIndex();n.getIndex()<r.length;){if(n.skipBlanks(),n.char()==="]"){var i=r.substring(o,n.getIndex());return n.skip(1),i}var a=null;if(n.char()==="<"&&n.char(1)==="!")switch(n.char(2)){case"E":n.char(3)==="L"?a=n.getMatch(G.elementdecl):n.char(3)==="N"&&(a=n.getMatch(G.EntityDecl));break;case"A":a=n.getMatch(G.AttlistDecl);break;case"N":a=n.getMatch(G.NotationDecl);break;case"-":a=n.getMatch(G.Comment);break}else if(n.char()==="<"&&n.char(1)==="?")a=t(n,e);else if(n.char()==="%")a=n.getMatch(G.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!a)return e.fatalError("Error in internal subset at position "+n.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function eh(n,e,t,r,o){var i=Qf(n,e);switch(o?i.char(2).toUpperCase():i.char(2)){case"-":var a=i.getMatch(G.Comment);return a?(t.comment(a,G.COMMENT_START.length,a.length-G.COMMENT_START.length-G.COMMENT_END.length),i.getIndex()):r.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var s=i.getMatch(G.CDSect);return s?!o&&!t.currentElement?r.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(s,G.CDATA_START.length,s.length-G.CDATA_START.length-G.CDATA_END.length),t.endCDATA(),i.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 "+i.getIndex());if(o?!i.substringStartsWithCaseInsensitive(G.DOCTYPE_DECL_START):!i.substringStartsWith(G.DOCTYPE_DECL_START))return r.fatalError("Expected "+G.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(G.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return r.fatalError("Expected whitespace after "+G.DOCTYPE_DECL_START+" at position "+i.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=i.getMatch(G.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(o&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(G.PUBLIC)||i.substringStartsWith(G.SYSTEM)){var u=G.ExternalID_match.exec(i.substringFromIndex());if(!u)return r.fatalError("doctype external id is not well-formed at position "+i.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),i.skip(u[0].length)}else if(o&&i.substringStartsWithCaseInsensitive(G.SYSTEM)){if(i.skip(G.SYSTEM.length),i.skipBlanks()<1)return r.fatalError("Expected whitespace after "+G.SYSTEM+" at position "+i.getIndex());if(l.systemId=i.getMatch(G.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+G.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+G.SYSTEM+" at position "+i.getIndex())}return o&&l.systemId&&!G.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),o||(i.skipBlanks(),l.internalSubset=S_(i,r)),i.skipBlanks(),i.char()!==">"?r.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),i.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function C_(n,e,t,r){var o=n.substring(e).match(G.PI);if(!o)return r.fatalError("Invalid processing instruction starting at position "+e);if(o[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(!G.XMLDecl.test(n.substring(e)))return r.fatalError("xml declaration is not well-formed")}return t.processingInstruction(o[1],o[2]),e+o[0].length}function th(){this.attributeNames=Object.create(null)}th.prototype={setTagName:function(n){if(!G.QName_exact.test(n))throw new Error("invalid tagName:"+n);this.tagName=n},addValue:function(n,e,t){if(!G.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}};ja.XMLReader=Jf;ja.parseUtils=Qf;ja.parseDoctypeCommentOrCData=eh});var uh=sr(Yn=>{"use strict";var Gr=zr(),N_=gu(),I_=Ho(),nh=Wf(),O_=rh(),R_=N_.DOMImplementation,B_=Gr.hasDefaultHTMLNamespace,$_=Gr.isHTMLMimeType,M_=Gr.isValidMimeType,ah=Gr.MIME_TYPE,wu=Gr.NAMESPACE,oh=I_.ParseError,P_=O_.XMLReader;function sh(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 lh(n){if(n=n||{},n.locator===void 0&&(n.locator=!0),this.assign=n.assign||Gr.assign,this.domHandler=n.domHandler||Ua,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||sh,this.locator=!!n.locator,this.xmlns=this.assign(Object.create(null),n.xmlns)}lh.prototype.parseFromString=function(n,e){if(!M_(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),r=nh.XML_ENTITIES,o=t[""]||null;B_(e)?(r=nh.HTML_ENTITIES,o=wu.HTML):e===ah.XML_SVG_IMAGE&&(o=wu.SVG),t[""]=o,t.xml=t.xml||wu.XML;var i=new this.domHandler({mimeType:e,defaultNamespace:o,onError:this.onError}),a=this.locator?{}:void 0;this.locator&&i.setDocumentLocator(a);var s=new P_;s.errorHandler=i,s.domBuilder=i;var l=!Gr.isHTMLMimeType(e);return l&&typeof n!="string"&&s.errorHandler.fatalError("source is not a string"),s.parse(this.normalizeLineEndings(String(n)),t,r),i.doc.documentElement||s.errorHandler.fatalError("missing root element"),i.doc};function Ua(n){var e=n||{};this.mimeType=e.mimeType||ah.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 Wn(n,e){e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber}Ua.prototype={startDocument:function(){var n=new R_;this.doc=$_(this.mimeType)?n.createHTMLDocument(!1):n.createDocument(this.defaultNamespace,"")},startElement:function(n,e,t,r){var o=this.doc,i=o.createElementNS(n,t||e),a=r.length;qa(this,i),this.currentElement=i,this.locator&&Wn(this.locator,i);for(var s=0;s<a;s++){var n=r.getURI(s),l=r.getValue(s),t=r.getQName(s),u=o.createAttributeNS(n,t);this.locator&&Wn(r.getLocator(s),u),u.value=u.nodeValue=l,i.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&&Wn(this.locator,t),qa(this,t)},ignorableWhitespace:function(n,e,t){},characters:function(n,e,t){if(n=ih.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&&Wn(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=ih.apply(this,arguments);var r=this.doc.createComment(n);this.locator&&Wn(this.locator,r),qa(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(n,e,t,r){var o=this.doc.implementation;if(o&&o.createDocumentType){var i=o.createDocumentType(n,e,t,r);this.locator&&Wn(this.locator,i),qa(this,i),this.doc.doctype=i}},reportError:function(n,e){if(typeof this.onError=="function")try{this.onError(n,e,this)}catch(t){throw new oh("Reporting "+n+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+n+"] "+e,L_(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 oh(n,this.locator,e)}};function L_(n){if(n)return`
|
|
14
|
+
@#[line:`+n.lineNumber+",col:"+n.columnNumber+"]"}function ih(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){Ua.prototype[n]=function(){return null}});function qa(n,e){n.currentElement?n.currentElement.appendChild(e):n.doc.appendChild(e)}function F_(n){if(n==="error")throw"onErrorStopParsing"}function j_(){throw"onWarningStopParsing"}Yn.__DOMHandler=Ua;Yn.DOMParser=lh;Yn.normalizeLineEndings=sh;Yn.onErrorStopParsing=F_;Yn.onWarningStopParsing=j_});var _u=sr(Q=>{"use strict";var Xn=zr();Q.assign=Xn.assign;Q.hasDefaultHTMLNamespace=Xn.hasDefaultHTMLNamespace;Q.isHTMLMimeType=Xn.isHTMLMimeType;Q.isValidMimeType=Xn.isValidMimeType;Q.MIME_TYPE=Xn.MIME_TYPE;Q.NAMESPACE=Xn.NAMESPACE;var Va=Ho();Q.DOMException=Va.DOMException;Q.DOMExceptionName=Va.DOMExceptionName;Q.ExceptionCode=Va.ExceptionCode;Q.ParseError=Va.ParseError;var Ie=gu();Q.Attr=Ie.Attr;Q.CDATASection=Ie.CDATASection;Q.CharacterData=Ie.CharacterData;Q.Comment=Ie.Comment;Q.Document=Ie.Document;Q.DocumentFragment=Ie.DocumentFragment;Q.DocumentType=Ie.DocumentType;Q.DOMImplementation=Ie.DOMImplementation;Q.Element=Ie.Element;Q.Entity=Ie.Entity;Q.EntityReference=Ie.EntityReference;Q.LiveNodeList=Ie.LiveNodeList;Q.NamedNodeMap=Ie.NamedNodeMap;Q.Node=Ie.Node;Q.NodeList=Ie.NodeList;Q.Notation=Ie.Notation;Q.ProcessingInstruction=Ie.ProcessingInstruction;Q.Text=Ie.Text;Q.XMLSerializer=Ie.XMLSerializer;var za=uh();Q.DOMParser=za.DOMParser;Q.normalizeLineEndings=za.normalizeLineEndings;Q.onErrorStopParsing=za.onErrorStopParsing;Q.onWarningStopParsing=za.onWarningStopParsing});var ca=new WeakMap,Td=`
|
|
15
15
|
--gramlot-toolbar-thickness:56px; --gramlot-toolbar-control-size:44px; --gramlot-toolbar-padding:6px;
|
|
16
|
-
`,
|
|
16
|
+
`,Ad=`
|
|
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
|
+
`,yg=`
|
|
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]{${Td}}
|
|
23
|
+
:root[data-gramlot-touch="on"] [data-gramlot-viewport="root"]{${Ad}}
|
|
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]{${Td}}
|
|
27
|
+
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"]{${Ad}}
|
|
28
28
|
:root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"] > *{max-height:100%;}
|
|
29
29
|
}
|
|
30
|
-
`,Ao=class n{static install({document:e,root:t}){return aa.has(t)||aa.set(t,new n(e,t)),aa.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 o=r.content.split(",").map(i=>i.trim()).filter(i=>!i.startsWith("viewport-fit="));r.content=[...o,"viewport-fit=cover"].join(","),this.style=e.createElement("style"),this.style.textContent=cg,e.head.append(this.style)}subscribeAppearance(e){let t=this.document.defaultView,r=t.matchMedia("(prefers-color-scheme: dark)"),o=()=>{let s=t.getComputedStyle(this.document.documentElement).colorScheme;e({dark:s==="dark"||!["light","dark"].includes(s)&&r.matches})},i=new t.MutationObserver(o);i.observe(this.document.documentElement,{attributes:!0,attributeFilter:["data-theme","style","class"]}),r.addEventListener("change",o),o();let a=()=>{i.disconnect(),r.removeEventListener("change",o)};return this.releases.push(a),a}dispose(){if(!this.closed){this.closed=!0;for(let e of this.releases)e();this.style.remove(),this.root.removeAttribute("data-gramlot-viewport"),aa.delete(this.root)}}};var Do=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(o=>!["author","description"].includes(o))||Object.values(t).some(o=>typeof o!="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(o,i){if(typeof o!="string"||!o||o.includes(":"))throw new TypeError("Invalid command name");if(r.has(o))throw new Error(`Duplicate command: ${e}:${o}`);if(!i||typeof i!="object"||Array.isArray(i)||!Object.hasOwn(i,"label")||!Object.hasOwn(i,"publish")||Object.keys(i).some(a=>!["label","publish","icon","iconSrc","tooltip"].includes(a))||Object.values(i).some(a=>typeof a!="string"))throw new TypeError(`Invalid command definition: ${e}:${o}`);r.set(o,Object.freeze({...i}))}})}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 So=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:o=globalThis.navigator,XMLHttpRequest:i=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=o,this.XMLHttpRequest=i}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 sa=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 nr=class{createTransport({rpcUrl:e,closeUrl:t,document:r,channel:o=null}){let i=r.defaultView,a=new So(e,{closeUrl:t,navigator:i.navigator,XMLHttpRequest:i.XMLHttpRequest});return o===null?a:new sa(o,a)}};var Dn=9e15,sr=1e9,Sl="0123456789abcdef",ca="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",da="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Cl={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Dn,maxE:Dn,crypto:!1},yd,Vt,V=!0,ha="[DecimalError] ",ar=ha+"Invalid argument: ",vd=ha+"Precision limit exceeded",Ed=ha+"crypto unavailable",xd="[object Decimal]",Ue=Math.floor,Se=Math.pow,dg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,fg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,hg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,kd=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_t=1e7,L=7,pg=9007199254740991,mg=ca.length-1,Nl=da.length-1,D={toStringTag:xd};D.absoluteValue=D.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),P(n)};D.ceil=function(){return P(new this.constructor(this),this.e+1,2)};D.clampedTo=D.clamp=function(n,e){var t,r=this,o=r.constructor;if(n=new o(n),e=new o(e),!n.s||!e.s)return new o(NaN);if(n.gt(e))throw Error(ar+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new o(r)};D.comparedTo=D.cmp=function(n){var e,t,r,o,i=this,a=i.d,s=(n=new i.constructor(n)).d,l=i.s,u=n.s;if(!a||!s)return!l||!u?NaN:l!==u?l:a===s?0:!a^l<0?1:-1;if(!a[0]||!s[0])return a[0]?l:s[0]?-u:0;if(l!==u)return l;if(i.e!==n.e)return i.e>n.e^l<0?1:-1;for(r=a.length,o=s.length,e=0,t=r<o?r:o;e<t;++e)if(a[e]!==s[e])return a[e]>s[e]^l<0?1:-1;return r===o?0:r>o^l<0?1:-1};D.cosine=D.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())+L,r.rounding=1,t=gg(r,Cd(r,t)),r.precision=n,r.rounding=e,P(Vt==2||Vt==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};D.cubeRoot=D.cbrt=function(){var n,e,t,r,o,i,a,s,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(V=!1,i=c.s*Se(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=Be(c.d),n=c.e,(i=(n-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Se(t,1/3),n=Ue((n+1)/3)-(n%3==(n<0?-1:2)),i==1/0?t="5e"+n:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(i.toString()),a=(n=d.precision)+3;;)if(s=r,l=s.times(s).times(s),u=l.plus(c),r=de(u.plus(c).times(s),u.plus(l),a+2,1),Be(s.d).slice(0,a)===(t=Be(r.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!o&&t=="4999"){if(!o&&(P(s,n+1,0),s.times(s).times(s).eq(c))){r=s;break}a+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(P(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return V=!0,P(r,n,d.rounding,e)};D.decimalPlaces=D.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-Ue(this.e/L))*L,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};D.dividedBy=D.div=function(n){return de(this,new this.constructor(n))};D.dividedToIntegerBy=D.divToInt=function(n){var e=this,t=e.constructor;return P(de(e,new t(n),0,1,1),t.precision,t.rounding)};D.equals=D.eq=function(n){return this.cmp(n)===0};D.floor=function(){return P(new this.constructor(this),this.e+1,3)};D.greaterThan=D.gt=function(n){return this.cmp(n)>0};D.greaterThanOrEqualTo=D.gte=function(n){var e=this.cmp(n);return e==1||e===0};D.hyperbolicCosine=D.cosh=function(){var n,e,t,r,o,i=this,a=i.constructor,s=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return s;t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,o=i.d.length,o<32?(n=Math.ceil(o/3),e=(1/ma(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),i=Sn(a,1,i.times(e),new a(1),!0);for(var l,u=n,c=new a(8);u--;)l=i.times(i),i=s.minus(l.times(c.minus(l.times(c))));return P(i,a.precision=t,a.rounding=r,!0)};D.hyperbolicSine=D.sinh=function(){var n,e,t,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=Sn(i,2,o,o,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,o=o.times(1/ma(5,n)),o=Sn(i,2,o,o,!0);for(var a,s=new i(5),l=new i(16),u=new i(20);n--;)a=o.times(o),o=o.times(s.plus(a.times(l.times(a).plus(u))))}return i.precision=e,i.rounding=t,P(o,e,t,!0)};D.hyperbolicTangent=D.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,de(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};D.inverseCosine=D.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,o=e.rounding;return t!==-1?t===0?n.isNeg()?Nt(e,r,o):new e(0):new e(NaN):n.isZero()?Nt(e,r+4,o).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=o,n.times(2))};D.inverseHyperbolicCosine=D.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,V=!1,t=t.times(t).minus(1).sqrt().plus(t),V=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};D.inverseHyperbolicSine=D.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,V=!1,t=t.times(t).plus(1).sqrt().plus(t),V=!0,r.precision=n,r.rounding=e,t.ln())};D.inverseHyperbolicTangent=D.atanh=function(){var n,e,t,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(n=i.precision,e=i.rounding,r=o.sd(),Math.max(r,n)<2*-o.e-1?P(new i(o),n,e,!0):(i.precision=t=r-o.e,o=de(o.plus(1),new i(1).minus(o),t+n,1),i.precision=n+4,i.rounding=1,o=o.ln(),i.precision=n,i.rounding=e,o.times(.5))):new i(NaN)};D.inverseSine=D.asin=function(){var n,e,t,r,o=this,i=o.constructor;return o.isZero()?new i(o):(e=o.abs().cmp(1),t=i.precision,r=i.rounding,e!==-1?e===0?(n=Nt(i,t+4,r).times(.5),n.s=o.s,n):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,o.times(2)))};D.inverseTangent=D.atan=function(){var n,e,t,r,o,i,a,s,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<=Nl)return a=Nt(c,d+4,f).times(.25),a.s=u.s,a}else{if(!u.s)return new c(NaN);if(d+4<=Nl)return a=Nt(c,d+4,f).times(.5),a.s=u.s,a}for(c.precision=s=d+10,c.rounding=1,t=Math.min(28,s/L+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(V=!1,e=Math.ceil(s/L),r=1,l=u.times(u),a=new c(u),o=u;n!==-1;)if(o=o.times(l),i=a.minus(o.div(r+=2)),o=o.times(l),a=i.plus(o.div(r+=2)),a.d[e]!==void 0)for(n=e;a.d[n]===i.d[n]&&n--;);return t&&(a=a.times(2<<t-1)),V=!0,P(a,c.precision=d,c.rounding=f,!0)};D.isFinite=function(){return!!this.d};D.isInteger=D.isInt=function(){return!!this.d&&Ue(this.e/L)>this.d.length-2};D.isNaN=function(){return!this.s};D.isNegative=D.isNeg=function(){return this.s<0};D.isPositive=D.isPos=function(){return this.s>0};D.isZero=function(){return!!this.d&&this.d[0]===0};D.lessThan=D.lt=function(n){return this.cmp(n)<0};D.lessThanOrEqualTo=D.lte=function(n){return this.cmp(n)<1};D.logarithm=D.log=function(n){var e,t,r,o,i,a,s,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)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(V=!1,s=d+h,a=ir(u,s),r=e?fa(c,s+10):ir(n,s),l=de(a,r,s,1),Co(l.d,o=d,f))do if(s+=10,a=ir(u,s),r=e?fa(c,s+10):ir(n,s),l=de(a,r,s,1),!i){+Be(l.d).slice(o+1,o+15)+1==1e14&&(l=P(l,d+1,0));break}while(Co(l.d,o+=10,f));return V=!0,P(l,d,f)};D.minus=D.sub=function(n){var e,t,r,o,i,a,s,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,s=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 V?P(n,s,l):n}if(t=Ue(n.e/L),c=Ue(h.e/L),u=u.slice(),i=c-t,i){for(d=i<0,d?(e=u,i=-i,a=f.length):(e=f,t=c,a=u.length),r=Math.max(Math.ceil(s/L),a)+2,i>r&&(i=r,e.length=1),e.reverse(),r=i;r--;)e.push(0);e.reverse()}else{for(r=u.length,a=f.length,d=r<a,d&&(a=r),r=0;r<a;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}i=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),a=u.length,r=f.length-a;r>0;--r)u[a++]=0;for(r=f.length;r>i;){if(u[--r]<f[r]){for(o=r;o&&u[--o]===0;)u[o]=_t-1;--u[o],u[r]+=_t}u[r]-=f[r]}for(;u[--a]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=pa(u,t),V?P(n,s,l):n):new m(l===3?-0:0)};D.modulo=D.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]?P(new r(t),r.precision,r.rounding):(V=!1,r.modulo==9?(e=de(t,n.abs(),0,3,1),e.s*=n.s):e=de(t,n,0,r.modulo,1),e=e.times(n),V=!0,t.minus(e))};D.naturalExponential=D.exp=function(){return Il(this)};D.naturalLogarithm=D.ln=function(){return ir(this)};D.negated=D.neg=function(){var n=new this.constructor(this);return n.s=-n.s,P(n)};D.plus=D.add=function(n){var e,t,r,o,i,a,s,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,s=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),V?P(n,s,l):n;if(i=Ue(d.e/L),r=Ue(n.e/L),u=u.slice(),o=i-r,o){for(o<0?(t=u,o=-o,a=c.length):(t=c,r=i,a=u.length),i=Math.ceil(s/L),a=i>a?i+1:a+1,o>a&&(o=a,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(a=u.length,o=c.length,a-o<0&&(o=a,t=c,c=u,u=t),e=0;o;)e=(u[--o]=u[o]+c[o]+e)/_t|0,u[o]%=_t;for(e&&(u.unshift(e),++r),a=u.length;u[--a]==0;)u.pop();return n.d=u,n.e=pa(u,r),V?P(n,s,l):n};D.precision=D.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(ar+n);return t.d?(e=Td(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};D.round=function(){var n=this,e=n.constructor;return P(new e(n),n.e+1,e.rounding)};D.sine=D.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())+L,r.rounding=1,t=wg(r,Cd(r,t)),r.precision=n,r.rounding=e,P(Vt>2?t.neg():t,n,e,!0)):new r(NaN)};D.squareRoot=D.sqrt=function(){var n,e,t,r,o,i,a=this,s=a.d,l=a.e,u=a.s,c=a.constructor;if(u!==1||!s||!s[0])return new c(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(V=!1,u=Math.sqrt(+a),u==0||u==1/0?(e=Be(s),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=Ue((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(i=r,r=i.plus(de(a,i,t+2,1)).times(.5),Be(i.d).slice(0,t)===(e=Be(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(P(i,l+1,0),i.times(i).eq(a))){r=i;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(P(r,l+1,1),n=!r.times(r).eq(a));break}return V=!0,P(r,l,c.rounding,n)};D.tangent=D.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=de(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,P(Vt==2||Vt==4?t.neg():t,n,e,!0)):new r(NaN)};D.times=D.mul=function(n){var e,t,r,o,i,a,s,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=Ue(c.e/L)+Ue(n.e/L),l=f.length,u=h.length,l<u&&(i=f,f=h,h=i,a=l,l=u,u=a),i=[],a=l+u,r=a;r--;)i.push(0);for(r=u;--r>=0;){for(e=0,o=l+r;o>r;)s=i[o]+h[r]*f[o-r-1]+e,i[o--]=s%_t|0,e=s/_t|0;i[o]=(i[o]+e)%_t|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),n.d=i,n.e=pa(i,t),V?P(n,d.precision,d.rounding):n};D.toBinary=function(n,e){return Ol(this,2,n,e)};D.toDecimalPlaces=D.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(et(n,0,sr),e===void 0?e=r.rounding:et(e,0,8),P(t,n+t.e+1,e))};D.toExponential=function(n,e){var t,r=this,o=r.constructor;return n===void 0?t=It(r,!0):(et(n,0,sr),e===void 0?e=o.rounding:et(e,0,8),r=P(new o(r),n+1,e),t=It(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};D.toFixed=function(n,e){var t,r,o=this,i=o.constructor;return n===void 0?t=It(o):(et(n,0,sr),e===void 0?e=i.rounding:et(e,0,8),r=P(new i(o),n+o.e+1,e),t=It(r,!1,n+r.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};D.toFraction=function(n){var e,t,r,o,i,a,s,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),i=e.e=Td(m)-h.e-1,a=i%L,e.d[0]=Se(10,a<0?L+a:a),n==null)n=i>0?e:u;else{if(s=new p(n),!s.isInt()||s.lt(u))throw Error(ar+s);n=s.gt(e)?i>0?e:u:s}for(V=!1,s=new p(Be(m)),c=p.precision,p.precision=i=m.length*L*2;d=de(s,e,0,1,1),o=t.plus(d.times(r)),o.cmp(n)!=1;)t=r,r=o,o=u,u=l.plus(d.times(o)),l=o,o=e,e=s.minus(d.times(o)),s=o;return o=de(n.minus(t),r,0,1,1),l=l.plus(o.times(u)),t=t.plus(o.times(r)),l.s=u.s=h.s,f=de(u,r,i,1).minus(h).abs().cmp(de(l,t,i,1).minus(h).abs())<1?[u,r]:[l,t],p.precision=c,V=!0,f};D.toHexadecimal=D.toHex=function(n,e){return Ol(this,16,n,e)};D.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:et(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]?(V=!1,t=de(t,n,0,e,1).times(n),V=!0,P(t)):(n.s=t.s,t=n),t};D.toNumber=function(){return+this};D.toOctal=function(n,e){return Ol(this,8,n,e)};D.toPower=D.pow=function(n){var e,t,r,o,i,a,s=this,l=s.constructor,u=+(n=new l(n));if(!s.d||!n.d||!s.d[0]||!n.d[0])return new l(Se(+s,u));if(s=new l(s),s.eq(1))return s;if(r=l.precision,i=l.rounding,n.eq(1))return P(s,r,i);if(e=Ue(n.e/L),e>=n.d.length-1&&(t=u<0?-u:u)<=pg)return o=Ad(l,s,t,r),n.s<0?new l(1).div(o):P(o,r,i);if(a=s.s,a<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(a=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=a,s}return t=Se(+s,u),e=t==0||!isFinite(t)?Ue(u*(Math.log("0."+Be(s.d))/Math.LN10+s.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(V=!1,l.rounding=s.s=1,t=Math.min(12,(e+"").length),o=Il(n.times(ir(s,r+t)),r),o.d&&(o=P(o,r+5,1),Co(o.d,r,i)&&(e=r+10,o=P(Il(n.times(ir(s,e+t)),e),e+5,1),+Be(o.d).slice(r+1,r+15)+1==1e14&&(o=P(o,r+1,0)))),o.s=a,V=!0,l.rounding=i,P(o,r,i))};D.toPrecision=function(n,e){var t,r=this,o=r.constructor;return n===void 0?t=It(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(et(n,1,sr),e===void 0?e=o.rounding:et(e,0,8),r=P(new o(r),n,e),t=It(r,n<=r.e||r.e<=o.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};D.toSignificantDigits=D.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(et(n,1,sr),e===void 0?e=r.rounding:et(e,0,8)),P(new r(t),n,e)};D.toString=function(){var n=this,e=n.constructor,t=It(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};D.truncated=D.trunc=function(){return P(new this.constructor(this),this.e+1,1)};D.valueOf=D.toJSON=function(){var n=this,e=n.constructor,t=It(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function Be(n){var e,t,r,o=n.length-1,i="",a=n[0];if(o>0){for(i+=a,e=1;e<o;e++)r=n[e]+"",t=L-r.length,t&&(i+=or(t)),i+=r;a=n[e],r=a+"",t=L-r.length,t&&(i+=or(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function et(n,e,t){if(n!==~~n||n<e||n>t)throw Error(ar+n)}function Co(n,e,t,r){var o,i,a,s;for(i=n[0];i>=10;i/=10)--e;return--e<0?(e+=L,o=0):(o=Math.ceil((e+1)/L),e%=L),i=Se(10,L-e),s=n[o]%i|0,r==null?e<3?(e==0?s=s/100|0:e==1&&(s=s/10|0),a=t<4&&s==99999||t>3&&s==49999||s==5e4||s==0):a=(t<4&&s+1==i||t>3&&s+1==i/2)&&(n[o+1]/i/100|0)==Se(10,e-2)-1||(s==i/2||s==0)&&(n[o+1]/i/100|0)==0:e<4?(e==0?s=s/1e3|0:e==1?s=s/100|0:e==2&&(s=s/10|0),a=(r||t<4)&&s==9999||!r&&t>3&&s==4999):a=((r||t<4)&&s+1==i||!r&&t>3&&s+1==i/2)&&(n[o+1]/i/1e3|0)==Se(10,e-3)-1,a}function la(n,e,t){for(var r,o=[0],i,a=0,s=n.length;a<s;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=Sl.indexOf(n.charAt(a++)),r=0;r<o.length;r++)o[r]>t-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}function gg(n,e){var t,r,o;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),o=(1/ma(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),n.precision+=t,e=Sn(n,1,e.times(o),new n(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return n.precision-=t,e}var de=(function(){function n(r,o,i){var a,s=0,l=r.length;for(r=r.slice();l--;)a=r[l]*o+s,r[l]=a%i|0,s=a/i|0;return s&&r.unshift(s),r}function e(r,o,i,a){var s,l;if(i!=a)l=i>a?1:-1;else for(s=l=0;s<i;s++)if(r[s]!=o[s]){l=r[s]>o[s]?1:-1;break}return l}function t(r,o,i,a){for(var s=0;i--;)r[i]-=s,s=r[i]<o[i]?1:0,r[i]=s*a+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,a,s,l){var u,c,d,f,h,m,p,w,b,_,y,E,N,k,C,O,$,Z,W,ie,he=r.constructor,te=r.s==o.s?1:-1,se=r.d,z=o.d;if(!se||!se[0]||!z||!z[0])return new he(!r.s||!o.s||(se?z&&se[0]==z[0]:!z)?NaN:se&&se[0]==0||!z?te*0:te/0);for(l?(h=1,c=r.e-o.e):(l=_t,h=L,c=Ue(r.e/h)-Ue(o.e/h)),W=z.length,$=se.length,b=new he(te),_=b.d=[],d=0;z[d]==(se[d]||0);d++);if(z[d]>(se[d]||0)&&c--,i==null?(k=i=he.precision,a=he.rounding):s?k=i+(r.e-o.e)+1:k=i,k<0)_.push(1),m=!0;else{if(k=k/h+2|0,d=0,W==1){for(f=0,z=z[0],k++;(d<$||f)&&k--;d++)C=f*l+(se[d]||0),_[d]=C/z|0,f=C%z|0;m=f||d<$}else{for(f=l/(z[0]+1)|0,f>1&&(z=n(z,f,l),se=n(se,f,l),W=z.length,$=se.length),O=W,y=se.slice(0,W),E=y.length;E<W;)y[E++]=0;ie=z.slice(),ie.unshift(0),Z=z[0],z[1]>=l/2&&++Z;do f=0,u=e(z,y,W,E),u<0?(N=y[0],W!=E&&(N=N*l+(y[1]||0)),f=N/Z|0,f>1?(f>=l&&(f=l-1),p=n(z,f,l),w=p.length,E=y.length,u=e(p,y,w,E),u==1&&(f--,t(p,W<w?ie:z,w,l))):(f==0&&(u=f=1),p=z.slice()),w=p.length,w<E&&p.unshift(0),t(y,p,E,l),u==-1&&(E=y.length,u=e(z,y,W,E),u<1&&(f++,t(y,W<E?ie:z,E,l))),E=y.length):u===0&&(f++,y=[0]),_[d++]=f,u&&y[0]?y[E++]=se[O]||0:(y=[se[O]],E=1);while((O++<$||y[0]!==void 0)&&k--);m=y[0]!==void 0}_[0]||_.shift()}if(h==1)b.e=c,yd=m;else{for(d=1,f=_[0];f>=10;f/=10)d++;b.e=d+c*h-1,P(b,s?i+b.e+1:i,a,m)}return b}})();function P(n,e,t,r){var o,i,a,s,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(o=1,s=d[0];s>=10;s/=10)o++;if(i=e-o,i<0)i+=L,a=e,c=d[f=0],l=c/Se(10,o-a-1)%10|0;else if(f=Math.ceil((i+1)/L),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);c=l=0,o=1,i%=L,a=i-L+1}else break e;else{for(c=s=d[f],o=1;s>=10;s/=10)o++;i%=L,a=i-L+o,l=a<0?0:c/Se(10,o-a-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(a<0?c:c%Se(10,o-a-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(i>0?a>0?c/Se(10,o-a):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]=Se(10,(L-e%L)%L),n.e=-e||0):d[0]=n.e=0,n;if(i==0?(d.length=f,s=1,f--):(d.length=f+1,s=Se(10,L-i),d[f]=a>0?(c/Se(10,o-a)%Se(10,a)|0)*s:0),u)for(;;)if(f==0){for(i=1,a=d[0];a>=10;a/=10)i++;for(a=d[0]+=s,s=1;a>=10;a/=10)s++;i!=s&&(n.e++,d[0]==_t&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=_t)break;d[f--]=0,s=1}for(i=d.length;d[--i]===0;)d.pop()}return V&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function It(n,e,t){if(!n.isFinite())return Sd(n);var r,o=n.e,i=Be(n.d),a=i.length;return e?(t&&(r=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+or(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n.e<0?"e":"e+")+n.e):o<0?(i="0."+or(-o-1)+i,t&&(r=t-a)>0&&(i+=or(r))):o>=a?(i+=or(o+1-a),t&&(r=t-o-1)>0&&(i=i+"."+or(r))):((r=o+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),t&&(r=t-a)>0&&(o+1===a&&(i+="."),i+=or(r))),i}function pa(n,e){var t=n[0];for(e*=L;t>=10;t/=10)e++;return e}function fa(n,e,t){if(e>mg)throw V=!0,t&&(n.precision=t),Error(vd);return P(new n(ca),e,1,!0)}function Nt(n,e,t){if(e>Nl)throw Error(vd);return P(new n(da),e,t,!0)}function Td(n){var e=n.length-1,t=e*L+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 or(n){for(var e="";n--;)e+="0";return e}function Ad(n,e,t,r){var o,i=new n(1),a=Math.ceil(r/L+4);for(V=!1;;){if(t%2&&(i=i.times(e),wd(i.d,a)&&(o=!0)),t=Ue(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}e=e.times(e),wd(e.d,a)}return V=!0,i}function bd(n){return n.d[n.d.length-1]&1}function Dd(n,e,t){for(var r,o,i=new n(e[0]),a=0;++a<e.length;){if(o=new n(e[a]),!o.s){i=o;break}r=i.cmp(o),(r===t||r===0&&i.s===t)&&(i=o)}return i}function Il(n,e){var t,r,o,i,a,s,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?(V=!1,l=m):l=e,s=new f(.03125);n.e>-2;)n=n.times(s),d+=5;for(r=Math.log(Se(2,d))/Math.LN10*2+5|0,l+=r,t=i=a=new f(1),f.precision=l;;){if(i=P(i.times(n),l,1),t=t.times(++c),s=a.plus(de(i,t,l,1)),Be(s.d).slice(0,l)===Be(a.d).slice(0,l)){for(o=d;o--;)a=P(a.times(a),l,1);if(e==null)if(u<3&&Co(a.d,l-r,h,u))f.precision=l+=10,t=i=s=new f(1),c=0,u++;else return P(a,f.precision=m,h,V=!0);else return f.precision=m,a}a=s}}function ir(n,e){var t,r,o,i,a,s,l,u,c,d,f,h=1,m=10,p=n,w=p.d,b=p.constructor,_=b.rounding,y=b.precision;if(p.s<0||!w||!w[0]||!p.e&&w[0]==1&&w.length==1)return new b(w&&!w[0]?-1/0:p.s!=1?NaN:w?0:p);if(e==null?(V=!1,c=y):c=e,b.precision=c+=m,t=Be(w),r=t.charAt(0),Math.abs(i=p.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)p=p.times(n),t=Be(p.d),r=t.charAt(0),h++;i=p.e,r>1?(p=new b("0."+t),i++):p=new b(r+"."+t.slice(1))}else return u=fa(b,c+2,y).times(i+""),p=ir(new b(r+"."+t.slice(1)),c-m).plus(u),b.precision=y,e==null?P(p,y,_,V=!0):p;for(d=p,l=a=p=de(p.minus(1),p.plus(1),c,1),f=P(p.times(p),c,1),o=3;;){if(a=P(a.times(f),c,1),u=l.plus(de(a,new b(o),c,1)),Be(u.d).slice(0,c)===Be(l.d).slice(0,c))if(l=l.times(2),i!==0&&(l=l.plus(fa(b,c+2,y).times(i+""))),l=de(l,new b(h),c,1),e==null)if(Co(l.d,c-m,_,s))b.precision=c+=m,u=a=p=de(d.minus(1),d.plus(1),c,1),f=P(p.times(p),c,1),o=s=1;else return P(l,b.precision=y,_,V=!0);else return b.precision=y,l;l=u,o+=2}}function Sd(n){return String(n.s*n.s/0)}function ua(n,e){var t,r,o;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(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(r,o),e){if(o-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%L,t<0&&(r+=L),r<o){for(r&&n.d.push(+e.slice(0,r)),o-=L;r<o;)n.d.push(+e.slice(r,r+=L));e=e.slice(r),r=L-e.length}else r-=o;for(;r--;)e+="0";n.d.push(+e),V&&(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 bg(n,e){var t,r,o,i,a,s,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),kd.test(e))return ua(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(fg.test(e))t=16,e=e.toLowerCase();else if(dg.test(e))t=2;else if(hg.test(e))t=8;else throw Error(ar+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,r=n.constructor,a&&(e=e.replace(".",""),s=e.length,i=s-i,o=Ad(r,new r(t),i,i*2)),u=la(e,t,_t),c=u.length-1,i=c;u[i]===0;--i)u.pop();return i<0?new r(n.s*0):(n.e=pa(u,c),n.d=u,V=!1,a&&(n=de(n,o,s*4)),l&&(n=n.times(Math.abs(l)<54?Se(2,l):No.pow(2,l))),V=!0,n)}function wg(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:Sn(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/ma(5,t)),e=Sn(n,2,e,e);for(var o,i=new n(5),a=new n(16),s=new n(20);t--;)o=e.times(e),e=e.times(i.plus(o.times(a.times(o).minus(s))));return e}function Sn(n,e,t,r,o){var i,a,s,l,u=1,c=n.precision,d=Math.ceil(c/L);for(V=!1,l=t.times(t),s=new n(r);;){if(a=de(s.times(l),new n(e++*e++),c,1),s=o?r.plus(a):r.minus(a),r=de(a.times(l),new n(e++*e++),c,1),a=s.plus(r),a.d[d]!==void 0){for(i=d;a.d[i]===s.d[i]&&i--;);if(i==-1)break}i=s,s=r,r=a,a=i,u++}return V=!0,a.d.length=d+1,a}function ma(n,e){for(var t=n;--e;)t*=n;return t}function Cd(n,e){var t,r=e.s<0,o=Nt(n,n.precision,1),i=o.times(.5);if(e=e.abs(),e.lte(i))return Vt=r?4:1,e;if(t=e.divToInt(o),t.isZero())Vt=r?3:2;else{if(e=e.minus(t.times(o)),e.lte(i))return Vt=bd(t)?r?2:3:r?4:1,e;Vt=bd(t)?r?1:4:r?3:2}return e.minus(o).abs()}function Ol(n,e,t,r){var o,i,a,s,l,u,c,d,f,h=n.constructor,m=t!==void 0;if(m?(et(t,1,sr),r===void 0?r=h.rounding:et(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Sd(n);else{for(c=It(n),a=c.indexOf("."),m?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,a>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-a,f.d=la(It(f),10,o),f.e=f.d.length),d=la(c,10,o),i=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=m?"0p+0":"0";else{if(a<0?i--:(n=new h(n),n.d=d,n.e=i,n=de(n,f,t,r,0,o),d=n.d,i=n.e,u=yd),a=d[t],s=o/2,u=u||d[t+1]!==void 0,u=r<4?(a!==void 0||u)&&(r===0||r===(n.s<0?3:2)):a>s||a===s&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>o-1;)d[t]=0,t||(++i,d.unshift(1));for(l=d.length;!d[l-1];--l);for(a=0,c="";a<l;a++)c+=Sl.charAt(d[a]);if(m){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)c+="0";for(d=la(c,o,e),l=d.length;!d[l-1];--l);for(a=1,c="1.";a<l;a++)c+=Sl.charAt(d[a])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>l)for(i-=l;i--;)c+="0";else i<l&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function wd(n,e){if(n.length>e)return n.length=e,!0}function _g(n){return new this(n).abs()}function yg(n){return new this(n).acos()}function vg(n){return new this(n).acosh()}function Eg(n,e){return new this(n).plus(e)}function xg(n){return new this(n).asin()}function kg(n){return new this(n).asinh()}function Tg(n){return new this(n).atan()}function Ag(n){return new this(n).atanh()}function Dg(n,e){n=new this(n),e=new this(e);var t,r=this.precision,o=this.rounding,i=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=Nt(this,i,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?Nt(this,r,o):new this(0),t.s=n.s):!n.d||e.isZero()?(t=Nt(this,i,1).times(.5),t.s=n.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(de(n,e,i,1)),e=Nt(this,i,1),this.precision=r,this.rounding=o,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(de(n,e,i,1)),t}function Sg(n){return new this(n).cbrt()}function Cg(n){return P(n=new this(n),n.e+1,2)}function Ng(n,e,t){return new this(n).clamp(e,t)}function Ig(n){if(!n||typeof n!="object")throw Error(ha+"Object expected");var e,t,r,o=n.defaults===!0,i=["precision",1,sr,"rounding",0,8,"toExpNeg",-Dn,0,"toExpPos",0,Dn,"maxE",0,Dn,"minE",-Dn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],o&&(this[t]=Cl[t]),(r=n[t])!==void 0)if(Ue(r)===r&&r>=i[e+1]&&r<=i[e+2])this[t]=r;else throw Error(ar+t+": "+r);if(t="crypto",o&&(this[t]=Cl[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(Ed);else this[t]=!1;else throw Error(ar+t+": "+r);return this}function Og(n){return new this(n).cos()}function Rg(n){return new this(n).cosh()}function Nd(n){var e,t,r;function o(i){var a,s,l,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,_d(i)){u.s=i.s,V?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(a=0,s=i;s>=10;s/=10)a++;V?a>o.maxE?(u.e=NaN,u.d=null):a<o.minE?(u.e=0,u.d=[0]):(u.e=a,u.d=[i]):(u.e=a,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return ua(u,i.toString())}if(l==="string")return(s=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(s===43&&(i=i.slice(1)),u.s=1),kd.test(i)?ua(u,i):bg(u,i);if(l==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,ua(u,i.toString());throw Error(ar+i)}if(o.prototype=D,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Ig,o.clone=Nd,o.isDecimal=_d,o.abs=_g,o.acos=yg,o.acosh=vg,o.add=Eg,o.asin=xg,o.asinh=kg,o.atan=Tg,o.atanh=Ag,o.atan2=Dg,o.cbrt=Sg,o.ceil=Cg,o.clamp=Ng,o.cos=Og,o.cosh=Rg,o.div=Bg,o.exp=$g,o.floor=Mg,o.hypot=Pg,o.ln=Lg,o.log=Fg,o.log10=qg,o.log2=jg,o.max=Ug,o.min=Vg,o.mod=zg,o.mul=Hg,o.pow=Gg,o.random=Wg,o.round=Yg,o.sign=Xg,o.sin=Zg,o.sinh=Kg,o.sqrt=Jg,o.sub=Qg,o.sum=eb,o.tan=tb,o.tanh=rb,o.trunc=nb,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 o.config(n),o}function Bg(n,e){return new this(n).div(e)}function $g(n){return new this(n).exp()}function Mg(n){return P(n=new this(n),n.e+1,3)}function Pg(){var n,e,t=new this(0);for(V=!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 V=!0,new this(1/0);t=e}return V=!0,t.sqrt()}function _d(n){return n instanceof No||n&&n.toStringTag===xd||!1}function Lg(n){return new this(n).ln()}function Fg(n,e){return new this(n).log(e)}function jg(n){return new this(n).log(2)}function qg(n){return new this(n).log(10)}function Ug(){return Dd(this,arguments,-1)}function Vg(){return Dd(this,arguments,1)}function zg(n,e){return new this(n).mod(e)}function Hg(n,e){return new this(n).mul(e)}function Gg(n,e){return new this(n).pow(e)}function Wg(n){var e,t,r,o,i=0,a=new this(1),s=[];if(n===void 0?n=this.precision:et(n,1,sr),r=Math.ceil(n/L),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));i<r;)o=e[i],o>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:s[i++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);i<r;)o=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,i):(s.push(o%1e7),i+=4);i=r/4}else throw Error(Ed);else for(;i<r;)s[i++]=Math.random()*1e7|0;for(r=s[--i],n%=L,r&&n&&(o=Se(10,L-n),s[i]=(r/o|0)*o);s[i]===0;i--)s.pop();if(i<0)t=0,s=[0];else{for(t=-1;s[0]===0;t-=L)s.shift();for(r=1,o=s[0];o>=10;o/=10)r++;r<L&&(t-=L-r)}return a.e=t,a.d=s,a}function Yg(n){return P(n=new this(n),n.e+1,this.rounding)}function Xg(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function Zg(n){return new this(n).sin()}function Kg(n){return new this(n).sinh()}function Jg(n){return new this(n).sqrt()}function Qg(n,e){return new this(n).sub(e)}function eb(){var n=0,e=arguments,t=new this(e[n]);for(V=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return V=!0,P(t,this.precision,this.rounding)}function tb(n){return new this(n).tan()}function rb(n){return new this(n).tanh()}function nb(n){return P(n=new this(n),n.e+1,1)}D[Symbol.for("nodejs.util.inspect.custom")]=D.toString;D[Symbol.toStringTag]="Decimal";var No=D.constructor=Nd(Cl);ca=new No(ca);da=new No(da);var Id=No;var ob=20,ib=1,Lr=1e6,Od=1e6,ab=-7,sb=21,lb=!1,Io="[big.js] ",Fr=Io+"Invalid ",ga=Fr+"decimal places",ub=Fr+"rounding mode",Rd=Io+"Division by zero",le={},Ot=void 0,cb=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Bd(){function n(e){var t=this;if(!(t instanceof n))return e===Ot?Bd():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(Fr+"value");e=e===0&&1/e<0?"-0":String(e)}db(t,e)}t.constructor=n}return n.prototype=le,n.DP=ob,n.RM=ib,n.NE=ab,n.PE=sb,n.strict=lb,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function db(n,e){var t,r,o;if(!cb.test(e))throw Error(Fr+"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),o=e.length,r=0;r<o&&e.charAt(r)=="0";)++r;if(r==o)n.c=[n.e=0];else{for(;o>0&&e.charAt(--o)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=o;)n.c[t++]=+e.charAt(r++)}return n}function jr(n,e,t,r){var o=n.c;if(t===Ot&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(ub);if(e<1)r=t===3&&(r||!!o[0])||e===0&&(t===1&&o[0]>=5||t===2&&(o[0]>5||o[0]===5&&(r||o[1]!==Ot))),o.length=1,r?(n.e=n.e-e+1,o[0]=1):o[0]=n.e=0;else if(e<o.length){if(r=t===1&&o[e]>=5||t===2&&(o[e]>5||o[e]===5&&(r||o[e+1]!==Ot||o[e-1]&1))||t===3&&(r||!!o[0]),o.length=e,r){for(;++o[--e]>9;)if(o[e]=0,e===0){++n.e,o.unshift(1);break}}for(e=o.length;!o[--e];)o.pop()}return n}function qr(n,e,t){var r=n.e,o=n.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)o="0"+o;o="0."+o}else if(r>0)if(++r>i)for(r-=i;r--;)o+="0";else r<i&&(o=o.slice(0,r)+"."+o.slice(r));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return n.s<0&&t?"-"+o:o}le.abs=function(){var n=new this.constructor(this);return n.s=1,n};le.cmp=function(n){var e,t=this,r=t.c,o=(n=new t.constructor(n)).c,i=t.s,a=n.s,s=t.e,l=n.e;if(!r[0]||!o[0])return r[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,s!=l)return s>l^e?1:-1;for(a=(s=r.length)<(l=o.length)?s:l,i=-1;++i<a;)if(r[i]!=o[i])return r[i]>o[i]^e?1:-1;return s==l?0:s>l^e?1:-1};le.div=function(n){var e=this,t=e.constructor,r=e.c,o=(n=new t(n)).c,i=e.s==n.s?1:-1,a=t.DP;if(a!==~~a||a<0||a>Lr)throw Error(ga);if(!o[0])throw Error(Rd);if(!r[0])return n.s=i,n.c=[n.e=0],n;var s,l,u,c,d,f=o.slice(),h=s=o.length,m=r.length,p=r.slice(0,s),w=p.length,b=n,_=b.c=[],y=0,E=a+(b.e=e.e-n.e)+1;for(b.s=i,i=E<0?0:E,f.unshift(0);w++<s;)p.push(0);do{for(u=0;u<10;u++){if(s!=(w=p.length))c=s>w?1:-1;else for(d=-1,c=0;++d<s;)if(o[d]!=p[d]){c=o[d]>p[d]?1:-1;break}if(c<0){for(l=w==s?o:f;w;){if(p[--w]<l[w]){for(d=w;d&&!p[--d];)p[d]=9;--p[d],p[w]+=10}p[w]-=l[w]}for(;!p[0];)p.shift()}else break}_[y++]=c?u:++u,p[0]&&c?p[w]=r[h]||0:p=[r[h]]}while((h++<m||p[0]!==Ot)&&i--);return!_[0]&&y!=1&&(_.shift(),b.e--,E--),y>E&&jr(b,E,t.RM,p[0]!==Ot),b};le.eq=function(n){return this.cmp(n)===0};le.gt=function(n){return this.cmp(n)>0};le.gte=function(n){return this.cmp(n)>-1};le.lt=function(n){return this.cmp(n)<0};le.lte=function(n){return this.cmp(n)<1};le.minus=le.sub=function(n){var e,t,r,o,i=this,a=i.constructor,s=i.s,l=(n=new a(n)).s;if(s!=l)return n.s=-l,i.plus(n);var u=i.c.slice(),c=i.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new a(i):n.s=1,n;if(s=c-f){for((o=s<0)?(s=-s,r=u):(f=c,r=d),r.reverse(),l=s;l--;)r.push(0);r.reverse()}else for(t=((o=u.length<d.length)?u:d).length,s=l=0;l<t;l++)if(u[l]!=d[l]){o=u[l]<d[l];break}if(o&&(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>s;){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};le.mod=function(n){var e,t=this,r=t.constructor,o=t.s,i=(n=new r(n)).s;if(!n.c[0])throw Error(Rd);return t.s=n.s=1,e=n.cmp(t)==1,t.s=o,n.s=i,e?new r(t):(o=r.DP,i=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=o,r.RM=i,this.minus(t.times(n)))};le.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};le.plus=le.add=function(n){var e,t,r,o=this,i=o.constructor;if(n=new i(n),o.s!=n.s)return n.s=-n.s,o.minus(n);var a=o.e,s=o.c,l=n.e,u=n.c;if(!s[0]||!u[0])return u[0]||(s[0]?n=new i(o):n.s=o.s),n;if(s=s.slice(),e=a-l){for(e>0?(l=a,r=u):(e=-e,r=s),r.reverse();e--;)r.push(0);r.reverse()}for(s.length-u.length<0&&(r=u,u=s,s=r),e=u.length,t=0;e;s[e]%=10)t=(s[--e]=s[e]+u[e]+t)/10|0;for(t&&(s.unshift(t),++l),e=s.length;s[--e]===0;)s.pop();return n.c=s,n.e=l,n};le.pow=function(n){var e=this,t=new e.constructor("1"),r=t,o=n<0;if(n!==~~n||n<-Od||n>Od)throw Error(Fr+"exponent");for(o&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return o?t.div(r):r};le.prec=function(n,e){if(n!==~~n||n<1||n>Lr)throw Error(Fr+"precision");return jr(new this.constructor(this),n,e)};le.round=function(n,e){if(n===Ot)n=0;else if(n!==~~n||n<-Lr||n>Lr)throw Error(ga);return jr(new this.constructor(this),n+this.e+1,e)};le.sqrt=function(){var n,e,t,r=this,o=r.constructor,i=r.s,a=r.e,s=new o("0.5");if(!r.c[0])return new o(r);if(i<0)throw Error(Io+"No square root");i=Math.sqrt(+qr(r,!0,!0)),i===0||i===1/0?(e=r.c.join(""),e.length+a&1||(e+="0"),i=Math.sqrt(e),a=((a+1)/2|0)-(a<0||a&1),n=new o((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):n=new o(i+""),a=n.e+(o.DP+=4);do t=n,n=s.times(t.plus(r.div(t)));while(t.c.slice(0,a).join("")!==n.c.slice(0,a).join(""));return jr(n,(o.DP-=4)+n.e+1,o.RM)};le.times=le.mul=function(n){var e,t=this,r=t.constructor,o=t.c,i=(n=new r(n)).c,a=o.length,s=i.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!o[0]||!i[0])return n.c=[n.e=0],n;for(n.e=l+u,a<s&&(e=o,o=i,i=e,u=a,a=s,s=u),e=new Array(u=a+s);u--;)e[u]=0;for(l=s;l--;){for(s=0,u=a+l;u>l;)s=e[u]+i[l]*o[u-l-1]+s,e[u--]=s%10,s=s/10|0;e[u]=s}for(s?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};le.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Ot){if(n!==~~n||n<0||n>Lr)throw Error(ga);for(t=jr(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return qr(t,!0,!!r)};le.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Ot){if(n!==~~n||n<0||n>Lr)throw Error(ga);for(t=jr(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return qr(t,!1,!!r)};le[Symbol.for("nodejs.util.inspect.custom")]=le.toJSON=le.toString=function(){var n=this,e=n.constructor;return qr(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};le.toNumber=function(){var n=+qr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(Io+"Imprecise conversion");return n};le.toPrecision=function(n,e){var t=this,r=t.constructor,o=t.c[0];if(n!==Ot){if(n!==~~n||n<1||n>Lr)throw Error(Fr+"precision");for(t=jr(new r(t),n,e);t.c.length<n;)t.c.push(0)}return qr(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!o)};le.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(Io+"valueOf disallowed");return qr(n,n.e<=e.NE||n.e>=e.PE,!0)};var fb=Bd(),$d=fb;var Vl={};lg(Vl,{DecodeError:()=>Ve,Decoder:()=>vt,EXT_TIMESTAMP:()=>Bl,Encoder:()=>Cn,ExtData:()=>yt,ExtensionCodec:()=>lr,decode:()=>zd,decodeArrayStream:()=>Wd,decodeAsync:()=>Gd,decodeMulti:()=>Hd,decodeMultiStream:()=>Yd,decodeTimestampExtension:()=>Fl,decodeTimestampToTimeSpec:()=>Ll,encode:()=>_a,encodeDateToTimeSpec:()=>Ml,encodeTimeSpecToTimestamp:()=>$l,encodeTimestampExtension:()=>Pl});function Md(n){let e=n.length,t=0,r=0;for(;r<e;){let o=n.charCodeAt(r++);if((o&4294967168)===0){t++;continue}else if((o&4294965248)===0)t+=2;else{if(o>=55296&&o<=56319&&r<e){let i=n.charCodeAt(r);(i&64512)===56320&&(++r,o=((o&1023)<<10)+(i&1023)+65536)}(o&4294901760)===0?t+=3:t+=4}}return t}function hb(n,e,t){let r=n.length,o=t,i=0;for(;i<r;){let a=n.charCodeAt(i++);if((a&4294967168)===0){e[o++]=a;continue}else if((a&4294965248)===0)e[o++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&i<r){let s=n.charCodeAt(i);(s&64512)===56320&&(++i,a=((a&1023)<<10)+(s&1023)+65536)}(a&4294901760)===0?(e[o++]=a>>12&15|224,e[o++]=a>>6&63|128):(e[o++]=a>>18&7|240,e[o++]=a>>12&63|128,e[o++]=a>>6&63|128)}e[o++]=a&63|128}}var pb=new TextEncoder,mb=50;function gb(n,e,t){pb.encodeInto(n,e.subarray(t))}function Pd(n,e,t){n.length>mb?gb(n,e,t):hb(n,e,t)}var bb=4096;function Rl(n,e,t){let r=e,o=r+t,i=[],a="";for(;r<o;){let s=n[r++];if((s&128)===0)i.push(s);else if((s&224)===192){let l=n[r++]&63;i.push((s&31)<<6|l)}else if((s&240)===224){let l=n[r++]&63,u=n[r++]&63;i.push((s&31)<<12|l<<6|u)}else if((s&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(s&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(s);i.length>=bb&&(a+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(a+=String.fromCharCode(...i)),a}var wb=new TextDecoder,_b=200;function yb(n,e,t){let r=n.subarray(e,e+t);return wb.decode(r)}function Ld(n,e,t){return t>_b?yb(n,e,t):Rl(n,e,t)}var yt=class{type;data;constructor(e,t){this.type=e,this.data=t}};var Ve=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 Fd(n,e,t){let r=t/4294967296,o=t;n.setUint32(e,r),n.setUint32(e+4,o)}function ba(n,e,t){let r=Math.floor(t/4294967296),o=t;n.setUint32(e,r),n.setUint32(e+4,o)}function wa(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function jd(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var Bl=-1,vb=4294967296-1,Eb=17179869184-1;function $l({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=Eb)if(e===0&&n<=vb){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,o=new Uint8Array(8),i=new DataView(o.buffer);return i.setUint32(0,e<<2|t&3),i.setUint32(4,r),o}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),ba(r,4,n),t}}function Ml(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,o=Math.floor(r/1e9);return{sec:t+o,nsec:r-o*1e9}}function Pl(n){if(n instanceof Date){let e=Ml(n);return $l(e)}else return null}function Ll(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),o=(t&3)*4294967296+r,i=t>>>2;return{sec:o,nsec:i}}case 12:{let t=wa(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Ve(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function Fl(n){let e=Ll(n);return new Date(e.sec*1e3+e.nsec/1e6)}var qd={type:Bl,encode:Pl,decode:Fl};var lr=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(qd)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let o=-1-e;this.builtInEncoders[o]=t,this.builtInDecoders[o]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let o=this.builtInEncoders[r];if(o!=null){let i=o(e,t);if(i!=null){let a=-1-r;return new yt(a,i)}}}for(let r=0;r<this.encoders.length;r++){let o=this.encoders[r];if(o!=null){let i=o(e,t);if(i!=null){let a=r;return new yt(a,i)}}}return e instanceof yt?e:null}decode(e,t,r){let o=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return o?o(e,t,r):new yt(t,e)}};function xb(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function Oo(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):xb(n)?new Uint8Array(n):Uint8Array.from(n)}var kb=100,Tb=2048,Cn=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??lr.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??kb,this.initialBufferSize=e?.initialBufferSize??Tb,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),o=new DataView(t);r.set(this.bytes),this.view=o,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=Md(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),Pd(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=Oo(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 o of e)this.doEncode(o,t+1)}countWithoutUndefined(e,t){let r=0;for(let o of t)e[o]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let o=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error(`Too large map object: ${o}`);for(let i of r){let a=e[i];this.ignoreUndefined&&a===void 0||(this.encodeString(i),this.doEncode(a,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),o=r.length;if(o>=4294967296)throw new Error(`Too large extension object: ${o}`);this.writeU8(201),this.writeU32(o),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),Fd(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ba(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 _a(n,e){return new Cn(e).encodeSharedRef(n)}function ya(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var Ab=16,Db=16,va=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ab,t=Db){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 o=this.caches[r-1];e:for(let i of o){let a=i.bytes;for(let s=0;s<r;s++)if(a[s]!==e[t+s])continue e;return i.str}return null}store(e,t){let r=this.caches[e.length-1],o={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=o:r.push(o)}decode(e,t,r){let o=this.find(e,t,r);if(o!=null)return this.hit++,o;this.miss++;let i=Rl(e,t,r),a=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(a,i),i}};var jl="array",$o="map_key",Vd="map_value",Sb=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new Ve("The type of key must be string or number but "+typeof n)},ql=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=jl,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=$o,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===jl){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===$o||e.type===Vd){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}},Bo=-1,Ul=new DataView(new ArrayBuffer(0)),Cb=new Uint8Array(Ul.buffer);try{Ul.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 Ud=new RangeError("Insufficient data"),Nb=new va,vt=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Ul;bytes=Cb;headByte=Bo;stack=new ql;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??lr.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:Nb,this.mapKeyConverter=e?.mapKeyConverter??Sb}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=Bo,this.stack.reset()}setBuffer(e){let t=Oo(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Bo&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=Oo(e),o=new Uint8Array(t.length+r.length);o.set(t),o.set(r,t.length),this.setBuffer(o)}}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 s of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);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:o,pos:i,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${ya(o)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let r=t,o=-1;for await(let i of e){if(t&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),r&&(o=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--o!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let o=e-128;if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e<160){let o=e-144;if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else{let o=e-160;t=this.decodeString(o,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 o=this.lookU8();t=this.decodeString(o,1)}else if(e===218){let o=this.lookU16();t=this.decodeString(o,2)}else if(e===219){let o=this.lookU32();t=this.decodeString(o,4)}else if(e===220){let o=this.readU16();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===221){let o=this.readU32();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===222){let o=this.readU16();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===223){let o=this.readU32();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===196){let o=this.lookU8();t=this.decodeBinary(o,1)}else if(e===197){let o=this.lookU16();t=this.decodeBinary(o,2)}else if(e===198){let o=this.lookU32();t=this.decodeBinary(o,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 o=this.lookU8();t=this.decodeExtension(o,1)}else if(e===200){let o=this.lookU16();t=this.decodeExtension(o,2)}else if(e===201){let o=this.lookU32();t=this.decodeExtension(o,4)}else throw new Ve(`Unrecognized type byte: ${ya(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let o=r.top();if(o.type===jl)if(o.array[o.position]=t,o.position++,o.position===o.size)t=o.array,r.release(o);else continue e;else if(o.type===$o){if(t==="__proto__")throw new Ve("The key __proto__ is not allowed");o.key=this.mapKeyConverter(t),o.type=Vd;continue e}else if(o.map[o.key]=t,o.readCount++,o.readCount===o.size)t=o.map,r.release(o);else{o.key=null,o.type=$o;continue e}}return t}}readHeadByte(){return this.headByte===Bo&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Bo}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 Ve(`Unrecognized array type byte: ${ya(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Ve(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Ve(`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 Ve(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ud;let r=this.pos+t,o;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?o=this.keyDecoder.decode(this.bytes,r,e):o=Ld(this.bytes,r,e),this.pos+=t+e,o}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===$o:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Ve(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ud;let r=this.pos+t,o=this.bytes.subarray(r,r+e);return this.pos+=t+e,o}decodeExtension(e,t){if(e>this.maxExtLength)throw new Ve(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),o=this.decodeBinary(e,t+1);return this.extensionCodec.decode(o,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=jd(this.view,this.pos);return this.pos+=8,e}readI64(){let e=wa(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 zd(n,e){return new vt(e).decode(n)}function Hd(n,e){return new vt(e).decodeMulti(n)}function Ib(n){return n[Symbol.asyncIterator]!=null}async function*Ob(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function Ea(n){return Ib(n)?n:Ob(n)}async function Gd(n,e){let t=Ea(n);return new vt(e).decodeAsync(t)}function Wd(n,e){let t=Ea(n);return new vt(e).decodeArrayStream(t)}function Yd(n,e){let t=Ea(n);return new vt(e).decodeStream(t)}var qa=pd(du(),1),fu=Id,hu=$d,Mt=Vl,eh=qa.DOMParser,th=qa.XMLSerializer;var rh=Mt!==null;function nh(){if(!rh)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var oh=I_();function I_(){if(!rh)return null;let n=new TextEncoder,e=new TextDecoder,t=new Mt.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let o=mr(r);if(o==="D"||o==="H")return null}return Mt.encodeTimestampExtension(r)},decode:r=>Mt.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>fe(r)?n.encode(r.toString()):null,decode:r=>Pt(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&mr(r)==="D"){let o=r.getUTCFullYear(),i=String(r.getUTCMonth()+1).padStart(2,"0"),a=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${o}-${i}-${a}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&mr(r)==="H"){let o=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),a=String(r.getUTCSeconds()).padStart(2,"0"),s=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${o}:${i}:${a}.${s}`)}return null},decode:r=>{let o=e.decode(r),i=o.indexOf("."),a=i>=0?o.substring(0,i):o,s=i>=0?o.substring(i+1):"0",[l,u,c]=a.split(":"),d=Math.round(+s.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:r=>{let o=pu(r);if(o!==null){let[i,a]=o;return n.encode(`${i}:${a(r)}`)}return null},decode:r=>{let o=e.decode(r),i=o.indexOf(":"),a=o.slice(0,i),s=o.slice(i+1),l=gr[a];if(l!==void 0){let[,u]=l;return u(s)}return`${s}::${a}`}}),t}function ih(n){return nh(),Mt.encode(n,{extensionCodec:oh})}function ah(n){return nh(),Mt.decode(n,{extensionCodec:oh})}function Ua(n,e=!1){let t=Va(n);if(t===null)return[!1,String(n)];let[r,o,i]=t;return i&&!e?[!1,String(n)]:[!0,`${o(n)}::${r}`]}function mu(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),o=gr[r];if(o===void 0)return[!1,n];let[,i]=o;return[!0,i(t)]}function Yn(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[o,i]of Object.entries(n))r[o]=Yn(i,e,t);return r}return Array.isArray(n)?n.map(r=>Yn(r,e,t)):t(n)?e(n):n}function gu(n){let e=Va(n);if(e!==null){let[t,r,o]=e;return o?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(o=>{let[i,a]=gu(o);return a&&(t=!0),i}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[o,i]of Object.entries(n)){let[a,s]=gu(i);s&&(t=!0),r[o]=a}return[r,t]}return[n,!1]}function O_(n,e=!1){let[t,r]=Ua(n,e);if(t)return r;let[o,i]=gu(n),a=JSON.stringify(o);return i?`${a}::JS`:a}function R_(n){return JSON.stringify(n)}function B_(n){if(!Mt)throw new Error("@msgpack/msgpack is required for MessagePack support");return Mt.encode(n)}function F(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:o=!1}={}){if(r)return`${lh(n)}::QS`;if(t){if(e===null||e==="json")return R_(n);if(e==="msgpack")return B_(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 i=O_(n,o);return e==="json"?`"${i}"`:i}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${sh(n)}</tytx_root>`;if(e==="msgpack")return ih(n);throw new Error(`Unknown transport: ${e}`)}}var Xn,bu;typeof window<"u"&&window.DOMParser?(Xn=window.DOMParser,bu=window.XMLSerializer):(Xn=eh,bu=th);function uh(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 ch(n,e,t){let r=n.createElement(e),o=t.attrs||{},i=t.value;for(let[a,s]of Object.entries(o))r.setAttribute(a,F(s,null,{_forceSuffix:!0}));if(Array.isArray(i))for(let a of i)if(uh(a)){let[s]=Object.keys(a),l=a[s],u=ch(n,s,l);r.appendChild(u)}else{r.textContent=F(i);break}else r.textContent=F(i);return r}function sh(n){if(!Xn)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(uh(n)){let[e]=Object.keys(n),t=n[e],r=new Xn().parseFromString("<root/>","text/xml"),o=ch(r,e,t);return new bu().serializeToString(o)}else return F(n)}function wu(n){let e={};for(let r=0;r<n.attributes.length;r++){let o=n.attributes[r];e[o.name]=j(o.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let o=n.childNodes[r];o.nodeType===1&&t.push(o)}if(t.length>0)if(t.length===1){let r=t[0],o=wu(r);return{attrs:e,value:{[r.tagName]:o}}}else{let r=[];for(let o of t){let i=wu(o);r.push({[o.tagName]:i})}return{attrs:e,value:r}}return{attrs:e,value:j(n.textContent)}}function dh(n){if(!Xn)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new Xn().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let i=null;for(let a=0;a<r.childNodes.length;a++)if(r.childNodes[a].nodeType===1){i=r.childNodes[a];break}if(!i)return j(r.textContent);r=i}let o=wu(r);return{[r.tagName]:o}}function _u(n){return typeof n=="string"}function $_(n){let[e,t]=mu(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let o;try{o=JSON.parse(r)}catch{return n}return Yn(o,yu,_u)}function yu(n){return n.includes("::")?mu(n)[1]:n}function M_(n){let e=dh(n);return typeof e=="string"?j(e):e}function P_(n){return ah(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)),$_(t)}else{if(e==="xml")return M_(n);if(e==="msgpack")return P_(n);throw new Error(`Unknown transport: ${e}`)}}function fh(n){return Symbol.asyncIterator in n?(async function*(){for await(let t of n)yield Yn(t,yu,_u)})():(function*(){for(let t of n)yield Yn(t,yu,_u)})()}function lh(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[o,i]=Ua(r,!0);o?e.push(`${t}=${i}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function hh(n){if(!n)return[];let e=n.split("&"),t=e.map(a=>a.includes("=")),r=t.every(Boolean),o=!t.some(Boolean);if(!r&&!o)throw new Error("QS format error: mixed items with and without '='");if(o)return e.map(a=>j(a));let i={};for(let a of e){let s=a.indexOf("="),l=a.slice(0,s),u=a.slice(s+1);i[l]=j(u)}return i}var mh=fu||hu||Number,gh=fu?"decimal.js":hu?"big.js":"number";function Eu(){return gh}function Pt(n){return new mh(n)}function fe(n){return gh==="number"?!1:n instanceof mh}function mr(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 L_(n){return n.toString()}function F_(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 j_(n){return n.toISOString()}function q_(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),o=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${o}`}function U_(n){return n?"true":"false"}function V_(n){return n.toString()}function z_(n){return n.toString()}function H_(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 za=[],vu=new Map;function pu(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,o,i]of za)if(t.prototype===e)return[r,o,i];return null}function Va(n){if(n===null)return["NN",()=>"",!0];if(fe(n))return["N",L_,!1];if(n instanceof Uint8Array)return["RAW",H_,!1];if(n instanceof Date){let e=mr(n);return e==="D"?["D",F_,!1]:e==="H"?["H",q_,!1]:["DHZ",j_,!1]}return typeof n=="boolean"?["B",U_,!0]:typeof n=="number"?Number.isInteger(n)?["L",V_,!0]:["R",z_,!0]:pu(n)}function G_(n){return Pt(n)}function W_(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function ph(n){return new Date(n)}function Y_(n){let[e,t,r]=n.split(":"),[o,i]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(o),Number(i||0)))}function X_(n){return n.toLowerCase()==="true"}function Z_(n){return parseInt(n,10)}function K_(n){return parseFloat(n)}function J_(n){return n}function Q_(n){return null}var ey=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function ty(n){if(!ey.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 ry(n){return hh(n)}var ny=/^[A-Z]+$/,gr={N:[Object,G_],D:[Date,W_],DH:[Date,ph],DHZ:[Date,ph],H:[Date,Y_],L:[Number,Z_],R:[Number,K_],T:[String,J_],B:[Boolean,X_],QS:[Object,ry],NN:[null,Q_],RAW:[Uint8Array,ty]};function ti(n){return Object.hasOwn(gr,n)?gr[n][0]:null}function xu(n,e,t,r,o=!1){if(typeof e!="string"||!ny.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let i=gr[e];if(i!==void 0&&i[0]!==n){let a=i[0]===null?"null":i[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${a}`)}za=za.filter(([a])=>a!==n),za.push([n,e,t,o]),gr[e]=[n,r]}function Gr(n,e){vu.set(n,e)}function ht(n){return vu.has(n)?vu.get(n):{}}function re(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 bh=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Wr(n,e){let t="",r=!1;for(let o=0;o<n.length;){if(n[o]!=="{"&&n[o]!=="}"){t+=n[o++];continue}let i=n.slice(o).match(bh);if(!i)throw new SyntaxError("Invalid pointer template placeholder");let a=i[1]??"",s=a.startsWith("?"),l=e(s?a.slice(1):a);l==null||l===""&&!s?r=!0:t+=String(l),o+=i[0].length}return r?null:t}function ri(n){let e=[],t=new Set,r="",o=!0;for(let i=0;i<n.length;){let a=i,s=n[i];if(s==='"'||s==="'"||s==="`"){for(i++;i<n.length;){if(n[i]==="\\"){i+=2;continue}if(n[i++]===s)break}r+=n.slice(a,i),o=!1;continue}if(n.startsWith("//",i)){i=n.indexOf(`
|
|
31
|
-
`,i),i<0&&(i=n.length),r+=n.slice(a,i);continue}if(n.startsWith("/*",i)){let c=n.indexOf("*/",i+2);i=c<0?n.length:c+2,r+=n.slice(a,i);continue}if(s==="/"&&o){let c=!1;for(i++;i<n.length;){let d=n[i++];if(d==="\\"){i++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[i]??"")&&i<n.length;)i++;r+=n.slice(a,i),o=!1;continue}let l=s==="{"?n.slice(i).match(bh):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),i+=l[0].length,o=!1;continue}let u=n.slice(i).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],i+=u[0].length,o=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=s,i++,/\s/.test(s)||(o=/[([{,:;=!?&|+*%~<>\/-]/.test(s))}return{text:r,slots:e,identifiers:t}}function wh(n,e,t=()=>null){let r=new Map,o=[],i=a=>{if(r.has(a))return r.get(a);if(!n.has(a))throw new Error(`Referenced Source attribute '${a}' does not exist`);if(o.includes(a))throw new Error(`Cyclic attribute dependency: ${[...o,a].join(" -> ")}`);o.push(a);try{let s=n.get(a),l=typeof a=="string"?re(s):null,u=e.get(a);if(l){let c=d=>d?i(d):e.get(a);if(l.expression){let d=ri(l.body);u=t(a,s,d,d.slots.map(c))}else u=Wr(l.body,c),e.get(a)==null&&(u=null)}return r.set(a,u),u}finally{o.pop()}};return new Map([...n.keys()].map(a=>[a,i(a)]))}function Lt(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,o=[],i=a=>{let s=re(a);if(!s)return;let l=[];s.expression?l.push(...ri(s.body).slots):Wr(s.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(o.includes(u))throw new Error(`Cyclic attribute dependency: ${[...o,u].join(" -> ")}`);r.has(u)||(o.push(u),i(t.get(u)),o.pop(),r.add(u))}};return i(e),r}var _h={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 iy(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?_h[e]||null:e}function ay(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function sy(n){return new Promise(e=>setTimeout(e,n))}async function ly(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,o=e.backoff||2,i=e.jitter!==!1,a=e.on||["Error"],s=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(s=c,u<t-1&&ay(c,a)){let d=l;i&&(d*=1+Math.random()*.1),await sy(d),l*=o}else throw c}throw s}var ce=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 i of["interval","reactive"])if(Object.hasOwn(r,i))throw new TypeError(`Removed resolver option: ${i}. 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 o=this.constructor.internalParams;for(let[i,a]of Object.entries(r))o.has(i)||(this._kw[i]=a);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}_buildEffectiveKw(){let e={...this._kw};if(this._node&&this._node.attr)for(let t of Object.keys(this._kw))Object.hasOwn(this._node.attr,t)&&(e[t]=this._node.attr[t]);return e}resolve(e={}){let{static:t=!1,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let o=this._buildEffectiveKw();if(Object.keys(r).length>0)return this._load({...o,...r},a=>this._prepareValue(a));let i=this._computeEffectiveFingerprint(o);return i===this._lastEffectiveFingerprint&&!this.expired?this.cachedValue:(this._lastEffectiveFingerprint=i,this._load(o,a=>this._finalize(a)))}_load(e,t){let r=iy(this),o=()=>this.load(e);if(r)return ly(o,r).then(t);let i=o();return i&&typeof i.then=="function"?i.then(t):t(i)}_finalize(e){return e=this._prepareValue(e),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_prepareValue(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)),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}};ce._BagClass=null;var br=class extends ce{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 Et=class n{constructor(e,t,r=null,o=null,i=null,a=null,s=null,l=!0){this.label=t,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=a,this.xmlTag=s,this._compiled=null,this.parentBag=e,o&&this.setAttr(o,!1,!0,l),r!==null&&this.setValue(r,!1),i&&(this.resolver=i)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,t=null,r={}){if(t!==null){let o=j(`${t}::QS`);if(Array.isArray(o)){let i=o.length?o:Object.keys(this._attr),a=i.map(l=>{let u=this.getAttr(l);return!e&&u instanceof ce?u.resolve():u}),s=l=>o.length===0?Object.fromEntries(i.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return a.some(l=>l&&typeof l.then=="function")?Promise.all(a).then(s):s(a)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");r={...r,...o}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,o=null,i=!0,a=null,s=!1){e instanceof ce?(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,o,i);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,a,s))}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 o=this._value,i={...this._attr},a=this.resolver;a&&a._node===this&&(a._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let s=this._buildAttrDiff(i,this._attr),l=Object.keys(s).length?s:null,u=o!==t||a!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:o,attrs_diff:l}:{oldvalue:o};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,o,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={},o=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of o){let a=i in e?e[i]:null,s=i in t?t[i]:null;a!==s&&(r[i]={old:a,new:s})}return r}setAttr(e=null,t=!0,r=!0,o=!0){let i=e||{},a=Object.keys(this._nodeSubscribers).length>0,l=t&&(a||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?Object.assign(this._attr,i):this._attr={...i},o)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(t&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&a)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let 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 o of t)if(this._attr[o]!==e._attr[o])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(o=>this._attr[o]!==e._attr[o])?`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 ni=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,o]=t,i=o.includes("::")?j(o):o;return r?this._list.findIndex(a=>a.getAttr(r)===i):this._list.findIndex(a=>a._value===i)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let i=this._parseSharpIndex(r.slice(1),e);return Math.min(i,t)}let o=this.index(r);if(o<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return o}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let i=this._parseSharpIndex(r.slice(1),e);return Math.min(i+1,t)}let o=this.index(r);if(o<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return o+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=">",o=null,i=null,a=null,s=!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)o={[p[0]]:t};else{if(!Array.isArray(t)||t.length!==p.length)throw new Error("Wrong attributes assignment");o={};for(let w=0;w<p.length;w++)o[p[w]]=t[w]}t=null}let m=this._dict[e];if(m)f&&(m.nodeTag=f),a!==null&&(a===!1?m.resolver=null:m.resolver=a),h?m.setAttr(o,c,!0,l):m.setValue(t,c,o,s,l,u,d);else{let p=i&&i.nodeClass?i.nodeClass:Et;m=new p(i,e,h?null:t,o,a,f,null,l);let w=this._parsePosition(r);this._dict[e]=m,this._list.splice(w,0,m),c&&i&&i.backref&&i._onNodeInserted(m,w,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 o=Array.isArray(e)?e:[e];if(o.length===0||t>=this._list.length)return;let i=this._list[t].label;if(o.length>1){let a=[...o].sort((c,d)=>c-d),s=a[0]<t?1:0,l=[];for(let c=a.length-1;c>=0;c--){let d=a[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(i);u<0&&(u=this._list.length),u+=s;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let a=o[0];if(a===t||a<0||a>=this._list.length)return;let s=this._list[a];this._list.splice(a,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(s,a),this._list.splice(t,0,s),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(s,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],o=e._list[t];if(!r.isEqual(o))return!1}return!0}};var xh=pd(du(),1);var ku="::RSLV:",Ha=new Map,Ga=new Map,Wa=new WeakMap,ke=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Zn=class extends ce{constructor(e){super({asBag:!1}),Wa.set(this,e)}get payload(){return Wa.get(this)}load(){throw new ke("This resolver is opaque; local execution is unavailable")}};function Tu(n,{module:e,name:t,encode:r,decode:o}){if(!(n.prototype instanceof ce)||n===Zn||typeof e!="string"||!e||typeof t!="string"||!t||typeof r!="function"||typeof o!="function")throw new TypeError("registerResolver requires a BagResolver subclass, module, name and adapters");let i=JSON.stringify([e,t]);if(Ha.has(i)&&Ha.get(i).cls!==n)throw new TypeError(`Resolver ${e}.${t} is already registered`);if(Ga.has(n)&&Ga.get(n).key!==i)throw new TypeError("A resolver class cannot own two wire identities");let a={cls:n,module:e,name:t,encode:r,decode:o,key:i};Ha.set(i,a),Ga.set(n,a)}function yh(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 ke("Invalid resolver description")}function vh(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 ke("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))vh(t,e);e.delete(n)}}function oi(n){if(Wa.has(n))return Wa.get(n);let e=Ga.get(n.constructor);if(!e)throw new ke(`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 yh(r),vh(r),ku+JSON.stringify(r)}function Ya(n){if(typeof n!="string"||!n.startsWith(ku))return null;let e=n.slice(ku.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Zn(n);let t;try{t=JSON.parse(e)}catch{throw new ke("Invalid resolver JSON or signed token")}yh(t);let r=Ha.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new Zn(n);let o=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(o instanceof r.cls))throw new ke("Resolver decoder returned an incompatible instance");return o}function Xa(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof ce?oi(t):t]))}function Au(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,Ya(t)??t]))}var xt="__cls";function Kn(n,e){return n!==null&&n.tytxSuffix===e?n:ti(e)}function uy(n){let e=n.tytxSuffix,t=Object.entries(ht(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new ke(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new ke(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Du(n,e){let t=ht(n);if(!Object.hasOwn(t,e))throw new ke(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function Su(n,e){return n===e?null:uy(n)}function*kh(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let o=t.getValue(!0);!t.resolver&&o instanceof x&&(yield*kh(o,r))}}function cy(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 o=e.replace(/\.000Z$/,"Z");return t&&!r?o.slice(o.indexOf("T")+1):o}function Jn(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function wr(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(wr):Jn(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,wr(t)])):n}function Cu(n){if(!Jn(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 Eh=!1,x=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new ni,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Cu(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 Et}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(o=>o)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!0){let[o,i]=this._htraverseBefore(e);if(o===null)return[null,null];if(i.length===0)return[o,""];for(;i.length>1&&o instanceof n;){let a=i[0];if(a==="#parent"){if(o.parent===null||o.parent===void 0)break;i.shift(),o=o.parent;continue}let s=o._nodes.get(a);if(!s)break;let l=s.getValue(r);if(l instanceof n)i.shift(),o=l;else if(t){let u=o.createChildBag();s.setValue(u,!0,null,!0,!0,"autocreate"),i.shift(),o=u}else break}if(!t)return i.length>1?[null,null]:[o,i[0]];for(;i.length>1;){let a=i.shift();if(a.startsWith("#"))throw new ii("Not existing index in #n syntax");let s=o.createChildBag();o._nodes.set(a,s,">",null,o,null,!1,!0,"autocreate"),o=s}return[o,i[0]]}get(e,t=null,r=!0,o={}){if(!e)return this;if(e==="#parent")return this.parent;let i=null;e.includes("?")&&([e,i]=e.split("?",2));let a=this._nodes.get(e);return a?a.getValue(r,i,o):t}getItem(e,t=null,r=!1,o={}){if(!e)return this;let[i,a]=this._htraverse(e,!1,r);return i instanceof n?i.get(a,t,r,o):t}setItem(e,t,r=null,o=">",i=!1,a=!0,s=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,o,r,f,c,i,a,s,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let o=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(o,r,null,t),o}return null}pop(e,t=null,r=null){let o=this.popNode(e,r);return o?o.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,o]=this._htraverse(e,!1,!0);if(!r||!o)return null;let i=r._nodes.get(o);if(!i)return null;try{return r._pop(o,t)}finally{i.parentBag===r&&r._nodes._dict[i.label]!==i&&(i.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,r=!1,o=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[i,a]=this._htraverse(e,r,t);if(i instanceof n&&a){let s=i._nodes.get(a);if(s)return s;if(r)return i._nodes.set(a,o,">",null,i,null,!1,!0,"autocreate"),i._nodes.get(a)}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 o of this)o.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,o=null,i=null,a=null,s=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:o,attrs_diff:i,evt:r,reason:a,fired:s});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,o,i,a,s)}_onNodeInserted(e,t,r=null,o=null,i=!1){let a=e.parentBag,s=e.getValue(!0);a!==null&&a.backref&&s instanceof n&&s.setBackref(e,a),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:o,fired:i});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],o,i)}_onNodeDeleted(e,t,r=null,o=null){for(let i of Object.values(this._delSubscribers))i({node:e,pathlist:r,ind:t,evt:"del",reason:o});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],o))}_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:o=null,delete:i=null,any:a=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||a),this._subscribe(e,this._insSubscribers,o||a),this._subscribe(e,this._delSubscribers,i||a)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=!1,insert:o=!1,delete:i=!1,any:a=!1}=t;(r||a)&&delete this._updSubscribers[e],(o||a)&&delete this._insSubscribers[e],(i||a)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,t=null,r=!0){let o=n.prototype.getNode.call(this,e,!0,!0);o&&o.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let o=this.getNode(e);return o?o.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 o=r.value;if(o instanceof n){if(o.getItem(e)===t)return r}else if(o&&o.get&&o.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,o=!1){let i=t===void 0,a=r&&typeof t=="string"?t.toLowerCase():t,s=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(i||d==a)return c}if(c._value instanceof n)if(o){let d=s(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=s(c);if(d)return d}return null};return s(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 o=r.getValue(!0);if(o!=null&&!(e&&o===0)&&!(t&&o===""))return!1}return!0}query(e=null,t=null,r=!1,o=!1,i=!0,a=!0,s=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,w,b)=>{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 _=b();return w&&_ instanceof n?null:_}else if(m.startsWith("#v.")){let _=m.split(".").slice(1).join("."),y=b();return y&&y.getItem?y.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 _=b();return _&&_.getItem?_.getItem(m):null}}};function*f(){let h=0;function*m(p,w){for(let b of p._nodes){let _=w?`${w}.${b.label}`:b.label,y=!1,E,N=()=>(y||(E=b.getValue(l),y=!0),E);if((i&&a||(N()instanceof n?a:i))&&(t===null||t(b))&&(yield c.length===1?d(b,c[0],_,o,N):c.map(C=>d(b,C,_,o,N)),h++,s!==null&&h>=s))return;if(o){let C=N();if(C instanceof n&&(yield*m(C,_),s!==null&&h>=s))return}}}yield*m(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,o)=>{for(let i of r._nodes){let a=o?`${o}.${i.label}`:i.label,s=i.getValue(!1);s instanceof n?t(s,a):e.push([a,s])}};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 o=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){if(!o||o.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let i=[...o];if(i.length&&Array.isArray(i[0])){let a=i[0].length,s=[];for(let l=0;l<a;l++)s.push(i.map(u=>u[l]));return s}return[i]}return[...o]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",o=e.map(i=>`${r}${i}`).join(",");return this.digest(o,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 o=i=>{let a=0,s=!1;for(let l of this.query(i,r)){if(l==null||l===""){s=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}a+=l}return t&&s?null:a};return e.includes(",")?e.split(",").map(i=>o(i.trim())):o(e)}sort(e="#k:a"){let t=(o,i)=>o==null?[-1,""]:i&&typeof o=="string"?[0,o.toLowerCase()]:[0,o],r=(o,i)=>o[0]!==i[0]?o[0]-i[0]:o[1]<i[1]?-1:o[1]>i[1]?1:0;if(typeof e=="function")this._nodes._list.sort((o,i)=>{let a=e(o),s=e(i);return a<s?-1:a>s?1:0});else{let o=e.split(",");o.reverse();for(let i of o){let a,s;i.includes(":")?[a,s]=i.split(":",2):(a=i,s="a"),a=a.trim(),s=s.trim();let l=s==="d"||s==="D",u=s==="a"||s==="d",c;if(a.toLowerCase()==="#k")c=d=>t(d.label,u);else if(a.toLowerCase()==="#v")c=d=>t(d.value,u);else if(a.toLowerCase().startsWith("#a.")){let d=a.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof n?f.getItem(a):f?f[a]: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(o=>o 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 o=new br({callback:t,...r});this.setResolver(e,o)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!1,o=!1){let i={};for(let a of this._nodes){let s=a.value;if(o&&s==null)continue;let l=a.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),r&&s instanceof n&&(s=n.prototype.asDict.call(s,e,t,r,o)),Object.defineProperty(i,l,{value:s,enumerable:!0,writable:!0,configurable:!0})}return i}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 o=r.getValue(!e);o instanceof n&&(o=o.deepcopy(e));let i=new t.nodeClass(t,r.label,o);i.setAttr({...r.attr},!1,!1,!1),i.nodeTag=r.nodeTag,i.xmlTag=r.xmlTag,t._nodes._list.push(i),t._nodes._dict[i.label]=i}return t}update(e,t=null,r=null,o=!1){if(!(e instanceof n)){for(let i in e){let a=e[i];(!o||a!==null||!this._nodes.has(i))&&this.setItem(i,a,null,">",!1,!1,r,!1,r!==!1)}return}for(let i of[...e]){let a=i.label,s=t==="static"?i.resolver:null,l=s?null:i.getValue(),u=i.attr.__replace;delete i.attr.__replace;let c=this._nodes.get(a);if(c)if(c.setAttr(i.attr,r===null?!0:r,!0,!1),i.nodeTag!=null&&(c.nodeTag=i.nodeTag),i.xmlTag!=null&&(c.xmlTag=i.xmlTag),s)c.resolver=s,c.setValue(null,r===null?!0:r,null,null,!1,r);else{i.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,o):(!o||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(a,s||l,i.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=i.nodeTag,d.xmlTag=i.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,o=null,i=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let a=new this.nodeClass(this,e,null,r,o,i,null,!1);return t instanceof ce?a.resolver=t:a._value=t,this._nodes._dict[e]=a,this._nodes._list.push(a),a}fillFrom(e=null,t={}){let r=Cu(t);if(e!=null&&!Jn(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let o=this.createChildBag(),i=new Set,a=(s,l,u)=>{if(i.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);i.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let m=h;r&&(Jn(m)||Array.isArray(m))&&(m=this.createChildBag(),a(m,h,`${u}[${JSON.stringify(f)}]`)),s._appendLiteral(f,m)}}finally{i.delete(l)}};return e!=null&&a(o,e,"$"),this._replacePrepared(o)}_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 o=r.getValue(!0);o instanceof n&&o.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:o={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let i=(a,s)=>{for(let l=0;l<a._nodes.length;l++){let u=a._nodes._list[l],c={...s};"_pathlist"in s&&(c._pathlist=[...s._pathlist,u.label]),"_indexlist"in s&&(c._indexlist=[...s._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=i(f,c);if(h)return h}}}return null};return i(this,o)}*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 o=t?`${t}.${r.label}`:r.label;yield[o,r];let i=r.getValue(e);i instanceof n&&(yield*i._iterNodesWithPaths(e,o))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,o=0,i=new Map([["[]",this.constructor]]);for(let[a,s]of kh(this)){let l=a.slice(0,-1),u=JSON.stringify(a),c=JSON.stringify(l),d=s.getValue(!0),f,h=null;if(s.resolver)f=oi(s.resolver);else if(d instanceof n){let w=d.constructor,b=w.tytxSuffix;i.set(u,w),h=Su(w,Kn(i.get(c),b)),f=`::${b}`}else d===null?f="::NN":f=wr(d);if(s.attr&&Object.hasOwn(s.attr,xt))throw new ke(`node '${a}': the attribute '${xt}' is reserved for the Bag class name`);let m=Xa(wr(s.attr));h!==null&&(m[xt]=h);let p=s.nodeTag;t?(yield[l.length?r[c]:null,s.label,p,f,m],d instanceof n&&(r[u]=o,e[o]=a,o++)):yield[l,s.label,p,f,m]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),o=this.constructor.tytxSuffix;if(e==="json")return`${r}::${o}`;if(e==="msgpack")return _a(new yt(4,new TextEncoder().encode(`${o}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let i={};t={rows:[...this._nodeFlattener(i)],paths:i}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,o=Su(r,Kn(null,r.tytxSuffix));return o!==null&&(t[xt]=o),t.rows=t.rows.map(([i,a,s,l,u])=>[wr(i),wr(a),wr(s),l,u]),t.paths&&(t.paths=wr(t.paths)),F(t)}static fromTytx(e,t="json",r={}){if(Jn(t)&&(r=t,t="json"),Cu(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 o=j(e,t==="json"?null:t);if(o instanceof n)return o;if(!Jn(o)&&!Array.isArray(o))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(o,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Kn(null,t));let r=j(e);if(!r||!Array.isArray(r.rows))throw new ke("Invalid TYTX Bag: expected rows");let o=r.paths,i=o!=null,a=Object.hasOwn(r,xt)?Du(t,r[xt]):Kn(null,t),s=new a,l=new Map([["[]",s]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new ke("Invalid TYTX Bag row");let[c,d,f,h,m]=u,p=c??"";if(i){if(c!==null&&!Object.hasOwn(o,c))throw new ke(`Unknown TYTX parent reference: ${c}`);p=c===null?"":o[c]}if(typeof p=="string"&&(p=p?p.split("."):[]),!Array.isArray(p))throw new ke("Invalid TYTX parent path");let w=JSON.stringify(p);if(!l.has(w))throw new ke(`Missing or undecodable TYTX parent branch: ${p}`);let b=l.get(w),_=JSON.stringify([...p,d]),y=h,E=Ya(y),N=Au(m),k=Object.hasOwn(N,xt)?N[xt]:null;if(delete N[xt],y instanceof n){let O=y.constructor.tytxSuffix,$=k!==null?Du(O,k):Kn(b.constructor,O);y=new $,l.set(_,y)}else if(k!==null)throw new ke(`node '${_}': the attribute '${xt}' is reserved for the Bag class name of a branch`);let C=b._appendLiteral(d,E?null:y,N,E);C.nodeTag=f??null}return s}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:o=null,selfClosedTags:i=null}=e,a=this._bagToXml(i,t);return o===!0?a=`<?xml version='1.0' encoding='${r}'?>
|
|
30
|
+
`,Co=class n{static install({document:e,root:t}){return ca.has(t)||ca.set(t,new n(e,t)),ca.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 o=r.content.split(",").map(i=>i.trim()).filter(i=>!i.startsWith("viewport-fit="));r.content=[...o,"viewport-fit=cover"].join(","),this.style=e.createElement("style"),this.style.textContent=yg,e.head.append(this.style)}subscribeAppearance(e){let t=this.document.defaultView,r=t.matchMedia("(prefers-color-scheme: dark)"),o=()=>{let s=t.getComputedStyle(this.document.documentElement).colorScheme;e({dark:s==="dark"||!["light","dark"].includes(s)&&r.matches})},i=new t.MutationObserver(o);i.observe(this.document.documentElement,{attributes:!0,attributeFilter:["data-theme","style","class"]}),r.addEventListener("change",o),o();let a=()=>{i.disconnect(),r.removeEventListener("change",o)};return this.releases.push(a),a}dispose(){if(!this.closed){this.closed=!0;for(let e of this.releases)e();this.style.remove(),this.root.removeAttribute("data-gramlot-viewport"),ca.delete(this.root)}}};var No=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(o=>!["author","description"].includes(o))||Object.values(t).some(o=>typeof o!="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(o,i){if(typeof o!="string"||!o||o.includes(":"))throw new TypeError("Invalid command name");if(r.has(o))throw new Error(`Duplicate command: ${e}:${o}`);if(!i||typeof i!="object"||Array.isArray(i)||!Object.hasOwn(i,"label")||!Object.hasOwn(i,"publish")||Object.keys(i).some(a=>!["label","publish","icon","iconSrc","tooltip"].includes(a))||Object.values(i).some(a=>typeof a!="string"))throw new TypeError(`Invalid command definition: ${e}:${o}`);r.set(o,Object.freeze({...i}))}})}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 Io=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:o=globalThis.navigator,XMLHttpRequest:i=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=o,this.XMLHttpRequest=i}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 da=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 lr=class{createTransport({rpcUrl:e,closeUrl:t,document:r,channel:o=null}){let i=r.defaultView,a=new Io(e,{closeUrl:t,navigator:i.navigator,XMLHttpRequest:i.XMLHttpRequest});return o===null?a:new da(o,a)}};var Cn=9e15,fr=1e9,Ml="0123456789abcdef",pa="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ma="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Pl={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Cn,maxE:Cn,crypto:!1},Nd,Gt,z=!0,ba="[DecimalError] ",dr=ba+"Invalid argument: ",Id=ba+"Precision limit exceeded",Od=ba+"crypto unavailable",Rd="[object Decimal]",ze=Math.floor,Ce=Math.pow,vg=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Eg=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,xg=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bd=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,yt=1e7,F=7,kg=9007199254740991,Tg=pa.length-1,Ll=ma.length-1,D={toStringTag:Rd};D.absoluteValue=D.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),P(n)};D.ceil=function(){return P(new this.constructor(this),this.e+1,2)};D.clampedTo=D.clamp=function(n,e){var t,r=this,o=r.constructor;if(n=new o(n),e=new o(e),!n.s||!e.s)return new o(NaN);if(n.gt(e))throw Error(dr+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new o(r)};D.comparedTo=D.cmp=function(n){var e,t,r,o,i=this,a=i.d,s=(n=new i.constructor(n)).d,l=i.s,u=n.s;if(!a||!s)return!l||!u?NaN:l!==u?l:a===s?0:!a^l<0?1:-1;if(!a[0]||!s[0])return a[0]?l:s[0]?-u:0;if(l!==u)return l;if(i.e!==n.e)return i.e>n.e^l<0?1:-1;for(r=a.length,o=s.length,e=0,t=r<o?r:o;e<t;++e)if(a[e]!==s[e])return a[e]>s[e]^l<0?1:-1;return r===o?0:r>o^l<0?1:-1};D.cosine=D.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())+F,r.rounding=1,t=Ag(r,Fd(r,t)),r.precision=n,r.rounding=e,P(Gt==2||Gt==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};D.cubeRoot=D.cbrt=function(){var n,e,t,r,o,i,a,s,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(z=!1,i=c.s*Ce(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=Me(c.d),n=c.e,(i=(n-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Ce(t,1/3),n=ze((n+1)/3)-(n%3==(n<0?-1:2)),i==1/0?t="5e"+n:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(i.toString()),a=(n=d.precision)+3;;)if(s=r,l=s.times(s).times(s),u=l.plus(c),r=he(u.plus(c).times(s),u.plus(l),a+2,1),Me(s.d).slice(0,a)===(t=Me(r.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!o&&t=="4999"){if(!o&&(P(s,n+1,0),s.times(s).times(s).eq(c))){r=s;break}a+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(P(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return z=!0,P(r,n,d.rounding,e)};D.decimalPlaces=D.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-ze(this.e/F))*F,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};D.dividedBy=D.div=function(n){return he(this,new this.constructor(n))};D.dividedToIntegerBy=D.divToInt=function(n){var e=this,t=e.constructor;return P(he(e,new t(n),0,1,1),t.precision,t.rounding)};D.equals=D.eq=function(n){return this.cmp(n)===0};D.floor=function(){return P(new this.constructor(this),this.e+1,3)};D.greaterThan=D.gt=function(n){return this.cmp(n)>0};D.greaterThanOrEqualTo=D.gte=function(n){var e=this.cmp(n);return e==1||e===0};D.hyperbolicCosine=D.cosh=function(){var n,e,t,r,o,i=this,a=i.constructor,s=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return s;t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,o=i.d.length,o<32?(n=Math.ceil(o/3),e=(1/_a(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),i=Nn(a,1,i.times(e),new a(1),!0);for(var l,u=n,c=new a(8);u--;)l=i.times(i),i=s.minus(l.times(c.minus(l.times(c))));return P(i,a.precision=t,a.rounding=r,!0)};D.hyperbolicSine=D.sinh=function(){var n,e,t,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=Nn(i,2,o,o,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,o=o.times(1/_a(5,n)),o=Nn(i,2,o,o,!0);for(var a,s=new i(5),l=new i(16),u=new i(20);n--;)a=o.times(o),o=o.times(s.plus(a.times(l.times(a).plus(u))))}return i.precision=e,i.rounding=t,P(o,e,t,!0)};D.hyperbolicTangent=D.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,he(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};D.inverseCosine=D.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,o=e.rounding;return t!==-1?t===0?n.isNeg()?It(e,r,o):new e(0):new e(NaN):n.isZero()?It(e,r+4,o).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=o,n.times(2))};D.inverseHyperbolicCosine=D.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,z=!1,t=t.times(t).minus(1).sqrt().plus(t),z=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};D.inverseHyperbolicSine=D.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,z=!1,t=t.times(t).plus(1).sqrt().plus(t),z=!0,r.precision=n,r.rounding=e,t.ln())};D.inverseHyperbolicTangent=D.atanh=function(){var n,e,t,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(n=i.precision,e=i.rounding,r=o.sd(),Math.max(r,n)<2*-o.e-1?P(new i(o),n,e,!0):(i.precision=t=r-o.e,o=he(o.plus(1),new i(1).minus(o),t+n,1),i.precision=n+4,i.rounding=1,o=o.ln(),i.precision=n,i.rounding=e,o.times(.5))):new i(NaN)};D.inverseSine=D.asin=function(){var n,e,t,r,o=this,i=o.constructor;return o.isZero()?new i(o):(e=o.abs().cmp(1),t=i.precision,r=i.rounding,e!==-1?e===0?(n=It(i,t+4,r).times(.5),n.s=o.s,n):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,o.times(2)))};D.inverseTangent=D.atan=function(){var n,e,t,r,o,i,a,s,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<=Ll)return a=It(c,d+4,f).times(.25),a.s=u.s,a}else{if(!u.s)return new c(NaN);if(d+4<=Ll)return a=It(c,d+4,f).times(.5),a.s=u.s,a}for(c.precision=s=d+10,c.rounding=1,t=Math.min(28,s/F+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(z=!1,e=Math.ceil(s/F),r=1,l=u.times(u),a=new c(u),o=u;n!==-1;)if(o=o.times(l),i=a.minus(o.div(r+=2)),o=o.times(l),a=i.plus(o.div(r+=2)),a.d[e]!==void 0)for(n=e;a.d[n]===i.d[n]&&n--;);return t&&(a=a.times(2<<t-1)),z=!0,P(a,c.precision=d,c.rounding=f,!0)};D.isFinite=function(){return!!this.d};D.isInteger=D.isInt=function(){return!!this.d&&ze(this.e/F)>this.d.length-2};D.isNaN=function(){return!this.s};D.isNegative=D.isNeg=function(){return this.s<0};D.isPositive=D.isPos=function(){return this.s>0};D.isZero=function(){return!!this.d&&this.d[0]===0};D.lessThan=D.lt=function(n){return this.cmp(n)<0};D.lessThanOrEqualTo=D.lte=function(n){return this.cmp(n)<1};D.logarithm=D.log=function(n){var e,t,r,o,i,a,s,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)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(z=!1,s=d+h,a=cr(u,s),r=e?ga(c,s+10):cr(n,s),l=he(a,r,s,1),Oo(l.d,o=d,f))do if(s+=10,a=cr(u,s),r=e?ga(c,s+10):cr(n,s),l=he(a,r,s,1),!i){+Me(l.d).slice(o+1,o+15)+1==1e14&&(l=P(l,d+1,0));break}while(Oo(l.d,o+=10,f));return z=!0,P(l,d,f)};D.minus=D.sub=function(n){var e,t,r,o,i,a,s,l,u,c,d,f,h=this,p=h.constructor;if(n=new p(n),!h.d||!n.d)return!h.s||!n.s?n=new p(NaN):h.d?n.s=-n.s:n=new p(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,s=p.precision,l=p.rounding,!u[0]||!f[0]){if(f[0])n.s=-n.s;else if(u[0])n=new p(h);else return new p(l===3?-0:0);return z?P(n,s,l):n}if(t=ze(n.e/F),c=ze(h.e/F),u=u.slice(),i=c-t,i){for(d=i<0,d?(e=u,i=-i,a=f.length):(e=f,t=c,a=u.length),r=Math.max(Math.ceil(s/F),a)+2,i>r&&(i=r,e.length=1),e.reverse(),r=i;r--;)e.push(0);e.reverse()}else{for(r=u.length,a=f.length,d=r<a,d&&(a=r),r=0;r<a;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}i=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),a=u.length,r=f.length-a;r>0;--r)u[a++]=0;for(r=f.length;r>i;){if(u[--r]<f[r]){for(o=r;o&&u[--o]===0;)u[o]=yt-1;--u[o],u[r]+=yt}u[r]-=f[r]}for(;u[--a]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=wa(u,t),z?P(n,s,l):n):new p(l===3?-0:0)};D.modulo=D.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]?P(new r(t),r.precision,r.rounding):(z=!1,r.modulo==9?(e=he(t,n.abs(),0,3,1),e.s*=n.s):e=he(t,n,0,r.modulo,1),e=e.times(n),z=!0,t.minus(e))};D.naturalExponential=D.exp=function(){return Fl(this)};D.naturalLogarithm=D.ln=function(){return cr(this)};D.negated=D.neg=function(){var n=new this.constructor(this);return n.s=-n.s,P(n)};D.plus=D.add=function(n){var e,t,r,o,i,a,s,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,s=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),z?P(n,s,l):n;if(i=ze(d.e/F),r=ze(n.e/F),u=u.slice(),o=i-r,o){for(o<0?(t=u,o=-o,a=c.length):(t=c,r=i,a=u.length),i=Math.ceil(s/F),a=i>a?i+1:a+1,o>a&&(o=a,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(a=u.length,o=c.length,a-o<0&&(o=a,t=c,c=u,u=t),e=0;o;)e=(u[--o]=u[o]+c[o]+e)/yt|0,u[o]%=yt;for(e&&(u.unshift(e),++r),a=u.length;u[--a]==0;)u.pop();return n.d=u,n.e=wa(u,r),z?P(n,s,l):n};D.precision=D.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(dr+n);return t.d?(e=$d(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};D.round=function(){var n=this,e=n.constructor;return P(new e(n),n.e+1,e.rounding)};D.sine=D.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())+F,r.rounding=1,t=Sg(r,Fd(r,t)),r.precision=n,r.rounding=e,P(Gt>2?t.neg():t,n,e,!0)):new r(NaN)};D.squareRoot=D.sqrt=function(){var n,e,t,r,o,i,a=this,s=a.d,l=a.e,u=a.s,c=a.constructor;if(u!==1||!s||!s[0])return new c(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);for(z=!1,u=Math.sqrt(+a),u==0||u==1/0?(e=Me(s),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ze((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(i=r,r=i.plus(he(a,i,t+2,1)).times(.5),Me(i.d).slice(0,t)===(e=Me(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(P(i,l+1,0),i.times(i).eq(a))){r=i;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(P(r,l+1,1),n=!r.times(r).eq(a));break}return z=!0,P(r,l,c.rounding,n)};D.tangent=D.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=he(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,P(Gt==2||Gt==4?t.neg():t,n,e,!0)):new r(NaN)};D.times=D.mul=function(n){var e,t,r,o,i,a,s,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=ze(c.e/F)+ze(n.e/F),l=f.length,u=h.length,l<u&&(i=f,f=h,h=i,a=l,l=u,u=a),i=[],a=l+u,r=a;r--;)i.push(0);for(r=u;--r>=0;){for(e=0,o=l+r;o>r;)s=i[o]+h[r]*f[o-r-1]+e,i[o--]=s%yt|0,e=s/yt|0;i[o]=(i[o]+e)%yt|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),n.d=i,n.e=wa(i,t),z?P(n,d.precision,d.rounding):n};D.toBinary=function(n,e){return jl(this,2,n,e)};D.toDecimalPlaces=D.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(rt(n,0,fr),e===void 0?e=r.rounding:rt(e,0,8),P(t,n+t.e+1,e))};D.toExponential=function(n,e){var t,r=this,o=r.constructor;return n===void 0?t=Ot(r,!0):(rt(n,0,fr),e===void 0?e=o.rounding:rt(e,0,8),r=P(new o(r),n+1,e),t=Ot(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};D.toFixed=function(n,e){var t,r,o=this,i=o.constructor;return n===void 0?t=Ot(o):(rt(n,0,fr),e===void 0?e=i.rounding:rt(e,0,8),r=P(new i(o),n+o.e+1,e),t=Ot(r,!1,n+r.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};D.toFraction=function(n){var e,t,r,o,i,a,s,l,u,c,d,f,h=this,p=h.d,m=h.constructor;if(!p)return new m(h);if(u=t=new m(1),r=l=new m(0),e=new m(r),i=e.e=$d(p)-h.e-1,a=i%F,e.d[0]=Ce(10,a<0?F+a:a),n==null)n=i>0?e:u;else{if(s=new m(n),!s.isInt()||s.lt(u))throw Error(dr+s);n=s.gt(e)?i>0?e:u:s}for(z=!1,s=new m(Me(p)),c=m.precision,m.precision=i=p.length*F*2;d=he(s,e,0,1,1),o=t.plus(d.times(r)),o.cmp(n)!=1;)t=r,r=o,o=u,u=l.plus(d.times(o)),l=o,o=e,e=s.minus(d.times(o)),s=o;return o=he(n.minus(t),r,0,1,1),l=l.plus(o.times(u)),t=t.plus(o.times(r)),l.s=u.s=h.s,f=he(u,r,i,1).minus(h).abs().cmp(he(l,t,i,1).minus(h).abs())<1?[u,r]:[l,t],m.precision=c,z=!0,f};D.toHexadecimal=D.toHex=function(n,e){return jl(this,16,n,e)};D.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:rt(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]?(z=!1,t=he(t,n,0,e,1).times(n),z=!0,P(t)):(n.s=t.s,t=n),t};D.toNumber=function(){return+this};D.toOctal=function(n,e){return jl(this,8,n,e)};D.toPower=D.pow=function(n){var e,t,r,o,i,a,s=this,l=s.constructor,u=+(n=new l(n));if(!s.d||!n.d||!s.d[0]||!n.d[0])return new l(Ce(+s,u));if(s=new l(s),s.eq(1))return s;if(r=l.precision,i=l.rounding,n.eq(1))return P(s,r,i);if(e=ze(n.e/F),e>=n.d.length-1&&(t=u<0?-u:u)<=kg)return o=Md(l,s,t,r),n.s<0?new l(1).div(o):P(o,r,i);if(a=s.s,a<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(a=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=a,s}return t=Ce(+s,u),e=t==0||!isFinite(t)?ze(u*(Math.log("0."+Me(s.d))/Math.LN10+s.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(z=!1,l.rounding=s.s=1,t=Math.min(12,(e+"").length),o=Fl(n.times(cr(s,r+t)),r),o.d&&(o=P(o,r+5,1),Oo(o.d,r,i)&&(e=r+10,o=P(Fl(n.times(cr(s,e+t)),e),e+5,1),+Me(o.d).slice(r+1,r+15)+1==1e14&&(o=P(o,r+1,0)))),o.s=a,z=!0,l.rounding=i,P(o,r,i))};D.toPrecision=function(n,e){var t,r=this,o=r.constructor;return n===void 0?t=Ot(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(rt(n,1,fr),e===void 0?e=o.rounding:rt(e,0,8),r=P(new o(r),n,e),t=Ot(r,n<=r.e||r.e<=o.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};D.toSignificantDigits=D.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(rt(n,1,fr),e===void 0?e=r.rounding:rt(e,0,8)),P(new r(t),n,e)};D.toString=function(){var n=this,e=n.constructor,t=Ot(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};D.truncated=D.trunc=function(){return P(new this.constructor(this),this.e+1,1)};D.valueOf=D.toJSON=function(){var n=this,e=n.constructor,t=Ot(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function Me(n){var e,t,r,o=n.length-1,i="",a=n[0];if(o>0){for(i+=a,e=1;e<o;e++)r=n[e]+"",t=F-r.length,t&&(i+=ur(t)),i+=r;a=n[e],r=a+"",t=F-r.length,t&&(i+=ur(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function rt(n,e,t){if(n!==~~n||n<e||n>t)throw Error(dr+n)}function Oo(n,e,t,r){var o,i,a,s;for(i=n[0];i>=10;i/=10)--e;return--e<0?(e+=F,o=0):(o=Math.ceil((e+1)/F),e%=F),i=Ce(10,F-e),s=n[o]%i|0,r==null?e<3?(e==0?s=s/100|0:e==1&&(s=s/10|0),a=t<4&&s==99999||t>3&&s==49999||s==5e4||s==0):a=(t<4&&s+1==i||t>3&&s+1==i/2)&&(n[o+1]/i/100|0)==Ce(10,e-2)-1||(s==i/2||s==0)&&(n[o+1]/i/100|0)==0:e<4?(e==0?s=s/1e3|0:e==1?s=s/100|0:e==2&&(s=s/10|0),a=(r||t<4)&&s==9999||!r&&t>3&&s==4999):a=((r||t<4)&&s+1==i||!r&&t>3&&s+1==i/2)&&(n[o+1]/i/1e3|0)==Ce(10,e-3)-1,a}function fa(n,e,t){for(var r,o=[0],i,a=0,s=n.length;a<s;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=Ml.indexOf(n.charAt(a++)),r=0;r<o.length;r++)o[r]>t-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}function Ag(n,e){var t,r,o;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),o=(1/_a(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),n.precision+=t,e=Nn(n,1,e.times(o),new n(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return n.precision-=t,e}var he=(function(){function n(r,o,i){var a,s=0,l=r.length;for(r=r.slice();l--;)a=r[l]*o+s,r[l]=a%i|0,s=a/i|0;return s&&r.unshift(s),r}function e(r,o,i,a){var s,l;if(i!=a)l=i>a?1:-1;else for(s=l=0;s<i;s++)if(r[s]!=o[s]){l=r[s]>o[s]?1:-1;break}return l}function t(r,o,i,a){for(var s=0;i--;)r[i]-=s,s=r[i]<o[i]?1:0,r[i]=s*a+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,a,s,l){var u,c,d,f,h,p,m,w,b,_,y,E,S,x,N,O,$,K,W,se,me=r.constructor,te=r.s==o.s?1:-1,le=r.d,q=o.d;if(!le||!le[0]||!q||!q[0])return new me(!r.s||!o.s||(le?q&&le[0]==q[0]:!q)?NaN:le&&le[0]==0||!q?te*0:te/0);for(l?(h=1,c=r.e-o.e):(l=yt,h=F,c=ze(r.e/h)-ze(o.e/h)),W=q.length,$=le.length,b=new me(te),_=b.d=[],d=0;q[d]==(le[d]||0);d++);if(q[d]>(le[d]||0)&&c--,i==null?(x=i=me.precision,a=me.rounding):s?x=i+(r.e-o.e)+1:x=i,x<0)_.push(1),p=!0;else{if(x=x/h+2|0,d=0,W==1){for(f=0,q=q[0],x++;(d<$||f)&&x--;d++)N=f*l+(le[d]||0),_[d]=N/q|0,f=N%q|0;p=f||d<$}else{for(f=l/(q[0]+1)|0,f>1&&(q=n(q,f,l),le=n(le,f,l),W=q.length,$=le.length),O=W,y=le.slice(0,W),E=y.length;E<W;)y[E++]=0;se=q.slice(),se.unshift(0),K=q[0],q[1]>=l/2&&++K;do f=0,u=e(q,y,W,E),u<0?(S=y[0],W!=E&&(S=S*l+(y[1]||0)),f=S/K|0,f>1?(f>=l&&(f=l-1),m=n(q,f,l),w=m.length,E=y.length,u=e(m,y,w,E),u==1&&(f--,t(m,W<w?se:q,w,l))):(f==0&&(u=f=1),m=q.slice()),w=m.length,w<E&&m.unshift(0),t(y,m,E,l),u==-1&&(E=y.length,u=e(q,y,W,E),u<1&&(f++,t(y,W<E?se:q,E,l))),E=y.length):u===0&&(f++,y=[0]),_[d++]=f,u&&y[0]?y[E++]=le[O]||0:(y=[le[O]],E=1);while((O++<$||y[0]!==void 0)&&x--);p=y[0]!==void 0}_[0]||_.shift()}if(h==1)b.e=c,Nd=p;else{for(d=1,f=_[0];f>=10;f/=10)d++;b.e=d+c*h-1,P(b,s?i+b.e+1:i,a,p)}return b}})();function P(n,e,t,r){var o,i,a,s,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(o=1,s=d[0];s>=10;s/=10)o++;if(i=e-o,i<0)i+=F,a=e,c=d[f=0],l=c/Ce(10,o-a-1)%10|0;else if(f=Math.ceil((i+1)/F),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);c=l=0,o=1,i%=F,a=i-F+1}else break e;else{for(c=s=d[f],o=1;s>=10;s/=10)o++;i%=F,a=i-F+o,l=a<0?0:c/Ce(10,o-a-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(a<0?c:c%Ce(10,o-a-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(i>0?a>0?c/Ce(10,o-a):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]=Ce(10,(F-e%F)%F),n.e=-e||0):d[0]=n.e=0,n;if(i==0?(d.length=f,s=1,f--):(d.length=f+1,s=Ce(10,F-i),d[f]=a>0?(c/Ce(10,o-a)%Ce(10,a)|0)*s:0),u)for(;;)if(f==0){for(i=1,a=d[0];a>=10;a/=10)i++;for(a=d[0]+=s,s=1;a>=10;a/=10)s++;i!=s&&(n.e++,d[0]==yt&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=yt)break;d[f--]=0,s=1}for(i=d.length;d[--i]===0;)d.pop()}return z&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function Ot(n,e,t){if(!n.isFinite())return Ld(n);var r,o=n.e,i=Me(n.d),a=i.length;return e?(t&&(r=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+ur(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n.e<0?"e":"e+")+n.e):o<0?(i="0."+ur(-o-1)+i,t&&(r=t-a)>0&&(i+=ur(r))):o>=a?(i+=ur(o+1-a),t&&(r=t-o-1)>0&&(i=i+"."+ur(r))):((r=o+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),t&&(r=t-a)>0&&(o+1===a&&(i+="."),i+=ur(r))),i}function wa(n,e){var t=n[0];for(e*=F;t>=10;t/=10)e++;return e}function ga(n,e,t){if(e>Tg)throw z=!0,t&&(n.precision=t),Error(Id);return P(new n(pa),e,1,!0)}function It(n,e,t){if(e>Ll)throw Error(Id);return P(new n(ma),e,t,!0)}function $d(n){var e=n.length-1,t=e*F+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 ur(n){for(var e="";n--;)e+="0";return e}function Md(n,e,t,r){var o,i=new n(1),a=Math.ceil(r/F+4);for(z=!1;;){if(t%2&&(i=i.times(e),Sd(i.d,a)&&(o=!0)),t=ze(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Sd(e.d,a)}return z=!0,i}function Dd(n){return n.d[n.d.length-1]&1}function Pd(n,e,t){for(var r,o,i=new n(e[0]),a=0;++a<e.length;){if(o=new n(e[a]),!o.s){i=o;break}r=i.cmp(o),(r===t||r===0&&i.s===t)&&(i=o)}return i}function Fl(n,e){var t,r,o,i,a,s,l,u=0,c=0,d=0,f=n.constructor,h=f.rounding,p=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?(z=!1,l=p):l=e,s=new f(.03125);n.e>-2;)n=n.times(s),d+=5;for(r=Math.log(Ce(2,d))/Math.LN10*2+5|0,l+=r,t=i=a=new f(1),f.precision=l;;){if(i=P(i.times(n),l,1),t=t.times(++c),s=a.plus(he(i,t,l,1)),Me(s.d).slice(0,l)===Me(a.d).slice(0,l)){for(o=d;o--;)a=P(a.times(a),l,1);if(e==null)if(u<3&&Oo(a.d,l-r,h,u))f.precision=l+=10,t=i=s=new f(1),c=0,u++;else return P(a,f.precision=p,h,z=!0);else return f.precision=p,a}a=s}}function cr(n,e){var t,r,o,i,a,s,l,u,c,d,f,h=1,p=10,m=n,w=m.d,b=m.constructor,_=b.rounding,y=b.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new b(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(e==null?(z=!1,c=y):c=e,b.precision=c+=p,t=Me(w),r=t.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)m=m.times(n),t=Me(m.d),r=t.charAt(0),h++;i=m.e,r>1?(m=new b("0."+t),i++):m=new b(r+"."+t.slice(1))}else return u=ga(b,c+2,y).times(i+""),m=cr(new b(r+"."+t.slice(1)),c-p).plus(u),b.precision=y,e==null?P(m,y,_,z=!0):m;for(d=m,l=a=m=he(m.minus(1),m.plus(1),c,1),f=P(m.times(m),c,1),o=3;;){if(a=P(a.times(f),c,1),u=l.plus(he(a,new b(o),c,1)),Me(u.d).slice(0,c)===Me(l.d).slice(0,c))if(l=l.times(2),i!==0&&(l=l.plus(ga(b,c+2,y).times(i+""))),l=he(l,new b(h),c,1),e==null)if(Oo(l.d,c-p,_,s))b.precision=c+=p,u=a=m=he(d.minus(1),d.plus(1),c,1),f=P(m.times(m),c,1),o=s=1;else return P(l,b.precision=y,_,z=!0);else return b.precision=y,l;l=u,o+=2}}function Ld(n){return String(n.s*n.s/0)}function ha(n,e){var t,r,o;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(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(r,o),e){if(o-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%F,t<0&&(r+=F),r<o){for(r&&n.d.push(+e.slice(0,r)),o-=F;r<o;)n.d.push(+e.slice(r,r+=F));e=e.slice(r),r=F-e.length}else r-=o;for(;r--;)e+="0";n.d.push(+e),z&&(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 Dg(n,e){var t,r,o,i,a,s,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Bd.test(e))return ha(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Eg.test(e))t=16,e=e.toLowerCase();else if(vg.test(e))t=2;else if(xg.test(e))t=8;else throw Error(dr+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,r=n.constructor,a&&(e=e.replace(".",""),s=e.length,i=s-i,o=Md(r,new r(t),i,i*2)),u=fa(e,t,yt),c=u.length-1,i=c;u[i]===0;--i)u.pop();return i<0?new r(n.s*0):(n.e=wa(u,c),n.d=u,z=!1,a&&(n=he(n,o,s*4)),l&&(n=n.times(Math.abs(l)<54?Ce(2,l):Ro.pow(2,l))),z=!0,n)}function Sg(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:Nn(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/_a(5,t)),e=Nn(n,2,e,e);for(var o,i=new n(5),a=new n(16),s=new n(20);t--;)o=e.times(e),e=e.times(i.plus(o.times(a.times(o).minus(s))));return e}function Nn(n,e,t,r,o){var i,a,s,l,u=1,c=n.precision,d=Math.ceil(c/F);for(z=!1,l=t.times(t),s=new n(r);;){if(a=he(s.times(l),new n(e++*e++),c,1),s=o?r.plus(a):r.minus(a),r=he(a.times(l),new n(e++*e++),c,1),a=s.plus(r),a.d[d]!==void 0){for(i=d;a.d[i]===s.d[i]&&i--;);if(i==-1)break}i=s,s=r,r=a,a=i,u++}return z=!0,a.d.length=d+1,a}function _a(n,e){for(var t=n;--e;)t*=n;return t}function Fd(n,e){var t,r=e.s<0,o=It(n,n.precision,1),i=o.times(.5);if(e=e.abs(),e.lte(i))return Gt=r?4:1,e;if(t=e.divToInt(o),t.isZero())Gt=r?3:2;else{if(e=e.minus(t.times(o)),e.lte(i))return Gt=Dd(t)?r?2:3:r?4:1,e;Gt=Dd(t)?r?1:4:r?3:2}return e.minus(o).abs()}function jl(n,e,t,r){var o,i,a,s,l,u,c,d,f,h=n.constructor,p=t!==void 0;if(p?(rt(t,1,fr),r===void 0?r=h.rounding:rt(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Ld(n);else{for(c=Ot(n),a=c.indexOf("."),p?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,a>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-a,f.d=fa(Ot(f),10,o),f.e=f.d.length),d=fa(c,10,o),i=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=p?"0p+0":"0";else{if(a<0?i--:(n=new h(n),n.d=d,n.e=i,n=he(n,f,t,r,0,o),d=n.d,i=n.e,u=Nd),a=d[t],s=o/2,u=u||d[t+1]!==void 0,u=r<4?(a!==void 0||u)&&(r===0||r===(n.s<0?3:2)):a>s||a===s&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>o-1;)d[t]=0,t||(++i,d.unshift(1));for(l=d.length;!d[l-1];--l);for(a=0,c="";a<l;a++)c+=Ml.charAt(d[a]);if(p){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)c+="0";for(d=fa(c,o,e),l=d.length;!d[l-1];--l);for(a=1,c="1.";a<l;a++)c+=Ml.charAt(d[a])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>l)for(i-=l;i--;)c+="0";else i<l&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function Sd(n,e){if(n.length>e)return n.length=e,!0}function Cg(n){return new this(n).abs()}function Ng(n){return new this(n).acos()}function Ig(n){return new this(n).acosh()}function Og(n,e){return new this(n).plus(e)}function Rg(n){return new this(n).asin()}function Bg(n){return new this(n).asinh()}function $g(n){return new this(n).atan()}function Mg(n){return new this(n).atanh()}function Pg(n,e){n=new this(n),e=new this(e);var t,r=this.precision,o=this.rounding,i=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=It(this,i,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?It(this,r,o):new this(0),t.s=n.s):!n.d||e.isZero()?(t=It(this,i,1).times(.5),t.s=n.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(he(n,e,i,1)),e=It(this,i,1),this.precision=r,this.rounding=o,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(he(n,e,i,1)),t}function Lg(n){return new this(n).cbrt()}function Fg(n){return P(n=new this(n),n.e+1,2)}function jg(n,e,t){return new this(n).clamp(e,t)}function qg(n){if(!n||typeof n!="object")throw Error(ba+"Object expected");var e,t,r,o=n.defaults===!0,i=["precision",1,fr,"rounding",0,8,"toExpNeg",-Cn,0,"toExpPos",0,Cn,"maxE",0,Cn,"minE",-Cn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],o&&(this[t]=Pl[t]),(r=n[t])!==void 0)if(ze(r)===r&&r>=i[e+1]&&r<=i[e+2])this[t]=r;else throw Error(dr+t+": "+r);if(t="crypto",o&&(this[t]=Pl[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(Od);else this[t]=!1;else throw Error(dr+t+": "+r);return this}function Ug(n){return new this(n).cos()}function Vg(n){return new this(n).cosh()}function jd(n){var e,t,r;function o(i){var a,s,l,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,Cd(i)){u.s=i.s,z?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(a=0,s=i;s>=10;s/=10)a++;z?a>o.maxE?(u.e=NaN,u.d=null):a<o.minE?(u.e=0,u.d=[0]):(u.e=a,u.d=[i]):(u.e=a,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return ha(u,i.toString())}if(l==="string")return(s=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(s===43&&(i=i.slice(1)),u.s=1),Bd.test(i)?ha(u,i):Dg(u,i);if(l==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,ha(u,i.toString());throw Error(dr+i)}if(o.prototype=D,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=qg,o.clone=jd,o.isDecimal=Cd,o.abs=Cg,o.acos=Ng,o.acosh=Ig,o.add=Og,o.asin=Rg,o.asinh=Bg,o.atan=$g,o.atanh=Mg,o.atan2=Pg,o.cbrt=Lg,o.ceil=Fg,o.clamp=jg,o.cos=Ug,o.cosh=Vg,o.div=zg,o.exp=Hg,o.floor=Gg,o.hypot=Wg,o.ln=Yg,o.log=Xg,o.log10=Kg,o.log2=Zg,o.max=Jg,o.min=Qg,o.mod=eb,o.mul=tb,o.pow=rb,o.random=nb,o.round=ob,o.sign=ib,o.sin=ab,o.sinh=sb,o.sqrt=lb,o.sub=ub,o.sum=cb,o.tan=db,o.tanh=fb,o.trunc=hb,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 o.config(n),o}function zg(n,e){return new this(n).div(e)}function Hg(n){return new this(n).exp()}function Gg(n){return P(n=new this(n),n.e+1,3)}function Wg(){var n,e,t=new this(0);for(z=!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 z=!0,new this(1/0);t=e}return z=!0,t.sqrt()}function Cd(n){return n instanceof Ro||n&&n.toStringTag===Rd||!1}function Yg(n){return new this(n).ln()}function Xg(n,e){return new this(n).log(e)}function Zg(n){return new this(n).log(2)}function Kg(n){return new this(n).log(10)}function Jg(){return Pd(this,arguments,-1)}function Qg(){return Pd(this,arguments,1)}function eb(n,e){return new this(n).mod(e)}function tb(n,e){return new this(n).mul(e)}function rb(n,e){return new this(n).pow(e)}function nb(n){var e,t,r,o,i=0,a=new this(1),s=[];if(n===void 0?n=this.precision:rt(n,1,fr),r=Math.ceil(n/F),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));i<r;)o=e[i],o>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:s[i++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);i<r;)o=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,i):(s.push(o%1e7),i+=4);i=r/4}else throw Error(Od);else for(;i<r;)s[i++]=Math.random()*1e7|0;for(r=s[--i],n%=F,r&&n&&(o=Ce(10,F-n),s[i]=(r/o|0)*o);s[i]===0;i--)s.pop();if(i<0)t=0,s=[0];else{for(t=-1;s[0]===0;t-=F)s.shift();for(r=1,o=s[0];o>=10;o/=10)r++;r<F&&(t-=F-r)}return a.e=t,a.d=s,a}function ob(n){return P(n=new this(n),n.e+1,this.rounding)}function ib(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function ab(n){return new this(n).sin()}function sb(n){return new this(n).sinh()}function lb(n){return new this(n).sqrt()}function ub(n,e){return new this(n).sub(e)}function cb(){var n=0,e=arguments,t=new this(e[n]);for(z=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return z=!0,P(t,this.precision,this.rounding)}function db(n){return new this(n).tan()}function fb(n){return new this(n).tanh()}function hb(n){return P(n=new this(n),n.e+1,1)}D[Symbol.for("nodejs.util.inspect.custom")]=D.toString;D[Symbol.toStringTag]="Decimal";var Ro=D.constructor=jd(Pl);pa=new Ro(pa);ma=new Ro(ma);var qd=Ro;var pb=20,mb=1,Fr=1e6,Ud=1e6,gb=-7,bb=21,wb=!1,Bo="[big.js] ",jr=Bo+"Invalid ",ya=jr+"decimal places",_b=jr+"rounding mode",Vd=Bo+"Division by zero",ue={},Rt=void 0,yb=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function zd(){function n(e){var t=this;if(!(t instanceof n))return e===Rt?zd():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(jr+"value");e=e===0&&1/e<0?"-0":String(e)}vb(t,e)}t.constructor=n}return n.prototype=ue,n.DP=pb,n.RM=mb,n.NE=gb,n.PE=bb,n.strict=wb,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function vb(n,e){var t,r,o;if(!yb.test(e))throw Error(jr+"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),o=e.length,r=0;r<o&&e.charAt(r)=="0";)++r;if(r==o)n.c=[n.e=0];else{for(;o>0&&e.charAt(--o)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=o;)n.c[t++]=+e.charAt(r++)}return n}function qr(n,e,t,r){var o=n.c;if(t===Rt&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(_b);if(e<1)r=t===3&&(r||!!o[0])||e===0&&(t===1&&o[0]>=5||t===2&&(o[0]>5||o[0]===5&&(r||o[1]!==Rt))),o.length=1,r?(n.e=n.e-e+1,o[0]=1):o[0]=n.e=0;else if(e<o.length){if(r=t===1&&o[e]>=5||t===2&&(o[e]>5||o[e]===5&&(r||o[e+1]!==Rt||o[e-1]&1))||t===3&&(r||!!o[0]),o.length=e,r){for(;++o[--e]>9;)if(o[e]=0,e===0){++n.e,o.unshift(1);break}}for(e=o.length;!o[--e];)o.pop()}return n}function Ur(n,e,t){var r=n.e,o=n.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)o="0"+o;o="0."+o}else if(r>0)if(++r>i)for(r-=i;r--;)o+="0";else r<i&&(o=o.slice(0,r)+"."+o.slice(r));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return n.s<0&&t?"-"+o:o}ue.abs=function(){var n=new this.constructor(this);return n.s=1,n};ue.cmp=function(n){var e,t=this,r=t.c,o=(n=new t.constructor(n)).c,i=t.s,a=n.s,s=t.e,l=n.e;if(!r[0]||!o[0])return r[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,s!=l)return s>l^e?1:-1;for(a=(s=r.length)<(l=o.length)?s:l,i=-1;++i<a;)if(r[i]!=o[i])return r[i]>o[i]^e?1:-1;return s==l?0:s>l^e?1:-1};ue.div=function(n){var e=this,t=e.constructor,r=e.c,o=(n=new t(n)).c,i=e.s==n.s?1:-1,a=t.DP;if(a!==~~a||a<0||a>Fr)throw Error(ya);if(!o[0])throw Error(Vd);if(!r[0])return n.s=i,n.c=[n.e=0],n;var s,l,u,c,d,f=o.slice(),h=s=o.length,p=r.length,m=r.slice(0,s),w=m.length,b=n,_=b.c=[],y=0,E=a+(b.e=e.e-n.e)+1;for(b.s=i,i=E<0?0:E,f.unshift(0);w++<s;)m.push(0);do{for(u=0;u<10;u++){if(s!=(w=m.length))c=s>w?1:-1;else for(d=-1,c=0;++d<s;)if(o[d]!=m[d]){c=o[d]>m[d]?1:-1;break}if(c<0){for(l=w==s?o:f;w;){if(m[--w]<l[w]){for(d=w;d&&!m[--d];)m[d]=9;--m[d],m[w]+=10}m[w]-=l[w]}for(;!m[0];)m.shift()}else break}_[y++]=c?u:++u,m[0]&&c?m[w]=r[h]||0:m=[r[h]]}while((h++<p||m[0]!==Rt)&&i--);return!_[0]&&y!=1&&(_.shift(),b.e--,E--),y>E&&qr(b,E,t.RM,m[0]!==Rt),b};ue.eq=function(n){return this.cmp(n)===0};ue.gt=function(n){return this.cmp(n)>0};ue.gte=function(n){return this.cmp(n)>-1};ue.lt=function(n){return this.cmp(n)<0};ue.lte=function(n){return this.cmp(n)<1};ue.minus=ue.sub=function(n){var e,t,r,o,i=this,a=i.constructor,s=i.s,l=(n=new a(n)).s;if(s!=l)return n.s=-l,i.plus(n);var u=i.c.slice(),c=i.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new a(i):n.s=1,n;if(s=c-f){for((o=s<0)?(s=-s,r=u):(f=c,r=d),r.reverse(),l=s;l--;)r.push(0);r.reverse()}else for(t=((o=u.length<d.length)?u:d).length,s=l=0;l<t;l++)if(u[l]!=d[l]){o=u[l]<d[l];break}if(o&&(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>s;){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};ue.mod=function(n){var e,t=this,r=t.constructor,o=t.s,i=(n=new r(n)).s;if(!n.c[0])throw Error(Vd);return t.s=n.s=1,e=n.cmp(t)==1,t.s=o,n.s=i,e?new r(t):(o=r.DP,i=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=o,r.RM=i,this.minus(t.times(n)))};ue.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};ue.plus=ue.add=function(n){var e,t,r,o=this,i=o.constructor;if(n=new i(n),o.s!=n.s)return n.s=-n.s,o.minus(n);var a=o.e,s=o.c,l=n.e,u=n.c;if(!s[0]||!u[0])return u[0]||(s[0]?n=new i(o):n.s=o.s),n;if(s=s.slice(),e=a-l){for(e>0?(l=a,r=u):(e=-e,r=s),r.reverse();e--;)r.push(0);r.reverse()}for(s.length-u.length<0&&(r=u,u=s,s=r),e=u.length,t=0;e;s[e]%=10)t=(s[--e]=s[e]+u[e]+t)/10|0;for(t&&(s.unshift(t),++l),e=s.length;s[--e]===0;)s.pop();return n.c=s,n.e=l,n};ue.pow=function(n){var e=this,t=new e.constructor("1"),r=t,o=n<0;if(n!==~~n||n<-Ud||n>Ud)throw Error(jr+"exponent");for(o&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return o?t.div(r):r};ue.prec=function(n,e){if(n!==~~n||n<1||n>Fr)throw Error(jr+"precision");return qr(new this.constructor(this),n,e)};ue.round=function(n,e){if(n===Rt)n=0;else if(n!==~~n||n<-Fr||n>Fr)throw Error(ya);return qr(new this.constructor(this),n+this.e+1,e)};ue.sqrt=function(){var n,e,t,r=this,o=r.constructor,i=r.s,a=r.e,s=new o("0.5");if(!r.c[0])return new o(r);if(i<0)throw Error(Bo+"No square root");i=Math.sqrt(+Ur(r,!0,!0)),i===0||i===1/0?(e=r.c.join(""),e.length+a&1||(e+="0"),i=Math.sqrt(e),a=((a+1)/2|0)-(a<0||a&1),n=new o((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):n=new o(i+""),a=n.e+(o.DP+=4);do t=n,n=s.times(t.plus(r.div(t)));while(t.c.slice(0,a).join("")!==n.c.slice(0,a).join(""));return qr(n,(o.DP-=4)+n.e+1,o.RM)};ue.times=ue.mul=function(n){var e,t=this,r=t.constructor,o=t.c,i=(n=new r(n)).c,a=o.length,s=i.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!o[0]||!i[0])return n.c=[n.e=0],n;for(n.e=l+u,a<s&&(e=o,o=i,i=e,u=a,a=s,s=u),e=new Array(u=a+s);u--;)e[u]=0;for(l=s;l--;){for(s=0,u=a+l;u>l;)s=e[u]+i[l]*o[u-l-1]+s,e[u--]=s%10,s=s/10|0;e[u]=s}for(s?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};ue.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Rt){if(n!==~~n||n<0||n>Fr)throw Error(ya);for(t=qr(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return Ur(t,!0,!!r)};ue.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Rt){if(n!==~~n||n<0||n>Fr)throw Error(ya);for(t=qr(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return Ur(t,!1,!!r)};ue[Symbol.for("nodejs.util.inspect.custom")]=ue.toJSON=ue.toString=function(){var n=this,e=n.constructor;return Ur(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};ue.toNumber=function(){var n=+Ur(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(Bo+"Imprecise conversion");return n};ue.toPrecision=function(n,e){var t=this,r=t.constructor,o=t.c[0];if(n!==Rt){if(n!==~~n||n<1||n>Fr)throw Error(jr+"precision");for(t=qr(new r(t),n,e);t.c.length<n;)t.c.push(0)}return Ur(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!o)};ue.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(Bo+"valueOf disallowed");return Ur(n,n.e<=e.NE||n.e>=e.PE,!0)};var Eb=zd(),Hd=Eb;var Kl={};wg(Kl,{DecodeError:()=>He,Decoder:()=>Et,EXT_TIMESTAMP:()=>Ul,Encoder:()=>In,ExtData:()=>vt,ExtensionCodec:()=>hr,decode:()=>ef,decodeArrayStream:()=>nf,decodeAsync:()=>rf,decodeMulti:()=>tf,decodeMultiStream:()=>of,decodeTimestampExtension:()=>Wl,decodeTimestampToTimeSpec:()=>Gl,encode:()=>xa,encodeDateToTimeSpec:()=>zl,encodeTimeSpecToTimestamp:()=>Vl,encodeTimestampExtension:()=>Hl});function Gd(n){let e=n.length,t=0,r=0;for(;r<e;){let o=n.charCodeAt(r++);if((o&4294967168)===0){t++;continue}else if((o&4294965248)===0)t+=2;else{if(o>=55296&&o<=56319&&r<e){let i=n.charCodeAt(r);(i&64512)===56320&&(++r,o=((o&1023)<<10)+(i&1023)+65536)}(o&4294901760)===0?t+=3:t+=4}}return t}function xb(n,e,t){let r=n.length,o=t,i=0;for(;i<r;){let a=n.charCodeAt(i++);if((a&4294967168)===0){e[o++]=a;continue}else if((a&4294965248)===0)e[o++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&i<r){let s=n.charCodeAt(i);(s&64512)===56320&&(++i,a=((a&1023)<<10)+(s&1023)+65536)}(a&4294901760)===0?(e[o++]=a>>12&15|224,e[o++]=a>>6&63|128):(e[o++]=a>>18&7|240,e[o++]=a>>12&63|128,e[o++]=a>>6&63|128)}e[o++]=a&63|128}}var kb=new TextEncoder,Tb=50;function Ab(n,e,t){kb.encodeInto(n,e.subarray(t))}function Wd(n,e,t){n.length>Tb?Ab(n,e,t):xb(n,e,t)}var Db=4096;function ql(n,e,t){let r=e,o=r+t,i=[],a="";for(;r<o;){let s=n[r++];if((s&128)===0)i.push(s);else if((s&224)===192){let l=n[r++]&63;i.push((s&31)<<6|l)}else if((s&240)===224){let l=n[r++]&63,u=n[r++]&63;i.push((s&31)<<12|l<<6|u)}else if((s&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(s&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(s);i.length>=Db&&(a+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(a+=String.fromCharCode(...i)),a}var Sb=new TextDecoder,Cb=200;function Nb(n,e,t){let r=n.subarray(e,e+t);return Sb.decode(r)}function Yd(n,e,t){return t>Cb?Nb(n,e,t):ql(n,e,t)}var vt=class{type;data;constructor(e,t){this.type=e,this.data=t}};var He=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 Xd(n,e,t){let r=t/4294967296,o=t;n.setUint32(e,r),n.setUint32(e+4,o)}function va(n,e,t){let r=Math.floor(t/4294967296),o=t;n.setUint32(e,r),n.setUint32(e+4,o)}function Ea(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function Zd(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var Ul=-1,Ib=4294967296-1,Ob=17179869184-1;function Vl({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=Ob)if(e===0&&n<=Ib){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,o=new Uint8Array(8),i=new DataView(o.buffer);return i.setUint32(0,e<<2|t&3),i.setUint32(4,r),o}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),va(r,4,n),t}}function zl(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,o=Math.floor(r/1e9);return{sec:t+o,nsec:r-o*1e9}}function Hl(n){if(n instanceof Date){let e=zl(n);return Vl(e)}else return null}function Gl(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),o=(t&3)*4294967296+r,i=t>>>2;return{sec:o,nsec:i}}case 12:{let t=Ea(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new He(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function Wl(n){let e=Gl(n);return new Date(e.sec*1e3+e.nsec/1e6)}var Kd={type:Ul,encode:Hl,decode:Wl};var hr=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Kd)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let o=-1-e;this.builtInEncoders[o]=t,this.builtInDecoders[o]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let o=this.builtInEncoders[r];if(o!=null){let i=o(e,t);if(i!=null){let a=-1-r;return new vt(a,i)}}}for(let r=0;r<this.encoders.length;r++){let o=this.encoders[r];if(o!=null){let i=o(e,t);if(i!=null){let a=r;return new vt(a,i)}}}return e instanceof vt?e:null}decode(e,t,r){let o=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return o?o(e,t,r):new vt(t,e)}};function Rb(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function $o(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Rb(n)?new Uint8Array(n):Uint8Array.from(n)}var Bb=100,$b=2048,In=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??hr.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Bb,this.initialBufferSize=e?.initialBufferSize??$b,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),o=new DataView(t);r.set(this.bytes),this.view=o,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=Gd(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),Wd(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=$o(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 o of e)this.doEncode(o,t+1)}countWithoutUndefined(e,t){let r=0;for(let o of t)e[o]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let o=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error(`Too large map object: ${o}`);for(let i of r){let a=e[i];this.ignoreUndefined&&a===void 0||(this.encodeString(i),this.doEncode(a,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),o=r.length;if(o>=4294967296)throw new Error(`Too large extension object: ${o}`);this.writeU8(201),this.writeU32(o),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),Xd(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),va(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 xa(n,e){return new In(e).encodeSharedRef(n)}function ka(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var Mb=16,Pb=16,Ta=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Mb,t=Pb){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 o=this.caches[r-1];e:for(let i of o){let a=i.bytes;for(let s=0;s<r;s++)if(a[s]!==e[t+s])continue e;return i.str}return null}store(e,t){let r=this.caches[e.length-1],o={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=o:r.push(o)}decode(e,t,r){let o=this.find(e,t,r);if(o!=null)return this.hit++,o;this.miss++;let i=ql(e,t,r),a=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(a,i),i}};var Yl="array",Lo="map_key",Qd="map_value",Lb=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new He("The type of key must be string or number but "+typeof n)},Xl=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Yl,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=Lo,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===Yl){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Lo||e.type===Qd){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}},Po=-1,Zl=new DataView(new ArrayBuffer(0)),Fb=new Uint8Array(Zl.buffer);try{Zl.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 Jd=new RangeError("Insufficient data"),jb=new Ta,Et=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Zl;bytes=Fb;headByte=Po;stack=new Xl;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??hr.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:jb,this.mapKeyConverter=e?.mapKeyConverter??Lb}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=Po,this.stack.reset()}setBuffer(e){let t=$o(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Po&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=$o(e),o=new Uint8Array(t.length+r.length);o.set(t),o.set(r,t.length),this.setBuffer(o)}}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 s of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);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:o,pos:i,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${ka(o)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let r=t,o=-1;for await(let i of e){if(t&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),r&&(o=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--o!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let o=e-128;if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e<160){let o=e-144;if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else{let o=e-160;t=this.decodeString(o,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 o=this.lookU8();t=this.decodeString(o,1)}else if(e===218){let o=this.lookU16();t=this.decodeString(o,2)}else if(e===219){let o=this.lookU32();t=this.decodeString(o,4)}else if(e===220){let o=this.readU16();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===221){let o=this.readU32();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===222){let o=this.readU16();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===223){let o=this.readU32();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===196){let o=this.lookU8();t=this.decodeBinary(o,1)}else if(e===197){let o=this.lookU16();t=this.decodeBinary(o,2)}else if(e===198){let o=this.lookU32();t=this.decodeBinary(o,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 o=this.lookU8();t=this.decodeExtension(o,1)}else if(e===200){let o=this.lookU16();t=this.decodeExtension(o,2)}else if(e===201){let o=this.lookU32();t=this.decodeExtension(o,4)}else throw new He(`Unrecognized type byte: ${ka(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let o=r.top();if(o.type===Yl)if(o.array[o.position]=t,o.position++,o.position===o.size)t=o.array,r.release(o);else continue e;else if(o.type===Lo){if(t==="__proto__")throw new He("The key __proto__ is not allowed");o.key=this.mapKeyConverter(t),o.type=Qd;continue e}else if(o.map[o.key]=t,o.readCount++,o.readCount===o.size)t=o.map,r.release(o);else{o.key=null,o.type=Lo;continue e}}return t}}readHeadByte(){return this.headByte===Po&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Po}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 He(`Unrecognized array type byte: ${ka(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new He(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new He(`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 He(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Jd;let r=this.pos+t,o;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?o=this.keyDecoder.decode(this.bytes,r,e):o=Yd(this.bytes,r,e),this.pos+=t+e,o}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Lo:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new He(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Jd;let r=this.pos+t,o=this.bytes.subarray(r,r+e);return this.pos+=t+e,o}decodeExtension(e,t){if(e>this.maxExtLength)throw new He(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),o=this.decodeBinary(e,t+1);return this.extensionCodec.decode(o,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=Zd(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Ea(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 ef(n,e){return new Et(e).decode(n)}function tf(n,e){return new Et(e).decodeMulti(n)}function qb(n){return n[Symbol.asyncIterator]!=null}async function*Ub(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function Aa(n){return qb(n)?n:Ub(n)}async function rf(n,e){let t=Aa(n);return new Et(e).decodeAsync(t)}function nf(n,e){let t=Aa(n);return new Et(e).decodeArrayStream(t)}function of(n,e){let t=Aa(n);return new Et(e).decodeStream(t)}var Ha=kd(_u(),1),yu=qd,vu=Hd,Pt=Kl,ch=Ha.DOMParser,dh=Ha.XMLSerializer;var fh=Pt!==null;function hh(){if(!fh)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var ph=q_();function q_(){if(!fh)return null;let n=new TextEncoder,e=new TextDecoder,t=new Pt.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let o=yr(r);if(o==="D"||o==="H")return null}return Pt.encodeTimestampExtension(r)},decode:r=>Pt.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>pe(r)?n.encode(r.toString()):null,decode:r=>Lt(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&yr(r)==="D"){let o=r.getUTCFullYear(),i=String(r.getUTCMonth()+1).padStart(2,"0"),a=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${o}-${i}-${a}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&yr(r)==="H"){let o=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),a=String(r.getUTCSeconds()).padStart(2,"0"),s=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${o}:${i}:${a}.${s}`)}return null},decode:r=>{let o=e.decode(r),i=o.indexOf("."),a=i>=0?o.substring(0,i):o,s=i>=0?o.substring(i+1):"0",[l,u,c]=a.split(":"),d=Math.round(+s.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:r=>{let o=Eu(r);if(o!==null){let[i,a]=o;return n.encode(`${i}:${a(r)}`)}return null},decode:r=>{let o=e.decode(r),i=o.indexOf(":"),a=o.slice(0,i),s=o.slice(i+1),l=vr[a];if(l!==void 0){let[,u]=l;return u(s)}return`${s}::${a}`}}),t}function mh(n){return hh(),Pt.encode(n,{extensionCodec:ph})}function gh(n){return hh(),Pt.decode(n,{extensionCodec:ph})}function Ga(n,e=!1){let t=Wa(n);if(t===null)return[!1,String(n)];let[r,o,i]=t;return i&&!e?[!1,String(n)]:[!0,`${o(n)}::${r}`]}function xu(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),o=vr[r];if(o===void 0)return[!1,n];let[,i]=o;return[!0,i(t)]}function Zn(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[o,i]of Object.entries(n))r[o]=Zn(i,e,t);return r}return Array.isArray(n)?n.map(r=>Zn(r,e,t)):t(n)?e(n):n}function ku(n){let e=Wa(n);if(e!==null){let[t,r,o]=e;return o?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(o=>{let[i,a]=ku(o);return a&&(t=!0),i}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[o,i]of Object.entries(n)){let[a,s]=ku(i);s&&(t=!0),r[o]=a}return[r,t]}return[n,!1]}function U_(n,e=!1){let[t,r]=Ga(n,e);if(t)return r;let[o,i]=ku(n),a=JSON.stringify(o);return i?`${a}::JS`:a}function V_(n){return JSON.stringify(n)}function z_(n){if(!Pt)throw new Error("@msgpack/msgpack is required for MessagePack support");return Pt.encode(n)}function L(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:o=!1}={}){if(r)return`${wh(n)}::QS`;if(t){if(e===null||e==="json")return V_(n);if(e==="msgpack")return z_(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 i=U_(n,o);return e==="json"?`"${i}"`:i}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${bh(n)}</tytx_root>`;if(e==="msgpack")return mh(n);throw new Error(`Unknown transport: ${e}`)}}var Kn,Tu;typeof window<"u"&&window.DOMParser?(Kn=window.DOMParser,Tu=window.XMLSerializer):(Kn=ch,Tu=dh);function _h(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 yh(n,e,t){let r=n.createElement(e),o=t.attrs||{},i=t.value;for(let[a,s]of Object.entries(o))r.setAttribute(a,L(s,null,{_forceSuffix:!0}));if(Array.isArray(i))for(let a of i)if(_h(a)){let[s]=Object.keys(a),l=a[s],u=yh(n,s,l);r.appendChild(u)}else{r.textContent=L(i);break}else r.textContent=L(i);return r}function bh(n){if(!Kn)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(_h(n)){let[e]=Object.keys(n),t=n[e],r=new Kn().parseFromString("<root/>","text/xml"),o=yh(r,e,t);return new Tu().serializeToString(o)}else return L(n)}function Au(n){let e={};for(let r=0;r<n.attributes.length;r++){let o=n.attributes[r];e[o.name]=j(o.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let o=n.childNodes[r];o.nodeType===1&&t.push(o)}if(t.length>0)if(t.length===1){let r=t[0],o=Au(r);return{attrs:e,value:{[r.tagName]:o}}}else{let r=[];for(let o of t){let i=Au(o);r.push({[o.tagName]:i})}return{attrs:e,value:r}}return{attrs:e,value:j(n.textContent)}}function vh(n){if(!Kn)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new Kn().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let i=null;for(let a=0;a<r.childNodes.length;a++)if(r.childNodes[a].nodeType===1){i=r.childNodes[a];break}if(!i)return j(r.textContent);r=i}let o=Au(r);return{[r.tagName]:o}}function Du(n){return typeof n=="string"}function H_(n){let[e,t]=xu(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let o;try{o=JSON.parse(r)}catch{return n}return Zn(o,Su,Du)}function Su(n){return n.includes("::")?xu(n)[1]:n}function G_(n){let e=vh(n);return typeof e=="string"?j(e):e}function W_(n){return gh(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)),H_(t)}else{if(e==="xml")return G_(n);if(e==="msgpack")return W_(n);throw new Error(`Unknown transport: ${e}`)}}function Eh(n){return Symbol.asyncIterator in n?(async function*(){for await(let t of n)yield Zn(t,Su,Du)})():(function*(){for(let t of n)yield Zn(t,Su,Du)})()}function wh(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[o,i]=Ga(r,!0);o?e.push(`${t}=${i}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function xh(n){if(!n)return[];let e=n.split("&"),t=e.map(a=>a.includes("=")),r=t.every(Boolean),o=!t.some(Boolean);if(!r&&!o)throw new Error("QS format error: mixed items with and without '='");if(o)return e.map(a=>j(a));let i={};for(let a of e){let s=a.indexOf("="),l=a.slice(0,s),u=a.slice(s+1);i[l]=j(u)}return i}var Th=yu||vu||Number,Ah=yu?"decimal.js":vu?"big.js":"number";function Nu(){return Ah}function Lt(n){return new Th(n)}function pe(n){return Ah==="number"?!1:n instanceof Th}function yr(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 Y_(n){return n.toString()}function X_(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 Z_(n){return n.toISOString()}function K_(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),o=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${o}`}function J_(n){return n?"true":"false"}function Q_(n){return n.toString()}function ey(n){return n.toString()}function ty(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 Ya=[],Cu=new Map;function Eu(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,o,i]of Ya)if(t.prototype===e)return[r,o,i];return null}function Wa(n){if(n===null)return["NN",()=>"",!0];if(pe(n))return["N",Y_,!1];if(n instanceof Uint8Array)return["RAW",ty,!1];if(n instanceof Date){let e=yr(n);return e==="D"?["D",X_,!1]:e==="H"?["H",K_,!1]:["DHZ",Z_,!1]}return typeof n=="boolean"?["B",J_,!0]:typeof n=="number"?Number.isInteger(n)?["L",Q_,!0]:["R",ey,!0]:Eu(n)}function ry(n){return Lt(n)}function ny(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function kh(n){return new Date(n)}function oy(n){let[e,t,r]=n.split(":"),[o,i]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(o),Number(i||0)))}function iy(n){return n.toLowerCase()==="true"}function ay(n){return parseInt(n,10)}function sy(n){return parseFloat(n)}function ly(n){return n}function uy(n){return null}var cy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function dy(n){if(!cy.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 fy(n){return xh(n)}var hy=/^[A-Z]+$/,vr={N:[Object,ry],D:[Date,ny],DH:[Date,kh],DHZ:[Date,kh],H:[Date,oy],L:[Number,ay],R:[Number,sy],T:[String,ly],B:[Boolean,iy],QS:[Object,fy],NN:[null,uy],RAW:[Uint8Array,dy]};function oi(n){return Object.hasOwn(vr,n)?vr[n][0]:null}function Iu(n,e,t,r,o=!1){if(typeof e!="string"||!hy.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let i=vr[e];if(i!==void 0&&i[0]!==n){let a=i[0]===null?"null":i[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${a}`)}Ya=Ya.filter(([a])=>a!==n),Ya.push([n,e,t,o]),vr[e]=[n,r]}function Wr(n,e){Cu.set(n,e)}function pt(n){return Cu.has(n)?Cu.get(n):{}}function re(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 Dh=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Yr(n,e){let t="",r=!1;for(let o=0;o<n.length;){if(n[o]!=="{"&&n[o]!=="}"){t+=n[o++];continue}let i=n.slice(o).match(Dh);if(!i)throw new SyntaxError("Invalid pointer template placeholder");let a=i[1]??"",s=a.startsWith("?"),l=e(s?a.slice(1):a);l==null||l===""&&!s?r=!0:t+=String(l),o+=i[0].length}return r?null:t}function ii(n){let e=[],t=new Set,r="",o=!0;for(let i=0;i<n.length;){let a=i,s=n[i];if(s==='"'||s==="'"||s==="`"){for(i++;i<n.length;){if(n[i]==="\\"){i+=2;continue}if(n[i++]===s)break}r+=n.slice(a,i),o=!1;continue}if(n.startsWith("//",i)){i=n.indexOf(`
|
|
31
|
+
`,i),i<0&&(i=n.length),r+=n.slice(a,i);continue}if(n.startsWith("/*",i)){let c=n.indexOf("*/",i+2);i=c<0?n.length:c+2,r+=n.slice(a,i);continue}if(s==="/"&&o){let c=!1;for(i++;i<n.length;){let d=n[i++];if(d==="\\"){i++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[i]??"")&&i<n.length;)i++;r+=n.slice(a,i),o=!1;continue}let l=s==="{"?n.slice(i).match(Dh):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),i+=l[0].length,o=!1;continue}let u=n.slice(i).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],i+=u[0].length,o=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=s,i++,/\s/.test(s)||(o=/[([{,:;=!?&|+*%~<>\/-]/.test(s))}return{text:r,slots:e,identifiers:t}}function Sh(n,e,t=()=>null){let r=new Map,o=[],i=a=>{if(r.has(a))return r.get(a);if(!n.has(a))throw new Error(`Referenced Source attribute '${a}' does not exist`);if(o.includes(a))throw new Error(`Cyclic attribute dependency: ${[...o,a].join(" -> ")}`);o.push(a);try{let s=n.get(a),l=typeof a=="string"?re(s):null,u=e.get(a);if(l){let c=d=>d?i(d):e.get(a);if(l.expression){let d=ii(l.body);u=t(a,s,d,d.slots.map(c))}else u=Yr(l.body,c),e.get(a)==null&&(u=null)}return r.set(a,u),u}finally{o.pop()}};return new Map([...n.keys()].map(a=>[a,i(a)]))}function Ft(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,o=[],i=a=>{let s=re(a);if(!s)return;let l=[];s.expression?l.push(...ii(s.body).slots):Yr(s.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(o.includes(u))throw new Error(`Cyclic attribute dependency: ${[...o,u].join(" -> ")}`);r.has(u)||(o.push(u),i(t.get(u)),o.pop(),r.add(u))}};return i(e),r}var Ch={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 my(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?Ch[e]||null:e}function gy(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function by(n){return new Promise(e=>setTimeout(e,n))}async function wy(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,o=e.backoff||2,i=e.jitter!==!1,a=e.on||["Error"],s=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(s=c,u<t-1&&gy(c,a)){let d=l;i&&(d*=1+Math.random()*.1),await by(d),l*=o}else throw c}throw s}var de=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 i of["interval","reactive"])if(Object.hasOwn(r,i))throw new TypeError(`Removed resolver option: ${i}. 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 o=this.constructor.internalParams;for(let[i,a]of Object.entries(r))o.has(i)||(this._kw[i]=a);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}_buildEffectiveKw(){let e={...this._kw};if(this._node&&this._node.attr)for(let t of Object.keys(this._kw))Object.hasOwn(this._node.attr,t)&&(e[t]=this._node.attr[t]);return e}resolve(e={}){let{static:t=!1,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let o=this._buildEffectiveKw();if(Object.keys(r).length>0)return this._load({...o,...r},a=>this._prepareValue(a));let i=this._computeEffectiveFingerprint(o);return i===this._lastEffectiveFingerprint&&!this.expired?this.cachedValue:(this._lastEffectiveFingerprint=i,this._load(o,a=>this._finalize(a)))}_load(e,t){let r=my(this),o=()=>this.load(e);if(r)return wy(o,r).then(t);let i=o();return i&&typeof i.then=="function"?i.then(t):t(i)}_finalize(e){return e=this._prepareValue(e),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_prepareValue(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)),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}};de._BagClass=null;var Er=class extends de{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 xt=class n{constructor(e,t,r=null,o=null,i=null,a=null,s=null,l=!0){this.label=t,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=a,this.xmlTag=s,this._compiled=null,this.parentBag=e,o&&this.setAttr(o,!1,!0,l),r!==null&&this.setValue(r,!1),i&&(this.resolver=i)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,t=null,r={}){if(t!==null){let o=j(`${t}::QS`);if(Array.isArray(o)){let i=o.length?o:Object.keys(this._attr),a=i.map(l=>{let u=this.getAttr(l);return!e&&u instanceof de?u.resolve():u}),s=l=>o.length===0?Object.fromEntries(i.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return a.some(l=>l&&typeof l.then=="function")?Promise.all(a).then(s):s(a)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");r={...r,...o}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,o=null,i=!0,a=null,s=!1){e instanceof de?(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,o,i);let p=this._buildAttrDiff(h,this._attr);d=Object.keys(p).length>0?p:null}t=c&&(u||d!==null);let f=d?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),t){let h=d!==null?{oldvalue:l,attrs_diff:d}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:h,evt:f})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),t&&this._parentBag._onNodeChanged(this,[this.label],f,l,d,a,s))}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 o=this._value,i={...this._attr},a=this.resolver;a&&a._node===this&&(a._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let s=this._buildAttrDiff(i,this._attr),l=Object.keys(s).length?s:null,u=o!==t||a!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:o,attrs_diff:l}:{oldvalue:o};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,o,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={},o=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of o){let a=i in e?e[i]:null,s=i in t?t[i]:null;a!==s&&(r[i]={old:a,new:s})}return r}setAttr(e=null,t=!0,r=!0,o=!0){let i=e||{},a=Object.keys(this._nodeSubscribers).length>0,l=t&&(a||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?Object.assign(this._attr,i):this._attr={...i},o)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(t&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&a)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let 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 o of t)if(this._attr[o]!==e._attr[o])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(o=>this._attr[o]!==e._attr[o])?`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 ai=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,o]=t,i=o.includes("::")?j(o):o;return r?this._list.findIndex(a=>a.getAttr(r)===i):this._list.findIndex(a=>a._value===i)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let i=this._parseSharpIndex(r.slice(1),e);return Math.min(i,t)}let o=this.index(r);if(o<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return o}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let i=this._parseSharpIndex(r.slice(1),e);return Math.min(i+1,t)}let o=this.index(r);if(o<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return o+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=">",o=null,i=null,a=null,s=!1,l=!0,u=null,c=!0,d=!1,f=null){let h=null;if(e.includes("?")&&([e,h]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(h){let m=h.split("&");if(m.length===1)o={[m[0]]:t};else{if(!Array.isArray(t)||t.length!==m.length)throw new Error("Wrong attributes assignment");o={};for(let w=0;w<m.length;w++)o[m[w]]=t[w]}t=null}let p=this._dict[e];if(p)f&&(p.nodeTag=f),a!==null&&(a===!1?p.resolver=null:p.resolver=a),h?p.setAttr(o,c,!0,l):p.setValue(t,c,o,s,l,u,d);else{let m=i&&i.nodeClass?i.nodeClass:xt;p=new m(i,e,h?null:t,o,a,f,null,l);let w=this._parsePosition(r);this._dict[e]=p,this._list.splice(w,0,p),c&&i&&i.backref&&i._onNodeInserted(p,w,null,u,d)}return d&&p.setValue(null,!1),p}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let 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 o=Array.isArray(e)?e:[e];if(o.length===0||t>=this._list.length)return;let i=this._list[t].label;if(o.length>1){let a=[...o].sort((c,d)=>c-d),s=a[0]<t?1:0,l=[];for(let c=a.length-1;c>=0;c--){let d=a[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(i);u<0&&(u=this._list.length),u+=s;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let a=o[0];if(a===t||a<0||a>=this._list.length)return;let s=this._list[a];this._list.splice(a,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(s,a),this._list.splice(t,0,s),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(s,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],o=e._list[t];if(!r.isEqual(o))return!1}return!0}};var Rh=kd(_u(),1);var Ou="::RSLV:",Xa=new Map,Za=new Map,Ka=new WeakMap,Te=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Jn=class extends de{constructor(e){super({asBag:!1}),Ka.set(this,e)}get payload(){return Ka.get(this)}load(){throw new Te("This resolver is opaque; local execution is unavailable")}};function Ru(n,{module:e,name:t,encode:r,decode:o}){if(!(n.prototype instanceof de)||n===Jn||typeof e!="string"||!e||typeof t!="string"||!t||typeof r!="function"||typeof o!="function")throw new TypeError("registerResolver requires a BagResolver subclass, module, name and adapters");let i=JSON.stringify([e,t]);if(Xa.has(i)&&Xa.get(i).cls!==n)throw new TypeError(`Resolver ${e}.${t} is already registered`);if(Za.has(n)&&Za.get(n).key!==i)throw new TypeError("A resolver class cannot own two wire identities");let a={cls:n,module:e,name:t,encode:r,decode:o,key:i};Xa.set(i,a),Za.set(n,a)}function Nh(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 Te("Invalid resolver description")}function Ih(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 Te("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))Ih(t,e);e.delete(n)}}function si(n){if(Ka.has(n))return Ka.get(n);let e=Za.get(n.constructor);if(!e)throw new Te(`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 Nh(r),Ih(r),Ou+JSON.stringify(r)}function Ja(n){if(typeof n!="string"||!n.startsWith(Ou))return null;let e=n.slice(Ou.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Jn(n);let t;try{t=JSON.parse(e)}catch{throw new Te("Invalid resolver JSON or signed token")}Nh(t);let r=Xa.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new Jn(n);let o=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(o instanceof r.cls))throw new Te("Resolver decoder returned an incompatible instance");return o}function Qa(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof de?si(t):t]))}function Bu(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,Ja(t)??t]))}var kt="__cls";function Qn(n,e){return n!==null&&n.tytxSuffix===e?n:oi(e)}function _y(n){let e=n.tytxSuffix,t=Object.entries(pt(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new Te(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new Te(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function $u(n,e){let t=pt(n);if(!Object.hasOwn(t,e))throw new Te(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function Mu(n,e){return n===e?null:_y(n)}function*Bh(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let o=t.getValue(!0);!t.resolver&&o instanceof k&&(yield*Bh(o,r))}}function yy(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 o=e.replace(/\.000Z$/,"Z");return t&&!r?o.slice(o.indexOf("T")+1):o}function eo(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function xr(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(xr):eo(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,xr(t)])):n}function Pu(n){if(!eo(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 Oh=!1,k=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new ai,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Pu(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 xt}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(o=>o)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!0){let[o,i]=this._htraverseBefore(e);if(o===null)return[null,null];if(i.length===0)return[o,""];for(;i.length>1&&o instanceof n;){let a=i[0];if(a==="#parent"){if(o.parent===null||o.parent===void 0)break;i.shift(),o=o.parent;continue}let s=o._nodes.get(a);if(!s)break;let l=s.getValue(r);if(l instanceof n)i.shift(),o=l;else if(t){let u=o.createChildBag();s.setValue(u,!0,null,!0,!0,"autocreate"),i.shift(),o=u}else break}if(!t)return i.length>1?[null,null]:[o,i[0]];for(;i.length>1;){let a=i.shift();if(a.startsWith("#"))throw new li("Not existing index in #n syntax");let s=o.createChildBag();o._nodes.set(a,s,">",null,o,null,!1,!0,"autocreate"),o=s}return[o,i[0]]}get(e,t=null,r=!0,o={}){if(!e)return this;if(e==="#parent")return this.parent;let i=null;e.includes("?")&&([e,i]=e.split("?",2));let a=this._nodes.get(e);return a?a.getValue(r,i,o):t}getItem(e,t=null,r=!1,o={}){if(!e)return this;let[i,a]=this._htraverse(e,!1,r);return i instanceof n?i.get(a,t,r,o):t}setItem(e,t,r=null,o=">",i=!1,a=!0,s=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,o,r,f,c,i,a,s,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let o=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(o,r,null,t),o}return null}pop(e,t=null,r=null){let o=this.popNode(e,r);return o?o.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,o]=this._htraverse(e,!1,!0);if(!r||!o)return null;let i=r._nodes.get(o);if(!i)return null;try{return r._pop(o,t)}finally{i.parentBag===r&&r._nodes._dict[i.label]!==i&&(i.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,r=!1,o=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[i,a]=this._htraverse(e,r,t);if(i instanceof n&&a){let s=i._nodes.get(a);if(s)return s;if(r)return i._nodes.set(a,o,">",null,i,null,!1,!0,"autocreate"),i._nodes.get(a)}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 o of this)o.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,o=null,i=null,a=null,s=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:o,attrs_diff:i,evt:r,reason:a,fired:s});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,o,i,a,s)}_onNodeInserted(e,t,r=null,o=null,i=!1){let a=e.parentBag,s=e.getValue(!0);a!==null&&a.backref&&s instanceof n&&s.setBackref(e,a),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:o,fired:i});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],o,i)}_onNodeDeleted(e,t,r=null,o=null){for(let i of Object.values(this._delSubscribers))i({node:e,pathlist:r,ind:t,evt:"del",reason:o});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],o))}_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:o=null,delete:i=null,any:a=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||a),this._subscribe(e,this._insSubscribers,o||a),this._subscribe(e,this._delSubscribers,i||a)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=!1,insert:o=!1,delete:i=!1,any:a=!1}=t;(r||a)&&delete this._updSubscribers[e],(o||a)&&delete this._insSubscribers[e],(i||a)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,t=null,r=!0){let o=n.prototype.getNode.call(this,e,!0,!0);o&&o.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let o=this.getNode(e);return o?o.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 o=r.value;if(o instanceof n){if(o.getItem(e)===t)return r}else if(o&&o.get&&o.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,o=!1){let i=t===void 0,a=r&&typeof t=="string"?t.toLowerCase():t,s=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(i||d==a)return c}if(c._value instanceof n)if(o){let d=s(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=s(c);if(d)return d}return null};return s(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 o=r.getValue(!0);if(o!=null&&!(e&&o===0)&&!(t&&o===""))return!1}return!0}query(e=null,t=null,r=!1,o=!1,i=!0,a=!0,s=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[h,p]=e.split(":");u=this.getItem(h),e=p}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,p,m,w,b)=>{if(p==="#k")return h.label;if(p==="#p")return m;if(p==="#n")return h;if(typeof p=="function")return p(h);if(p==="#v"){let _=b();return w&&_ instanceof n?null:_}else if(p.startsWith("#v.")){let _=p.split(".").slice(1).join("."),y=b();return y&&y.getItem?y.getItem(_):null}else{if(p==="#__v")return h.getValue(!0);if(p.startsWith("#a")){let _=p.includes(".")?p.split(".").slice(1).join("."):null;return h.getAttr(_)}else{let _=b();return _&&_.getItem?_.getItem(p):null}}};function*f(){let h=0;function*p(m,w){for(let b of m._nodes){let _=w?`${w}.${b.label}`:b.label,y=!1,E,S=()=>(y||(E=b.getValue(l),y=!0),E);if((i&&a||(S()instanceof n?a:i))&&(t===null||t(b))&&(yield c.length===1?d(b,c[0],_,o,S):c.map(N=>d(b,N,_,o,S)),h++,s!==null&&h>=s))return;if(o){let N=S();if(N instanceof n&&(yield*p(N,_),s!==null&&h>=s))return}}}yield*p(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,o)=>{for(let i of r._nodes){let a=o?`${o}.${i.label}`:i.label,s=i.getValue(!1);s instanceof n?t(s,a):e.push([a,s])}};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 o=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){if(!o||o.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let i=[...o];if(i.length&&Array.isArray(i[0])){let a=i[0].length,s=[];for(let l=0;l<a;l++)s.push(i.map(u=>u[l]));return s}return[i]}return[...o]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",o=e.map(i=>`${r}${i}`).join(",");return this.digest(o,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 o=i=>{let a=0,s=!1;for(let l of this.query(i,r)){if(l==null||l===""){s=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}a+=l}return t&&s?null:a};return e.includes(",")?e.split(",").map(i=>o(i.trim())):o(e)}sort(e="#k:a"){let t=(o,i)=>o==null?[-1,""]:i&&typeof o=="string"?[0,o.toLowerCase()]:[0,o],r=(o,i)=>o[0]!==i[0]?o[0]-i[0]:o[1]<i[1]?-1:o[1]>i[1]?1:0;if(typeof e=="function")this._nodes._list.sort((o,i)=>{let a=e(o),s=e(i);return a<s?-1:a>s?1:0});else{let o=e.split(",");o.reverse();for(let i of o){let a,s;i.includes(":")?[a,s]=i.split(":",2):(a=i,s="a"),a=a.trim(),s=s.trim();let l=s==="d"||s==="D",u=s==="a"||s==="d",c;if(a.toLowerCase()==="#k")c=d=>t(d.label,u);else if(a.toLowerCase()==="#v")c=d=>t(d.value,u);else if(a.toLowerCase().startsWith("#a.")){let d=a.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof n?f.getItem(a):f?f[a]: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(o=>o 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 o=new Er({callback:t,...r});this.setResolver(e,o)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!1,o=!1){let i={};for(let a of this._nodes){let s=a.value;if(o&&s==null)continue;let l=a.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),r&&s instanceof n&&(s=n.prototype.asDict.call(s,e,t,r,o)),Object.defineProperty(i,l,{value:s,enumerable:!0,writable:!0,configurable:!0})}return i}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 o=r.getValue(!e);o instanceof n&&(o=o.deepcopy(e));let i=new t.nodeClass(t,r.label,o);i.setAttr({...r.attr},!1,!1,!1),i.nodeTag=r.nodeTag,i.xmlTag=r.xmlTag,t._nodes._list.push(i),t._nodes._dict[i.label]=i}return t}update(e,t=null,r=null,o=!1){if(!(e instanceof n)){for(let i in e){let a=e[i];(!o||a!==null||!this._nodes.has(i))&&this.setItem(i,a,null,">",!1,!1,r,!1,r!==!1)}return}for(let i of[...e]){let a=i.label,s=t==="static"?i.resolver:null,l=s?null:i.getValue(),u=i.attr.__replace;delete i.attr.__replace;let c=this._nodes.get(a);if(c)if(c.setAttr(i.attr,r===null?!0:r,!0,!1),i.nodeTag!=null&&(c.nodeTag=i.nodeTag),i.xmlTag!=null&&(c.xmlTag=i.xmlTag),s)c.resolver=s,c.setValue(null,r===null?!0:r,null,null,!1,r);else{i.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,o):(!o||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(a,s||l,i.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=i.nodeTag,d.xmlTag=i.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,o=null,i=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let a=new this.nodeClass(this,e,null,r,o,i,null,!1);return t instanceof de?a.resolver=t:a._value=t,this._nodes._dict[e]=a,this._nodes._list.push(a),a}fillFrom(e=null,t={}){let r=Pu(t);if(e!=null&&!eo(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let o=this.createChildBag(),i=new Set,a=(s,l,u)=>{if(i.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);i.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let p=h;r&&(eo(p)||Array.isArray(p))&&(p=this.createChildBag(),a(p,h,`${u}[${JSON.stringify(f)}]`)),s._appendLiteral(f,p)}}finally{i.delete(l)}};return e!=null&&a(o,e,"$"),this._replacePrepared(o)}_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 o=r.getValue(!0);o instanceof n&&o.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:o={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let i=(a,s)=>{for(let l=0;l<a._nodes.length;l++){let u=a._nodes._list[l],c={...s};"_pathlist"in s&&(c._pathlist=[...s._pathlist,u.label]),"_indexlist"in s&&(c._indexlist=[...s._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=i(f,c);if(h)return h}}}return null};return i(this,o)}*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 o=t?`${t}.${r.label}`:r.label;yield[o,r];let i=r.getValue(e);i instanceof n&&(yield*i._iterNodesWithPaths(e,o))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,o=0,i=new Map([["[]",this.constructor]]);for(let[a,s]of Bh(this)){let l=a.slice(0,-1),u=JSON.stringify(a),c=JSON.stringify(l),d=s.getValue(!0),f,h=null;if(s.resolver)f=si(s.resolver);else if(d instanceof n){let w=d.constructor,b=w.tytxSuffix;i.set(u,w),h=Mu(w,Qn(i.get(c),b)),f=`::${b}`}else d===null?f="::NN":f=xr(d);if(s.attr&&Object.hasOwn(s.attr,kt))throw new Te(`node '${a}': the attribute '${kt}' is reserved for the Bag class name`);let p=Qa(xr(s.attr));h!==null&&(p[kt]=h);let m=s.nodeTag;t?(yield[l.length?r[c]:null,s.label,m,f,p],d instanceof n&&(r[u]=o,e[o]=a,o++)):yield[l,s.label,m,f,p]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),o=this.constructor.tytxSuffix;if(e==="json")return`${r}::${o}`;if(e==="msgpack")return xa(new vt(4,new TextEncoder().encode(`${o}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let i={};t={rows:[...this._nodeFlattener(i)],paths:i}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,o=Mu(r,Qn(null,r.tytxSuffix));return o!==null&&(t[kt]=o),t.rows=t.rows.map(([i,a,s,l,u])=>[xr(i),xr(a),xr(s),l,u]),t.paths&&(t.paths=xr(t.paths)),L(t)}static fromTytx(e,t="json",r={}){if(eo(t)&&(r=t,t="json"),Pu(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 o=j(e,t==="json"?null:t);if(o instanceof n)return o;if(!eo(o)&&!Array.isArray(o))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(o,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Qn(null,t));let r=j(e);if(!r||!Array.isArray(r.rows))throw new Te("Invalid TYTX Bag: expected rows");let o=r.paths,i=o!=null,a=Object.hasOwn(r,kt)?$u(t,r[kt]):Qn(null,t),s=new a,l=new Map([["[]",s]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new Te("Invalid TYTX Bag row");let[c,d,f,h,p]=u,m=c??"";if(i){if(c!==null&&!Object.hasOwn(o,c))throw new Te(`Unknown TYTX parent reference: ${c}`);m=c===null?"":o[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new Te("Invalid TYTX parent path");let w=JSON.stringify(m);if(!l.has(w))throw new Te(`Missing or undecodable TYTX parent branch: ${m}`);let b=l.get(w),_=JSON.stringify([...m,d]),y=h,E=Ja(y),S=Bu(p),x=Object.hasOwn(S,kt)?S[kt]:null;if(delete S[kt],y instanceof n){let O=y.constructor.tytxSuffix,$=x!==null?$u(O,x):Qn(b.constructor,O);y=new $,l.set(_,y)}else if(x!==null)throw new Te(`node '${_}': the attribute '${kt}' is reserved for the Bag class name of a branch`);let N=b._appendLiteral(d,E?null:y,S,E);N.nodeTag=f??null}return s}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:o=null,selfClosedTags:i=null}=e,a=this._bagToXml(i,t);return o===!0?a=`<?xml version='1.0' encoding='${r}'?>
|
|
32
32
|
${a}`:typeof o=="string"&&(a=`${o}
|
|
33
33
|
${a}`),a}_bagToXml(e=null,t=!1,r=0){let o=[];for(let i of this._nodes)o.push((t?" ".repeat(r):"")+this._nodeToXml(i,e,t,r));return o.join(t?`
|
|
34
|
-
`:"")}_nodeToXml(e,t=null,r=!1,o=0){let i=e.xmlTag||e.nodeTag||e.label,a=this._sanitizeTag(i),s=[];if(a!==i&&s.push(`_tag="${this._escapeAttr(i)}"`),e.resolver&&s.push(`_resolver="${this._escapeAttr(
|
|
34
|
+
`:"")}_nodeToXml(e,t=null,r=!1,o=0){let i=e.xmlTag||e.nodeTag||e.label,a=this._sanitizeTag(i),s=[];if(a!==i&&s.push(`_tag="${this._escapeAttr(i)}"`),e.resolver&&s.push(`_resolver="${this._escapeAttr(si(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(Qa(e.attr)))h!==null&&h!==!1&&h!==void 0&&s.push(`${f}="${this._escapeAttr(String(h))}"`);let l=s.length?" "+s.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,o+1);return f?r?`<${a}${l}>
|
|
35
35
|
${f}
|
|
36
|
-
${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`}if(u==null||u==="")return t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?
|
|
37
|
-
`)}toString(e=!0,t=null,r=""){t||(t=new Set);let o=[],i=[...this._nodes];for(let a=0;a<i.length;a++){let s=i[a],l=a===i.length-1,u=s.getValue(e),c="",d=s.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([
|
|
38
|
-
`)}},ii=class extends Error{constructor(e){super(e),this.name="BagException"}};ce.registerBagClass(x);xu(x,"X",n=>n._toTytxPayload(),n=>x._fromTytxPayload(n));Gr(x.tytxSuffix,{...ht(x.tytxSuffix),Bag:x});var Th=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 Ah(n){return n.endsWith("_")&&Th.has(n.slice(0,-1))?n.slice(0,-1):n}function Dh(n){let e=Ah(n);return e!==n?e:n.startsWith("_")&&Th.has(n.slice(1))?n.slice(1):n}function ai(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let o=e||n;if(!o)return o;if(o=Ah(o),t&&!e){let i=`${r}_`;o.startsWith(i)&&(o=o.slice(i.length)),o=`${t}:${o}`}return o}var Qn=Symbol("value"),Yr=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function Pe(n){return Object.entries(n||{}).filter(([e])=>!Yr.has(e)).map(([e,t])=>[Dh(e),t])}var Xe=class extends Et{constructor(e,t,r=null,o=null,i=null,a=null,s=null){super(e,t,r,o,i,a,s),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(o=>o.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(o=>t[o]!==void 0?t[o]: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 Pe(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(Qn,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(re(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 o=r.getAttr("datapath");o!=null&&(e=e==="."?o:o+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let o of e.split("."))if(o==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(o);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),o=r.indexOf("."),i=o===-1?r:r.slice(0,o),a=o===-1?"":r.slice(o+1),s;if(i==="FORM")s=this._findMarkedDatapathAncestor(!0,!1,t);else if(i==="ANCHOR")s=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(s=l.source.getNodeByAttr("nodeId",i),s==null)throw new Error(`#<id>: cannot resolve ${t}`)}return s.absDatapath(a?`.${a}`:".")}_findMarkedDatapathAncestor(e,t,r){let o=this;for(;o!=null;){let a=o.getAttr()||{};if(e&&(a.formId!=null||a.form===!0)||t&&"_anchor"in a)return o;o=o.parentNode}let i=e?"FORM":"ANCHOR";throw new Error(`#${i}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let o=this.data,i=this.absDatapath(e);return r&&o.getItem(i)==null&&o.setItem(i,t),o.getItem(i,t)}setRelativeData(e,t,{attributes:r=null,fired:o=!1,reason:i=null}={}){let a=this.data,s=this.absDatapath(e);a.setItem(s,t,r,">",!1,!0,i===null?!0:i,o)}fireEvent(e,t=!0,{attributes:r=null,reason:o=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:o})}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})}},I=class n extends x{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return Xe}_setBuilderItem(e,t,r,...o){let i=t?.map(([s])=>[s,s._builder])||null;if(t)for(let[s,l]of t)s._builder=l;let a=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(r,...o)}catch(s){if(this.node(r)==null&&i)for(let[l,u]of i)l._builder=u;throw s}finally{this._insertingBuilder=a}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[r,o]of t)r._builder=o;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,o=(i,a)=>{if(r.has(i))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(i),t.push([i,a]);for(let s of i.getNodes()){let l=a,u=s._getMeta("subbuilder");u!=null&&(l=a._resolveSubbuilderReference(u,s.getAttr()||{},s.nodeTag)),t.push([s,l]);let c=s.getValue(!0);c instanceof n&&o(c,l)}};return o(this,e),t}};if((ht(I.tytxSuffix).SourceBag??I)!==I)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Gr(I.tytxSuffix,{...ht(I.tytxSuffix),SourceBag:I});function py(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 my=new Set(["then","toJSON"]),Ch=new WeakMap;function ae(n){return Ch.get(n)||n}function si(n){if(n==null)return n;n=ae(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function Nh(n,e){let t=e instanceof x,r=new Proxy(e,{get(o,i){if(typeof i=="symbol"||i.startsWith("_")||my.has(i))return Reflect.get(o,i,o);let a=n.schemaTag(i);if(t&&a)return Sh(n,o,a,t);if(i in o){let l=Reflect.get(o,i,o);return typeof l=="function"?l.bind(o):l}if(a)return Sh(n,o,a,t);let s=n.containerMethod(i);if(s)return(...l)=>n[s](n.wrapSource(o),...l)}});return Ch.set(r,e),r}function Sh(n,e,t,r){return(...o)=>{let{value:i,attrs:a}=py(o),s=r?n.bagCall(e,t,i,a):n.commandOnNode(e,t,i,a);return s.builder.wrapSource(s)}}function Nu(n,e,{transport:t="json"}={}){let r=j(n,t==="json"?null:t);if(!(r instanceof I))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Oh=/^[A-Za-z_][A-Za-z0-9_]*$/,gy=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),by=new Set(["framework","value","attribute"]),wy=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 Zr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function B(n,e){throw new TypeError(`${n}: ${e}`)}function Ft(n,e,t,r){Zr(n)||B(r,"must be an object");for(let o of Object.keys(n))e.includes(o)||B(r,`unknown field '${o}'`);for(let o of t)Object.hasOwn(n,o)||B(r,`missing field '${o}'`)}function Kr(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)=>Kr(t,`${e}[${r}]`));if(Zr(n))return Object.entries(n).forEach(([t,r])=>Kr(r,`${e}.${t}`));B(e,"must be lossless JSON data")}}function _y(n,e){let t="",r=!1;for(let o=0;o<n.length;o++){let i=n[o];if(i==="\\"){t+=i+(n[++o]??"");continue}i==="["&&(r=!0),!r&&i==="."&&!(e&16)?t+="[^\\n]":!r&&i==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&i==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=i,i==="]"&&(r=!1)}return t}function Xr(n,e,t=!1,r=null){if(n===null)return null;switch(Ft(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 Ft(n,["kind","name"],["kind","name"],e),r||B(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{Ft(n,["kind","dtype"],["kind","dtype"],e);let o=n.dtype;typeof o!="string"&&B(e,"dtype must be a string");let i=ti(o);return!i&&o!=="NN"&&B(e,`unknown dtype '${o}'`),{...n,test:s=>o==="NN"?s===null:o==="N"?fe(s)&&!["NaN","Infinity","-Infinity"].includes(s.toString()):i===Number?typeof s=="number"&&Number.isFinite(s)&&(o!=="L"||Number.isInteger(s)):i===String?typeof s=="string":i===Boolean?typeof s=="boolean":i===Date?s instanceof Date&&Number.isFinite(s.getTime()):i===Object?Zr(s)&&[Object.prototype,null].includes(Object.getPrototypeOf(s)):s instanceof i}}case"any":return{...n,test:o=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&B(e,"type requires string module/name");let o=`${n.module}.${n.name}`;if(o==="collections.abc.Callable")return{...n,test:a=>typeof a=="function",portable:!1};let i=wy.get(o);return i||B(e,`unsupported type '${o}'`),{...n,test:i}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&B(e,"union items must be non-empty");let o=n.items.map((i,a)=>Xr(i,`${e}.items[${a}]`,!0,r));return{...n,items:o,inputConstraint:o.some(i=>i.inputConstraint),test:i=>o.some(a=>a.test&&a.test(i))}}case"literal":return Array.isArray(n.values)||B(e,"literal values must be an array"),n.values.forEach((o,i)=>Kr(o,`${e}.values[${i}]`)),{...n,test:o=>n.values.some(i=>Object.is(i,o))};case"annotated":{Array.isArray(n.metadata)||B(e,"annotated metadata must be an array"),n.metadata.some(a=>!["regex","range","value"].includes(a?.kind))&&B(e,"unsupported annotation metadata kind");let o=Xr(n.base,`${e}.base`,!0,r),i=n.metadata.map((a,s)=>Xr(a,`${e}.metadata[${s}]`,!0,r));return{...n,base:o,metadata:i,inputConstraint:o.inputConstraint,test:a=>o.test(a)&&i.every(s=>!s.test||s.test(a))}}case"range":{for(let o of["ge","le","gt","lt"])Object.hasOwn(n,o)||B(e,`range missing '${o}'`);for(let o of["ge","le","gt","lt"])n[o]!==null&&(typeof n[o]!="number"||!Number.isFinite(n[o]))&&B(e,`${o} must be finite number or null`);return{...n,test:o=>typeof o=="number"&&(n.ge===null||o>=n.ge)&&(n.le===null||o<=n.le)&&(n.gt===null||o>n.gt)&&(n.lt===null||o<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&B(e,"regex requires pattern and non-negative integer flags");let o=n.flags&-59;o&&B(e,`unsupported Python regex flags ${o}`),n.flags&2&&B(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&B(e,"regex uses a non-portable construct or character class");let i="uy";n.flags&16&&(i+="s");let a;try{a=new RegExp(`(?:${_y(n.pattern,n.flags)})(?![\\s\\S])`,i)}catch(s){B(e,`invalid portable regex: ${s.message}`)}return{...n,test:s=>typeof s!="string"?!1:(a.lastIndex=0,a.test(s))}}case"value":return Kr(n.value,`${e}.value`),{...n};case"generic":{let o=Xr(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&B(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||B(e,"generic arguments must be an array");let i=n.arguments.map((a,s)=>Xr(a,`${e}.arguments[${s}]`,!0,r));return{...n,origin:o,arguments:i,inputConstraint:i.some(a=>a.inputConstraint),test:a=>o.test(a)&&yy(n.origin,i,a)}}case"arguments":B(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||B(e,"ellipsis is only valid as a nested descriptor"),{...n};default:B(e,`unknown annotation kind '${n.kind}'`)}}function yy(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((o,i)=>e[i].test(o)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(o=>!e[0]?.test||e[0].test(o)):r==="builtins.dict"?Object.entries(t).every(([o,i])=>(!e[0]?.test||e[0].test(o))&&(!e[1]?.test||e[1].test(i))):!1}function Rh(n,e){if(n===null)return null;if(typeof n!="string"&&B(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let o=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(o)&&B(e,`invalid cardinality item '${r}'`);let i=o.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);i||B(e,`invalid cardinality item '${r}'`);let[,a,s,l,u]=i;t.has(a)&&B(e,`duplicate tag '${a}'`);let c=0,d=1/0;o.includes("[")&&(o.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(s)),d<c&&B(e,`maximum ${d} is below minimum ${c}`),t.set(a,{min:c,max:d})}return t.has("*")&&t.size>1&&B(e,"wildcard '*' cannot be combined with named tags"),t}function Bh(n,e){if(n===null)return null;typeof n!="string"&&B(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let o=r.trim();o&&((!Oh.test(o)||t.has(o))&&B(e,`invalid or duplicate parent '${r}'`),t.add(o))}return t}function vy(n,e,t){if(n===null)return null;Ft(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||B(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")&&B(e,"invalid signature descriptor");let o=new Set,i=!1,a=!1,s=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return Ft(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Oh.test(l.name)||o.has(l.name))&&B(c,"invalid or duplicate parameter name"),o.add(l.name),(!gy.has(l.kind)||!by.has(l.role)||typeof l.has_default!="boolean")&&B(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&B(c,"default presence must equal has_default"),l.has_default&&Kr(l.default,`${c}.default`),i||=l.kind==="var_keyword",a||=l.kind==="var_positional",{...l,annotation:Xr(l.annotation,`${c}.annotation`,!1,t)}});return(i!==n.accepts_var_keyword||a!==n.accepts_var_positional)&&B(e,"variadic summary flags do not match parameters"),{...n,parameters:s}}function Ih(n,e,t,r){let o=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];Ft(n,o,[],e),n={...Object.fromEntries(o.map(i=>[i,null])),...n};for(let i of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[i]!==null&&typeof n[i]!="string"&&B(e,`${i} must be string or null`);return n._meta!==null&&(Zr(n._meta)||B(e,"_meta must be object or null"),Kr(n._meta,`${e}._meta`)),Rh(n.sub_tags,`${e}.sub_tags`),Bh(n.parent_tags,`${e}.parent_tags`),{...n,attributes:vy(n.attributes,`${e}.attributes`,r)}}function $h(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function Mh(n,e){let t={...e};for(let[r,o]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=o);return t._meta={...n._meta||{},...e._meta||{}},t}function Ph(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?Rh(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Bh(e.parent_tags,"resolved.parent_tags"):null,e}function Lh(n,e,t,r){if(t.get(n)===1&&B(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let o=e[n];o||B(r,`unknown abstract '${n}'`),t.set(n,1);let i={...o};for(let a of $h(o.inherits_from))i=Mh(Lh(a,e,t,r),i);return i=Ph(i),t.set(n,2),e[n]=i,i}function Iu({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let i of Object.keys(t))Lh(i,t,r,`abstracts.${i}.inherits_from`);let o={};for(let[i,a]of Object.entries(e)){let s={...a};for(let l of $h(a.inherits_from)){let u=t[l];u||B(`elements.${i}.inherits_from`,`unknown abstract '${l}'`),s=Mh(u,s)}o[i]=Ph(s)}return{abstracts:t,elements:o}}function Ou(n){Ft(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),Ft(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&B("document_format","expected builder_grammar version 1.1 or 1.2"),Ft(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&B("grammar.name","must be non-empty string");for(let o of["version","title","description"])n.grammar[o]!==null&&typeof n.grammar[o]!="string"&&B(`grammar.${o}`,"must be string or null");(!Zr(n.abstracts)||!Zr(n.elements))&&B("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&B("custom_types","requires version 1.2");let e=eo.fromJSON(n.custom_types??{}),t={};for(let[o,i]of Object.entries(n.abstracts))(!o||o.startsWith("_"))&&B("abstracts",`invalid public name '${o}'`),t[o]=Ih(i,`abstracts.${o}`,!1,e);let r={};for(let[o,i]of Object.entries(n.elements))(!o||o.startsWith("_"))&&B("elements",`invalid public name '${o}'`),r[o]=Ih(i,`elements.${o}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function Fh(n,e,t,r){let o=e.attributes;if(!o)return;let i={...r};t!=null&&(i.node_value=t);let a=new Set(o.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),s=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!o.accepts_var_keyword)for(let u of Object.keys(r))!a.has(u)&&!s.has(u)&&B(n,`unknown attribute '${u}'`);let l=e._meta?.component?o.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of o.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(i,u.name);!c&&!u.has_default&&B(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(i[u.name]))&&B(n,`invalid value for ${u.role} '${u.name}'`)}}var eo=class n{#e=new Map;#t=new Map;register(e,t,r){let o=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),i=o.has(t)?{kind:"type",module:"builtins",name:o.get(t)}:t;return this.#r(e,{kind:"annotated",base:i,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)||Ey.has(e))&&B("custom_types",`invalid, reserved or duplicate name '${e}'`),Ft(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))&&B(`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))&&B(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Kr(t,`custom_types.${e}`);let o=structuredClone(t),i=Xr(o,`custom_types.${e}`),a=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:a,enumerable:!0}),this.#e.set(e,o),this.#t.set(e,{...a,inputConstraint:!0,test:i.test}),a}resolve(e,t="custom_types"){return this.#t.has(e)||B(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||B(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Zr(e)||B("custom_types","must be an object");let t=new n;for(let[r,o]of Object.entries(e))t.#r(r,o);return t}},Ey=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 jh(n,e,t,r){let o=e?.attributes;if(o)for(let i of o.parameters){if(!i.annotation?.inputConstraint||i.role==="framework"||["var_keyword","var_positional"].includes(i.kind))continue;let a=i.role==="value"?t:r[i.name];a!==void 0&&(i.annotation.test(a)||B(n,`invalid input for '${i.name}' (custom type)`))}}function qh(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!Ru(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(Wt(n)&&Wt(e)){let r=structuredClone(n);for(let[o,i]of Object.entries(e))i!==null&&Object.defineProperty(r,o,{value:qh(r[o],i,[...t,o]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function Ru(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>Ru(t,e[r])):Wt(n)&&Wt(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&Ru(n[t],e[t])):!1}function Wt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function Bu(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(Bu);return}if(Wt(n)){Object.values(n).forEach(Bu);return}throw new TypeError("collection must contain only finite JSON values")}}var Yt=class n{#e;constructor(e){Bu(e);let t=["document_format","grammar","abstracts","elements"];if(!Wt(e)||Object.keys(e).some(o=>![...t,"custom_types"].includes(o))||t.some(o=>!Object.hasOwn(e,o)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!Wt(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 o of["grammar","abstracts","elements"])if(!Wt(e[o]))throw new TypeError(`${o} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!Wt(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=qh(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 Jr=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,[o,i]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,i,t);let a=this.getRender(r),s;return[s,i]=a._handleMeta(e,i),e._getMeta("subbuilder")||(i=a.adaptAttrs(i)),e.value instanceof I&&(o=this.renderChildren(e.value,t)),a.renderedItem(e,o,i,{tag:s,...t})}renderChildren(e,t={}){let r=[];for(let o of e.getNodes()){let i=this.render(o,t);i!==null&&(Array.isArray(i)?r.push(...i):r.push(i))}return r}_renderComponent(e,t,r){let[o,i,a,s]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,o,a,s,r);if(i==null)return[];if(!(i instanceof x))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${i?.constructor?.name||typeof i}`);return i.getNodes().map(l=>this._expandBlock(e,o,a,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,o=r.componentMethod(e.nodeTag),i=o&&r[o];if(typeof i!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let a=t.iterate;delete t.iterate,delete t.store;let s=e.getAttr("iterate")||e.getAttr("store");s!=null?(e.pointerType(s)&&(s=s.slice(1)),s.startsWith(".")&&(s=e._composeRelativeDatapath(s,s))):s=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[i,a,s,t]}_expandBlock(e,t,r,o,i){let a=e.builder._expansionRoot(r);t.call(e.builder,si(a),o);let s=a.getNodes();if(s.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${s.length} root nodes`);let l={...i,depthOffset:this._nodeDepth(e,i.depthOffset||0)};return this.render(s[0],l)}preprocess(e){return e}renderedItem(e,t,r,o){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,o]=e._getMeta("render_tag,render_attributes"),i=ai(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!i)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return o&&(t={...t,...o}),[i,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,r={}){let o=this._composeStringFragments(e);if(t==null)return o;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(o),null;if(typeof t.write=="function")return t.write(o),null;if(typeof t=="function")return t(o),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 o=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(o-1,0)+t}};var Qr=class extends Jr{static mode="xml";renderedItem(e,t,r,{tag:o,pretty:i=!1,depthOffset:a=0}={}){let s=this._formatAttrs(r),l=i?" ".repeat(this._nodeDepth(e,a)):"",u=i?`
|
|
39
|
-
`:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${o}${s}>${u}${c}${l}</${o}>${u}`}return t==null?`${l}<${o}${s}></${o}>${u}`:`${l}<${o}${s}>${this._escapeText(t)}</${o}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let o=this._composeStringFragments(e);return r===!0?o=`<?xml version='1.0' encoding='UTF-8'?>${o}`:typeof r=="string"&&(o=r+o),super.finalize(o,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var Uh={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 Vh(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function ky(n){let e=Object.create(null),t=(r,o)=>{let i=r.toLowerCase(),a=e[i];if(a!==void 0&&a!==o)throw new Error(`container '${r}' is already tied to implementation method '${a}' (cannot rebind to '${o}')`);e[i]=o};for(let r of Vh(n))if(Object.hasOwn(r,"containers"))for(let o of r.containers||[])t(o,o);return e}function li(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 ui="_root_",ci="_root_",zh=new Set(["destination","func","value","_on_start"]),Ze=class n{static _sourceClass=I;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(ci,new x),this.data=this._dataroot.getItem(ci),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(ui,new t(null,this)),this.source=this._sourceroot.getItem(ui)}wrapSource(e){if(e=ae(e),!(e instanceof I)&&!(e instanceof Xe))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=Nh(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 Yt(t.toDocument()).update(e):new Yt(e),o=Ou(r.toDocument()),i=Iu(o),a=li(i.elements);this._classCollection=r,this._classSchema=i.elements,this._abstracts=i.abstracts,this._tagNames=a}static{this.defineGrammar(Uh)}get _containers(){return ky(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??=li(this.schema):this.constructor._tagNames??=li(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let o=`${this.constructor._name}_`;return t.startsWith(o)&&this.schemaTagNames[t.slice(o.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,o=t?new Yt(e):new Yt(r.toDocument()).update(e),i=Ou(o.toDocument()),a=Iu(i),s=li(a.elements);return this._collection=o,this._schemaOverride=a.elements,this._tagNamesOverride=s,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;jh(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let o=this.schemaTag(e);if(!o)throw new Error(`unknown element '${e}'`);return Fh(o,this.schema[o],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:o}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let i=t!==void 0?t:e.value instanceof I?null:e.value;this.validateNodeValues(e.nodeTag,i,r||e.getAttr?.()||{});let a=this.schema[this.schemaTag(e.nodeTag)],s=o||(e.value instanceof I?e.value.getNodes().map(l=>l.nodeTag):null);return s&&this._validateChildren(e.nodeTag,a,s,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let o=this.schemaTag(e);if(!o)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(i=>typeof i!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(o,this.schema[o],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let o=this.schema[r];if(!this._countsForGrammar(o))return!0;let i=o._parentSpec;if(i==null||i.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let a=this.schemaTag(t);if(!a)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,o,a),!0}bagCall(e,t,r,o){return this.setChild(e,t,r,o)}commandOnNode(e,t,r,o){if(e=ae(e),e.value instanceof I)return this.setChild(e.value,t,r,o);let i=e.value,a=new e.parentBag.constructor(null,e.builder||this),s=this.setChild(a,t,r,o,e);return this.promoteNodeValue(e,i,a),s}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,o,i=null){let a={...o},s=this.schema[t];if(!s)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,a);let l=s._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,a,t))||this,d=r instanceof I?r._builderBindingPlan(c):null,f=i?.rootBuilder||e.root._builder||this;if(a.nodeId!=null&&f.source.getNodeByAttr("nodeId",a.nodeId))throw new Error(`Duplicate nodeId '${a.nodeId}'`);r instanceof I&&this._validateChildren(t,s,r.getNodes().map(y=>y.nodeTag),!1);let h=i||e.parentNode,m=h?.nodeTag?this.schema[h.nodeTag]:null;if(m&&!h._getMeta("subbuilder")&&this._countsForGrammar(s))this._validateParent(t,s,h.nodeTag),this._validateChildren(h.nodeTag,m,[...e.getNodes().map(y=>y.nodeTag),t],!1);else if(!m&&!h?._getMeta("subbuilder")&&s._parentSpec!=null&&this._countsForGrammar(s))throw new Error(`'${t}' requires a declared parent`);s._meta&&!("_meta"in a)&&(a._meta=s._meta),s.ns&&!("ns"in a)&&(a.ns=s.ns);let p=a.node_position;delete a.node_position;let w=a.node_label;delete a.node_label;let b;if(m?.collection_key){if(w!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);b=this._collectionLabel(m.collection_key,t,a)}else{let y=m?._subSpec?.get(t);if(y&&y.max===1){if(w!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);b=t}else b=w||s.node_label||this._autoLabel(e,t)}if(e.node(b)!=null)throw new Error(`duplicate node label '${b}'`);return e._setBuilderItem(c,d,b,r,a,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 o=t._parentSpec;if(!(o==null||o.has("*")||!this._countsForGrammar(t))&&!o.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,o){let i=t._subSpec;if(i==null||i.has("*")||t._meta?.subbuilder)return[];let a=new Map;for(let s of r){let l=this.schema[s];if(l&&!this._countsForGrammar(l))continue;let u=i.get(s);if(!u)throw new Error(`'${s}' not allowed as child of '${e}'`);let c=(a.get(s)||0)+1;if(a.set(s,c),c>u.max)throw new Error(`too many '${s}' in '${e}'`)}return o?[...i].filter(([s,l])=>(a.get(s)||0)<l.min).map(([s])=>s):[]}_collectionLabel(e,t,r){let o=i=>{if(r[i]===null||r[i]===void 0)throw new Error(`'${t}': collection key needs attribute '${i}'`);return String(r[i])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(i,a)=>o(a)):o(e)}validateSource(){let e=[],t=(r,o="")=>{for(let i of r.getNodes()){let a=o?`${o}.${i.label}`:i.label,s=i.builder;s.validateCustomTypes(i);let l=s.schema[i.nodeTag];if(l&&!i._getMeta("data_element,subbuilder,component").some(Boolean)){let u=i.value instanceof I?i.value.getNodes().map(d=>d.nodeTag):[],c=s._validateChildren(i.nodeTag,l,u,!0);c.length&&e.push([a,c])}i.value instanceof I&&t(i.value,a)}};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={},o=e.runtimeToEvaluate(),i=new Set(o.keys()),a=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...o])if(!(typeof c!="string"||!re(d)))for(let f of Lt(e,d))o.has(f)||o.set(f,a.get(f));let s=e._getMeta("data_element");for(let[c,d]of o){if(d instanceof ce){t.set(c,d.resolve());continue}let f=typeof c=="string"?re(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)),!s&&!h.includes("?")&&c===Qn){let m=this.data.getNode(h);m&&Object.assign(r,m.getAttr("_wdg"))}}let l=wh(o,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Qn);l.delete(Qn);for(let c of l.keys())i.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,o,i){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let o=(typeof t=="function"?t:t.constructor)[e];if(typeof o=="function")return o}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[o,i]of Object.entries(t))zh.has(o)||(r[o]=i);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[o,i]of Object.entries(t))o!=="destination"&&o!=="value"&&!o.startsWith("_")&&(r[o]=i);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 o of r.getNodes())o._getMeta("data_element")&&e.push(o),o.value instanceof I&&t(o.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 s of Vh(this.constructor))if(Object.hasOwn(s,"components"))for(let l of s.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},r={};for(let[s,l]of Object.entries(e))t[s]={sub_tags:"",_meta:{component:!0}},r[s.toLowerCase()]=l;let o=li(t),i=this._collection||this.constructor._classCollection,a=i.toDocument();a.abstracts={},a.elements=Object.fromEntries(Object.keys(e).map(s=>[s,t[s]])),this._collection=new Yt(i.toDocument()).update(a),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=o}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(ui,new t(null,this),e?{datapath:e}:null),r.getItem(ui)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Qr(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),o=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=o,o}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 o=this.getRenderer(e);if(t===!1&&o.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let i=t===!1?null:t||this._defaultTargets.get(o.mode)||null,a={...i?.renderOpts,...r};return o.finalize(this.materialize(e,a),i,a)}};Ze._registry=new Map;var Ty=new Set(["short","medium","long","full"]),Ay=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Dy(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 Sy(n,e,t,r){let o=e.match(Ay)||[];if(o.join("")!==e)throw new RangeError("Unclosed format literal");let i=(c,d=2)=>String(c).padStart(d,"0"),a=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>i(n.getUTCFullYear()%100),yyyy:()=>i(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>i(n.getUTCMonth()+1),MMM:()=>a({month:"short"}),MMMM:()=>a({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>i(n.getUTCDate()),EEE:()=>a({weekday:"short"}),EEEE:()=>a({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>i(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>i(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>i(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>i(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return o.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 Hh(n,{format:e,mask:t,locale:r,dtype:o,places:i}={}){let a=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||i!=null))if(typeof n=="number"||fe(n))a=Ny(n,{format:e,locale:r,places:i});else{let s=Dy(n,o);if(Ty.has(e)){let l={timeZone:"UTC"};s!=="H"&&(l.dateStyle=e),s!=="D"&&(l.timeStyle=e),a=new Intl.DateTimeFormat(r||void 0,l).format(n)}else a=Sy(n,String(e),r||void 0,s)}return t==null?a:String(t).replaceAll("%s",()=>a)}function Cy({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 Ny(n,e={}){if(typeof n!="number"&&!fe(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,Cy(e));if(fe(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(fe(n)?n.toString():n)}var Iy=new Set(["style","script"]),Oy=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"]),Gh=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"]),di=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),Wh=n=>n===!0?"true":n===!1?"false":String(n),Za=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function Ry(n){if(Gh.has(n))return!0;for(let e of Gh)if(n.startsWith(`${e}_`))return!0;return!1}function By(n){let e=new Map;if(!n)return e;let t=[],r=0,o=null,i=!1,a=!1,s=0,l=String(n);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(a){c==="*"&&d==="/"&&(a=!1,u+=1);continue}if(i){i=!1;continue}if(c==="\\"){i=!0;continue}if(o){c===o&&(o=null);continue}c==='"'||c==="'"?o=c:c==="/"&&d==="*"?(a=!0,u+=1):"([{".includes(c)?s+=1:")]}".includes(c)&&s>0?s-=1:c===";"&&s===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 en=class extends Jr{static mode="html";renderedItem(e,t,r,{tag:o,xml:i=!0,pretty:a=!1,depthOffset:s=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=Hh(t,{format:c,mask:d,places:h,dtype:m,locale:this._displayLocale(e,f)}));let w=this._formatAttrs(p);if(l){if(!Object.hasOwn(r,"id")){let E=this.builder.targetId(e);E!==null&&(w+=` id="${this._htmlAttrValue(E)}"`)}for(let[E,N]of Object.entries(e.getAttr()))e.pointerType(N)&&(w+=` data-${this.adapt(E)}-pointer="${this._htmlAttrValue(e.absDatapath(N))}"`)}let b=a?" ".repeat(this._nodeDepth(e,s)):"",_=a?`
|
|
40
|
-
`:"";if(e._getMeta("void"))return`${b}<${o}${w}${i?"/":""}>${_}`;if(Array.isArray(t)){let E=this._composeStringFragments(t);return`${b}<${o}${w}>${_}${E}${b}</${o}>${_}`}if(t==null)return`${b}<${o}${w}></${o}>${_}`;let y=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Iy.has(o)?String(t):this._escapeText(t);return`${b}<${o}${w}>${y}</${o}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let o=r.getAttr("locale");if(o==null)continue;let i=r.pointerType(o)?r.data.getItem(r.absDatapath(o)):o;if(i)return i}}adaptAttrs(e){let t={},r={};for(let[i,a]of Object.entries(e||{}))if(i.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(i)]=a;else if(i==="dtype")t.dtype=a;else{if(this.builder.constructor.retainedAttrPrefixes.some(s=>i.startsWith(s)))continue;this._isStyleContribution(i)?r[i]=a:t[i]=a}let o=this._adaptStyle(r);return o&&(t.style=o),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||di.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&di.has(t)||Ry(e)}_adaptStyle(e){let t=By(e.style),r=new Map,o=new Map;for(let[i,a]of Object.entries(e))if(i!=="style")if(i.startsWith("style_"))t.set(i.slice(6).replaceAll("_","-"),Wh(a));else if(di.has(i))r.set(i,a);else{let s=i.indexOf("_"),l=s<0?i:i.slice(0,s);s>=0&&di.has(l)?(o.has(l)||o.set(l,{}),o.get(l)[i.slice(s+1)]=a):t.set(i.replaceAll("_","-"),Wh(a))}for(let i of di)(r.has(i)||o.has(i))&&this[`_macro_${i}`](r.get(i),o.get(i)||{},t);return[...t].map(([i,a])=>`${i}: ${a}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,o]of Object.entries(e||{}))Oy.has(r)?o&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(o)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_macro_rounded(e,t,r){let o=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[i,a]of Object.entries(t))if(i==="top"||i==="bottom")o[`${i}_left`]=a,o[`${i}_right`]=a;else if(i==="left"||i==="right")o[`top_${i}`]=a,o[`bottom_${i}`]=a;else if(["top_left","top_right","bottom_left","bottom_right"].includes(i))o[i]=a;else throw new TypeError(`rounded: unknown sub-kwarg '${i}'`);for(let[i,a]of Object.entries(o))r.set(`border-${i.replaceAll("_","-")}-radius`,Za(a))}_macro_transform(e,t,r){let o=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?o.push(`rotate(${a}deg)`):i==="scale"||i==="translate"?o.push(`${i}(${a})`):i==="translate_x"?o.push(`translateX(${Za(a)})`):i==="translate_y"?o.push(`translateY(${Za(a)})`):i==="skew_x"?o.push(`skewX(${a}deg)`):i==="skew_y"?o.push(`skewY(${a}deg)`):o.push(`${i.replaceAll("_","-")}(${a})`);o.length&&r.set("transform",o.join(" "))}_macro_filter(e,t,r){let o=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?o.push(`hue-rotate(${a}deg)`):i==="blur"?o.push(`blur(${Za(a)})`):i==="drop_shadow"?o.push(`drop-shadow(${a})`):o.push(`${i.replaceAll("_","-")}(${a})`);o.length&&r.set("filter",o.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[o,i]of Object.entries(t))r.set(`transition-${o.replaceAll("_","-")}`,String(i))}_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[o,i]of Object.entries(t))r.set(`box-shadow-${o.replaceAll("_","-")}`,String(i))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var $y=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 Ka(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[$y.has(e)?e.replaceAll("_","-"):e,t]))}var tn=class extends Qr{static mode="svg";adaptAttrs(e){return Ka(e)}};var Yh={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 _r=class extends Ze{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(Yh)}get renderer_html(){return new en(this)}};Ze.registerBuilder(_r);var Xh={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 yr=class extends Ze{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(Xh)}get renderer_svg(){return new tn(this)}};Ze.registerBuilder(yr);function kt(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(ae(n)instanceof Xe||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(o=>[o.staticValue,o.getAttr()]):Object.values(n);for(let o of r)kt(o,e);e.delete(n)}var fi=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,o=i=>{for(let a of i.getNodes()){let s=a.getAttr("__ref");if(s){if(r.has(s))throw new Error("Duplicate Source reference");let l=this.entries.get(s);if(e!==this.sourceRoot&&l&&l.node!==a&&!t.has(l.node))throw new Error("Duplicate Source reference");r.set(s,a)}a.value instanceof I&&o(a.value)}};o(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 ee(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var Ke=class{constructor(e){this.gramlot=e}};var rn=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:o}){super(r),this.code=e,this.remoteName=t,o!==void 0&&(this.details=o)}},hi=class extends Ke{constructor(e,{rpcUrl:t,closeUrl:r,document:o,transport:i}){super(e),this.transport=i===!1?null:i??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:o,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(kt(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let o=ee(),i=j(this.transport.callSync(F({id:o,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(i.id!==o)throw new Error("rpc response id mismatch");if(i.error)throw new rn(i.error);return i.value}async call(e,t,r={},o={}){return(await this.callEnvelope(e,t,r,o)).value}async callEnvelope(e,t,r={},{signal:o=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);kt(r);let i=ee(),a=F({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),s=o?[this.gramlot.abort.signal,o]:[this.gramlot.abort.signal],l=s.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of s)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(i),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(i,u);try{let f=j(await Promise.race([this.transport.call(a,u.signal),d]));if(f.id!==i)throw new Error("rpc response id mismatch");if(f.error)throw new rn(f.error);return f}finally{this.remoteRequests.delete(i);for(let f of s)f.removeEventListener("abort",c)}}};var Ja=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 o=new URL(t,r.baseURI);o.protocol=o.protocol==="https:"?"wss:":"ws:",this.endpoint=o.href,this.origin=this.window.location.origin,this.parent=this.frames.parent?.window??null,this.frames.registerChannel("server",{changed:i=>this.peerChanged(i),disconnected:i=>{i.parent?this.fail(new Error("PageStore parent disconnected")):this.forget(i.window)},receive:(i,a)=>{try{this.receive(i,a)}catch(s){this.fail(s)}}},{endpoint:this.endpoint,ready:!1}),!this.parent&&(o.searchParams.set("pageId",e.pageId),this.socket=new this.window.WebSocket(o.href),this.socket.addEventListener("open",()=>this.connected()),this.socket.addEventListener("message",i=>{try{this.deliver(i.data)}catch(a){this.fail(a)}}),this.socket.addEventListener("error",()=>this.fail(new Error("PageStore WebSocket failed"))),this.socket.addEventListener("close",i=>{this.closed||this.fail(new Error("PageStore disconnected ("+i.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(o){this.window.console.error("PageStore publication subscriber failed",o)}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");kt(t);let r={op:"publish",id:ee(),pageId:this.gramlot.pageId,topic:e.topic,payload:t};e.pageId!==void 0&&(r.targetPageId=e.pageId);let o=F(r);return async()=>{let i=j(await this.call(o));if(i.error)throw new rn(i.error);return i.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((o,i)=>{let a={message:r,sent:!1,finish:(l,u)=>{this.calls.delete(r.id)&&(t?.removeEventListener("abort",s),u===void 0?i(l):o(u))}},s=()=>{if(a.finish(t.reason),a.sent&&this.ready&&!this.closed)try{this.send({op:"cancel",id:r.id})}catch(l){this.fail(l)}};this.calls.set(r.id,a),t?.addEventListener("abort",s,{once:!0}),this.ready&&this.sendCall(a)})}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 Zh="gramlot:message",Qa=class{#e;#t;#r;#n=ee();#o=new Map;#a=new Map;#i=!1;#s;#l;#c;#u;#d;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#s=r=>this.#g(r),this.#l=r=>{if(r.target?.localName!=="iframe")return;let o=this.#v(r.target);o&&this.#w(o)},this.#c=r=>{r.persisted||this.#e.dispose({beacon:!0})},this.#u=()=>this.ready(),this.#t.addEventListener("message",this.#s),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.#v(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.#o.values()].filter(e=>!e.parent)}isConnected(e){return!this.#i&&this.#o.has(e)}connect(){this.parent&&(this.#f(),this.#w(this.parent));for(let e of this.#r.getElementsByTagName("iframe")){let t=this.#v(e);t&&this.#w(t)}}ready(){if(!this.#i){this.connect();for(let e of this.#o.values())this.#_(e)}}registerChannel(e,t,r){if(this.#i||e==="publish"||this.#a.has(e))throw new Error("Invalid family channel");this.#a.set(e,{handler:t,state:r});for(let o of this.#o.values())t.changed(o)}setChannelState(e,t){this.#a.get(e).state=t;for(let r of this.#o.values())this.#_(r)}unregisterChannel(e){if(this.#a.delete(e),this.#e.state!=="disposed")for(let t of this.#o.values())this.#_(t)}send(e,t,r){let o=this.#o.get(e);if(this.#i||!o)throw new Error("Destination page is not connected");kt(r),this.#y(o,{kind:"message",recipient:o.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 a=e.iframe,s=ae(a),l=typeof a=="string"?this.#r.getElementById(a):s instanceof Xe?this.#e.dom.getDomNode(s):null,u=this.#v(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 a=this.children.find(s=>s.pageId===e.pageId);if(!a)throw new Error("pageId destination must be a registered direct Gramlot child");r.push(a)}let o=r.map(a=>{let s=this.#o.get(a.window);if(!s?.ready||s.origin!==a.origin)throw new Error("Destination page is not ready");return{...a,session:s.session}});kt(t);let i=F({topic:e.topic,payload:t});return()=>{if(!this.#i)for(let a of o){let s=this.#k(a.window);if(!s||s.origin!==a.origin||this.#o.get(a.window)?.session!==a.session)throw new Error("Destination page disconnected before publication");this.#y(a,{kind:"message",recipient:a.session,channel:"publish",wire:i})}}}dispose(){if(this.#i)return;for(let t of this.children)this.#h(t.window,!0);let e=this.parent;e&&this.#o.has(e.window)&&(this.#y(this.#o.get(e.window),{kind:"close"}),this.#h(e.window)),this.#i=!0,this.#a.clear(),this.#t.removeEventListener("message",this.#s),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.#o.get(e);if(r){t&&this.#y(r,{kind:"close"}),this.#o.delete(e),r.release?.();for(let{handler:o}of this.#a.values())o.disconnected(r);t&&r.kind==="popup"&&!r.parent&&e.close()}}#m(e,t){let r=this.#o.get(e.window),o=r?.session!==t.session;o&&this.#h(e.window);let i=o?{...e,session:t.session}:r;Object.assign(i,{ready:t.ready===!0,pageId:t.pageId,channels:t.channels}),this.#o.set(e.window,i),this.#f(),o&&e.node&&(i.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#h(e.window,!0)}));for(let{handler:a}of this.#a.values())a.changed(i);return o}#g(e){if(this.#i||e.data?.type!==Zh)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 i=this.#m(t,r);(r.kind==="hello"||i)&&this.#_(this.#o.get(t.window));return}let o=this.#o.get(t.window);if(!(!o||o.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 i=j(r.wire);if(r.channel==="publish"){if(this.#e.state!=="started"||!o.ready||typeof i.topic!="string"||!i.topic)return;this.#e.publish(i.topic,i.payload)}else this.#a.get(r.channel)?.handler.receive(o,i)}}}#b(){return{pageId:this.#e.pageId,ready:this.#e.state==="started",channels:Object.fromEntries([...this.#a].map(([e,t])=>[e,t.state]))}}#w(e){this.#y(e,{kind:"hello",...this.#b()})}#_(e){this.#y(e,{kind:"ready",recipient:e.session,...this.#b()})}#y(e,t){e.window.postMessage({type:Zh,session:this.#n,recipient:e.session,...t},e.origin==="null"?"*":e.origin)}#v(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"),i=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:i,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 o=this.#v(r);if(o?.window===e)return o}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 nn=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=eo.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)}},pi=new nn(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var $u=["TL","TC","TR","L","R","BL","BC","BR"],Kh=`.gramlot-labelbox[hidden]{display:none!important}
|
|
36
|
+
${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`}if(u==null||u==="")return t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?yy(u):String(u),d=this._escapeXml(c);return`<${a}${l}>${d}</${a}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&").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,o;if(typeof DOMParser<"u"){o=new DOMParser().parseFromString(e,"application/xml");let a=o.querySelector("parsererror");if(a)throw new Error(`XML parse error: ${a.textContent}`)}else o=new Rh.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(o.documentElement,r)}static _xmlElementToBag(e,t=null){let r=new this,o=Array.from(e.childNodes).filter(i=>i.nodeType===1);for(let i of o){let a=i.tagName,s={};for(let m=0;m<i.attributes.length;m++){let w=i.attributes[m];s[w.name]=w.value}let l=Ja(s._resolver);l&&delete s._resolver;let u=String(s._T||"").toUpperCase()==="BAG";Object.assign(s,Bu(s));let c=a;"_tag"in s&&(c=s._tag,delete s._tag),t&&t in s&&(c=s[t],delete s[t]);let d=c,f=1;for(;r.getNode(c);)c=`${d}_${f++}`;let h=Array.from(i.childNodes).filter(m=>m.nodeType===1),p;if(h.length>0||u){let m=this._xmlElementToBag(i,t);p=r.setItem(c,m,Object.keys(s).length>0?s:null)}else{let m=i.textContent||"";p=r.setItem(c,m,Object.keys(s).length>0?s:null)}l&&(p.resolver=l),p.xmlTag=a}return r}static async fromUrl(e,t={}){let{timeout:r=30}=t,o={};r&&(o.signal=AbortSignal.timeout(r*1e3));let i=await fetch(e,o),a=i.headers.get("content-type")||"",s=await i.text();if(a.includes("json"))return n.fromTytx(s);if(a.includes("xml"))return n.fromXml(s);let l=s.trim();if(l.startsWith("<"))return n.fromXml(s);if(l.startsWith("{")||l.startsWith("["))return n.fromTytx(s);throw new li(`Unsupported content-type: ${a}`)}toJson(e=!0){let t=[];for(let r of this._nodes)t.push(this._nodeToJsonDict(r,e));return e?L(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let r=e.resolver?null:e.getValue(!0);if(r&&typeof r._nodeToJsonDict=="function"){let i=[];for(let a of r._nodes)i.push(r._nodeToJsonDict(a,t));r=i}let o={label:e.label,value:r,attr:Qa(e.attr)};return e.nodeTag!==null&&(o.tag=e.nodeTag),e.resolver&&(o.resolver=si(e.resolver)),o}static fromJson(e,t={}){return Oh||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),Oh=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,r="",o=!0){t===null&&(t=new Map);let i=[],a=[...this._nodes];for(let s=0;s<a.length;s++){let l=a[s],u=s===a.length-1,c=l.getValue(e),d=l.getAttr(),f="",h=Object.keys(d);h.length>0&&(f=" ["+h.map(b=>`${b}=${JSON.stringify(d[b])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=r+(u?" ":"\u2502 ");if(c instanceof n){let w=l,b=c.backref?"(*)":"";if(t.has(w))i.push(`${r}${p}${l.label}${b}${f} \u2192 (circular ref)`);else{t.set(w,l.label),i.push(`${r}${p}${l.label}${b}${f}`);let _=c.toStringTree(e,t,m,u);_&&i.push(_)}}else{let w;if(c===null)w="null";else if(c===void 0)w="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let b=new TextDecoder("utf-8",{fatal:!1}),_=c instanceof ArrayBuffer?new Uint8Array(c):c;w=b.decode(_)}else typeof c=="string"?c.length>50?w=JSON.stringify(c.slice(0,47)+"..."):w=JSON.stringify(c):w=String(c);i.push(`${r}${p}${l.label}: ${w}${f}`)}}return i.join(`
|
|
37
|
+
`)}toString(e=!0,t=null,r=""){t||(t=new Set);let o=[],i=[...this._nodes];for(let a=0;a<i.length;a++){let s=i[a],l=a===i.length-1,u=s.getValue(e),c="",d=s.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([m,w])=>`${m}=${JSON.stringify(w)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=r+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=s;if(t.has(p))o.push(`${r}${f}${s.label}${c} \u2192 (circular ref)`);else{t.add(p),o.push(`${r}${f}${s.label}${c}`);let m=u.toString(e,t,h);m&&o.push(m)}}else{let p;u==null?p="null":typeof u=="string"&&u.length>50?p=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?p=JSON.stringify(u):p=String(u),o.push(`${r}${f}${s.label}: ${p}${c}`)}}return o.join(`
|
|
38
|
+
`)}},li=class extends Error{constructor(e){super(e),this.name="BagException"}};de.registerBagClass(k);Iu(k,"X",n=>n._toTytxPayload(),n=>k._fromTytxPayload(n));Wr(k.tytxSuffix,{...pt(k.tytxSuffix),Bag:k});var $h=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 Mh(n){return n.endsWith("_")&&$h.has(n.slice(0,-1))?n.slice(0,-1):n}function Ph(n){let e=Mh(n);return e!==n?e:n.startsWith("_")&&$h.has(n.slice(1))?n.slice(1):n}function ui(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let o=e||n;if(!o)return o;if(o=Mh(o),t&&!e){let i=`${r}_`;o.startsWith(i)&&(o=o.slice(i.length)),o=`${t}:${o}`}return o}var to=Symbol("value"),Xr=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function Fe(n){return Object.entries(n||{}).filter(([e])=>!Xr.has(e)).map(([e,t])=>[Ph(e),t])}var Ze=class extends xt{constructor(e,t,r=null,o=null,i=null,a=null,s=null){super(e,t,r,o,i,a,s),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(o=>o.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(o=>t[o]!==void 0?t[o]: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 Fe(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(to,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(re(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 o=r.getAttr("datapath");o!=null&&(e=e==="."?o:o+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let o of e.split("."))if(o==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(o);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),o=r.indexOf("."),i=o===-1?r:r.slice(0,o),a=o===-1?"":r.slice(o+1),s;if(i==="FORM")s=this._findMarkedDatapathAncestor(!0,!1,t);else if(i==="ANCHOR")s=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(s=l.source.getNodeByAttr("nodeId",i),s==null)throw new Error(`#<id>: cannot resolve ${t}`)}return s.absDatapath(a?`.${a}`:".")}_findMarkedDatapathAncestor(e,t,r){let o=this;for(;o!=null;){let a=o.getAttr()||{};if(e&&(a.formId!=null||a.form===!0)||t&&"_anchor"in a)return o;o=o.parentNode}let i=e?"FORM":"ANCHOR";throw new Error(`#${i}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let o=this.data,i=this.absDatapath(e);return r&&o.getItem(i)==null&&o.setItem(i,t),o.getItem(i,t)}setRelativeData(e,t,{attributes:r=null,fired:o=!1,reason:i=null}={}){let a=this.data,s=this.absDatapath(e);a.setItem(s,t,r,">",!1,!0,i===null?!0:i,o)}fireEvent(e,t=!0,{attributes:r=null,reason:o=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:o})}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})}},I=class n extends k{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return Ze}_setBuilderItem(e,t,r,...o){let i=t?.map(([s])=>[s,s._builder])||null;if(t)for(let[s,l]of t)s._builder=l;let a=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(r,...o)}catch(s){if(this.node(r)==null&&i)for(let[l,u]of i)l._builder=u;throw s}finally{this._insertingBuilder=a}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[r,o]of t)r._builder=o;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,o=(i,a)=>{if(r.has(i))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(i),t.push([i,a]);for(let s of i.getNodes()){let l=a,u=s._getMeta("subbuilder");u!=null&&(l=a._resolveSubbuilderReference(u,s.getAttr()||{},s.nodeTag)),t.push([s,l]);let c=s.getValue(!0);c instanceof n&&o(c,l)}};return o(this,e),t}};if((pt(I.tytxSuffix).SourceBag??I)!==I)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Wr(I.tytxSuffix,{...pt(I.tytxSuffix),SourceBag:I});function ky(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 Ty=new Set(["then","toJSON"]),Fh=new WeakMap;function ie(n){return Fh.get(n)||n}function ci(n){if(n==null)return n;n=ie(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function jh(n,e){let t=e instanceof k,r=new Proxy(e,{get(o,i){if(typeof i=="symbol"||i.startsWith("_")||Ty.has(i))return Reflect.get(o,i,o);let a=n.schemaTag(i);if(t&&a)return Lh(n,o,a,t);if(i in o){let l=Reflect.get(o,i,o);return typeof l=="function"?l.bind(o):l}if(a)return Lh(n,o,a,t);let s=n.containerMethod(i);if(s)return(...l)=>n[s](n.wrapSource(o),...l)}});return Fh.set(r,e),r}function Lh(n,e,t,r){return(...o)=>{let{value:i,attrs:a}=ky(o),s=r?n.bagCall(e,t,i,a):n.commandOnNode(e,t,i,a);return s.builder.wrapSource(s)}}function Lu(n,e,{transport:t="json"}={}){let r=j(n,t==="json"?null:t);if(!(r instanceof I))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Uh=/^[A-Za-z_][A-Za-z0-9_]*$/,Ay=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),Dy=new Set(["framework","value","attribute"]),Sy=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 Kr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function B(n,e){throw new TypeError(`${n}: ${e}`)}function jt(n,e,t,r){Kr(n)||B(r,"must be an object");for(let o of Object.keys(n))e.includes(o)||B(r,`unknown field '${o}'`);for(let o of t)Object.hasOwn(n,o)||B(r,`missing field '${o}'`)}function Jr(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)=>Jr(t,`${e}[${r}]`));if(Kr(n))return Object.entries(n).forEach(([t,r])=>Jr(r,`${e}.${t}`));B(e,"must be lossless JSON data")}}function Cy(n,e){let t="",r=!1;for(let o=0;o<n.length;o++){let i=n[o];if(i==="\\"){t+=i+(n[++o]??"");continue}i==="["&&(r=!0),!r&&i==="."&&!(e&16)?t+="[^\\n]":!r&&i==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&i==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=i,i==="]"&&(r=!1)}return t}function Zr(n,e,t=!1,r=null){if(n===null)return null;switch(jt(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 jt(n,["kind","name"],["kind","name"],e),r||B(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{jt(n,["kind","dtype"],["kind","dtype"],e);let o=n.dtype;typeof o!="string"&&B(e,"dtype must be a string");let i=oi(o);return!i&&o!=="NN"&&B(e,`unknown dtype '${o}'`),{...n,test:s=>o==="NN"?s===null:o==="N"?pe(s)&&!["NaN","Infinity","-Infinity"].includes(s.toString()):i===Number?typeof s=="number"&&Number.isFinite(s)&&(o!=="L"||Number.isInteger(s)):i===String?typeof s=="string":i===Boolean?typeof s=="boolean":i===Date?s instanceof Date&&Number.isFinite(s.getTime()):i===Object?Kr(s)&&[Object.prototype,null].includes(Object.getPrototypeOf(s)):s instanceof i}}case"any":return{...n,test:o=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&B(e,"type requires string module/name");let o=`${n.module}.${n.name}`;if(o==="collections.abc.Callable")return{...n,test:a=>typeof a=="function",portable:!1};let i=Sy.get(o);return i||B(e,`unsupported type '${o}'`),{...n,test:i}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&B(e,"union items must be non-empty");let o=n.items.map((i,a)=>Zr(i,`${e}.items[${a}]`,!0,r));return{...n,items:o,inputConstraint:o.some(i=>i.inputConstraint),test:i=>o.some(a=>a.test&&a.test(i))}}case"literal":return Array.isArray(n.values)||B(e,"literal values must be an array"),n.values.forEach((o,i)=>Jr(o,`${e}.values[${i}]`)),{...n,test:o=>n.values.some(i=>Object.is(i,o))};case"annotated":{Array.isArray(n.metadata)||B(e,"annotated metadata must be an array"),n.metadata.some(a=>!["regex","range","value"].includes(a?.kind))&&B(e,"unsupported annotation metadata kind");let o=Zr(n.base,`${e}.base`,!0,r),i=n.metadata.map((a,s)=>Zr(a,`${e}.metadata[${s}]`,!0,r));return{...n,base:o,metadata:i,inputConstraint:o.inputConstraint,test:a=>o.test(a)&&i.every(s=>!s.test||s.test(a))}}case"range":{for(let o of["ge","le","gt","lt"])Object.hasOwn(n,o)||B(e,`range missing '${o}'`);for(let o of["ge","le","gt","lt"])n[o]!==null&&(typeof n[o]!="number"||!Number.isFinite(n[o]))&&B(e,`${o} must be finite number or null`);return{...n,test:o=>typeof o=="number"&&(n.ge===null||o>=n.ge)&&(n.le===null||o<=n.le)&&(n.gt===null||o>n.gt)&&(n.lt===null||o<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&B(e,"regex requires pattern and non-negative integer flags");let o=n.flags&-59;o&&B(e,`unsupported Python regex flags ${o}`),n.flags&2&&B(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&B(e,"regex uses a non-portable construct or character class");let i="uy";n.flags&16&&(i+="s");let a;try{a=new RegExp(`(?:${Cy(n.pattern,n.flags)})(?![\\s\\S])`,i)}catch(s){B(e,`invalid portable regex: ${s.message}`)}return{...n,test:s=>typeof s!="string"?!1:(a.lastIndex=0,a.test(s))}}case"value":return Jr(n.value,`${e}.value`),{...n};case"generic":{let o=Zr(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&B(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||B(e,"generic arguments must be an array");let i=n.arguments.map((a,s)=>Zr(a,`${e}.arguments[${s}]`,!0,r));return{...n,origin:o,arguments:i,inputConstraint:i.some(a=>a.inputConstraint),test:a=>o.test(a)&&Ny(n.origin,i,a)}}case"arguments":B(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||B(e,"ellipsis is only valid as a nested descriptor"),{...n};default:B(e,`unknown annotation kind '${n.kind}'`)}}function Ny(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((o,i)=>e[i].test(o)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(o=>!e[0]?.test||e[0].test(o)):r==="builtins.dict"?Object.entries(t).every(([o,i])=>(!e[0]?.test||e[0].test(o))&&(!e[1]?.test||e[1].test(i))):!1}function Vh(n,e){if(n===null)return null;if(typeof n!="string"&&B(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let o=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(o)&&B(e,`invalid cardinality item '${r}'`);let i=o.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);i||B(e,`invalid cardinality item '${r}'`);let[,a,s,l,u]=i;t.has(a)&&B(e,`duplicate tag '${a}'`);let c=0,d=1/0;o.includes("[")&&(o.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(s)),d<c&&B(e,`maximum ${d} is below minimum ${c}`),t.set(a,{min:c,max:d})}return t.has("*")&&t.size>1&&B(e,"wildcard '*' cannot be combined with named tags"),t}function zh(n,e){if(n===null)return null;typeof n!="string"&&B(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let o=r.trim();o&&((!Uh.test(o)||t.has(o))&&B(e,`invalid or duplicate parent '${r}'`),t.add(o))}return t}function Iy(n,e,t){if(n===null)return null;jt(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||B(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")&&B(e,"invalid signature descriptor");let o=new Set,i=!1,a=!1,s=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return jt(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Uh.test(l.name)||o.has(l.name))&&B(c,"invalid or duplicate parameter name"),o.add(l.name),(!Ay.has(l.kind)||!Dy.has(l.role)||typeof l.has_default!="boolean")&&B(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&B(c,"default presence must equal has_default"),l.has_default&&Jr(l.default,`${c}.default`),i||=l.kind==="var_keyword",a||=l.kind==="var_positional",{...l,annotation:Zr(l.annotation,`${c}.annotation`,!1,t)}});return(i!==n.accepts_var_keyword||a!==n.accepts_var_positional)&&B(e,"variadic summary flags do not match parameters"),{...n,parameters:s}}function qh(n,e,t,r){let o=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];jt(n,o,[],e),n={...Object.fromEntries(o.map(i=>[i,null])),...n};for(let i of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[i]!==null&&typeof n[i]!="string"&&B(e,`${i} must be string or null`);return n._meta!==null&&(Kr(n._meta)||B(e,"_meta must be object or null"),Jr(n._meta,`${e}._meta`)),Vh(n.sub_tags,`${e}.sub_tags`),zh(n.parent_tags,`${e}.parent_tags`),{...n,attributes:Iy(n.attributes,`${e}.attributes`,r)}}function Hh(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function Gh(n,e){let t={...e};for(let[r,o]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=o);return t._meta={...n._meta||{},...e._meta||{}},t}function Wh(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?Vh(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?zh(e.parent_tags,"resolved.parent_tags"):null,e}function Yh(n,e,t,r){if(t.get(n)===1&&B(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let o=e[n];o||B(r,`unknown abstract '${n}'`),t.set(n,1);let i={...o};for(let a of Hh(o.inherits_from))i=Gh(Yh(a,e,t,r),i);return i=Wh(i),t.set(n,2),e[n]=i,i}function Fu({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let i of Object.keys(t))Yh(i,t,r,`abstracts.${i}.inherits_from`);let o={};for(let[i,a]of Object.entries(e)){let s={...a};for(let l of Hh(a.inherits_from)){let u=t[l];u||B(`elements.${i}.inherits_from`,`unknown abstract '${l}'`),s=Gh(u,s)}o[i]=Wh(s)}return{abstracts:t,elements:o}}function ju(n){jt(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),jt(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&B("document_format","expected builder_grammar version 1.1 or 1.2"),jt(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&B("grammar.name","must be non-empty string");for(let o of["version","title","description"])n.grammar[o]!==null&&typeof n.grammar[o]!="string"&&B(`grammar.${o}`,"must be string or null");(!Kr(n.abstracts)||!Kr(n.elements))&&B("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&B("custom_types","requires version 1.2");let e=ro.fromJSON(n.custom_types??{}),t={};for(let[o,i]of Object.entries(n.abstracts))(!o||o.startsWith("_"))&&B("abstracts",`invalid public name '${o}'`),t[o]=qh(i,`abstracts.${o}`,!1,e);let r={};for(let[o,i]of Object.entries(n.elements))(!o||o.startsWith("_"))&&B("elements",`invalid public name '${o}'`),r[o]=qh(i,`elements.${o}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function Xh(n,e,t,r){let o=e.attributes;if(!o)return;let i={...r};t!=null&&(i.node_value=t);let a=new Set(o.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),s=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!o.accepts_var_keyword)for(let u of Object.keys(r))!a.has(u)&&!s.has(u)&&B(n,`unknown attribute '${u}'`);let l=e._meta?.component?o.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of o.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(i,u.name);!c&&!u.has_default&&B(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(i[u.name]))&&B(n,`invalid value for ${u.role} '${u.name}'`)}}var ro=class n{#e=new Map;#t=new Map;register(e,t,r){let o=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),i=o.has(t)?{kind:"type",module:"builtins",name:o.get(t)}:t;return this.#r(e,{kind:"annotated",base:i,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)||Oy.has(e))&&B("custom_types",`invalid, reserved or duplicate name '${e}'`),jt(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))&&B(`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))&&B(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Jr(t,`custom_types.${e}`);let o=structuredClone(t),i=Zr(o,`custom_types.${e}`),a=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:a,enumerable:!0}),this.#e.set(e,o),this.#t.set(e,{...a,inputConstraint:!0,test:i.test}),a}resolve(e,t="custom_types"){return this.#t.has(e)||B(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||B(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Kr(e)||B("custom_types","must be an object");let t=new n;for(let[r,o]of Object.entries(e))t.#r(r,o);return t}},Oy=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 Zh(n,e,t,r){let o=e?.attributes;if(o)for(let i of o.parameters){if(!i.annotation?.inputConstraint||i.role==="framework"||["var_keyword","var_positional"].includes(i.kind))continue;let a=i.role==="value"?t:r[i.name];a!==void 0&&(i.annotation.test(a)||B(n,`invalid input for '${i.name}' (custom type)`))}}function Kh(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!qu(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(Zt(n)&&Zt(e)){let r=structuredClone(n);for(let[o,i]of Object.entries(e))i!==null&&Object.defineProperty(r,o,{value:Kh(r[o],i,[...t,o]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function qu(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>qu(t,e[r])):Zt(n)&&Zt(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&qu(n[t],e[t])):!1}function Zt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function Uu(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(Uu);return}if(Zt(n)){Object.values(n).forEach(Uu);return}throw new TypeError("collection must contain only finite JSON values")}}var Kt=class n{#e;constructor(e){Uu(e);let t=["document_format","grammar","abstracts","elements"];if(!Zt(e)||Object.keys(e).some(o=>![...t,"custom_types"].includes(o))||t.some(o=>!Object.hasOwn(e,o)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!Zt(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 o of["grammar","abstracts","elements"])if(!Zt(e[o]))throw new TypeError(`${o} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!Zt(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=Kh(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 Qr=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,[o,i]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,i,t);let a=this.getRender(r),s;return[s,i]=a._handleMeta(e,i),e._getMeta("subbuilder")||(i=a.adaptAttrs(i)),e.value instanceof I&&(o=this.renderChildren(e.value,t)),a.renderedItem(e,o,i,{tag:s,...t})}renderChildren(e,t={}){let r=[];for(let o of e.getNodes()){let i=this.render(o,t);i!==null&&(Array.isArray(i)?r.push(...i):r.push(i))}return r}_renderComponent(e,t,r){let[o,i,a,s]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,o,a,s,r);if(i==null)return[];if(!(i instanceof k))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${i?.constructor?.name||typeof i}`);return i.getNodes().map(l=>this._expandBlock(e,o,a,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,o=r.componentMethod(e.nodeTag),i=o&&r[o];if(typeof i!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let a=t.iterate;delete t.iterate,delete t.store;let s=e.getAttr("iterate")||e.getAttr("store");s!=null?(e.pointerType(s)&&(s=s.slice(1)),s.startsWith(".")&&(s=e._composeRelativeDatapath(s,s))):s=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[i,a,s,t]}_expandBlock(e,t,r,o,i){let a=e.builder._expansionRoot(r);t.call(e.builder,ci(a),o);let s=a.getNodes();if(s.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${s.length} root nodes`);let l={...i,depthOffset:this._nodeDepth(e,i.depthOffset||0)};return this.render(s[0],l)}preprocess(e){return e}renderedItem(e,t,r,o){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,o]=e._getMeta("render_tag,render_attributes"),i=ui(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!i)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return o&&(t={...t,...o}),[i,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,r={}){let o=this._composeStringFragments(e);if(t==null)return o;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(o),null;if(typeof t.write=="function")return t.write(o),null;if(typeof t=="function")return t(o),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 o=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(o-1,0)+t}};var en=class extends Qr{static mode="xml";renderedItem(e,t,r,{tag:o,pretty:i=!1,depthOffset:a=0}={}){let s=this._formatAttrs(r),l=i?" ".repeat(this._nodeDepth(e,a)):"",u=i?`
|
|
39
|
+
`:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${o}${s}>${u}${c}${l}</${o}>${u}`}return t==null?`${l}<${o}${s}></${o}>${u}`:`${l}<${o}${s}>${this._escapeText(t)}</${o}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let o=this._composeStringFragments(e);return r===!0?o=`<?xml version='1.0' encoding='UTF-8'?>${o}`:typeof r=="string"&&(o=r+o),super.finalize(o,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var Jh={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 Qh(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function By(n){let e=Object.create(null),t=(r,o)=>{let i=r.toLowerCase(),a=e[i];if(a!==void 0&&a!==o)throw new Error(`container '${r}' is already tied to implementation method '${a}' (cannot rebind to '${o}')`);e[i]=o};for(let r of Qh(n))if(Object.hasOwn(r,"containers"))for(let o of r.containers||[])t(o,o);return e}function di(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 fi="_root_",hi="_root_",ep=new Set(["destination","func","value","_on_start"]),Ke=class n{static _sourceClass=I;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 k,this._dataroot.setBackref(),this._dataroot.setItem(hi,new k),this.data=this._dataroot.getItem(hi),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(fi,new t(null,this)),this.source=this._sourceroot.getItem(fi)}wrapSource(e){if(e=ie(e),!(e instanceof I)&&!(e instanceof Ze))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=jh(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 Kt(t.toDocument()).update(e):new Kt(e),o=ju(r.toDocument()),i=Fu(o),a=di(i.elements);this._classCollection=r,this._classSchema=i.elements,this._abstracts=i.abstracts,this._tagNames=a}static{this.defineGrammar(Jh)}get _containers(){return By(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??=di(this.schema):this.constructor._tagNames??=di(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let o=`${this.constructor._name}_`;return t.startsWith(o)&&this.schemaTagNames[t.slice(o.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,o=t?new Kt(e):new Kt(r.toDocument()).update(e),i=ju(o.toDocument()),a=Fu(i),s=di(a.elements);return this._collection=o,this._schemaOverride=a.elements,this._tagNamesOverride=s,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;Zh(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let o=this.schemaTag(e);if(!o)throw new Error(`unknown element '${e}'`);return Xh(o,this.schema[o],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:o}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let i=t!==void 0?t:e.value instanceof I?null:e.value;this.validateNodeValues(e.nodeTag,i,r||e.getAttr?.()||{});let a=this.schema[this.schemaTag(e.nodeTag)],s=o||(e.value instanceof I?e.value.getNodes().map(l=>l.nodeTag):null);return s&&this._validateChildren(e.nodeTag,a,s,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let o=this.schemaTag(e);if(!o)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(i=>typeof i!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(o,this.schema[o],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let o=this.schema[r];if(!this._countsForGrammar(o))return!0;let i=o._parentSpec;if(i==null||i.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let a=this.schemaTag(t);if(!a)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,o,a),!0}bagCall(e,t,r,o){return this.setChild(e,t,r,o)}commandOnNode(e,t,r,o){if(e=ie(e),e.value instanceof I)return this.setChild(e.value,t,r,o);let i=e.value,a=new e.parentBag.constructor(null,e.builder||this),s=this.setChild(a,t,r,o,e);return this.promoteNodeValue(e,i,a),s}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,o,i=null){let a={...o},s=this.schema[t];if(!s)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,a);let l=s._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,a,t))||this,d=r instanceof I?r._builderBindingPlan(c):null,f=i?.rootBuilder||e.root._builder||this;if(a.nodeId!=null&&f.source.getNodeByAttr("nodeId",a.nodeId))throw new Error(`Duplicate nodeId '${a.nodeId}'`);r instanceof I&&this._validateChildren(t,s,r.getNodes().map(y=>y.nodeTag),!1);let h=i||e.parentNode,p=h?.nodeTag?this.schema[h.nodeTag]:null;if(p&&!h._getMeta("subbuilder")&&this._countsForGrammar(s))this._validateParent(t,s,h.nodeTag),this._validateChildren(h.nodeTag,p,[...e.getNodes().map(y=>y.nodeTag),t],!1);else if(!p&&!h?._getMeta("subbuilder")&&s._parentSpec!=null&&this._countsForGrammar(s))throw new Error(`'${t}' requires a declared parent`);s._meta&&!("_meta"in a)&&(a._meta=s._meta),s.ns&&!("ns"in a)&&(a.ns=s.ns);let m=a.node_position;delete a.node_position;let w=a.node_label;delete a.node_label;let b;if(p?.collection_key){if(w!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);b=this._collectionLabel(p.collection_key,t,a)}else{let y=p?._subSpec?.get(t);if(y&&y.max===1){if(w!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);b=t}else b=w||s.node_label||this._autoLabel(e,t)}if(e.node(b)!=null)throw new Error(`duplicate node label '${b}'`);return e._setBuilderItem(c,d,b,r,a,m||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,r){let o=t._parentSpec;if(!(o==null||o.has("*")||!this._countsForGrammar(t))&&!o.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,o){let i=t._subSpec;if(i==null||i.has("*")||t._meta?.subbuilder)return[];let a=new Map;for(let s of r){let l=this.schema[s];if(l&&!this._countsForGrammar(l))continue;let u=i.get(s);if(!u)throw new Error(`'${s}' not allowed as child of '${e}'`);let c=(a.get(s)||0)+1;if(a.set(s,c),c>u.max)throw new Error(`too many '${s}' in '${e}'`)}return o?[...i].filter(([s,l])=>(a.get(s)||0)<l.min).map(([s])=>s):[]}_collectionLabel(e,t,r){let o=i=>{if(r[i]===null||r[i]===void 0)throw new Error(`'${t}': collection key needs attribute '${i}'`);return String(r[i])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(i,a)=>o(a)):o(e)}validateSource(){let e=[],t=(r,o="")=>{for(let i of r.getNodes()){let a=o?`${o}.${i.label}`:i.label,s=i.builder;s.validateCustomTypes(i);let l=s.schema[i.nodeTag];if(l&&!i._getMeta("data_element,subbuilder,component").some(Boolean)){let u=i.value instanceof I?i.value.getNodes().map(d=>d.nodeTag):[],c=s._validateChildren(i.nodeTag,l,u,!0);c.length&&e.push([a,c])}i.value instanceof I&&t(i.value,a)}};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={},o=e.runtimeToEvaluate(),i=new Set(o.keys()),a=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...o])if(!(typeof c!="string"||!re(d)))for(let f of Ft(e,d))o.has(f)||o.set(f,a.get(f));let s=e._getMeta("data_element");for(let[c,d]of o){if(d instanceof de){t.set(c,d.resolve());continue}let f=typeof c=="string"?re(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)),!s&&!h.includes("?")&&c===to){let p=this.data.getNode(h);p&&Object.assign(r,p.getAttr("_wdg"))}}let l=Sh(o,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(to);l.delete(to);for(let c of l.keys())i.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,o,i){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let o=(typeof t=="function"?t:t.constructor)[e];if(typeof o=="function")return o}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[o,i]of Object.entries(t))ep.has(o)||(r[o]=i);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[o,i]of Object.entries(t))o!=="destination"&&o!=="value"&&!o.startsWith("_")&&(r[o]=i);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 o of r.getNodes())o._getMeta("data_element")&&e.push(o),o.value instanceof I&&t(o.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 s of Qh(this.constructor))if(Object.hasOwn(s,"components"))for(let l of s.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},r={};for(let[s,l]of Object.entries(e))t[s]={sub_tags:"",_meta:{component:!0}},r[s.toLowerCase()]=l;let o=di(t),i=this._collection||this.constructor._classCollection,a=i.toDocument();a.abstracts={},a.elements=Object.fromEntries(Object.keys(e).map(s=>[s,t[s]])),this._collection=new Kt(i.toDocument()).update(a),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=o}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(fi,new t(null,this),e?{datapath:e}:null),r.getItem(fi)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new en(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),o=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=o,o}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 o=this.getRenderer(e);if(t===!1&&o.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let i=t===!1?null:t||this._defaultTargets.get(o.mode)||null,a={...i?.renderOpts,...r};return o.finalize(this.materialize(e,a),i,a)}};Ke._registry=new Map;var $y=new Set(["short","medium","long","full"]),My=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Py(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||L(n).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Ly(n,e,t,r){let o=e.match(My)||[];if(o.join("")!==e)throw new RangeError("Unclosed format literal");let i=(c,d=2)=>String(c).padStart(d,"0"),a=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>i(n.getUTCFullYear()%100),yyyy:()=>i(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>i(n.getUTCMonth()+1),MMM:()=>a({month:"short"}),MMMM:()=>a({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>i(n.getUTCDate()),EEE:()=>a({weekday:"short"}),EEEE:()=>a({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>i(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>i(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>i(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>i(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return o.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 tp(n,{format:e,mask:t,locale:r,dtype:o,places:i}={}){let a=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||i!=null))if(typeof n=="number"||pe(n))a=jy(n,{format:e,locale:r,places:i});else{let s=Py(n,o);if($y.has(e)){let l={timeZone:"UTC"};s!=="H"&&(l.dateStyle=e),s!=="D"&&(l.timeStyle=e),a=new Intl.DateTimeFormat(r||void 0,l).format(n)}else a=Ly(n,String(e),r||void 0,s)}return t==null?a:String(t).replaceAll("%s",()=>a)}function Fy({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 jy(n,e={}){if(typeof n!="number"&&!pe(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,Fy(e));if(pe(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(pe(n)?n.toString():n)}var qy=new Set(["style","script"]),Uy=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"]),rp=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"]),pi=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),np=n=>n===!0?"true":n===!1?"false":String(n),es=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function Vy(n){if(rp.has(n))return!0;for(let e of rp)if(n.startsWith(`${e}_`))return!0;return!1}function zy(n){let e=new Map;if(!n)return e;let t=[],r=0,o=null,i=!1,a=!1,s=0,l=String(n);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(a){c==="*"&&d==="/"&&(a=!1,u+=1);continue}if(i){i=!1;continue}if(c==="\\"){i=!0;continue}if(o){c===o&&(o=null);continue}c==='"'||c==="'"?o=c:c==="/"&&d==="*"?(a=!0,u+=1):"([{".includes(c)?s+=1:")]}".includes(c)&&s>0?s-=1:c===";"&&s===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 tn=class extends Qr{static mode="html";renderedItem(e,t,r,{tag:o,xml:i=!0,pretty:a=!1,depthOffset:s=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:p,...m}=r;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=tp(t,{format:c,mask:d,places:h,dtype:p,locale:this._displayLocale(e,f)}));let w=this._formatAttrs(m);if(l){if(!Object.hasOwn(r,"id")){let E=this.builder.targetId(e);E!==null&&(w+=` id="${this._htmlAttrValue(E)}"`)}for(let[E,S]of Object.entries(e.getAttr()))e.pointerType(S)&&(w+=` data-${this.adapt(E)}-pointer="${this._htmlAttrValue(e.absDatapath(S))}"`)}let b=a?" ".repeat(this._nodeDepth(e,s)):"",_=a?`
|
|
40
|
+
`:"";if(e._getMeta("void"))return`${b}<${o}${w}${i?"/":""}>${_}`;if(Array.isArray(t)){let E=this._composeStringFragments(t);return`${b}<${o}${w}>${_}${E}${b}</${o}>${_}`}if(t==null)return`${b}<${o}${w}></${o}>${_}`;let y=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):qy.has(o)?String(t):this._escapeText(t);return`${b}<${o}${w}>${y}</${o}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let o=r.getAttr("locale");if(o==null)continue;let i=r.pointerType(o)?r.data.getItem(r.absDatapath(o)):o;if(i)return i}}adaptAttrs(e){let t={},r={};for(let[i,a]of Object.entries(e||{}))if(i.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(i)]=a;else if(i==="dtype")t.dtype=a;else{if(this.builder.constructor.retainedAttrPrefixes.some(s=>i.startsWith(s)))continue;this._isStyleContribution(i)?r[i]=a:t[i]=a}let o=this._adaptStyle(r);return o&&(t.style=o),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||pi.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&pi.has(t)||Vy(e)}_adaptStyle(e){let t=zy(e.style),r=new Map,o=new Map;for(let[i,a]of Object.entries(e))if(i!=="style")if(i.startsWith("style_"))t.set(i.slice(6).replaceAll("_","-"),np(a));else if(pi.has(i))r.set(i,a);else{let s=i.indexOf("_"),l=s<0?i:i.slice(0,s);s>=0&&pi.has(l)?(o.has(l)||o.set(l,{}),o.get(l)[i.slice(s+1)]=a):t.set(i.replaceAll("_","-"),np(a))}for(let i of pi)(r.has(i)||o.has(i))&&this[`_macro_${i}`](r.get(i),o.get(i)||{},t);return[...t].map(([i,a])=>`${i}: ${a}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,o]of Object.entries(e||{}))Uy.has(r)?o&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(o)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_macro_rounded(e,t,r){let o=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[i,a]of Object.entries(t))if(i==="top"||i==="bottom")o[`${i}_left`]=a,o[`${i}_right`]=a;else if(i==="left"||i==="right")o[`top_${i}`]=a,o[`bottom_${i}`]=a;else if(["top_left","top_right","bottom_left","bottom_right"].includes(i))o[i]=a;else throw new TypeError(`rounded: unknown sub-kwarg '${i}'`);for(let[i,a]of Object.entries(o))r.set(`border-${i.replaceAll("_","-")}-radius`,es(a))}_macro_transform(e,t,r){let o=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?o.push(`rotate(${a}deg)`):i==="scale"||i==="translate"?o.push(`${i}(${a})`):i==="translate_x"?o.push(`translateX(${es(a)})`):i==="translate_y"?o.push(`translateY(${es(a)})`):i==="skew_x"?o.push(`skewX(${a}deg)`):i==="skew_y"?o.push(`skewY(${a}deg)`):o.push(`${i.replaceAll("_","-")}(${a})`);o.length&&r.set("transform",o.join(" "))}_macro_filter(e,t,r){let o=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?o.push(`hue-rotate(${a}deg)`):i==="blur"?o.push(`blur(${es(a)})`):i==="drop_shadow"?o.push(`drop-shadow(${a})`):o.push(`${i.replaceAll("_","-")}(${a})`);o.length&&r.set("filter",o.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[o,i]of Object.entries(t))r.set(`transition-${o.replaceAll("_","-")}`,String(i))}_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[o,i]of Object.entries(t))r.set(`box-shadow-${o.replaceAll("_","-")}`,String(i))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var Hy=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 ts(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[Hy.has(e)?e.replaceAll("_","-"):e,t]))}var rn=class extends en{static mode="svg";adaptAttrs(e){return ts(e)}};var op={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 qt=class extends Ke{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(op)}get renderer_html(){return new tn(this)}};Ke.registerBuilder(qt);var ip={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 kr=class extends Ke{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(ip)}get renderer_svg(){return new rn(this)}};Ke.registerBuilder(kr);function Tt(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(ie(n)instanceof Ze||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 k?n.getNodes().flatMap(o=>[o.staticValue,o.getAttr()]):Object.values(n);for(let o of r)Tt(o,e);e.delete(n)}var mi=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,o=i=>{for(let a of i.getNodes()){let s=a.getAttr("__ref");if(s){if(r.has(s))throw new Error("Duplicate Source reference");let l=this.entries.get(s);if(e!==this.sourceRoot&&l&&l.node!==a&&!t.has(l.node))throw new Error("Duplicate Source reference");r.set(s,a)}a.value instanceof I&&o(a.value)}};o(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 ee(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var Je=class{constructor(e){this.gramlot=e}};var nn=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:o}){super(r),this.code=e,this.remoteName=t,o!==void 0&&(this.details=o)}},gi=class extends Je{constructor(e,{rpcUrl:t,closeUrl:r,document:o,transport:i}){super(e),this.transport=i===!1?null:i??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:o,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(Tt(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let o=ee(),i=j(this.transport.callSync(L({id:o,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(i.id!==o)throw new Error("rpc response id mismatch");if(i.error)throw new nn(i.error);return i.value}async call(e,t,r={},o={}){return(await this.callEnvelope(e,t,r,o)).value}async callEnvelope(e,t,r={},{signal:o=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Tt(r);let i=ee(),a=L({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),s=o?[this.gramlot.abort.signal,o]:[this.gramlot.abort.signal],l=s.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of s)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(i),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(i,u);try{let f=j(await Promise.race([this.transport.call(a,u.signal),d]));if(f.id!==i)throw new Error("rpc response id mismatch");if(f.error)throw new nn(f.error);return f}finally{this.remoteRequests.delete(i);for(let f of s)f.removeEventListener("abort",c)}}};var rs=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 o=new URL(t,r.baseURI);o.protocol=o.protocol==="https:"?"wss:":"ws:",this.endpoint=o.href,this.origin=this.window.location.origin,this.parent=this.frames.parent?.window??null,this.frames.registerChannel("server",{changed:i=>this.peerChanged(i),disconnected:i=>{i.parent?this.fail(new Error("PageStore parent disconnected")):this.forget(i.window)},receive:(i,a)=>{try{this.receive(i,a)}catch(s){this.fail(s)}}},{endpoint:this.endpoint,ready:!1}),!this.parent&&(o.searchParams.set("pageId",e.pageId),this.socket=new this.window.WebSocket(o.href),this.socket.addEventListener("open",()=>this.connected()),this.socket.addEventListener("message",i=>{try{this.deliver(i.data)}catch(a){this.fail(a)}}),this.socket.addEventListener("error",()=>this.fail(new Error("PageStore WebSocket failed"))),this.socket.addEventListener("close",i=>{this.closed||this.fail(new Error("PageStore disconnected ("+i.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(L(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(L(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(o){this.window.console.error("PageStore publication subscriber failed",o)}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");Tt(t);let r={op:"publish",id:ee(),pageId:this.gramlot.pageId,topic:e.topic,payload:t};e.pageId!==void 0&&(r.targetPageId=e.pageId);let o=L(r);return async()=>{let i=j(await this.call(o));if(i.error)throw new nn(i.error);return i.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((o,i)=>{let a={message:r,sent:!1,finish:(l,u)=>{this.calls.delete(r.id)&&(t?.removeEventListener("abort",s),u===void 0?i(l):o(u))}},s=()=>{if(a.finish(t.reason),a.sent&&this.ready&&!this.closed)try{this.send({op:"cancel",id:r.id})}catch(l){this.fail(l)}};this.calls.set(r.id,a),t?.addEventListener("abort",s,{once:!0}),this.ready&&this.sendCall(a)})}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 ap="gramlot:message",ns=class{#e;#t;#r;#n=ee();#o=new Map;#a=new Map;#i=!1;#s;#l;#c;#u;#d;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#s=r=>this.#g(r),this.#l=r=>{if(r.target?.localName!=="iframe")return;let o=this.#v(r.target);o&&this.#w(o)},this.#c=r=>{r.persisted||this.#e.dispose({beacon:!0})},this.#u=()=>this.ready(),this.#t.addEventListener("message",this.#s),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.#v(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.#o.values()].filter(e=>!e.parent)}isConnected(e){return!this.#i&&this.#o.has(e)}connect(){this.parent&&(this.#f(),this.#w(this.parent));for(let e of this.#r.getElementsByTagName("iframe")){let t=this.#v(e);t&&this.#w(t)}}ready(){if(!this.#i){this.connect();for(let e of this.#o.values())this.#_(e)}}registerChannel(e,t,r){if(this.#i||e==="publish"||this.#a.has(e))throw new Error("Invalid family channel");this.#a.set(e,{handler:t,state:r});for(let o of this.#o.values())t.changed(o)}setChannelState(e,t){this.#a.get(e).state=t;for(let r of this.#o.values())this.#_(r)}unregisterChannel(e){if(this.#a.delete(e),this.#e.state!=="disposed")for(let t of this.#o.values())this.#_(t)}send(e,t,r){let o=this.#o.get(e);if(this.#i||!o)throw new Error("Destination page is not connected");Tt(r),this.#y(o,{kind:"message",recipient:o.session,channel:t,wire:L(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 a=e.iframe,s=ie(a),l=typeof a=="string"?this.#r.getElementById(a):s instanceof Ze?this.#e.dom.getDomNode(s):null,u=this.#v(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 a=this.children.find(s=>s.pageId===e.pageId);if(!a)throw new Error("pageId destination must be a registered direct Gramlot child");r.push(a)}let o=r.map(a=>{let s=this.#o.get(a.window);if(!s?.ready||s.origin!==a.origin)throw new Error("Destination page is not ready");return{...a,session:s.session}});Tt(t);let i=L({topic:e.topic,payload:t});return()=>{if(!this.#i)for(let a of o){let s=this.#k(a.window);if(!s||s.origin!==a.origin||this.#o.get(a.window)?.session!==a.session)throw new Error("Destination page disconnected before publication");this.#y(a,{kind:"message",recipient:a.session,channel:"publish",wire:i})}}}dispose(){if(this.#i)return;for(let t of this.children)this.#h(t.window,!0);let e=this.parent;e&&this.#o.has(e.window)&&(this.#y(this.#o.get(e.window),{kind:"close"}),this.#h(e.window)),this.#i=!0,this.#a.clear(),this.#t.removeEventListener("message",this.#s),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.#o.get(e);if(r){t&&this.#y(r,{kind:"close"}),this.#o.delete(e),r.release?.();for(let{handler:o}of this.#a.values())o.disconnected(r);t&&r.kind==="popup"&&!r.parent&&e.close()}}#m(e,t){let r=this.#o.get(e.window),o=r?.session!==t.session;o&&this.#h(e.window);let i=o?{...e,session:t.session}:r;Object.assign(i,{ready:t.ready===!0,pageId:t.pageId,channels:t.channels}),this.#o.set(e.window,i),this.#f(),o&&e.node&&(i.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#h(e.window,!0)}));for(let{handler:a}of this.#a.values())a.changed(i);return o}#g(e){if(this.#i||e.data?.type!==ap)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 i=this.#m(t,r);(r.kind==="hello"||i)&&this.#_(this.#o.get(t.window));return}let o=this.#o.get(t.window);if(!(!o||o.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 i=j(r.wire);if(r.channel==="publish"){if(this.#e.state!=="started"||!o.ready||typeof i.topic!="string"||!i.topic)return;this.#e.publish(i.topic,i.payload)}else this.#a.get(r.channel)?.handler.receive(o,i)}}}#b(){return{pageId:this.#e.pageId,ready:this.#e.state==="started",channels:Object.fromEntries([...this.#a].map(([e,t])=>[e,t.state]))}}#w(e){this.#y(e,{kind:"hello",...this.#b()})}#_(e){this.#y(e,{kind:"ready",recipient:e.session,...this.#b()})}#y(e,t){e.window.postMessage({type:ap,session:this.#n,recipient:e.session,...t},e.origin==="null"?"*":e.origin)}#v(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"),i=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:i,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 o=this.#v(r);if(o?.window===e)return o}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 on=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=ro.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)}},bi=new on(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var Vu=["TL","TC","TR","L","R","BL","BC","BR"],sp=`.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}
|
|
@@ -84,7 +84,7 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
84
84
|
.gramlot-labelbox>.tray-resize[hidden]{display:none}
|
|
85
85
|
.gramlot-labelbox>.tray-resize svg{width:16px;height:16px;pointer-events:none}
|
|
86
86
|
.gramlot-labelbox>.tray-resize:hover,.gramlot-labelbox>.tray-resize:focus-visible{opacity:1}
|
|
87
|
-
.gramlot-labelbox>.tray-resize:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}`;function
|
|
87
|
+
.gramlot-labelbox>.tray-resize:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}`;function lp(n,e){let t=n.createElement("div"),r=n.createElement("div"),o=n.createElement("label");r.append(o),t.append(r,e);let i={box:t,labelBox:r,fieldLabel:o,controlBox:e,previous:{box:{},label:{},labelBox:{},controlBox:{}}};return t.labelbox=i,i}function up(n,e,t){let{lbl:r,lbl_variant:o,lbl_position:i=o==="card"?"TC":"TL",...a}=e;if(!Vu.includes(i))throw new TypeError(`Invalid lbl_position: ${i}`);let s={box:{},label:{},labelBox:{},controlBox:{}},l=[["box_l_","labelBox"],["box_c_","controlBox"],["lbl_","label"],["box_","box"]];for(let[c,d]of Object.entries(a)){let f=l.find(([h])=>c.startsWith(h));f&&(s[f[1]][c.slice(f[0].length)]=d,delete a[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(s[c]),h=n.previous[c];for(let p of new Set([...Object.keys(h),...Object.keys(f)]))f[p]==null?d.removeAttribute(p):d.setAttribute(p,String(f[p]));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=i,o==null?delete n.box.dataset.variant:n.box.dataset.variant=o,n.fieldLabel.textContent=r??"",n.labelBox.hidden=r==null||r==="",n.box.dispatchEvent(new n.box.ownerDocument.defaultView.Event("gramlot-label-layout",{bubbles:!0})),a}function Re(n){return n?.labelbox?n.labelbox.controlBox.firstElementChild:n}function an(n){let e=n?.parentElement?.parentElement;return e?.labelbox&&Re(e)===n?e:n}var Yy=/^[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,Xy=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function Jt(n){let e=n.code;if(typeof e!="string"||Yy.exec(e)?.[0]!==e||!e.includes("-")||Xy.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function zu(n){for(let e of Object.values(n))e&&typeof e=="object"&&zu(e);return Object.freeze(n)}function cp(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 Ar({name:n,tag:e,base:t,mixins:r=[],parameters:o={},subTags:i="",presentationDefaults:a=[],dataScope:s=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,bagStruct:f=!1,dragSource:h=!1,implementation:p}){if(Jt({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n))throw new TypeError("Invalid component authoring name");let m={...t.parameters};for(let w of r)for(let[b,_]of Object.entries(w.parameters)){if(Object.hasOwn(m,b))throw new Error(`Duplicate mixin parameter: ${b}`);m[b]=_}Object.assign(m,o);for(let w of Object.values(m))cp(w);return Object.freeze({name:n,tag:e,base:t,subTags:i,presentationDefaults:Object.freeze([...a]),dataScope:s,command:l,bagStore:d,bagStruct:f,mixins:Object.freeze([...r]),labelbox:r.some(w=>w.labelbox===!0),parameters:zu(structuredClone(m)),childParameters:zu(structuredClone(u)),sourceContext:c,dragSource:h,implementation:p})}var Tr=class n{#e=new WeakMap;constructor({name:e,components:t,dependencies:r=[],css:o=[],assets:i={},registerCommands:a=()=>{}}){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(o)||o.some(u=>!(u instanceof URL))||!i||typeof i!="object"||Array.isArray(i)||Object.values(i).some(u=>!(u instanceof URL)))throw new TypeError("Collection css/assets require URL objects");if(typeof a!="function")throw new TypeError("registerCommands must be a function");this.dependencies=Object.freeze([...r]),this.css=Object.freeze([...o]),this.assets=Object.freeze({...i}),this.registerCommands=a,this.name=e,this.components=Object.freeze([...t]);let s=new Set,l=new Set;for(let u of t){if(s.has(u.name.toLowerCase())||l.has(u.tag))throw new Error(`Duplicate component: ${u.name}`);s.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:cp(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}:{},...e.bagStruct?{bagStruct:!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 o=r.base(e.HTMLElement);for(let a of r.mixins)o=a(o);let i=r.implementation(o);Object.defineProperty(i,"gramlotComponent",{value:r}),t.push([r.tag,i])}for(let[r,o]of t)e.customElements.define(r,o);this.#e.set(e,t)}};function Hu(n){return new Tr(n)}function no(n,e){return n.parameters=Gu(n.constructor.gramlotComponent,e),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(n.parameters,t)))}function Gu(n,e){return Object.fromEntries(Object.entries(n.parameters).map(([t,r])=>[t,Object.hasOwn(e,t)?e[t]:r.default]))}function dp(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 o=r.indexOf(":"),i=o<0?r:r.slice(0,o),a=o<0?r:r.slice(o+1);if(!i||t.has(i))throw new Error("Invalid or duplicate choice code");return t.add(i),{id:i,caption:a}})}function os(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}
|
|
88
88
|
input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
|
|
89
89
|
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
|
|
90
90
|
appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
@@ -100,7 +100,7 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
100
100
|
input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
|
|
101
101
|
input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
|
|
102
102
|
.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)}
|
|
103
|
-
.caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return to(this,e)}setPageContext(e){this.pageContext=e}connectedCallback(){}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(){}validationValueCheck(){let e=this.constructor.gramlotComponent.parameters.value.nullable;return(t,r)=>{if(t==null&&!e)throw new TypeError("This component requires a non-null value.");if(t!=null&&r!=null&&typeof t!=typeof r)throw new TypeError("Validation must preserve the component value type.")}}validationSelection(){return()=>{throw new TypeError("validate_select requires a constrained choice editor.")}}validateSelection(e){return this.validationSelection()(e)}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{this.validationValueCheck()(t,e),this.sameControlValue(e,t)||this.writeControlValue(t)})}restoreFormDraft(e){this.control.value=e}restoreFormValue(e){this.writeControlValue(e)}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function rp(n){return class extends es(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:o,readonly:i}=this.parameters;this.control.disabled=!!o,this.control.readOnly=!!i;for(let[a,s]of Object.entries(this.constructor.gramlotComponent.parameters)){if(s.target==="control"){let l=this.parameters[a]??"";String(this.control[a])!==String(l)&&(this.control[a]=l)}s.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[a]??"")}return r}}}rp.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function np(n){return class extends es(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 o=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[o].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),o=this.parameters.values??"";if(o!==this.#t){let a=tp(o),s=new Set,l=null;for(let{id:u,caption:c}of a){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let 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,s.add(u)}for(let[u,c]of this.#e)s.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=o}let i=this.parameters.cols;if(!Number.isInteger(i)||i<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${i}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return 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:o}]of this.#e)o.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:o}]of this.#e)o.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)}}}np.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function ro(n,e,{align:t="start",matchWidth:r=!1,inset:o=0,placement:i="bottom",point:a=null}={}){let s=e.ownerDocument.defaultView,l=a?{left:a.x,right:a.x,top:a.y,bottom:a.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,s.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*o),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(i==="side"){let b=Math.max(0,s.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),y=c.width>b&&_>b;n.style.setProperty("--gramlot-popup-available-width",`${y?_:b}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,s.innerHeight-16)}px`);let E=n.getBoundingClientRect(),N=y?l.left-E.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(N,s.innerWidth-E.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,s.innerHeight-E.height-8))}px`;return}let d=Math.max(0,s.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-o:l.left+o,w=h?l.top-m.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(p,s.innerWidth-m.width-8))}px`,n.style.top=`${Math.max(8,Math.min(w,s.innerHeight-m.height-8))}px`}var no=new Map;function ts(n,e,t){let r=JSON.stringify([n,e,t]),o=no.get(r);if(o)no.delete(r);else{let i=n?Intl.DateTimeFormat:Intl.NumberFormat;if(!i.supportedLocalesOf([e]).length)throw new RangeError(`Unsupported format locale: ${e}`);o=new i(e,t),no.size===64&&no.delete(no.keys().next().value)}return no.set(r,o),o}function op(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function ns(n,e){return op(e),e==null?n:e.replaceAll("{}",()=>n)}function jy(n){if(n instanceof Date)return mr(n);if(fe(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 qy(n,e,{pattern:t="short",locale:r,timeZone:o}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof o!="string"||!o))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let i={timeZone:e==="DHZ"?o:"UTC"};return e!=="H"&&(i.dateStyle=t),e!=="D"&&(i.timeStyle=t),ts(!0,r,i).format(n)}function rs(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 Uy(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=rs(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!=="-"&&rs(r);let o=e.length>1?rs(e.at(-1)):null;return{positive:t,zero:r,negative:o}}function os(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 w of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(w))throw new RangeError(`Unsupported format option: ${w}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?jy(n):e.dtype,o=["D","H","DHZ"].includes(r);if(!o&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(o){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))&&!(fe(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:i,locale:a,mask:s}=e;if(!o&&typeof i!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof a!="string"||!a)throw new TypeError("Formatting currently requires an explicit locale");if(op(s),o){let w=qy(n,r,e);return ns(w,s)}let{positive:l,zero:u,negative:c}=Uy(i),d=ts(!1,a,l.intl),f=fe(n),h=f?n.eq(0):n===0,m=f?n.lt(0):n<0;if(f&&ts(!1,"en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let p;if(h&&u!==null){if(u==="")return"";if(u==="-")p="-";else{let w=rs(u);p=w.prefix+ts(!1,a,w.intl).format(0)+w.suffix}}else{let w=m&&c?c:l,b=f?(m&&c?n.abs():n).toString():m&&c?-n:n===0?0:n;p=w.prefix+d.format(b)+w.suffix}return ns(p,s)}var Le="http://www.w3.org/1999/xhtml",xr="http://www.w3.org/2000/svg",Vy=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","onComplete","onClose","onEnd","onChecked","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),zy=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],Hy={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},Gy=["format","mask","locale","timeZone","places","dtype"],Wy=new Set(["href","src","data","action","formaction","xlink:href","xlink_href"]);function kr(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!Vy.has(e)&&!zy.some(r=>e.startsWith(r))))}function io(n,e,t=[]){for(let[r,o]of Object.entries(e)){let i=t.find(s=>r.startsWith(s))??"",a=r.slice(i.length);if(["style","class","_class"].includes(a)&&o!=null&&typeof o!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function ao(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],...Pe(n.getAttr()).filter(([o])=>["src","href","xlink:href","xlink_href","_text"].includes(o.slice((t.find(i=>o.startsWith(i))??"").length).toLowerCase()))];for(let[o,i]of r)if(n.pointerType(i)||pt(i))throw new Error(`script '${n.label}': '${o}' 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.onChecked!=null&&!n._getMeta("gramlot_component")?.parameters?.onChecked)throw new Error("onChecked is only supported on a component that declares it");if(e.onComplete!=null&&!["uploader","imageUploader"].includes(n.nodeTag))throw new Error("onComplete is only supported on an uploader or imageUploader");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,o]of Object.entries(so(kr(e)))){let i=t.find(s=>r.startsWith(s)),a=i?r.slice(i.length):r;if(/^on./i.test(a))throw new Error(`${n.nodeTag} '${n.label}': '${r}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${a} for an event, or rename the attribute`);if(Wy.has(a.toLowerCase())&&Yy(o))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 Yy(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function ip(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=s=>{let l=t.find(u=>s.startsWith(u))??"";return[l,s.slice(l.length).toLowerCase()]},o=Object.fromEntries(Pe(n.getAttr())),i=[...Object.keys(o),...Object.keys(e)].find(s=>r(s)[1]==="srcdoc");if(i===void 0||Object.keys(o).some(s=>r(s)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(o,i)&&(n.pointerType(o[i])!==null||pt(o[i]))))return e;let a=Object.fromEntries(Object.entries(e).filter(([s])=>r(s)[1]!=="sandbox"));return{[`${r(i)[0]}sandbox`]:"",...a}}function so(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function mi(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 is(n){let{_meta:e,...t}=n;return mi(so(kr(t)))}function ap(n,e){let t=Hy[String(n).toLowerCase()]??[],r={},o={};for(let[i,a]of Object.entries(e))t.includes(i)?o[i]=a:r[i]=a;return[r,o]}function oo(n){return String(n)}function gi(n,e,t=null){let r={...e},{mask:o,format:i,locale:a,timeZone:s,dtype:l,places:u}=r;for(let d of Gy)delete r[d];let c=d=>{if(t&&i!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:i,mask:o,...a==null?{}:{locale:a},...s==null?{}:{timeZone:s},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=oo(d)),o==null)return d;let f=d==null?"":oo(d);return f===""?f:ns(f,o)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function pt(n){return typeof n=="string"&&n.startsWith("==")}var as=class{#e;#t;#r;#n;#o;#a;#i;#s=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 o=r.createElementNS(xr,"svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false");let i=r.createElementNS(xr,"path");i.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.8"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),o.append(i),this.#n.append(o),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 a=r.createElement("slot");a.name="overflow",this.#r.append(a),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 s=r.createElement("style");s.textContent=`
|
|
103
|
+
.caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return no(this,e)}setPageContext(e){this.pageContext=e}connectedCallback(){}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(){}validationValueCheck(){return this.constructor.validationValueCheck(this.pageContext)}static validationValueCheck(){let e=this.gramlotComponent.parameters.value.nullable;return(t,r)=>{if(t==null&&!e)throw new TypeError("This component requires a non-null value.");if(t!=null&&r!=null&&typeof t!=typeof r)throw new TypeError("Validation must preserve the component value type.")}}validationSelection(){return this.constructor.validationSelection(this.parameters,this.pageContext)}static validationSelection(){return()=>{throw new TypeError("validate_select requires a constrained choice editor.")}}validateSelection(e){return this.validationSelection()(e)}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{this.validationValueCheck()(t,e),this.sameControlValue(e,t)||this.writeControlValue(t)})}restoreFormDraft(e){this.control.value=e}restoreFormValue(e){this.writeControlValue(e)}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function fp(n){return class extends os(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:o,readonly:i}=this.parameters;this.control.disabled=!!o,this.control.readOnly=!!i;for(let[a,s]of Object.entries(this.constructor.gramlotComponent.parameters)){if(s.target==="control"){let l=this.parameters[a]??"";String(this.control[a])!==String(l)&&(this.control[a]=l)}s.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[a]??"")}return r}}}fp.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function hp(n){return class extends os(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 o=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[o].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),o=this.parameters.values??"";if(o!==this.#t){let a=dp(o),s=new Set,l=null;for(let{id:u,caption:c}of a){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let p=this.ownerDocument.createElement("input");p.type=this.choiceType,p.name="choice",p.value=u;let m=this.ownerDocument.createElement("span");h.append(p,m),d={label:h,input:p,text:m},this.#e.set(u,d)}d.text.textContent=c;let f=l?l.nextSibling:this.control.firstChild;f!==d.label&&this.control.insertBefore(d.label,f),l=d.label,s.add(u)}for(let[u,c]of this.#e)s.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=o}let i=this.parameters.cols;if(!Number.isInteger(i)||i<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${i}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return 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:o}]of this.#e)o.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:o}]of this.#e)o.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)}}}hp.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function oo(n,e,{align:t="start",matchWidth:r=!1,inset:o=0,placement:i="bottom",point:a=null}={}){let s=e.ownerDocument.defaultView,l=a?{left:a.x,right:a.x,top:a.y,bottom:a.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,s.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*o),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(i==="side"){let b=Math.max(0,s.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),y=c.width>b&&_>b;n.style.setProperty("--gramlot-popup-available-width",`${y?_:b}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,s.innerHeight-16)}px`);let E=n.getBoundingClientRect(),S=y?l.left-E.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(S,s.innerWidth-E.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,s.innerHeight-E.height-8))}px`;return}let d=Math.max(0,s.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 p=n.getBoundingClientRect(),m=t==="end"?l.right-p.width-o:l.left+o,w=h?l.top-p.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(m,s.innerWidth-p.width-8))}px`,n.style.top=`${Math.max(8,Math.min(w,s.innerHeight-p.height-8))}px`}var io=new Map;function is(n,e,t){let r=JSON.stringify([n,e,t]),o=io.get(r);if(o)io.delete(r);else{let i=n?Intl.DateTimeFormat:Intl.NumberFormat;if(!i.supportedLocalesOf([e]).length)throw new RangeError(`Unsupported format locale: ${e}`);o=new i(e,t),io.size===64&&io.delete(io.keys().next().value)}return io.set(r,o),o}function pp(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function ss(n,e){return pp(e),e==null?n:e.replaceAll("{}",()=>n)}function Zy(n){if(n instanceof Date)return yr(n);if(pe(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 Ky(n,e,{pattern:t="short",locale:r,timeZone:o}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof o!="string"||!o))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let i={timeZone:e==="DHZ"?o:"UTC"};return e!=="H"&&(i.dateStyle=t),e!=="D"&&(i.timeStyle=t),is(!0,r,i).format(n)}function as(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 Jy(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=as(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!=="-"&&as(r);let o=e.length>1?as(e.at(-1)):null;return{positive:t,zero:r,negative:o}}function ls(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 w of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(w))throw new RangeError(`Unsupported format option: ${w}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?Zy(n):e.dtype,o=["D","H","DHZ"].includes(r);if(!o&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(o){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))&&!(pe(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:i,locale:a,mask:s}=e;if(!o&&typeof i!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof a!="string"||!a)throw new TypeError("Formatting currently requires an explicit locale");if(pp(s),o){let w=Ky(n,r,e);return ss(w,s)}let{positive:l,zero:u,negative:c}=Jy(i),d=is(!1,a,l.intl),f=pe(n),h=f?n.eq(0):n===0,p=f?n.lt(0):n<0;if(f&&is(!1,"en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(h&&u!==null){if(u==="")return"";if(u==="-")m="-";else{let w=as(u);m=w.prefix+is(!1,a,w.intl).format(0)+w.suffix}}else{let w=p&&c?c:l,b=f?(p&&c?n.abs():n).toString():p&&c?-n:n===0?0:n;m=w.prefix+d.format(b)+w.suffix}return ss(m,s)}var je="http://www.w3.org/1999/xhtml",Dr="http://www.w3.org/2000/svg",Qy=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","onComplete","onClose","onEnd","onChecked","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),ev=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],tv={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},rv=["format","mask","locale","timeZone","places","dtype"],nv=new Set(["href","src","data","action","formaction","xlink:href","xlink_href"]);function Sr(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!Qy.has(e)&&!ev.some(r=>e.startsWith(r))))}function so(n,e,t=[]){for(let[r,o]of Object.entries(e)){let i=t.find(s=>r.startsWith(s))??"",a=r.slice(i.length);if(["style","class","_class"].includes(a)&&o!=null&&typeof o!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function lo(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],...Fe(n.getAttr()).filter(([o])=>["src","href","xlink:href","xlink_href","_text"].includes(o.slice((t.find(i=>o.startsWith(i))??"").length).toLowerCase()))];for(let[o,i]of r)if(n.pointerType(i)||mt(i))throw new Error(`script '${n.label}': '${o}' 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.onChecked!=null&&!n._getMeta("gramlot_component")?.parameters?.onChecked)throw new Error("onChecked is only supported on a component that declares it");if(e.onComplete!=null&&!["uploader","imageUploader"].includes(n.nodeTag))throw new Error("onComplete is only supported on an uploader or imageUploader");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,o]of Object.entries(uo(Sr(e)))){let i=t.find(s=>r.startsWith(s)),a=i?r.slice(i.length):r;if(/^on./i.test(a))throw new Error(`${n.nodeTag} '${n.label}': '${r}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${a} for an event, or rename the attribute`);if(nv.has(a.toLowerCase())&&ov(o))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 ov(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function mp(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=s=>{let l=t.find(u=>s.startsWith(u))??"";return[l,s.slice(l.length).toLowerCase()]},o=Object.fromEntries(Fe(n.getAttr())),i=[...Object.keys(o),...Object.keys(e)].find(s=>r(s)[1]==="srcdoc");if(i===void 0||Object.keys(o).some(s=>r(s)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(o,i)&&(n.pointerType(o[i])!==null||mt(o[i]))))return e;let a=Object.fromEntries(Object.entries(e).filter(([s])=>r(s)[1]!=="sandbox"));return{[`${r(i)[0]}sandbox`]:"",...a}}function uo(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function wi(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 us(n){let{_meta:e,...t}=n;return wi(uo(Sr(t)))}function gp(n,e){let t=tv[String(n).toLowerCase()]??[],r={},o={};for(let[i,a]of Object.entries(e))t.includes(i)?o[i]=a:r[i]=a;return[r,o]}function ao(n){return String(n)}function _i(n,e,t=null){let r={...e},{mask:o,format:i,locale:a,timeZone:s,dtype:l,places:u}=r;for(let d of rv)delete r[d];let c=d=>{if(t&&i!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:i,mask:o,...a==null?{}:{locale:a},...s==null?{}:{timeZone:s},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=ao(d)),o==null)return d;let f=d==null?"":ao(d);return f===""?f:ss(f,o)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function mt(n){return typeof n=="string"&&n.startsWith("==")}var cs=class{#e;#t;#r;#n;#o;#a;#i;#s=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 o=r.createElementNS(Dr,"svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false");let i=r.createElementNS(Dr,"path");i.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.8"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),o.append(i),this.#n.append(o),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 a=r.createElement("slot");a.name="overflow",this.#r.append(a),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 s=r.createElement("style");s.textContent=`
|
|
104
104
|
:host([role=toolbar]){min-width:0;min-height:0;max-width:100%;width:100%;flex-shrink:1;gap:0}
|
|
105
105
|
:host([role=toolbar][aria-orientation=vertical]){width:auto;height:100%;max-height:100%}
|
|
106
106
|
.toolbar-viewport{display:contents}
|
|
@@ -116,7 +116,7 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
116
116
|
max-width:var(--gramlot-popup-available-width);max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
117
117
|
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}
|
|
118
118
|
.toolbar-overflow ::slotted([role=separator]){margin:5px 7px;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
119
|
-
`,e.shadowRoot.append(s,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.#o)return;let e=this.#e.ownerDocument.defaultView;this.#a=new e.AbortController,this.#o=new e.ResizeObserver(()=>this.schedule()),this.#o.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#a.signal}),this.schedule()}disconnect(){this.close(!1),this.#o?.disconnect(),this.#o=null,this.#a?.abort(),this.#s!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#s),this.#s=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.#o||this.connect(),this.#s===null&&(this.#s=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#s=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",o=r?"height":"width",i=t.getComputedStyle(e),a=(r?e.clientHeight:e.clientWidth)-parseFloat(i[r?"paddingTop":"paddingLeft"]||0)-parseFloat(i[r?"paddingBottom":"paddingRight"]||0);if(a<=0)return;let s=e.ownerDocument.activeElement;for(;s?.shadowRoot?.activeElement;)s=s.shadowRoot.activeElement;let l=[...e.children].filter(b=>!b.hidden&&(
|
|
119
|
+
`,e.shadowRoot.append(s,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.#o)return;let e=this.#e.ownerDocument.defaultView;this.#a=new e.AbortController,this.#o=new e.ResizeObserver(()=>this.schedule()),this.#o.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#a.signal}),this.schedule()}disconnect(){this.close(!1),this.#o?.disconnect(),this.#o=null,this.#a?.abort(),this.#s!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#s),this.#s=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.#o||this.connect(),this.#s===null&&(this.#s=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#s=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",o=r?"height":"width",i=t.getComputedStyle(e),a=(r?e.clientHeight:e.clientWidth)-parseFloat(i[r?"paddingTop":"paddingLeft"]||0)-parseFloat(i[r?"paddingBottom":"paddingRight"]||0);if(a<=0)return;let s=e.ownerDocument.activeElement;for(;s?.shadowRoot?.activeElement;)s=s.shadowRoot.activeElement;let l=[...e.children].filter(b=>!b.hidden&&(Re(b).localName!=="gramlot-menu"||Re(b).permanent));for(let b of this.#c)l.includes(b)||(this.#o.unobserve(b),b.removeAttribute("slot"),b.removeAttribute("data-menu-overflow"));for(let b of l)this.#c.includes(b)||this.#o.observe(b);this.#c=l;for(let b of l)b.removeAttribute("slot"),b.removeAttribute("data-menu-overflow");this.#u.clear(),e.refreshItems();for(let b of e.items)b.refreshAvailability();let u=parseFloat(t.getComputedStyle(this.#t).gap)||0,c=new Map(l.map(b=>{let _=t.getComputedStyle(b),y=Re(b).localName==="gramlot-spacer"?Re(b).parameters.size??0:b.getBoundingClientRect()[o];return[b,y+(parseFloat(_[r?"marginTop":"marginLeft"])||0)+(parseFloat(_[r?"marginBottom":"marginRight"])||0)]})),d=b=>Re(b).getAttribute("role")==="separator",f=b=>b.filter((_,y)=>!d(_)||b.slice(0,y).some(E=>Re(E).localName!=="gramlot-spacer"&&!d(E))&&b.slice(y+1).find(E=>Re(E).localName!=="gramlot-spacer")&&!d(b.slice(y+1).find(E=>Re(E).localName!=="gramlot-spacer"))),h=b=>b.reduce((_,y)=>_+c.get(y),0)+Math.max(0,b.length-1)*u,p=f(l);if(h(p)>a){let b=l.map((_,y)=>({unit:_,index:y})).filter(({unit:_})=>Re(_).localName==="gramlot-menu-line"&&!d(_)&&Re(_).parameters.overflowable).sort((_,y)=>Re(_.unit).parameters.priority-Re(y.unit).parameters.priority||y.index-_.index);for(let{unit:_}of b){if(h(p)<=a-32)break;this.#u.add(_),p=f(p.filter(y=>y!==_))}}let m=f(l.filter(b=>this.#u.has(b)||d(b)&&!p.includes(b)));for(let b of m)this.#u.add(b);for(let b of l)d(b)&&!p.includes(b)&&!this.#u.has(b)&&(b.slot="suppressed");for(let b of this.#u)b.slot="overflow",b.setAttribute("data-menu-overflow","");this.#n.hidden=this.#u.size===0;for(let b of e.items)b.refreshAvailability();e.refreshItems();let w=l.find(b=>{let _=s;for(;_;){if(_===b)return!0;_=_.parentNode??_.host}return!1});this.#u.size===0?this.close(!1):w&&this.#u.has(w)?this.open(!1):this.#l&&this.#d(),w&&s?.isConnected&&s.focus({preventScroll:!0}),e.refreshItems()}#d(){oo(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.#i=new this.#e.ownerDocument.defaultView.AbortController;let t={signal:this.#i.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=o=>{if(o.hidden||o.disabled)return null;if(o.localName==="gramlot-menu-line"&&!o.parameters.group)return o.getAttribute("role")==="separator"?null:o;if(o.matches('input:not([type=hidden]),textarea,select,button,[tabindex="0"]'))return o;for(let i of o.children){let a=t(i);if(a)return a}return null};([...this.#e.children].filter(o=>this.#u.has(o)).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.#i?.abort(),this.#n.setAttribute("aria-expanded","false"),e&&!this.#n.hidden&&this.#n.focus()}}};function bp(n){return class extends n{#e;#t;#r=null;#n=[];#o=null;#a;#i;#s;#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)}
|
|
120
120
|
: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;
|
|
121
121
|
max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
122
122
|
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}
|
|
@@ -125,7 +125,7 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
125
125
|
:host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
126
126
|
: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}
|
|
127
127
|
:host([hidden]){display:none!important} slot{display:contents} .status{padding:.4em;opacity:.75}
|
|
128
|
-
.status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#i=e.createElement("span"),this.#i.className="status",this.#i.setAttribute("role","status"),this.#s=e.createElement("button"),this.#s.textContent="Riprova",this.#s.hidden=!0,this.#s.addEventListener("click",o=>{o.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#i,this.#s),this.#a=new
|
|
128
|
+
.status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#i=e.createElement("span"),this.#i.className="status",this.#i.setAttribute("role","status"),this.#s=e.createElement("button"),this.#s.textContent="Riprova",this.#s.hidden=!0,this.#s.addEventListener("click",o=>{o.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#i,this.#s),this.#a=new cs(this,this.#l),this.addEventListener("keydown",o=>this.#h(o)),this.addEventListener("focusin",o=>{let i=o.composedPath().find(a=>this.items.includes(a));i&&(this.#r=i,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.#a}isOverflowed(e){return this.#a.contains(e)}get usableItems(){return this.items.filter(e=>an(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.#a.schedule()}),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["hidden","disabled"]}),this.refreshItems(),this.#p(),this.#a.connect(),this.permanent&&this.menuBinding?.load()}disconnectedCallback(){this.#a.disconnect(),this.#t?.disconnect(),this.#e?.abort(),this.#d?.abort(),this.#u=null,this.#c=!1}projectAttributes(e){let t=no(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.#a.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=an(this).parentElement;if(this.permanent||!e)return;if(["gramlot-menu-line","gramlot-drop-down-button"].includes(e.localName)){an(this).slot="menu";return}if(e.localName==="gramlot-grouplet-card"){an(this).slot="card-menu";return}if(an(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=i=>!i.composedPath().some(a=>a.localName==="gramlot-menu"),o=i=>{if(this.hidden||this.permanent||!r(i)||i.composedPath().some(u=>u instanceof this.ownerDocument.defaultView.Element&&(u.disabled===!0||u.getAttribute("aria-disabled")==="true")))return;let a=this.#f();if(i.type==="click"){if(a===null||i.button!==0||["shift","ctrl","alt","meta"].some(u=>!!i[u+"Key"]!==a.includes(u)))return}else if(a!==null)return;i.preventDefault(),i.stopPropagation();let s=i.type==="keydown",l=s?e.getBoundingClientRect():null;this.open(e,!1,s?{x:l.left+8,y:l.top+8}:{x:i.clientX,y:i.clientY})};e.addEventListener("click",o,t),e.addEventListener("contextmenu",o,t),e.addEventListener("keydown",i=>{(i.key==="ContextMenu"||i.key==="F10"&&i.shiftKey&&!i.ctrlKey&&!i.altKey&&!i.metaKey)&&o(i)},t)}setStatus(e){this.status=e,this.#i.textContent={loading:"Caricamento\u2026",empty:"Nessuna voce",error:"Impossibile caricare"}[e]??"",this.#s.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),o=this.#n.slice(r+1).find(i=>e.includes(i))??this.#n.slice(0,r).reverse().find(i=>e.includes(i));this.#r=o??null,this.opened&&this.status!=="loading"&&(o?o.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.#o=e,this.#c||(this.showPopover(),this.#c=!0),e.setAttribute("aria-expanded","true"),this.#e?.abort(),this.#e=new this.ownerDocument.defaultView.AbortController;let o={signal:this.#e.signal},i=()=>oo(this,e,{point:r,placement:this.parentMenu&&(!this.parentMenu.permanent||this.parentMenu.parameters.orientation==="vertical"||this.parentMenu.isOverflowed(this.parentElement))?"side":"bottom"});i(),this.ownerDocument.defaultView.addEventListener("resize",i,o),this.ownerDocument.addEventListener("scroll",i,{...o,capture:!0}),this.ownerDocument.addEventListener("pointerdown",a=>{!a.composedPath().includes(this)&&(e===this.#u||!a.composedPath().includes(e))&&this.closeChain(!1)},o),this.menuBinding?.load().then(()=>{this.#c&&(this.ownerDocument.activeElement===this||!this.contains(this.ownerDocument.activeElement))&&this.focusEntry(t),this.#c&&i()}),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.#a.close(e);return}this.#c&&(this.hidePopover(),this.#c=!1,this.#e?.abort(),this.#o?.setAttribute("aria-expanded","false"),e&&this.#o?.isConnected&&this.#o.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.#o?.isConnected&&this.#o.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),o=this.usableItems.filter(u=>this.isOverflowed(u)===!!r),i=o.indexOf(t),a=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowRight":"ArrowDown",s=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowLeft":"ArrowUp",l;if(e.key===a&&(l=Math.min(o.length-1,i+1)),e.key===s&&(l=Math.max(0,i-1)),e.key==="Home"&&(l=0),e.key==="End"&&(l=o.length-1),l!==void 0){e.preventDefault(),e.stopPropagation(),o[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 wp(n){return class extends n{#e;#t;#r;#n;#o;#a;#i=null;#s=!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.#o=e.createElement("span"),this.#o.className="menu-arrow",this.#o.setAttribute("aria-hidden","true"),this.#n.setAttribute("aria-hidden","true"),this.control.prepend(this.#n),this.control.append(this.#r,this.#o);let t=e.createElement("style");t.textContent=`:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
|
|
129
129
|
.menu-check:empty,.menu-arrow:empty{display:none}
|
|
130
130
|
button.menu-row{display:grid;grid-template-columns:1em 1.15em minmax(0,1fr) .7em;column-gap:.5em;
|
|
131
131
|
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);
|
|
@@ -161,7 +161,7 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
161
161
|
:host([data-menu-overflow]) .menu-group,:host([data-menu-group-rows]) .menu-group{flex-direction:column;align-items:stretch;padding:3px 0}
|
|
162
162
|
:host([data-menu-overflow][role=group]){border-block-end:1px solid var(--gramlot-border-control,#888);margin-block-end:4px}
|
|
163
163
|
:host([role=group][aria-disabled=true]) .menu-group{opacity:.45;pointer-events:none}
|
|
164
|
-
: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.#a),this.#a=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let o of this.menuOwner.items)o.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#a))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].map(
|
|
164
|
+
: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.#a),this.#a=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let o of this.menuOwner.items)o.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#a))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].map(Re).find(e=>e.localName==="gramlot-menu")??null}get entryCaption(){return this.parameters.caption??this.#i?.label??""}get entryIcon(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.icon:this.#i?.icon}get entryIconSrc(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.iconSrc:this.#i?.iconSrc}get occurrence(){return this.parameters.code??this.sourceLabel}setCommandDefinition(e,t){this.#i=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.#s=!!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.#s)),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.#i?"???":this.entryCaption,this.caption.hidden=!0,this.renderIcon(this.entryIcon,this.entryIconSrc);let t=this.parameters.tooltip??this.#i?.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=s=>{for(let l=this;l&&l!==e;l=l.parentElement)if(l.localName==="gramlot-menu-line"&&l.parameters[s]!=null)return l.parameters[s];return e?.parameters[s]},o=!!(e?.permanent&&!t),i=r("labelPosition");this.control.classList.toggle("toolbar-button",o),this.control.classList.toggle("toolbar-below",o&&i==="below"),this.control.classList.toggle("toolbar-tooltip",o&&i==="tooltip"),o?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.#o.textContent=this.submenu?t||e?.parameters.orientation==="vertical"?"\u203A":"\u25BE":"";let a=this.#s||this.getAttribute("role")==="separator"||!!(this.parameters.command&&!this.#i)||["loading","error"].includes(e?.status)||!!this.closest("gramlot-drop-down-button")?.parameters.disabled;this.control.disabled!==a&&(this.control.disabled=a)}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.#a),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=an(this.menuOwner)?.parentElement;return t?.localName==="gramlot-drop-down-button"?t.selectCommand(this,e.shiftKey):this.menuOwner.closeChain(),!0}}}function yi(n){return class extends os(n){#e=null;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} :host([hidden]){display:none} .control-box{display:flex;align-items:stretch}
|
|
165
165
|
button{display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,.35em);font:inherit;
|
|
166
166
|
color:var(--gramlot-button-color,var(--gramlot-ink,CanvasText));background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
|
|
167
167
|
border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
|
|
@@ -188,33 +188,33 @@ ${" ".repeat(o)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
|
|
|
188
188
|
:host([role=separator]){display:block;border-top:1px solid var(--gramlot-border-control,#888);margin:.25em}
|
|
189
189
|
:host([role=separator]) button{display:none}
|
|
190
190
|
@media(forced-colors:active){button,:host(.button--secondary) button,:host(.button--quiet) button{background:ButtonFace;color:ButtonText;border-color:ButtonText;filter:none}}
|
|
191
|
-
`,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"),this.#e&&this.setActionPresentation(this.#e),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}setActionPresentation(e){this.#e=e,this.hidden=e.hidden,this.icon.textContent=e.icon,this.title=e.title,this.control.setAttribute("aria-label",e.title)}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}bi.parameters={action:{dtype:"T",nullable:!0},disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var Xy=Er({name:"button",tag:"gramlot-button",base:bi,command:!0,subTags:"*",implementation:n=>class extends n{}}),Zy=Er({name:"toggleButton",tag:"gramlot-toggle-button",base:bi,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)}}}),Ky=Er({name:"menu",tag:"gramlot-menu",base:sp,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{}}),Jy=Er({name:"menuline",tag:"gramlot-menu-line",base:bi,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:lp}),Qy=Er({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=to(this,e),{size:r,flex:o}=this.parameters;if(r!=null&&o!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||o!=null&&(!Number.isFinite(o)||o<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=o!=null?`${o} 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{}}),ev=Er({name:"dropDownButton",tag:"gramlot-drop-down-button",base:bi,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#o;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#o=e.createElement("span"),this.#o.hidden=!0,this.control.append(this.#o),this.#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(Oe).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.#a(),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.#a(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#a()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.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.#a()}this.closeMenu()}#a(){let e=this.menuItems.map(o=>o.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.#o.hidden=!r,this.#o.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()}}}),ss=Pu({name:"buttons",components:[Xy,Zy,ev,Ky,Jy,Qy]});var lo=class{epoch=0;controller=null;cancel(){this.epoch++,this.controller?.abort(),this.controller=null}start(e,t,r,o,i,a=()=>{}){this.cancel();let s=new AbortController,l=this.epoch;this.controller=s;let u=r.validationCurrent(),c=()=>l===this.epoch&&!s.signal.aborted&&u(),d=p=>({value:e,modified:!1,error:p.message,warnings:[],issues:[],datachanges:[]}),f=!1,h=p=>{if(f||!c())return{ok:!1};f=!0,this.controller=null;let w={ok:!p.error,value:p.value,result:p,rules:t,isCurrent:c};return i(w),w},m;try{if(t.validate_timeout!=null&&(!Number.isInteger(t.validate_timeout)||t.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");m=o(e,t,{...r,signal:s.signal})}catch(p){return h(d(p))}return m instanceof Promise?(a(),new Promise(p=>{let w,b=()=>{clearTimeout(w),p({ok:!1})};s.signal.addEventListener("abort",b,{once:!0});let _=y=>{clearTimeout(w),s.signal.removeEventListener("abort",b);try{p(h(y))}catch(E){r.reportError(E,"Validation completion failed"),p({ok:!1})}};t.validate_timeout!=null&&(w=setTimeout(()=>{_(d(new Error("Validation timed out."))),s.abort()},t.validate_timeout)),m.then(_,y=>_(d(y)))})):h(m)}};function wi(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function an(n,e,t,r){let{group:o,method:i}=n.logicRegistry.resolve(t,e);return i.call(o,e,r)}function jt(n,e,t,r,o,i=Object.keys(o)){return wi(r)?an(n,e,r,o):n.inlineCompiler.compile(e,t,r,i)(o)}function ls(n){let e=n.node,t=n.runtime.gramlot,r=(o,i,a,s=!1)=>s?n.runtime.inlineCompiler.compile(e,o,i,Object.keys(a),`return (${i});`)(a):jt(n.runtime,e,o,i,a);return{isDecimal:fe,invoke:r,remote:(o,i,a)=>t.rpc.call("data",o,i,{signal:a}),reportError:(o,i)=>{n.closed||n.runtime.reportError(o,i)},validationCurrent:()=>{let o=e.getAttr("value"),i=e.pointerType(o)?e.absDatapath(o):null;return()=>!n.closed&&e.getAttr("value")===o&&(i===null||e.absDatapath(o)===i)},finishValidation:({ok:o,result:i,rules:a})=>{if(n.closed)return;if(o)for(let l of i.datachanges)e.getRelativeData(".").update(l);let s=o?"validate_onAccept":"validate_onReject";if(a[s]){let l=u=>{n.closed||n.runtime.reportError(u,"Validation callback failed")};try{let u=Object.fromEntries(Object.entries(a).map(([d,f])=>[d.slice(9),f])),c=r(s,a[s],{value:i.value,result:i,validations:u,userChange:!0});c instanceof Promise&&c.catch(l)}catch(u){l(u)}}},checkDataPatch:o=>{if(!(o instanceof x))throw new TypeError("Validation data changes must be a Bag.");if(!(e.getRelativeData(".")instanceof x))throw new TypeError("Validation data changes require a Bag datapath.")}}}var Tr=n=>j(F(n)),Ar=(n,e)=>F(n)===F(e),_i=n=>n.absDatapath(n.getAttr("value")),mt=n=>encodeURIComponent(n).replaceAll(".","%2E"),Dr=n=>mt(_i(n)),up=(n,e)=>mt(n.fullpath)+":"+e,yi=class{constructor(e,t,r=e.absDatapath(".")){if(this.node=e,this.runtime=t,this.registers=new x,this.validationQueue=new Set,this.fields=new Map,this.validations=new Map,this.disposed=!1,this.scheduled=!1,this.writing=0,this.path=r,this.retainedFields=new Map,this.listeners=new Set,this.navigators=new Set,!(this.data instanceof x))throw new TypeError("A form requires a Bag at its datapath.");this.registers.setItem("baseline",Tr(this.data));for(let o of["changes","errors","pending","drafts"])this.registers.setItem(o,new x);this.subscription=t.router.register({path:this.path,recipient:this,subtree:!0}),t.bindingFor(e).track(()=>this.dispose())}rebind(){let e=this.node.absDatapath(".");if(e!==this.path){if(!(this.data instanceof x))throw new TypeError("A form requires a Bag at its datapath.");this.subscription.close();for(let t of["errors","pending","drafts"])this.registers.setItem(t,new x);this.path=e,this.subscription=this.runtime.router.register({path:e,recipient:this,subtree:!0}),this.updateChanges();for(let t of this.fields.values())t.element.cancelValidation(),this.clearDraft(t.node),this.scheduleValidation(t)}}get data(){return this.runtime.gramlot.data.getItem(this.path)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get errorEntries(){return this.registers.getItem("errors").getNodes().map(e=>({path:decodeURIComponent(e.label),message:e.value.getNodes().map(t=>t.value).join(`
|
|
192
|
-
`)}))}get changeEntries(){let e=[];for(let t of this.registers.getItem("changes").getNodes()){let r=t.value,o=[this.path,r.getItem("path")].filter(Boolean).join("."),i=r.getItem("existed"),a=r.getItem("exists"),s=r.getItem("previous"),l=r.getItem("current");if((!i||!a||!
|
|
193
|
-
`)),e.element.setFieldState({invalid:!!i,pending:!!this.fieldStatus(r.path).pending})}),()=>{this.fields.delete(t)}}forgetField(e){let t=this.validations.get(e);if(t){t.run.cancel(),t.release(),t.binding.editingSession===this&&(t.binding.editingSession=null),this.validations.delete(e),this.validationQueue.delete(e);for(let r of["errors","pending"]){let o=this.registers.getItem(r).getItem(mt(t.path));if(o){for(let i of[...o.getNodes()])i.label.startsWith(mt(e.fullpath)+":")&&o.popNode(i.label);o.length||this.registers.getItem(r).popNode(mt(t.path))}}if(![...this.validations.values()].some(r=>r.path===t.path)){let r=this.registers.getItem("drafts");r.getNode(mt(t.path))&&r.popNode(mt(t.path))}delete e.formDraft,this.notify()}}refreshField(e){let t=this.validations.get(e);if(!t||this.disposed||this.writing)return;let[,r]=e.rootBuilder.runtimeValues(e),o=this.runtime.renderer.evaluateExpressions(e,r),i=Object.fromEntries(Object.entries(o).filter(([c])=>c.startsWith("validate_"))),a=_i(e),s=this.runtime.gramlot.data.getNode(a.split("?")[0]),l=e.getRelativeData(e.getAttr("value")),u=t.path!==a||t.target!==s||!Ar(t.value,l);if(!(!u&&Ar(t.rules,i))){if(this.cancelValidation(e),t.path!==a)for(let c of["errors","pending","drafts"]){let d=this.registers.getItem(c);d.getNode(mt(t.path))&&d.popNode(mt(t.path))}Object.assign(t,{path:a,target:s,value:l,rules:i,result:null}),u&&this.clearDraft(e),this.scheduleField(e)}}cancelValidation(e){this.validations.get(e)?.run.cancel(),this.validationQueue.delete(e),this.pendingPart(e,"validation",null)}writeCandidate(e,t){this.clearDraft(e),this.writing++;try{this.runtime.renderer.html.writeParameter(e,"value",t)}finally{this.writing--}let r=this.validations.get(e);r&&(r.value=e.getRelativeData(e.getAttr("value")),r.target=this.runtime.gramlot.data.getNode(r.path.split("?")[0]));for(let o of this.validations.keys())o!==e&&this.refreshField(o)}validateCandidate(e,t,r){this.cancelValidation(e),this.writeCandidate(e,t);let o=this.validations.get(e);return o.selection=r,this.validateField(e,!1)}scheduleField(e){this.disposed||!this.validations.has(e)||this.validationQueue.has(e)||this.registers.getItem("drafts").getNode(Dr(e))||(this.validationQueue.add(e),this.pendingPart(e,"validation","scheduled"),this.schedule(()=>{this.validationQueue.delete(e)&&this.validateField(e)}))}scheduleValidation(e){this.refreshField(e.node);let t=this.validations.get(e.node);t&&!t.result&&!t.run.controller&&this.scheduleField(e.node)}validateField(e,t=!0){let r=this.validations.get(e);if(!r||this.disposed||r.binding.closed||(this.validationQueue.delete(e),this.registers.getItem("drafts").getNode(Dr(e)))||this.registers.getItem("pending").getItem(Dr(e))?.getItem(up(e,"selection")))return;let o=e.getRelativeData(e.getAttr("value")),i=this.fields.get(e);t&&i&&(r.selection=i.element.validationSelection());let a=r.selection,s=r.target,l=r.context.validationCurrent();return r.run.start(o,r.rules,{...r.context,validationCurrent:()=>()=>!this.disposed&&l()&&this.validations.get(e)===r&&this.runtime.gramlot.data.getNode(r.path.split("?")[0])===s,selection:a},r.execute,u=>{if(u.ok)try{r.checkValue(u.value,o)}catch(d){u.ok=!1,u.result.error=d.message}this.result(e,u.result),r.result=u.result,u.ok&&this.writeCandidate(e,u.value);let c=this.fields.get(e);c&&c.element.presentValidation(u.result),r.context.finishValidation(u)},()=>{this.pendingPart(e,"validation","active"),this.fields.get(e)?.element.setFieldState({pending:!0})})}remove(e,t){let r=this.registers.getItem(e),o=Dr(t);r.getNode(o)&&r.popNode(o)}set(e,t,r){r==null?this.remove(e,t):this.registers.getItem(e).setItem(Dr(t),r),this.notify()}draft(e,t){this.cancelValidation(e),e.formDraft=t,this.set("drafts",e,t)}clearDraft(e){delete e.formDraft,this.set("drafts",e,null),this.issue(e,"parse",null)}result(e,t){this.pendingPart(e,"validation",null),this.issue(e,"validation",t.error||null)}part(e,t,r,o){r=up(t,r);let i=this.registers.getItem(e),a=Dr(t),s=i.getItem(a);!s&&o!=null&&(s=new x,i.setItem(a,s)),s&&(o==null?s.getNode(r)&&s.popNode(r):s.setItem(r,o),s.length||this.remove(e,t)),this.notify()}issue(e,t,r){this.part("errors",e,t,r||null)}pendingPart(e,t,r){this.part("pending",e,t,r)}parseError(e,t){this.issue(e,"parse",t)}schedule(e){queueMicrotask(()=>{this.disposed||e()})}receive(e){if(!this.disposed&&(this.updateChanges(e.path),!this.writing))for(let t of this.validations.keys())this.refreshField(t)}updateChanges(e=null){let t=this.registers.getItem("changes"),r=e===this.path?"":e?.startsWith(this.path+".")?e.slice(this.path.length+1).split("?")[0]:"",o=(l,u,c)=>{if(l&&u&&l.value instanceof x&&u.value instanceof x&&Ar(l.attr,u.attr)){let d=new Set([...l.value.getNodes(),...u.value.getNodes()].map(f=>f.label));for(let f of d)o(l.value.getNode(f),u.value.getNode(f),c?c+"."+f:f)}else(!l||!u||!Ar([l.value,l.attr],[u.value,u.attr]))&&t.setItem(mt(c),new x({path:c,existed:!!l,exists:!!u,previous:l?Tr(l.value):null,current:u?Tr(u.value):null,previousAttributes:l?Tr(l.attr):null,currentAttributes:u?Tr(u.attr):null}))},i=this.registers.getItem("baseline"),a=r;for(let l of t.getNodes()){let u=l.value.getItem("path");a.startsWith(u+".")&&(a=u)}let s=a;for(;s.includes(".");){s=s.slice(0,s.lastIndexOf("."));let l=i.getNode(s),u=this.data.getNode(s);(!l||!u||!Ar(l.attr,u.attr))&&(a=s)}for(let l of[...t.getNodes()]){let u=l.value.getItem("path");(!a||u===a||u.startsWith(a+"."))&&t.popNode(l.label)}a?o(i.getNode(a),this.data.getNode(a),a):o({value:i,attr:{}},{value:this.data,attr:{}},""),this.notify()}notify(){this.disposed||this.scheduled||(this.scheduled=!0,this.schedule(()=>{this.scheduled=!1;let e=this.status,t=this.registers.getItem("status");(!t||!Ar(t,new x(e)))&&(this.registers.setItem("status",new x(e)),this.node.publish("formStatus",e));for(let r of this.listeners)r()}))}commitField(e){for(let t of this.fields.values())_i(t.node)===e&&Object.hasOwn(t.node,"formDraft")&&t.commit()}accept(){if(this.disposed)return!1;for(let e of this.fields.values())Object.hasOwn(e.node,"formDraft")&&e.commit();return!this.status.valid||this.status.pending?!1:(this.registers.setItem("baseline",Tr(this.data)),this.updateChanges(),!0)}load(e){if(!(e instanceof x))throw new TypeError("Editing load requires a Bag.");this.disposed||(this.registers.setItem("baseline",Tr(e)),this.restore())}restore(){if(!this.disposed){for(let e of this.validations.keys())this.cancelValidation(e);for(let e of this.fields.values())e.element.cancelValidation(),this.clearDraft(e.node),e.element.restoreFormValue(this.registers.getItem("baseline").getItem(e.node.absDatapath(e.node.getAttr("value")).slice(this.path?this.path.length+1:0)));this.runtime.gramlot.data.setItem(this.path,Tr(this.registers.getItem("baseline")));for(let e of["errors","pending","drafts"])this.registers.setItem(e,new x);this.updateChanges();for(let e of this.validations.keys())this.scheduleField(e)}}dispose(){if(!this.disposed){this.disposed=!0,this.subscription.close();for(let e of this.validations.keys())this.forgetField(e);this.fields.clear(),this.validationQueue.clear(),this.retainedFields.clear(),this.listeners.clear(),this.navigators.clear()}}};function tv(n,e,t=n){let r=new Map,o=new Set,i=new Map;for(let[s,l]of e){if(typeof s!="string")continue;let u=re(l)?.pointer??l;i.set(s,u instanceof ce?u.resolve():n.pointerType(u)?t.getRelativeData(u):pt(u)?null:u)}let a=s=>{if(r.has(s))return r.get(s);if(!e.has(s))throw new Error(`Source attribute '${s}' does not exist`);if(o.has(s))throw new Error(`cyclic attribute dependency: ${[...o,s].join(" -> ")}`);o.add(s);let l=e.get(s),u=re(l),c=u?i.get(s):null,d,f=h=>h?a(h):c;try{if(u)if(u.expression){let h=ri(u.body),m=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,s,l,h,m)}else d=Wr(u.body,f),c==null&&(d=null);else d=i.get(s);return r.set(s,d),d}finally{o.delete(s)}};return{resolve:a}}function Sr(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),...Pe(n.getAttr())]);return tv(n,r,t).resolve(e)}var rv={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"]},Lu=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],nv=["_if","_else","_onRemote","_onCalling"],Fu=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.#o()}return t}submit(e,t,r){try{let o=F(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((i,a)=>{this.#r={method:e,text:o,perform:r,resolve:i,reject:a}}):(this.#r?.resolve(void 0),this.#r=null,this.#a(e,t,o,r))}catch(o){return Promise.reject(o)}}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()}#o(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#a(e.method,j(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#a(e,t,r,o){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let i=new AbortController,a={method:e,params:t,text:r,controller:i,ignored:!1};a.view=Object.freeze({method:e,get params(){return j(r)},sentAt:Date.now(),cancel:()=>this.#s(a)}),this.#t=a,i.signal.addEventListener("abort",()=>this.#i(a),{once:!0});let s;try{s=Promise.resolve(o(a))}catch(l){s=Promise.reject(l)}return s.then(()=>this.#i(a),()=>this.#i(a)),s}#i(e){this.#t===e&&(this.#t=null,this.#o())}#s(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#o())}};function cp(n){return typeof n=="string"&&n.startsWith("==")}var sn=class extends Xe{#e=null;get formState(){for(let e=this;e;e=e.parentNode){if(e.#e&&e._getMeta("gramlot_component")?.bagStore)return e.#e;if(e.getAttr("formId")!=null||e.getAttr("form")===!0){let t=e.#e??=new yi(e,this.rootBuilder.binding);return t.rebind(),t}}return null}editCollection(e){let t=this.parentNode?.formState;if(t){if(e!==t.path&&!e.startsWith(t.path+"."))throw new Error("An edited grid in a form must use data within that form.");return t}if(this.#e&&this.#e.path!==e)throw new Error("An active grid editing session cannot change its storepath.");return this.#e??=new yi(this,this.rootBuilder.binding,e)}get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof I?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 grid(){if(this.nodeTag==="framePane"){let e=this.staticValue instanceof I?this.staticValue.getNode("center.grid"):null;if(!e||e.nodeTag!=="grid")throw new TypeError("This frame has no central grid");return this.builder.wrapSource(e)}return(e={})=>this.builder.wrapSource(this.builder.commandOnNode(this,"grid",null,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 I?this.value.getNodes().find(o=>o.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))}#t=new Set;#r=null;#n=null;get requests(){return this.#n??=new Fu(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...rv[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"?nv:[]],t=[];for(let[r,o]of Object.entries(this.getAttr()??{}))typeof o=="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,o]);for(let r of["ask","_ask"]){let o=this.getAttr(r);if(o&&typeof o=="object")for(let i of["_if","askIf"])typeof o[i]=="string"&&t.push([`${r}.${i}`,o[i]])}for(let[r,o]of Pe(this.getAttr()))if(cp(o)&&t.push([r,o]),this.nodeTag==="script"&&typeof o=="string"){let i=this.builder.constructor.dialectPrefixes.find(a=>r.startsWith(a))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(i.length).toLowerCase())&&t.push([r,o])}return(cp(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[...Pe(this.getAttr()),["datapath",this.getAttr("datapath")]])re(r)?.expression&&e.set(t,r);this.#r=e}activatedCode(e){return this.#r?.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 o=Object.keys(t).find(a=>a.startsWith("_")&&!Lu.includes(a));if(o)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${o}' is not accepted; the control attributes are ${Lu.join(", ")}`);let i={remote:e};for(let[a,s]of Object.entries(t))i[Lu.includes(a)?a:`remote_${a}`]=s;return this.setAttr(i),si(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=re(e)?Lt(this,e):new Set,r=super.pointers().filter(([o,i])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o))&&!t.has(o)&&!this.#i(o,i)).map(([o,i])=>[o,re(i)?.pointer??i]);for(let o of t){let i=this.getAttr(o);this.pointerType(i)==="^"&&r.push(["datapath",re(i)?.pointer??i])}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 br(()=>r));continue}if(this.pointerType(r)){if(re(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 br(()=>Sr(this,t)));continue}this.#i(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 re(t)?Sr(this,e):this.pointerType(t)&&this.#i(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.#s(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#s(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.#s(e);let o=this.absDatapath(e);if(o.includes("?")){this.#o(o,t);return}this.data.getNode(o)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(o)?.setValue(null,!1)}}#o(e,t){let[r,o]=e.split("?",2),i=this.data;i.getNode(r)?.setAttr({[o]:null},!1);try{let a=i.getNode(r);a?a.setValue(a.staticValue,!0,{[o]:t},!0,!0,!0,!0):i.setItem(r,null,{[o]:t},">",!0,!0,!0,!0)}finally{i.getNode(r)?.setAttr({[o]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#s(e);let o=this.rootBuilder?.binding?.bindingFor(this)??null,i=null,a=setTimeout(()=>{i?.(),this.FIRE(e,t)},r);return i=o?.track(()=>clearTimeout(a))??null,()=>{clearTimeout(a),i?.()}}absDatapath(e){e=re(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,o]=t.split("?",2),i=super.absDatapath(r);return i===null?null:`${i}?${o}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let o=r.getAttr("datapath");if(this.pointerType(o)&&(o=this.#a(r,o),o===null))return null;if(o!=null&&(e=e==="."?o:o+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 o=this.rootBuilder?.binding;if(!o)return super._resolveSymbolicDatapath(e,t);let i=o.nodeIds.get(r);if(!i)throw new Error(`#<id>: cannot resolve ${t}`);let a=e.slice(r.length+2);return i.absDatapath(a?`.${a}`:".")}#a(e,t){if(re(t)){let i=Sr(e,"datapath",e.parentNode);return i==null||i===""?null:i}let r=e.parentNode.absDatapath(t);if(r===null)return null;let o=this.data.getItem(r);return o==null||o===""?null:o}#i(e,t){return re(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#t.has(e)||(this.#t.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#s(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},Te=class n extends I{get nodeClass(){return sn}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let o=r.getAttr("auth")??null;if(o!==null){if(typeof o!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof o}`);if(e(o)!==null)continue}let i=r.staticValue;i instanceof n&&(i=i.authorizedCopy(e));let{auth:a,...s}=r.getAttr(),l=t.setItem(r.label,i,s,">",!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((ht(Te.tytxSuffix).GramlotBuilderBag??Te)!==Te)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Gr(Te.tytxSuffix,{...ht(Te.tytxSuffix),GramlotBuilderBag:Te});var ov=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"]),vi=class extends tn{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);ao(e,r);let[o,i]=super._handleMeta(e,r);return io(e,i),e._getMeta("subbuilder")?[o,Ka(is(i))]:[o,i]}adaptAttrs(e){let{_meta:t,...r}=e;return mi(super.adaptAttrs(so(kr(r))))}renderedItem(e,t,r,o={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,o);let{_text:i,...a}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&i!=null&&(t=[this._escapeText(oo(i)),...t]),ov.has(o.tag)?`${o.pretty?" ".repeat(this._nodeDepth(e,o.depthOffset??0)):""}<${o.tag}${this._formatAttrs(a)} />${o.pretty?`
|
|
194
|
-
`:""}`:super.renderedItem(e,t,a,o)}};var ln=class extends en{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof _r?this.addRender(e,this):e instanceof yr&&this.addRender(e,new vi(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,o]=e.rootBuilder.runtimeValues(e),i=this.getRender(e.builder),[a,s]=i._handleMeta(e,o);return e._getMeta("subbuilder")||(s=i.adaptAttrs(s)),i.renderedItem(e,e.value instanceof I?this.renderChildren(e.value,t):r,s,{tag:a,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,o=this.evaluateExpressions(e,t);ao(e,o,r);let[i,a]=super._handleMeta(e,ip(e,o,r));if(io(e,a,r),e.nodeTag==="webcomponent"){i=Xt(e.getAttr());let{code:u,...c}=a;a=c}if(e._getMeta("subbuilder")){let u=is(a);return e._getMeta("subbuilder")==="html"&&(u.xmlns=xr),[i,u]}let[s,l]=ap(i,a);return Object.keys(l).length&&this.#e.set(e,l),[i,s]}evaluateExpressions(e,t){let r=this.inlineCompiler,o=(a,s)=>r?r.compileExpression(e,a,s)(t):null,i={...t};for(let[a,s]of Pe(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(a)||pt(s)&&Object.hasOwn(i,a)&&(i[a]=o(a,s));return pt(e.value)&&this.#t.set(e,o("",e.value)),i}expressionValue(e,t){return pt(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...so(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,o=`${this.builder.constructor._name}_`,i=this.builder.constructor.dialectPrefixes,a={},s={};for(let[l,u]of Object.entries(kr(r))){if(u==null)continue;if(l.startsWith(o))throw new Error(`${l}: the attribute prefix '${o}' is not accepted; use the prefix '${i[0]}'`);let c=i.find(d=>l.startsWith(d));c?a[l.slice(c.length)]=u:s[l]=u}return mi({...super.adaptAttrs(s),...a})}renderedItem(e,t,r,o={}){let i;[t,i]=gi(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:a,...s}=i;Array.isArray(t)&&a!=null&&(t=[this._escapeText(oo(a)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:Le,...s}:s;return super.renderedItem(e,t,l,o)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let o=this._composeStringFragments(e),i=this.builder.source.getNodes().filter(a=>!a._getMeta("data_element"));return i.length===1&&i[0].nodeTag==="html"||(o=`<html>${o}</html>`),super.finalize(`<!doctype html>${o}`,t,r)}};var dp={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 fp={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 sv="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",lv=new Set,uv=new Set(["serverpath","dbenv","shared_id"]),cv=["formsubscribe_"],dv={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},fv={dataFormula:"formula",dataController:"script"};function hp(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&re(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(o=>["action","ask","_delay","fire"].includes(o)||o.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(o=>o.startsWith("subscribe_")||o.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=dv[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=fv[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 pp(n){return Object.keys(n).find(e=>uv.has(e)||cv.some(t=>e.startsWith(t)))}var Ie=class n extends _r{static _name="gramlot";static containers=["frameGrid"];static _sourceClass=Te;static{this.defineGrammar(dp)}static{this.defineGrammar(fp)}static{this.defineGrammar(ss.toDocument())}frameGrid(e,{storepath:t,rowMode:r,structpath:o,searchOn:i=!1,...a}={}){for(let u of["framePane","grid"])if(!this.schemaTag(u))throw new TypeError(`frameGrid requires the ${u} collection`);let s={storepath:t,rowMode:r,...o==null?{}:{structpath:o},node_label:"grid",frameTarget:!0,height:"100%",width:"100%"};this.validateNodeValues("grid",null,s),i!==!1&&this.validateNodeValues("searchBox",null,{searchOn:i});let l=e.framePane(a);return l.center.grid(s),i!==!1&&l.top.menu({presentation:"bar",node_label:"search",aria_label:"Grid search",padding:"4px 8px",background:"var(--gramlot-surface-subtle)"}).menuline({group:!0}).searchBox({searchOn:i}),l}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:o=pi}={}){if(!(o instanceof nn))throw new TypeError(`nameSyntax must be a NameSyntax, not ${o}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=o;for(let i of t)this.loadCollection(i)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,o,i){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,o.text)(i):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof vr?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(lv.has(t))throw new Error(`${e}: excluded from Gramlot`);let o=this.schemaTagNames[t];if(o)return o;for(let i of r)if(t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)])return t;return null}bagCall(e,t,r,o){return t=this.#e(t),[r,o]=this.menuArguments(t,r,o),super.bagCall(e,t,r,o)}commandOnNode(e,t,r,o){return t=this.#e(t),[r,o]=this.menuArguments(t,r,o),super.commandOnNode(e,t,r,o)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new Te(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&&re(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&Xt(r);let o=pp(r);if(o)throw new Error(`${e}: attribute '${o}' is excluded from Gramlot`);let i=hp(e,r);if(i)throw new Error(`${e}: ${i}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&re((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&Xt(t.attrs??e.getAttr());let r=pp(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let o=hp(e.nodeTag,t.attrs??e.getAttr());if(o)throw new Error(`${e.nodeTag} '${e.label}': ${o}`);return super.validateNode(e,t)}_validateChildren(e,t,r,o){return super._validateChildren(e,t,r.map(i=>i==="html_button"?"button":i==="html_dialog"?"dialog":i),o)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,o,i=null){o=Object.fromEntries(Object.entries(o??{}).map(([l,u])=>[l,ae(u)instanceof Xe?this.reference(u):u]));let s=t==="dataSetter"&&o?.value!==null&&typeof o?.value=="object"&&Object.getPrototypeOf(o.value)===Object.prototype?{...o,value:new x(o.value)}:o;return super.setChild(e,t,r,s,i)}#e(e){if(e==="data")throw new Error(sv);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 ln(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let o=t!=null?{_text:t}:null;e.setValue(r,!0,o,!0)}reference(e,t="node"){if(e=ae(e),!(e instanceof Xe)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=ee(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return F(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function ju(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function us(n){if(!n||!(n.value instanceof I))return null;let e=n.value.getNodes().find(o=>o.getAttr("region")==="center"),t=[];function r(o){if(o.nodeTag!=="framePane"&&(o.getAttr("frameTarget")===!0&&t.push(o),o.value instanceof I))for(let i of o.value.getNodes())r(i)}return e&&r(e),t.length===1?t[0]:null}function hv(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 mp(n){if(n&&typeof n=="object"){for(let e of Object.values(n))mp(e);Object.freeze(n)}return n}function gp(n,e){let t=n.node,r=t.getAttr("command"),o=n.runtime.gramlot.commands.get(r),i=ju(t),a=us(i);if(!o||!a)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let s=t.getAttr("parameters")??{};if(typeof s!="object"||Array.isArray(s))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(s).map(([p,w])=>[p,t.pointerType(w)?t.getRelativeData(w):w])),u=mp(j(F(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(p=>[p,!!e[`${p}Key`]]))),d=Object.freeze({sender:t,target:a,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(a).track(()=>{f=!0}),m=()=>!f&&hv(n)&&us(i)===a&&n.runtime.renderer.attached(a)&&t.getAttr("command")===r;return{message:d,current:m,release:h,cancel(){f=!0},deliver(){m()&&a.publish(o.publish,d)}}}var pv=new Set(["input","select","textarea"]),mv=["type","multiple"];function bp(n,e){let t=n.node,r=t.getAttr(e);return t.pointerType(r)?t.getRelativeData(r):n.resolved[e]}var Fe=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#o=!1;#a=!1;#i=!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!==Le)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?Hu:qu;if(e.localName==="textarea")return qt;if(e.localName==="select")return Ei;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(wp,r)?wp[r]:qt}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([]):e?.namespaceURI!==Le||!pv.has(e.localName)?null:JSON.stringify(mv.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.#a){this.#i=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)&&(!this.#o||this.same(this.read(),e))||(this.#e=e,this.#t=!0,!(this.#o&&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.#o=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#o=!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.#i=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#a=!0;return}if(e.type==="compositionend"){this.#a=!1,this.writeEvent==="input"&&this.commit(e),this.#i&&(this.#i=!1,this.binding.runtime.renderer.project(this.node));return}this.#a||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},qu=class extends Fe{#e;form=null;static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.form=this.element.supportsFormValidation&&this.node.pointerType(this.node.getAttr("value"))==="^"?this.node.formState:null,this.element.setPageContext(Wu(this)),this.form&&this.node.pointerType(this.node.getAttr("value"))==="^"&&(this.#e=this.form.register(this)),super.attach()}refresh(){let e=this.element.supportsFormValidation&&this.node.pointerType(this.node.getAttr("value"))==="^"?this.node.formState:null;e!==this.form&&(this.#e?.(),this.form=e,this.element.setPageContext(Wu(this)),this.#e=e?e.register(this):null)}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),this.#e?.(),super.detach()}commit(e){if(this.binding.closed||this.element.control.disabled||this.element.control.readOnly)return;let t=this.element.acceptControlValue();this.form||_p(this.element,t,r=>super.commit(e,r.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(e.type==="input"&&this.form&&!this.binding.closed&&!this.element.control.disabled&&!this.element.control.readOnly&&this.form.draft(this.node,this.element.control.value??""),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}))}}},qt=class extends Fe{static liveWrites=!0},Uu=class extends Fe{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},Vu=class extends Fe{static liveWrites=!0;read(){return Number(this.element.value)}},Ei=class extends Fe{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 o of t.options){let i=r.has(o.value);o.selected!==i&&(o.selected=i)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((r,o)=>Object.is(r,e[o])):super.same(e,t)}},un=class extends Fe{read(){return this.element.value===""?null:this.element.value}},zu=class extends Fe{},cs=class extends Fe{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()}},uo=class extends cs{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,r=Gu(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=Gu(this.node);if(!Object.is(e??null,t)){let o=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 i of o){if(this.binding.closed||!this.binding.runtime.renderer.attached(this.node))return;i.binding.closed||!i.binding.runtime.renderer.attached(i.node)||i.binding.runtime.renderer.html.writeParameter(i.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(bp(this,"value")&&this.groups.peersOf(e,t).some(o=>!o.binding.closed&&o.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 o=this.read();super.project(e,t),!r&&!o&&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),bp(e,"value")&&e.commit(null))}}},Hu=class extends uo{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||_p(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Wu(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,Gu(this.node)).filter(a=>!a.binding.closed&&!a.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let o=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,i=t[(r+o+t.length)%t.length];i.element.focus(),i.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},ds=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#o=0;constructor(e){this.#e=e}join(e,t,r){let o=this.nameOf(t,r);return this.#t.has(o)||this.#t.set(o,new Set),this.#t.get(o).add(e),this.#r.set(e,o),o}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.#o++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function Gu(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 wp={text:qt,password:qt,email:qt,url:qt,tel:qt,search:qt,number:Uu,range:Vu,color:zu,date:un,time:un,month:un,week:un,"datetime-local":un,checkbox:cs,radio:uo,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Wu(n){let{binding:e,node:t}=n,r=e.runtime.gramlot;return{locale:r.locale,timeZone:r.timeZone,createDecimal:Pt,isDecimal:fe,getDecimalLibrary:Eu,form:n.form,formCancelValidation:()=>n.form?.cancelValidation(t),formValidateCandidate:(o,i)=>n.form.validateCandidate(t,o,i),formValidate:()=>n.form?.scheduleValidation(n),formSelectionPending:o=>n.form?.pendingPart(t,"selection",o?"active":null),formSelectionError:o=>n.form?.issue(t,"selection",o),formParseError:o=>n.form?.parseError(t,o),formClearDraft:()=>n.form?.clearDraft(t),publish:(o,i)=>t.publish(o,i),isActive:()=>!e.closed,reportError:(o,i)=>{e.closed||e.runtime.reportError(o,i)},callLogic:(o,i)=>an(e.runtime,t,o,i),format:(o,i)=>r.format(o,i),...ls(e),selectionOutputs:({selectedCaption:o,selectedRecord:i,fields:a},s)=>{if(!e.closed){o&&t.setRelativeData(o,s?.caption??null),i&&t.setRelativeData(i,s?new x(s.record):null);for(let[l,u]of Object.entries(a))t.setRelativeData(u,s?.record[l.slice(9)]??null)}}}}function _p(n,e,t){let r=n.pageContext,o=i=>{i.ok&&i.isCurrent()&&(t(i),n.finishValidation(i))};if(e instanceof Promise)e.then(o).catch(i=>r.reportError(i,"Field update failed"));else try{o(e)}catch(i){r.reportError(i,"Field update failed")}}var Yu=Symbol("source text"),yp={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},gv=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"]),bv=new Set(["checked","muted","selected","value"]),wv=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function _v(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return wv.get(e.toLowerCase())??e}var fs=class{constructor({format:e,metadataAttributes:t=[],invokeScript:r=null,callLogic:o=null,reportError:i=null,uploadContext:a=null}={}){this.format=e,this.uploadContext=a,this.invokeScript=r,this.callLogic=o,this.reportError=i,this.metadataAttributes=new Set([...Yr,"_text",...t])}definition(e){let t=e.builder,o={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},i=e.nodeTag==="webcomponent"?Xt(e.getAttr()):ai(e.nodeTag,{renderTag:o.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),a=i==="foreignObject"?xr:o.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof yr?xr:Le);return{meta:o,namespace:a,tag:i}}validate(e,t=e.builder){this.validateLabelbox(e);let r=e.value instanceof I,o=r?e.getAttr("_text"):e.value;if(o!=null&&!["string","number","boolean"].includes(typeof o))throw new TypeError("HTML text must be scalar");let i=this.definition(e).meta.gramlot_component;for(let[l,u]of Object.entries(e.attr))if(!(i&&Object.hasOwn(i.parameters,l))&&!(e.nodeTag==="menuline"&&l==="parameters")&&!(this.metadataAttributes.has(l)||["ask","_ask"].includes(l)||u&&typeof u=="object"&&Object.hasOwn(u,"$gramlotRef"))&&u!=null&&!["string","number","boolean"].includes(typeof u))throw new TypeError(`HTML attribute ${l} must be scalar`);let a=Object.fromEntries(Object.entries(e.attr).filter(([l])=>!this.metadataAttributes.has(l))),s=r?e.value.getNodes().map(l=>l.nodeTag).filter(Boolean):[];t.validateNode(e,{value:o,attrs:a,childTags:s})}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!==Le&&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 o=e.parentNode;if(o?.nodeTag){let i=this.definition(o);if(i.namespace!==Le&&i.tag!=="foreignObject"||["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","ul","ol","dl","p","button","label"].includes(i.tag))throw new TypeError("Labelbox requires an HTML flow container")}}create(e,t,r=null,o=e.attr,i=null){let{tag:a,namespace:s,meta:l}=this.definition(e);r??=a;let u=s===Le?t.createElement(r):t.createElementNS(s,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({sourceNode:e,frameRecipient:()=>us(ju(e)),locale:e.rootBuilder.binding.gramlot.locale,timeZone:e.rootBuilder.binding.gramlot.timeZone,collectionView:(f,h)=>e.rootBuilder.binding.collectionView(e,f,h),format:this.format,upload:()=>this.uploadContext(),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));(s!==Le||!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=Jh(t,f),d.presentation=d.labelbox.box,d.labelId=`gramlot-label-${ee()}`,d.controlId=`gramlot-control-${ee()}`;let h=t.createElement("style");h.textContent=Kh,d.presentation.prepend(h),l.gramlot_component?.labelbox&&u.setLabelbox(d.labelbox)}return this.update(d,e,o,Yu,i),d}matches(e,t){let{tag:r,namespace:o}=this.definition(t);return(o===Le?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===o}writeParameter(e,t,r){let o=e.getAttr(t);e.pointerType(o)==="^"&&!re(o)&&!Object.is(e.getRelativeData(o.slice(1)),r)&&e.setRelativeData(o.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let o of r)e.element.append(o)}update(e,t,r=t.attr,o=Yu,i=null,a=null){if(t.nodeTag==="script"){for(let[b,_]of t.codeAttributes())if(t.activatedCode(b)!==_)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:s,text:l}=e;if(this.hasLabelbox(t)&&!e.labelbox)throw new TypeError("Declare lbl or box_* when creating an experimental HTML labelbox");let u=s.namespaceURI===Le,c=this.definition(t).meta.render_attributes??{},d=e.attrs??{},f=b=>(ao(t,b,t.builder.constructor.dialectPrefixes),io(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),h=t.parentNode;if(h?._getMeta("gramlot_component")?.childParameters&&(r=s.ownerDocument.defaultView.customElements.get(h._getMeta("render_tag")).projectChild(e.presentation,r,{label:t.label,adapt:f,invoke:(_,y,E)=>this.invokeScript(t,_,y,E),reportError:(_,y)=>this.reportError(t,_,y),publish:(_,y)=>t.publish(_,y),publishParent:(_,y)=>h.publish(_,y),writeParameter:(_,y)=>this.writeParameter(t,_,y),remove:()=>t.parentBag.popNode(t.label)})),e.labelbox&&(e.labelbox.box.style.visibility="",Qh(e.labelbox,r,f)),this.definition(t).meta.gramlot_component){if(this.definition(t).meta.gramlot_component.bagStore)if(t.nodeTag==="tree")s.setStoreBag(t.rootBuilder.binding.treeStore(t));else{let b=t.absDatapath(t.getAttr("storepath"));(!a||a.path===b||a.path.startsWith(`${b}.`)||b.startsWith(`${a.path}.`))&&s.setStoreBag(t.getRelativeData(t.getAttr("storepath")))}if(this.definition(t).meta.gramlot_component.bagStruct){let b=t.absDatapath(t.getAttr("structpath"));(!a||a.path===b||a.path.startsWith(`${b}.`)||b.startsWith(`${a.path}.`))&&s.setStructBag(t.getRelativeData(t.getAttr("structpath")))}r=s.projectAttributes(r,f)}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(Pe({...r,...c}));let m=Fe.classFor(s,r)!==null;o===Yu&&(o=this.text(t));let p=o==null?"":String(o);l.data!==p&&(l.data=p);let w=[...new Set([...Object.keys(d),...Object.keys(r)])];w.sort((b,_)=>(_==="sandbox")-(b==="sandbox")||(u&&s.localName==="input"?(_==="type")-(b==="type"):0));for(let b of w){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||m&&b==="value")continue;let _=r[b];if(u&&b==="multiple"&&["input","select"].includes(s.localName)){s.multiple!==!!_&&(s.multiple=!!_);continue}if(u&&s.localName==="input"&&b==="type"){Object.is(d.type,_)||(_==null?s.removeAttribute("type"):s.type=String(_));continue}let y=b,E=_v(y),N=u&&gv.has(E)&&typeof s[E]=="boolean",k=y==="xmlns"?"xmlns":y.includes(":")?y.split(":")[0]:"",C=Object.hasOwn(yp,k)?yp[k]:null;if(Object.is(d[b],_)||(_==null||N&&!_?C?s.removeAttributeNS(C,y.split(":").at(-1)):s.removeAttribute(y):C?s.setAttributeNS(C,y,String(_)):s.setAttribute(y,N?"":String(_))),u&&(N||bv.has(E))&&E in s){let O=E==="value"?_==null?"":String(_):!!_;s[E]!==O&&(s[E]=O)}}if(i===!1?s.style.visibility!=="hidden"&&(s.style.visibility="hidden"):e.visible===!1&&(r.style==null?s.removeAttribute("style"):s.setAttribute("style",String(r.style))),e.visible=i,e.labelbox){let{fieldLabel:b,labelBox:_,box:y}=e.labelbox;["input","textarea","select","button","output","meter","progress"].includes(e.tag)?(s.id||(s.id=e.controlId),b.htmlFor=s.id):(b.id=e.labelId,this.definition(t).meta.gramlot_component?.labelbox||(y.setAttribute("role","group"),_.hidden?y.removeAttribute("aria-labelledby"):y.setAttribute("aria-labelledby",b.id))),y.hidden=!!r.hidden,i===!1&&(y.style.visibility="hidden")}e.attrs=r}text(e){return e.value instanceof I?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};var hs=class n{#e;#t;#r=null;#n=0;#o=new Set;#a=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()??{},o=[];if(t.length&&o.push("controller"),r.action!=null&&o.push("action"),e.nodeTag==="menuline"&&r.command!=null&&o.push("registered"),vp(r).length&&o.push("fire"),e.nodeTag==="menuline"&&e.value instanceof I&&e.value.getNodes().some(i=>i.nodeTag==="menu")&&o.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&o.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(o.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${o.join(" and ")} together; a button has one click mechanism`);return o[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.#a!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#a=t)}for(let t of this.#o)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.#o)e.cancel(),e.release();this.#o.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);let r=this.element.closest("gramlot-row-actions"),o=r?r.getRowContext():null;if(r&&o===null||!this.element.prepareCommand(e))return;let i=this.mechanism;if(!i||(e.stopPropagation(),this.element.disabled))return;let a=i==="registered"?gp(this.binding,e):null;if(i==="registered"&&!a)return;a&&this.#o.add(a);let s=this.binding.countClick(),l=this.node;for(;l&&l.getAttr("_delay")==null;)l=l.parentNode;let u=l?l.rootBuilder.runtimeValues(l)[1]._delay:0;if(u>0){let c=this.#n+1;this.#r?.(),this.#n=c;let d=setTimeout(()=>{f(),this.#r=null,this.#n=0,this.#s(e,c,a,o)},u),f=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(d),a&&(a.cancel(),a.release(),this.#o.delete(a)),f(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#s(e,s,a,o)}async#i(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,o={...e.message.parameters};if(t&&r.required(this.binding,t,o,"ask")&&await r.show(this.binding,t,o)===null)return;e.deliver()}finally{e.release(),this.#o.delete(e)}}#s(e,t,r=null,o=null){if(r)return this.#i(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let a=this.node,s=yv(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t,rowContext:o});else if(i==="action"){let l=()=>{let[,f]=a.rootBuilder.runtimeValues(a),h=Object.fromEntries(Object.entries(f).filter(([m])=>m!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(h),...o,event:e,_counter:t,modifiers:s}},u=f=>{if(this.binding.closed||this.element.disabled||f===null)return;let h={...l(),...f};f&&(h._askResult=f),jt(this.binding.runtime,a,"action",a.getAttr("action"),h)},c=a.getAttr("ask"),d=this.binding.runtime.askDialog;if(c&&d.required(this.binding,c,l(),"ask"))return d.show(this.binding,c,l()).then(u);u(void 0)}else{let l={modifier:s,_counter:t},u=a.getAttr("fire");if(u!=null){a.FIRE(u,s||!0,l);return}for(let[c,d]of vp(a.getAttr())){if(this.binding.closed)return;a.FIRE(d,c.slice(5),l)}}}};function vp(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function yv(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var Tt=class extends ce{static classKwargs={...ce.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.#e(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}async#e(e){if(this.closed)return;let t=this._computeEffectiveFingerprint(this._buildEffectiveKw()),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let o=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(o,this.cacheTime!==0):this.cachedValue=o}finally{this.writing=!1}return o}};var co=class extends Tt{static internalParams=new Set([...Tt.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:o,onCalling:i=null,onError:a,sync:s=!1}){super({cacheTime:o,onError:a}),this.binding=e,this.sync=s,this.method=t,this.params=r,this.onCalling=i}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Ep=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function xp(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 o=r.attr,i=o.kind,a=r.staticValue;if(Object.keys(o).some(l=>!Ep.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(i))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(o[l]!=null&&typeof o[l]!="boolean"&&!(typeof o[l]=="string"&&o[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(o.favorite!=null&&typeof o.favorite!="boolean")throw new TypeError("favorite must be boolean");if(o.caption!=null&&typeof o.caption!="string")throw new TypeError("Menu caption must be text");if(o.parameters!=null&&(typeof o.parameters!="object"||Array.isArray(o.parameters)))throw new TypeError("Menu parameters must be a mapping");if(i==="command"&&(typeof o.command!="string"||!o.command||a!=null||o.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(i==="separator"&&(a!=null||Object.keys(o).length!==1))throw new TypeError("Separator record accepts kind only");if(i==="submenu"&&(typeof o.caption!="string"||o.command!=null||a instanceof x==(o.resolver!=null)||!(a instanceof x)&&a!=null))throw new TypeError("Submenu requires caption and exactly one content source");let s=a instanceof x?xp(a,t):null;return{label:r.label,attrs:{...o},children:s}})}function kp(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof I?n.value.getNodes():[],o=new Set(e.map(i=>i.label));for(let i of r)o.has(i.label)||n.value.popNode(i.label);for(let[i,a]of e.entries()){let{kind:s,...l}=a.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=s==="separator"?"-":null,d=n.value instanceof I?n.value.getNodes().find(m=>m.label===a.label):null,f=d?.value instanceof I;if(d&&(f!==(s==="submenu")||d.value==="-"!=(s==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=ae(t.menuline(c,{...l,node_label:a.label}));else{let m=Object.keys(d.attr).filter(p=>Ep.has(p)&&!Object.hasOwn(l,p));d.setAttr({...Object.fromEntries(m.map(p=>[p,null])),...l})}if(s==="submenu"){let m=d.value instanceof I?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=ae(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),a.children&&kp(m,a.children)}let h=n.value.getNodes().indexOf(d);h!==i&&n.value.move(h,i)}}var ps=class{#e=null;#t=null;#r=0;#n=!1;#o=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(([o])=>o.startsWith("resolver_")).map(([o,i])=>[o.slice(9),i])),r=F([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#o=null,this.#t=e.resolver?new co({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 o=t.cachedValue,i=xp(o),a=F(o);this.#o!==a&&(kp(this.node,i),this.#o=a),this.element.setStatus(i.length?null:"empty")}catch(o){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,o)}}};var ms=class{#e=!1;#t=!1;constructor(e,t){this.binding=e,this.element=t}attach(){this.element.cardActions=this}detach(){this.#e=!0,delete this.element.cardActions}async clear(){let{binding:e,element:t}=this,r=()=>!this.#e&&!e.closed&&t.isConnected&&t.parameters.delitem===!0;if(this.#t||!r())return;let o=e.node,i=o.value,a=o.absDatapath(".");if(!(a===null||!(i instanceof I))){this.#t=!0;try{if(await e.runtime.askDialog.show(e,{title:"Clear card fields",msg:`Clear the fields of \u201C${t.parameters.title}\u201D? This cannot be undone.`},{})===null||!r()||o.value!==i||o.absDatapath(".")!==a)return;let l=new Map,u=new Set,c=f=>{for(let h of["collapsed","checkbox"]){let m=f.getAttr(h);f.pointerType(m)&&u.add(f.absDatapath(m))}};c(o);let d=f=>{for(let h of f.getNodes()){h.nodeTag==="groupletCard"&&c(h);let m=h.getAttr("value");if(!h._getMeta("data_element")&&h.pointerType(m)==="^"&&!re(m)){let p=h.absDatapath(m);p!==null&&(a===""||p.startsWith(`${a}.`))&&l.set(p,{child:h,pointer:m})}h.staticValue instanceof I&&d(h.staticValue)}};d(i);for(let[f,{child:h,pointer:m}]of l){if(!r()||o.value!==i||o.absDatapath(".")!==a)break;u.has(f)||h.getAttr("value")!==m||h.absDatapath(m)!==f||e.runtime.renderer.html.writeParameter(h,"value",null)}}finally{this.#t=!1}}}};var gs="connect_on",xi=class{#e;#t;#r;#n;#o;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(gs)&&t.length>gs.length&&r!=null).map(([t,r])=>[t,t.slice(gs.length).toLowerCase(),r])}constructor(e,t,r,o,i=`${gs}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.#o=i}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#n}get attribute(){return this.#o}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(wi(this.handler))return an(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function cn(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 lt(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>cn(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 dn(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 lt(...e),e}function ki(n,e,t){let r=n-1,o=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let i=1;i<e;i++)o+=cn(n,i);return o}function Ti(n,e){let t=ki(...dn(n))+e;if(!Number.isSafeInteger(t)||t<0||t>ki(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,o=1e4;for(;o-r>1;){let a=Math.floor((r+o)/2);ki(a,1,1)<=t?r=a:o=a}t-=ki(r,1,1);let i=1;for(;t>=cn(r,i);)t-=cn(r,i++);return lt(r,i,t+1)}function Xu(n){return Ti(n,-(ki(...dn(n))%7))}function Tp(n,e,t=0,r=1){let o=n*12+e-1+t,i=Math.floor(o/12),a=(o%12+12)%12+1,s=o+r-1,l=Math.floor(s/12),u=(s%12+12)%12+1;return{start:lt(i,a,1),end:lt(l,u,cn(l,u))}}var bs={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 Ap(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(),o=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(bs,r))throw new RangeError(`Unsupported locale: ${n}`);let i=bs[r];return{dictionary:i,phrases:s=>[...new Set([...i.keywords[s],...bs.en.keywords[s]])],order:i.date_order[o]??i.date_order.default}}var fn=/^(?:\d{4}|\d{2})$/,Dp=/^\d{1,2}$/,Ai=(n,e)=>({ok:!1,error:{code:n,message:e}}),pn=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},Np=(n,e)=>Object.hasOwn(n,e);function hn(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 vv(n,e){if(n.includes(";")){let o=n.split(";").map(i=>i.trim());return o.length!==2?pn("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let o of t)if(n.startsWith(`${o} `))return{bounds:["",n.slice(o.length+1).trim()],range:!0};for(let o of t){let i=` ${o} `;if(!n.includes(i))continue;for(let s of r)if(n.startsWith(`${s} `)){n=n.slice(s.length+1);break}let a=n.split(i).map(s=>s.trim());return a.length!==2?pn("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:a,range:!0}}for(let o of r)if(n.startsWith(`${o} `))return{bounds:[n.slice(o.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function Ev(n,e,t){let r=[[n,0]],o=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);o&&r.push([o[1],Number(o[2]+o[3])]);let i={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[a,s]of r)for(let[l,u]of Object.entries(i))if(e.phrases(l).includes(a)){if(l.endsWith("_week"))return Ti(Xu(e.workdate),(u+s)*7+(t?6:0));if(l.endsWith("_month")){let c=Tp(e.year,e.month,u+s);return t?c.end:c.start}return Ti(e.workdate,u+s)}return null}function xv(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((o,i)=>i[0].length-o[0].length);for(let[o,i]of r){let a;if(n===o)a=null;else if(n.startsWith(o)&&fn.test(n.slice(o.length).trim()))a=hn(n.slice(o.length).trim(),e);else if(n.endsWith(o)&&fn.test(n.slice(0,-o.length).trim()))a=hn(n.slice(0,-o.length).trim(),e);else continue;return{year:a,month:t?i*3:i*3-2}}return null}function Sp(n,e){if(Np(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 kv(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>Sp(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return pn();let o=r[0],i=Sp(t[o],e.dictionary),a=t.slice(0,o),s=t.slice(o+1),l=[...a,...s];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(i>e.month?1:0),month:i};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(i<e.month?1:0),month:i};if(!l.length)return{year:null,month:i};if(!a.length&&s.length===1&&fn.test(s[0]))return{year:hn(s[0],e),month:i};if(a.length===1&&Dp.test(a[0])){if(!s.length)return lt(e.year,i,Number(a[0]));if(s.length===1&&fn.test(s[0]))return lt(hn(s[0],e),i,Number(a[0]))}return!a.length&&s.length===2&&Dp.test(s[0])&&fn.test(s[1])?lt(hn(s[1],e),i,Number(s[0])):pn()}function Tv(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return lt(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),o={};if(r)e.order.split("").forEach((s,l)=>{o[s]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let s=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?s:2;o[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!fn.test(o.Y)||o.D.length>2||o.M.length>2)return pn();let i=Number(o.D),a=Number(o.M);return r&&a>12&&i<=12&&([i,a]=[a,i]),lt(hn(o.Y,e),a,i)}function Cp(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(i=>!r.includes(i)).join(" "),!n)return pn();if(fn.test(n))return lt(hn(n,e),t?12:1,t?31:1);let o=Ev(n,e,t)??xv(n,e,t)??kv(n,e);return o!==null?o:Np(e.dictionary.weekdays,n)?Ti(Xu(e.workdate),e.dictionary.weekdays[n]):Tv(n,e)??pn()}function Av(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,o=typeof e=="string"?dn(e)[0]:e?.year,i=typeof e=="string"?dn(e)[1]:e?.month;return o&&(r>o&&(r=o),r===o&&n.month>i&&r--),lt(r,n.month,1)}function Dv(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[o,i]=dn(e);r<o&&(r=o),r===o&&i>n.month&&r++}return lt(r,n.month,cn(r,n.month))}function ws(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return Ai("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:o,twoDigitYearAhead:i=20}=e,[a,s]=dn(o);if(!Number.isInteger(i)||i<0||i>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...Ap(r),workdate:o,year:a,month:s,twoDigitYearAhead:i}}catch(r){return Ai("INVALID_CONTEXT",r.message)}if(typeof n!="string")return Ai("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:o,range:i}=vv(r,t),a=Cp(o[1],t,!0),s=Cp(o[0],t,!1),l=Av(s,a,t),u=Dv(a,l,t);return!i&&typeof s=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return Ai("INVALID_DATE",r.message);if(r instanceof SyntaxError)return Ai(r.code,r.message);throw r}}function Ip(n){if(n===null)return null;let{value:e,columns:t,dtype:r,locale:o}=n;if(typeof e!="string"||!Array.isArray(t)||!t.length||t.some(u=>typeof u!="string"||!u||u==="rowidx")||!["T","L","R","N","D"].includes(r))throw new TypeError("Invalid collection filter");if(!e.trim())return null;if(r==="T"){let u=new RegExp(e,"i");return c=>u.test(t.map(d=>Sv(c(d),o,n.timeZone)).join(" "))}if(t.length!==1)throw new TypeError("Typed filters require one column");let i=/^\s*(<=|>=|==|!=|[<>=!#])\s*(.+?)\s*$/.exec(e);if(!i)throw new Error("Enter a comparison, for example > 100 or = 12.");let[,a,s]=i,l;if(r==="D"){let u=new Date,c=`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,d=ws(s,{locale:o,workdate:c});if(!d.ok||d.kind!=="date")throw new Error("Enter one complete date after the comparison.");l=new Date(`${d.date}T00:00:00Z`)}else l=Cv(s,o);return u=>{let c=u(t[0]);if(c==null)return!1;if(r==="D"?!(c instanceof Date)||!Number.isFinite(c.getTime()):!(typeof c=="number"&&Number.isFinite(c)||fe(c)&&c.isFinite()))throw new TypeError(`Filter value does not match ${r}`);let d=fe(l)?-l.comparedTo(c):c<l?-1:c>l?1:0;switch(a){case"=":case"==":return d===0;case"!":case"#":case"!=":return d!==0;case"<":return d<0;case">":return d>0;case"<=":return d<=0;case">=":return d>=0}}}function Sv(n,e,t){return n==null?"":typeof n=="string"||typeof n=="boolean"?String(n):os(n,{pattern:n instanceof Date?"short":"#,##0.####################"},{locale:e,timeZone:t})}function Cv(n,e){let t=new Intl.NumberFormat(e).formatToParts(-12345.6),r=t.find(l=>l.type==="decimal").value,o=t.find(l=>l.type==="group")?.value,i=t.find(l=>l.type==="minusSign").value,a=n.replaceAll(i,"-");if(o&&a.includes(o)){let u=a.split(r)[0].replace(/^[+-]/,"").split(o),c=new Intl.NumberFormat(e).formatToParts(1234567890123).filter(h=>h.type==="integer").map(h=>h.value.length),d=c.at(-1),f=c.at(-2);if(a.split(r).slice(1).some(h=>h.includes(o))||!/^\d+$/.test(u[0])||u[0].length>f||u.slice(1).some((h,m)=>!/^\d+$/.test(h)||h.length!==(m===u.length-2?d:f)))throw new Error("Invalid numeric grouping.");a=a.replaceAll(o,"")}if(a=a.replace(r,"."),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(a))throw new Error("Enter a complete number.");let s=Pt(a);if(!fe(s)||!s.isFinite())throw new Error("A finite Decimal backend is required.");return s}var _s=class{#e=new Set;constructor(e,t){if(!(e instanceof x))throw new TypeError("collection store requires a Bag");if(!["values","attributes"].includes(t))throw new TypeError("collection store rowMode must explicitly be values or attributes");if(!e.parentNode)throw new TypeError("collection store requires a Bag attached to Data");this.bag=e,this.rowMode=t}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}receiveData(e,t=null){ys(this.#e,{full:t===null,rows:t?[t]:[]})}getRows(){let e=this.bag.getNodes();for(let t of e){if(t.resolver)throw new TypeError("collection store requires loaded rows");if(this.rowMode==="values"&&!(t.staticValue instanceof x))throw new TypeError(`collection store row ${t.label} must contain a Bag`)}return e}value(e,t){if(e.resolver)throw new TypeError("collection store requires loaded rows");if(this.rowMode==="attributes")return e.getAttr(t);let r=e.staticValue;if(!(r instanceof x))throw new TypeError(`collection store row ${e.label} must contain a Bag`);let o=r.getNode(t);if(o?.resolver)throw new TypeError("collection store requires loaded cells");return o?.staticValue}};function ys(n,e){let t=[],r=Object.freeze({full:e.full,rows:Object.freeze([...e.rows])});for(let o of[...n])if(n.has(o))try{o(r)}catch(i){t.push(i)}if(t.length)throw new AggregateError(t,"Collection notification failed")}var vs=class{#e;#t=null;#r=new Set;#n=new Map;#o="";#a=null;#i=null;#s=null;constructor(e){this.bindStore(e)}get bag(){return this.#e.bag}get rowMode(){return this.#e.rowMode}get sortedBy(){return this.#o}get criteria(){return Op(this.#o)}get filter(){return this.#a}get filtered(){return this.#s===null?null:[...this.#s]}isFiltered(){return this.#s!==null}value(e,t){return this.#e.value(e,t)}subscribe(e){return this.#r.add(e),()=>this.#r.delete(e)}connect(){this.#t||(this.synchronize(),this.#t=this.#e.subscribe(e=>this.synchronize(e)))}disconnect(){this.#t?.(),this.#t=null}bindStore(e){if(this.#e===e)return;let t=this.#t!==null;this.disconnect(),this.#e=e,this.#n.clear(),t?this.connect():this.synchronize()}getRows(e=!0){let t=this.#l();return e&&this.#s!==null?this.#s.map(r=>t[r]):t}#l(){return this.#e.getRows().toSorted((e,t)=>(this.#n.get(e)??1/0)-(this.#n.get(t)??1/0))}synchronize(e={full:!0,rows:[]}){if(!e.full&&!this.#o&&!this.#i){ys(this.#r,e);return}this.#c(this.#u(this.#l(),this.criteria),this.#o,this.#a,this.#i,e)}sort(e){let t=this.#u(this.#l(),Op(e));this.#c(t,e,this.#a,this.#i)}moveRow(e,t,r=!1){if(e===t||e.parentBag!==this.bag||t.parentBag!==this.bag)return;let o=this.getRows(!1);o.splice(o.indexOf(e),1),o.splice(o.indexOf(t)+Number(r),0,e),this.#c(o,"",this.#a,this.#i)}applyFilter(e){let t=e===null?null:Object.freeze({...e,columns:Object.freeze([...e.columns])}),r=Ip(t);this.#c(this.#l(),this.#o,t,r)}#c(e,t,r,o,i={full:!1,rows:[]}){let a=o?e.flatMap((c,d)=>o(f=>this.value(c,f))?[d]:[]):null,s=i.full||t!==this.#o||JSON.stringify(r)!==JSON.stringify(this.#a)||e.length!==this.#n.size||e.some((c,d)=>this.#n.get(c)!==d)||JSON.stringify(a)!==JSON.stringify(this.#s);this.#n=new Map(e.map((c,d)=>[c,d])),this.#o=t,this.#a=r,this.#i=o,this.#s=a;let l=a===null?null:new Set(a),u=s?[]:i.rows.filter(c=>this.#n.has(c)&&(l===null||l.has(this.#n.get(c))));(s||u.length)&&ys(this.#r,{full:s,rows:u})}#u(e,t){if(!t.length)return e;let r=e.map(o=>({node:o,keys:t.map(({field:i})=>this.value(o,i))}));for(let o=0;o<t.length;o++)if(new Set(r.map(a=>Nv(a.keys[o])).filter(a=>a!==null)).size>1)throw new TypeError(`collection view cannot compare mixed types in ${t[o].field}`);return r.sort((o,i)=>{for(let[a,{direction:s}]of t.entries()){let l=Iv(o.keys[a],i.keys[a]);if(l)return s==="a"?l:-l}return 0}).map(o=>o.node)}};function Op(n){if(typeof n!="string")throw new TypeError("collection view sortedBy must be a string");if(n==="")return[];let e=new Set;return n.split(",").map(t=>{let r=/^([^,:]+):([ad])$/.exec(t);if(!r||e.has(r[1]))throw new TypeError(`Invalid collection view sort criterion: ${t}`);return e.add(r[1]),{field:r[1],direction:r[2]}})}function Nv(n){if(n==null)return null;if(typeof n=="number"&&Number.isFinite(n)||fe(n)&&n.isFinite())return"number";if(n instanceof Date&&Number.isFinite(n.getTime()))return"date";if(typeof n=="string"||typeof n=="boolean")return typeof n;throw new TypeError("collection view sort requires loaded finite scalar values")}function Iv(n,e){return n==null||e==null?n==null?e==null?0:-1:1:fe(n)?n.comparedTo(e):fe(e)?-e.comparedTo(n):n<e?-1:n>e?1:0}var Es=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},Zu=class{#e;#t;#r;#n;#o;#a=!0;#i;constructor(e,{path:t,attr:r,recipient:o,order:i,subtree:a=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.#o=i,this.#i=a}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#i}get active(){return this.#a}get order(){return this.#o}close(){this.active&&(this.#a=!1,this.router.unregister(this))}},Ku=class{constructor({evt:e,node:t,path:r,oldvalue:o,attrsDiff:i,reason:a,fired:s,level:l,registration:u,index:c}){this.evt=e,this.node=t,this.path=r,this.oldvalue=o,this.attrsDiff=i,this.reason=a,this.fired=s,this.level=l,this.registration=u,this.index=c}},xs=class{#e;#t=new Es;#r=new Map;#n=0;#o=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:o=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let i=this.#t;for(let s of e.split(".")){let l=i.children.get(s);l||(l=new Es(i,s),i.children.set(s,l)),i=l}this.#o+=1;let a=new Zu(this,{path:e,attr:t,recipient:r,order:this.#o,subtree:o});return i.registrations.add(a),this.#r.set(a,i),this.#n+=1,a}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]!==ci||e.reason==="autocreate")return;let r=t.slice(1),o=e.evt==="ins"||e.evt==="del";for(let i of Array.isArray(e.node)?e.node:[e.node]){let a=o?[...r,i.label]:r,s=a.join(".");for(let[l,u]of this.#a(a,e))l.active&&l.recipient.receive(new Ku({evt:e.evt,node:i,path:s,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}))}}#a(e,t){let r=[],o=this.#t;for(let a of e){for(let s of o.registrations)o!==this.#t&&this.#i(s,"child",t)&&r.push([s,"child"]);if(o=o.children.get(a),!o)return r.sort(([s],[l])=>s.order-l.order)}for(let a of o.registrations)this.#i(a,"node",t)&&r.push([a,"node"]);let i=[...o.children.values()];for(;i.length;){let a=i.pop();for(let s of a.registrations)this.#i(s,"container",t)&&r.push([s,"container"]);i.push(...a.children.values())}return r.sort(([a],[s])=>a.order-s.order)}#i(e,t,r){let{evt:o}=r;return e.subtree?t!=="container"||o!=="upd_attrs":e.attr===null?o==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?o!=="upd_attrs":o==="ins"||o==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var Ov=new Set(["T","B","L","R","N","D","H","DHZ"]),Rv=new Set(["tag","field","name","dtype","width","align","format","columnset","white_space","edit"]),Bv=new Set(["tag","code","name","background","color"]),Di=class{#e=new Map;constructor(e){if(!(e instanceof x))throw new TypeError("grid structpath must resolve to a Bag");let t=ks(e,"view_0"),r=ks(e,"info"),o=ks(t,"rows_0"),i=ks(r,"columnsets"),a=new Set,s=new Map;for(let l of i.getNodes()){let u=l.getAttr();if(Rp(u,Bv),Bp(u.code,"colgroup code"),u.tag!=="columnset"||l.resolver||l.staticValue!=null||l.label!==u.code)throw new TypeError("grid columnset requires a scalar definition labelled by code");if(s.has(u.code))throw new TypeError(`Duplicate grid colgroup: ${u.code}`);if(u.name!=null&&typeof u.name!="string")throw new TypeError("grid group name must be text");for(let c of["background","color"])if(u[c]!=null&&typeof u[c]!="string")throw new TypeError(`grid ${c} must be text`);s.set(u.code,{...u,name:u.name??u.code})}this.columns=[],this.groups=[];for(let l of o.getNodes()){let u=l.getAttr();if(Rp(u,Rv),u.tag!=="cell"||l.staticValue!=null||l.resolver)throw new TypeError("grid cell must be a scalar declaration");if(Bp(u.field,"field"),a.has(u.field))throw new TypeError(`Duplicate grid field: ${u.field}`);if(a.add(u.field),this.#e.set(u.field,l),u.columnset!=null&&!s.has(u.columnset))throw new TypeError(`Unknown grid columnset: ${u.columnset}`);if(u.dtype!=null&&!Ov.has(u.dtype))throw new TypeError(`Unsupported grid dtype: ${u.dtype}`);if(u.align!=null&&!["start","center","end"].includes(u.align))throw new TypeError("grid align requires start, center or end");if(u.width!=null&&(typeof u.width!="string"||!/^(?:\d+(?:\.\d+)?)(?:px|em|rem|ch|%)$/.test(u.width)))throw new TypeError("grid width requires a nonnegative CSS length (px, em, rem, ch or %)");if(u.white_space!=null&&!["normal","nowrap","pre-wrap"].includes(u.white_space))throw new TypeError("grid white_space requires normal, nowrap or pre-wrap");for(let h of["name","format"])if(u[h]!=null&&typeof u[h]!="string")throw new TypeError(`grid ${h} must be text`);if(u.edit!=null&&typeof u.edit!="boolean"&&(typeof u.edit!="object"||Array.isArray(u.edit)))throw new TypeError("grid edit requires a boolean or editor options");let c=Object.freeze({...u,name:u.name??u.field,align:u.align??(["L","R","N"].includes(u.dtype)?"end":"start")});this.columns.push(c);let d=u.columnset??null,f=this.groups.at(-1);(!f||f.code!==d)&&(f={code:d,...d===null?{name:null}:s.get(d),columns:[]},this.groups.push(f)),f.columns.push(c)}if(!this.columns.length)throw new TypeError("grid struct requires at least one column");for(let l of this.groups)Object.freeze(l.columns),Object.freeze(l);Object.freeze(this.columns),Object.freeze(this.groups),Object.freeze(this)}columnNode(e){return this.#e.get(e)}moveColumn(e,t,r=!1){let o=this.#e.get(e),i=this.#e.get(t);if(!o||!i||o===i)return;let a=o.parentBag,s=a.getNodes(),l=s.indexOf(o),u=s.indexOf(i),c=u+Number(r)-+(l<u);c!==l&&a.move(l,c)}setColumnWidth(e,t){if(!Number.isFinite(t)||t<=0)throw new TypeError("grid resized width must be positive pixels");this.#e.get(e).setAttr({width:`${Math.round(t)}px`})}};function ks(n,e){let t=n.getNode(e);if(!t||t.resolver||!(t.staticValue instanceof x))throw new TypeError(`grid struct requires Bag ${e}`);return t.staticValue}function Rp(n,e){for(let t of Object.keys(n))if(!e.has(t))throw new TypeError(`Unsupported grid struct attribute: ${t}`)}function Bp(n,e){if(typeof n!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new TypeError(`grid ${e} requires a simple field identifier`)}function $p(n){let e=new x,t=new x,r=new x;e.setItem("view_0",new x,{tag:"view"}),e.getItem("view_0").setItem("rows_0",t,{tag:"rows"}),e.setItem("info",new x),e.getItem("info").setItem("columnsets",r);let o=(i,a=null)=>{if(i.builder.validateNode(i),i.nodeTag!=="column"||i.staticValue!=null)throw new TypeError("grid column must be a scalar declaration");let s={tag:"cell"};for(let u of["field","name","dtype","width","align","format","white_space","edit"])i.getAttr(u)!=null&&(s[u]=i.getAttr(u));let l=`cell_${s.field}`;if(t.getNode(l))throw new TypeError(`Duplicate grid field: ${s.field}`);a!==null&&(s.columnset=a),t.setItem(l,null,s)};for(let i of n.getNodes())if(i.nodeTag==="column")o(i);else if(i.nodeTag==="colgroup"){if(i.builder.validateNode(i),!(i.staticValue instanceof I))throw new TypeError("grid colgroup requires column declarations");let a=i.getAttr("code");if(r.getNode(a))throw new TypeError(`Duplicate grid colgroup: ${a}`);let s={tag:"columnset",code:a,name:i.getAttr("name")??a};for(let l of["background","color"])i.getAttr(l)!=null&&(s[l]=i.getAttr(l));r.setItem(a,null,s);for(let l of i.staticValue.getNodes())o(l,a)}else throw new TypeError("grid struct accepts column and colgroup only");return e}function Mp(n){if(n._getMeta("gramlot_component")?.bagStruct){let e=n.staticValue instanceof I?n.staticValue.getNodes():[];if(e.some(t=>!t._getMeta("gridStruct"))||e.length>1)throw new TypeError("grid accepts one struct declaration");if(e.length&&n.getAttr("structpath")!=null)throw new TypeError("grid requires structpath or nested struct, not both");if(!e.length&&!n.getAttr("structpath"))throw new TypeError("grid requires structpath or nested struct");if(!["values","attributes"].includes(n.getAttr("rowMode")))throw new TypeError("grid rowMode must explicitly be values or attributes")}if(n._getMeta("gridStruct")){if(!n.parentNode?._getMeta("gramlot_component")?.bagStruct)throw new TypeError("struct requires a grid parent");if(!(n.staticValue instanceof I))throw new TypeError("grid struct requires column declarations");new Di($p(n.staticValue))}}function Pp(n,e){let t=$p(n.staticValue);new Di(t);let r=`gramlot.grid.${crypto.randomUUID().replaceAll("-","")}.struct`;e.setItem(r,t,null,">",!1,!0,n),n.parentNode.setAttr({structpath:r},!1),n.setValue(null,!1)}var Ts=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=Si(e),r=this.setterNodes(e);Qu(e);for(let o of r)o._getMeta("gridStruct")?Pp(o,this.runtime.data):this.applySetter(o),this.runtime.closeBranch(o),o.parentBag&&o.parentBag.popNode(o.label);this.applyDefaults(t.filter(o=>o.nodeTag&&!o._getMeta("data_element")))}setterNodes(e){return Si(e).filter(t=>t.nodeTag==="dataSetter"||t._getMeta("gridStruct"))}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let r=e.getAttr("value")??null,o=Mv(e.getAttr()),i=this.runtime.data;if(r!==null)i.setItem(t,r,o,">",!1,!0,e),r instanceof x&&e.setAttr({value:null},!1);else{let a=i.getNode(t);a?o&&a.setAttr(o,!0):i.setItem(t,null,o,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[o,i]of Object.entries(r)){if(!$v(t,o,i))continue;let a=o==="value"?r.default_value??r.default:r[`default_${o}`];a!=null&&this.#t(t,i,a)}this.#r(t,r)}}#t(e,t,r){let o=e.absDatapath(t);if(o===null)return;let[i,a=null]=o.split("?",2),s=this.runtime.data,l=s.getNode(i);if(a===null){if(l&&l.value!==null&&l.value!==void 0)return;s.setItem(i,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(a);u==null&&l.setAttr({[a]:r},!0)}else s.setItem(i,null,{[a]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[a,s]of Object.entries(t))a.startsWith("attr_")&&(r[a.slice(5)]=re(s)?Sr(e,a):e.pointerType(s)?e.getRelativeData(s):s);if(!Object.keys(r).length)return;let o=[t.value,t.src].find(a=>e.pointerType(a));if(!o)return;let i=e.absDatapath(o);i!==null&&this.runtime.data.getNode(i.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function $v(n,e,t){return e==="_meta"||Yr.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function Mv(n){let e={};for(let[t,r]of Object.entries(kr(n??{})))Yr.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function Pv(n){let e=n.builder;if(!(e instanceof Ie))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function Qu(n){for(let e of Si(n))Mp(e),e.nodeTag==="dataSetter"&&Pv(e),Uv(e)}var Lv=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Fv=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),jv=["_onCalling","_onResult","_onError"],qv=["_delay","_timing","_userChanges"],Ju=["_init","_onBuilt","_onStart"];function Uv(n){let e=i=>n.getAttr(i)!==null&&n.getAttr(i)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let i=jv.find(a=>e(a)&&!(a==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(i){let a=i==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${i}' is allowed only on ${a}`)}}if(Fv.has(n.nodeTag)){let i=Object.entries(n.getAttr()).find(([,s])=>pt(s));if(i)throw new Error(`${n.nodeTag} '${n.label}': '${i[0]}' is a == expression, not accepted on ${n.nodeTag}`);let a=n.nodeTag==="dataRemote"?Ju.find(e):null;if(a)throw new Error(`dataRemote '${n.label}': '${a}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let s of Ju){let l=n.getAttr(s);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${s}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Lv.find(i=>e(i)&&!(i==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&qv.includes(i)));if(!r)return;let o=Ju.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${o}`)}function Si(n){if(n instanceof I)return n.getNodes().flatMap(t=>Si(t));let e=[n];return n.value instanceof I&&e.push(...Si(n.value)),e}var Vv=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"]),Ci=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,o=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(o)),this.#r=()=>{clearTimeout(o),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),o=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),o(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},fo=class{#e;#t=[];#r=new Set;#n;#o=null;#a=!1;constructor(e){this.#e=e,this.#n=new Ci(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,o=Lt(e,e.getAttr("_timing"));for(let[i,a]of e.pointers()){if(i==="datapath")continue;let s=e.absDatapath(a);if(s===null)continue;let[l,u=null]=s.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(i==="_timing"||o.has(i))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(i,a,s)=>(l,u)=>{let c={kind:"subscription",topic:s,payload:l,metadata:u};if(this.#s("_userChanges")&&s!=="node")return;let d=this.#s("_delay");d>0?this.#n.debounce(d,()=>this.invoke(c)):this.invoke(c)})),this.#i(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#i();return}if(this.#s("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},r=this.#s("_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",o=this.kind==="rpc",i=this.kind==="remote",a=this.readArguments(e);e.askResult&&(Object.assign(a,e.askResult),a._askResult=e.askResult);let s=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(s&&!e.askDone&&l.required(this.binding,s,a,"_ask"))return l.show(this.binding,s,a,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,a,!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})`,a,!1)){if(i&&this.#f(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(o||i){this.#l(u,c,c,a,!0);return}}if(o)return this.#c(a);if(i)return this.#d(a);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,a,!0);else if(f==null){if(!r)return;h=new x(As(a))}else{let{group:m,method:p}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?p.call(m,a):p.call(m,t,a)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),o=Object.fromEntries(Object.entries(r).filter(([l])=>!Vv.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),i={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(o)};e.kind==="subscription"&&(i._subscription_kwargs=e.payload,i._subscription_metadata=e.metadata);let a=e.change??null,s=a?a.level:e.kind==="subscription"?e.topic:e.kind;return i._node=a?a.node:null,i._triggerpars={kw:a,trigger_reason:s},i._reason=s,e.kind==="click"&&(Object.assign(i,zv(e)),e.rowContext&&Object.assign(i,e.rowContext,{event:e.event})),i}cancel(){this.#n.cancel()}#i(){this.#n.startTiming(this.#s("_timing"),()=>this.invoke({kind:"timing",change:null}))}#s(e){let t=this.node,r=t.getAttr(e);return re(r)?Sr(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,o,i){let a=[...i?["_kwargs"]:[],...Lp,...Fp,...Object.keys(As(o))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?jt(this.binding.runtime,this.node,e,t,{...o,_kwargs:o},a):this.binding.runtime.inlineCompiler.compile(this.node,e,t,a,r)({...o,_kwargs:o})}async#c(e){let t=this.node,[r,o,i]=["_onCalling","_onResult","_onError"].map(s=>t.getAttr(s)),a=t.requests;if(a.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return a.submit(this.#s("method"),As(e),s=>this.#u(s,e,o,i))}async#u(e,t,r,o){if(this.binding.closed)return;let i=this.node,a=this.#s("timeout"),s=a>0?setTimeout(()=>{let c=new Error(`${i.nodeTag} '${i.label}': no answer within ${a} ms`);c.name="TimeoutError",e.controller.abort(c)},a):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(s),this.binding.closed||e.ignored)return;if("error"in l){if(!o)throw l.error;this.#l("_onError",o,o,{...t,error:l.error},!0);return}let{result:u}=l;i.getAttr("result_path")!=null&&i.setRelativeData(i.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#f();let t=this.#a;this.#a=!1;let r=this.node,o=r.absDatapath(r.pathAttribute("destination_path"));if(o===null)return;let i=r.getAttr("_onCalling"),a=new co({binding:this.binding,method:this.#s("method"),params:As(e),cacheTime:this.#s("cacheTime"),sync:this.#s("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:i?()=>this.#l("_onCalling",i,i,e,!0):null,onError:s=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${a.method}' failed: ${s.message}`,{cause:s})}});this.binding.runtime.data.setResolver(o,a),this.#o={path:o,resolver:a},t&&a.refresh()}#f(){if(!this.#o)return;let{path:e,resolver:t}=this.#o;this.#o=null,this.#a=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()}},Ds=class extends fo{get kind(){return"formula"}},Ss=class extends fo{get kind(){return"controller"}},Cs=class extends fo{get kind(){return"rpc"}},Ns=class extends fo{get kind(){return"remote"}},Lp=["_node","_triggerpars","_reason","_subscription_kwargs","_subscription_metadata","_askResult"],Fp=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function As(n){let e={...n};for(let t of[...Lp,...Fp])delete e[t];return e}function zv({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 Hv=[[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 "]],Gv=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,Wv=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"]),Is=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 o=r.trim();if(Gv.test(o))throw new Error(`${Ni(e,t)}: the PUBLISH macro is excluded from Gramlot`);let i=o.replace(/\$(\d+)/g,(a,s)=>`arguments[${parseInt(s,10)-1}]`);for(let[a,s,l]of Hv)a&&(i=i.replace(a,`; ${a.source.slice(1)}`)),i=i.replace(s,l);return i!==o&&console.warn(`${Ni(e,t)}: legacy macros are deprecated; write this.GET(path), this.SET(path, value), this.PUT(path, value), this.FIRE(path, value), this.FIRE_AFTER(path, value) and arguments[n] in place of GET, SET, PUT, FIRE, FIRE_AFTER and $n`),i}compile(e,t,r,o,i=r){if(e.activatedCode(t)!==r)throw new Error(`${Ni(e,t)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);let a=this.#t.get(e);a||(a=new Map,this.#t.set(e,a),this.runtime.bindingFor(e).track(()=>this.release(e)));let s=a.get(t);s?.source!==i&&(s={source:i,text:this.preprocess(e,t,i),key:null,run:null},a.set(t,s));let l=o.filter(Yv),u=l.join(",");if(s.key!==u){let c=Xv(e,t,s.text,l);s.key=u,s.run=d=>c.apply(e,l.map(f=>d[f]))}return s.run}compileExpression(e,t,r){let o=r.slice(2).trim(),i=Pe(e.getAttr()).filter(([,s])=>!pt(s)),a=this.compile(e,t,r,[...i.map(([s])=>s).filter(s=>s!=="_F"),"_F"],`return ${o}`);return s=>{let l={};for(let[u,c]of i)Object.hasOwn(s,u)?l[u]=s[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return a({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,r,o){let i=this.compile(e,t,r,["_pointerValues","_F"],`return (${o}
|
|
195
|
-
)`);return a=>i({_pointerValues:a,_F:(s,l)=>this.runtime.gramlot.format(s,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let o of t){r.delete(o);for(let[i]of
|
|
191
|
+
`,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"),this.#e&&this.setActionPresentation(this.#e),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}setActionPresentation(e){this.#e=e,this.hidden=e.hidden,this.icon.textContent=e.icon,this.title=e.title,this.control.setAttribute("aria-label",e.title)}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}yi.parameters={action:{dtype:"T",nullable:!0},disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var iv=Ar({name:"button",tag:"gramlot-button",base:yi,command:!0,subTags:"*",implementation:n=>class extends n{}}),av=Ar({name:"toggleButton",tag:"gramlot-toggle-button",base:yi,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)}}}),sv=Ar({name:"menu",tag:"gramlot-menu",base:bp,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{}}),lv=Ar({name:"menuline",tag:"gramlot-menu-line",base:yi,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:wp}),uv=Ar({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=no(this,e),{size:r,flex:o}=this.parameters;if(r!=null&&o!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||o!=null&&(!Number.isFinite(o)||o<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=o!=null?`${o} 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{}}),cv=Ar({name:"dropDownButton",tag:"gramlot-drop-down-button",base:yi,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#o;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#o=e.createElement("span"),this.#o.hidden=!0,this.control.append(this.#o),this.#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(Re).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.#a(),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.#a(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#a()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.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.#a()}this.closeMenu()}#a(){let e=this.menuItems.map(o=>o.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.#o.hidden=!r,this.#o.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()}}}),ds=Hu({name:"buttons",components:[iv,av,cv,sv,lv,uv]});var co=class{epoch=0;controller=null;cancel(){this.epoch++,this.controller?.abort(),this.controller=null}start(e,t,r,o,i,a=()=>{}){this.cancel();let s=new AbortController,l=this.epoch;this.controller=s;let u=r.validationCurrent(),c=()=>l===this.epoch&&!s.signal.aborted&&u(),d=m=>({value:e,modified:!1,error:m.message,warnings:[],issues:[],datachanges:[]}),f=!1,h=m=>{if(f||!c())return{ok:!1};f=!0,this.controller=null;let w={ok:!m.error,value:m.value,result:m,rules:t,isCurrent:c};return i(w),w},p;try{if(t.validate_timeout!=null&&(!Number.isInteger(t.validate_timeout)||t.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");p=o(e,t,{...r,signal:s.signal})}catch(m){return h(d(m))}return p instanceof Promise?(a(),new Promise(m=>{let w,b=()=>{clearTimeout(w),m({ok:!1})};s.signal.addEventListener("abort",b,{once:!0});let _=y=>{clearTimeout(w),s.signal.removeEventListener("abort",b);try{m(h(y))}catch(E){r.reportError(E,"Validation completion failed"),m({ok:!1})}};t.validate_timeout!=null&&(w=setTimeout(()=>{_(d(new Error("Validation timed out."))),s.abort()},t.validate_timeout)),p.then(_,y=>_(d(y)))})):h(p)}};function vi(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function Qt(n,e,t,r){let{group:o,method:i}=n.logicRegistry.resolve(t,e);return i.call(o,e,r)}function Ut(n,e,t,r,o,i=Object.keys(o)){return vi(r)?Qt(n,e,r,o):n.inlineCompiler.compile(e,t,r,i)(o)}function fs(n){let e=n.node,t=n.runtime.gramlot,r=(o,i,a,s=!1)=>s?n.runtime.inlineCompiler.compile(e,o,i,Object.keys(a),`return (${i});`)(a):Ut(n.runtime,e,o,i,a);return{isDecimal:pe,invoke:r,callLogic:(o,i)=>Qt(n.runtime,e,o,i),remote:(o,i,a)=>t.rpc.call("data",o,i,{signal:a}),reportError:(o,i)=>{n.closed||n.runtime.reportError(o,i)},validationCurrent:()=>{let o=e.getAttr("value"),i=e.pointerType(o)?e.absDatapath(o):null;return()=>!n.closed&&e.getAttr("value")===o&&(i===null||e.absDatapath(o)===i)},finishValidation:({ok:o,result:i,rules:a})=>{if(n.closed)return;if(o)for(let l of i.datachanges)e.getRelativeData(".").update(l);let s=o?"validate_onAccept":"validate_onReject";if(a[s]){let l=u=>{n.closed||n.runtime.reportError(u,"Validation callback failed")};try{let u=Object.fromEntries(Object.entries(a).map(([d,f])=>[d.slice(9),f])),c=r(s,a[s],{value:i.value,result:i,validations:u,userChange:!0});c instanceof Promise&&c.catch(l)}catch(u){l(u)}}},checkDataPatch:o=>{if(!(o instanceof k))throw new TypeError("Validation data changes must be a Bag.");if(!(e.getRelativeData(".")instanceof k))throw new TypeError("Validation data changes require a Bag datapath.")}}}var Cr=n=>j(L(n)),sn=(n,e)=>L(n)===L(e),Ei=n=>n.absDatapath(n.getAttr("value")),gt=n=>encodeURIComponent(n).replaceAll(".","%2E"),Nr=n=>gt(Ei(n)),_p=(n,e)=>gt(n.fullpath)+":"+e,xi=class{constructor(e,t,r=e.absDatapath(".")){if(this.node=e,this.runtime=t,this.registers=new k,this.validationQueue=new Set,this.fields=new Map,this.validations=new Map,this.disposed=!1,this.scheduled=!1,this.writing=0,this.path=r,this.retainedFields=new Map,this.listeners=new Set,this.navigators=new Set,this.validationSources=new Set,this.validationDependencies=new Map,this.validationRevision=0,this.validatedRevision=-1,this.fullValidation=null,!(this.data instanceof k))throw new TypeError("A form requires a Bag at its datapath.");this.registers.setItem("baseline",Cr(this.data));for(let o of["changes","errors","pending","drafts"])this.registers.setItem(o,new k);this.subscription=t.router.register({path:this.path,recipient:this,subtree:!0}),t.bindingFor(e).track(()=>this.dispose())}rebind(){let e=this.node.absDatapath(".");if(e!==this.path){if(!(this.data instanceof k))throw new TypeError("A form requires a Bag at its datapath.");this.subscription.close();for(let t of["errors","pending","drafts"])this.registers.setItem(t,new k);this.path=e,this.subscription=this.runtime.router.register({path:e,recipient:this,subtree:!0}),this.updateChanges();for(let t of this.fields.values())t.element.cancelValidation(),this.clearDraft(t.node),this.scheduleValidation(t)}}get data(){return this.runtime.gramlot.data.getItem(this.path)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get errorEntries(){return this.registers.getItem("errors").getNodes().map(e=>({path:decodeURIComponent(e.label),message:e.value.getNodes().map(t=>t.value).join(`
|
|
192
|
+
`)}))}get changeEntries(){let e=[];for(let t of this.registers.getItem("changes").getNodes()){let r=t.value,o=[this.path,r.getItem("path")].filter(Boolean).join("."),i=r.getItem("existed"),a=r.getItem("exists"),s=r.getItem("previous"),l=r.getItem("current");if((!i||!a||!sn(s,l))&&e.push({path:o,previous:s,current:l,existed:i,exists:a}),i&&a){let u=r.getItem("previousAttributes"),c=r.getItem("currentAttributes");for(let d of new Set([...u.getNodes(),...c.getNodes()].map(f=>f.label))){let f=u.getNode(d)!==null,h=c.getNode(d)!==null;(f!==h||!sn(u.getItem(d),c.getItem(d)))&&e.push({path:o+"?"+d,previous:u.getItem(d),current:c.getItem(d),existed:f,exists:h})}}}return e}registerNavigator(e){return this.navigators.add(e),()=>this.navigators.delete(e)}focusField(e){if(this.disposed)return!1;for(let t of this.fields.values())if(Ei(t.node)===e&&t.element.isConnected)return t.element.control.focus(),!0;for(let t of this.navigators)if(t(e))return!0;return!1}retainField(e){this.retainedFields.set(e,(this.retainedFields.get(e)??0)+1)}releaseField(e){let t=this.retainedFields.get(e);if(t>1){this.retainedFields.set(e,t-1);return}if(this.retainedFields.delete(e),![...this.validations.values()].some(r=>r.path===e)){for(let r of["errors","pending","drafts"]){let o=this.registers.getItem(r),i=gt(e);o.getNode(i)&&o.popNode(i)}this.notify()}}fieldStatus(e){let t=gt(e);return{error:this.registers.getItem("errors").getItem(t),pending:this.registers.getItem("pending").getItem(t),draft:this.registers.getItem("drafts").getItem(t)}}get status(){let e=this.registers.getItem("changes").length>0,t=this.fullValidation!==null||this.registers.getItem("pending").length>0,r=this.registers.getItem("errors").length>0,o=this.registers.getItem("drafts").length>0;return{dirty:e,pending:t,valid:!r&&!o,canSave:e&&!r&&!o&&!t,status:r?"error":t||o?"pending":e?"changed":"ok"}}register(e){let t=e.node;this.fields.set(t,e);let r=this.registerField(t,e.element.constructor);return r.selection=e.element.validationSelection(),this.schedule(()=>{if(this.fields.get(t)!==e)return;let o=this.registers.getItem("drafts").getNode(Nr(t));o&&(t.formDraft=o.value,e.element.restoreFormDraft(o.value)),r.result&&e.element.presentValidation(r.result);let i=this.registers.getItem("errors").getItem(Nr(t));i&&e.element.error(i.getNodes().map(a=>a.value).join(`
|
|
193
|
+
`)),e.element.setFieldState({invalid:!!i,pending:!!this.fieldStatus(r.path).pending})}),()=>{this.fields.delete(t)}}registerField(e,t,r=!0){let o=this.validations.get(e);if(o)return o;if(!t.validationExecutor)throw new TypeError("Grid editors require shared input validation.");let i=this.runtime.bindingFor(e),a=fs(i);return o={node:e,binding:i,context:a,component:t,run:new co,execute:t.validationExecutor,checkValue:t.validationValueCheck(a),path:Ei(e),rules:null,value:void 0,target:null,result:null,selection:null},this.validations.set(e,o),i.editingSession=this,o.release=i.track(()=>this.forgetField(e)),this.refreshField(e,r),o}registerValidationSource(e){return this.validationSources.add(e),this.invalidateValidation(),()=>{this.validationSources.delete(e),this.invalidateValidation()}}invalidateValidation(){if(this.validationRevision++,this.fullValidation)for(let e of this.fullValidation.active)this.cancelValidation(e)}trackValidationDependency(e){if(e===null||this.validationDependencies.has(e))return;let[t,r=null]=e.split("?",2);this.validationDependencies.set(e,this.runtime.router.register({path:t,attr:r,subtree:!0,recipient:{receive:()=>this.invalidateValidation()}}))}clearValidationDependencies(){for(let e of this.validationDependencies.values())e.close();this.validationDependencies.clear()}validate(){if(this.disposed)return Promise.resolve(!1);if(this.fullValidation)return this.fullValidation.promise;for(let a of this.fields.values())Object.hasOwn(a.node,"formDraft")&&a.commit();this.clearValidationDependencies();let e={revision:this.validationRevision,promise:null,active:new Set,failed:!1,complete:!0};this.fullValidation=e,this.notify();let t=this.validationFields(),r=()=>!this.disposed&&!e.failed&&e.revision===this.validationRevision,o=new WeakSet,i=async()=>{let a=0;for(;r();){let s=t.next();if(s.done)return;let{node:l,release:u}=s.value;try{if(o.has(l))continue;o.add(l);for(let[d,f]of l.pointers())d!=="value"&&this.trackValidationDependency((d==="datapath"?l.parentNode:l).absDatapath(f));e.active.add(l),(await this.validateField(l))?.ok||(e.complete=!1)}finally{e.active.delete(l),u()}++a%20===0&&await new Promise(c=>setTimeout(c,0))}};return e.promise=Promise.resolve().then(async()=>{let s=(await Promise.allSettled(Array.from({length:8},()=>i().catch(u=>{e.failed=!0;for(let c of e.active)this.cancelValidation(c);throw u})))).find(u=>u.status==="rejected");if(s)throw s.reason;if(!r())return!1;let l=e.complete&&this.status.valid&&this.registers.getItem("pending").length===0;return l&&(this.validatedRevision=this.validationRevision),l}).finally(()=>{t.return(),this.fullValidation=null,this.notify()}),e.promise}*validationFields(){let e=[...this.validations.keys()];for(let t of this.validationSources)yield*t();for(let t of e)this.validations.has(t)&&(yield{node:t,release:()=>{}})}forgetField(e){let t=this.validations.get(e);if(t){t.run.cancel(),t.release(),t.binding.editingSession===this&&(t.binding.editingSession=null),this.validations.delete(e),this.validationQueue.delete(e);for(let r of["errors","pending"]){let o=this.registers.getItem(r).getItem(gt(t.path));if(o){for(let i of[...o.getNodes()])i.label.startsWith(gt(e.fullpath)+":")&&o.popNode(i.label);o.length||this.registers.getItem(r).popNode(gt(t.path))}}if(![...this.validations.values()].some(r=>r.path===t.path)){let r=this.registers.getItem("drafts");r.getNode(gt(t.path))&&r.popNode(gt(t.path))}delete e.formDraft,this.notify()}}refreshField(e,t=!0){let r=this.validations.get(e);if(!r||this.disposed||this.writing)return;let[,o]=e.rootBuilder.runtimeValues(e),i=r.component.validationParameters(this.runtime.renderer.evaluateExpressions(e,o)),a=Object.fromEntries(Object.entries(i).filter(([f])=>f.startsWith("validate_"))),s=L(Object.fromEntries(Object.entries(i).filter(([f])=>f!=="value"))),l=Ei(e),u=this.runtime.gramlot.data.getNode(l.split("?")[0]),c=e.getRelativeData(e.getAttr("value")),d=r.path!==l||r.target!==u||!sn(r.value,c);if(!(!d&&r.configuration===s)){if(r.rules!==null&&this.invalidateValidation(),this.cancelValidation(e),r.path!==l)for(let f of["errors","pending","drafts"]){let h=this.registers.getItem(f);h.getNode(gt(r.path))&&h.popNode(gt(r.path))}Object.assign(r,{path:l,target:u,value:c,rules:a,configuration:s,result:null,selection:r.component.validationSelection(i,r.context)}),d&&this.clearDraft(e),t&&this.scheduleField(e)}}cancelValidation(e){this.validations.get(e)?.run.cancel(),this.validationQueue.delete(e),this.pendingPart(e,"validation",null)}writeCandidate(e,t){this.clearDraft(e),this.writing++;try{this.runtime.renderer.html.writeParameter(e,"value",t)}finally{this.writing--}let r=this.validations.get(e);r&&(r.value=e.getRelativeData(e.getAttr("value")),r.target=this.runtime.gramlot.data.getNode(r.path.split("?")[0]));for(let o of this.validations.keys())o!==e&&this.refreshField(o)}validateCandidate(e,t,r){this.invalidateValidation(),this.cancelValidation(e),this.writeCandidate(e,t);let o=this.validations.get(e);return o.selection=r,this.validateField(e,!1)}scheduleField(e){this.disposed||!this.validations.has(e)||this.validationQueue.has(e)||this.registers.getItem("drafts").getNode(Nr(e))||(this.validationQueue.add(e),this.pendingPart(e,"validation","scheduled"),this.schedule(()=>{this.validationQueue.delete(e)&&this.validateField(e)}))}scheduleValidation(e){this.refreshField(e.node);let t=this.validations.get(e.node);t&&!t.result&&!t.run.controller&&this.scheduleField(e.node)}validateField(e,t=!0){let r=this.validations.get(e);if(!r||this.disposed||r.binding.closed||(this.validationQueue.delete(e),this.registers.getItem("drafts").getNode(Nr(e)))||this.registers.getItem("pending").getItem(Nr(e))?.getItem(_p(e,"selection")))return;let o=e.getRelativeData(e.getAttr("value")),i=this.fields.get(e);t&&i&&(r.selection=i.element.validationSelection());let a=r.selection,s=r.target,l=r.context.validationCurrent();return r.run.start(o,r.rules,{...r.context,validationCurrent:()=>()=>!this.disposed&&l()&&this.validations.get(e)===r&&this.runtime.gramlot.data.getNode(r.path.split("?")[0])===s,selection:a},r.execute,u=>{if(u.ok)try{r.checkValue(u.value,o)}catch(d){u.ok=!1,u.result.error=d.message}this.result(e,u.result),r.result=u.result,u.ok&&this.writeCandidate(e,u.value);let c=this.fields.get(e);c&&c.element.presentValidation(u.result),r.context.finishValidation(u)},()=>{this.pendingPart(e,"validation","active"),this.fields.get(e)?.element.setFieldState({pending:!0})})}remove(e,t){let r=this.registers.getItem(e),o=Nr(t);r.getNode(o)&&r.popNode(o)}set(e,t,r){r==null?this.remove(e,t):this.registers.getItem(e).setItem(Nr(t),r),this.notify()}draft(e,t){this.invalidateValidation(),this.cancelValidation(e),e.formDraft=t,this.set("drafts",e,t)}clearDraft(e){delete e.formDraft,this.set("drafts",e,null),this.issue(e,"parse",null)}result(e,t){this.pendingPart(e,"validation",null),this.issue(e,"validation",t.error||null)}part(e,t,r,o){r=_p(t,r);let i=this.registers.getItem(e),a=Nr(t),s=i.getItem(a);!s&&o!=null&&(s=new k,i.setItem(a,s)),s&&(o==null?s.getNode(r)&&s.popNode(r):s.setItem(r,o),s.length||this.remove(e,t)),this.notify()}issue(e,t,r){this.part("errors",e,t,r||null)}pendingPart(e,t,r){this.part("pending",e,t,r)}parseError(e,t){this.issue(e,"parse",t)}schedule(e){queueMicrotask(()=>{this.disposed||e()})}receive(e){if(!this.disposed&&(this.updateChanges(e.path),!this.writing)){this.invalidateValidation();for(let t of this.validations.keys())this.refreshField(t)}}updateChanges(e=null){let t=this.registers.getItem("changes"),r=e===this.path?"":e?.startsWith(this.path+".")?e.slice(this.path.length+1).split("?")[0]:"",o=(l,u,c)=>{if(l&&u&&l.value instanceof k&&u.value instanceof k&&sn(l.attr,u.attr)){let d=new Set([...l.value.getNodes(),...u.value.getNodes()].map(f=>f.label));for(let f of d)o(l.value.getNode(f),u.value.getNode(f),c?c+"."+f:f)}else(!l||!u||!sn([l.value,l.attr],[u.value,u.attr]))&&t.setItem(gt(c),new k({path:c,existed:!!l,exists:!!u,previous:l?Cr(l.value):null,current:u?Cr(u.value):null,previousAttributes:l?Cr(l.attr):null,currentAttributes:u?Cr(u.attr):null}))},i=this.registers.getItem("baseline"),a=r;for(let l of t.getNodes()){let u=l.value.getItem("path");a.startsWith(u+".")&&(a=u)}let s=a;for(;s.includes(".");){s=s.slice(0,s.lastIndexOf("."));let l=i.getNode(s),u=this.data.getNode(s);(!l||!u||!sn(l.attr,u.attr))&&(a=s)}for(let l of[...t.getNodes()]){let u=l.value.getItem("path");(!a||u===a||u.startsWith(a+"."))&&t.popNode(l.label)}a?o(i.getNode(a),this.data.getNode(a),a):o({value:i,attr:{}},{value:this.data,attr:{}},""),this.notify()}notify(){this.disposed||this.scheduled||(this.scheduled=!0,this.schedule(()=>{this.scheduled=!1;let e=this.status,t=this.registers.getItem("status");(!t||!sn(t,new k(e)))&&(this.registers.setItem("status",new k(e)),this.node.publish("formStatus",e));for(let r of this.listeners)r()}))}commitField(e){for(let t of this.fields.values())Ei(t.node)===e&&Object.hasOwn(t.node,"formDraft")&&t.commit()}accept(){if(this.disposed)return!1;for(let e of this.fields.values())Object.hasOwn(e.node,"formDraft")&&e.commit();return!this.status.valid||this.status.pending||this.validationSources.size&&this.validatedRevision!==this.validationRevision?!1:(this.registers.setItem("baseline",Cr(this.data)),this.updateChanges(),!0)}load(e){if(!(e instanceof k))throw new TypeError("Editing load requires a Bag.");this.disposed||(this.registers.setItem("baseline",Cr(e)),this.restore())}restore(){if(!this.disposed){this.invalidateValidation();for(let e of this.validations.keys())this.cancelValidation(e);for(let e of this.fields.values())e.element.cancelValidation(),this.clearDraft(e.node),e.element.restoreFormValue(this.registers.getItem("baseline").getItem(e.node.absDatapath(e.node.getAttr("value")).slice(this.path?this.path.length+1:0)));this.runtime.gramlot.data.setItem(this.path,Cr(this.registers.getItem("baseline")));for(let e of["errors","pending","drafts"])this.registers.setItem(e,new k);this.updateChanges();for(let e of this.validations.keys())this.scheduleField(e)}}dispose(){if(!this.disposed){this.disposed=!0,this.subscription.close();for(let e of this.validations.keys())this.forgetField(e);this.fields.clear(),this.validationQueue.clear(),this.retainedFields.clear(),this.listeners.clear(),this.navigators.clear(),this.validationSources.clear(),this.clearValidationDependencies()}}};function dv(n,e,t=n){let r=new Map,o=new Set,i=new Map;for(let[s,l]of e){if(typeof s!="string")continue;let u=re(l)?.pointer??l;i.set(s,u instanceof de?u.resolve():n.pointerType(u)?t.getRelativeData(u):mt(u)?null:u)}let a=s=>{if(r.has(s))return r.get(s);if(!e.has(s))throw new Error(`Source attribute '${s}' does not exist`);if(o.has(s))throw new Error(`cyclic attribute dependency: ${[...o,s].join(" -> ")}`);o.add(s);let l=e.get(s),u=re(l),c=u?i.get(s):null,d,f=h=>h?a(h):c;try{if(u)if(u.expression){let h=ii(u.body),p=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,s,l,h,p)}else d=Yr(u.body,f),c==null&&(d=null);else d=i.get(s);return r.set(s,d),d}finally{o.delete(s)}};return{resolve:a}}function Ir(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),...Fe(n.getAttr())]);return dv(n,r,t).resolve(e)}var fv={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"]},Wu=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],hv=["_if","_else","_onRemote","_onCalling"],Yu=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.#o()}return t}submit(e,t,r){try{let o=L(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((i,a)=>{this.#r={method:e,text:o,perform:r,resolve:i,reject:a}}):(this.#r?.resolve(void 0),this.#r=null,this.#a(e,t,o,r))}catch(o){return Promise.reject(o)}}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()}#o(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#a(e.method,j(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#a(e,t,r,o){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let i=new AbortController,a={method:e,params:t,text:r,controller:i,ignored:!1};a.view=Object.freeze({method:e,get params(){return j(r)},sentAt:Date.now(),cancel:()=>this.#s(a)}),this.#t=a,i.signal.addEventListener("abort",()=>this.#i(a),{once:!0});let s;try{s=Promise.resolve(o(a))}catch(l){s=Promise.reject(l)}return s.then(()=>this.#i(a),()=>this.#i(a)),s}#i(e){this.#t===e&&(this.#t=null,this.#o())}#s(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#o())}};function yp(n){return typeof n=="string"&&n.startsWith("==")}var ln=class extends Ze{#e=null;get formState(){for(let e=this;e;e=e.parentNode){if(e.#e&&e._getMeta("gramlot_component")?.bagStore)return e.#e;if(e.getAttr("formId")!=null||e.getAttr("form")===!0){let t=e.#e??=new xi(e,this.rootBuilder.binding);return t.rebind(),t}}return null}editCollection(e){let t=this.parentNode?.formState;if(t){if(e!==t.path&&!e.startsWith(t.path+"."))throw new Error("An edited grid in a form must use data within that form.");return t}if(this.#e&&this.#e.path!==e)throw new Error("An active grid editing session cannot change its storepath.");return this.#e??=new xi(this,this.rootBuilder.binding,e)}get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof I?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 grid(){if(this.nodeTag==="framePane"){let e=this.staticValue instanceof I?this.staticValue.getNode("center.grid"):null;if(!e||e.nodeTag!=="grid")throw new TypeError("This frame has no central grid");return this.builder.wrapSource(e)}return(e={})=>this.builder.wrapSource(this.builder.commandOnNode(this,"grid",null,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 I?this.value.getNodes().find(o=>o.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))}#t=new Set;#r=null;#n=null;get requests(){return this.#n??=new Yu(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...fv[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"?hv:[]],t=[];for(let[r,o]of Object.entries(this.getAttr()??{}))typeof o=="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,o]);for(let r of["ask","_ask"]){let o=this.getAttr(r);if(o&&typeof o=="object")for(let i of["_if","askIf"])typeof o[i]=="string"&&t.push([`${r}.${i}`,o[i]])}for(let[r,o]of Fe(this.getAttr()))if(yp(o)&&t.push([r,o]),this.nodeTag==="script"&&typeof o=="string"){let i=this.builder.constructor.dialectPrefixes.find(a=>r.startsWith(a))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(i.length).toLowerCase())&&t.push([r,o])}return(yp(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[...Fe(this.getAttr()),["datapath",this.getAttr("datapath")]])re(r)?.expression&&e.set(t,r);this.#r=e}activatedCode(e){return this.#r?.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 o=Object.keys(t).find(a=>a.startsWith("_")&&!Wu.includes(a));if(o)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${o}' is not accepted; the control attributes are ${Wu.join(", ")}`);let i={remote:e};for(let[a,s]of Object.entries(t))i[Wu.includes(a)?a:`remote_${a}`]=s;return this.setAttr(i),ci(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=re(e)?Ft(this,e):new Set,r=super.pointers().filter(([o,i])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o))&&!t.has(o)&&!this.#i(o,i)).map(([o,i])=>[o,re(i)?.pointer??i]);for(let o of t){let i=this.getAttr(o);this.pointerType(i)==="^"&&r.push(["datapath",re(i)?.pointer??i])}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 Er(()=>r));continue}if(this.pointerType(r)){if(re(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 Er(()=>Ir(this,t)));continue}this.#i(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 re(t)?Ir(this,e):this.pointerType(t)&&this.#i(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.#s(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#s(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.#s(e);let o=this.absDatapath(e);if(o.includes("?")){this.#o(o,t);return}this.data.getNode(o)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(o)?.setValue(null,!1)}}#o(e,t){let[r,o]=e.split("?",2),i=this.data;i.getNode(r)?.setAttr({[o]:null},!1);try{let a=i.getNode(r);a?a.setValue(a.staticValue,!0,{[o]:t},!0,!0,!0,!0):i.setItem(r,null,{[o]:t},">",!0,!0,!0,!0)}finally{i.getNode(r)?.setAttr({[o]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#s(e);let o=this.rootBuilder?.binding?.bindingFor(this)??null,i=null,a=setTimeout(()=>{i?.(),this.FIRE(e,t)},r);return i=o?.track(()=>clearTimeout(a))??null,()=>{clearTimeout(a),i?.()}}absDatapath(e){e=re(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,o]=t.split("?",2),i=super.absDatapath(r);return i===null?null:`${i}?${o}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let o=r.getAttr("datapath");if(this.pointerType(o)&&(o=this.#a(r,o),o===null))return null;if(o!=null&&(e=e==="."?o:o+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 o=this.rootBuilder?.binding;if(!o)return super._resolveSymbolicDatapath(e,t);let i=o.nodeIds.get(r);if(!i)throw new Error(`#<id>: cannot resolve ${t}`);let a=e.slice(r.length+2);return i.absDatapath(a?`.${a}`:".")}#a(e,t){if(re(t)){let i=Ir(e,"datapath",e.parentNode);return i==null||i===""?null:i}let r=e.parentNode.absDatapath(t);if(r===null)return null;let o=this.data.getItem(r);return o==null||o===""?null:o}#i(e,t){return re(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#t.has(e)||(this.#t.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#s(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},Ae=class n extends I{get nodeClass(){return ln}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let o=r.getAttr("auth")??null;if(o!==null){if(typeof o!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof o}`);if(e(o)!==null)continue}let i=r.staticValue;i instanceof n&&(i=i.authorizedCopy(e));let{auth:a,...s}=r.getAttr(),l=t.setItem(r.label,i,s,">",!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((pt(Ae.tytxSuffix).GramlotBuilderBag??Ae)!==Ae)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Wr(Ae.tytxSuffix,{...pt(Ae.tytxSuffix),GramlotBuilderBag:Ae});var pv=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"]),ki=class extends rn{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);lo(e,r);let[o,i]=super._handleMeta(e,r);return so(e,i),e._getMeta("subbuilder")?[o,ts(us(i))]:[o,i]}adaptAttrs(e){let{_meta:t,...r}=e;return wi(super.adaptAttrs(uo(Sr(r))))}renderedItem(e,t,r,o={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,o);let{_text:i,...a}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&i!=null&&(t=[this._escapeText(ao(i)),...t]),pv.has(o.tag)?`${o.pretty?" ".repeat(this._nodeDepth(e,o.depthOffset??0)):""}<${o.tag}${this._formatAttrs(a)} />${o.pretty?`
|
|
194
|
+
`:""}`:super.renderedItem(e,t,a,o)}};var un=class extends tn{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof qt?this.addRender(e,this):e instanceof kr&&this.addRender(e,new ki(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,o]=e.rootBuilder.runtimeValues(e),i=this.getRender(e.builder),[a,s]=i._handleMeta(e,o);return e._getMeta("subbuilder")||(s=i.adaptAttrs(s)),i.renderedItem(e,e.value instanceof I?this.renderChildren(e.value,t):r,s,{tag:a,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,o=this.evaluateExpressions(e,t);lo(e,o,r);let[i,a]=super._handleMeta(e,mp(e,o,r));if(so(e,a,r),e.nodeTag==="webcomponent"){i=Jt(e.getAttr());let{code:u,...c}=a;a=c}if(e._getMeta("subbuilder")){let u=us(a);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Dr),[i,u]}let[s,l]=gp(i,a);return Object.keys(l).length&&this.#e.set(e,l),[i,s]}evaluateExpressions(e,t){let r=this.inlineCompiler,o=(a,s)=>r?r.compileExpression(e,a,s)(t):null,i={...t};for(let[a,s]of Fe(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(a)||mt(s)&&Object.hasOwn(i,a)&&(i[a]=o(a,s));return mt(e.value)&&this.#t.set(e,o("",e.value)),i}expressionValue(e,t){return mt(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...uo(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,o=`${this.builder.constructor._name}_`,i=this.builder.constructor.dialectPrefixes,a={},s={};for(let[l,u]of Object.entries(Sr(r))){if(u==null)continue;if(l.startsWith(o))throw new Error(`${l}: the attribute prefix '${o}' is not accepted; use the prefix '${i[0]}'`);let c=i.find(d=>l.startsWith(d));c?a[l.slice(c.length)]=u:s[l]=u}return wi({...super.adaptAttrs(s),...a})}renderedItem(e,t,r,o={}){let i;[t,i]=_i(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:a,...s}=i;Array.isArray(t)&&a!=null&&(t=[this._escapeText(ao(a)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:je,...s}:s;return super.renderedItem(e,t,l,o)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let o=this._composeStringFragments(e),i=this.builder.source.getNodes().filter(a=>!a._getMeta("data_element"));return i.length===1&&i[0].nodeTag==="html"||(o=`<html>${o}</html>`),super.finalize(`<!doctype html>${o}`,t,r)}};var vp={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 Ep={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 bv="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",wv=new Set,_v=new Set(["serverpath","dbenv","shared_id"]),yv=["formsubscribe_"],vv={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Ev={dataFormula:"formula",dataController:"script"};function xp(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&re(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(o=>["action","ask","_delay","fire"].includes(o)||o.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(o=>o.startsWith("subscribe_")||o.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=vv[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=Ev[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 kp(n){return Object.keys(n).find(e=>_v.has(e)||yv.some(t=>e.startsWith(t)))}var Oe=class n extends qt{static _name="gramlot";static containers=["frameGrid"];static _sourceClass=Ae;static{this.defineGrammar(vp)}static{this.defineGrammar(Ep)}static{this.defineGrammar(ds.toDocument())}frameGrid(e,{storepath:t,rowMode:r,structpath:o,searchOn:i=!1,...a}={}){for(let u of["framePane","grid"])if(!this.schemaTag(u))throw new TypeError(`frameGrid requires the ${u} collection`);let s={storepath:t,rowMode:r,...o==null?{}:{structpath:o},node_label:"grid",frameTarget:!0,height:"100%",width:"100%"};this.validateNodeValues("grid",null,s),i!==!1&&this.validateNodeValues("searchBox",null,{searchOn:i});let l=e.framePane(a);return l.center.grid(s),i!==!1&&l.top.menu({presentation:"bar",node_label:"search",aria_label:"Grid search",padding:"4px 8px",background:"var(--gramlot-surface-subtle)"}).menuline({group:!0}).searchBox({searchOn:i}),l}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:o=bi}={}){if(!(o instanceof on))throw new TypeError(`nameSyntax must be a NameSyntax, not ${o}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=o;for(let i of t)this.loadCollection(i)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,o,i){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,o.text)(i):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof Tr?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(wv.has(t))throw new Error(`${e}: excluded from Gramlot`);let o=this.schemaTagNames[t];if(o)return o;for(let i of r)if(t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)])return t;return null}bagCall(e,t,r,o){return t=this.#e(t),[r,o]=this.menuArguments(t,r,o),super.bagCall(e,t,r,o)}commandOnNode(e,t,r,o){return t=this.#e(t),[r,o]=this.menuArguments(t,r,o),super.commandOnNode(e,t,r,o)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new Ae(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&&re(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&Jt(r);let o=kp(r);if(o)throw new Error(`${e}: attribute '${o}' is excluded from Gramlot`);let i=xp(e,r);if(i)throw new Error(`${e}: ${i}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&re((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&Jt(t.attrs??e.getAttr());let r=kp(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let o=xp(e.nodeTag,t.attrs??e.getAttr());if(o)throw new Error(`${e.nodeTag} '${e.label}': ${o}`);return super.validateNode(e,t)}_validateChildren(e,t,r,o){return super._validateChildren(e,t,r.map(i=>i==="html_button"?"button":i==="html_dialog"?"dialog":i),o)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,o,i=null){o=Object.fromEntries(Object.entries(o??{}).map(([l,u])=>[l,ie(u)instanceof Ze?this.reference(u):u]));let s=t==="dataSetter"&&o?.value!==null&&typeof o?.value=="object"&&Object.getPrototypeOf(o.value)===Object.prototype?{...o,value:new k(o.value)}:o;return super.setChild(e,t,r,s,i)}#e(e){if(e==="data")throw new Error(bv);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 un(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let o=t!=null?{_text:t}:null;e.setValue(r,!0,o,!0)}reference(e,t="node"){if(e=ie(e),!(e instanceof Ze)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=ee(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return L(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function Xu(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function hs(n){if(!n||!(n.value instanceof I))return null;let e=n.value.getNodes().find(o=>o.getAttr("region")==="center"),t=[];function r(o){if(o.nodeTag!=="framePane"&&(o.getAttr("frameTarget")===!0&&t.push(o),o.value instanceof I))for(let i of o.value.getNodes())r(i)}return e&&r(e),t.length===1?t[0]:null}function xv(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 Tp(n){if(n&&typeof n=="object"){for(let e of Object.values(n))Tp(e);Object.freeze(n)}return n}function Ap(n,e){let t=n.node,r=t.getAttr("command"),o=n.runtime.gramlot.commands.get(r),i=Xu(t),a=hs(i);if(!o||!a)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let s=t.getAttr("parameters")??{};if(typeof s!="object"||Array.isArray(s))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(s).map(([m,w])=>[m,t.pointerType(w)?t.getRelativeData(w):w])),u=Tp(j(L(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(m=>[m,!!e[`${m}Key`]]))),d=Object.freeze({sender:t,target:a,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(a).track(()=>{f=!0}),p=()=>!f&&xv(n)&&hs(i)===a&&n.runtime.renderer.attached(a)&&t.getAttr("command")===r;return{message:d,current:p,release:h,cancel(){f=!0},deliver(){p()&&a.publish(o.publish,d)}}}var kv=new Set(["input","select","textarea"]),Tv=["type","multiple"];function Dp(n,e){let t=n.node,r=t.getAttr(e);return t.pointerType(r)?t.getRelativeData(r):n.resolved[e]}var qe=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#o=!1;#a=!1;#i=!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!==je)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?ec:Zu;if(e.localName==="textarea")return Vt;if(e.localName==="select")return Ti;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(Sp,r)?Sp[r]:Vt}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([]):e?.namespaceURI!==je||!kv.has(e.localName)?null:JSON.stringify(Tv.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.#a){this.#i=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)&&(!this.#o||this.same(this.read(),e))||(this.#e=e,this.#t=!0,!(this.#o&&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.#o=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#o=!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.#i=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#a=!0;return}if(e.type==="compositionend"){this.#a=!1,this.writeEvent==="input"&&this.commit(e),this.#i&&(this.#i=!1,this.binding.runtime.renderer.project(this.node));return}this.#a||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},Zu=class extends qe{#e;form=null;static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.form=this.element.supportsFormValidation&&this.node.pointerType(this.node.getAttr("value"))==="^"?this.node.formState:null,this.element.setPageContext(rc(this)),this.form&&this.node.pointerType(this.node.getAttr("value"))==="^"&&(this.#e=this.form.register(this)),super.attach()}refresh(){let e=this.element.supportsFormValidation&&this.node.pointerType(this.node.getAttr("value"))==="^"?this.node.formState:null;e!==this.form&&(this.#e?.(),this.form=e,this.element.setPageContext(rc(this)),this.#e=e?e.register(this):null)}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),this.#e?.(),super.detach()}commit(e){if(this.binding.closed||this.element.control.disabled||this.element.control.readOnly)return;let t=this.element.acceptControlValue();this.form||Cp(this.element,t,r=>super.commit(e,r.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(e.type==="input"&&this.form&&!this.binding.closed&&!this.element.control.disabled&&!this.element.control.readOnly&&this.form.draft(this.node,this.element.control.value??""),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}))}}},Vt=class extends qe{static liveWrites=!0},Ku=class extends qe{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},Ju=class extends qe{static liveWrites=!0;read(){return Number(this.element.value)}},Ti=class extends qe{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 o of t.options){let i=r.has(o.value);o.selected!==i&&(o.selected=i)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((r,o)=>Object.is(r,e[o])):super.same(e,t)}},cn=class extends qe{read(){return this.element.value===""?null:this.element.value}},Qu=class extends qe{},ps=class extends qe{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()}},fo=class extends ps{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,r=tc(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=tc(this.node);if(!Object.is(e??null,t)){let o=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 i of o){if(this.binding.closed||!this.binding.runtime.renderer.attached(this.node))return;i.binding.closed||!i.binding.runtime.renderer.attached(i.node)||i.binding.runtime.renderer.html.writeParameter(i.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(Dp(this,"value")&&this.groups.peersOf(e,t).some(o=>!o.binding.closed&&o.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 o=this.read();super.project(e,t),!r&&!o&&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),Dp(e,"value")&&e.commit(null))}}},ec=class extends fo{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||Cp(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(rc(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,tc(this.node)).filter(a=>!a.binding.closed&&!a.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let o=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,i=t[(r+o+t.length)%t.length];i.element.focus(),i.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},ms=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#o=0;constructor(e){this.#e=e}join(e,t,r){let o=this.nameOf(t,r);return this.#t.has(o)||this.#t.set(o,new Set),this.#t.get(o).add(e),this.#r.set(e,o),o}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.#o++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function tc(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 Sp={text:Vt,password:Vt,email:Vt,url:Vt,tel:Vt,search:Vt,number:Ku,range:Ju,color:Qu,date:cn,time:cn,month:cn,week:cn,"datetime-local":cn,checkbox:ps,radio:fo,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function rc(n){let{binding:e,node:t}=n,r=e.runtime.gramlot;return{locale:r.locale,timeZone:r.timeZone,createDecimal:Lt,isDecimal:pe,getDecimalLibrary:Nu,form:n.form,formCancelValidation:()=>n.form?.cancelValidation(t),formValidateCandidate:(o,i)=>n.form.validateCandidate(t,o,i),formValidate:()=>n.form?.scheduleValidation(n),formSelectionPending:o=>n.form?.pendingPart(t,"selection",o?"active":null),formSelectionError:o=>n.form?.issue(t,"selection",o),formParseError:o=>n.form?.parseError(t,o),formClearDraft:()=>n.form?.clearDraft(t),publish:(o,i)=>t.publish(o,i),isActive:()=>!e.closed,reportError:(o,i)=>{e.closed||e.runtime.reportError(o,i)},callLogic:(o,i)=>Qt(e.runtime,t,o,i),format:(o,i)=>r.format(o,i),...fs(e),selectionOutputs:({selectedCaption:o,selectedRecord:i,fields:a},s)=>{if(!e.closed){o&&t.setRelativeData(o,s?.caption??null),i&&t.setRelativeData(i,s?new k(s.record):null);for(let[l,u]of Object.entries(a))t.setRelativeData(u,s?.record[l.slice(9)]??null)}}}}function Cp(n,e,t){let r=n.pageContext,o=i=>{i.ok&&i.isCurrent()&&(t(i),n.finishValidation(i))};if(e instanceof Promise)e.then(o).catch(i=>r.reportError(i,"Field update failed"));else try{o(e)}catch(i){r.reportError(i,"Field update failed")}}var nc=Symbol("source text"),Np={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Av=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"]),Dv=new Set(["checked","muted","selected","value"]),Sv=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Cv(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return Sv.get(e.toLowerCase())??e}var gs=class{constructor({format:e,metadataAttributes:t=[],invokeScript:r=null,callLogic:o=null,reportError:i=null,uploadContext:a=null}={}){this.format=e,this.uploadContext=a,this.invokeScript=r,this.callLogic=o,this.reportError=i,this.metadataAttributes=new Set([...Xr,"_text",...t])}definition(e){let t=e.builder,o={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},i=e.nodeTag==="webcomponent"?Jt(e.getAttr()):ui(e.nodeTag,{renderTag:o.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),a=i==="foreignObject"?Dr:o.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof kr?Dr:je);return{meta:o,namespace:a,tag:i}}validate(e,t=e.builder){this.validateLabelbox(e);let r=e.value instanceof I,o=r?e.getAttr("_text"):e.value;if(o!=null&&!["string","number","boolean"].includes(typeof o))throw new TypeError("HTML text must be scalar");let i=this.definition(e).meta.gramlot_component;for(let[l,u]of Object.entries(e.attr))if(!(i&&Object.hasOwn(i.parameters,l))&&!(e.nodeTag==="menuline"&&l==="parameters")&&!(this.metadataAttributes.has(l)||["ask","_ask"].includes(l)||u&&typeof u=="object"&&Object.hasOwn(u,"$gramlotRef"))&&u!=null&&!["string","number","boolean"].includes(typeof u))throw new TypeError(`HTML attribute ${l} must be scalar`);let a=Object.fromEntries(Object.entries(e.attr).filter(([l])=>!this.metadataAttributes.has(l))),s=r?e.value.getNodes().map(l=>l.nodeTag).filter(Boolean):[];t.validateNode(e,{value:o,attrs:a,childTags:s})}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!==je&&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 o=e.parentNode;if(o?.nodeTag){let i=this.definition(o);if(i.namespace!==je&&i.tag!=="foreignObject"||["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","ul","ol","dl","p","button","label"].includes(i.tag))throw new TypeError("Labelbox requires an HTML flow container")}}create(e,t,r=null,o=e.attr,i=null){let{tag:a,namespace:s,meta:l}=this.definition(e);r??=a;let u=s===je?t.createElement(r):t.createElementNS(s,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({sourceNode:e,frameRecipient:()=>hs(Xu(e)),locale:e.rootBuilder.binding.gramlot.locale,timeZone:e.rootBuilder.binding.gramlot.timeZone,collectionView:(f,h)=>e.rootBuilder.binding.collectionView(e,f,h),format:this.format,upload:()=>this.uploadContext(),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));(s!==je||!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=lp(t,f),d.presentation=d.labelbox.box,d.labelId=`gramlot-label-${ee()}`,d.controlId=`gramlot-control-${ee()}`;let h=t.createElement("style");h.textContent=sp,d.presentation.prepend(h),l.gramlot_component?.labelbox&&u.setLabelbox(d.labelbox)}return this.update(d,e,o,nc,i),d}matches(e,t){let{tag:r,namespace:o}=this.definition(t);return(o===je?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===o}writeParameter(e,t,r){let o=e.getAttr(t);e.pointerType(o)==="^"&&!re(o)&&!Object.is(e.getRelativeData(o.slice(1)),r)&&e.setRelativeData(o.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let o of r)e.element.append(o)}update(e,t,r=t.attr,o=nc,i=null,a=null){if(t.nodeTag==="script"){for(let[b,_]of t.codeAttributes())if(t.activatedCode(b)!==_)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:s,text:l}=e;if(this.hasLabelbox(t)&&!e.labelbox)throw new TypeError("Declare lbl or box_* when creating an experimental HTML labelbox");let u=s.namespaceURI===je,c=this.definition(t).meta.render_attributes??{},d=e.attrs??{},f=b=>(lo(t,b,t.builder.constructor.dialectPrefixes),so(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),h=t.parentNode;if(h?._getMeta("gramlot_component")?.childParameters&&(r=s.ownerDocument.defaultView.customElements.get(h._getMeta("render_tag")).projectChild(e.presentation,r,{label:t.label,adapt:f,invoke:(_,y,E)=>this.invokeScript(t,_,y,E),reportError:(_,y)=>this.reportError(t,_,y),publish:(_,y)=>t.publish(_,y),publishParent:(_,y)=>h.publish(_,y),writeParameter:(_,y)=>this.writeParameter(t,_,y),remove:()=>t.parentBag.popNode(t.label)})),e.labelbox&&(e.labelbox.box.style.visibility="",up(e.labelbox,r,f)),this.definition(t).meta.gramlot_component){if(this.definition(t).meta.gramlot_component.bagStore)if(t.nodeTag==="tree")s.setStoreBag(t.rootBuilder.binding.treeStore(t));else{let b=t.absDatapath(t.getAttr("storepath"));(!a||a.path===b||a.path.startsWith(`${b}.`)||b.startsWith(`${a.path}.`))&&s.setStoreBag(t.getRelativeData(t.getAttr("storepath")))}if(this.definition(t).meta.gramlot_component.bagStruct){let b=t.absDatapath(t.getAttr("structpath"));(!a||a.path===b||a.path.startsWith(`${b}.`)||b.startsWith(`${a.path}.`))&&s.setStructBag(t.getRelativeData(t.getAttr("structpath")))}r=s.projectAttributes(r,f)}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(Fe({...r,...c}));let p=qe.classFor(s,r)!==null;o===nc&&(o=this.text(t));let m=o==null?"":String(o);l.data!==m&&(l.data=m);let w=[...new Set([...Object.keys(d),...Object.keys(r)])];w.sort((b,_)=>(_==="sandbox")-(b==="sandbox")||(u&&s.localName==="input"?(_==="type")-(b==="type"):0));for(let b of w){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||p&&b==="value")continue;let _=r[b];if(u&&b==="multiple"&&["input","select"].includes(s.localName)){s.multiple!==!!_&&(s.multiple=!!_);continue}if(u&&s.localName==="input"&&b==="type"){Object.is(d.type,_)||(_==null?s.removeAttribute("type"):s.type=String(_));continue}let y=b,E=Cv(y),S=u&&Av.has(E)&&typeof s[E]=="boolean",x=y==="xmlns"?"xmlns":y.includes(":")?y.split(":")[0]:"",N=Object.hasOwn(Np,x)?Np[x]:null;if(Object.is(d[b],_)||(_==null||S&&!_?N?s.removeAttributeNS(N,y.split(":").at(-1)):s.removeAttribute(y):N?s.setAttributeNS(N,y,String(_)):s.setAttribute(y,S?"":String(_))),u&&(S||Dv.has(E))&&E in s){let O=E==="value"?_==null?"":String(_):!!_;s[E]!==O&&(s[E]=O)}}if(i===!1?s.style.visibility!=="hidden"&&(s.style.visibility="hidden"):e.visible===!1&&(r.style==null?s.removeAttribute("style"):s.setAttribute("style",String(r.style))),e.visible=i,e.labelbox){let{fieldLabel:b,labelBox:_,box:y}=e.labelbox;["input","textarea","select","button","output","meter","progress"].includes(e.tag)?(s.id||(s.id=e.controlId),b.htmlFor=s.id):(b.id=e.labelId,this.definition(t).meta.gramlot_component?.labelbox||(y.setAttribute("role","group"),_.hidden?y.removeAttribute("aria-labelledby"):y.setAttribute("aria-labelledby",b.id))),y.hidden=!!r.hidden,i===!1&&(y.style.visibility="hidden")}e.attrs=r}text(e){return e.value instanceof I?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};var bs=class n{#e;#t;#r=null;#n=0;#o=new Set;#a=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()??{},o=[];if(t.length&&o.push("controller"),r.action!=null&&o.push("action"),e.nodeTag==="menuline"&&r.command!=null&&o.push("registered"),Ip(r).length&&o.push("fire"),e.nodeTag==="menuline"&&e.value instanceof I&&e.value.getNodes().some(i=>i.nodeTag==="menu")&&o.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&o.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(o.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${o.join(" and ")} together; a button has one click mechanism`);return o[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.#a!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#a=t)}for(let t of this.#o)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.#o)e.cancel(),e.release();this.#o.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);let r=this.element.closest("gramlot-row-actions"),o=r?r.getRowContext():null;if(r&&o===null||!this.element.prepareCommand(e))return;let i=this.mechanism;if(!i||(e.stopPropagation(),this.element.disabled))return;let a=i==="registered"?Ap(this.binding,e):null;if(i==="registered"&&!a)return;a&&this.#o.add(a);let s=this.binding.countClick(),l=this.node;for(;l&&l.getAttr("_delay")==null;)l=l.parentNode;let u=l?l.rootBuilder.runtimeValues(l)[1]._delay:0;if(u>0){let c=this.#n+1;this.#r?.(),this.#n=c;let d=setTimeout(()=>{f(),this.#r=null,this.#n=0,this.#s(e,c,a,o)},u),f=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(d),a&&(a.cancel(),a.release(),this.#o.delete(a)),f(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#s(e,s,a,o)}async#i(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,o={...e.message.parameters};if(t&&r.required(this.binding,t,o,"ask")&&await r.show(this.binding,t,o)===null)return;e.deliver()}finally{e.release(),this.#o.delete(e)}}#s(e,t,r=null,o=null){if(r)return this.#i(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let a=this.node,s=Nv(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t,rowContext:o});else if(i==="action"){let l=()=>{let[,f]=a.rootBuilder.runtimeValues(a),h=Object.fromEntries(Object.entries(f).filter(([p])=>p!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(h),...o,event:e,_counter:t,modifiers:s}},u=f=>{if(this.binding.closed||this.element.disabled||f===null)return;let h={...l(),...f};f&&(h._askResult=f),Ut(this.binding.runtime,a,"action",a.getAttr("action"),h)},c=a.getAttr("ask"),d=this.binding.runtime.askDialog;if(c&&d.required(this.binding,c,l(),"ask"))return d.show(this.binding,c,l()).then(u);u(void 0)}else{let l={modifier:s,_counter:t},u=a.getAttr("fire");if(u!=null){a.FIRE(u,s||!0,l);return}for(let[c,d]of Ip(a.getAttr())){if(this.binding.closed)return;a.FIRE(d,c.slice(5),l)}}}};function Ip(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function Nv(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var At=class extends de{static classKwargs={...de.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.#e(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}async#e(e){if(this.closed)return;let t=this._computeEffectiveFingerprint(this._buildEffectiveKw()),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let o=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(o,this.cacheTime!==0):this.cachedValue=o}finally{this.writing=!1}return o}};var ho=class extends At{static internalParams=new Set([...At.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:o,onCalling:i=null,onError:a,sync:s=!1}){super({cacheTime:o,onError:a}),this.binding=e,this.sync=s,this.method=t,this.params=r,this.onCalling=i}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Op=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function Rp(n,e=new Set){if(!(n instanceof k)||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 o=r.attr,i=o.kind,a=r.staticValue;if(Object.keys(o).some(l=>!Op.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(i))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(o[l]!=null&&typeof o[l]!="boolean"&&!(typeof o[l]=="string"&&o[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(o.favorite!=null&&typeof o.favorite!="boolean")throw new TypeError("favorite must be boolean");if(o.caption!=null&&typeof o.caption!="string")throw new TypeError("Menu caption must be text");if(o.parameters!=null&&(typeof o.parameters!="object"||Array.isArray(o.parameters)))throw new TypeError("Menu parameters must be a mapping");if(i==="command"&&(typeof o.command!="string"||!o.command||a!=null||o.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(i==="separator"&&(a!=null||Object.keys(o).length!==1))throw new TypeError("Separator record accepts kind only");if(i==="submenu"&&(typeof o.caption!="string"||o.command!=null||a instanceof k==(o.resolver!=null)||!(a instanceof k)&&a!=null))throw new TypeError("Submenu requires caption and exactly one content source");let s=a instanceof k?Rp(a,t):null;return{label:r.label,attrs:{...o},children:s}})}function Bp(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof I?n.value.getNodes():[],o=new Set(e.map(i=>i.label));for(let i of r)o.has(i.label)||n.value.popNode(i.label);for(let[i,a]of e.entries()){let{kind:s,...l}=a.attrs,u=Object.fromEntries(Object.entries(l).filter(([p])=>p==="resolver"||p==="cacheTime"||p==="sync"||p.startsWith("resolver_")));for(let p of Object.keys(u))delete l[p];let c=s==="separator"?"-":null,d=n.value instanceof I?n.value.getNodes().find(p=>p.label===a.label):null,f=d?.value instanceof I;if(d&&(f!==(s==="submenu")||d.value==="-"!=(s==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=ie(t.menuline(c,{...l,node_label:a.label}));else{let p=Object.keys(d.attr).filter(m=>Op.has(m)&&!Object.hasOwn(l,m));d.setAttr({...Object.fromEntries(p.map(m=>[m,null])),...l})}if(s==="submenu"){let p=d.value instanceof I?d.value.getNodes().find(m=>m.nodeTag==="menu"):null;p?p.setAttr({...Object.fromEntries(Object.keys(p.attr).filter(m=>m==="resolver"||m==="cacheTime"||m==="sync"||m.startsWith("resolver_")).map(m=>[m,null])),...u}):p=ie(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),a.children&&Bp(p,a.children)}let h=n.value.getNodes().indexOf(d);h!==i&&n.value.move(h,i)}}var ws=class{#e=null;#t=null;#r=0;#n=!1;#o=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(([o])=>o.startsWith("resolver_")).map(([o,i])=>[o.slice(9),i])),r=L([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#o=null,this.#t=e.resolver?new ho({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 o=t.cachedValue,i=Rp(o),a=L(o);this.#o!==a&&(Bp(this.node,i),this.#o=a),this.element.setStatus(i.length?null:"empty")}catch(o){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,o)}}};var _s=class{#e=!1;#t=!1;constructor(e,t){this.binding=e,this.element=t}attach(){this.element.cardActions=this}detach(){this.#e=!0,delete this.element.cardActions}async clear(){let{binding:e,element:t}=this,r=()=>!this.#e&&!e.closed&&t.isConnected&&t.parameters.delitem===!0;if(this.#t||!r())return;let o=e.node,i=o.value,a=o.absDatapath(".");if(!(a===null||!(i instanceof I))){this.#t=!0;try{if(await e.runtime.askDialog.show(e,{title:"Clear card fields",msg:`Clear the fields of \u201C${t.parameters.title}\u201D? This cannot be undone.`},{})===null||!r()||o.value!==i||o.absDatapath(".")!==a)return;let l=new Map,u=new Set,c=f=>{for(let h of["collapsed","checkbox"]){let p=f.getAttr(h);f.pointerType(p)&&u.add(f.absDatapath(p))}};c(o);let d=f=>{for(let h of f.getNodes()){h.nodeTag==="groupletCard"&&c(h);let p=h.getAttr("value");if(!h._getMeta("data_element")&&h.pointerType(p)==="^"&&!re(p)){let m=h.absDatapath(p);m!==null&&(a===""||m.startsWith(`${a}.`))&&l.set(m,{child:h,pointer:p})}h.staticValue instanceof I&&d(h.staticValue)}};d(i);for(let[f,{child:h,pointer:p}]of l){if(!r()||o.value!==i||o.absDatapath(".")!==a)break;u.has(f)||h.getAttr("value")!==p||h.absDatapath(p)!==f||e.runtime.renderer.html.writeParameter(h,"value",null)}}finally{this.#t=!1}}}};var ys="connect_on",Ai=class{#e;#t;#r;#n;#o;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(ys)&&t.length>ys.length&&r!=null).map(([t,r])=>[t,t.slice(ys.length).toLowerCase(),r])}constructor(e,t,r,o,i=`${ys}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.#o=i}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#n}get attribute(){return this.#o}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(vi(this.handler))return Qt(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function dn(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 lt(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>dn(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 fn(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 lt(...e),e}function Di(n,e,t){let r=n-1,o=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let i=1;i<e;i++)o+=dn(n,i);return o}function Si(n,e){let t=Di(...fn(n))+e;if(!Number.isSafeInteger(t)||t<0||t>Di(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,o=1e4;for(;o-r>1;){let a=Math.floor((r+o)/2);Di(a,1,1)<=t?r=a:o=a}t-=Di(r,1,1);let i=1;for(;t>=dn(r,i);)t-=dn(r,i++);return lt(r,i,t+1)}function oc(n){return Si(n,-(Di(...fn(n))%7))}function $p(n,e,t=0,r=1){let o=n*12+e-1+t,i=Math.floor(o/12),a=(o%12+12)%12+1,s=o+r-1,l=Math.floor(s/12),u=(s%12+12)%12+1;return{start:lt(i,a,1),end:lt(l,u,dn(l,u))}}var vs={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 Mp(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(),o=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(vs,r))throw new RangeError(`Unsupported locale: ${n}`);let i=vs[r];return{dictionary:i,phrases:s=>[...new Set([...i.keywords[s],...vs.en.keywords[s]])],order:i.date_order[o]??i.date_order.default}}var hn=/^(?:\d{4}|\d{2})$/,Pp=/^\d{1,2}$/,Ci=(n,e)=>({ok:!1,error:{code:n,message:e}}),mn=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},jp=(n,e)=>Object.hasOwn(n,e);function pn(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 Iv(n,e){if(n.includes(";")){let o=n.split(";").map(i=>i.trim());return o.length!==2?mn("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let o of t)if(n.startsWith(`${o} `))return{bounds:["",n.slice(o.length+1).trim()],range:!0};for(let o of t){let i=` ${o} `;if(!n.includes(i))continue;for(let s of r)if(n.startsWith(`${s} `)){n=n.slice(s.length+1);break}let a=n.split(i).map(s=>s.trim());return a.length!==2?mn("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:a,range:!0}}for(let o of r)if(n.startsWith(`${o} `))return{bounds:[n.slice(o.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function Ov(n,e,t){let r=[[n,0]],o=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);o&&r.push([o[1],Number(o[2]+o[3])]);let i={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[a,s]of r)for(let[l,u]of Object.entries(i))if(e.phrases(l).includes(a)){if(l.endsWith("_week"))return Si(oc(e.workdate),(u+s)*7+(t?6:0));if(l.endsWith("_month")){let c=$p(e.year,e.month,u+s);return t?c.end:c.start}return Si(e.workdate,u+s)}return null}function Rv(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((o,i)=>i[0].length-o[0].length);for(let[o,i]of r){let a;if(n===o)a=null;else if(n.startsWith(o)&&hn.test(n.slice(o.length).trim()))a=pn(n.slice(o.length).trim(),e);else if(n.endsWith(o)&&hn.test(n.slice(0,-o.length).trim()))a=pn(n.slice(0,-o.length).trim(),e);else continue;return{year:a,month:t?i*3:i*3-2}}return null}function Lp(n,e){if(jp(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 Bv(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>Lp(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return mn();let o=r[0],i=Lp(t[o],e.dictionary),a=t.slice(0,o),s=t.slice(o+1),l=[...a,...s];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(i>e.month?1:0),month:i};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(i<e.month?1:0),month:i};if(!l.length)return{year:null,month:i};if(!a.length&&s.length===1&&hn.test(s[0]))return{year:pn(s[0],e),month:i};if(a.length===1&&Pp.test(a[0])){if(!s.length)return lt(e.year,i,Number(a[0]));if(s.length===1&&hn.test(s[0]))return lt(pn(s[0],e),i,Number(a[0]))}return!a.length&&s.length===2&&Pp.test(s[0])&&hn.test(s[1])?lt(pn(s[1],e),i,Number(s[0])):mn()}function $v(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return lt(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),o={};if(r)e.order.split("").forEach((s,l)=>{o[s]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let s=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?s:2;o[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!hn.test(o.Y)||o.D.length>2||o.M.length>2)return mn();let i=Number(o.D),a=Number(o.M);return r&&a>12&&i<=12&&([i,a]=[a,i]),lt(pn(o.Y,e),a,i)}function Fp(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(i=>!r.includes(i)).join(" "),!n)return mn();if(hn.test(n))return lt(pn(n,e),t?12:1,t?31:1);let o=Ov(n,e,t)??Rv(n,e,t)??Bv(n,e);return o!==null?o:jp(e.dictionary.weekdays,n)?Si(oc(e.workdate),e.dictionary.weekdays[n]):$v(n,e)??mn()}function Mv(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,o=typeof e=="string"?fn(e)[0]:e?.year,i=typeof e=="string"?fn(e)[1]:e?.month;return o&&(r>o&&(r=o),r===o&&n.month>i&&r--),lt(r,n.month,1)}function Pv(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[o,i]=fn(e);r<o&&(r=o),r===o&&i>n.month&&r++}return lt(r,n.month,dn(r,n.month))}function Es(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return Ci("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:o,twoDigitYearAhead:i=20}=e,[a,s]=fn(o);if(!Number.isInteger(i)||i<0||i>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...Mp(r),workdate:o,year:a,month:s,twoDigitYearAhead:i}}catch(r){return Ci("INVALID_CONTEXT",r.message)}if(typeof n!="string")return Ci("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:o,range:i}=Iv(r,t),a=Fp(o[1],t,!0),s=Fp(o[0],t,!1),l=Mv(s,a,t),u=Pv(a,l,t);return!i&&typeof s=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return Ci("INVALID_DATE",r.message);if(r instanceof SyntaxError)return Ci(r.code,r.message);throw r}}function qp(n){if(n===null)return null;let{value:e,columns:t,dtype:r,locale:o}=n;if(typeof e!="string"||!Array.isArray(t)||!t.length||t.some(u=>typeof u!="string"||!u||u==="rowidx")||!["T","L","R","N","D"].includes(r))throw new TypeError("Invalid collection filter");if(!e.trim())return null;if(r==="T"){let u=new RegExp(e,"i");return c=>u.test(t.map(d=>Lv(c(d),o,n.timeZone)).join(" "))}if(t.length!==1)throw new TypeError("Typed filters require one column");let i=/^\s*(<=|>=|==|!=|[<>=!#])\s*(.+?)\s*$/.exec(e);if(!i)throw new Error("Enter a comparison, for example > 100 or = 12.");let[,a,s]=i,l;if(r==="D"){let u=new Date,c=`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,d=Es(s,{locale:o,workdate:c});if(!d.ok||d.kind!=="date")throw new Error("Enter one complete date after the comparison.");l=new Date(`${d.date}T00:00:00Z`)}else l=Fv(s,o);return u=>{let c=u(t[0]);if(c==null)return!1;if(r==="D"?!(c instanceof Date)||!Number.isFinite(c.getTime()):!(typeof c=="number"&&Number.isFinite(c)||pe(c)&&c.isFinite()))throw new TypeError(`Filter value does not match ${r}`);let d=pe(l)?-l.comparedTo(c):c<l?-1:c>l?1:0;switch(a){case"=":case"==":return d===0;case"!":case"#":case"!=":return d!==0;case"<":return d<0;case">":return d>0;case"<=":return d<=0;case">=":return d>=0}}}function Lv(n,e,t){return n==null?"":typeof n=="string"||typeof n=="boolean"?String(n):ls(n,{pattern:n instanceof Date?"short":"#,##0.####################"},{locale:e,timeZone:t})}function Fv(n,e){let t=new Intl.NumberFormat(e).formatToParts(-12345.6),r=t.find(l=>l.type==="decimal").value,o=t.find(l=>l.type==="group")?.value,i=t.find(l=>l.type==="minusSign").value,a=n.replaceAll(i,"-");if(o&&a.includes(o)){let u=a.split(r)[0].replace(/^[+-]/,"").split(o),c=new Intl.NumberFormat(e).formatToParts(1234567890123).filter(h=>h.type==="integer").map(h=>h.value.length),d=c.at(-1),f=c.at(-2);if(a.split(r).slice(1).some(h=>h.includes(o))||!/^\d+$/.test(u[0])||u[0].length>f||u.slice(1).some((h,p)=>!/^\d+$/.test(h)||h.length!==(p===u.length-2?d:f)))throw new Error("Invalid numeric grouping.");a=a.replaceAll(o,"")}if(a=a.replace(r,"."),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(a))throw new Error("Enter a complete number.");let s=Lt(a);if(!pe(s)||!s.isFinite())throw new Error("A finite Decimal backend is required.");return s}var xs=class{#e=new Set;constructor(e,t){if(!(e instanceof k))throw new TypeError("collection store requires a Bag");if(!["values","attributes"].includes(t))throw new TypeError("collection store rowMode must explicitly be values or attributes");if(!e.parentNode)throw new TypeError("collection store requires a Bag attached to Data");this.bag=e,this.rowMode=t}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}receiveData(e,t=null){ks(this.#e,{full:t===null,rows:t?[t]:[]})}getRows(){let e=this.bag.getNodes();for(let t of e){if(t.resolver)throw new TypeError("collection store requires loaded rows");if(this.rowMode==="values"&&!(t.staticValue instanceof k))throw new TypeError(`collection store row ${t.label} must contain a Bag`)}return e}value(e,t){if(e.resolver)throw new TypeError("collection store requires loaded rows");if(this.rowMode==="attributes")return e.getAttr(t);let r=e.staticValue;if(!(r instanceof k))throw new TypeError(`collection store row ${e.label} must contain a Bag`);let o=r.getNode(t);if(o?.resolver)throw new TypeError("collection store requires loaded cells");return o?.staticValue}};function ks(n,e){let t=[],r=Object.freeze({full:e.full,rows:Object.freeze([...e.rows])});for(let o of[...n])if(n.has(o))try{o(r)}catch(i){t.push(i)}if(t.length)throw new AggregateError(t,"Collection notification failed")}var Ts=class{#e;#t=null;#r=new Set;#n=new Map;#o="";#a=null;#i=null;#s=null;constructor(e){this.bindStore(e)}get bag(){return this.#e.bag}get rowMode(){return this.#e.rowMode}get sortedBy(){return this.#o}get criteria(){return Up(this.#o)}get filter(){return this.#a}get filtered(){return this.#s===null?null:[...this.#s]}isFiltered(){return this.#s!==null}value(e,t){return this.#e.value(e,t)}subscribe(e){return this.#r.add(e),()=>this.#r.delete(e)}connect(){this.#t||(this.synchronize(),this.#t=this.#e.subscribe(e=>this.synchronize(e)))}disconnect(){this.#t?.(),this.#t=null}bindStore(e){if(this.#e===e)return;let t=this.#t!==null;this.disconnect(),this.#e=e,this.#n.clear(),t?this.connect():this.synchronize()}getRows(e=!0){let t=this.#l();return e&&this.#s!==null?this.#s.map(r=>t[r]):t}#l(){return this.#e.getRows().toSorted((e,t)=>(this.#n.get(e)??1/0)-(this.#n.get(t)??1/0))}synchronize(e={full:!0,rows:[]}){if(!e.full&&!this.#o&&!this.#i){ks(this.#r,e);return}this.#c(this.#u(this.#l(),this.criteria),this.#o,this.#a,this.#i,e)}sort(e){let t=this.#u(this.#l(),Up(e));this.#c(t,e,this.#a,this.#i)}moveRow(e,t,r=!1){if(e===t||e.parentBag!==this.bag||t.parentBag!==this.bag)return;let o=this.getRows(!1);o.splice(o.indexOf(e),1),o.splice(o.indexOf(t)+Number(r),0,e),this.#c(o,"",this.#a,this.#i)}applyFilter(e){let t=e===null?null:Object.freeze({...e,columns:Object.freeze([...e.columns])}),r=qp(t);this.#c(this.#l(),this.#o,t,r)}#c(e,t,r,o,i={full:!1,rows:[]}){let a=o?e.flatMap((c,d)=>o(f=>this.value(c,f))?[d]:[]):null,s=i.full||t!==this.#o||JSON.stringify(r)!==JSON.stringify(this.#a)||e.length!==this.#n.size||e.some((c,d)=>this.#n.get(c)!==d)||JSON.stringify(a)!==JSON.stringify(this.#s);this.#n=new Map(e.map((c,d)=>[c,d])),this.#o=t,this.#a=r,this.#i=o,this.#s=a;let l=a===null?null:new Set(a),u=s?[]:i.rows.filter(c=>this.#n.has(c)&&(l===null||l.has(this.#n.get(c))));(s||u.length)&&ks(this.#r,{full:s,rows:u})}#u(e,t){if(!t.length)return e;let r=e.map(o=>({node:o,keys:t.map(({field:i})=>this.value(o,i))}));for(let o=0;o<t.length;o++)if(new Set(r.map(a=>jv(a.keys[o])).filter(a=>a!==null)).size>1)throw new TypeError(`collection view cannot compare mixed types in ${t[o].field}`);return r.sort((o,i)=>{for(let[a,{direction:s}]of t.entries()){let l=qv(o.keys[a],i.keys[a]);if(l)return s==="a"?l:-l}return 0}).map(o=>o.node)}};function Up(n){if(typeof n!="string")throw new TypeError("collection view sortedBy must be a string");if(n==="")return[];let e=new Set;return n.split(",").map(t=>{let r=/^([^,:]+):([ad])$/.exec(t);if(!r||e.has(r[1]))throw new TypeError(`Invalid collection view sort criterion: ${t}`);return e.add(r[1]),{field:r[1],direction:r[2]}})}function jv(n){if(n==null)return null;if(typeof n=="number"&&Number.isFinite(n)||pe(n)&&n.isFinite())return"number";if(n instanceof Date&&Number.isFinite(n.getTime()))return"date";if(typeof n=="string"||typeof n=="boolean")return typeof n;throw new TypeError("collection view sort requires loaded finite scalar values")}function qv(n,e){return n==null||e==null?n==null?e==null?0:-1:1:pe(n)?n.comparedTo(e):pe(e)?-e.comparedTo(n):n<e?-1:n>e?1:0}var As=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},ic=class{#e;#t;#r;#n;#o;#a=!0;#i;constructor(e,{path:t,attr:r,recipient:o,order:i,subtree:a=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.#o=i,this.#i=a}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#i}get active(){return this.#a}get order(){return this.#o}close(){this.active&&(this.#a=!1,this.router.unregister(this))}},ac=class{constructor({evt:e,node:t,path:r,oldvalue:o,attrsDiff:i,reason:a,fired:s,level:l,registration:u,index:c}){this.evt=e,this.node=t,this.path=r,this.oldvalue=o,this.attrsDiff=i,this.reason=a,this.fired=s,this.level=l,this.registration=u,this.index=c}},Ds=class{#e;#t=new As;#r=new Map;#n=0;#o=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:o=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let i=this.#t;for(let s of e.split(".")){let l=i.children.get(s);l||(l=new As(i,s),i.children.set(s,l)),i=l}this.#o+=1;let a=new ic(this,{path:e,attr:t,recipient:r,order:this.#o,subtree:o});return i.registrations.add(a),this.#r.set(a,i),this.#n+=1,a}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]!==hi||e.reason==="autocreate")return;let r=t.slice(1),o=e.evt==="ins"||e.evt==="del";for(let i of Array.isArray(e.node)?e.node:[e.node]){let a=o?[...r,i.label]:r,s=a.join(".");for(let[l,u]of this.#a(a,e))l.active&&l.recipient.receive(new ac({evt:e.evt,node:i,path:s,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}))}}#a(e,t){let r=[],o=this.#t;for(let a of e){for(let s of o.registrations)o!==this.#t&&this.#i(s,"child",t)&&r.push([s,"child"]);if(o=o.children.get(a),!o)return r.sort(([s],[l])=>s.order-l.order)}for(let a of o.registrations)this.#i(a,"node",t)&&r.push([a,"node"]);let i=[...o.children.values()];for(;i.length;){let a=i.pop();for(let s of a.registrations)this.#i(s,"container",t)&&r.push([s,"container"]);i.push(...a.children.values())}return r.sort(([a],[s])=>a.order-s.order)}#i(e,t,r){let{evt:o}=r;return e.subtree?t!=="container"||o!=="upd_attrs":e.attr===null?o==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?o!=="upd_attrs":o==="ins"||o==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var Uv=new Set(["T","B","L","R","N","D","H","DHZ"]),Vv=new Set(["tag","field","name","dtype","width","align","format","columnset","white_space","max_height","edit"]),zv=new Set(["tag","code","name","background","color"]),Ni=class{#e=new Map;constructor(e){if(!(e instanceof k))throw new TypeError("grid structpath must resolve to a Bag");let t=Ss(e,"view_0"),r=Ss(e,"info"),o=Ss(t,"rows_0"),i=Ss(r,"columnsets"),a=new Set,s=new Map;for(let l of i.getNodes()){let u=l.getAttr();if(Vp(u,zv),zp(u.code,"colgroup code"),u.tag!=="columnset"||l.resolver||l.staticValue!=null||l.label!==u.code)throw new TypeError("grid columnset requires a scalar definition labelled by code");if(s.has(u.code))throw new TypeError(`Duplicate grid colgroup: ${u.code}`);if(u.name!=null&&typeof u.name!="string")throw new TypeError("grid group name must be text");for(let c of["background","color"])if(u[c]!=null&&typeof u[c]!="string")throw new TypeError(`grid ${c} must be text`);s.set(u.code,{...u,name:u.name??u.code})}this.columns=[],this.groups=[];for(let l of o.getNodes()){let u=l.getAttr();if(Vp(u,Vv),u.tag!=="cell"||l.staticValue!=null||l.resolver)throw new TypeError("grid cell must be a scalar declaration");if(zp(u.field,"field"),a.has(u.field))throw new TypeError(`Duplicate grid field: ${u.field}`);if(a.add(u.field),this.#e.set(u.field,l),u.columnset!=null&&!s.has(u.columnset))throw new TypeError(`Unknown grid columnset: ${u.columnset}`);if(u.dtype!=null&&!Uv.has(u.dtype))throw new TypeError(`Unsupported grid dtype: ${u.dtype}`);if(u.align!=null&&!["start","center","end"].includes(u.align))throw new TypeError("grid align requires start, center or end");if(u.width!=null&&(typeof u.width!="string"||!/^(?:\d+(?:\.\d+)?)(?:px|em|rem|ch|%)$/.test(u.width)))throw new TypeError("grid width requires a nonnegative CSS length (px, em, rem, ch or %)");if(u.max_height!=null&&(typeof u.max_height!="string"||!/^(?:\d+(?:\.\d+)?)(?:px|em|rem)$/.test(u.max_height)))throw new TypeError("grid max_height requires a nonnegative CSS length (px, em or rem)");if(u.white_space!=null&&!["normal","nowrap","pre-wrap"].includes(u.white_space))throw new TypeError("grid white_space requires normal, nowrap or pre-wrap");for(let h of["name","format"])if(u[h]!=null&&typeof u[h]!="string")throw new TypeError(`grid ${h} must be text`);if(u.edit!=null&&typeof u.edit!="boolean"&&(typeof u.edit!="object"||Array.isArray(u.edit)))throw new TypeError("grid edit requires a boolean or editor options");let c=Object.freeze({...u,name:u.name??u.field,align:u.align??(["L","R","N"].includes(u.dtype)?"end":"start")});this.columns.push(c);let d=u.columnset??null,f=this.groups.at(-1);(!f||f.code!==d)&&(f={code:d,...d===null?{name:null}:s.get(d),columns:[]},this.groups.push(f)),f.columns.push(c)}if(!this.columns.length)throw new TypeError("grid struct requires at least one column");for(let l of this.groups)Object.freeze(l.columns),Object.freeze(l);Object.freeze(this.columns),Object.freeze(this.groups),Object.freeze(this)}columnNode(e){return this.#e.get(e)}moveColumn(e,t,r=!1){let o=this.#e.get(e),i=this.#e.get(t);if(!o||!i||o===i)return;let a=o.parentBag,s=a.getNodes(),l=s.indexOf(o),u=s.indexOf(i),c=u+Number(r)-+(l<u);c!==l&&a.move(l,c)}setColumnWidth(e,t){if(!Number.isFinite(t)||t<=0)throw new TypeError("grid resized width must be positive pixels");this.#e.get(e).setAttr({width:`${Math.round(t)}px`})}};function Ss(n,e){let t=n.getNode(e);if(!t||t.resolver||!(t.staticValue instanceof k))throw new TypeError(`grid struct requires Bag ${e}`);return t.staticValue}function Vp(n,e){for(let t of Object.keys(n))if(!e.has(t))throw new TypeError(`Unsupported grid struct attribute: ${t}`)}function zp(n,e){if(typeof n!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new TypeError(`grid ${e} requires a simple field identifier`)}function Hp(n){let e=new k,t=new k,r=new k;e.setItem("view_0",new k,{tag:"view"}),e.getItem("view_0").setItem("rows_0",t,{tag:"rows"}),e.setItem("info",new k),e.getItem("info").setItem("columnsets",r);let o=(i,a=null)=>{if(i.builder.validateNode(i),i.nodeTag!=="column"||i.staticValue!=null)throw new TypeError("grid column must be a scalar declaration");let s={tag:"cell"};for(let u of["field","name","dtype","width","align","format","white_space","max_height","edit"])i.getAttr(u)!=null&&(s[u]=i.getAttr(u));let l=`cell_${s.field}`;if(t.getNode(l))throw new TypeError(`Duplicate grid field: ${s.field}`);a!==null&&(s.columnset=a),t.setItem(l,null,s)};for(let i of n.getNodes())if(i.nodeTag==="column")o(i);else if(i.nodeTag==="colgroup"){if(i.builder.validateNode(i),!(i.staticValue instanceof I))throw new TypeError("grid colgroup requires column declarations");let a=i.getAttr("code");if(r.getNode(a))throw new TypeError(`Duplicate grid colgroup: ${a}`);let s={tag:"columnset",code:a,name:i.getAttr("name")??a};for(let l of["background","color"])i.getAttr(l)!=null&&(s[l]=i.getAttr(l));r.setItem(a,null,s);for(let l of i.staticValue.getNodes())o(l,a)}else throw new TypeError("grid struct accepts column and colgroup only");return e}function Gp(n){if(n._getMeta("gramlot_component")?.bagStruct){let e=n.staticValue instanceof I?n.staticValue.getNodes():[];if(e.some(t=>!t._getMeta("gridStruct"))||e.length>1)throw new TypeError("grid accepts one struct declaration");if(e.length&&n.getAttr("structpath")!=null)throw new TypeError("grid requires structpath or nested struct, not both");if(!e.length&&!n.getAttr("structpath"))throw new TypeError("grid requires structpath or nested struct");if(!["values","attributes"].includes(n.getAttr("rowMode")))throw new TypeError("grid rowMode must explicitly be values or attributes")}if(n._getMeta("gridStruct")){if(!n.parentNode?._getMeta("gramlot_component")?.bagStruct)throw new TypeError("struct requires a grid parent");if(!(n.staticValue instanceof I))throw new TypeError("grid struct requires column declarations");new Ni(Hp(n.staticValue))}}function Wp(n,e){let t=Hp(n.staticValue);new Ni(t);let r=`gramlot.grid.${crypto.randomUUID().replaceAll("-","")}.struct`;e.setItem(r,t,null,">",!1,!0,n),n.parentNode.setAttr({structpath:r},!1),n.setValue(null,!1)}var Cs=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=Ii(e),r=this.setterNodes(e);lc(e);for(let o of r)o._getMeta("gridStruct")?Wp(o,this.runtime.data):this.applySetter(o),this.runtime.closeBranch(o),o.parentBag&&o.parentBag.popNode(o.label);this.applyDefaults(t.filter(o=>o.nodeTag&&!o._getMeta("data_element")))}setterNodes(e){return Ii(e).filter(t=>t.nodeTag==="dataSetter"||t._getMeta("gridStruct"))}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let r=e.getAttr("value")??null,o=Gv(e.getAttr()),i=this.runtime.data;if(r!==null)i.setItem(t,r,o,">",!1,!0,e),r instanceof k&&e.setAttr({value:null},!1);else{let a=i.getNode(t);a?o&&a.setAttr(o,!0):i.setItem(t,null,o,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[o,i]of Object.entries(r)){if(!Hv(t,o,i))continue;let a=o==="value"?r.default_value??r.default:r[`default_${o}`];a!=null&&this.#t(t,i,a)}this.#r(t,r)}}#t(e,t,r){let o=e.absDatapath(t);if(o===null)return;let[i,a=null]=o.split("?",2),s=this.runtime.data,l=s.getNode(i);if(a===null){if(l&&l.value!==null&&l.value!==void 0)return;s.setItem(i,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(a);u==null&&l.setAttr({[a]:r},!0)}else s.setItem(i,null,{[a]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[a,s]of Object.entries(t))a.startsWith("attr_")&&(r[a.slice(5)]=re(s)?Ir(e,a):e.pointerType(s)?e.getRelativeData(s):s);if(!Object.keys(r).length)return;let o=[t.value,t.src].find(a=>e.pointerType(a));if(!o)return;let i=e.absDatapath(o);i!==null&&this.runtime.data.getNode(i.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function Hv(n,e,t){return e==="_meta"||Xr.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function Gv(n){let e={};for(let[t,r]of Object.entries(Sr(n??{})))Xr.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function Wv(n){let e=n.builder;if(!(e instanceof Oe))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function lc(n){for(let e of Ii(n))Gp(e),e.nodeTag==="dataSetter"&&Wv(e),Jv(e)}var Yv=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Xv=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Zv=["_onCalling","_onResult","_onError"],Kv=["_delay","_timing","_userChanges"],sc=["_init","_onBuilt","_onStart"];function Jv(n){let e=i=>n.getAttr(i)!==null&&n.getAttr(i)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let i=Zv.find(a=>e(a)&&!(a==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(i){let a=i==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${i}' is allowed only on ${a}`)}}if(Xv.has(n.nodeTag)){let i=Object.entries(n.getAttr()).find(([,s])=>mt(s));if(i)throw new Error(`${n.nodeTag} '${n.label}': '${i[0]}' is a == expression, not accepted on ${n.nodeTag}`);let a=n.nodeTag==="dataRemote"?sc.find(e):null;if(a)throw new Error(`dataRemote '${n.label}': '${a}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let s of sc){let l=n.getAttr(s);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${s}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Yv.find(i=>e(i)&&!(i==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&Kv.includes(i)));if(!r)return;let o=sc.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${o}`)}function Ii(n){if(n instanceof I)return n.getNodes().flatMap(t=>Ii(t));let e=[n];return n.value instanceof I&&e.push(...Ii(n.value)),e}var Qv=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"]),Oi=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,o=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(o)),this.#r=()=>{clearTimeout(o),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),o=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),o(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},po=class{#e;#t=[];#r=new Set;#n;#o=null;#a=!1;constructor(e){this.#e=e,this.#n=new Oi(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,o=Ft(e,e.getAttr("_timing"));for(let[i,a]of e.pointers()){if(i==="datapath")continue;let s=e.absDatapath(a);if(s===null)continue;let[l,u=null]=s.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(i==="_timing"||o.has(i))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(i,a,s)=>(l,u)=>{let c={kind:"subscription",topic:s,payload:l,metadata:u};if(this.#s("_userChanges")&&s!=="node")return;let d=this.#s("_delay");d>0?this.#n.debounce(d,()=>this.invoke(c)):this.invoke(c)})),this.#i(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#i();return}if(this.#s("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},r=this.#s("_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",o=this.kind==="rpc",i=this.kind==="remote",a=this.readArguments(e);e.askResult&&(Object.assign(a,e.askResult),a._askResult=e.askResult);let s=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(s&&!e.askDone&&l.required(this.binding,s,a,"_ask"))return l.show(this.binding,s,a,t.getAttr("_ask_title")??"Warning").then(p=>{if(!this.binding.closed){if(p===null){let m=t.getAttr("_ask_onCancel");m&&this.#l("_ask_onCancel",m,m,a,!0);return}return this.invoke({...e,askDone:!0,askResult:p})}});let[u,c]=[r?"formula":"script",t.getAttr(r?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,a,!1)){if(i&&this.#f(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(o||i){this.#l(u,c,c,a,!0);return}}if(o)return this.#c(a);if(i)return this.#d(a);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,a,!0);else if(f==null){if(!r)return;h=new k(Ns(a))}else{let{group:p,method:m}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?m.call(p,a):m.call(p,t,a)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),o=Object.fromEntries(Object.entries(r).filter(([l])=>!Qv.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),i={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(o)};e.kind==="subscription"&&(i._subscription_kwargs=e.payload,i._subscription_metadata=e.metadata);let a=e.change??null,s=a?a.level:e.kind==="subscription"?e.topic:e.kind;return i._node=a?a.node:null,i._triggerpars={kw:a,trigger_reason:s},i._reason=s,e.kind==="click"&&(Object.assign(i,e2(e)),e.rowContext&&Object.assign(i,e.rowContext,{event:e.event})),i}cancel(){this.#n.cancel()}#i(){this.#n.startTiming(this.#s("_timing"),()=>this.invoke({kind:"timing",change:null}))}#s(e){let t=this.node,r=t.getAttr(e);return re(r)?Ir(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,o,i){let a=[...i?["_kwargs"]:[],...Yp,...Xp,...Object.keys(Ns(o))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?Ut(this.binding.runtime,this.node,e,t,{...o,_kwargs:o},a):this.binding.runtime.inlineCompiler.compile(this.node,e,t,a,r)({...o,_kwargs:o})}async#c(e){let t=this.node,[r,o,i]=["_onCalling","_onResult","_onError"].map(s=>t.getAttr(s)),a=t.requests;if(a.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return a.submit(this.#s("method"),Ns(e),s=>this.#u(s,e,o,i))}async#u(e,t,r,o){if(this.binding.closed)return;let i=this.node,a=this.#s("timeout"),s=a>0?setTimeout(()=>{let c=new Error(`${i.nodeTag} '${i.label}': no answer within ${a} ms`);c.name="TimeoutError",e.controller.abort(c)},a):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(s),this.binding.closed||e.ignored)return;if("error"in l){if(!o)throw l.error;this.#l("_onError",o,o,{...t,error:l.error},!0);return}let{result:u}=l;i.getAttr("result_path")!=null&&i.setRelativeData(i.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#f();let t=this.#a;this.#a=!1;let r=this.node,o=r.absDatapath(r.pathAttribute("destination_path"));if(o===null)return;let i=r.getAttr("_onCalling"),a=new ho({binding:this.binding,method:this.#s("method"),params:Ns(e),cacheTime:this.#s("cacheTime"),sync:this.#s("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:i?()=>this.#l("_onCalling",i,i,e,!0):null,onError:s=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${a.method}' failed: ${s.message}`,{cause:s})}});this.binding.runtime.data.setResolver(o,a),this.#o={path:o,resolver:a},t&&a.refresh()}#f(){if(!this.#o)return;let{path:e,resolver:t}=this.#o;this.#o=null,this.#a=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()}},Is=class extends po{get kind(){return"formula"}},Os=class extends po{get kind(){return"controller"}},Rs=class extends po{get kind(){return"rpc"}},Bs=class extends po{get kind(){return"remote"}},Yp=["_node","_triggerpars","_reason","_subscription_kwargs","_subscription_metadata","_askResult"],Xp=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function Ns(n){let e={...n};for(let t of[...Yp,...Xp])delete e[t];return e}function e2({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 t2=[[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 "]],r2=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,n2=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"]),$s=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 o=r.trim();if(r2.test(o))throw new Error(`${Ri(e,t)}: the PUBLISH macro is excluded from Gramlot`);let i=o.replace(/\$(\d+)/g,(a,s)=>`arguments[${parseInt(s,10)-1}]`);for(let[a,s,l]of t2)a&&(i=i.replace(a,`; ${a.source.slice(1)}`)),i=i.replace(s,l);return i!==o&&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`),i}compile(e,t,r,o,i=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 a=this.#t.get(e);a||(a=new Map,this.#t.set(e,a),this.runtime.bindingFor(e).track(()=>this.release(e)));let s=a.get(t);s?.source!==i&&(s={source:i,text:this.preprocess(e,t,i),key:null,run:null},a.set(t,s));let l=o.filter(o2),u=l.join(",");if(s.key!==u){let c=i2(e,t,s.text,l);s.key=u,s.run=d=>c.apply(e,l.map(f=>d[f]))}return s.run}compileExpression(e,t,r){let o=r.slice(2).trim(),i=Fe(e.getAttr()).filter(([,s])=>!mt(s)),a=this.compile(e,t,r,[...i.map(([s])=>s).filter(s=>s!=="_F"),"_F"],`return ${o}`);return s=>{let l={};for(let[u,c]of i)Object.hasOwn(s,u)?l[u]=s[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return a({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,r,o){let i=this.compile(e,t,r,["_pointerValues","_F"],`return (${o}
|
|
195
|
+
)`);return a=>i({_pointerValues:a,_F:(s,l)=>this.runtime.gramlot.format(s,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let o of t){r.delete(o);for(let[i]of Fe({[o]:null}))r.delete(i)}}};function o2(n){return/^[A-Za-z_$][\w$]*$/.test(n)&&!n2.has(n)}function Ri(n,e){return`${n.nodeTag} '${n.label}' ${e?`'${e}'`:"node value"}`}function i2(n,e,t,r){try{return t.startsWith("function")?new Function(`return (${t}
|
|
196
196
|
)`)():new Function(...r,`${t}
|
|
197
|
-
`)}catch(o){throw o instanceof EvalError?new EvalError(`${
|
|
198
|
-
${t}`,{cause:o})}}var
|
|
197
|
+
`)}catch(o){throw o 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:o}):new SyntaxError(`${Ri(n,e)}: ${o.message} in the inline code:
|
|
198
|
+
${t}`,{cause:o})}}var Ms=class{#e;#t;#r=!1;#n=null;#o=null;constructor(e){this.#e=e,this.#t=new Oi(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.#i("_timing"),()=>this.trigger())}receive(e){if(this.#i("_userChanges")&&e.level!=="node")return;let t=this.#i("_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,o={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(o[l.slice(7)]=u);let i=e.getAttr("_if");if(i&&!this.#s("_if",i,`return (${i})`,o)){let l=e.getAttr("_else");l&&this.#s("_else",l,l,o);return}let a;try{let l=L(o);if(t._cachedRemote&&this.#a(r,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#s("_onCalling",u,u,o):null))return;a=await this.binding.runtime.gramlot.src.remoteSource(e,r,o)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${r}' failed: ${l.message}`,{cause:l})}let s=e.getAttr("_onRemote");!this.closed&&a&&s&&await this.#s("_onRemote",s,s,o)}fragmentMounted(e,t){this.#n=e,this.#o=t}#a(e,t){let r=this.node.requests.inflight;return r?r.method===e&&L(r.params)===t:e===this.#n&&t===this.#o}#i(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#s(e,t,r,o){return e==="_onRemote"?Ut(this.binding.runtime,this.node,e,t,o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(o),r)(o)}};var mo="gramlot-page-store-remote",Ps=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=ee(),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===mo)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",o=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?o?"upd_value":"del":e.evt,value:o?.value??null,attr:{...o?.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,mo):t.popNode(this.clientPath,mo);else if(e.op==="change")e.evt==="del"?t.popNode(r,mo):e.evt==="upd_attrs"?t.getNode(r).setAttr(e.attr,mo,!1,!1):t.setItem(r,e.value,e.attr,e.index??">",!1,!1,mo);else throw new Error("Unknown PageStore delivery")}unregister(){this.ready=!1,this.registration?.close(),this.registration=null,this.connection?.unregister(this)}};var a2=new Set(["title","msg","fields","_if","askIf"]),s2=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),Ls=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,r,o){let i=(a,s)=>typeof s=="boolean"?s:e.runtime.inlineCompiler.compile(e.node,a,s,Object.keys(r),`return (${s});`)(r);if(typeof t=="string"){let a=e.node.getAttr("_ask_if");return!a||!!i("_ask_if",a)}return t?.askIf&&i(`${o}.askIf`,t.askIf),!t?._if||!!i(`${o}._if`,t._if)}show(e,t,r,o="Parameters"){let i=typeof t=="string"?{msg:t,title:o}:t;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(i))if(!a2.has(d))throw new Error(`Unsupported ask option: ${d}`);let a=i.fields??[];if(!Array.isArray(a))throw new TypeError("ask fields must be an array");let s=new Set;for(let d of a){if(!d||!/^[A-Za-z_]\w*$/.test(d.name)||s.has(d.name))throw new Error("ask fields require distinct simple names");s.add(d.name);for(let f of Object.keys(d))if(!s2.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_${ee()}`,p=!1,m=()=>{},w=(b,_=null)=>{if(p)return;p=!0;let y=b?Object.fromEntries(a.map(E=>[E.name,l.data.getItem(`${h}.${E.name}`)])):null;c.delete(h),m();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),_?f(_):d(y)}catch(E){f(E)}};c.set(h,{finish:w}),m=e.track(()=>w(!1));try{let b=new Oe,_=b.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(i.title??o,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),i.msg&&_.p(i.msg);let y=_.form({request:h,connect_onsubmit:`${u}.confirm`});for(let x of a){y.dataSetter({destination_path:`.${x.name}`,value:Object.hasOwn(r,x.name)?r[x.name]:x.default_value??(x.type==="checkbox"?!1:"")});let N=y.div({style:"margin:8px 0;"});N.html_label(x.lbl??x.name,{for:`${h}_${x.name}`,style:"display:block;margin-bottom:4px;"});let O={id:`${h}_${x.name}`,value:`^.${x.name}`,live:!0};for(let $ of["required","min","max","step","placeholder"])x[$]!==void 0&&(O[$]=x[$]);x.tag==="textarea"?N.textarea(O):N.input({...O,type:x.type??"text"})}let E=y.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:a.length===0}),l.src.source.setItem(h,l.src.prepareSource(b.source));let S=l.src.binding.nodeIds.get(h);l.dom.getDomNode(S).showModal()}catch(b){w(!1,b)}})}#n(){if(this.#t===null){let e=`ask_${ee()}`,t=this.#r;class r{confirm(i,a){a.preventDefault(),t.get(i.getAttr("request"))?.finish(!0)}cancel(i,a){a.preventDefault(),t.get(i.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(r,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var Fs=class{#e;#t=`errors_${ee()}`;#r=null;#n=new Map;#o=new Set;#a=0;constructor(e){this.#e=e}show(e,t){let r=new Set,o=[];for(let a=e;a!==null&&typeof a=="object"&&!r.has(a);a=a.cause){if(a.name==="AbortError")return;r.add(a),o.push(a.stack??a.message)}let i=typeof e?.message=="string"?e.message:String(e);queueMicrotask(()=>{this.#e.disposed||this.#i(i,t,o.join(`
|
|
199
199
|
Caused by:
|
|
200
|
-
`))})}#i(e,t,r){let o=this.#e.gramlot,i=JSON.stringify([t,e]);if(this.#o.has(i))return;let a=this.#e.nodeIds.get(this.#t);if(!a){if(this.#n.clear(),this.#a=0,this.#r===null){let m=this;class p{close(b){m.#s(b.getAttr("notice"))}}this.#r=`errors_${ee()}`,this.#e.logicRegistry.register(p,{group:this.#r,resource:"gramlot:error-notifications"})}let h=new Ie;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;"}),o.src.source.setItem(this.#t,o.src.prepareSource(h.source)),a=this.#e.nodeIds.get(this.#t)}if(this.#n.has(i))return;if(this.#n.size===5){let h=`${++this.#a} additional errors`,m=a.value.getNode("overflow");m?m.setValue(h):o.src.builder.wrapSource(a).p(h,{node_label:"overflow",role:"status",style:"margin:0;padding:12px;"});return}let s=`notice_${ee()}`,l=new Ie,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:s,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=o.src.builder.wrapSource(a).div({node_label:s});ae(f).setValue(o.src.prepareSource(l.source)),this.#n.set(i,s),o.dom.getDomNode(a).showPopover()}#s(e){this.#e.nodeIds.get(this.#t).value.popNode(e);for(let[r,o]of this.#n)o===e&&(this.#n.delete(r),this.#o.add(r));this.#n.size||this.#e.gramlot.src.source.popNode(this.#t)}};var jp={dataFormula:Ds,dataController:Ss,dataRpc:Cs,dataRemote:Ns},Jv=["datapath","_anchor","nodeId","form","formId"],po=class{#e;#t=new Map;#r=new Map;#n;#o;#a;#i;#s;#l;#c=`gramlot-data-${ee()}`;#u=!1;#d=new Set;#f=new Set;#p=new WeakMap;constructor(e,{subscriptions:t}){this.#e=e,this.#l=t,this.#n=new xs(this),this.#o=new Ts(this),this.#a=new Is(this),this.#i=new Bs(this),this.#s=new $s(this)}get gramlot(){return this.#e}reportError(e,t){this.disposed||this.#s.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}treeStore(e){let t=e.getAttr("storepath");if(t==="*S"||t.startsWith("*S.")){let r=this.renderer.source.getItem("main");return t==="*S"?r:r.getItem(t.slice(3))}return t==="*D"||t.startsWith("*D.")?t==="*D"?this.data:this.data.getItem(t.slice(3)):e.getRelativeData(t)}registerTreeRoot(e,t){let r=t?this.#d:this.#f;return r.add(e),{close:()=>r.delete(e)}}refreshSourceTrees(){for(let e of[...this.#d])!e.closed&&this.renderer.attached(e.node)&&this.renderer.project(e.node)}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.#o}get inlineCompiler(){return this.#a}get askDialog(){return this.#i}get nodeIds(){return this.#r}collectionStore(e,t){if(this.disposed)throw new Error("BindingRuntime is disposed");let r=this.#p.get(e);if(!r)r=new _s(e,t),this.#p.set(e,r);else if(r.rowMode!==t)throw new TypeError("A shared collection store requires one rowMode");return r}collectionView(e,t,r){let o=this.collectionStore(t,r);return Object.hasOwn(e,"gridCollectionView")?e.gridCollectionView.bindStore(o):Object.defineProperty(e,"gridCollectionView",{value:new vs(o),configurable:!0}),e.gridCollectionView}attach(){this.root.subscribe(this.#c,{any:e=>this.receiveData(e)})}receiveData(e){let t=this.root;for(let[r,o]of(e.pathlist??[]).entries()){let i=t.node(o)?.staticValue;if(!(i instanceof x))break;this.#p.get(i)?.receiveData(e,r+1<e.pathlist.length?i.node(e.pathlist[r+1]):null),t=i}this.router.deliver(e);for(let r of[...this.#f])!r.closed&&this.renderer.attached(r.node)&&this.renderer.project(r.node)}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 ec(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof I)for(let o of e.value.getNodes())try{this.closeBranch(o)}catch(i){t.push(i)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let o=e.getAttr("nodeId");this.nodeIds.get(o)===e&&this.nodeIds.delete(o);try{r.close()}catch(i){t.push(i)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#_(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,o=[],i=a=>{try{this.closeBranch(a)}catch(s){o.push(s)}};try{if(t==="ins")this.#h(r);else if(t==="del")for(let a of Array.isArray(r)?r:[r])i(a);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof I)for(let a of e.oldvalue.getNodes())i(a);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#b(r,e.attrs_diff):this.#w(r).rebind(),r.value instanceof I&&this.#h(r.value)}else if(t==="upd_attrs")this.#b(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(a){throw o.length?new AggregateError([...o,a],"Source event failed"):a}return o}branchBuilt(e){let t=[];for(let r of this.#_(e)){let o=this.bindingFor(r);!o||o.hasStamp("built")||!this.renderer.attached(r)||(o.stamp("built"),t.push(o))}for(let r of t)this.renderer.attached(r.node)&&this.#g(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#m(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#m(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#c,{any:!0}),this.nodeIds.clear(),this.#p=new WeakMap;let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(o){e.push(o)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#h(e){if(!(e instanceof I)&&this.bindingFor(e))return;let t=e instanceof I?e.getNodes().flatMap(i=>this.#_(i)):this.#_(e),r=new Set(t.filter(i=>this.bindingFor(i))),o=new Map;for(let i of t){let a=i.getAttr("nodeId");if(a!=null){if(o.has(a)||this.nodeIds.has(a)&&this.nodeIds.get(a)!==i)throw new Error(`Duplicate nodeId '${a}'`);o.set(a,i)}}for(let[i,a]of o)this.nodeIds.set(i,a);try{for(let i of t)this.openBinding(i);this.installer.install(e);for(let i of t)this.renderer.attached(i)&&this.bindingFor(i).registerPointers()}catch(i){let a=[i];for(let s of t.filter(l=>!r.has(l)).reverse()){let l=s.getAttr("nodeId");o.get(l)===s&&this.nodeIds.get(l)===s&&this.nodeIds.delete(l);let u=this.bindingFor(s);if(u){this.#t.delete(s);try{u.close()}catch(c){a.push(c)}}}throw a.length>1?new AggregateError(a,"Source branch installation failed"):i}for(let i of t){let a=this.bindingFor(i);if(!(!a||a.hasStamp("init")||!this.renderer.attached(i))&&(a.stamp("init"),qp(i.getAttr("_init"))))for(let s of a.providers)s.invoke({kind:"init",change:null})}}#m(e){e.hasStamp("start")||(e.stamp("start"),this.#g(e,"start","_onStart"),e.remote?.trigger())}#g(e,t,r){let o=e.node.getAttr(r);if(qp(o))for(let i of e.providers){if(typeof o!="number"||o<=0){i.invoke({kind:t,change:null});continue}let a=null,s=setTimeout(()=>{a(),i.invoke({kind:t,change:null})},o);a=e.track(()=>clearTimeout(s))}}#b(e,t){let r=this.#w(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:o,new:i}=t.nodeId;if(i!=null&&this.nodeIds.has(i)&&this.nodeIds.get(i)!==e)throw new Error(`Duplicate nodeId '${i}'`);this.nodeIds.get(o)===e&&this.nodeIds.delete(o),i!=null&&this.nodeIds.set(i,e)}Jv.some(o=>Object.hasOwn(t,o))?this.rebindBranch(e):r.rebind()}#w(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}#_(e){let t=[e];if(e.value instanceof I)for(let r of e.value.getNodes())t.push(...this.#_(r));return t}};function qp(n){return n===!0||typeof n=="number"}var ec=class{#e;#t;#r=!1;#n=[];#o=[];#a=new Set;#i=null;#s=null;#l=null;#c=new Set;#u=new Set;#d=0;#f=new Set;#p=null;editingSession=null;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.#o]}get providers(){return this.#i?[this.#i]:[]}get remote(){return this.#l}get clickCount(){return this.#d}countClick(){return++this.#d}hasStamp(e){return this.#a.has(e)}stamp(e){this.#a.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&&!jp[e.nodeTag]&&e.nodeTag!=="dataBinder")return;!t&&typeof e.getAttr("remote")=="string"?this.#l??=new Os(this):this.#l&&(this.#l.close(),this.#l=null);let r=new Set,o=e._getMeta("gramlot_component");for(let[a,s]of[["bagStore","storepath"],["bagStruct","structpath"]]){if(!o?.[a])continue;let l=e.getAttr(s);if(typeof l!="string"||!l||/^[\^=]/.test(l)||l.includes("?"))throw new TypeError(`${s} requires a plain Bag data path`);if(a==="bagStore"&&e.nodeTag==="tree"&&(l==="*S"||l.startsWith("*S."))){this.#o.push(this.runtime.registerTreeRoot(this,!0));continue}if(a==="bagStore"&&e.nodeTag==="tree"&&l==="*D"){this.#o.push(this.runtime.registerTreeRoot(this,!1));continue}let u=a==="bagStore"&&e.nodeTag==="tree"&&l.startsWith("*D.")?l.slice(3):e.absDatapath(l),c=this.runtime.router.register({path:u,recipient:this,subtree:!0});this.#o.push(c),a==="bagStore"&&o.bagStruct&&(this.#p=c)}let i=this.remote?Lt(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[a,s]of Object.entries(e.getAttr()))if(a.startsWith("remote_"))for(let l of Lt(e,s))r.add(l)}for(let[a,s]of e.pointers()){if(t&&a!=="datapath")continue;let u=(a==="datapath"?e.parentNode:e).absDatapath(s);if(u===null)continue;let[c,d=null]=u.split("?",2),f=this.runtime.router.register({path:c,attr:d,recipient:this});this.#o.push(f),a==="datapath"&&this.#f.add(f),this.remote&&(a==="remote"||a.startsWith("remote_")||r.has(a))&&this.#c.add(f),this.remote&&(a==="_timing"||i.has(a))&&this.#u.add(f)}if(!t){this.#h(),this.remote?.register();return}if(e.nodeTag==="dataBinder"){this.#s??=new Rs(this),this.#s.register();return}this.#i??=new jp[e.nodeTag](this),this.#i.register()}#h(){let e=this.node;this.#o.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return o=>{if(this.closed)return;if(wi(r))return an(this.runtime,e,r,o);let[,i]=e.rootBuilder.runtimeValues(e),a=Object.fromEntries(Object.entries(i).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...this.runtime.renderer.references.resolveArguments(a),p_0:o};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(s))(s)}}))}rebind(){this.#m(),this.registerPointers(),this.editingSession?.refreshField(this.node)}receive(e){if(!(e.registration===this.#p&&(e.level==="child"||e.evt==="upd_attrs"))){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.editingSession?.refreshField(this.node),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,o=this.track(()=>r.abort());try{let i=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return i}finally{o()}}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.#m();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`)}#m(){this.#s?.unregister();for(let e of this.#o.splice(0))e.close();this.#p=null,this.#f.clear(),this.#c.clear(),this.#u.clear()}};var Ms=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 o=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(o===null)return null;let{dragValues:i,item:a,path:s}=o;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:i,item:a,path:s});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return kt(i),{dragValues:Object.fromEntries(Object.entries(i).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,j(F(c))]})),item:a,path:s}}};var Cr=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 o=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{let a=i.split("*").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${a.join(".*")}$`)});return e.filter(i=>i!=="dragTags"&&(r.includes(i)||o.some(a=>a.test(i))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(o=>o.trim()).filter(Boolean));return r.size?t.split(",").some(o=>o.split(" AND ").every(i=>(i=i.trim(),!i||i==="!"?!1:i.startsWith("!")?!r.has(i.slice(1)):r.has(i)))):!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,o,i=[]){let a=this.acceptedTypes(e,o.dropTypes,i),s=o.dropEffect??"move",l=this.isTarget(o)&&a.length>0&&this.acceptsTags(t,o.dropTags)&&this.acceptsEffect(r,s);return{accepted:l,types:a,dropEffect:l?s:"none"}}};var Up=["dragstart","dragover","dragleave","drop","dragend"],Ps=class{#e;#t;#r=null;#n=null;#o=null;#a;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Up)this.#t.addEventListener(t,this);this.#a=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#a)}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)}#i(e,t){for(let r of e.composedPath()){let o=this.#e.elements.get(r);if(o&&t(o.resolved))return o}return null}#s(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.#i(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 o=this.#s(t,e);if(!o){e.preventDefault();return}let i=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:F(c)]));if(!i.size){e.preventDefault();return}let a=t.resolved.effectAllowed??"all";Cr.acceptsEffect(a,"move");let s="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){s=u.resolved.dragTags;break}let l=this.#r={record:t,wires:i,effectAllowed:a,phase:"active",tags:[s,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 i)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=a,this.#o=this.#t.createElement("style"),this.#o.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.#o),this.#c(l,o.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#w(r)}}}#c(e,t,r){let o=t.cloneNode(!0);o.removeAttribute("id");for(let i of o.querySelectorAll("[id]"))i.removeAttribute("id");o.setAttribute("aria-hidden","true"),o.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(o),e.preview=o,r.setDragImage(o,0,0)}#u(e){let t=this.#r,r=this.#i(e,u=>Cr.isTarget(u));if(!r)return null;let o=this.#s(r,e);if(!o)return{record:r,element:r.element,accepted:!1};let i=Cr.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),s={dropValues:Object.fromEntries(i.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):j(t.wires.get(u))])),item:o.item,path:o.path,source:{...t.source},selfdrop:r===t.record,dropEffect:i.dropEffect,dataAvailable:!0},l=i.accepted&&this.#e.checkDropTarget(r.node,s)&&this.#e.records.get(r.node)===r&&o.element.isConnected;return{record:r,element:o.element,accepted:l,context:s}}#d(e){if(!this.#r){this.#i(e,t=>Cr.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.#w(t)}}async#f(e){if(!this.#r){this.#i(e,o=>Cr.isTarget(o))&&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(o){this.#r===t&&(t.phase="rejected",this.#m()),(!r||this.#e.records.has(r.record.node))&&this.#w(o)}}#p(e,t){let r=t?"canBeDropped":"cannotBeDropped",o=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:o.includes(r)},e.classList.add(r),o.includes(r)||e.setAttribute("part",[...o,r].join(" "))}#h(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:o}=this.#n;r||e.classList.remove(t),o||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(i=>i!==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.#o?.remove(),this.#o=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.#w(r))}#w(e){this.#e.binding.reportError(e,"Drag and drop failed")}dispose(){this.#g();for(let e of Up)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#a)}};var Ii=class extends ln{static renderType="object";#e=new Set;#t=new WeakSet;#r=new WeakMap;#n=new WeakMap;#o=new WeakMap;constructor(e,t,r,{binding:o}={}){if(super(e),!(e instanceof Ze)||!(t instanceof Te)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(o instanceof po))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof Ze))throw new TypeError("SourceBag requires builder ownership");this._binding=o,this.source=t,this.destination=r,this.html=new fs({uploadContext:()=>({gramlot:o.gramlot,window:r.ownerDocument.defaultView}),metadataAttributes:["__ref"],format:(i,a)=>o.gramlot.format(i,a),reportError:(i,a,s)=>{this.records.has(i)&&o.reportError(a,s)},callLogic:(i,a,s)=>{let{group:l,method:u}=o.gramlot.src.logicRegistry.resolve(a,i);return u.call(l,i,s)},invokeScript:(i,a,s,l)=>jt(o,i,a,s,l,i.parentNode._getMeta("gramlot_component").childParameters[a].inline)}),this.records=new Map,this.references=new fi(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new Ms(this),this.instanceId=ee(),this.radioGroups=new ds(this),this.dragDrop=new Ps(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:i=>this.receive(i)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},o){let i={source:t,dropEffect:r},a=[],s=this.records.get(e);try{s&&!s.binding.closed&&s.resolved.onDragEnd&&await this.html.callLogic(e,s.resolved.onDragEnd,i)}catch(l){a.push(l)}try{this.binding.gramlot.publish(o,i)}catch(l){a.push(l)}if(a.length)throw new AggregateError(a,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let r=this.#n.get(e)??super.evaluateExpressions(e,t),o=e._getMeta("gramlot_component");if(o?.presentationDefaults.length){let i=e.getAttr();this.#o.set(e,Object.fromEntries(Object.entries(r).filter(([a])=>Object.hasOwn(i,a)&&o.presentationDefaults.some(s=>a.startsWith(s)))))}if(this.html.hasLabelbox(e)||o?.presentationDefaults.length){let i=[];for(let a=e.parentNode;a;a=a.parentNode)this.#o.has(a)&&i.unshift(this.#o.get(a));r=Object.assign({},...i,r)}return this.#n.delete(e),this.#r.set(e,r),r}render(e,t={}){if(!(e instanceof sn))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||this.#t.has(e)||!this.binding.bindingFor(e)&&this.#l(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof I))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 o=t.createDocumentFragment(),i={node:e,binding:this.#m(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,i),this.elements.set(o,i),o.append(i.start);for(let a of e.value.getNodes()){let s=this.render(a,{document:t,...r});if(s===null)continue;o.append(s);let l=this.elements.get(s);l&&(l.parent=i,i.children.add(a))}return o.append(i.end),o}renderedItem(e,t,r,{tag:o,document:i=this.destination.ownerDocument}={}){let a=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(a=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,a]=gi(t,a,(h,m)=>this._binding.gramlot.format(h,m)))),a=this.componentAttributes(e,a);let s=Array.isArray(t)?t:[],l=Array.isArray(t)?a._text:t,u=this.#r.get(e),c={node:e,binding:this.#m(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,i,o,a,u.visible??null)};this.html.compose(c,l,s),c.shape=Fe.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c),this.elements.set(c.presentation,c);let d=Fe.for(c.binding,c);(d||c.element.namespaceURI===Le&&c.element.localName==="input")&&c.cleanup.push(()=>c.control?.detach()),d&&(c.control=d,d.attach(),this.#f(c,e,a,null));let f=hs.for(c.binding,c);if(f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new ps(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),e.nodeTag==="groupletCard"){let h=new ms(c.binding,c.element);h.attach(),c.cleanup.push(()=>h.detach())}this.#p(c),this.references?.register(e,c.element);for(let h of s){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 Te))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,o=s=>{if(!r.has(s)){r.add(s);for(let l of this.records.get(s)?.children??[])o(l);if(s.value instanceof I)for(let l of s.value.getNodes())o(l)}};for(let s of this.records.get(t)?.children??[])o(s);if(t?.value instanceof I)for(let s of t.value.getNodes())o(s);this.#a(e,t?t.nodeTag:null),Qu(e),this.references?.validate(e,r);let i=new Set,a=s=>{for(let l of s.getNodes()){let u=l.getAttr("nodeId");if(u!=null){let c=this.binding.nodeIds.get(u);if(i.has(u)||c&&c!==l&&!r.has(c))throw new Error(`Duplicate nodeId '${u}'`);i.add(u)}l.value instanceof I&&a(l.value)}};return a(e),e}#a(e,t=null){let r=new Set,o=(i,a=null)=>{if(!(i instanceof Te)||r.has(i))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(i._builder instanceof Ze))throw new TypeError("SourceBag requires builder ownership");r.add(i);for(let s of i.getNodes()){if(!(s instanceof sn))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(s.builder instanceof Ze))throw new TypeError("SourceBagNode requires builder ownership");if(s.resolver)throw new TypeError("Source resolvers are outside this port");if(s._getMeta("data_element"))s.builder.validateNode(s);else if(s.nodeTag){let l=s._getMeta("subbuilder")?i._builder:s.builder;this.html.validate(s,l),s._getMeta("subbuilder")||s.builder.validateParent(s.nodeTag,a)}else{if(!(s.value instanceof I))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(s.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}s.value instanceof I&&o(s.value,s._getMeta("subbuilder")?null:s.nodeTag??a)}};o(e,t)}freeze(e){e=ae(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=ae(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=o=>{delete o.frozen;for(let i of o.children)r(this.records.get(i))};r(t),!this.#i(e)&&(this.attached(e)?this.#g(e):this.remove(e))}#i(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(this.disposed)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(o=>!t(o));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.#c(r);let o=this.binding.handleSourceEvent(r);try{this.#s(r,o)}catch(i){if(!o.length)throw i;o.push(i)}if(this.binding.refreshSourceTrees(),o.length)throw o.length===1?o[0]:new AggregateError(o,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#s(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#i(r))continue;let o=this.records.get(r)?.parent??null;try{this.remove(r)}catch(i){t.push(i)}this.#h(o)}return}if(!this.#i(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#l(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}#c(e){let t=r=>{if(!(r instanceof sn))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof I){if(!(r.value instanceof Te))throw new TypeError("Source values must be GramlotBuilderBags");for(let o of r.value.getNodes())t(o)}};t(e.node)}unmountView(e){this.#t.add(e),this.remove(e)}mountView(e){this.#t.delete(e),this.insert(e)}insert(e){if(!this.attached(e)||this.records.has(e))return;for(let a=e;a;a=a.parentNode)if(this.#t.has(a))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,o=e.parentBag.getNodes(),i=t?.end??null;for(let a=o.indexOf(e)+1;a<o.length;a++){let s=this.records.get(o[a]);if(s){i=s.presentation??s.start;break}}this.buildNode(e,r,i,t)}buildNode(e,t,r=null,o=null){this.#e.add(e);let i;try{i=this.render(e,{document:t.ownerDocument})}catch(s){this.#u(e,s)}finally{this.#e.delete(e)}let a=this.records.get(e);return t.insertBefore(i,r),a.parent=o,this.assignContainer(a,t),o?.children.add(e),this.#h(o),this.binding.branchBuilt(e),a}#u(e,t){let r=[t],o=[],i=a=>{if(o.push(a),a.value instanceof I)for(let s of a.value.getNodes())i(s)};i(e);for(let a of o.reverse())try{this.remove(a)}catch(s){r.push(s)}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 o of e.children){let i=this.records.get(o);i&&this.assignContainer(i,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let o=e.value==null||["string","number","boolean"].includes(typeof e.value),i=t==="upd_value"&&o&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||i)&&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.#g(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element||!this.attached(e))return;let o=this.getRender(e.builder),i=this.#o.get(e),[a,s]=e.rootBuilder.runtimeValues(e),[,l]=o._handleMeta(e,s),u=this.#r.get(e),c=r.element.namespaceURI===Le&&r.element.localName==="input"&&!Object.is(r.resolved.type,u.type),d=r.element.namespaceURI===Le&&["input","select"].includes(r.element.localName)&&!!r.resolved.multiple!=!!u.multiple,f=r.resolved.group,h=r.control instanceof uo&&!Object.is(f??null,u.group??null);if((c||d||h)&&this.#i(e))return;if(r.shape!==Fe.shape(r.element,u)){if(this.#i(e))return;this.#n.set(e,u);try{this.#g(e)}finally{this.#n.delete(e)}return}let m=c?Fe.classFor(r.element,u):null,p=c&&(r.control?.constructor??null)!==m,w=(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 b=e._getMeta("subbuilder")?l:o.adaptAttrs(l),_=e.value instanceof I,y=_?[]:this.expressionValue(e,a);if(o===this&&(b=this.restoreNativeAttributes(e,b),e._getMeta("gramlot_component")||([y,b]=gi(y,b,(N,k)=>this._binding.gramlot.format(N,k)))),b=this.componentAttributes(e,b),this.html.update(r,e,b,_?b._text:y,u.visible??null,t),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}w||this.#f(r,e,b,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#p(r);let E=this.#o.get(e);if(E){let N=new Set([...Object.keys(i??{}),...Object.keys(E)].filter(k=>!Object.is(i?.[k],E[k])));N.size&&this.#d(e,N)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#h(r.parent)}#d(e,t){if(e.value instanceof I)for(let r of e.value.getNodes()){let o=r._getMeta("gramlot_component"),i=r.getAttr(),a=t;o?.presentationDefaults.length?a=new Set([...t].filter(s=>!Object.hasOwn(i,s))):this.html.hasLabelbox(r)&&[...t].some(s=>!Object.hasOwn(i,s))&&this.project(r),a.size&&this.#d(r,a)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),o=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!o)return t;let i=this.#r.get(e),a=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(o??{}),...Object.keys(i).filter(s=>s.startsWith("validate_"))])].filter(s=>Object.hasOwn(i,s)).map(s=>[s,i[s]]));return{...t,...a}}#f(e,t,r,o){if(!e.control)return;let i=t.getAttr("value")!=null;(i||e.valueDeclared)&&e.control.project(r.value??null,o),e.valueDeclared=i}#p(e){let t=new Map(xi.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,o]of[...e.events])t.get(r)?.[2]!==o.handler&&(o.detach(),e.events.delete(r));for(let[r,[,o,i]]of t){if(e.events.has(r))continue;let a=new xi(e.binding,e,o,i,r);a.attach(),e.events.set(r,a)}}#h(e){for(let t=e;t;t=t.parent){if(t.control instanceof Ei){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=ae(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}#m(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#g(e){let t=this.records.get(e),r=t.presentation?.nextSibling??t.end?.nextSibling??null,o=t.container,i=t.parent,a=null;try{this.remove(e)}catch(s){a=s}try{this.buildNode(e,o,r,i)}catch(s){throw a?new AggregateError([a,s],"Source replacement cleanup and commit failed"):s}if(a)throw a}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 o=r.cleanup.indexOf(t);o!==-1&&r.cleanup.splice(o,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let o of[...t.children])try{this.remove(o)}catch(i){r.push(i)}for(let o of t.cleanup.splice(0).reverse())try{o()}catch(i){r.push(i)}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.#r.delete(e),this.#o.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(o){e.push(o)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var Qv=new Set(["page","constructor"]);function Vp(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(Qv.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var e2=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function t2(n){return/^[\w$]/.test(n)?e2.has(n):n!==")"&&n!=="]"}function r2(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let o=n[r];if(o===`
|
|
201
|
-
`)return-1;if(o==="\\"){r++;continue}if(o==="[")t=!0;else if(o==="]")t=!1;else if(o==="/"&&!t)return r}return-1}function
|
|
202
|
-
`,o),o<0)break;continue}if(i==="/"&&n[o+1]==="*"){let a=n.indexOf("*/",o+2);if(a>=0){o=a+1;continue}}if(i==="/"&&t2(r)){let a=r2(n,o);if(a>=0){o=a,r=")";continue}}if(i==='"'||i==="'"||i==="`"){let a=o+1;for(;a<n.length&&n[a]!==i;)a+=n[a]==="\\"?2:1;e===1&&(t+=n.slice(o+1,a)==="constructor"?" constructor":' ""'),o=a,r=")";continue}if(/[\w$]/.test(i)){let a=o+1;for(;a<n.length&&/[\w$]/.test(n[a]);)a++;e===1&&(t+=n.slice(o,a)),r=n.slice(o,a),o=a-1;continue}if(/\s/.test(i)||(r=i),i==="{"){++e===2&&(t+=" {}");continue}if(i==="}"){e--;continue}e===1&&(t+=i)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function zp(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(n2(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 o=Object.getOwnPropertyDescriptor(n.prototype,r);if(o.get||o.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof o.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,o.value])}return t}function Hp(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var mn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},mo=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new mn(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:o}of e){let i=Vp(r,o);for(let a=0;a<i.length;a++){let s=i.slice(0,a).join("/");t.has(s)||t.set(s,new Set),t.get(s).add(i[a])}}for(let{logicClass:r,group:o,resource:i}of e){let a=t.get(o??"")??new Set;for(let[s]of zp(r,i))if(a.has(s))throw new Error(`${i}: the logic method '${s}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let o=Vp(t,r),i=zp(e,r),a=this.#e.logic;for(let s of o){let l=Object.getOwnPropertyDescriptor(a,s)?.value;if(l===void 0){let u=new mn(this,this.#e);Hp(a,s,u),a=u}else if(l instanceof mn)a=l;else throw new Error(`${r}: the group '${s}' has the name of a logic method`)}for(let[s,l]of i){if(Object.getOwnPropertyDescriptor(a,s)?.value instanceof mn)throw new Error(`${r}: the logic method '${s}' has the name of a child group`);Hp(a,s,l)}this.#t.has(a)||this.#t.set(a,[]),this.#t.get(a).push(r)}resolve(e,t){let r=e.split("."),o=r.pop(),i=this.#e.logic;for(let s=0;s<r.length;s++)if(i=Object.getOwnPropertyDescriptor(i,r[s])?.value,!(i instanceof mn))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,s+1).join("/")}'`);let a=Object.getOwnPropertyDescriptor(i,o)?.value;if(typeof a!="function"){let s=this.#t.get(i)??[],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 '${o}' (resources: ${s.join(", ")||"none"})`)}return{group:i,method:a}}};var Oi=class extends Ke{constructor(e,{collections:t,destination:r,subscriptions:o,nameSyntax:i}){super(e),e.src=this,this.logicRegistry=new mo(e),this.builder=new Ie(null,{collections:t,nameSyntax:i}),this.binding=new po(e,{subscriptions:o}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Ii(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 I)throw new TypeError("Initial page data must be a Data Bag");for(let o of t.getNodes())this.builder.data.setItem([o.label],o.getValue(),o.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(o){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),o}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof I){if(!(e instanceof Te))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=Nu(e,t);if(!(r instanceof Te))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 i=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!i)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,a=>this.#e(e,i,a))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let o=!1,i=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let a=await t.call("source",r);if(!i())return!1;let s=this.prepareSource(a,e.builder);return i()?(this.renderer.validateCandidate(s,{replacingNode:e}),o=!0,e.setValue(s,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(a){if(!o&&!i())return!1;throw a}}};var Ri=class extends Ke{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 Ls=class extends Ke{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#o=!1;ready(){this.gramlot._frames.ready()}subscribe(e,t){if(this.#s(),this.#i(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.#s(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#a(e,t,r);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(a=>!["topic","nodeId","parent","iframe","pageId","server"].includes(a)))throw new Error("This publication route is not implemented yet");if(this.#i(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 i=null;if(e.server===!0){if(["parent","iframe","nodeId"].some(a=>Object.hasOwn(e,a)))throw new Error("Server publication cannot combine window or node selectors");if(!this.gramlot._pageStore)throw new Error("Server publication requires a WebSocket channel");i=this.gramlot._pageStore.preparePublish(e,t)}else(e.parent||e.iframe!==void 0||e.pageId!==void 0)&&(i=this.gramlot._frames.prepare(e,t));if(Object.hasOwn(e,"nodeId")){let a=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!a)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(a,e.topic,t)}return this.#a(e.topic,t),i?.()}topicFor(e,t){this.#i(t),e=ae(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 o=e.getAttr("nodeId");return o==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),o=this.#r.get(e)),`${o}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[o,i]of Object.entries(e.getAttr())){let a=o.startsWith("selfsubscribe_")?"selfsubscribe_":o.startsWith("subscribe_")?"subscribe_":null;if(!a)continue;let s=a==="selfsubscribe_"?this.topicFor(e,o.slice(a.length)):o.slice(a.length);this.#i(s),r.push([s,t(o,i,s)])}return this.#s(),r.map(([o,i])=>{let a=this.subscribe(o,i);return{close:()=>this.unsubscribe(a)}})}dispose(){this.#o=!0,this.#e.clear()}#a(e,t,r={}){this.#i(e);let o=this.#e.get(e);if(o)for(let[i,a]of[...o]){if(this.#o)break;o.has(i)&&a(t,{...r})}}#i(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#s(){if(this.#o)throw new Error("Gramlot subscriptions are disposed")}};var Fs=class extends ce{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 Gp=["appinfo","location"],Wp={UNAVAILABLE:"unavailable",PERMISSION_DENIED:"denied",TIMEOUT:"error",FAILED:"error",CANCELLED:"cancelled"};function ne(n){let e=Object.hasOwn(Wp,n?.code)?n.code:"FAILED";return{status:Wp[e],error:e==="CANCELLED"?null:{code:e,message:String(n?.message??"Device operation failed")}}}var Bi=class extends Ke{#e=null;#t=null;#r=null;#n=null;#o=null;#a=null;#i=new Map;#s=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.#s.set(p,{node:e.data.getNode(`gramlot.device.${p}`),stream:null,cleanup:Promise.resolve()});for(let p of Gp){let w=`gramlot.device.${p}`,b={status:"idle",error:null,cacheTime:p==="appinfo"?-1:5};p==="location"&&Object.assign(b,{enabled:!1,watching:!1}),e.data.setItem(w,null);let _=e.data.getNode(w);_.setAttr(b,!1,!0,!1);let y=new Fs(this,p,b.cacheTime);_.resolver=y,this.resolvers.set(p,y)}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 o=e.data.getNode("gramlot.device.barcode");e.data.setItem("gramlot.device.biometrics",null,{status:"idle",error:null,verify:null});let i=e.data.getNode("gramlot.device.biometrics"),a=new x;a.setItem("request",new x);for(let p of["scheduled","received","action"])a.setItem(p,null);e.data.setItem("gramlot.device.notifications",a,{status:"idle",error:null,schedule:null,listening:!1,listenerError:null});let s=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[w,b]of this.#s)if(p.node===b.node&&p.attrs_diff?.enabled){if(typeof b.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.#g(w,b)}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.#w(m),p.attrs_diff?.cancel?.new===!0&&this.#y(m),p.attrs_diff?.share?.new===!0&&this.#_(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===o&&p.fired&&p.attrs_diff?.scan?.new===!0&&this.#S(o),p.node===r&&p.fired&&p.attrs_diff?.choose?.new===!0&&this.#T(r,"choose"),p.node===r&&p.fired&&p.attrs_diff?.capture?.new===!0&&this.#T(r,"capture"),p.node===i&&p.fired&&p.attrs_diff?.verify?.new===!0&&this.#C(i),p.node===s&&p.fired&&p.attrs_diff?.schedule?.new===!0&&this.#N(s),p.node===u&&p.fired&&p.attrs_diff?.register?.new===!0&&this.#O(u);for(let w of this.resolvers.values()){if(p.node!==w._node)continue;let{cacheTime:b}=p.node.attr;if(typeof b!="number"||!Number.isFinite(b)||b<0&&b!==-1)throw new TypeError("Device cacheTime must be -1 or a nonnegative number of seconds");if(w.cacheTime=b,w.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=>![...Gp,"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,o)=>e.startOrientationEvents(r,o),(r,o)=>{if(!["portrait","landscape"].includes(o?.type)||!["primary","secondary"].includes(o.direction)||!Number.isFinite(o.timestamp))throw new TypeError("Invalid screen orientation from device provider");let i=new x;for(let a of["type","direction","timestamp"])i.setItem(a,o[a]);r.setValue(i,!0,{status:"success",error:null},!0,!1)}),this.#m("network",(r,o)=>e.startNetworkEvents(r,o),(r,o)=>{if(typeof o?.connected!="boolean"||!["none","unknown","wifi","cellular"].includes(o.type))throw new TypeError("Invalid network state from device provider");let i=new x;i.setItem("connected",o.connected),i.setItem("type",o.type),r.setValue(i,!0,{status:"success",error:null},!0,!1)}),this.#m("lifecycle",(r,o)=>e.startLifecycleEvents(r,o),(r,o)=>{if(o?.kind==="state"&&typeof o.active=="boolean")r.staticValue.setItem("active",o.active);else if(o?.kind==="pause"||o?.kind==="resume")r.staticValue.setItem("event",o.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.#B(this.gramlot.data.getNode("gramlot.device.links")),e.capabilities.includes("shortcuts")&&this.#R(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.#A(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(o=>{this.disposed||t.request!==r||(this.accept(t,o),t.revision!==r.revision&&(t._lastUpdate=null))}).catch(o=>{!this.disposed&&t.request===r&&t.received===r.received&&this.failure(t,o)}).finally(()=>{t.request===r&&(t.request=null)})}#m(e,t,r){let o=this.gramlot.data.getNode(`gramlot.device.${e}`);if(!this.provider.capabilities.includes(e)){o.setAttr(ne({code:"UNAVAILABLE",message:`${e} is unavailable`}),!0,!0,!1);return}let i={controller:new AbortController};this.#i.set(e,i),o.setAttr({status:"pending",error:null},!0,!0,!1),i.start=Promise.resolve().then(()=>i.controller.signal.aborted?async()=>{}:t(a=>{if(!i.controller.signal.aborted)try{r(o,a)}catch(s){o.setAttr(ne(s),!0,!0,!1)}},i.controller.signal)).then(a=>(i.controller.signal.aborted||o.setAttr({listening:!0},!0,!0,!1),a)),i.start.catch(a=>{let s=i.controller.signal.aborted;i.controller.abort(),s||o.setAttr({...ne(a),listening:!1},!0,!0,!1)})}#g(e,t){let{node:r}=t;if(!r.attr.enabled){let i=t.stream;if(!i)return;t.stream=null,i.controller.abort(),t.cleanup=i.start.then(a=>a(),()=>{}).then(()=>{!this.disposed&&!t.stream&&r.setAttr({watching:!1,status:"idle",error:null},!0,!0,!1)}),t.cleanup.catch(a=>{this.disposed||r.setAttr(ne(a),!0,!0,!1)});return}if(t.stream)return;let o={controller:new AbortController};t.stream=o,o.start=t.cleanup.then(()=>{if(o.controller.signal.aborted)return async()=>{};this.requireCapability(e);let i=a=>{if(!(this.disposed||o.controller.signal.aborted))try{if(a?.kind==="state"&&typeof a.watching=="boolean")r.setAttr({watching:a.watching,status:a.watching?"pending":"idle",error:null},!0,!0,!1);else if(a?.kind==="sample"){for(let l of["x","y","z","timestamp"])if(!Number.isFinite(a[l]))throw new TypeError(`Invalid ${e}.${l}`);if(!r.attr.watching||r.staticValue&&a.timestamp<r.staticValue.getItem("timestamp"))return;let s=new x;for(let l of["x","y","z","timestamp"])s.setItem(l,a[l]);r.setValue(s,!0,{status:"success",error:null},!0,!1)}else if(a?.kind==="error"&&a.error instanceof Error)r.setAttr({...ne(a.error),watching:!1},!0,!0,!1);else throw new TypeError(`Invalid ${e} event`)}catch(s){r.setAttr(ne(s),!0,!0,!1)}};return e==="gyroscope"?this.provider.startGyroscopeUpdates(i,o.controller.signal):this.provider.startAccelerometerUpdates(i,o.controller.signal)}),o.start.catch(i=>{!this.disposed&&!o.controller.signal.aborted&&r.setAttr({...ne(i),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(o=>o.dispose()).then(()=>{this.disposed||t.controller.signal.aborted||this.#n!==t||(this.#n=null,this.#b(e))}).catch(o=>{!this.disposed&&this.#n===t&&(t.phase="failed",e.setAttr(ne(o),!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(o=>{this.#n===r&&!r.controller.signal.aborted&&this.#y(e,o)},r.controller.signal))),r.start.then(o=>{!o||r.controller.signal.aborted||this.disposed||(r.phase="recording",e.setAttr({status:"recording",error:null,recording:!0},!0,!0,!1))}).catch(o=>{r.controller.signal.aborted||this.disposed||(this.#n===r&&(this.#n=null),e.setAttr({...ne(o),recording:!1},!0,!0,!1))})}#w(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 o=new x;for(let i of["url","mimeType","duration"])o.setItem(i,r[i]);t.phase="complete",e.setValue(o,!0,{status:"success",error:null,recording:!1},!0,!1)}).catch(r=>{!t.controller.signal.aborted&&!this.disposed&&this.#y(e,r)}))}#_(e){let t=this.#n;if(t?.phase!=="sharing"){if(!t||t.phase!=="complete"){let r=ne(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 o=ne(r);e.setAttr({shareStatus:o.status,shareError:o.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(o=>o===null?void 0:o.dispose(),o=>{if(o?.code!=="CANCELLED")throw o}).then(()=>{this.disposed||this.#n!==r||(this.#n=null,e.setAttr({...ne(t),recording:!1},!0,!0,!1))}).catch(o=>{!this.disposed&&this.#n===r&&(r.phase="failed",e.setAttr(ne(o),!0,!0,!1))}))}#v(e,t){if(this.#t)return;let r=new AbortController;this.#t=r;let o=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 i;if(t==="copy"){if(typeof o!="string")throw new TypeError("Clipboard text must be a string");await this.provider.copyText(o,r.signal),i={text:o}}else i=await this.provider.pasteText(r.signal);if(r.signal.aborted)return;if(typeof i?.text!="string")throw new TypeError("Invalid clipboard text from device provider");let a=new x;a.setItem("text",i.text),e.setValue(a,!0,{status:"success",error:null},!0,!1)}).catch(i=>{r.signal.aborted||e.setAttr(ne(i),!0,!0,!1)}).finally(()=>{this.#t===r&&(this.#t=null)})}#E(e){if(this.#a)return;let t=new AbortController;this.#a=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 o=new x;o.setItem("duration",r),o.setItem("acknowledged",!0),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(o=>{t.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#a===t&&(this.#a=null)})}#k(e){if(this.#a)return;let t=new AbortController;this.#a=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 o=new x;o.setItem("style",r),o.setItem("acknowledged",!0),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(o=>{t.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#a===t&&(this.#a=null)})}#S(e){if(this.#o)return;let t=new AbortController;this.#o=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 o=new x;o.setItem("text",r.text),o.setItem("format",r.format),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setAttr(ne(r),!0,!0,!1)}).finally(()=>{this.#o===t&&(this.#o=null)})}#T(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(o=>{if(r.signal.aborted)return;if(typeof o?.url!="string"||!o.url||typeof o.format!="string"||!o.format)throw new TypeError("Invalid camera photo from device provider");let i=new x;i.setItem("url",o.url),i.setItem("format",o.format),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(o=>{r.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#r===r&&(this.#r=null)})}#C(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,ne(r),!0,!1)}).finally(()=>{this.#l===t&&(this.#l=null)})}#A(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 o=new x;for(let i of["id","title","body"])o.setItem(i,r[i]);r.kind==="action"&&o.setItem("actionId",r.actionId),e.staticValue.setItem(r.kind,o)}catch(o){e.setAttr({listenerError:ne(o).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 o=t.controller.signal.aborted;t.controller.abort(),this.#u===t&&(this.#u=null),o||e.setAttr({listening:!1,listenerError:ne(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"),o=r instanceof x?Object.fromEntries(["id","title","body","delay"].map(i=>[i,r.getItem(i)])):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"),!o||!Number.isInteger(o.id)||o.id<1||o.id>2147483647||typeof o.title!="string"||!o.title.trim()||typeof o.body!="string"||!o.body.trim()||typeof o.delay!="number"||!Number.isFinite(o.delay)||o.delay<=0)throw new TypeError("Notification requires a positive 32-bit id, title, body and positive delay in seconds");if(await this.#A(e),!t.signal.aborted)return this.provider.scheduleNotification(o,t.signal)}}).then(i=>{if(t.signal.aborted)return;if(i?.id!==o.id||typeof i.at!="number"||!Number.isFinite(i.at))throw new TypeError("Invalid notification scheduling acknowledgement");let a=new x;a.setItem("id",i.id),a.setItem("at",i.at),e.staticValue.setItem("scheduled",a),e.setAttr({status:"success",error:null},!0,!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(ne(i),!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(ne(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 o=new x;for(let i of r){if(typeof t[i]!="string")throw new TypeError(`Invalid push event ${i}`);o.setItem(i,t[i])}e.staticValue.setItem(t.kind,o)}}#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(o){e.setAttr({listenerError:ne(o).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 o=t.controller.signal.aborted;t.controller.abort(),this.#f===t&&(this.#f=null),o||e.setAttr({listening:!1,listenerError:ne(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(ne({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(ne(r),!0,!0,!1))})}#R(e){let t={controller:new AbortController};this.#p=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startShortcutEvents((r,o=null)=>{if(!t.controller.signal.aborted)try{if(o)throw o;for(let a of["id","destination"])if(typeof r?.[a]!="string"||!r[a])throw new TypeError(`Invalid shortcut request ${a}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let i=new x;i.setItem("id",r.id),i.setItem("destination",r.destination),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",i)}catch(i){e.setAttr({listenerError:ne(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 o=t.controller.signal.aborted;t.controller.abort(),o||e.setAttr({listening:!1,listenerError:ne(r).error},!0,!0,!1)})}#B(e){let t={controller:new AbortController};this.#h=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startLinkEvents((r,o=null)=>{if(!t.controller.signal.aborted)try{if(o)throw o;for(let a of["id","url"])if(typeof r?.[a]!="string"||!r[a])throw new TypeError(`Invalid link request ${a}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let i=new x;i.setItem("id",r.id),i.setItem("url",r.url),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",i)}catch(i){e.setAttr({listenerError:ne(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 o=t.controller.signal.aborted;t.controller.abort(),o||e.setAttr({listening:!1,listenerError:ne(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"],o=e.name==="appinfo"?"string":"number";for(let l of r)if(typeof t[l]!==o||o==="number"&&!Number.isFinite(t[l]))throw new TypeError(`Invalid ${e.name}.${l} from device provider`);let i=e.cachedValue;if(e.name==="location"&&i&&t.timestamp<i.getItem("timestamp")){this.attributes(e,{status:"success",error:null});return}let a=new x;for(let l of r)a.setItem(l,t[l]);e._lastUpdate=Date.now(),e.failed=!1,e.received++;let s=e.writing;e.writing=!0;try{e._node.setValue(a,!0,{status:"success",error:null},!0,!1)}finally{e.writing=s}}failure(e,t){e.failed=!0,this.attributes(e,ne(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,o)=>{if(!(this.disposed||this.monitor!==t))if(o)this.failure(e,o);else try{this.accept(e,r)}catch(i){this.failure(e,i)}},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=(i,a=null)=>{this.disposed||t.setAttr({status:i,error:a},!0,!0,!1)};if(!this.provider.capabilities.includes("database")){let i=Object.assign(new Error("Native database unavailable"),{code:"UNAVAILABLE"});throw r("unavailable",{code:i.code,message:i.message}),i}let o={controller:new AbortController,close:null,start:null};this.#e=o,r("pending"),o.start=this.provider.openDatabase(e,o.controller.signal);try{let i=await o.start,a=!1,s=null,l=()=>s||(a=!0,s=i.close().then(()=>{r("closed")},c=>{throw r("error",{code:"FAILED",message:c.message}),c}).finally(()=>{this.#e===o&&(this.#e=null)}),s);if(o.close=l,this.disposed||o.controller.signal.aborted)throw await l(),Object.assign(new Error("Page closed"),{code:"CANCELLED"});let u=async(c,d,f)=>{if(this.assertLive(),a)throw new Error("Database connection is closed");r("pending");try{let h=await i[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(i){throw this.#e===o&&(this.#e=null),this.disposed||t.setAttr(ne(i),!0,!0,!1),i}}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.#s.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.#a?.abort(),this.#a=null;let o=[...this.#i.values()];this.#i.clear();for(let c of o)c.controller.abort();let i=this.#h;this.#h=null,i?.controller.abort();let a=this.#p;this.#p=null,a?.controller.abort(),this.#x()?.controller.abort();let s=this.#f;this.#f=null,s?.controller.abort(),this.#o?.abort(),this.#o=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(()=>{})),s&&(this.cleanup=Promise.all([this.cleanup,s.start.then(c=>c(),()=>{})]).then(()=>{})),i&&(this.cleanup=Promise.all([this.cleanup,i.start.then(c=>c(),()=>{})]).then(()=>{})),a&&(this.cleanup=Promise.all([this.cleanup,a.start.then(c=>c(),()=>{})]).then(()=>{})),this.cleanup=Promise.all([this.cleanup,...t,...o.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 Yp=2e3;function o2(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 $i=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=(o,i)=>{for(let a of o.getNodes()){let s=i+a.label;a.value instanceof x?r(a.value,`${s}.`):t.push(`${s}: ${o2(a.value)}`)}};return r(this.branch(e),""),t.join(`
|
|
203
|
-
`)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>
|
|
204
|
-
<${i}>${o.toXml()}</${i}>`,t,"application/xml")}}async copyText(e){if(typeof e!="string")throw new TypeError("gramlot.utl.inout.copyText: text must be a string");await this.document.defaultView.navigator.clipboard.writeText(e)}saveText(e,t,r){let o=this.document.defaultView,i=o.URL.createObjectURL(new o.Blob([e],{type:r}));this.open(i,t),o.setTimeout(()=>o.URL.revokeObjectURL(i),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var Mi=class extends Ke{constructor(e,t){super(e),this.inout=new $i(e,t)}};var Pi=class{#e;constructor({pageId:e,uploadUrl:t=null,rpcUrl:r="/gramlot/rpc",closeUrl:o="/gramlot/close",rootId:i="gramlot-root",capabilities:a=[],element:s=null,document:l=s?.ownerDocument??globalThis.document,transport:u=null,collections:c=[],locale:d=null,timeZone:f=null,devices:h=[],serverAdapter:m=new nr,nameSyntax:p=null,websocketUrl:w=null}={}){ss.register(l.defaultView);for(let _ of c)_ instanceof vr&&_.register(l.defaultView);this.commands=new Do,this.pageId=e,this.uploadUrl=t;let b=d==null||f==null?l.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...h]),this.locale=d??b.locale,this.timeZone=f??b.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Ls(this)}),this.capabilities=Object.freeze([...a]),this.serverAdapter=m,this.src=new Oi(this,{collections:c,destination:s??l.getElementById(i),subscriptions:this._subscriptions,nameSyntax:p===null?pi:nn.fromJSON(p)}),this.#e=Ao.install({document:l,root:this.src.renderer.destination}),this.data=this.src.builder.data,this.dvc=new Bi(this),this.dom=new Ri(this),this.utl=new Mi(this,l),this.state="ready",this.abort=new AbortController,Object.defineProperty(this,"_frames",{value:new Qa(this,l)}),w!==null&&(this._pageStore=new Ja(this,w,l)),this.rpc=new hi(this,{rpcUrl:r,closeUrl:o,document:l,transport:u}),this._frames.connect(),this.rpc.transport&&(this.pagehide=_=>{_.persisted||this.dispose()},l.defaultView.addEventListener("pagehide",this.pagehide),this.window=l.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 os(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 tc=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new nr}async run(){let{config:e,resources:t,document:r}=this,o=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let i=!1,a,s,l=[],u=new Promise(d=>{a=d}),c=d=>{if(!(d.persisted||i)){i=!0;try{this.closePage()}finally{a(null)}}};o.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((y,E)=>{let N=r.createElement("link");N.rel="stylesheet",N.href=_;let k=()=>{N.removeEventListener("load",C),N.removeEventListener("error",O)};l.push(k);let C=()=>{k(),y()},O=()=>{k(),E(new Error(`${_}: stylesheet load failed`))};N.addEventListener("load",C),N.addEventListener("error",O),r.head.append(N)})),f=t.js.map(async({url:_,group:y})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:y,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:y,url:E,buildId:N}=_,k;try{k=await import(new URL(E,r.baseURI).href)}catch(C){throw new Error(`${y}: collection import failed: ${C.message}`,{cause:C})}if(k.default?.name!==y||k.buildId!==N)throw new Error(`${y}: collection identity mismatch; expected ${N}, received ${k.buildId}`);return k.default}),p=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(m)]),u]);if(i)return null;let[,w,b]=p;mo.check(w);for(let _ of b)_.register(o);s=new Pi({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...b.map(_=>_.toDocument())]}),o.removeEventListener("pagehide",c);for(let _ of b)_.registerCommands(s);for(let{logicClass:_,group:y,resource:E}of w)s.src.logicRegistry.register(_,{group:y,resource:E});return o.gramlot=s,await s.start(),s}catch(d){throw s?s.dispose():i||this.closePage(),d}finally{for(let d of l)d();o.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"),qs=Symbol("gramlot.endpoint"),Li=Symbol("gramlot.upload"),i2=new Map([[js,"registerSource"],[qs,"registerEndpoint"],[Li,"registerUpload"]]);function rc(n,e,t,r){let o=i2.get(t);if(e==="main")throw new TypeError(`${o} cannot declare main`);let i=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof i!="function")throw new TypeError(`${o} requires an own method of ${n.name}: ${String(e)}`);if(i[t])throw new TypeError(`${t===js?"Source method":t===qs?"Endpoint":"Upload operation"} already registered: ${e}`);if([js,qs,Li].some(a=>i[a])){let a=t!==Li&&!i[Li]?`${e} is declared both as Source method and endpoint`:`${e} has conflicting declarations`;throw new TypeError(a)}i[t]={auth:r}}var Us=class{static registerSource(e,{auth:t=null}={}){rc(this,e,js,t)}static registerEndpoint(e,{auth:t=null}={}){rc(this,e,qs,t)}static registerUpload(e,{auth:t=null}={}){rc(this,e,Li,t)}},Fi=class extends Us{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=Ie;main(e){throw new Error("Page.main(root) must be implemented")}};var go=class extends Fi{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 o of["top","bottom","left","right","center"])if(this[o]!==void 0){let i=r.contentPane({region:o,node_label:o});this[o](i)}this.behavior(t)}center(e){}behavior(e){}};var ji=class extends go{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})}};ji.registerSource("index_panel");function nc(n,e,t=()=>{},r=()=>{},{state:o=e.getRelativeData("."),createEntry:i=null,onLoad:a=()=>{}}={}){let s=o.getItem("navigation");if(!(s 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=o.getItem("opened");for(let k of f.getNodes()){let{url:C,path:O,title:$}=k.attr,Z=l.value.getNode(k.label),W={url:C,path:O,title:$,pane:Z,node:s.getNode(O),loading:!1};r(W),c.set(C,W),d.sequence++}let h=(k,C,O)=>{try{a(k.url,C,O)}catch($){n.binding.reportError($,"Page load callback failed")}},m=(k,C,O)=>{k.loading&&(k.loading=!1,h(k,C,O))},p=k=>{if(!d.disposed){d.selecting=!0;try{o.setItem("active",k.url),o.setItem("navigationSelection",k.path),t(c,k.url)}finally{d.selecting=!1}}};function w(k){b(k).catch(C=>{d.disposed||n.binding.reportError(C,"Page could not be opened")})}async function b(k){let C=s.getNode(k);if(!C)throw new Error(`Unknown index navigation path: ${k}`);let O=C.attr.url;if(O==null)return;if(typeof O!="string"||!O)throw new TypeError("IndexPage URL must be nonempty text");d.requested=O;let $=c.get(O);if($){$.path=k,p($);return}for(;l.value!==null&&l.value.getNode(`page${d.sequence}`);)d.sequence++;let Z=ae(u.wrapSource(l).contentPane({node_label:`page${d.sequence++}`,title:C.attr.title??C.label,pageName:O,height:"100%",closable:!0})),W=o.getItem("active");$={url:O,path:k,node:C,pane:Z,title:C.attr.title??C.label,loading:!0},c.set(O,$);try{if(h($,"loading"),d.disposed||c.get(O)!==$||(p($),d.disposed||c.get(O)!==$))return;if(i)await i($);else{let ie=new x;if(ie.setItem(C.label,null,{...C.attr}),!await n.binding.gramlot.src.remoteSource(Z,"index_panel",{selection:ie}))throw new Error("Panel loading was cancelled")}if(d.disposed||c.get(O)!==$)return;f.setItem(Z.label,null,{url:O,path:$.path,title:$.title}),r($)}catch(ie){if(d.disposed||c.get(O)!==$)return;try{if(n.binding.reportError(ie,"Page could not be opened"),c.delete(O),f.getNode(Z.label)&&f.popNode(Z.label),Z.parentBag&&Z.parentBag.popNode(Z.label),!d.disposed&&d.requested===O){let he=c.get(W);if(d.requested=he?.url??null,he)p(he);else{d.selecting=!0;try{o.setItem("active",null),o.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}}finally{m($,"error",ie)}return}d.disposed||c.get(O)!==$||(m($,"ready"),!d.disposed&&c.get(O)===$&&d.requested===O&&p($))}let _=`${e.getAttr("id")}-page-close`;e.value.subscribe(_,{any:k=>{if(k.evt!=="del")return;let C=[...c.values()].find(Z=>Z.pane===k.node);if(!C)return;let{url:O,pane:$}=C;if(!(d.disposed||n.disposed||c.get(O)!==C)){c.delete(O),f.getNode($.label)&&f.popNode($.label);try{if(o.getItem("active")===O){let Z=[...c.values()].at(-1);if(d.requested=Z?.url??null,Z)p(Z);else{d.selecting=!0;try{o.setItem("active",null),o.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}else t(c,o.getItem("active"))}finally{m(C,"cancelled")}}}});let y=`${e.getAttr("id")}-selection`;o.subscribe(y,{any:k=>{if(!(d.selecting||d.disposed)){if(k.node===o.getNode("navigationSelection")){let C=o.getItem("navigationSelection");C!==null&&w(C)}else if(k.node===o.getNode("active")){let C=c.get(o.getItem("active"));C&&(d.requested=C.url,p(C))}}}});let E=()=>{if(!d.disposed){d.disposed=!0,o.unsubscribe(y,{any:!0}),e.value.unsubscribe(_,{any:!0});for(let k of c.values())k.loading&&(k.pane.parentBag&&k.pane.parentBag.popNode(k.pane.label),m(k,"cancelled"));c.clear(),e.indexContext===d&&delete e.indexContext}};d.dispose=E,n.onDispose(e,E);let N=c.get(o.getItem("active"));return N?p(N):o.getItem("navigationSelection")!==null&&w(o.getItem("navigationSelection")),d}var Vs=class{indexMount(e){nc(this.page.src.renderer,e.parentNode)}};function zs(n,{datapath:e,value:t,language:r="text",height:o="420px",...i}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let a=n.borderContainer({datapath:e,height:o,class:"gramlot-editor-options"}),s={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(s))a.dataSetter({destination_path:`.settings.${d}`,value:f});let l=a.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 a.contentPane({region:"center",min_height:0}).codeMirror({...i,value:t,height:"100%",...Object.fromEntries(Object.keys(s).map(d=>[d,`^.settings.${d}`]))}),a}var qi=class n extends Tt{static internalParams=new Set([...Tt.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:o}){super({cacheTime:-1,onError:o}),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:o}=e,i,a=new Promise((s,l)=>{i=()=>l(o.reason),o.addEventListener("abort",i,{once:!0})});try{let s=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:o}),a]);if(o.aborted)throw o.reason;return s}finally{o.removeEventListener("abort",i),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()}},Ui=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 o=new qi({gramlot:this.gramlot,root:r.root,onError:a=>this.state.setItem("status",a.message)}),i=o.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=o,this.state.setItem("selectedPath",null),this.state.setItem("store",i),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()}},gn=class{fileSystemMount(e){let t=e.parentNode,r=new Ui(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 Xp(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 a2=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Hs=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=a2(e,t),o=this.documents.getNodes().find(s=>!s.value.getItem("isNew")&&s.value.getItem("root")===e&&s.value.getItem("path")===t);if(o)return o.label;if(this.pending.has(r))return this.pending.get(r).promise;let i=new AbortController,a=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:i.signal}).then(s=>{if(this.disposed||i.signal.aborted)return null;let l=new x;for(let[u,c]of Object.entries({...s,root:e,saved:s.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:i,promise:a}),a}newDocument(e,t,r=""){let o=`new_${ee()}`,i=new x;for(let[a,s]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}`}))i.setItem(a,s);return this.documents.setItem(o,i),o}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"),o=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==o.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let i=t.getItem("content"),a=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_create",{root:r,path:o,content:i},{signal:a.signal}).then(l=>this.disposed||a.signal.aborted?!1:(t.setItem("root",l.root),t.setItem("path",l.path),t.setItem("revision",l.revision),t.setItem("saved",i),t.setItem("isNew",!1),t.setItem("createHidden",!0),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:a,promise:s}),s}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"),o=new AbortController;t.setItem("busy",!0),t.setItem("rendering",!0),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generating Typst on the server\u2026");let i=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:o.signal}).then(a=>this.disposed||o.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",a.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(a=>(!this.disposed&&!o.signal.aborted&&t.setItem("renderStatus",a.message),!1)).finally(()=>{this.pending.delete(e),this.disposed||(t.setItem("rendering",!1),t.setItem("busy",!1))});return this.pending.set(e,{request:o,promise:i}),i}dirty(e){let t=this.documents.getItem(e);return t&&t.getItem("content")!==t.getItem("saved")}async save(e){let t=this.documents.getItem(e);if(!t||t.getItem("isNew")||!this.dirty(e)||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let i=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:o.signal}).then(a=>this.disposed||o.signal.aborted?!1:(t.setItem("revision",a.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:o,promise:i}),i}revert(e){let t=this.documents.getItem(e);return!t||!this.dirty(e)||this.pending.has(e)?!1:(t.setItem("content",t.getItem("saved")),!0)}canClose(e,t=!1){return!this.pending.has(e)&&(t||!this.dirty(e))}close(e,t=!1){return this.canClose(e,t)?(this.documents.popNode(e),this.state.getItem("active")===e&&this.state.setItem("active",this.documents.getNodes()[0]?.label??null),!0):!1}dispose(){this.disposed=!0;for(let{request:e}of this.pending.values())e.abort()}},Gs=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,o)=>t.setItem(`r${o}`,r,{caption:r})),t}};function ut(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 Ws=class{fileSystemMount(e){return gn.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return gn.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){let t=e.parentNode,r={scope:t,documents:new Hs(this.page,t),requested:0,editorPrefix:`ide_${ee()}`,recent:new Gs(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage)};Object.defineProperty(t,"ideContext",{value:r,configurable:!0});let{documents:o,recent:i}=r,a=t.getRelativeData("."),s=i.read();a.setItem("recent",i.choices(s)),a.setItem("workspace",s[0]??"");let l=a.getItem("browser");l.subscribe("ide-browser",{any:c=>{if(c.node===l.getNode("root")){let d=l.getItem("root");a.setItem("workspace",d),a.setItem("recent",i.choices(i.remember(d))),a.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=o.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=o.documents.getItem(f);h&&(c.node===h.getNode("content")&&o.invalidateRecipe(f),this.ideDocumentState(t,f),d.setAttr({title:`${o.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}),o.dispose()})}ideOpenWorkspace(e){let r=ut(e).scope.getRelativeData("."),o=r.getItem("workspace");o&&o!==r.getItem("browser.root")&&r.setItem("browser.requestedRoot",o)}ideDocumentState(e,t){let r=ut(e),{documents:o}=r,i=o.documents.getItem(t),a=!o.dirty(t)&&!i.getItem("isNew")||i.getItem("busy");i.setItem("saveDisabled",!!(a||!i.getItem("writable"))),i.setItem("revertDisabled",!!(!o.dirty(t)||i.getItem("busy"))),i.setItem("displayPath",i.getItem("isNew")?i.getItem("path"):`${i.getItem("root")}/${i.getItem("path")}`),i.setItem("pdfFilename",i.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),i.setItem("renderDisabled",!!(i.getItem("busy")||!i.getItem("writable"))),this.ideHistoryState(i)}async ideOpenDocument(e,t,r){let o=ut(e),{documents:i}=o,a=o.scope.getRelativeData("."),s=++o.requested;try{let l=await i.open(t,r);if(l===null||i.disposed)return;this.ideShowDocument(e,l),s===o.requested&&(a.setItem("active",l),a.setItem("status",`${r}${i.documents.getItem(l).getItem("writable")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}catch(l){i.disposed||a.setItem("status",l.message)}}ideNew(e){let t=ut(e),{documents:r}=t,o=t.scope.getRelativeData("."),i=o.getItem("newType"),a=i==="typstRecipe"?"python":i,s={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(a,s[i],o.getItem("workspace"));r.documents.getItem(l).setItem("writable",o.getItem("browser.writable")===!0),++t.requested,this.ideShowDocument(e,l),o.setItem("active",l),o.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e,t){let r=ut(e),{documents:o}=r,a=o.documents.getItem(t).getItem("path"),s=r.scope.value.getNode("frame.center.tabs");if(!s.value?.getNode(t)){let l=o.documents.getItem(t),u=a.endsWith(".typ.py");u&&o.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=ae(s.builder.wrapSource(s).contentPane({node_label:t,title:a,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 ${a}`});for(let[k,C,O,$]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 Z=f.button({title:O,"aria-label":O,disabled:`^.${k}Disabled`,class:`button--quiet gramlot-ide-${k}`});Z.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:C}),Z.dataController({func:$,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",w=l.getItem("language")==="markdown",b=p||w,_=l.getItem("language")==="typst",y=b||_||u,E=y?m.tabContainer({height:"100%",selectedPage:`^.documents.${t}.view`}):null,N=y?E.contentPane({title:"Code",pageName:"code",height:"100%"}):m;if(zs(N,{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 k=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});k.div(`^.documents.${t}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),k.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(b){let k=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});w&&(l.setItem("allowHtml",!1),k.checkbox({value:`^.documents.${t}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),k[p?"htmlPreview":"markdownPreview"]({value:`^.documents.${t}.content`,flex:"1",min_height:0,...w?{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=ut(e),{documents:o}=r;o.documents.getItem(t).setItem("view","preview"),await o.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){let r=ut(e),{documents:o}=r;o.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData(".");i.setItem("status","Creating file\u2026");try{let a=await o.create(t);if(!o.disposed&&a){i.setItem("status","File created.");let s=i.getItem("browser");s.getItem("root")&&await r.scope.value.getNode("frame.left.browser").fileSystemController.open(s.getItem("root"))}}catch(a){o.disposed||i.setItem("status",a.message)}}async ideSave(e,{documentKey:t=null}={}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData("."),a=t??i.getItem("active");if(!a||o.documents.getItem(a).getItem("saveDisabled"))return;let s=o.documents.getItem(a);if(s.getItem("isNew")){s.setItem("createHidden",!1);return}i.setItem("status","Saving\u2026");try{let l=await o.save(a);o.disposed||i.setItem("status",l?"Saved.":"Document is read only or a request is pending.")}catch(l){o.disposed||i.setItem("status",l.message)}}ideRevert(e,{documentKey:t}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData(".");o.revert(t)&&i.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let o=e.getRelativeData("."),i=e.getAttr("editorView");o.setItem(`${i}CanUndo`,t),o.setItem(`${i}CanRedo`,r),this.ideHistoryState(o)}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=ut(e),{documents:o}=r,i=o.documents.getItem(t).getItem("view")==="rich",a=this.page.src.binding.nodeIds.get(`${r.editorPrefix}_${i?"rich_":""}editor_${t}`);return this.page.src.renderer.records.get(a).element}ideUndo(e,{documentKey:t}){this.ideEditor(e,t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(e,t).redo()}ideClose(e){let t=ut(e),{documents:r}=t,o=t.scope.getRelativeData("."),i=e.getAttr("documentKey");return r.canClose(i)?!0:(o.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 o=ut(e),{documents:i}=o,a=o.scope.getRelativeData("."),s=i.documents.getItem(t),l=a.getItem("browser"),u=l.getItem("selectedPath"),c=u===null?null:l.getItem("store").getNode(u);s&&l.getItem("root")===s.getItem("root")&&c?.attr.path===s.getItem("path")&&l.setItem("selectedPath",null),i.close(t,r)}};var Nr=class extends ce{constructor({readOnly:e=!1}={}){super({cacheTime:-1,readOnly:e}),this.store=null,this.path=null,this.pending=null}bind(e,t){if(this.store!==null)throw new Error("TreeStoreResolver is already bound");this.store=e,this.path=t}load(){if(this.store===null)throw new Error("TreeStoreResolver is not bound to a store");if(this.pending!==null)return this.pending;let e=this.node,t=this.path?this.store.pathFor(e):"",r=this.store.load(t,t?e.label:null,t?{...e.attr}:{});return this.pending=r,r.finally(()=>{this.pending===r&&(this.pending=null)}).catch(()=>{}),r}};Tu(Nr,{module:"gramlot.tree_store",name:"TreeStoreResolver",encode:()=>({args:[],kwargs:{}}),decode:()=>new Nr});var Vi=class{constructor({gramlot:e,method:t,params:r={}}){if(!e||typeof t!="string"||!t)throw new TypeError("TreeStore requires a page and method");for(let o of["path","label","attributes"])if(Object.hasOwn(r,o))throw new TypeError(`TreeStore params reserves ${o}`);this.gramlot=e,this.method=t,this.params={...r},this.controller=new AbortController,this.root=null}pathFor(e){let t=[];for(;e&&e.parentBag!==this.root;)t.unshift(e.label),e=e.parentNode;if(!e||this.root===null)throw new Error("TreeStore node is outside its root");return t.unshift(e.label),t.join(".")}async load(e="",t=null,r={}){if(this.controller.signal.aborted)throw this.controller.signal.reason;let o=await this.gramlot.rpc.call("data",this.method,{...this.params,path:e,label:t,attributes:r},{signal:this.controller.signal});if(this.controller.signal.aborted)throw this.controller.signal.reason;if(!(o instanceof x))throw new TypeError("TreeStore method must return a Bag");e||(this.root=o,o.setBackref());let i=(a,s)=>{for(let l of a.getNodes()){let u=s?`${s}.${l.label}`:l.label;l.resolver instanceof Nr&&l.resolver.bind(this,u),l.staticValue instanceof x&&i(l.staticValue,u)}};return i(o,e),o}dispose(){this.controller.abort()}},Ys=class{treeFavoriteActionState(e,{item:t,state:r}){let o=t.resolver!==null||t.staticValue instanceof x;if(t.getAttr("favoriteEntry")===!0)return{hidden:!1,icon:"\u2715",title:"Remove favorite"};let i=!o&&r.getNodes().some(a=>a.getAttr("fieldpath")===t.getAttr("fieldpath"));return{hidden:o,icon:i?"\u2665":"\u2661",title:i?"Remove favorite":"Add favorite"}}treeFavoritesMount(e,{favoriteKey:t}){let o=this.page.src.renderer.destination.ownerDocument.defaultView.localStorage.getItem(t);this.setTreeFavorites(e.getRelativeData("."),o===null?[]:j(o))}setTreeFavorites(e,t){if(!Array.isArray(t))throw new TypeError("Tree favorites must be an array");let r=new x;t.forEach((o,i)=>{if(!o||typeof o.fieldpath!="string"||typeof o.path!="string"||typeof o.caption!="string"||!o.attrs||typeof o.attrs!="object")throw new TypeError("Invalid tree favorite");let a={...o.attrs};for(let s of["caption","fullcaption"])typeof a[s]=="string"&&(a[s]=a[s].replace(/(^|\.)!!(?:\[[^\]]+\])?/g,"$1"));r.setItem(`favorite_${i}`,null,{...a,favoriteEntry:!0,originalPath:o.path})}),e.setItem("favorites",r)}treeFavoriteToggle(e,{item:t,path:r,favoriteKey:o}){if(t.resolver||t.staticValue instanceof x)return;let i=t.getAttr(),a=e.getRelativeData("."),s=a.getItem("favorites").getNodes().map(c=>{let{favoriteEntry:d,originalPath:f,...h}=c.getAttr();return{fieldpath:h.fieldpath,path:f,caption:h.caption,attrs:h}}),l=s.findIndex(c=>c.fieldpath===i.fieldpath);l===-1?s.push({fieldpath:i.fieldpath,path:r,caption:i.caption,attrs:{...i}}):s.splice(l,1),this.page.src.renderer.destination.ownerDocument.defaultView.localStorage.setItem(o,F(s)),this.setTreeFavorites(a,s)}treeStoreMount(e,{storeMethod:t,storeParams:r}){let o=e.parentNode,i=e.getRelativeData("."),a=new Vi({gramlot:this.page,method:t,params:r});this.page.src.renderer.onDispose(o,()=>a.dispose());let s=new Nr({readOnly:!0});return s.bind(a,""),i.setResolver("store",s),Promise.resolve(i.getItem("store")).then(l=>{a.controller.signal.aborted||i.setItem("store",l)})}treeInspect(e,{item:t,path:r}){let o=this.page.src.binding.bindingFor(e),i=!1,a=`tree_inspect_${ee()}`,s=()=>{},l=()=>{i||(i=!0,s(),this.page.src.source.getNode(a)&&this.page.src.source.popNode(a))};s=o.track(l);try{let u=new Ie,c=u.root.html_dialog({nodeId:a,request:a,connect_oncancel:"treeInspectClose",connect_onclose:"treeInspectClose","aria-labelledby":`${a}_title`,style:"width:min(36rem,calc(100% - 48px));max-height:80vh;overflow:auto;"});c.h2("Attributes",{id:`${a}_title`}),c.p(`==${JSON.stringify(r)}`),c.html_button("Close",{type:"button",autofocus:!0,request:a,connect_onclick:"treeInspectClose"});let d=c.table();for(let[h,m]of Object.entries(t.getAttr())){let p=d.tr();p.th(`==${JSON.stringify(h)}`,{scope:"row"});let w=typeof m=="string"?m:m===void 0?"undefined":F(m);p.td(`==${JSON.stringify(w)}`)}this.page.src.source.setItem(a,this.page.src.prepareSource(u.source));let f=this.page.src.binding.nodeIds.get(a);Object.defineProperty(f,"treeInspectClose",{value:l,configurable:!0}),this.page.src.renderer.onDispose(f,()=>{l(),delete f.treeInspectClose}),this.page.dom.getDomNode(f).showModal()}catch(u){throw l(),u}}treeInspectClose(e,t){t.preventDefault();let r=this.page.src.binding.nodeIds.get(e.getAttr("request"));r&&r.treeInspectClose()}};var bo=class{constructor({maxBytes:e}){if(!Number.isSafeInteger(e)||e<0)throw new TypeError("maxBytes must be a nonnegative safe integer");this.maxBytes=e}write(e){throw new Error("UploadTarget.write must be implemented")}finish(){throw new Error("UploadTarget.finish must be implemented")}abort(){throw new Error("UploadTarget.abort must be implemented")}status(){throw new Error("UploadTarget.status must be implemented")}};var He={navigation:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M9%204v16M5.5%208h1M5.5%2012h1%22%2F%3E%3C%2Fsvg%3E",catalogue:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2214%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M14%2017.5h7M17.5%2014v7%22%2F%3E%3C%2Fsvg%3E",properties:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3Ccircle%20cx%3D%228%22%20cy%3D%226%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2212%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2218%22%20r%3D%222%22%2F%3E%3C%2Fsvg%3E",new:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%202H6a2%202%200%200%200-2%202v16a2%202%200%200%200%202%202h12a2%202%200%200%200%202-2V8Z%20M14%202v6h6%20M8%2015h8%20M12%2011v8%22%2F%3E%3C%2Fsvg%3E",download:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5%20M4%2016v4a1%201%200%200%200%201%201h14a1%201%200%200%200%201-1v-4%22%2F%3E%3C%2Fsvg%3E",copy:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%228%22%20y%3D%228%22%20width%3D%2212%22%20height%3D%2213%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M16%208V5a2%202%200%200%200-2-2H5a2%202%200%200%200-2%202v9a2%202%200%200%200%202%202h3%22%2F%3E%3C%2Fsvg%3E"};He.open="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207V5a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v2M3%209h18l-2%2011H4z%22%2F%3E%3C%2Fsvg%3E";He.cut="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%226%22%20cy%3D%226%22%20r%3D%223%22%2F%3E%3Ccircle%20cx%3D%226%22%20cy%3D%2218%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22m8%208%2012%2012M8%2016%2020%204%22%2F%3E%3C%2Fsvg%3E";He.paste="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%225%22%20y%3D%225%22%20width%3D%2214%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%222%22%20width%3D%226%22%20height%3D%225%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M9%2012h6m-6%204h6%22%2F%3E%3C%2Fsvg%3E";He.appearance="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%228%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%2F%3E%3Cpath%20d%3D%22M12%204a8%208%200%200%201%200%2016z%22%20fill%3D%22black%22%2F%3E%3C%2Fsvg%3E";var Xs=class{constructor(e,{datapath:t="__editor",dataRoot:r="",editorId:o="visual",uploadOperation:i="import_source",codeDocument:a=null,...s}={}){if(!/^[A-Za-z][A-Za-z0-9_]*$/.test(o))throw new Error("editorId must be a literal identifier");if(!r&&t!=="__editor"&&!t.startsWith("__editor."))throw new Error("Root Data editing requires an __editor datapath");this.dataRoot=r;let l=this.pane=e.main({node_label:o,datapath:t,visualEditorId:o,...s,nodeId:`${o}Editor`,class:`visual-editor-shell ${s.class??""}`,overflow:"hidden",tabindex:0,connect_onkeydown:"clipboardShortcut"});l.dataSetter({destination_path:".uploadQueue",value:new x}),l.dataController({func:"initializeEditor",dataRoot:this.dataRoot,_init:!0}),l.dataController({func:"showProperties",path:"^.selection",_init:!0}),l.dataController({func:"initializeCanvasSelection",_onBuilt:!0}),l.dataController({func:"highlightSelection",path:"^.selection",_init:!0}),l.style("^.appearanceCss"),l.dataController({func:"initializeEditorAppearance",_onBuilt:!0}),l.dataController({func:"applyEditorAppearance",profile:"^.appearanceProfile",palette:"^.appearancePalette",mode:"^.appearanceMode"});let u=this.rail=l.menu({presentation:"bar",orientation:"vertical",aria_label:"Editor panels",class:"visual-editor-rail"});this.toolButton(u.menuline({group:!0,overflowable:!1}),"Source / Data","toggleNavigation",He.navigation),this.toolButton(u.menuline({group:!0,overflowable:!1}),"Catalogue","openCatalogue",He.catalogue),this.toolButton(u.menuline({group:!0,overflowable:!1}),"Properties","openProperties",He.properties),this.toolButton(u.menuline({group:!0,overflowable:!1}),"Clipboard","this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))",He.paste),u.spacer({flex:1}),this.toolButton(u.menuline({group:!0,overflowable:!1}),"Appearance","this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))",He.appearance);let c=l.framePane({node_label:"layout",height:"100%",id:`${o}-editor-frame`,class:"visual-editor-layout"});c.top.setAttr({height:"38px"});let d=c.top.menu({presentation:"bar",aria_label:"Editor tools",class:"visual-editor-toolbar"});d.menuline({group:!0,overflowable:!1}).span("Source editor",{class:"visual-editor-brand"});let f=d.menuline({group:!0,overflowable:!1,gap:"4px"});for(let[vo,Rr,At]of[["New","newPage","new"],["Open","openUpload","open"],["Download","downloadPage","download"],["Copy Source","copySource","copy"]])this.toolButton(f,vo,Rr,He[At],{id:`${o}-${At}`});d.menuline({group:!0,overflowable:!1}).span({class:"visual-toolbar-divider",aria_hidden:"true"});let h=d.menuline({group:!0,overflowable:!1,gap:"2px"});this.toolButton(h,"Cut branch","cutBranch",He.cut,{title:"Cut branch (F8)"}),this.toolButton(h,"Copy branch","copyBranch",He.copy),this.toolButton(h,"Paste branch","pasteBranch",He.paste,{title:"Paste branch (F9)"}),d.spacer({flex:1}),d.menuline({group:!0,overflowable:!1}).span("^.fileStatus",{role:"status",class:"visual-editor-file-status"}),d.menuline({group:!0,overflowable:!1}).span("^.filename",{class:"visual-editor-filename"});let m=c.left;m.setAttr({width:"min(260px, 34vw)",splitter:!0,drawer:"^.navigationOpen",default_drawer:!0,drawer_label:"Source / Data",drawer_onclick:"this.SET('.navigationOpen', show ? true : 'close')",display:"flex",flex_direction:"column",min_height:0,class:"visual-editor-sidebar"});let p=m.borderContainer({height:"100%",flex:1,min_height:0}),w=p.contentPane({region:"center"}).borderContainer({height:"100%",min_height:0}),b=w.contentPane({region:"center"}).borderContainer({height:"100%",min_height:0}),_=b.contentPane({node_label:"source",region:"center",title:"Source",detachable:!0,display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"});this.search(_,"sourceSearch","Search Source"),_.tree({storepath:`*S.${ae(l).fullpath.split(".").slice(1).join(".")}.layout.center.design`,hideValues:!0,getLabel:"sourceLabel",searchText:"^.sourceSearch",selectedPath:"^.selection",draggable:!0,dragTags:`${o}Source`,effectAllowed:"all",onDrag:"prepareSource",dropTarget:!0,dropTypes:"app/widget,app/source,app/clipboard",dropTags:`widget,${o}Source,${o}Clipboard`,dropEffect:"^.sourceDropEffect",onDrop:"dropNode",id:`${o}-source-tree`,class:"visual-source-tree",flex:1,min_height:0});let y=b.contentPane({node_label:"clipboard",region:"bottom",height:"112px",splitter:!0,minSize:80,title:"Clipboard",detachable:!0,hidden:"^.clipboardVisible:=!{}",display:"flex",flex_direction:"column",min_height:0,overflow:"hidden",dropTarget:!0,dropTypes:"app/source",dropTags:`${o}Source`,dropEffect:"^.clipboardDropEffect",connect_ondragover:"clipboardModifiers",connect_ondrop:"clipboardModifiers",onDrop:"dropClipboard",class:"visual-clipboard"});y.span("Drop a branch here \xB7 Option to copy",{class:"visual-editor-hint"}),y.tree({storepath:".clipboard",hideValues:!0,labelAttribute:"name",selectedPath:"^.clipboardSelection",draggable:!0,dragTags:`${o}Clipboard`,effectAllowed:"copy",onDrag:"prepareClipboard",id:`${o}-clipboard-tree`,class:"visual-clipboard-tree",flex:1,min_height:0}),y.p("^.error",{role:"alert",class:"visual-editor-hint"});let E=w.contentPane({node_label:"data",region:"bottom",title:"Data",detachable:!0,height:"108px",splitter:!0,minSize:80,display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"});this.search(E,"dataSearch","Search Data"),E.tree({storepath:this.dataRoot?`*D.${this.dataRoot}`:"*D",excludeRoot:this.dataRoot?null:"__editor",searchText:"^.dataSearch",id:`${o}-data-tree`,flex:1,min_height:0});let N=c.center;N.setAttr({overflow:"auto",class:"visual-editor-workspace"});let k=N.div({node_label:"design",class:"visual-editor-canvas"});k.div({node_label:"pageRoot",...this.dataRoot?{datapath:this.dataRoot}:{}});let C=l.floatingPane({title:"Widget catalogue",open:"^.catalogueOpen",default_open:!1,width:"320px",height:"480px",movable:!0,resizable:!0});this.search(C.frame.top,"catalogueSearch","Search widgets"),C.frame.center.tree({storepath:".catalogue",hideValues:!0,labelAttribute:"caption",searchText:"^.catalogueSearch",draggable:!0,dragTags:"widget",effectAllowed:"all",onDrag:"prepareWidget",id:`${o}-widget-tree`});let O=p.contentPane({region:"bottom",height:"^.propertiesHeight",default_height:"240px",minSize:140,splitter:!0,title:"^.propertiesTitle",detachable:!0,hidden:"^.propertiesOpen:=!{}",display:"flex",flex_direction:"column",overflow:"hidden",min_height:0});O.div({nodeId:`${o}EditorFields`,class:"visual-editor-fields",display:"flex",flex_direction:"column",flex:1,min_height:0}).span(""),O.p("^.propertyError",{role:"alert",class:"visual-editor-hint",margin:"8px"}),l.dialog({title:"Open Source",open:"^.uploadOpen",width:"480px",height:"300px",movable:!0,resizable:!0}).frame.center.uploader({operation:i,storepath:".uploadQueue",accept:".grmlt",multiple:!1,autoUpload:!0,onComplete:"sourceUploaded",id:`${o}-uploader`});let Z=l.dialog({title:"Save branch to clipboard",open:"^.clipboardOpen",width:"380px",height:"210px"});Z.frame.center.textbox({value:"^.clipboardDraft.name",lbl:"Name",margin:"12px"}),Z.frame.center.p("^.error",{role:"alert",margin:"12px"});let W=Z.frame.bottom.menu({presentation:"bar",aria_label:"Clipboard commands",padding:"8px 12px"});W.spacer({flex:1});let ie=W.menuline({group:!0,overflowable:!1,gap:"8px"});ie.button("Cancel",{action:"this.SET('.clipboardOpen', false)"}),ie.button("Save branch",{action:"saveClipboard"});let he=l.dialog({title:"Required parameters",open:"^.insertionOpen",width:"400px",height:"280px",movable:!0,resizable:!0});he.frame.center.div({nodeId:`${o}InsertFields`,class:"visual-editor-fields",padding:"12px"}).span(""),he.frame.center.p("^.error",{role:"alert"});let te=he.frame.bottom.menu({presentation:"bar",aria_label:"Insertion commands",padding:"8px 12px",border_top:"1px solid var(--gramlot-border)"});te.spacer({flex:1});let se=te.menuline({group:!0,overflowable:!1,gap:"8px"});se.button("Cancel",{action:"this.SET('.insertionOpen', false)"}),se.button("Insert",{action:"insertWidget"});let at=l.floatingPane({title:"Appearance",open:"^.appearanceOpen",default_open:!1,width:"280px",height:"260px",movable:!0,resizable:!0}).frame.center.formlet({columns:1,lbl_position:"TL",gap:"10px",padding:"12px"});at.filteringSelect({validate_notnull:!0,lbl:"Theme",value:"^.appearanceProfile",values:"base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela"}),at.filteringSelect({validate_notnull:!0,lbl:"Colors",value:"^.appearancePalette",values:"default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue"}),at.filteringSelect({validate_notnull:!0,lbl:"Mode",value:"^.appearanceMode",values:"light:Light,dark:Dark"}),l.p("^.error",{role:"alert",class:"visual-editor-error",hidden:"^.error:=!{}"}),this.frame=c,this.toolbar=d,this.design=k,a!==null&&this.codeDocument(a)}toolButton(e,t,r,o,i={}){let a=e.button({aria_label:t,title:t,action:r,class:"button--quiet visual-editor-tool",...i});return a.span({class:"visual-tool-icon",aria_hidden:"true",style:`mask-image:url("${o}")`}),a}codeDocument(e,t=this.frame){if(!["python","javascript"].includes(e.language))throw new TypeError("Expected a Python or JavaScript page document");let r=this.pane;r.setAttr({codeDocumentKey:e.key}),r.dataSetter({destination_path:".codeDocument",value:new x({...e,saved:e.content,busy:!1,status:""})});let o=`#${r.getAttr("visualEditorId")}Editor`;(t===this.frame?this.toolbar:t.top.menu({presentation:"bar",aria_label:"Code drawer"})).menuline({group:!0,overflowable:!1}).button("Code",{action:"openCode",class:"button--quiet"});let a=t.right;a.setAttr({datapath:o,title:"Page code",detachable:!0,width:"60%",minSize:240,splitter:!0,drawer:"^.codeOpen",default_drawer:"close",drawer_label:"Code",drawer_minimize:!1,drawer_onclick:"this.SET('.codeOpen', show ? true : 'close')",min_height:0,overflow:"hidden"});let s=a.framePane({height:"100%",width:"100%",min_width:0,flex:1});s.top.setAttr({height:"32px"}),s.bottom.setAttr({height:"58px"}),s.center.setAttr({display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"}),s.top.div(e.path,{padding:"8px 12px",font_size:"12px",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap"}),s.center.codeMirror({value:"^.codeDocument.content",language:e.language,live:!0,readonly:"^.codeDocument.writable:=!{}",height:"100%",box_height:"100%",box_c_height:"100%",box_min_height:0,box_c_min_height:0,fontSize:13,flex:1,min_height:0}),s.bottom.div("^.codeDocument.status",{role:"status",font_size:"12px",padding:"4px 10px"});let l=s.bottom.menu({presentation:"bar",aria_label:"Page code commands",padding:"6px 10px"});l.spacer({flex:1});let u=l.menuline({group:!0,overflowable:!1,gap:"6px"});u.button("Close",{action:"this.SET('.codeOpen', 'close')"}),u.button("Preview saved",{action:"codePreview",disabled:"^.codeDocument.busy"}),u.button("Save",{action:"codeSave",disabled:"^.codeSaveDisabled"}),r.dataFormula({result_path:".codeSaveDisabled",formula:"!writable || busy || content === saved",writable:"^.codeDocument.writable",busy:"^.codeDocument.busy",content:"^.codeDocument.content",saved:"^.codeDocument.saved",_init:!0})}search(e,t,r){let i=e.menu({presentation:"bar",aria_label:r,class:"visual-search-toolbar"}).menuline({group:!0,overflowable:!1,flex:1,min_width:0}).div({class:"visual-search-field"});i.span({class:"visual-search-icon",aria_hidden:"true"}),i.input({type:"search",value:`^.${t}`,default:"",live:!0,placeholder:r,aria_label:r}),i.html_button({type:"button",class:"visual-search-clear",aria_label:`Clear ${r.toLowerCase()}`,hidden:`^.${t}:={} === ''`,connect_onclick:`this.SET('.${t}', '')`})}};var Zs=class extends bo{constructor(){super({maxBytes:5*1024*1024}),this.decoder=new TextDecoder("utf-8",{fatal:!0}),this.parts=[],this.outcome={state:"pending"}}write(e){this.parts.push(this.decoder.decode(e,{stream:!0}))}finish(){this.parts.push(this.decoder.decode());let e=this.parts.join("");this.parts=[];let t=j(e);if(!(t instanceof I)||t.length!==1||t.getNodes()[0].label!=="pageRoot")throw new TypeError("Expected one pageRoot Source");return this.outcome={state:"completed",result:e},this.outcome}abort(){return this.outcome.state!=="completed"&&(this.parts=[],this.outcome={state:"unsaved"}),this.outcome}status(){return this.outcome}};function s2(n,e){this.v=n,this.k=e}function Zp(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t<e;t++)r[t]=n[t];return r}function l2(n){if(Array.isArray(n))return n}function u2(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,o,i,a,s=[],l=!0,u=!1;try{if(i=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=i.call(t)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,o=c}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}function c2(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
205
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function d2(n,e){return l2(n)||u2(n,e)||f2(n,e)||c2()}function f2(n,e){if(n){if(typeof n=="string")return Zp(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Zp(n,e):void 0}}function Ks(n){var e,t;function r(i,a){try{var s=n[i](a),l=s.value,u=l instanceof s2;Promise.resolve(u?l.v:l).then(function(c){if(u){var d=i==="return"&&l.k?i:"next";if(!l.k||c.done)return r(d,c);c=n[d](c).value}o(!!s.done,c)},function(c){r("throw",c)})}catch(c){o(2,c)}}function o(i,a){i===2?e.reject(a):e.resolve({value:a,done:i}),(e=e.next)?r(e.key,e.arg):t=null}this._invoke=function(i,a){return new Promise(function(s,l){var u={key:i,arg:a,resolve:s,reject:l,next:null};t?t=t.next=u:(e=t=u,r(i,a))})},typeof n.return!="function"&&(this.return=void 0)}Ks.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Ks.prototype.next=function(n){return this._invoke("next",n)},Ks.prototype.throw=function(n){return this._invoke("throw",n)},Ks.prototype.return=function(n){return this._invoke("return",n)};var dm=Object.entries,Kp=Object.setPrototypeOf,h2=Object.isFrozen,fm=Object.getPrototypeOf,hm=Object.getOwnPropertyDescriptor,Re=Object.freeze,qe=Object.seal,wo=Object.create,pm=typeof Reflect<"u"&&Reflect,hc=pm.apply,pc=pm.construct;Re||(Re=function(e){return e});qe||(qe=function(e){return e});hc||(hc=function(e,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(t,o)});pc||(pc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return new e(...r)});var Zt=we(Array.prototype.forEach);Array.prototype.indexOf;var p2=we(Array.prototype.lastIndexOf),Jp=we(Array.prototype.pop),zi=we(Array.prototype.push),m2=we(Array.prototype.slice),g2=we(Array.prototype.splice),_o=Array.isArray,oc=mm(Set),ic=we(Set.prototype.add),Hi=we(Set.prototype.has),bn=we(String.prototype.toLowerCase),ac=we(String.prototype.toString),Qp=we(String.prototype.match),Gi=we(String.prototype.replace),em=we(String.prototype.indexOf),b2=we(String.prototype.trim),w2=we(Number.prototype.toString),_2=we(Boolean.prototype.toString),tm=typeof BigInt>"u"?null:we(BigInt.prototype.toString),rm=typeof Symbol>"u"?null:we(Symbol.prototype.toString),ot=we(Object.prototype.hasOwnProperty),Wi=we(Object.prototype.toString),je=we(RegExp.prototype.test),Kt=mm(TypeError);function we(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return hc(n,e,r)}}function mm(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return pc(n,t)}}function oe(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bn;if(Kp&&Kp(n,null),!_o(e))return n;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=t(o);i!==o&&(h2(e)||(e[r]=i),o=i)}n[o]=!0}return n}function y2(n){for(let e=0;e<n.length;e++)ot(n,e)||(n[e]=null);return n}function ct(n){let e=wo(null);for(let r of dm(n)){var t=d2(r,2);let o=t[0],i=t[1];ot(n,o)&&(_o(i)?e[o]=y2(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=ct(i):e[o]=i)}return e}function v2(n){switch(typeof n){case"string":return n;case"number":return w2(n);case"boolean":return _2(n);case"bigint":return tm?tm(n):"0";case"symbol":return rm?rm(n):"Symbol()";case"undefined":return Wi(n);case"function":case"object":{if(n===null)return Wi(n);let e=n,t=gt(e,"toString");if(typeof t=="function"){let r=t(e);return typeof r=="string"?r:Wi(r)}return Wi(n)}default:return Wi(n)}}function gt(n,e){for(;n!==null;){let r=hm(n,e);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}n=fm(n)}function t(){return null}return t}function E2(n,e){for(;n!==null;){let t=hm(n,e);if(t)return t.get?we(t.get):null;n=fm(n)}return null}function x2(n){try{return je(n,""),!0}catch{return!1}}var nm=Re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),sc=Re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),lc=Re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),k2=Re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),uc=Re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),T2=Re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),om=Re(["#text"]),im=Re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),cc=Re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),am=Re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Js=Re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),A2=qe(/{{[\w\W]*|^[\w\W]*}}/g),D2=qe(/<%[\w\W]*|^[\w\W]*%>/g),S2=qe(/\${[\w\W]*/g),C2=qe(/^data-[\-\w.\u00B7-\uFFFF]+$/),N2=qe(/^aria-[\-\w]+$/),sm=qe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),I2=qe(/^(?:\w+script|data):/i),O2=qe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),R2=qe(/^html$/i),B2=qe(/^[a-z][.\w]*(-[.\w]+)+$/i),dc=qe(/<[/\w!]/g),lm=qe(/<[/\w]/g),$2=qe(/<\/no(script|embed|frames)/i),um=qe(/\/>/i),Ae={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},M2=Re(oe({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),P2=function(){return typeof window>"u"?null:window},L2=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(r=t.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},cm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ir=function(e,t,r,o){return ot(e,t)&&_o(e[t])?oe(o.base?ct(o.base):{},e[t],o.transform):r},fc=function(e,t,r){let o=ot(e,t)?e[t]:void 0;return o&&typeof o=="object"?ct(o):r()};function gm(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P2(),e=S=>gm(S);if(e.version="3.4.17",e.removed=[],!n||!n.document||n.document.nodeType!==Ae.document||!n.Element)return e.isSupported=!1,e;let t=n.document,r=t,o=r.currentScript;n.DocumentFragment;let i=n.HTMLTemplateElement,a=n.Node,s=n.Element,l=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let u=n.DOMParser,c=n.trustedTypes,d=s.prototype,f=gt(d,"cloneNode"),h=gt(d,"remove"),m=gt(d,"removeAttributeNode"),p=gt(d,"nextSibling"),w=gt(d,"childNodes"),b=gt(d,"parentNode"),_=gt(d,"shadowRoot"),y=gt(d,"attributes"),E=a&&a.prototype?gt(a.prototype,"nodeType"):null,N=a&&a.prototype?gt(a.prototype,"nodeName"):null,k=a&&a.prototype?gt(a.prototype,"ownerDocument"):null,C=function(g){return E?E(g):g.nodeType},O=function(g){return N?N(g):g.nodeName},$=E2(d,"namespaceURI"),Z=function(g){return $?$(g):g.namespaceURI};if(typeof i=="function"){let S=t.createElement("template");S.content&&S.content.ownerDocument&&(t=S.content.ownerDocument)}let W,ie="",he,te=!1,se=0,z=function(){if(se>0)throw Kt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},at=function(g){z(),se++;try{return W.createHTML(g)}finally{se--}},vo=function(g){z(),se++;try{return W.createScriptURL(g)}finally{se--}},Rr=function(){return te||(he=L2(c,o),te=!0),he},At=t,K=At.implementation,Ge=At.createNodeIterator,wn=At.createDocumentFragment,_n=At.getElementsByTagName,Cm=r.importNode,pe=cm();e.isSupported=typeof dm=="function"&&typeof b=="function"&&K&&K.createHTMLDocument!==void 0;let Nm=A2,Im=D2,Om=S2,Rm=C2,Bm=N2,$m=I2,Fc=O2,Mm=B2,jc=sm,ge=null,il=oe({},[...nm,...sc,...lc,...uc,...om]),be=null,al=oe({},[...im,...cc,...am,...Js]),Dt=Object.seal(wo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Eo=null,qc=null,Qt=Object.seal(wo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Uc=!0,sl=!0,Vc=!1,ll=!0,Ut=!1,Br=!0,$r=!1,ul=!1,Ki=null,Ji=null,cl=!1,yn=!1,Qi=!1,ea=!1,zc=!0,Hc=!1,Gc="user-content-",dl=!0,fl=!1,Mr=null,vn={},Pr=null,Wc=oe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Yc=null,Xc=oe({},["audio","video","img","source","image","track"]),Zc=null,Kc=oe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ta="http://www.w3.org/1998/Math/MathML",ra="http://www.w3.org/2000/svg",St="http://www.w3.org/1999/xhtml",En=St,hl=!1,pl=null,Pm=oe({},[ta,ra,St],ac),Jc=Re(["mi","mo","mn","ms","mtext"]),ml=oe({},Jc),Qc=Re(["annotation-xml"]),gl=oe({},Qc),Lm=oe({},["title","style","font","a","script"]),xo=null,Fm=["application/xhtml+xml","text/html"],jm="text/html",xe=null,xn=null,qm=t.createElement("form"),ed=function(g){return g instanceof RegExp||g instanceof Function},bl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(xn&&xn===g)return;(!g||typeof g!="object")&&(g={}),g=ct(g),xo=Fm.indexOf(g.PARSER_MEDIA_TYPE)===-1?jm:g.PARSER_MEDIA_TYPE,xe=xo==="application/xhtml+xml"?ac:bn,ge=Ir(g,"ALLOWED_TAGS",il,{transform:xe}),be=Ir(g,"ALLOWED_ATTR",al,{transform:xe}),pl=Ir(g,"ALLOWED_NAMESPACES",Pm,{transform:ac}),Zc=Ir(g,"ADD_URI_SAFE_ATTR",Kc,{transform:xe,base:Kc}),Yc=Ir(g,"ADD_DATA_URI_TAGS",Xc,{transform:xe,base:Xc}),Pr=Ir(g,"FORBID_CONTENTS",Wc,{transform:xe}),Eo=Ir(g,"FORBID_TAGS",ct({}),{transform:xe}),qc=Ir(g,"FORBID_ATTR",ct({}),{transform:xe}),vn=ot(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?ct(g.USE_PROFILES):g.USE_PROFILES:!1,Uc=g.ALLOW_ARIA_ATTR!==!1,sl=g.ALLOW_DATA_ATTR!==!1,Vc=g.ALLOW_UNKNOWN_PROTOCOLS||!1,ll=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ut=g.SAFE_FOR_TEMPLATES||!1,Br=g.SAFE_FOR_XML!==!1,$r=g.WHOLE_DOCUMENT||!1,yn=g.RETURN_DOM||!1,Qi=g.RETURN_DOM_FRAGMENT||!1,ea=g.RETURN_TRUSTED_TYPE||!1,cl=g.FORCE_BODY||!1,zc=g.SANITIZE_DOM!==!1,Hc=g.SANITIZE_NAMED_PROPS||!1,dl=g.KEEP_CONTENT!==!1,fl=g.IN_PLACE||!1,jc=x2(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:sm,En=typeof g.NAMESPACE=="string"?g.NAMESPACE:St,ml=fc(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>oe({},Jc)),gl=fc(g,"HTML_INTEGRATION_POINTS",()=>oe({},Qc));let v=fc(g,"CUSTOM_ELEMENT_HANDLING",()=>wo(null));if(Dt=wo(null),ot(v,"tagNameCheck")&&ed(v.tagNameCheck)&&(Dt.tagNameCheck=v.tagNameCheck),ot(v,"attributeNameCheck")&&ed(v.attributeNameCheck)&&(Dt.attributeNameCheck=v.attributeNameCheck),ot(v,"allowCustomizedBuiltInElements")&&typeof v.allowCustomizedBuiltInElements=="boolean"&&(Dt.allowCustomizedBuiltInElements=v.allowCustomizedBuiltInElements),qe(Dt),Ut&&(sl=!1),Qi&&(yn=!0),vn&&(ge=oe({},om),be=wo(null),vn.html===!0&&(oe(ge,nm),oe(be,im)),vn.svg===!0&&(oe(ge,sc),oe(be,cc),oe(be,Js)),vn.svgFilters===!0&&(oe(ge,lc),oe(be,cc),oe(be,Js)),vn.mathMl===!0&&(oe(ge,uc),oe(be,am),oe(be,Js))),Qt.tagCheck=null,Qt.attributeCheck=null,ot(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?Qt.tagCheck=g.ADD_TAGS:_o(g.ADD_TAGS)&&(ge===il&&(ge=ct(ge)),oe(ge,g.ADD_TAGS,xe))),ot(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?Qt.attributeCheck=g.ADD_ATTR:_o(g.ADD_ATTR)&&(be===al&&(be=ct(be)),oe(be,g.ADD_ATTR,xe))),ot(g,"ADD_FORBID_CONTENTS")&&_o(g.ADD_FORBID_CONTENTS)&&(Pr===Wc&&(Pr=ct(Pr)),oe(Pr,g.ADD_FORBID_CONTENTS,xe)),dl&&(ge["#text"]=!0),$r&&oe(ge,["html","head","body"]),ge.table&&(oe(ge,["tbody"]),delete Eo.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Kt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Kt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let T=W;W=g.TRUSTED_TYPES_POLICY;try{ie=at("")}catch(A){throw W=T,A}}else g.TRUSTED_TYPES_POLICY===null?(W=void 0,ie=""):(W===void 0&&(W=Rr()),W&&typeof ie=="string"&&(ie=at("")));Re&&Re(g),xn=g},td=oe({},[...sc,...lc,...k2]),rd=oe({},[...uc,...T2]),Um=function(g,v,T){return v.namespaceURI===St?g==="svg":v.namespaceURI===ta?g==="svg"&&(T==="annotation-xml"||ml[T]):!!td[g]},Vm=function(g,v,T){return v.namespaceURI===St?g==="math":v.namespaceURI===ra?g==="math"&&gl[T]:!!rd[g]},zm=function(g,v,T){return v.namespaceURI===ra&&!gl[T]||v.namespaceURI===ta&&!ml[T]?!1:!rd[g]&&(Lm[g]||!td[g])},Hm=function(g){let v=Z(g),T=bn(O(g)),A=b(g),M,q;return A&&C(A)===Ae.element?(M={namespaceURI:Z(A)},q=bn(O(A))):(M={namespaceURI:En},q="template"),pl[v]?v===ra?Um(T,M,q):v===ta?Vm(T,M,q):v===St?zm(T,M,q):!!(xo==="application/xhtml+xml"&&pl[v]):!1},er=function(g){zi(e.removed,{element:g});try{b(g).removeChild(g)}catch{if(h(g),!b(g))throw Kt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},nd=function(g,v,T){try{m(g,v)}catch{try{g.removeAttribute(T)}catch{}}},wl=function(g){yl(g);let v=w(g);v&&Zt(m2(v),A=>{try{h(A)}catch{}});let T=C(g)===Ae.element?y(g):null;if(T)for(let A=T.length-1;A>=0;--A){let M=T[A],q=M&&M.name;typeof q=="string"&&nd(g,M,q)}},kn=function(g,v,T){if(!T)try{T=v.getAttributeNode(g)}catch{T=null}zi(e.removed,{attribute:T||null,from:v});try{T?m(v,T):v.removeAttribute(g)}catch{try{v.removeAttribute(g)}catch{}}if(g==="is")if(yn||Qi)try{er(v)}catch{}else try{v.setAttribute(g,"")}catch{}},od=function(g){let v=y(g);if(v)for(let T=v.length-1;T>=0;--T){let A=v[T],M=A&&A.name;typeof M!="string"||be[xe(M)]||nd(g,A,M)}},_l=function(g,v){let T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,A=[g];for(;A.length>0;){let M=A.pop();if(v(M)===!1)continue;if(T&&C(M)===Ae.element){let X=_(M);tr(X)&&A.push(X)}let q=w(M);if(q)for(let X=q.length-1;X>=0;--X)A.push(q[X])}},yl=function(g){_l(g,v=>{C(v)===Ae.element&&od(v)})},vl=function(g){let v=[];return _l(g,T=>{v.push(T)},!0),v},Gm=function(g,v){let T=oc();Zt(vl(g),A=>{C(A)===Ae.element&&ic(T,A)}),Zt(v,A=>{C(A)===Ae.element&&!Hi(T,A)&&od(A)})},id=function(g,v){let T=!1;return Zt(e.removed,A=>{A.element&&(T=T||A.element===g,yl(A.element))}),Gm(g,v),T},Wm=8,Ym=function(g,v){let T=Mr,A=null,M=()=>(A||(A=oc(),Zt(v,q=>{ic(A,q)})),A);for(let q=0;;q++){let X=vl(g),De=[g],Ct=!1;if(Zt(X,We=>{C(We)===Ae.documentFragment?zi(De,We):!Ct&&!Hi(T,We)&&(Ct=Hi(M(),We))}),!Ct)return;if(q>=Wm)throw Kt("the tree kept changing during in-place sanitization; refusing to return it");Zt(De,(We,Je)=>{Xm(We,Je>0,g,M())})}},Xm=function(g,v,T,A){let M=El(g),q;for(;q=M.nextNode();)!Hi(A,q)||Hi(Mr,q)||(v&&wt(pe.uponSanitizeShadowNode,q,null),kl(q,T),Tl(q,T),tr(q.content)&&To(q.content))},Zm=function(g){Mr&&ic(Mr,g)},ad=function(g,v){return Br?g==="patchsrc"?!0:g==="for"&&v!=="label"&&v!=="output":!1},Km=function(g){Br&&_l(g,v=>{let T=C(v);if(T===Ae.processingInstruction||T===Ae.comment&&je(lm,v.data)){try{h(v)}catch{}return!1}if(T===Ae.element){let A=v,M=xe(O(v));try{A.hasAttribute&&A.hasAttribute("patchsrc")&&A.removeAttribute("patchsrc"),A.hasAttribute&&A.hasAttribute("for")&&ad("for",M)&&A.removeAttribute("for")}catch{}}return!0})},sd=function(g){let v=null,T=null;if(cl)g="<remove></remove>"+g;else{let q=Qp(g,/^[\r\n\t ]+/);T=q&&q[0]}xo==="application/xhtml+xml"&&En===St&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let A=W?at(g):g;if(En===St)try{v=new u().parseFromString(A,xo)}catch{}if(!v||!v.documentElement){v=K.createDocument(En,"template",null);try{v.documentElement.innerHTML=hl?ie:A}catch{}}let M=v.body||v.documentElement;return g&&T&&M.insertBefore(t.createTextNode(T),M.childNodes[0]||null),En===St?_n.call(v,$r?"html":"body")[0]:$r?v.documentElement:M},El=function(g){let v=k?k(g):g.ownerDocument;return Ge.call(v||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},na=function(g){return g=Gi(g,Nm," "),g=Gi(g,Im," "),g=Gi(g,Om," "),g},xl=function(g){var v;ld(g);let T=(v=g.querySelectorAll)===null||v===void 0?void 0:v.call(g,"template");T&&Zt(T,A=>{tr(A.content)&&xl(A.content)})},ld=function(g){g.normalize();let v=k?k(g):g.ownerDocument,T=Ge.call(v||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),A=T.nextNode();for(;A;)A.data=na(A.data),A=T.nextNode()},oa=function(g){let v=N?N(g):null;return typeof v!="string"||xe(v)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==y(g)||typeof g.removeAttribute!="function"||typeof g.removeAttributeNode!="function"||typeof g.getAttributeNode!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==E(g)||g.childNodes!==w(g)},tr=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return E(g)===Ae.documentFragment}catch{return!1}},ko=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return typeof E(g)=="number"}catch{return!1}};function wt(S,g,v){S.length!==0&&Zt(S,T=>{T.call(e,g,v,xn)})}let Jm=function(g,v){return!!(Br&&g.hasChildNodes()&&!ko(g.firstElementChild)&&je(dc,g.textContent)&&je(dc,g.innerHTML)||Br&&M2[v]&&C(g)===Ae.element&&Z(g)===St&&(ko(g.firstElementChild)||typeof g.textContent=="string"&&je(dc,g.textContent))||g.nodeType===Ae.processingInstruction||Br&&g.nodeType===Ae.comment&&je(lm,g.data))},ia=function(g,v){if(g instanceof RegExp)return je(g,v);if(g instanceof Function){for(var T=arguments.length,A=new Array(T>2?T-2:0),M=2;M<T;M++)A[M-2]=arguments[M];return!!g(v,...A)}return!1},Qm=function(g,v,T){if(!Eo[v]&&dd(v)&&ia(Dt.tagNameCheck,v))return!1;if(dl&&!Pr[v]&&!Pr[bn(v)]){let A=b(g),M=w(g);if(M&&A){let q=M.length;for(let X=q-1;X>=0;--X){let De=g===T?f(M[X],!0):M[X];A.insertBefore(De,p(g))}}}return er(g),!0},ud=function(g,v,T,A){return g.length===0?v:v===T||v===A?ct(v):v},Tn=function(g,v){return g===v||b(g)!==null?!1:(fl&&yl(g),!0)},kl=function(g,v){if(Zm(g),wt(pe.beforeSanitizeElements,g,null),Tn(g,v))return!0;if(oa(g))return er(g),!0;let T=xe(O(g));if(ge=ud(pe.uponSanitizeElement,ge,il,Ki),wt(pe.uponSanitizeElement,g,{tagName:T,allowedTags:ge}),Tn(g,v))return!0;if(Jm(g,T))return er(g),!0;if(Eo[T]||!(Qt.tagCheck instanceof Function&&Qt.tagCheck(T))&&!ge[T]){let A=Qm(g,T,v);return A===!1&&(wt(pe.afterSanitizeElements,g,null),Tn(g,v))?!0:A}if(C(g)===Ae.element&&!Hm(g)||(T==="noscript"||T==="noembed"||T==="noframes")&&je($2,g.innerHTML))return er(g),!0;if(Ut&&g.nodeType===Ae.text){let A=na(g.textContent);g.textContent!==A&&(zi(e.removed,{element:g.cloneNode()}),g.textContent=A)}return wt(pe.afterSanitizeElements,g,null),Tn(g,v)},cd=function(g,v,T){if(qc[v]||ad(v,g)||zc&&(v==="id"||v==="name")&&(T in t||T in qm))return!1;let A=be[v]||Qt.attributeCheck instanceof Function&&Qt.attributeCheck(v,g);return sl&&je(Rm,v)||Uc&&je(Bm,v)?!0:A?Zc[v]||je(jc,Gi(T,Fc,""))||(v==="src"||v==="xlink:href"||v==="href")&&g!=="script"&&em(T,"data:")===0&&Yc[g]||Vc&&!je($m,Gi(T,Fc,""))?!0:!T:dd(g)&&ia(Dt.tagNameCheck,g)&&ia(Dt.attributeNameCheck,v,g)||v==="is"&&Dt.allowCustomizedBuiltInElements&&ia(Dt.tagNameCheck,T)},eg=oe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),dd=function(g){return!eg[bn(g)]&&je(Mm,g)},tg=function(g,v,T,A){if(W&&typeof c=="object"&&typeof c.getAttributeType=="function"&&!T)switch(c.getAttributeType(g,v)){case"TrustedHTML":return at(A);case"TrustedScriptURL":return vo(A)}return A},rg=function(g,v,T,A){try{return T?g.setAttributeNS(T,v,A):g.setAttribute(v,A),oa(g)?(er(g),!1):!0}catch{return kn(v,g),!1}},fd=function(g,v){return Br&&je(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,v)?!0:bn(g)==="attributename"&&Qp(v,"href")!==null},Tl=function(g,v){if(wt(pe.beforeSanitizeAttributes,g,null),Tn(g,v))return;let T=g.attributes;if(!T||oa(g))return;be=ud(pe.uponSanitizeAttribute,be,al,Ji);let A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be,forceKeepAttr:void 0},M=T.length,q=xe(g.nodeName);for(;M--;){let X=T[M],De=X.name,Ct=X.namespaceURI,We=X.value,Je=xe(De),An=We,Qe=De==="value"?An:b2(An),hd=!1;if(A.attrName=Je,A.attrValue=Qe,A.keepAttr=!0,A.forceKeepAttr=void 0,wt(pe.uponSanitizeAttribute,g,A),Qe=A.attrValue,Hc&&(Je==="id"||Je==="name")&&em(Qe,Gc)!==0&&(kn(De,g,X),Qe=Gc+Qe,hd=!0),fd(De,Qe)){kn(De,g,X);continue}if(!A.forceKeepAttr){if(!A.keepAttr){kn(De,g,X);continue}if(!ll&&je(um,Qe)){kn(De,g,X);continue}if(Ut&&(Qe=na(Qe)),!cd(q,Je,Qe)){kn(De,g,X);continue}Qe=tg(q,Je,Ct,Qe),Qe!==An&&rg(g,De,Ct,Qe)&&hd&&Jp(e.removed)}}wt(pe.afterSanitizeAttributes,g,null),Tn(g,v)},To=function(g){let v=null,T=El(g);for(wt(pe.beforeSanitizeShadowDOM,g,null);v=T.nextNode();)if(wt(pe.uponSanitizeShadowNode,v,null),kl(v,g),Tl(v,g),tr(v.content)&&To(v.content),C(v)===Ae.element){let A=_(v);tr(A)&&(Al(A),To(A))}Ut&&ld(g),wt(pe.afterSanitizeShadowDOM,g,null)},Al=function(g){let v=[{node:g,shadow:null}];for(;v.length>0;){let T=v.pop();if(T.shadow){To(T.shadow);continue}let A=T.node,M=C(A)===Ae.element,q=w(A);if(q)for(let X=q.length-1;X>=0;--X)v.push({node:q[X],shadow:null});if(M){let X=N?N(A):null;if(typeof X=="string"&&xe(X)==="template"){let De=A.content;tr(De)&&v.push({node:De,shadow:null})}}if(M){let X=_(A);tr(X)&&v.push({node:null,shadow:X},{node:X,shadow:null})}}};return e.sanitize=function(S){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=null,T=null,A=null,M=null;if(hl=!S,hl&&(S="<!-->"),typeof S!="string"&&!ko(S)&&(S=v2(S),typeof S!="string"))throw Kt("dirty is not a string, aborting");if(!e.isSupported)return S;ul?(ge=Ki,be=Ji):bl(g),(pe.uponSanitizeElement.length>0||pe.uponSanitizeAttribute.length>0)&&(ge=ct(ge)),pe.uponSanitizeAttribute.length>0&&(be=ct(be)),e.removed=[];let q=fl&&typeof S!="string"&&ko(S),X=[],De=Mr;if(q){Km(S);let Je=O(S);if(typeof Je=="string"){let An=xe(Je);if(!ge[An]||Eo[An])throw wl(S),Kt("root node is forbidden and cannot be sanitized in-place")}if(oa(S))throw wl(S),Kt("root node is clobbered and cannot be sanitized in-place");X=vl(S),Mr=oc()}else if(ko(S))v=sd("<!---->"),T=v.ownerDocument.importNode(S,!0),T.nodeType===Ae.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?v=T:v.appendChild(T),Al(v);else{if(!yn&&!Ut&&!$r&&S.indexOf("<")===-1)return W&&ea?at(S):S;if(v=sd(S),!v)return yn?null:ea?ie:""}v&&cl&&er(v.firstChild);let Ct=q?S:v;try{q&&Al(S);let Je=El(Ct);for(;A=Je.nextNode();)kl(A,Ct),Tl(A,Ct),tr(A.content)&&To(A.content);q&&Ym(S,X)}catch(Je){throw q&&(wl(S),id(S,X)),Je}finally{Mr=De}if(q){if(id(S,X))throw Kt("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ut&&xl(S),S}if(yn){if(Ut&&xl(v),Qi)for(M=wn.call(v.ownerDocument);v.firstChild;)M.appendChild(v.firstChild);else M=v;return(be.shadowroot||be.shadowrootmode)&&(M=Cm.call(r,M,!0)),M}let We=$r?v.outerHTML:v.innerHTML;return $r&&ge["!doctype"]&&v.ownerDocument&&v.ownerDocument.doctype&&v.ownerDocument.doctype.name&&je(R2,v.ownerDocument.doctype.name)&&(We="<!DOCTYPE "+v.ownerDocument.doctype.name+`>
|
|
206
|
-
`+
|
|
200
|
+
`))})}#i(e,t,r){let o=this.#e.gramlot,i=JSON.stringify([t,e]);if(this.#o.has(i))return;let a=this.#e.nodeIds.get(this.#t);if(!a){if(this.#n.clear(),this.#a=0,this.#r===null){let p=this;class m{close(b){p.#s(b.getAttr("notice"))}}this.#r=`errors_${ee()}`,this.#e.logicRegistry.register(m,{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;"}),o.src.source.setItem(this.#t,o.src.prepareSource(h.source)),a=this.#e.nodeIds.get(this.#t)}if(this.#n.has(i))return;if(this.#n.size===5){let h=`${++this.#a} additional errors`,p=a.value.getNode("overflow");p?p.setValue(h):o.src.builder.wrapSource(a).p(h,{node_label:"overflow",role:"status",style:"margin:0;padding:12px;"});return}let s=`notice_${ee()}`,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:s,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=o.src.builder.wrapSource(a).div({node_label:s});ie(f).setValue(o.src.prepareSource(l.source)),this.#n.set(i,s),o.dom.getDomNode(a).showPopover()}#s(e){this.#e.nodeIds.get(this.#t).value.popNode(e);for(let[r,o]of this.#n)o===e&&(this.#n.delete(r),this.#o.add(r));this.#n.size||this.#e.gramlot.src.source.popNode(this.#t)}};var Zp={dataFormula:Is,dataController:Os,dataRpc:Rs,dataRemote:Bs},l2=["datapath","_anchor","nodeId","form","formId"],go=class{#e;#t=new Map;#r=new Map;#n;#o;#a;#i;#s;#l;#c=`gramlot-data-${ee()}`;#u=!1;#d=new Set;#f=new Set;#p=new WeakMap;constructor(e,{subscriptions:t}){this.#e=e,this.#l=t,this.#n=new Ds(this),this.#o=new Cs(this),this.#a=new $s(this),this.#i=new Ls(this),this.#s=new Fs(this)}get gramlot(){return this.#e}reportError(e,t){this.disposed||this.#s.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}treeStore(e){let t=e.getAttr("storepath");if(t==="*S"||t.startsWith("*S.")){let r=this.renderer.source.getItem("main");return t==="*S"?r:r.getItem(t.slice(3))}return t==="*D"||t.startsWith("*D.")?t==="*D"?this.data:this.data.getItem(t.slice(3)):e.getRelativeData(t)}registerTreeRoot(e,t){let r=t?this.#d:this.#f;return r.add(e),{close:()=>r.delete(e)}}refreshSourceTrees(){for(let e of[...this.#d])!e.closed&&this.renderer.attached(e.node)&&this.renderer.project(e.node)}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.#o}get inlineCompiler(){return this.#a}get askDialog(){return this.#i}get nodeIds(){return this.#r}collectionStore(e,t){if(this.disposed)throw new Error("BindingRuntime is disposed");let r=this.#p.get(e);if(!r)r=new xs(e,t),this.#p.set(e,r);else if(r.rowMode!==t)throw new TypeError("A shared collection store requires one rowMode");return r}collectionView(e,t,r){let o=this.collectionStore(t,r);return Object.hasOwn(e,"gridCollectionView")?e.gridCollectionView.bindStore(o):Object.defineProperty(e,"gridCollectionView",{value:new Ts(o),configurable:!0}),e.gridCollectionView}attach(){this.root.subscribe(this.#c,{any:e=>this.receiveData(e)})}receiveData(e){let t=this.root;for(let[r,o]of(e.pathlist??[]).entries()){let i=t.node(o)?.staticValue;if(!(i instanceof k))break;this.#p.get(i)?.receiveData(e,r+1<e.pathlist.length?i.node(e.pathlist[r+1]):null),t=i}this.router.deliver(e);for(let r of[...this.#f])!r.closed&&this.renderer.attached(r.node)&&this.renderer.project(r.node)}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 uc(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof I)for(let o of e.value.getNodes())try{this.closeBranch(o)}catch(i){t.push(i)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let o=e.getAttr("nodeId");this.nodeIds.get(o)===e&&this.nodeIds.delete(o);try{r.close()}catch(i){t.push(i)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#_(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,o=[],i=a=>{try{this.closeBranch(a)}catch(s){o.push(s)}};try{if(t==="ins")this.#h(r);else if(t==="del")for(let a of Array.isArray(r)?r:[r])i(a);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof I)for(let a of e.oldvalue.getNodes())i(a);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#b(r,e.attrs_diff):this.#w(r).rebind(),r.value instanceof I&&this.#h(r.value)}else if(t==="upd_attrs")this.#b(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(a){throw o.length?new AggregateError([...o,a],"Source event failed"):a}return o}branchBuilt(e){let t=[];for(let r of this.#_(e)){let o=this.bindingFor(r);!o||o.hasStamp("built")||!this.renderer.attached(r)||(o.stamp("built"),t.push(o))}for(let r of t)this.renderer.attached(r.node)&&this.#g(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#m(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#m(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#c,{any:!0}),this.nodeIds.clear(),this.#p=new WeakMap;let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(o){e.push(o)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#h(e){if(!(e instanceof I)&&this.bindingFor(e))return;let t=e instanceof I?e.getNodes().flatMap(i=>this.#_(i)):this.#_(e),r=new Set(t.filter(i=>this.bindingFor(i))),o=new Map;for(let i of t){let a=i.getAttr("nodeId");if(a!=null){if(o.has(a)||this.nodeIds.has(a)&&this.nodeIds.get(a)!==i)throw new Error(`Duplicate nodeId '${a}'`);o.set(a,i)}}for(let[i,a]of o)this.nodeIds.set(i,a);try{for(let i of t)this.openBinding(i);this.installer.install(e);for(let i of t)this.renderer.attached(i)&&this.bindingFor(i).registerPointers()}catch(i){let a=[i];for(let s of t.filter(l=>!r.has(l)).reverse()){let l=s.getAttr("nodeId");o.get(l)===s&&this.nodeIds.get(l)===s&&this.nodeIds.delete(l);let u=this.bindingFor(s);if(u){this.#t.delete(s);try{u.close()}catch(c){a.push(c)}}}throw a.length>1?new AggregateError(a,"Source branch installation failed"):i}for(let i of t){let a=this.bindingFor(i);if(!(!a||a.hasStamp("init")||!this.renderer.attached(i))&&(a.stamp("init"),Kp(i.getAttr("_init"))))for(let s of a.providers)s.invoke({kind:"init",change:null})}}#m(e){e.hasStamp("start")||(e.stamp("start"),this.#g(e,"start","_onStart"),e.remote?.trigger())}#g(e,t,r){let o=e.node.getAttr(r);if(Kp(o))for(let i of e.providers){if(typeof o!="number"||o<=0){i.invoke({kind:t,change:null});continue}let a=null,s=setTimeout(()=>{a(),i.invoke({kind:t,change:null})},o);a=e.track(()=>clearTimeout(s))}}#b(e,t){let r=this.#w(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:o,new:i}=t.nodeId;if(i!=null&&this.nodeIds.has(i)&&this.nodeIds.get(i)!==e)throw new Error(`Duplicate nodeId '${i}'`);this.nodeIds.get(o)===e&&this.nodeIds.delete(o),i!=null&&this.nodeIds.set(i,e)}l2.some(o=>Object.hasOwn(t,o))?this.rebindBranch(e):r.rebind()}#w(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}#_(e){let t=[e];if(e.value instanceof I)for(let r of e.value.getNodes())t.push(...this.#_(r));return t}};function Kp(n){return n===!0||typeof n=="number"}var uc=class{#e;#t;#r=!1;#n=[];#o=[];#a=new Set;#i=null;#s=null;#l=null;#c=new Set;#u=new Set;#d=0;#f=new Set;#p=null;editingSession=null;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.#o]}get providers(){return this.#i?[this.#i]:[]}get remote(){return this.#l}get clickCount(){return this.#d}countClick(){return++this.#d}hasStamp(e){return this.#a.has(e)}stamp(e){this.#a.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&&!Zp[e.nodeTag]&&e.nodeTag!=="dataBinder")return;!t&&typeof e.getAttr("remote")=="string"?this.#l??=new Ms(this):this.#l&&(this.#l.close(),this.#l=null);let r=new Set,o=e._getMeta("gramlot_component");for(let[a,s]of[["bagStore","storepath"],["bagStruct","structpath"]]){if(!o?.[a])continue;let l=e.getAttr(s);if(typeof l!="string"||!l||/^[\^=]/.test(l)||l.includes("?"))throw new TypeError(`${s} requires a plain Bag data path`);if(a==="bagStore"&&e.nodeTag==="tree"&&(l==="*S"||l.startsWith("*S."))){this.#o.push(this.runtime.registerTreeRoot(this,!0));continue}if(a==="bagStore"&&e.nodeTag==="tree"&&l==="*D"){this.#o.push(this.runtime.registerTreeRoot(this,!1));continue}let u=a==="bagStore"&&e.nodeTag==="tree"&&l.startsWith("*D.")?l.slice(3):e.absDatapath(l),c=this.runtime.router.register({path:u,recipient:this,subtree:!0});this.#o.push(c),a==="bagStore"&&o.bagStruct&&(this.#p=c)}let i=this.remote?Ft(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[a,s]of Object.entries(e.getAttr()))if(a.startsWith("remote_"))for(let l of Ft(e,s))r.add(l)}for(let[a,s]of e.pointers()){if(t&&a!=="datapath")continue;let u=(a==="datapath"?e.parentNode:e).absDatapath(s);if(u===null)continue;let[c,d=null]=u.split("?",2),f=this.runtime.router.register({path:c,attr:d,recipient:this});this.#o.push(f),a==="datapath"&&this.#f.add(f),this.remote&&(a==="remote"||a.startsWith("remote_")||r.has(a))&&this.#c.add(f),this.remote&&(a==="_timing"||i.has(a))&&this.#u.add(f)}if(!t){this.#h(),this.remote?.register();return}if(e.nodeTag==="dataBinder"){this.#s??=new Ps(this),this.#s.register();return}this.#i??=new Zp[e.nodeTag](this),this.#i.register()}#h(){let e=this.node;this.#o.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return o=>{if(this.closed)return;if(vi(r))return Qt(this.runtime,e,r,o);let[,i]=e.rootBuilder.runtimeValues(e),a=Object.fromEntries(Object.entries(i).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...this.runtime.renderer.references.resolveArguments(a),p_0:o};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(s))(s)}}))}rebind(){this.#m(),this.registerPointers(),this.editingSession?.refreshField(this.node)}receive(e){if(!(e.registration===this.#p&&(e.level==="child"||e.evt==="upd_attrs"))){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.editingSession?.refreshField(this.node),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,o=this.track(()=>r.abort());try{let i=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return i}finally{o()}}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.#m();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`)}#m(){this.#s?.unregister();for(let e of this.#o.splice(0))e.close();this.#p=null,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 o=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(o===null)return null;let{dragValues:i,item:a,path:s}=o;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:i,item:a,path:s});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Tt(i),{dragValues:Object.fromEntries(Object.entries(i).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,j(L(c))]})),item:a,path:s}}};var Or=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 o=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{let a=i.split("*").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${a.join(".*")}$`)});return e.filter(i=>i!=="dragTags"&&(r.includes(i)||o.some(a=>a.test(i))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(o=>o.trim()).filter(Boolean));return r.size?t.split(",").some(o=>o.split(" AND ").every(i=>(i=i.trim(),!i||i==="!"?!1:i.startsWith("!")?!r.has(i.slice(1)):r.has(i)))):!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,o,i=[]){let a=this.acceptedTypes(e,o.dropTypes,i),s=o.dropEffect??"move",l=this.isTarget(o)&&a.length>0&&this.acceptsTags(t,o.dropTags)&&this.acceptsEffect(r,s);return{accepted:l,types:a,dropEffect:l?s:"none"}}};var Jp=["dragstart","dragover","dragleave","drop","dragend"],qs=class{#e;#t;#r=null;#n=null;#o=null;#a;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Jp)this.#t.addEventListener(t,this);this.#a=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#a)}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)}#i(e,t){for(let r of e.composedPath()){let o=this.#e.elements.get(r);if(o&&t(o.resolved))return o}return null}#s(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.#i(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 o=this.#s(t,e);if(!o){e.preventDefault();return}let i=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:L(c)]));if(!i.size){e.preventDefault();return}let a=t.resolved.effectAllowed??"all";Or.acceptsEffect(a,"move");let s="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){s=u.resolved.dragTags;break}let l=this.#r={record:t,wires:i,effectAllowed:a,phase:"active",tags:[s,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 i)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=a,this.#o=this.#t.createElement("style"),this.#o.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.#o),this.#c(l,o.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#w(r)}}}#c(e,t,r){let o=t.cloneNode(!0);o.removeAttribute("id");for(let i of o.querySelectorAll("[id]"))i.removeAttribute("id");o.setAttribute("aria-hidden","true"),o.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(o),e.preview=o,r.setDragImage(o,0,0)}#u(e){let t=this.#r,r=this.#i(e,u=>Or.isTarget(u));if(!r)return null;let o=this.#s(r,e);if(!o)return{record:r,element:r.element,accepted:!1};let i=Or.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),s={dropValues:Object.fromEntries(i.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):j(t.wires.get(u))])),item:o.item,path:o.path,source:{...t.source},selfdrop:r===t.record,dropEffect:i.dropEffect,dataAvailable:!0},l=i.accepted&&this.#e.checkDropTarget(r.node,s)&&this.#e.records.get(r.node)===r&&o.element.isConnected;return{record:r,element:o.element,accepted:l,context:s}}#d(e){if(!this.#r){this.#i(e,t=>Or.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.#w(t)}}async#f(e){if(!this.#r){this.#i(e,o=>Or.isTarget(o))&&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(o){this.#r===t&&(t.phase="rejected",this.#m()),(!r||this.#e.records.has(r.record.node))&&this.#w(o)}}#p(e,t){let r=t?"canBeDropped":"cannotBeDropped",o=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:o.includes(r)},e.classList.add(r),o.includes(r)||e.setAttribute("part",[...o,r].join(" "))}#h(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:o}=this.#n;r||e.classList.remove(t),o||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(i=>i!==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.#o?.remove(),this.#o=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.#w(r))}#w(e){this.#e.binding.reportError(e,"Drag and drop failed")}dispose(){this.#g();for(let e of Jp)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#a)}};var Bi=class extends un{static renderType="object";#e=new Set;#t=new WeakSet;#r=new WeakMap;#n=new WeakMap;#o=new WeakMap;constructor(e,t,r,{binding:o}={}){if(super(e),!(e instanceof Ke)||!(t instanceof Ae)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(o instanceof go))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof Ke))throw new TypeError("SourceBag requires builder ownership");this._binding=o,this.source=t,this.destination=r,this.html=new gs({uploadContext:()=>({gramlot:o.gramlot,window:r.ownerDocument.defaultView}),metadataAttributes:["__ref"],format:(i,a)=>o.gramlot.format(i,a),reportError:(i,a,s)=>{this.records.has(i)&&o.reportError(a,s)},callLogic:(i,a,s)=>{let{group:l,method:u}=o.gramlot.src.logicRegistry.resolve(a,i);return u.call(l,i,s)},invokeScript:(i,a,s,l)=>Ut(o,i,a,s,l,i.parentNode._getMeta("gramlot_component").childParameters[a].inline)}),this.records=new Map,this.references=new mi(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new js(this),this.instanceId=ee(),this.radioGroups=new ms(this),this.dragDrop=new qs(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:i=>this.receive(i)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,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:o,source:i,selfdrop:a,dropEffect:s,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},o){let i={source:t,dropEffect:r},a=[],s=this.records.get(e);try{s&&!s.binding.closed&&s.resolved.onDragEnd&&await this.html.callLogic(e,s.resolved.onDragEnd,i)}catch(l){a.push(l)}try{this.binding.gramlot.publish(o,i)}catch(l){a.push(l)}if(a.length)throw new AggregateError(a,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let r=this.#n.get(e)??super.evaluateExpressions(e,t),o=e._getMeta("gramlot_component");if(o?.presentationDefaults.length){let i=e.getAttr();this.#o.set(e,Object.fromEntries(Object.entries(r).filter(([a])=>Object.hasOwn(i,a)&&o.presentationDefaults.some(s=>a.startsWith(s)))))}if(this.html.hasLabelbox(e)||o?.presentationDefaults.length){let i=[];for(let a=e.parentNode;a;a=a.parentNode)this.#o.has(a)&&i.unshift(this.#o.get(a));r=Object.assign({},...i,r)}return this.#n.delete(e),this.#r.set(e,r),r}render(e,t={}){if(!(e instanceof ln))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||this.#t.has(e)||!this.binding.bindingFor(e)&&this.#l(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof I))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 o=t.createDocumentFragment(),i={node:e,binding:this.#m(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,i),this.elements.set(o,i),o.append(i.start);for(let a of e.value.getNodes()){let s=this.render(a,{document:t,...r});if(s===null)continue;o.append(s);let l=this.elements.get(s);l&&(l.parent=i,i.children.add(a))}return o.append(i.end),o}renderedItem(e,t,r,{tag:o,document:i=this.destination.ownerDocument}={}){let a=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(a=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,a]=_i(t,a,(h,p)=>this._binding.gramlot.format(h,p)))),a=this.componentAttributes(e,a);let s=Array.isArray(t)?t:[],l=Array.isArray(t)?a._text:t,u=this.#r.get(e),c={node:e,binding:this.#m(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,i,o,a,u.visible??null)};this.html.compose(c,l,s),c.shape=qe.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c),this.elements.set(c.presentation,c);let d=qe.for(c.binding,c);(d||c.element.namespaceURI===je&&c.element.localName==="input")&&c.cleanup.push(()=>c.control?.detach()),d&&(c.control=d,d.attach(),this.#f(c,e,a,null));let f=bs.for(c.binding,c);if(f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new ws(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),e.nodeTag==="groupletCard"){let h=new _s(c.binding,c.element);h.attach(),c.cleanup.push(()=>h.detach())}this.#p(c),this.references?.register(e,c.element);for(let h of s){let p=this.elements.get(h);p&&(p.parent=c,p.container=c.element,c.children.add(p.node))}return c.presentation}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof Ae))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,o=s=>{if(!r.has(s)){r.add(s);for(let l of this.records.get(s)?.children??[])o(l);if(s.value instanceof I)for(let l of s.value.getNodes())o(l)}};for(let s of this.records.get(t)?.children??[])o(s);if(t?.value instanceof I)for(let s of t.value.getNodes())o(s);this.#a(e,t?t.nodeTag:null),lc(e),this.references?.validate(e,r);let i=new Set,a=s=>{for(let l of s.getNodes()){let u=l.getAttr("nodeId");if(u!=null){let c=this.binding.nodeIds.get(u);if(i.has(u)||c&&c!==l&&!r.has(c))throw new Error(`Duplicate nodeId '${u}'`);i.add(u)}l.value instanceof I&&a(l.value)}};return a(e),e}#a(e,t=null){let r=new Set,o=(i,a=null)=>{if(!(i instanceof Ae)||r.has(i))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(i._builder instanceof Ke))throw new TypeError("SourceBag requires builder ownership");r.add(i);for(let s of i.getNodes()){if(!(s instanceof ln))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(s.builder instanceof Ke))throw new TypeError("SourceBagNode requires builder ownership");if(s.resolver)throw new TypeError("Source resolvers are outside this port");if(s._getMeta("data_element"))s.builder.validateNode(s);else if(s.nodeTag){let l=s._getMeta("subbuilder")?i._builder:s.builder;this.html.validate(s,l),s._getMeta("subbuilder")||s.builder.validateParent(s.nodeTag,a)}else{if(!(s.value instanceof I))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(s.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}s.value instanceof I&&o(s.value,s._getMeta("subbuilder")?null:s.nodeTag??a)}};o(e,t)}freeze(e){e=ie(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=ie(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=o=>{delete o.frozen;for(let i of o.children)r(this.records.get(i))};r(t),!this.#i(e)&&(this.attached(e)?this.#g(e):this.remove(e))}#i(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(this.disposed)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(o=>!t(o));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.#c(r);let o=this.binding.handleSourceEvent(r);try{this.#s(r,o)}catch(i){if(!o.length)throw i;o.push(i)}if(this.binding.refreshSourceTrees(),o.length)throw o.length===1?o[0]:new AggregateError(o,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#s(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#i(r))continue;let o=this.records.get(r)?.parent??null;try{this.remove(r)}catch(i){t.push(i)}this.#h(o)}return}if(!this.#i(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#l(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}#c(e){let t=r=>{if(!(r instanceof ln))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof I){if(!(r.value instanceof Ae))throw new TypeError("Source values must be GramlotBuilderBags");for(let o of r.value.getNodes())t(o)}};t(e.node)}unmountView(e){this.#t.add(e),this.remove(e)}mountView(e){this.#t.delete(e),this.insert(e)}insert(e){if(!this.attached(e)||this.records.has(e))return;for(let a=e;a;a=a.parentNode)if(this.#t.has(a))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,o=e.parentBag.getNodes(),i=t?.end??null;for(let a=o.indexOf(e)+1;a<o.length;a++){let s=this.records.get(o[a]);if(s){i=s.presentation??s.start;break}}this.buildNode(e,r,i,t)}buildNode(e,t,r=null,o=null){this.#e.add(e);let i;try{i=this.render(e,{document:t.ownerDocument})}catch(s){this.#u(e,s)}finally{this.#e.delete(e)}let a=this.records.get(e);return t.insertBefore(i,r),a.parent=o,this.assignContainer(a,t),o?.children.add(e),this.#h(o),this.binding.branchBuilt(e),a}#u(e,t){let r=[t],o=[],i=a=>{if(o.push(a),a.value instanceof I)for(let s of a.value.getNodes())i(s)};i(e);for(let a of o.reverse())try{this.remove(a)}catch(s){r.push(s)}throw r.length===1?t:new AggregateError(r,"Source build and cleanup failed")}mountDestination(e,t){let r=this.records.get(e);if(!r?.presentation||t?.nodeType!==1)throw new TypeError("mountDestination requires a mounted element and an HTML destination");if(r.presentation.contains(t))throw new Error("Destination cannot be inside the moved presentation");let o=r.parent;return this.remove(e),this.buildNode(e,t,null,o)}assignContainer(e,t){e.container=t;let r=e.element??t;for(let o of e.children){let i=this.records.get(o);i&&this.assignContainer(i,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let o=e.value==null||["string","number","boolean"].includes(typeof e.value),i=t==="upd_value"&&o&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||i)&&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.#g(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element||!this.attached(e))return;let o=this.getRender(e.builder),i=this.#o.get(e),[a,s]=e.rootBuilder.runtimeValues(e),[,l]=o._handleMeta(e,s),u=this.#r.get(e),c=r.element.namespaceURI===je&&r.element.localName==="input"&&!Object.is(r.resolved.type,u.type),d=r.element.namespaceURI===je&&["input","select"].includes(r.element.localName)&&!!r.resolved.multiple!=!!u.multiple,f=r.resolved.group,h=r.control instanceof fo&&!Object.is(f??null,u.group??null);if((c||d||h)&&this.#i(e))return;if(r.shape!==qe.shape(r.element,u)){if(this.#i(e))return;this.#n.set(e,u);try{this.#g(e)}finally{this.#n.delete(e)}return}let p=c?qe.classFor(r.element,u):null,m=c&&(r.control?.constructor??null)!==p,w=(c||d&&r.element.localName==="input")&&!m&&r.control&&Object.is(r.resolved.value,u.value);if(m&&(r.control?.detach(),r.control=null),h&&!m&&u.group!=null&&e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);r.resolved=u;let b=e._getMeta("subbuilder")?l:o.adaptAttrs(l),_=e.value instanceof I,y=_?[]:this.expressionValue(e,a);if(o===this&&(b=this.restoreNativeAttributes(e,b),e._getMeta("gramlot_component")||([y,b]=_i(y,b,(S,x)=>this._binding.gramlot.format(S,x)))),b=this.componentAttributes(e,b),this.html.update(r,e,b,_?b._text:y,u.visible??null,t),m&&p&&(r.control=new p(r.binding,r),r.control.attach()),h&&!m){r.control.refresh(f??null),this.records.get(e)===r&&!r.binding.closed&&this.project(e);return}w||this.#f(r,e,b,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#p(r);let E=this.#o.get(e);if(E){let S=new Set([...Object.keys(i??{}),...Object.keys(E)].filter(x=>!Object.is(i?.[x],E[x])));S.size&&this.#d(e,S)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#h(r.parent)}#d(e,t){if(e.value instanceof I)for(let r of e.value.getNodes()){let o=r._getMeta("gramlot_component"),i=r.getAttr(),a=t;o?.presentationDefaults.length?a=new Set([...t].filter(s=>!Object.hasOwn(i,s))):this.html.hasLabelbox(r)&&[...t].some(s=>!Object.hasOwn(i,s))&&this.project(r),a.size&&this.#d(r,a)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),o=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!o)return t;let i=this.#r.get(e),a=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(o??{}),...Object.keys(i).filter(s=>s.startsWith("validate_"))])].filter(s=>Object.hasOwn(i,s)).map(s=>[s,i[s]]));return{...t,...a}}#f(e,t,r,o){if(!e.control)return;let i=t.getAttr("value")!=null;(i||e.valueDeclared)&&e.control.project(r.value??null,o),e.valueDeclared=i}#p(e){let t=new Map(Ai.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,o]of[...e.events])t.get(r)?.[2]!==o.handler&&(o.detach(),e.events.delete(r));for(let[r,[,o,i]]of t){if(e.events.has(r))continue;let a=new Ai(e.binding,e,o,i,r);a.attach(),e.events.set(r,a)}}#h(e){for(let t=e;t;t=t.parent){if(t.control instanceof Ti){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=ie(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}#m(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#g(e){let t=this.records.get(e),r=t.presentation?.nextSibling??t.end?.nextSibling??null,o=t.container,i=t.parent,a=null;try{this.remove(e)}catch(s){a=s}try{this.buildNode(e,o,r,i)}catch(s){throw a?new AggregateError([a,s],"Source replacement cleanup and commit failed"):s}if(a)throw a}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 o=r.cleanup.indexOf(t);o!==-1&&r.cleanup.splice(o,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let o of[...t.children])try{this.remove(o)}catch(i){r.push(i)}for(let o of t.cleanup.splice(0).reverse())try{o()}catch(i){r.push(i)}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.#r.delete(e),this.#o.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(o){e.push(o)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var u2=new Set(["page","constructor"]);function Qp(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(u2.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var c2=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function d2(n){return/^[\w$]/.test(n)?c2.has(n):n!==")"&&n!=="]"}function f2(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let o=n[r];if(o===`
|
|
201
|
+
`)return-1;if(o==="\\"){r++;continue}if(o==="[")t=!0;else if(o==="]")t=!1;else if(o==="/"&&!t)return r}return-1}function h2(n){let e=0,t="",r="";for(let o=n.indexOf("{");o<n.length;o++){let i=n[o];if(i==="/"&&n[o+1]==="/"){if(o=n.indexOf(`
|
|
202
|
+
`,o),o<0)break;continue}if(i==="/"&&n[o+1]==="*"){let a=n.indexOf("*/",o+2);if(a>=0){o=a+1;continue}}if(i==="/"&&d2(r)){let a=f2(n,o);if(a>=0){o=a,r=")";continue}}if(i==='"'||i==="'"||i==="`"){let a=o+1;for(;a<n.length&&n[a]!==i;)a+=n[a]==="\\"?2:1;e===1&&(t+=n.slice(o+1,a)==="constructor"?" constructor":' ""'),o=a,r=")";continue}if(/[\w$]/.test(i)){let a=o+1;for(;a<n.length&&/[\w$]/.test(n[a]);)a++;e===1&&(t+=n.slice(o,a)),r=n.slice(o,a),o=a-1;continue}if(/\s/.test(i)||(r=i),i==="{"){++e===2&&(t+=" {}");continue}if(i==="}"){e--;continue}e===1&&(t+=i)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function em(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(h2(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 o=Object.getOwnPropertyDescriptor(n.prototype,r);if(o.get||o.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof o.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,o.value])}return t}function tm(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var gn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},bo=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new gn(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:o}of e){let i=Qp(r,o);for(let a=0;a<i.length;a++){let s=i.slice(0,a).join("/");t.has(s)||t.set(s,new Set),t.get(s).add(i[a])}}for(let{logicClass:r,group:o,resource:i}of e){let a=t.get(o??"")??new Set;for(let[s]of em(r,i))if(a.has(s))throw new Error(`${i}: the logic method '${s}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let o=Qp(t,r),i=em(e,r),a=this.#e.logic;for(let s of o){let l=Object.getOwnPropertyDescriptor(a,s)?.value;if(l===void 0){let u=new gn(this,this.#e);tm(a,s,u),a=u}else if(l instanceof gn)a=l;else throw new Error(`${r}: the group '${s}' has the name of a logic method`)}for(let[s,l]of i){if(Object.getOwnPropertyDescriptor(a,s)?.value instanceof gn)throw new Error(`${r}: the logic method '${s}' has the name of a child group`);tm(a,s,l)}this.#t.has(a)||this.#t.set(a,[]),this.#t.get(a).push(r)}resolve(e,t){let r=e.split("."),o=r.pop(),i=this.#e.logic;for(let s=0;s<r.length;s++)if(i=Object.getOwnPropertyDescriptor(i,r[s])?.value,!(i instanceof gn))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,s+1).join("/")}'`);let a=Object.getOwnPropertyDescriptor(i,o)?.value;if(typeof a!="function"){let s=this.#t.get(i)??[],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 '${o}' (resources: ${s.join(", ")||"none"})`)}return{group:i,method:a}}};var $i=class extends Je{constructor(e,{collections:t,destination:r,subscriptions:o,nameSyntax:i}){super(e),e.src=this,this.logicRegistry=new bo(e),this.builder=new Oe(null,{collections:t,nameSyntax:i}),this.binding=new go(e,{subscriptions:o}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Bi(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 k)||t instanceof I)throw new TypeError("Initial page data must be a Data Bag");for(let o of t.getNodes())this.builder.data.setItem([o.label],o.getValue(),o.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(o){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),o}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof I){if(!(e instanceof Ae))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=Lu(e,t);if(!(r instanceof Ae))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 i=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!i)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,a=>this.#e(e,i,a))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let o=!1,i=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let a=await t.call("source",r);if(!i())return!1;let s=this.prepareSource(a,e.builder);return i()?(this.renderer.validateCandidate(s,{replacingNode:e}),o=!0,e.setValue(s,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(a){if(!o&&!i())return!1;throw a}}};var Mi=class extends Je{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 Us=class extends Je{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#o=!1;ready(){this.gramlot._frames.ready()}subscribe(e,t){if(this.#s(),this.#i(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.#s(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#a(e,t,r);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(a=>!["topic","nodeId","parent","iframe","pageId","server"].includes(a)))throw new Error("This publication route is not implemented yet");if(this.#i(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 i=null;if(e.server===!0){if(["parent","iframe","nodeId"].some(a=>Object.hasOwn(e,a)))throw new Error("Server publication cannot combine window or node selectors");if(!this.gramlot._pageStore)throw new Error("Server publication requires a WebSocket channel");i=this.gramlot._pageStore.preparePublish(e,t)}else(e.parent||e.iframe!==void 0||e.pageId!==void 0)&&(i=this.gramlot._frames.prepare(e,t));if(Object.hasOwn(e,"nodeId")){let a=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!a)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(a,e.topic,t)}return this.#a(e.topic,t),i?.()}topicFor(e,t){this.#i(t),e=ie(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 o=e.getAttr("nodeId");return o==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),o=this.#r.get(e)),`${o}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[o,i]of Object.entries(e.getAttr())){let a=o.startsWith("selfsubscribe_")?"selfsubscribe_":o.startsWith("subscribe_")?"subscribe_":null;if(!a)continue;let s=a==="selfsubscribe_"?this.topicFor(e,o.slice(a.length)):o.slice(a.length);this.#i(s),r.push([s,t(o,i,s)])}return this.#s(),r.map(([o,i])=>{let a=this.subscribe(o,i);return{close:()=>this.unsubscribe(a)}})}dispose(){this.#o=!0,this.#e.clear()}#a(e,t,r={}){this.#i(e);let o=this.#e.get(e);if(o)for(let[i,a]of[...o]){if(this.#o)break;o.has(i)&&a(t,{...r})}}#i(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#s(){if(this.#o)throw new Error("Gramlot subscriptions are disposed")}};var Vs=class extends de{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 rm=["appinfo","location"],nm={UNAVAILABLE:"unavailable",PERMISSION_DENIED:"denied",TIMEOUT:"error",FAILED:"error",CANCELLED:"cancelled"};function ne(n){let e=Object.hasOwn(nm,n?.code)?n.code:"FAILED";return{status:nm[e],error:e==="CANCELLED"?null:{code:e,message:String(n?.message??"Device operation failed")}}}var Pi=class extends Je{#e=null;#t=null;#r=null;#n=null;#o=null;#a=null;#i=new Map;#s=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 m of["gyroscope","accelerometer"])e.data.setItem(`gramlot.device.${m}`,null,{enabled:!1,watching:!1,status:"idle",error:null}),e.data.getNode(`gramlot.device.${m}`).setAttr({error:null},!1,!0,!1),this.#s.set(m,{node:e.data.getNode(`gramlot.device.${m}`),stream:null,cleanup:Promise.resolve()});for(let m of rm){let w=`gramlot.device.${m}`,b={status:"idle",error:null,cacheTime:m==="appinfo"?-1:5};m==="location"&&Object.assign(b,{enabled:!1,watching:!1}),e.data.setItem(w,null);let _=e.data.getNode(w);_.setAttr(b,!1,!0,!1);let y=new Vs(this,m,b.cacheTime);_.resolver=y,this.resolvers.set(m,y)}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 o=e.data.getNode("gramlot.device.barcode");e.data.setItem("gramlot.device.biometrics",null,{status:"idle",error:null,verify:null});let i=e.data.getNode("gramlot.device.biometrics"),a=new k;a.setItem("request",new k);for(let m of["scheduled","received","action"])a.setItem(m,null);e.data.setItem("gramlot.device.notifications",a,{status:"idle",error:null,schedule:null,listening:!1,listenerError:null});let s=e.data.getNode("gramlot.device.notifications"),l=new k;for(let m of["registration","received","action"])l.setItem(m,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 k;c.setItem("request",null),e.data.setItem("gramlot.device.links",c,{listening:!1,listenerError:null});let d=new k;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 k;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 p=e.data.getNode("gramlot.device.audio");e.data.subscribe("gramlot.device",{update:m=>{if(!this.disposed){for(let[w,b]of this.#s)if(m.node===b.node&&m.attrs_diff?.enabled){if(typeof b.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.#g(w,b)}m.node===t&&m.fired&&(m.attrs_diff?.copy?.new===!0&&this.#v(t,"copy"),m.attrs_diff?.paste?.new===!0&&this.#v(t,"paste")),m.node===p&&m.fired&&(m.attrs_diff?.start?.new===!0&&this.#b(p),m.attrs_diff?.stop?.new===!0&&this.#w(p),m.attrs_diff?.cancel?.new===!0&&this.#y(p),m.attrs_diff?.share?.new===!0&&this.#_(p)),m.node===h&&m.fired&&m.attrs_diff?.impact?.new===!0&&this.#k(h),m.node===h&&m.fired&&m.attrs_diff?.vibrate?.new===!0&&this.#E(h),m.node===o&&m.fired&&m.attrs_diff?.scan?.new===!0&&this.#S(o),m.node===r&&m.fired&&m.attrs_diff?.choose?.new===!0&&this.#T(r,"choose"),m.node===r&&m.fired&&m.attrs_diff?.capture?.new===!0&&this.#T(r,"capture"),m.node===i&&m.fired&&m.attrs_diff?.verify?.new===!0&&this.#C(i),m.node===s&&m.fired&&m.attrs_diff?.schedule?.new===!0&&this.#N(s),m.node===u&&m.fired&&m.attrs_diff?.register?.new===!0&&this.#O(u);for(let w of this.resolvers.values()){if(m.node!==w._node)continue;let{cacheTime:b}=m.node.attr;if(typeof b!="number"||!Number.isFinite(b)||b<0&&b!==-1)throw new TypeError("Device cacheTime must be -1 or a nonnegative number of seconds");if(w.cacheTime=b,w.name==="location"){if(typeof m.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=>![...rm,"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,o)=>e.startOrientationEvents(r,o),(r,o)=>{if(!["portrait","landscape"].includes(o?.type)||!["primary","secondary"].includes(o.direction)||!Number.isFinite(o.timestamp))throw new TypeError("Invalid screen orientation from device provider");let i=new k;for(let a of["type","direction","timestamp"])i.setItem(a,o[a]);r.setValue(i,!0,{status:"success",error:null},!0,!1)}),this.#m("network",(r,o)=>e.startNetworkEvents(r,o),(r,o)=>{if(typeof o?.connected!="boolean"||!["none","unknown","wifi","cellular"].includes(o.type))throw new TypeError("Invalid network state from device provider");let i=new k;i.setItem("connected",o.connected),i.setItem("type",o.type),r.setValue(i,!0,{status:"success",error:null},!0,!1)}),this.#m("lifecycle",(r,o)=>e.startLifecycleEvents(r,o),(r,o)=>{if(o?.kind==="state"&&typeof o.active=="boolean")r.staticValue.setItem("active",o.active);else if(o?.kind==="pause"||o?.kind==="resume")r.staticValue.setItem("event",o.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.#B(this.gramlot.data.getNode("gramlot.device.links")),e.capabilities.includes("shortcuts")&&this.#R(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.#A(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(o=>{this.disposed||t.request!==r||(this.accept(t,o),t.revision!==r.revision&&(t._lastUpdate=null))}).catch(o=>{!this.disposed&&t.request===r&&t.received===r.received&&this.failure(t,o)}).finally(()=>{t.request===r&&(t.request=null)})}#m(e,t,r){let o=this.gramlot.data.getNode(`gramlot.device.${e}`);if(!this.provider.capabilities.includes(e)){o.setAttr(ne({code:"UNAVAILABLE",message:`${e} is unavailable`}),!0,!0,!1);return}let i={controller:new AbortController};this.#i.set(e,i),o.setAttr({status:"pending",error:null},!0,!0,!1),i.start=Promise.resolve().then(()=>i.controller.signal.aborted?async()=>{}:t(a=>{if(!i.controller.signal.aborted)try{r(o,a)}catch(s){o.setAttr(ne(s),!0,!0,!1)}},i.controller.signal)).then(a=>(i.controller.signal.aborted||o.setAttr({listening:!0},!0,!0,!1),a)),i.start.catch(a=>{let s=i.controller.signal.aborted;i.controller.abort(),s||o.setAttr({...ne(a),listening:!1},!0,!0,!1)})}#g(e,t){let{node:r}=t;if(!r.attr.enabled){let i=t.stream;if(!i)return;t.stream=null,i.controller.abort(),t.cleanup=i.start.then(a=>a(),()=>{}).then(()=>{!this.disposed&&!t.stream&&r.setAttr({watching:!1,status:"idle",error:null},!0,!0,!1)}),t.cleanup.catch(a=>{this.disposed||r.setAttr(ne(a),!0,!0,!1)});return}if(t.stream)return;let o={controller:new AbortController};t.stream=o,o.start=t.cleanup.then(()=>{if(o.controller.signal.aborted)return async()=>{};this.requireCapability(e);let i=a=>{if(!(this.disposed||o.controller.signal.aborted))try{if(a?.kind==="state"&&typeof a.watching=="boolean")r.setAttr({watching:a.watching,status:a.watching?"pending":"idle",error:null},!0,!0,!1);else if(a?.kind==="sample"){for(let l of["x","y","z","timestamp"])if(!Number.isFinite(a[l]))throw new TypeError(`Invalid ${e}.${l}`);if(!r.attr.watching||r.staticValue&&a.timestamp<r.staticValue.getItem("timestamp"))return;let s=new k;for(let l of["x","y","z","timestamp"])s.setItem(l,a[l]);r.setValue(s,!0,{status:"success",error:null},!0,!1)}else if(a?.kind==="error"&&a.error instanceof Error)r.setAttr({...ne(a.error),watching:!1},!0,!0,!1);else throw new TypeError(`Invalid ${e} event`)}catch(s){r.setAttr(ne(s),!0,!0,!1)}};return e==="gyroscope"?this.provider.startGyroscopeUpdates(i,o.controller.signal):this.provider.startAccelerometerUpdates(i,o.controller.signal)}),o.start.catch(i=>{!this.disposed&&!o.controller.signal.aborted&&r.setAttr({...ne(i),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(o=>o.dispose()).then(()=>{this.disposed||t.controller.signal.aborted||this.#n!==t||(this.#n=null,this.#b(e))}).catch(o=>{!this.disposed&&this.#n===t&&(t.phase="failed",e.setAttr(ne(o),!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(o=>{this.#n===r&&!r.controller.signal.aborted&&this.#y(e,o)},r.controller.signal))),r.start.then(o=>{!o||r.controller.signal.aborted||this.disposed||(r.phase="recording",e.setAttr({status:"recording",error:null,recording:!0},!0,!0,!1))}).catch(o=>{r.controller.signal.aborted||this.disposed||(this.#n===r&&(this.#n=null),e.setAttr({...ne(o),recording:!1},!0,!0,!1))})}#w(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 o=new k;for(let i of["url","mimeType","duration"])o.setItem(i,r[i]);t.phase="complete",e.setValue(o,!0,{status:"success",error:null,recording:!1},!0,!1)}).catch(r=>{!t.controller.signal.aborted&&!this.disposed&&this.#y(e,r)}))}#_(e){let t=this.#n;if(t?.phase!=="sharing"){if(!t||t.phase!=="complete"){let r=ne(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 o=ne(r);e.setAttr({shareStatus:o.status,shareError:o.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(o=>o===null?void 0:o.dispose(),o=>{if(o?.code!=="CANCELLED")throw o}).then(()=>{this.disposed||this.#n!==r||(this.#n=null,e.setAttr({...ne(t),recording:!1},!0,!0,!1))}).catch(o=>{!this.disposed&&this.#n===r&&(r.phase="failed",e.setAttr(ne(o),!0,!0,!1))}))}#v(e,t){if(this.#t)return;let r=new AbortController;this.#t=r;let o=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 i;if(t==="copy"){if(typeof o!="string")throw new TypeError("Clipboard text must be a string");await this.provider.copyText(o,r.signal),i={text:o}}else i=await this.provider.pasteText(r.signal);if(r.signal.aborted)return;if(typeof i?.text!="string")throw new TypeError("Invalid clipboard text from device provider");let a=new k;a.setItem("text",i.text),e.setValue(a,!0,{status:"success",error:null},!0,!1)}).catch(i=>{r.signal.aborted||e.setAttr(ne(i),!0,!0,!1)}).finally(()=>{this.#t===r&&(this.#t=null)})}#E(e){if(this.#a)return;let t=new AbortController;this.#a=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 o=new k;o.setItem("duration",r),o.setItem("acknowledged",!0),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(o=>{t.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#a===t&&(this.#a=null)})}#k(e){if(this.#a)return;let t=new AbortController;this.#a=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 o=new k;o.setItem("style",r),o.setItem("acknowledged",!0),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(o=>{t.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#a===t&&(this.#a=null)})}#S(e){if(this.#o)return;let t=new AbortController;this.#o=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 o=new k;o.setItem("text",r.text),o.setItem("format",r.format),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setAttr(ne(r),!0,!0,!1)}).finally(()=>{this.#o===t&&(this.#o=null)})}#T(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(o=>{if(r.signal.aborted)return;if(typeof o?.url!="string"||!o.url||typeof o.format!="string"||!o.format)throw new TypeError("Invalid camera photo from device provider");let i=new k;i.setItem("url",o.url),i.setItem("format",o.format),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(o=>{r.signal.aborted||e.setAttr(ne(o),!0,!0,!1)}).finally(()=>{this.#r===r&&(this.#r=null)})}#C(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 k;r.setItem("verified",!0),e.setValue(r,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setValue(null,!0,ne(r),!0,!1)}).finally(()=>{this.#l===t&&(this.#l=null)})}#A(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 o=new k;for(let i of["id","title","body"])o.setItem(i,r[i]);r.kind==="action"&&o.setItem("actionId",r.actionId),e.staticValue.setItem(r.kind,o)}catch(o){e.setAttr({listenerError:ne(o).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 o=t.controller.signal.aborted;t.controller.abort(),this.#u===t&&(this.#u=null),o||e.setAttr({listening:!1,listenerError:ne(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"),o=r instanceof k?Object.fromEntries(["id","title","body","delay"].map(i=>[i,r.getItem(i)])):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"),!o||!Number.isInteger(o.id)||o.id<1||o.id>2147483647||typeof o.title!="string"||!o.title.trim()||typeof o.body!="string"||!o.body.trim()||typeof o.delay!="number"||!Number.isFinite(o.delay)||o.delay<=0)throw new TypeError("Notification requires a positive 32-bit id, title, body and positive delay in seconds");if(await this.#A(e),!t.signal.aborted)return this.provider.scheduleNotification(o,t.signal)}}).then(i=>{if(t.signal.aborted)return;if(i?.id!==o.id||typeof i.at!="number"||!Number.isFinite(i.at))throw new TypeError("Invalid notification scheduling acknowledgement");let a=new k;a.setItem("id",i.id),a.setItem("at",i.at),e.staticValue.setItem("scheduled",a),e.setAttr({status:"success",error:null},!0,!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(ne(i),!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 k;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(ne(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 o=new k;for(let i of r){if(typeof t[i]!="string")throw new TypeError(`Invalid push event ${i}`);o.setItem(i,t[i])}e.staticValue.setItem(t.kind,o)}}#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(o){e.setAttr({listenerError:ne(o).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 o=t.controller.signal.aborted;t.controller.abort(),this.#f===t&&(this.#f=null),o||e.setAttr({listening:!1,listenerError:ne(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(ne({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(ne(r),!0,!0,!1))})}#R(e){let t={controller:new AbortController};this.#p=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startShortcutEvents((r,o=null)=>{if(!t.controller.signal.aborted)try{if(o)throw o;for(let a of["id","destination"])if(typeof r?.[a]!="string"||!r[a])throw new TypeError(`Invalid shortcut request ${a}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let i=new k;i.setItem("id",r.id),i.setItem("destination",r.destination),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",i)}catch(i){e.setAttr({listenerError:ne(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 o=t.controller.signal.aborted;t.controller.abort(),o||e.setAttr({listening:!1,listenerError:ne(r).error},!0,!0,!1)})}#B(e){let t={controller:new AbortController};this.#h=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startLinkEvents((r,o=null)=>{if(!t.controller.signal.aborted)try{if(o)throw o;for(let a of["id","url"])if(typeof r?.[a]!="string"||!r[a])throw new TypeError(`Invalid link request ${a}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let i=new k;i.setItem("id",r.id),i.setItem("url",r.url),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",i)}catch(i){e.setAttr({listenerError:ne(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 o=t.controller.signal.aborted;t.controller.abort(),o||e.setAttr({listening:!1,listenerError:ne(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"],o=e.name==="appinfo"?"string":"number";for(let l of r)if(typeof t[l]!==o||o==="number"&&!Number.isFinite(t[l]))throw new TypeError(`Invalid ${e.name}.${l} from device provider`);let i=e.cachedValue;if(e.name==="location"&&i&&t.timestamp<i.getItem("timestamp")){this.attributes(e,{status:"success",error:null});return}let a=new k;for(let l of r)a.setItem(l,t[l]);e._lastUpdate=Date.now(),e.failed=!1,e.received++;let s=e.writing;e.writing=!0;try{e._node.setValue(a,!0,{status:"success",error:null},!0,!1)}finally{e.writing=s}}failure(e,t){e.failed=!0,this.attributes(e,ne(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,o)=>{if(!(this.disposed||this.monitor!==t))if(o)this.failure(e,o);else try{this.accept(e,r)}catch(i){this.failure(e,i)}},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=(i,a=null)=>{this.disposed||t.setAttr({status:i,error:a},!0,!0,!1)};if(!this.provider.capabilities.includes("database")){let i=Object.assign(new Error("Native database unavailable"),{code:"UNAVAILABLE"});throw r("unavailable",{code:i.code,message:i.message}),i}let o={controller:new AbortController,close:null,start:null};this.#e=o,r("pending"),o.start=this.provider.openDatabase(e,o.controller.signal);try{let i=await o.start,a=!1,s=null,l=()=>s||(a=!0,s=i.close().then(()=>{r("closed")},c=>{throw r("error",{code:"FAILED",message:c.message}),c}).finally(()=>{this.#e===o&&(this.#e=null)}),s);if(o.close=l,this.disposed||o.controller.signal.aborted)throw await l(),Object.assign(new Error("Page closed"),{code:"CANCELLED"});let u=async(c,d,f)=>{if(this.assertLive(),a)throw new Error("Database connection is closed");r("pending");try{let h=await i[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(i){throw this.#e===o&&(this.#e=null),this.disposed||t.setAttr(ne(i),!0,!0,!1),i}}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.#s.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.#a?.abort(),this.#a=null;let o=[...this.#i.values()];this.#i.clear();for(let c of o)c.controller.abort();let i=this.#h;this.#h=null,i?.controller.abort();let a=this.#p;this.#p=null,a?.controller.abort(),this.#x()?.controller.abort();let s=this.#f;this.#f=null,s?.controller.abort(),this.#o?.abort(),this.#o=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(()=>{})),s&&(this.cleanup=Promise.all([this.cleanup,s.start.then(c=>c(),()=>{})]).then(()=>{})),i&&(this.cleanup=Promise.all([this.cleanup,i.start.then(c=>c(),()=>{})]).then(()=>{})),a&&(this.cleanup=Promise.all([this.cleanup,a.start.then(c=>c(),()=>{})]).then(()=>{})),this.cleanup=Promise.all([this.cleanup,...t,...o.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 om=2e3;function p2(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 Li=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof k))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],r=(o,i)=>{for(let a of o.getNodes()){let s=i+a.label;a.value instanceof k?r(a.value,`${s}.`):t.push(`${s}: ${p2(a.value)}`)}};return r(this.branch(e),""),t.join(`
|
|
203
|
+
`)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>om)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${r.length} characters long, over the mailto: limit of ${om}; 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)),o=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(!o.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${o.status}`);return o}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,o)=>{let i=()=>o(new this.document.defaultView.DOMException("File selection cancelled","AbortError"));t.addEventListener("cancel",i,{once:!0}),t.addEventListener("change",async()=>{if(t.removeEventListener("cancel",i),!t.files.length){i();return}try{let a=j(await t.files[0].text());if(!(a instanceof k))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,a),r(a)}catch(a){o(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${a.message}`,{cause:a}))}},{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 o=this.branch(e);if(r==="json")this.saveText(o.toJson(!1),t,"application/json");else{let i=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
|
|
204
|
+
<${i}>${o.toXml()}</${i}>`,t,"application/xml")}}async copyText(e){if(typeof e!="string")throw new TypeError("gramlot.utl.inout.copyText: text must be a string");await this.document.defaultView.navigator.clipboard.writeText(e)}saveText(e,t,r){let o=this.document.defaultView,i=o.URL.createObjectURL(new o.Blob([e],{type:r}));this.open(i,t),o.setTimeout(()=>o.URL.revokeObjectURL(i),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var Fi=class extends Je{constructor(e,t){super(e),this.inout=new Li(e,t)}};var ji=class{#e;#t;constructor({pageId:e,uploadUrl:t=null,rpcUrl:r="/gramlot/rpc",closeUrl:o="/gramlot/close",rootId:i="gramlot-root",capabilities:a=[],element:s=null,document:l=s?.ownerDocument??globalThis.document,transport:u=null,collections:c=[],locale:d=null,timeZone:f=null,devices:h=[],serverAdapter:p=new lr,nameSyntax:m=null,websocketUrl:w=null}={}){this.#t=[ds,...c.filter(_=>_ instanceof Tr)],this.registerDocument(l),this.commands=new No,this.pageId=e,this.uploadUrl=t;let b=d==null||f==null?l.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...h]),this.locale=d??b.locale,this.timeZone=f??b.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Us(this)}),this.capabilities=Object.freeze([...a]),this.serverAdapter=p,this.src=new $i(this,{collections:c,destination:s??l.getElementById(i),subscriptions:this._subscriptions,nameSyntax:m===null?bi:on.fromJSON(m)}),this.#e=Co.install({document:l,root:this.src.renderer.destination}),this.data=this.src.builder.data,this.dvc=new Pi(this),this.dom=new Mi(this),this.utl=new Fi(this,l),this.state="ready",this.abort=new AbortController,Object.defineProperty(this,"_frames",{value:new ns(this,l)}),w!==null&&(this._pageStore=new rs(this,w,l)),this.rpc=new gi(this,{rpcUrl:r,closeUrl:o,document:l,transport:u}),this._frames.connect(),this.rpc.transport&&(this.pagehide=_=>{_.persisted||this.dispose()},l.defaultView.addEventListener("pagehide",this.pagehide),this.window=l.defaultView)}publish(e,t={}){return this._subscriptions.publish(e,t)}registerDocument(e){for(let t of this.#t)t.register(e.defaultView)}subscribe(e,t){return this._subscriptions.subscribe(e,t)}unsubscribe(e){this._subscriptions.unsubscribe(e)}format(e,t){return ls(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 cc=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new lr}async run(){let{config:e,resources:t,document:r}=this,o=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let i=!1,a,s,l=[],u=new Promise(d=>{a=d}),c=d=>{if(!(d.persisted||i)){i=!0;try{this.closePage()}finally{a(null)}}};o.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((y,E)=>{let S=r.createElement("link");S.rel="stylesheet",S.href=_;let x=()=>{S.removeEventListener("load",N),S.removeEventListener("error",O)};l.push(x);let N=()=>{x(),y()},O=()=>{x(),E(new Error(`${_}: stylesheet load failed`))};S.addEventListener("load",N),S.addEventListener("error",O),r.head.append(S)})),f=t.js.map(async({url:_,group:y})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:y,resource:_}}catch(E){throw new Error(`${_}: import failed: ${E.message}`,{cause:E})}}),h=new Set,p=(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:y,url:E,buildId:S}=_,x;try{x=await import(new URL(E,r.baseURI).href)}catch(N){throw new Error(`${y}: collection import failed: ${N.message}`,{cause:N})}if(x.default?.name!==y||x.buildId!==S)throw new Error(`${y}: collection identity mismatch; expected ${S}, received ${x.buildId}`);return x.default}),m=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(p)]),u]);if(i)return null;let[,w,b]=m;bo.check(w);for(let _ of b)_.register(o);s=new ji({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...b.map(_=>_.toDocument())]}),o.removeEventListener("pagehide",c);for(let _ of b)_.registerCommands(s);for(let{logicClass:_,group:y,resource:E}of w)s.src.logicRegistry.register(_,{group:y,resource:E});return o.gramlot=s,await s.start(),s}catch(d){throw s?s.dispose():i||this.closePage(),d}finally{for(let d of l)d();o.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 zs=Symbol("gramlot.source"),Hs=Symbol("gramlot.endpoint"),qi=Symbol("gramlot.upload"),m2=new Map([[zs,"registerSource"],[Hs,"registerEndpoint"],[qi,"registerUpload"]]);function dc(n,e,t,r){let o=m2.get(t);if(e==="main")throw new TypeError(`${o} cannot declare main`);let i=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof i!="function")throw new TypeError(`${o} requires an own method of ${n.name}: ${String(e)}`);if(i[t])throw new TypeError(`${t===zs?"Source method":t===Hs?"Endpoint":"Upload operation"} already registered: ${e}`);if([zs,Hs,qi].some(a=>i[a])){let a=t!==qi&&!i[qi]?`${e} is declared both as Source method and endpoint`:`${e} has conflicting declarations`;throw new TypeError(a)}i[t]={auth:r}}var Gs=class{static registerSource(e,{auth:t=null}={}){dc(this,e,zs,t)}static registerEndpoint(e,{auth:t=null}={}){dc(this,e,Hs,t)}static registerUpload(e,{auth:t=null}={}){dc(this,e,qi,t)}},Ui=class extends Gs{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 wo=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 o of["top","bottom","left","right","center"])if(this[o]!==void 0){let i=r.contentPane({region:o,node_label:o});this[o](i)}this.behavior(t)}center(e){}behavior(e){}};var Vi=class extends wo{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:r}=this.constructor;if(!(t instanceof k))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 k}),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})}};Vi.registerSource("index_panel");function fc(n,e,t=()=>{},r=()=>{},{state:o=e.getRelativeData("."),createEntry:i=null,onLoad:a=()=>{}}={}){let s=o.getItem("navigation");if(!(s instanceof k))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=o.getItem("opened");for(let x of f.getNodes()){let{url:N,path:O,title:$}=x.attr,K=l.value.getNode(x.label),W={url:N,path:O,title:$,pane:K,node:s.getNode(O),loading:!1};r(W),c.set(N,W),d.sequence++}let h=(x,N,O)=>{try{a(x.url,N,O)}catch($){n.binding.reportError($,"Page load callback failed")}},p=(x,N,O)=>{x.loading&&(x.loading=!1,h(x,N,O))},m=x=>{if(!d.disposed){d.selecting=!0;try{o.setItem("active",x.url),o.setItem("navigationSelection",x.path),t(c,x.url)}finally{d.selecting=!1}}};function w(x){b(x).catch(N=>{d.disposed||n.binding.reportError(N,"Page could not be opened")})}async function b(x){let N=s.getNode(x);if(!N)throw new Error(`Unknown index navigation path: ${x}`);let O=N.attr.url;if(O==null)return;if(typeof O!="string"||!O)throw new TypeError("IndexPage URL must be nonempty text");d.requested=O;let $=c.get(O);if($){$.path=x,m($);return}for(;l.value!==null&&l.value.getNode(`page${d.sequence}`);)d.sequence++;let K=ie(u.wrapSource(l).contentPane({node_label:`page${d.sequence++}`,title:N.attr.title??N.label,pageName:O,height:"100%",closable:!0})),W=o.getItem("active");$={url:O,path:x,node:N,pane:K,title:N.attr.title??N.label,loading:!0},c.set(O,$);try{if(h($,"loading"),d.disposed||c.get(O)!==$||(m($),d.disposed||c.get(O)!==$))return;if(i)await i($);else{let se=new k;if(se.setItem(N.label,null,{...N.attr}),!await n.binding.gramlot.src.remoteSource(K,"index_panel",{selection:se}))throw new Error("Panel loading was cancelled")}if(d.disposed||c.get(O)!==$)return;f.setItem(K.label,null,{url:O,path:$.path,title:$.title}),r($)}catch(se){if(d.disposed||c.get(O)!==$)return;try{if(n.binding.reportError(se,"Page could not be opened"),c.delete(O),f.getNode(K.label)&&f.popNode(K.label),K.parentBag&&K.parentBag.popNode(K.label),!d.disposed&&d.requested===O){let me=c.get(W);if(d.requested=me?.url??null,me)m(me);else{d.selecting=!0;try{o.setItem("active",null),o.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}}finally{p($,"error",se)}return}d.disposed||c.get(O)!==$||(p($,"ready"),!d.disposed&&c.get(O)===$&&d.requested===O&&m($))}let _=`${e.getAttr("id")}-page-close`;e.value.subscribe(_,{any:x=>{if(x.evt!=="del")return;let N=[...c.values()].find(K=>K.pane===x.node);if(!N)return;let{url:O,pane:$}=N;if(!(d.disposed||n.disposed||c.get(O)!==N)){c.delete(O),f.getNode($.label)&&f.popNode($.label);try{if(o.getItem("active")===O){let K=[...c.values()].at(-1);if(d.requested=K?.url??null,K)m(K);else{d.selecting=!0;try{o.setItem("active",null),o.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}else t(c,o.getItem("active"))}finally{p(N,"cancelled")}}}});let y=`${e.getAttr("id")}-selection`;o.subscribe(y,{any:x=>{if(!(d.selecting||d.disposed)){if(x.node===o.getNode("navigationSelection")){let N=o.getItem("navigationSelection");N!==null&&w(N)}else if(x.node===o.getNode("active")){let N=c.get(o.getItem("active"));N&&(d.requested=N.url,m(N))}}}});let E=()=>{if(!d.disposed){d.disposed=!0,o.unsubscribe(y,{any:!0}),e.value.unsubscribe(_,{any:!0});for(let x of c.values())x.loading&&(x.pane.parentBag&&x.pane.parentBag.popNode(x.pane.label),p(x,"cancelled"));c.clear(),e.indexContext===d&&delete e.indexContext}};d.dispose=E,n.onDispose(e,E);let S=c.get(o.getItem("active"));return S?m(S):o.getItem("navigationSelection")!==null&&w(o.getItem("navigationSelection")),d}var Ws=class{indexMount(e){fc(this.page.src.renderer,e.parentNode)}};function Ys(n,{datapath:e,value:t,language:r="text",height:o="420px",...i}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let a=n.borderContainer({datapath:e,height:o,class:"gramlot-editor-options"}),s={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(s))a.dataSetter({destination_path:`.settings.${d}`,value:f});let l=a.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 a.contentPane({region:"center",min_height:0}).codeMirror({...i,value:t,height:"100%",...Object.fromEntries(Object.keys(s).map(d=>[d,`^.settings.${d}`]))}),a}var zi=class n extends At{static internalParams=new Set([...At.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:o}){super({cacheTime:-1,onError:o}),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:o}=e,i,a=new Promise((s,l)=>{i=()=>l(o.reason),o.addEventListener("abort",i,{once:!0})});try{let s=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:o}),a]);if(o.aborted)throw o.reason;return s}finally{o.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof k))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 o=new zi({gramlot:this.gramlot,root:r.root,onError:a=>this.state.setItem("status",a.message)}),i=o.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=o,this.state.setItem("selectedPath",null),this.state.setItem("store",i),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()}},bn=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 im(n,{datapath:e,...t}){let r=n.div({datapath:e,class:"gramlot-filesystem",...t});return r.dataSetter({destination_path:".store",value:new k}),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 g2=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Xs=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=g2(e,t),o=this.documents.getNodes().find(s=>!s.value.getItem("isNew")&&s.value.getItem("root")===e&&s.value.getItem("path")===t);if(o)return o.label;if(this.pending.has(r))return this.pending.get(r).promise;let i=new AbortController,a=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:i.signal}).then(s=>{if(this.disposed||i.signal.aborted)return null;let l=new k;for(let[u,c]of Object.entries({...s,root:e,saved:s.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:i,promise:a}),a}newDocument(e,t,r=""){let o=`new_${ee()}`,i=new k;for(let[a,s]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}`}))i.setItem(a,s);return this.documents.setItem(o,i),o}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"),o=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==o.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let i=t.getItem("content"),a=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_create",{root:r,path:o,content:i},{signal:a.signal}).then(l=>this.disposed||a.signal.aborted?!1:(t.setItem("root",l.root),t.setItem("path",l.path),t.setItem("revision",l.revision),t.setItem("saved",i),t.setItem("isNew",!1),t.setItem("createHidden",!0),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:a,promise:s}),s}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"),o=new AbortController;t.setItem("busy",!0),t.setItem("rendering",!0),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generating Typst on the server\u2026");let i=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:o.signal}).then(a=>this.disposed||o.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",a.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(a=>(!this.disposed&&!o.signal.aborted&&t.setItem("renderStatus",a.message),!1)).finally(()=>{this.pending.delete(e),this.disposed||(t.setItem("rendering",!1),t.setItem("busy",!1))});return this.pending.set(e,{request:o,promise:i}),i}dirty(e){let t=this.documents.getItem(e);return t&&t.getItem("content")!==t.getItem("saved")}async save(e){let t=this.documents.getItem(e);if(!t||t.getItem("isNew")||!this.dirty(e)||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let i=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:o.signal}).then(a=>this.disposed||o.signal.aborted?!1:(t.setItem("revision",a.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:o,promise:i}),i}revert(e){let t=this.documents.getItem(e);return!t||!this.dirty(e)||this.pending.has(e)?!1:(t.setItem("content",t.getItem("saved")),!0)}canClose(e,t=!1){return!this.pending.has(e)&&(t||!this.dirty(e))}close(e,t=!1){return this.canClose(e,t)?(this.documents.popNode(e),this.state.getItem("active")===e&&this.state.setItem("active",this.documents.getNodes()[0]?.label??null),!0):!1}dispose(){this.disposed=!0;for(let{request:e}of this.pending.values())e.abort()}},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 k;return e.forEach((r,o)=>t.setItem(`r${o}`,r,{caption:r})),t}};function ut(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 Ks=class{fileSystemMount(e){return bn.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return bn.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){let t=e.parentNode,r={scope:t,documents:new Xs(this.page,t),requested:0,editorPrefix:`ide_${ee()}`,recent:new Zs(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage)};Object.defineProperty(t,"ideContext",{value:r,configurable:!0});let{documents:o,recent:i}=r,a=t.getRelativeData("."),s=i.read();a.setItem("recent",i.choices(s)),a.setItem("workspace",s[0]??"");let l=a.getItem("browser");l.subscribe("ide-browser",{any:c=>{if(c.node===l.getNode("root")){let d=l.getItem("root");a.setItem("workspace",d),a.setItem("recent",i.choices(i.remember(d))),a.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=o.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=o.documents.getItem(f);h&&(c.node===h.getNode("content")&&o.invalidateRecipe(f),this.ideDocumentState(t,f),d.setAttr({title:`${o.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}),o.dispose()})}ideOpenWorkspace(e){let r=ut(e).scope.getRelativeData("."),o=r.getItem("workspace");o&&o!==r.getItem("browser.root")&&r.setItem("browser.requestedRoot",o)}ideDocumentState(e,t){let r=ut(e),{documents:o}=r,i=o.documents.getItem(t),a=!o.dirty(t)&&!i.getItem("isNew")||i.getItem("busy");i.setItem("saveDisabled",!!(a||!i.getItem("writable"))),i.setItem("revertDisabled",!!(!o.dirty(t)||i.getItem("busy"))),i.setItem("displayPath",i.getItem("isNew")?i.getItem("path"):`${i.getItem("root")}/${i.getItem("path")}`),i.setItem("pdfFilename",i.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),i.setItem("renderDisabled",!!(i.getItem("busy")||!i.getItem("writable"))),this.ideHistoryState(i)}async ideOpenDocument(e,t,r){let o=ut(e),{documents:i}=o,a=o.scope.getRelativeData("."),s=++o.requested;try{let l=await i.open(t,r);if(l===null||i.disposed)return;this.ideShowDocument(e,l),s===o.requested&&(a.setItem("active",l),a.setItem("status",`${r}${i.documents.getItem(l).getItem("writable")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}catch(l){i.disposed||a.setItem("status",l.message)}}ideNew(e){let t=ut(e),{documents:r}=t,o=t.scope.getRelativeData("."),i=o.getItem("newType"),a=i==="typstRecipe"?"python":i,s={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(a,s[i],o.getItem("workspace"));r.documents.getItem(l).setItem("writable",o.getItem("browser.writable")===!0),++t.requested,this.ideShowDocument(e,l),o.setItem("active",l),o.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e,t){let r=ut(e),{documents:o}=r,a=o.documents.getItem(t).getItem("path"),s=r.scope.value.getNode("frame.center.tabs");if(!s.value?.getNode(t)){let l=o.documents.getItem(t),u=a.endsWith(".typ.py");u&&o.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=ie(s.builder.wrapSource(s).contentPane({node_label:t,title:a,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 ${a}`});for(let[x,N,O,$]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 K=f.button({title:O,"aria-label":O,disabled:`^.${x}Disabled`,class:`button--quiet gramlot-ide-${x}`});K.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:N}),K.dataController({func:$,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 p=d.div({flex:"1",min_height:0}),m=l.getItem("language")==="html",w=l.getItem("language")==="markdown",b=m||w,_=l.getItem("language")==="typst",y=b||_||u,E=y?p.tabContainer({height:"100%",selectedPage:`^.documents.${t}.view`}):null,S=y?E.contentPane({title:"Code",pageName:"code",height:"100%"}):p;if(Ys(S,{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 x=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});x.div(`^.documents.${t}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),x.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(b){let x=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});w&&(l.setItem("allowHtml",!1),x.checkbox({value:`^.documents.${t}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),x[m?"htmlPreview":"markdownPreview"]({value:`^.documents.${t}.content`,flex:"1",min_height:0,...w?{allowHtml:`^.documents.${t}.allowHtml`}:{}}),E.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[m?"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=ut(e),{documents:o}=r;o.documents.getItem(t).setItem("view","preview"),await o.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){let r=ut(e),{documents:o}=r;o.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData(".");i.setItem("status","Creating file\u2026");try{let a=await o.create(t);if(!o.disposed&&a){i.setItem("status","File created.");let s=i.getItem("browser");s.getItem("root")&&await r.scope.value.getNode("frame.left.browser").fileSystemController.open(s.getItem("root"))}}catch(a){o.disposed||i.setItem("status",a.message)}}async ideSave(e,{documentKey:t=null}={}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData("."),a=t??i.getItem("active");if(!a||o.documents.getItem(a).getItem("saveDisabled"))return;let s=o.documents.getItem(a);if(s.getItem("isNew")){s.setItem("createHidden",!1);return}i.setItem("status","Saving\u2026");try{let l=await o.save(a);o.disposed||i.setItem("status",l?"Saved.":"Document is read only or a request is pending.")}catch(l){o.disposed||i.setItem("status",l.message)}}ideRevert(e,{documentKey:t}){let r=ut(e),{documents:o}=r,i=r.scope.getRelativeData(".");o.revert(t)&&i.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let o=e.getRelativeData("."),i=e.getAttr("editorView");o.setItem(`${i}CanUndo`,t),o.setItem(`${i}CanRedo`,r),this.ideHistoryState(o)}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=ut(e),{documents:o}=r,i=o.documents.getItem(t).getItem("view")==="rich",a=this.page.src.binding.nodeIds.get(`${r.editorPrefix}_${i?"rich_":""}editor_${t}`);return this.page.src.renderer.records.get(a).element}ideUndo(e,{documentKey:t}){this.ideEditor(e,t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(e,t).redo()}ideClose(e){let t=ut(e),{documents:r}=t,o=t.scope.getRelativeData("."),i=e.getAttr("documentKey");return r.canClose(i)?!0:(o.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 o=ut(e),{documents:i}=o,a=o.scope.getRelativeData("."),s=i.documents.getItem(t),l=a.getItem("browser"),u=l.getItem("selectedPath"),c=u===null?null:l.getItem("store").getNode(u);s&&l.getItem("root")===s.getItem("root")&&c?.attr.path===s.getItem("path")&&l.setItem("selectedPath",null),i.close(t,r)}};var Rr=class extends de{constructor({readOnly:e=!1}={}){super({cacheTime:-1,readOnly:e}),this.store=null,this.path=null,this.pending=null}bind(e,t){if(this.store!==null)throw new Error("TreeStoreResolver is already bound");this.store=e,this.path=t}load(){if(this.store===null)throw new Error("TreeStoreResolver is not bound to a store");if(this.pending!==null)return this.pending;let e=this.node,t=this.path?this.store.pathFor(e):"",r=this.store.load(t,t?e.label:null,t?{...e.attr}:{});return this.pending=r,r.finally(()=>{this.pending===r&&(this.pending=null)}).catch(()=>{}),r}};Ru(Rr,{module:"gramlot.tree_store",name:"TreeStoreResolver",encode:()=>({args:[],kwargs:{}}),decode:()=>new Rr});var Gi=class{constructor({gramlot:e,method:t,params:r={}}){if(!e||typeof t!="string"||!t)throw new TypeError("TreeStore requires a page and method");for(let o of["path","label","attributes"])if(Object.hasOwn(r,o))throw new TypeError(`TreeStore params reserves ${o}`);this.gramlot=e,this.method=t,this.params={...r},this.controller=new AbortController,this.root=null}pathFor(e){let t=[];for(;e&&e.parentBag!==this.root;)t.unshift(e.label),e=e.parentNode;if(!e||this.root===null)throw new Error("TreeStore node is outside its root");return t.unshift(e.label),t.join(".")}async load(e="",t=null,r={}){if(this.controller.signal.aborted)throw this.controller.signal.reason;let o=await this.gramlot.rpc.call("data",this.method,{...this.params,path:e,label:t,attributes:r},{signal:this.controller.signal});if(this.controller.signal.aborted)throw this.controller.signal.reason;if(!(o instanceof k))throw new TypeError("TreeStore method must return a Bag");e||(this.root=o,o.setBackref());let i=(a,s)=>{for(let l of a.getNodes()){let u=s?`${s}.${l.label}`:l.label;l.resolver instanceof Rr&&l.resolver.bind(this,u),l.staticValue instanceof k&&i(l.staticValue,u)}};return i(o,e),o}dispose(){this.controller.abort()}},Js=class{treeFavoriteActionState(e,{item:t,state:r}){let o=t.resolver!==null||t.staticValue instanceof k;if(t.getAttr("favoriteEntry")===!0)return{hidden:!1,icon:"\u2715",title:"Remove favorite"};let i=!o&&r.getNodes().some(a=>a.getAttr("fieldpath")===t.getAttr("fieldpath"));return{hidden:o,icon:i?"\u2665":"\u2661",title:i?"Remove favorite":"Add favorite"}}treeFavoritesMount(e,{favoriteKey:t}){let o=this.page.src.renderer.destination.ownerDocument.defaultView.localStorage.getItem(t);this.setTreeFavorites(e.getRelativeData("."),o===null?[]:j(o))}setTreeFavorites(e,t){if(!Array.isArray(t))throw new TypeError("Tree favorites must be an array");let r=new k;t.forEach((o,i)=>{if(!o||typeof o.fieldpath!="string"||typeof o.path!="string"||typeof o.caption!="string"||!o.attrs||typeof o.attrs!="object")throw new TypeError("Invalid tree favorite");let a={...o.attrs};for(let s of["caption","fullcaption"])typeof a[s]=="string"&&(a[s]=a[s].replace(/(^|\.)!!(?:\[[^\]]+\])?/g,"$1"));r.setItem(`favorite_${i}`,null,{...a,favoriteEntry:!0,originalPath:o.path})}),e.setItem("favorites",r)}treeFavoriteToggle(e,{item:t,path:r,favoriteKey:o}){if(t.resolver||t.staticValue instanceof k)return;let i=t.getAttr(),a=e.getRelativeData("."),s=a.getItem("favorites").getNodes().map(c=>{let{favoriteEntry:d,originalPath:f,...h}=c.getAttr();return{fieldpath:h.fieldpath,path:f,caption:h.caption,attrs:h}}),l=s.findIndex(c=>c.fieldpath===i.fieldpath);l===-1?s.push({fieldpath:i.fieldpath,path:r,caption:i.caption,attrs:{...i}}):s.splice(l,1),this.page.src.renderer.destination.ownerDocument.defaultView.localStorage.setItem(o,L(s)),this.setTreeFavorites(a,s)}treeStoreMount(e,{storeMethod:t,storeParams:r}){let o=e.parentNode,i=e.getRelativeData("."),a=new Gi({gramlot:this.page,method:t,params:r});this.page.src.renderer.onDispose(o,()=>a.dispose());let s=new Rr({readOnly:!0});return s.bind(a,""),i.setResolver("store",s),Promise.resolve(i.getItem("store")).then(l=>{a.controller.signal.aborted||i.setItem("store",l)})}treeInspect(e,{item:t,path:r}){let o=this.page.src.binding.bindingFor(e),i=!1,a=`tree_inspect_${ee()}`,s=()=>{},l=()=>{i||(i=!0,s(),this.page.src.source.getNode(a)&&this.page.src.source.popNode(a))};s=o.track(l);try{let u=new Oe,c=u.root.html_dialog({nodeId:a,request:a,connect_oncancel:"treeInspectClose",connect_onclose:"treeInspectClose","aria-labelledby":`${a}_title`,style:"width:min(36rem,calc(100% - 48px));max-height:80vh;overflow:auto;"});c.h2("Attributes",{id:`${a}_title`}),c.p(`==${JSON.stringify(r)}`),c.html_button("Close",{type:"button",autofocus:!0,request:a,connect_onclick:"treeInspectClose"});let d=c.table();for(let[h,p]of Object.entries(t.getAttr())){let m=d.tr();m.th(`==${JSON.stringify(h)}`,{scope:"row"});let w=typeof p=="string"?p:p===void 0?"undefined":L(p);m.td(`==${JSON.stringify(w)}`)}this.page.src.source.setItem(a,this.page.src.prepareSource(u.source));let f=this.page.src.binding.nodeIds.get(a);Object.defineProperty(f,"treeInspectClose",{value:l,configurable:!0}),this.page.src.renderer.onDispose(f,()=>{l(),delete f.treeInspectClose}),this.page.dom.getDomNode(f).showModal()}catch(u){throw l(),u}}treeInspectClose(e,t){t.preventDefault();let r=this.page.src.binding.nodeIds.get(e.getAttr("request"));r&&r.treeInspectClose()}};var _o=class{constructor({maxBytes:e}){if(!Number.isSafeInteger(e)||e<0)throw new TypeError("maxBytes must be a nonnegative safe integer");this.maxBytes=e}write(e){throw new Error("UploadTarget.write must be implemented")}finish(){throw new Error("UploadTarget.finish must be implemented")}abort(){throw new Error("UploadTarget.abort must be implemented")}status(){throw new Error("UploadTarget.status must be implemented")}};var b2=new Set(Object.entries(new qt().schema).filter(([,n])=>!n._meta?.data_element&&!n._meta?.subbuilder&&!n._meta?.container).map(([n])=>n));function yo(n){if(!(n==null||n==="html")){if(!Array.isArray(n)||n.some(e=>typeof e!="string"||!e||e.trim()!==e))throw new TypeError('catalogue must be "html" or a list of tag names');if(!n.includes("div"))throw new Error("catalogue must include div for pageRoot")}}function vo(n,e,t={}){return n==null?!0:Array.isArray(n)?n.includes(e):!t.gramlot_component&&!t.data_element&&!t.subbuilder&&!t.container&&b2.has(t.render_tag??e)}function Dt(n,e){if(n==null)return;let t=(r,o)=>{for(let i of r.getNodes()){let a=o?`${o}.${i.label}`:i.label;if(!vo(n,i.nodeTag,i.getAttr("_meta")??{}))throw new Error(`Tag ${i.nodeTag} is outside the editor catalogue at ${a}`);if(i.resolver)throw new Error(`Catalogue scope requires materialized Source at ${a}`);let s=i.getValue(!0);s instanceof I&&t(s,a)}};t(e,"")}var We={navigation:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M9%204v16M5.5%208h1M5.5%2012h1%22%2F%3E%3C%2Fsvg%3E",catalogue:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2214%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M14%2017.5h7M17.5%2014v7%22%2F%3E%3C%2Fsvg%3E",properties:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3Ccircle%20cx%3D%228%22%20cy%3D%226%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2212%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2218%22%20r%3D%222%22%2F%3E%3C%2Fsvg%3E",new:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%202H6a2%202%200%200%200-2%202v16a2%202%200%200%200%202%202h12a2%202%200%200%200%202-2V8Z%20M14%202v6h6%20M8%2015h8%20M12%2011v8%22%2F%3E%3C%2Fsvg%3E",download:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5%20M4%2016v4a1%201%200%200%200%201%201h14a1%201%200%200%200%201-1v-4%22%2F%3E%3C%2Fsvg%3E",copy:"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%228%22%20y%3D%228%22%20width%3D%2212%22%20height%3D%2213%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M16%208V5a2%202%200%200%200-2-2H5a2%202%200%200%200-2%202v9a2%202%200%200%200%202%202h3%22%2F%3E%3C%2Fsvg%3E"};We.open="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207V5a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v2M3%209h18l-2%2011H4z%22%2F%3E%3C%2Fsvg%3E";We.cut="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%226%22%20cy%3D%226%22%20r%3D%223%22%2F%3E%3Ccircle%20cx%3D%226%22%20cy%3D%2218%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22m8%208%2012%2012M8%2016%2020%204%22%2F%3E%3C%2Fsvg%3E";We.paste="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%225%22%20y%3D%225%22%20width%3D%2214%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%222%22%20width%3D%226%22%20height%3D%225%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M9%2012h6m-6%204h6%22%2F%3E%3C%2Fsvg%3E";We.appearance="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%228%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.7%22%2F%3E%3Cpath%20d%3D%22M12%204a8%208%200%200%201%200%2016z%22%20fill%3D%22black%22%2F%3E%3C%2Fsvg%3E";var Qs=class{constructor(e,{datapath:t="__editor",dataRoot:r="",editorId:o="visual",uploadOperation:i="import_source",codeDocument:a=null,catalogue:s=null,fileCommands:l=!0,canvasCss:u=null,...c}={}){if(!/^[A-Za-z][A-Za-z0-9_]*$/.test(o))throw new Error("editorId must be a literal identifier");if(!r&&t!=="__editor"&&!t.startsWith("__editor."))throw new Error("Root Data editing requires an __editor datapath");if(yo(s),u!=null&&(!Array.isArray(u)||u.some(X=>typeof X!="string")))throw new TypeError("canvasCss must be a list of CSS texts");this.dataRoot=r;let d=this.pane=e.main({node_label:o,datapath:t,visualEditorId:o,...c,nodeId:`${o}Editor`,class:`visual-editor-shell ${c.class??""}`,overflow:"hidden",tabindex:0,connect_onkeydown:"clipboardShortcut"});d.dataSetter({destination_path:".catalogueScope",value:s}),d.dataSetter({destination_path:".canvasCss",value:u}),d.dataSetter({destination_path:".uploadQueue",value:new k}),d.dataController({func:"initializeEditor",dataRoot:this.dataRoot,_init:!0}),d.dataController({func:"showProperties",path:"^.selection",_init:!0}),d.dataController({func:"initializeCanvasSelection",_onBuilt:!0}),d.dataController({func:"initializeDocument",_onBuilt:!0}),d.dataController({func:"highlightSelection",path:"^.selection",_init:!0}),d.style("^.appearanceCss"),d.dataController({func:"initializeEditorAppearance",_onBuilt:!0}),d.dataController({func:"applyEditorAppearance",profile:"^.appearanceProfile",palette:"^.appearancePalette",mode:"^.appearanceMode"});let f=this.rail=d.menu({presentation:"bar",orientation:"vertical",aria_label:"Editor panels",class:"visual-editor-rail"});this.toolButton(f.menuline({group:!0,overflowable:!1}),"Source / Data","toggleNavigation",We.navigation),this.toolButton(f.menuline({group:!0,overflowable:!1}),"Catalogue","openCatalogue",We.catalogue),this.toolButton(f.menuline({group:!0,overflowable:!1}),"Properties","openProperties",We.properties),this.toolButton(f.menuline({group:!0,overflowable:!1}),"Clipboard","this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))",We.paste,{dropTarget:!0,dropTypes:"app/source",dropTags:`${o}Source`,dropEffect:"^.clipboardDropEffect",connect_ondragover:"clipboardModifiers",connect_ondrop:"clipboardModifiers",onDrop:"dropClipboard"}),f.spacer({flex:1}),this.toolButton(f.menuline({group:!0,overflowable:!1}),"Appearance","this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))",We.appearance);let h=d.framePane({node_label:"layout",height:"100%",id:`${o}-editor-frame`,class:"visual-editor-layout"});h.top.setAttr({height:"30px"});let p=h.top.menu({presentation:"bar",aria_label:"Editor tools",class:"visual-editor-toolbar"});p.menuline({group:!0,overflowable:!1}).span("Source editor",{class:"visual-editor-brand"});let m=p.menuline({group:!0,overflowable:!1,gap:"4px",hidden:!l});for(let[X,$e,zt]of[["New","newPage","new"],["Open","openUpload","open"],["Download","downloadPage","download"],["Copy Source","copySource","copy"]])this.toolButton(m,X,$e,We[zt],{id:`${o}-${zt}`});p.menuline({group:!0,overflowable:!1}).span({class:"visual-toolbar-divider",aria_hidden:"true"});let w=p.menuline({group:!0,overflowable:!1,gap:"2px"});this.toolButton(w,"Cut branch","cutBranch",We.cut,{title:"Cut branch (F8)"}),this.toolButton(w,"Copy branch","copyBranch",We.copy),this.toolButton(w,"Paste branch","pasteBranch",We.paste,{title:"Paste branch (F9)"}),p.spacer({flex:1}),p.menuline({group:!0,overflowable:!1,hidden:"^.modified:=!{}"}).span("Unsaved changes",{role:"status",class:"visual-editor-hint"}),p.menuline({group:!0,overflowable:!1}).span("^.fileStatus",{role:"status",class:"visual-editor-file-status"}),p.menuline({group:!0,overflowable:!1}).span("^.filename",{class:"visual-editor-filename"});let b=h.left;b.setAttr({width:"min(240px, 34vw)",splitter:!0,drawer:"^.navigationOpen",default_drawer:!0,drawer_label:"Source / Data",drawer_onclick:"this.SET('.navigationOpen', show ? true : 'close')",display:"flex",flex_direction:"column",min_height:0,class:"visual-editor-sidebar"});let _=b.borderContainer({height:"100%",flex:1,min_height:0}),y=_.contentPane({region:"center"}).borderContainer({height:"100%",min_height:0}),E=y.contentPane({region:"center"}).borderContainer({height:"100%",min_height:0}),S=E.contentPane({node_label:"source",region:"center",title:"Source",detachable:!0,display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"});this.search(S,"sourceSearch","Search Source"),S.tree({storepath:`*S.${ie(d).fullpath.split(".").slice(1).join(".")}.layout.center.design`,hideValues:!0,getLabel:"sourceLabel",searchText:"^.sourceSearch",selectedPath:"^.selection",draggable:!0,dragTags:`${o}Source`,effectAllowed:"all",onDrag:"prepareSource",dropTarget:!0,dropTypes:"app/widget,app/source,app/clipboard",dropTags:`widget,${o}Source,${o}Clipboard`,dropEffect:"^.sourceDropEffect",onDrop:"dropNode",id:`${o}-source-tree`,class:"visual-source-tree",flex:1,min_height:0});let x=E.contentPane({node_label:"clipboard",region:"bottom",height:"112px",splitter:!0,minSize:80,title:"Clipboard",detachable:!0,hidden:"^.clipboardVisible:=!{}",display:"flex",flex_direction:"column",min_height:0,overflow:"hidden",dropTarget:!0,dropTypes:"app/source",dropTags:`${o}Source`,dropEffect:"^.clipboardDropEffect",connect_ondragover:"clipboardModifiers",connect_ondrop:"clipboardModifiers",onDrop:"dropClipboard",class:"visual-clipboard"});x.span("Drop a branch here \xB7 Option to copy",{class:"visual-editor-hint"}),x.tree({storepath:".clipboard",hideValues:!0,labelAttribute:"name",selectedPath:"^.clipboardSelection",draggable:!0,dragTags:`${o}Clipboard`,effectAllowed:"copy",onDrag:"prepareClipboard",id:`${o}-clipboard-tree`,class:"visual-clipboard-tree",flex:1,min_height:0}),x.p("^.error",{role:"alert",class:"visual-editor-hint"});let N=y.contentPane({node_label:"data",region:"bottom",title:"Data",detachable:!0,height:"108px",splitter:!0,minSize:80,display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"});this.search(N,"dataSearch","Search Data"),N.tree({storepath:this.dataRoot?`*D.${this.dataRoot}`:"*D",excludeRoot:this.dataRoot?null:"__editor",searchText:"^.dataSearch",id:`${o}-data-tree`,flex:1,min_height:0});let O=h.center;O.setAttr({overflow:"auto",class:"visual-editor-workspace"});let $=O.div({node_label:"design",class:"visual-editor-canvas"});$.div({node_label:"pageRoot",...this.dataRoot?{datapath:this.dataRoot}:{}});let K=d.floatingPane({title:"Widget catalogue",open:"^.catalogueOpen",default_open:!1,width:"280px",height:"400px",class:"visual-editor-popup",movable:!0,resizable:!0});this.search(K.frame.top,"catalogueSearch","Search widgets"),K.frame.center.tree({storepath:".catalogue",hideValues:!0,labelAttribute:"caption",searchText:"^.catalogueSearch",draggable:!0,dragTags:"widget",effectAllowed:"all",onDrag:"prepareWidget",id:`${o}-widget-tree`});let W=_.contentPane({region:"bottom",height:"^.propertiesHeight",default_height:"200px",minSize:140,splitter:!0,title:"^.propertiesTitle",detachable:!0,hidden:"^.propertiesOpen:=!{}",display:"flex",flex_direction:"column",overflow:"hidden",min_height:0});W.div({nodeId:`${o}EditorFields`,class:"visual-editor-fields",display:"flex",flex_direction:"column",flex:1,min_height:0}).span(""),W.p("^.propertyError",{role:"alert",class:"visual-editor-hint",margin:"3px"}),d.dialog({class:"visual-editor-popup",title:"Open Source",open:"^.uploadOpen",width:"480px",height:"300px",movable:!0,resizable:!0}).frame.center.uploader({operation:i,storepath:".uploadQueue",accept:".grmlt",multiple:!1,autoUpload:!0,onComplete:"sourceUploaded",id:`${o}-uploader`});let me=d.dialog({class:"visual-editor-popup",title:"Save branch to clipboard",open:"^.clipboardOpen",width:"380px",height:"210px"});me.frame.center.textbox({value:"^.clipboardDraft.name",lbl:"Name",margin:"12px"}),me.frame.center.p("^.error",{role:"alert",margin:"12px"});let te=me.frame.bottom.menu({presentation:"bar",aria_label:"Clipboard commands",padding:"3px 6px"});te.spacer({flex:1});let le=te.menuline({group:!0,overflowable:!1,gap:"8px"});le.button("Cancel",{action:"this.SET('.clipboardOpen', false)"}),le.button("Save branch",{action:"saveClipboard"});let q=d.dialog({class:"visual-editor-popup",title:"Required parameters",open:"^.insertionOpen",width:"400px",height:"280px",movable:!0,resizable:!0});q.frame.center.div({nodeId:`${o}InsertFields`,class:"visual-editor-fields",padding:"6px"}).span(""),q.frame.center.p("^.error",{role:"alert"});let dt=q.frame.bottom.menu({presentation:"bar",aria_label:"Insertion commands",padding:"3px 6px",border_top:"1px solid var(--gramlot-border)"});dt.spacer({flex:1});let _n=dt.menuline({group:!0,overflowable:!1,gap:"8px"});_n.button("Cancel",{action:"this.SET('.insertionOpen', false)"}),_n.button("Insert",{action:"insertWidget"});let wt=d.floatingPane({class:"visual-editor-popup",title:"Appearance",open:"^.appearanceOpen",default_open:!1,width:"280px",height:"260px",movable:!0,resizable:!0}).frame.center.formlet({columns:1,lbl_position:"TL",gap:"4px",padding:"6px"});wt.filteringSelect({validate_notnull:!0,lbl:"Theme",value:"^.appearanceProfile",values:"base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela"}),wt.filteringSelect({validate_notnull:!0,lbl:"Colors",value:"^.appearancePalette",values:"default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue"}),wt.filteringSelect({validate_notnull:!0,lbl:"Mode",value:"^.appearanceMode",values:"light:Light,dark:Dark"}),d.p("^.error",{role:"alert",class:"visual-editor-error",hidden:"^.error:=!{}"}),this.frame=h,this.toolbar=p,this.design=$,a!==null&&this.codeDocument(a)}toolButton(e,t,r,o,i={}){let a=e.button({aria_label:t,title:t,action:r,class:"button--quiet visual-editor-tool",...i});return a.span({class:"visual-tool-icon",aria_hidden:"true",style:`mask-image:url("${o}")`}),a}codeDocument(e,t=this.frame){if(!["python","javascript"].includes(e.language))throw new TypeError("Expected a Python or JavaScript page document");let r=this.pane;r.setAttr({codeDocumentKey:e.key}),r.dataSetter({destination_path:".codeDocument",value:new k({...e,saved:e.content,busy:!1,status:""})});let o=`#${r.getAttr("visualEditorId")}Editor`;(t===this.frame?this.toolbar:t.top.menu({presentation:"bar",aria_label:"Code drawer"})).menuline({group:!0,overflowable:!1}).button("Code",{action:"openCode",class:"button--quiet"});let a=t.right;a.setAttr({class:"visual-editor-code",datapath:o,title:"Page code",detachable:!0,width:"60%",minSize:240,splitter:!0,drawer:"^.codeOpen",default_drawer:"close",drawer_label:"Code",drawer_minimize:!1,drawer_onclick:"this.SET('.codeOpen', show ? true : 'close')",min_height:0,overflow:"hidden"});let s=a.framePane({height:"100%",width:"100%",min_width:0,flex:1});s.top.setAttr({height:"26px"}),s.bottom.setAttr({height:"48px"}),s.center.setAttr({display:"flex",flex_direction:"column",min_height:0,overflow:"hidden"}),s.top.div(e.path,{padding:"3px 6px",font_size:"12px",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap"}),s.center.codeMirror({value:"^.codeDocument.content",language:e.language,live:!0,readonly:"^.codeDocument.writable:=!{}",height:"100%",box_height:"100%",box_c_height:"100%",box_min_height:0,box_c_min_height:0,fontSize:13,flex:1,min_height:0}),s.bottom.div("^.codeDocument.status",{role:"status",font_size:"12px",padding:"4px 10px"});let l=s.bottom.menu({presentation:"bar",aria_label:"Page code commands",padding:"3px 6px"});l.spacer({flex:1});let u=l.menuline({group:!0,overflowable:!1,gap:"6px"});u.button("Close",{action:"this.SET('.codeOpen', 'close')"}),u.button("Preview saved",{action:"codePreview",disabled:"^.codeDocument.busy"}),u.button("Save",{action:"codeSave",disabled:"^.codeSaveDisabled"}),r.dataFormula({result_path:".codeSaveDisabled",formula:"!writable || busy || content === saved",writable:"^.codeDocument.writable",busy:"^.codeDocument.busy",content:"^.codeDocument.content",saved:"^.codeDocument.saved",_init:!0})}search(e,t,r){let i=e.menu({presentation:"bar",aria_label:r,class:"visual-search-toolbar"}).menuline({group:!0,overflowable:!1,flex:1,min_width:0}).div({class:"visual-search-field"});i.span({class:"visual-search-icon",aria_hidden:"true"}),i.input({type:"search",value:`^.${t}`,default:"",live:!0,placeholder:r,aria_label:r}),i.html_button({type:"button",class:"visual-search-clear",aria_label:`Clear ${r.toLowerCase()}`,hidden:`^.${t}:={} === ''`,connect_onclick:`this.SET('.${t}', '')`})}};var el=class extends _o{constructor({catalogue:e=null}={}){super({maxBytes:5*1024*1024}),yo(e),this.catalogue=e,this.decoder=new TextDecoder("utf-8",{fatal:!0}),this.parts=[],this.outcome={state:"pending"}}write(e){this.parts.push(this.decoder.decode(e,{stream:!0}))}finish(){this.parts.push(this.decoder.decode());let e=this.parts.join("");this.parts=[];let t=j(e);if(!(t instanceof I)||t.length!==1||t.getNodes()[0].label!=="pageRoot")throw new TypeError("Expected one pageRoot Source");return Dt(this.catalogue,t),this.outcome={state:"completed",result:e},this.outcome}abort(){return this.outcome.state!=="completed"&&(this.parts=[],this.outcome={state:"unsaved"}),this.outcome}status(){return this.outcome}};function w2(n,e){this.v=n,this.k=e}function am(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t<e;t++)r[t]=n[t];return r}function _2(n){if(Array.isArray(n))return n}function y2(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,o,i,a,s=[],l=!0,u=!1;try{if(i=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=i.call(t)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,o=c}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}function v2(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
205
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function E2(n,e){return _2(n)||y2(n,e)||x2(n,e)||v2()}function x2(n,e){if(n){if(typeof n=="string")return am(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?am(n,e):void 0}}function tl(n){var e,t;function r(i,a){try{var s=n[i](a),l=s.value,u=l instanceof w2;Promise.resolve(u?l.v:l).then(function(c){if(u){var d=i==="return"&&l.k?i:"next";if(!l.k||c.done)return r(d,c);c=n[d](c).value}o(!!s.done,c)},function(c){r("throw",c)})}catch(c){o(2,c)}}function o(i,a){i===2?e.reject(a):e.resolve({value:a,done:i}),(e=e.next)?r(e.key,e.arg):t=null}this._invoke=function(i,a){return new Promise(function(s,l){var u={key:i,arg:a,resolve:s,reject:l,next:null};t?t=t.next=u:(e=t=u,r(i,a))})},typeof n.return!="function"&&(this.return=void 0)}tl.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},tl.prototype.next=function(n){return this._invoke("next",n)},tl.prototype.throw=function(n){return this._invoke("throw",n)},tl.prototype.return=function(n){return this._invoke("return",n)};var vm=Object.entries,sm=Object.setPrototypeOf,k2=Object.isFrozen,Em=Object.getPrototypeOf,xm=Object.getOwnPropertyDescriptor,Be=Object.freeze,Ve=Object.seal,Eo=Object.create,km=typeof Reflect<"u"&&Reflect,Ec=km.apply,xc=km.construct;Be||(Be=function(e){return e});Ve||(Ve=function(e){return e});Ec||(Ec=function(e,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(t,o)});xc||(xc=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return new e(...r)});var er=_e(Array.prototype.forEach);Array.prototype.indexOf;var T2=_e(Array.prototype.lastIndexOf),lm=_e(Array.prototype.pop),Wi=_e(Array.prototype.push),A2=_e(Array.prototype.slice),D2=_e(Array.prototype.splice),xo=Array.isArray,hc=Tm(Set),pc=_e(Set.prototype.add),Yi=_e(Set.prototype.has),wn=_e(String.prototype.toLowerCase),mc=_e(String.prototype.toString),um=_e(String.prototype.match),Xi=_e(String.prototype.replace),cm=_e(String.prototype.indexOf),S2=_e(String.prototype.trim),C2=_e(Number.prototype.toString),N2=_e(Boolean.prototype.toString),dm=typeof BigInt>"u"?null:_e(BigInt.prototype.toString),fm=typeof Symbol>"u"?null:_e(Symbol.prototype.toString),at=_e(Object.prototype.hasOwnProperty),Zi=_e(Object.prototype.toString),Ue=_e(RegExp.prototype.test),tr=Tm(TypeError);function _e(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return Ec(n,e,r)}}function Tm(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return xc(n,t)}}function oe(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wn;if(sm&&sm(n,null),!xo(e))return n;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=t(o);i!==o&&(k2(e)||(e[r]=i),o=i)}n[o]=!0}return n}function I2(n){for(let e=0;e<n.length;e++)at(n,e)||(n[e]=null);return n}function ct(n){let e=Eo(null);for(let r of vm(n)){var t=E2(r,2);let o=t[0],i=t[1];at(n,o)&&(xo(i)?e[o]=I2(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=ct(i):e[o]=i)}return e}function O2(n){switch(typeof n){case"string":return n;case"number":return C2(n);case"boolean":return N2(n);case"bigint":return dm?dm(n):"0";case"symbol":return fm?fm(n):"Symbol()";case"undefined":return Zi(n);case"function":case"object":{if(n===null)return Zi(n);let e=n,t=bt(e,"toString");if(typeof t=="function"){let r=t(e);return typeof r=="string"?r:Zi(r)}return Zi(n)}default:return Zi(n)}}function bt(n,e){for(;n!==null;){let r=xm(n,e);if(r){if(r.get)return _e(r.get);if(typeof r.value=="function")return _e(r.value)}n=Em(n)}function t(){return null}return t}function R2(n,e){for(;n!==null;){let t=xm(n,e);if(t)return t.get?_e(t.get):null;n=Em(n)}return null}function B2(n){try{return Ue(n,""),!0}catch{return!1}}var hm=Be(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gc=Be(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),bc=Be(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$2=Be(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),wc=Be(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),M2=Be(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),pm=Be(["#text"]),mm=Be(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),_c=Be(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),gm=Be(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),rl=Be(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),P2=Ve(/{{[\w\W]*|^[\w\W]*}}/g),L2=Ve(/<%[\w\W]*|^[\w\W]*%>/g),F2=Ve(/\${[\w\W]*/g),j2=Ve(/^data-[\-\w.\u00B7-\uFFFF]+$/),q2=Ve(/^aria-[\-\w]+$/),bm=Ve(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),U2=Ve(/^(?:\w+script|data):/i),V2=Ve(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),z2=Ve(/^html$/i),H2=Ve(/^[a-z][.\w]*(-[.\w]+)+$/i),yc=Ve(/<[/\w!]/g),wm=Ve(/<[/\w]/g),G2=Ve(/<\/no(script|embed|frames)/i),_m=Ve(/\/>/i),De={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},W2=Be(oe({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),Y2=function(){return typeof window>"u"?null:window},X2=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(r=t.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ym=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Br=function(e,t,r,o){return at(e,t)&&xo(e[t])?oe(o.base?ct(o.base):{},e[t],o.transform):r},vc=function(e,t,r){let o=at(e,t)?e[t]:void 0;return o&&typeof o=="object"?ct(o):r()};function Am(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Y2(),e=C=>Am(C);if(e.version="3.4.17",e.removed=[],!n||!n.document||n.document.nodeType!==De.document||!n.Element)return e.isSupported=!1,e;let t=n.document,r=t,o=r.currentScript;n.DocumentFragment;let i=n.HTMLTemplateElement,a=n.Node,s=n.Element,l=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let u=n.DOMParser,c=n.trustedTypes,d=s.prototype,f=bt(d,"cloneNode"),h=bt(d,"remove"),p=bt(d,"removeAttributeNode"),m=bt(d,"nextSibling"),w=bt(d,"childNodes"),b=bt(d,"parentNode"),_=bt(d,"shadowRoot"),y=bt(d,"attributes"),E=a&&a.prototype?bt(a.prototype,"nodeType"):null,S=a&&a.prototype?bt(a.prototype,"nodeName"):null,x=a&&a.prototype?bt(a.prototype,"ownerDocument"):null,N=function(g){return E?E(g):g.nodeType},O=function(g){return S?S(g):g.nodeName},$=R2(d,"namespaceURI"),K=function(g){return $?$(g):g.namespaceURI};if(typeof i=="function"){let C=t.createElement("template");C.content&&C.content.ownerDocument&&(t=C.content.ownerDocument)}let W,se="",me,te=!1,le=0,q=function(){if(le>0)throw tr('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},dt=function(g){q(),le++;try{return W.createHTML(g)}finally{le--}},_n=function(g){q(),le++;try{return W.createScriptURL(g)}finally{le--}},yn=function(){return te||(me=X2(c,o),te=!0),me},wt=t,X=wt.implementation,$e=wt.createNodeIterator,zt=wt.createDocumentFragment,vn=wt.getElementsByTagName,Fm=r.importNode,ge=ym();e.isSupported=typeof vm=="function"&&typeof b=="function"&&X&&X.createHTMLDocument!==void 0;let jm=P2,qm=L2,Um=F2,Vm=j2,zm=q2,Hm=U2,Xc=V2,Gm=H2,Zc=bm,be=null,hl=oe({},[...hm,...gc,...bc,...wc,...pm]),we=null,pl=oe({},[...mm,..._c,...gm,...rl]),St=Object.seal(Eo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),To=null,Kc=null,or=Object.seal(Eo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Jc=!0,ml=!0,Qc=!1,gl=!0,Ht=!1,$r=!0,Mr=!1,bl=!1,ta=null,ra=null,wl=!1,En=!1,na=!1,oa=!1,ed=!0,td=!1,rd="user-content-",_l=!0,yl=!1,Pr=null,xn={},Lr=null,nd=oe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),od=null,id=oe({},["audio","video","img","source","image","track"]),ad=null,sd=oe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ia="http://www.w3.org/1998/Math/MathML",aa="http://www.w3.org/2000/svg",Ct="http://www.w3.org/1999/xhtml",kn=Ct,vl=!1,El=null,Wm=oe({},[ia,aa,Ct],mc),ld=Be(["mi","mo","mn","ms","mtext"]),xl=oe({},ld),ud=Be(["annotation-xml"]),kl=oe({},ud),Ym=oe({},["title","style","font","a","script"]),Ao=null,Xm=["application/xhtml+xml","text/html"],Zm="text/html",ke=null,Tn=null,Km=t.createElement("form"),cd=function(g){return g instanceof RegExp||g instanceof Function},Tl=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tn&&Tn===g)return;(!g||typeof g!="object")&&(g={}),g=ct(g),Ao=Xm.indexOf(g.PARSER_MEDIA_TYPE)===-1?Zm:g.PARSER_MEDIA_TYPE,ke=Ao==="application/xhtml+xml"?mc:wn,be=Br(g,"ALLOWED_TAGS",hl,{transform:ke}),we=Br(g,"ALLOWED_ATTR",pl,{transform:ke}),El=Br(g,"ALLOWED_NAMESPACES",Wm,{transform:mc}),ad=Br(g,"ADD_URI_SAFE_ATTR",sd,{transform:ke,base:sd}),od=Br(g,"ADD_DATA_URI_TAGS",id,{transform:ke,base:id}),Lr=Br(g,"FORBID_CONTENTS",nd,{transform:ke}),To=Br(g,"FORBID_TAGS",ct({}),{transform:ke}),Kc=Br(g,"FORBID_ATTR",ct({}),{transform:ke}),xn=at(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?ct(g.USE_PROFILES):g.USE_PROFILES:!1,Jc=g.ALLOW_ARIA_ATTR!==!1,ml=g.ALLOW_DATA_ATTR!==!1,Qc=g.ALLOW_UNKNOWN_PROTOCOLS||!1,gl=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ht=g.SAFE_FOR_TEMPLATES||!1,$r=g.SAFE_FOR_XML!==!1,Mr=g.WHOLE_DOCUMENT||!1,En=g.RETURN_DOM||!1,na=g.RETURN_DOM_FRAGMENT||!1,oa=g.RETURN_TRUSTED_TYPE||!1,wl=g.FORCE_BODY||!1,ed=g.SANITIZE_DOM!==!1,td=g.SANITIZE_NAMED_PROPS||!1,_l=g.KEEP_CONTENT!==!1,yl=g.IN_PLACE||!1,Zc=B2(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:bm,kn=typeof g.NAMESPACE=="string"?g.NAMESPACE:Ct,xl=vc(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>oe({},ld)),kl=vc(g,"HTML_INTEGRATION_POINTS",()=>oe({},ud));let v=vc(g,"CUSTOM_ELEMENT_HANDLING",()=>Eo(null));if(St=Eo(null),at(v,"tagNameCheck")&&cd(v.tagNameCheck)&&(St.tagNameCheck=v.tagNameCheck),at(v,"attributeNameCheck")&&cd(v.attributeNameCheck)&&(St.attributeNameCheck=v.attributeNameCheck),at(v,"allowCustomizedBuiltInElements")&&typeof v.allowCustomizedBuiltInElements=="boolean"&&(St.allowCustomizedBuiltInElements=v.allowCustomizedBuiltInElements),Ve(St),Ht&&(ml=!1),na&&(En=!0),xn&&(be=oe({},pm),we=Eo(null),xn.html===!0&&(oe(be,hm),oe(we,mm)),xn.svg===!0&&(oe(be,gc),oe(we,_c),oe(we,rl)),xn.svgFilters===!0&&(oe(be,bc),oe(we,_c),oe(we,rl)),xn.mathMl===!0&&(oe(be,wc),oe(we,gm),oe(we,rl))),or.tagCheck=null,or.attributeCheck=null,at(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?or.tagCheck=g.ADD_TAGS:xo(g.ADD_TAGS)&&(be===hl&&(be=ct(be)),oe(be,g.ADD_TAGS,ke))),at(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?or.attributeCheck=g.ADD_ATTR:xo(g.ADD_ATTR)&&(we===pl&&(we=ct(we)),oe(we,g.ADD_ATTR,ke))),at(g,"ADD_FORBID_CONTENTS")&&xo(g.ADD_FORBID_CONTENTS)&&(Lr===nd&&(Lr=ct(Lr)),oe(Lr,g.ADD_FORBID_CONTENTS,ke)),_l&&(be["#text"]=!0),Mr&&oe(be,["html","head","body"]),be.table&&(oe(be,["tbody"]),delete To.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw tr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw tr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let T=W;W=g.TRUSTED_TYPES_POLICY;try{se=dt("")}catch(A){throw W=T,A}}else g.TRUSTED_TYPES_POLICY===null?(W=void 0,se=""):(W===void 0&&(W=yn()),W&&typeof se=="string"&&(se=dt("")));Be&&Be(g),Tn=g},dd=oe({},[...gc,...bc,...$2]),fd=oe({},[...wc,...M2]),Jm=function(g,v,T){return v.namespaceURI===Ct?g==="svg":v.namespaceURI===ia?g==="svg"&&(T==="annotation-xml"||xl[T]):!!dd[g]},Qm=function(g,v,T){return v.namespaceURI===Ct?g==="math":v.namespaceURI===aa?g==="math"&&kl[T]:!!fd[g]},eg=function(g,v,T){return v.namespaceURI===aa&&!kl[T]||v.namespaceURI===ia&&!xl[T]?!1:!fd[g]&&(Ym[g]||!dd[g])},tg=function(g){let v=K(g),T=wn(O(g)),A=b(g),M,U;return A&&N(A)===De.element?(M={namespaceURI:K(A)},U=wn(O(A))):(M={namespaceURI:kn},U="template"),El[v]?v===aa?Jm(T,M,U):v===ia?Qm(T,M,U):v===Ct?eg(T,M,U):!!(Ao==="application/xhtml+xml"&&El[v]):!1},ir=function(g){Wi(e.removed,{element:g});try{b(g).removeChild(g)}catch{if(h(g),!b(g))throw tr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},hd=function(g,v,T){try{p(g,v)}catch{try{g.removeAttribute(T)}catch{}}},Al=function(g){Sl(g);let v=w(g);v&&er(A2(v),A=>{try{h(A)}catch{}});let T=N(g)===De.element?y(g):null;if(T)for(let A=T.length-1;A>=0;--A){let M=T[A],U=M&&M.name;typeof U=="string"&&hd(g,M,U)}},An=function(g,v,T){if(!T)try{T=v.getAttributeNode(g)}catch{T=null}Wi(e.removed,{attribute:T||null,from:v});try{T?p(v,T):v.removeAttribute(g)}catch{try{v.removeAttribute(g)}catch{}}if(g==="is")if(En||na)try{ir(v)}catch{}else try{v.setAttribute(g,"")}catch{}},pd=function(g){let v=y(g);if(v)for(let T=v.length-1;T>=0;--T){let A=v[T],M=A&&A.name;typeof M!="string"||we[ke(M)]||hd(g,A,M)}},Dl=function(g,v){let T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,A=[g];for(;A.length>0;){let M=A.pop();if(v(M)===!1)continue;if(T&&N(M)===De.element){let Z=_(M);ar(Z)&&A.push(Z)}let U=w(M);if(U)for(let Z=U.length-1;Z>=0;--Z)A.push(U[Z])}},Sl=function(g){Dl(g,v=>{N(v)===De.element&&pd(v)})},Cl=function(g){let v=[];return Dl(g,T=>{v.push(T)},!0),v},rg=function(g,v){let T=hc();er(Cl(g),A=>{N(A)===De.element&&pc(T,A)}),er(v,A=>{N(A)===De.element&&!Yi(T,A)&&pd(A)})},md=function(g,v){let T=!1;return er(e.removed,A=>{A.element&&(T=T||A.element===g,Sl(A.element))}),rg(g,v),T},ng=8,og=function(g,v){let T=Pr,A=null,M=()=>(A||(A=hc(),er(v,U=>{pc(A,U)})),A);for(let U=0;;U++){let Z=Cl(g),Se=[g],Nt=!1;if(er(Z,Ye=>{N(Ye)===De.documentFragment?Wi(Se,Ye):!Nt&&!Yi(T,Ye)&&(Nt=Yi(M(),Ye))}),!Nt)return;if(U>=ng)throw tr("the tree kept changing during in-place sanitization; refusing to return it");er(Se,(Ye,et)=>{ig(Ye,et>0,g,M())})}},ig=function(g,v,T,A){let M=Nl(g),U;for(;U=M.nextNode();)!Yi(A,U)||Yi(Pr,U)||(v&&_t(ge.uponSanitizeShadowNode,U,null),Ol(U,T),Rl(U,T),ar(U.content)&&So(U.content))},ag=function(g){Pr&&pc(Pr,g)},gd=function(g,v){return $r?g==="patchsrc"?!0:g==="for"&&v!=="label"&&v!=="output":!1},sg=function(g){$r&&Dl(g,v=>{let T=N(v);if(T===De.processingInstruction||T===De.comment&&Ue(wm,v.data)){try{h(v)}catch{}return!1}if(T===De.element){let A=v,M=ke(O(v));try{A.hasAttribute&&A.hasAttribute("patchsrc")&&A.removeAttribute("patchsrc"),A.hasAttribute&&A.hasAttribute("for")&&gd("for",M)&&A.removeAttribute("for")}catch{}}return!0})},bd=function(g){let v=null,T=null;if(wl)g="<remove></remove>"+g;else{let U=um(g,/^[\r\n\t ]+/);T=U&&U[0]}Ao==="application/xhtml+xml"&&kn===Ct&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let A=W?dt(g):g;if(kn===Ct)try{v=new u().parseFromString(A,Ao)}catch{}if(!v||!v.documentElement){v=X.createDocument(kn,"template",null);try{v.documentElement.innerHTML=vl?se:A}catch{}}let M=v.body||v.documentElement;return g&&T&&M.insertBefore(t.createTextNode(T),M.childNodes[0]||null),kn===Ct?vn.call(v,Mr?"html":"body")[0]:Mr?v.documentElement:M},Nl=function(g){let v=x?x(g):g.ownerDocument;return $e.call(v||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},sa=function(g){return g=Xi(g,jm," "),g=Xi(g,qm," "),g=Xi(g,Um," "),g},Il=function(g){var v;wd(g);let T=(v=g.querySelectorAll)===null||v===void 0?void 0:v.call(g,"template");T&&er(T,A=>{ar(A.content)&&Il(A.content)})},wd=function(g){g.normalize();let v=x?x(g):g.ownerDocument,T=$e.call(v||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),A=T.nextNode();for(;A;)A.data=sa(A.data),A=T.nextNode()},la=function(g){let v=S?S(g):null;return typeof v!="string"||ke(v)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==y(g)||typeof g.removeAttribute!="function"||typeof g.removeAttributeNode!="function"||typeof g.getAttributeNode!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==E(g)||g.childNodes!==w(g)},ar=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return E(g)===De.documentFragment}catch{return!1}},Do=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return typeof E(g)=="number"}catch{return!1}};function _t(C,g,v){C.length!==0&&er(C,T=>{T.call(e,g,v,Tn)})}let lg=function(g,v){return!!($r&&g.hasChildNodes()&&!Do(g.firstElementChild)&&Ue(yc,g.textContent)&&Ue(yc,g.innerHTML)||$r&&W2[v]&&N(g)===De.element&&K(g)===Ct&&(Do(g.firstElementChild)||typeof g.textContent=="string"&&Ue(yc,g.textContent))||g.nodeType===De.processingInstruction||$r&&g.nodeType===De.comment&&Ue(wm,g.data))},ua=function(g,v){if(g instanceof RegExp)return Ue(g,v);if(g instanceof Function){for(var T=arguments.length,A=new Array(T>2?T-2:0),M=2;M<T;M++)A[M-2]=arguments[M];return!!g(v,...A)}return!1},ug=function(g,v,T){if(!To[v]&&vd(v)&&ua(St.tagNameCheck,v))return!1;if(_l&&!Lr[v]&&!Lr[wn(v)]){let A=b(g),M=w(g);if(M&&A){let U=M.length;for(let Z=U-1;Z>=0;--Z){let Se=g===T?f(M[Z],!0):M[Z];A.insertBefore(Se,m(g))}}}return ir(g),!0},_d=function(g,v,T,A){return g.length===0?v:v===T||v===A?ct(v):v},Dn=function(g,v){return g===v||b(g)!==null?!1:(yl&&Sl(g),!0)},Ol=function(g,v){if(ag(g),_t(ge.beforeSanitizeElements,g,null),Dn(g,v))return!0;if(la(g))return ir(g),!0;let T=ke(O(g));if(be=_d(ge.uponSanitizeElement,be,hl,ta),_t(ge.uponSanitizeElement,g,{tagName:T,allowedTags:be}),Dn(g,v))return!0;if(lg(g,T))return ir(g),!0;if(To[T]||!(or.tagCheck instanceof Function&&or.tagCheck(T))&&!be[T]){let A=ug(g,T,v);return A===!1&&(_t(ge.afterSanitizeElements,g,null),Dn(g,v))?!0:A}if(N(g)===De.element&&!tg(g)||(T==="noscript"||T==="noembed"||T==="noframes")&&Ue(G2,g.innerHTML))return ir(g),!0;if(Ht&&g.nodeType===De.text){let A=sa(g.textContent);g.textContent!==A&&(Wi(e.removed,{element:g.cloneNode()}),g.textContent=A)}return _t(ge.afterSanitizeElements,g,null),Dn(g,v)},yd=function(g,v,T){if(Kc[v]||gd(v,g)||ed&&(v==="id"||v==="name")&&(T in t||T in Km))return!1;let A=we[v]||or.attributeCheck instanceof Function&&or.attributeCheck(v,g);return ml&&Ue(Vm,v)||Jc&&Ue(zm,v)?!0:A?ad[v]||Ue(Zc,Xi(T,Xc,""))||(v==="src"||v==="xlink:href"||v==="href")&&g!=="script"&&cm(T,"data:")===0&&od[g]||Qc&&!Ue(Hm,Xi(T,Xc,""))?!0:!T:vd(g)&&ua(St.tagNameCheck,g)&&ua(St.attributeNameCheck,v,g)||v==="is"&&St.allowCustomizedBuiltInElements&&ua(St.tagNameCheck,T)},cg=oe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vd=function(g){return!cg[wn(g)]&&Ue(Gm,g)},dg=function(g,v,T,A){if(W&&typeof c=="object"&&typeof c.getAttributeType=="function"&&!T)switch(c.getAttributeType(g,v)){case"TrustedHTML":return dt(A);case"TrustedScriptURL":return _n(A)}return A},fg=function(g,v,T,A){try{return T?g.setAttributeNS(T,v,A):g.setAttribute(v,A),la(g)?(ir(g),!1):!0}catch{return An(v,g),!1}},Ed=function(g,v){return $r&&Ue(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,v)?!0:wn(g)==="attributename"&&um(v,"href")!==null},Rl=function(g,v){if(_t(ge.beforeSanitizeAttributes,g,null),Dn(g,v))return;let T=g.attributes;if(!T||la(g))return;we=_d(ge.uponSanitizeAttribute,we,pl,ra);let A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0},M=T.length,U=ke(g.nodeName);for(;M--;){let Z=T[M],Se=Z.name,Nt=Z.namespaceURI,Ye=Z.value,et=ke(Se),Sn=Ye,tt=Se==="value"?Sn:S2(Sn),xd=!1;if(A.attrName=et,A.attrValue=tt,A.keepAttr=!0,A.forceKeepAttr=void 0,_t(ge.uponSanitizeAttribute,g,A),tt=A.attrValue,td&&(et==="id"||et==="name")&&cm(tt,rd)!==0&&(An(Se,g,Z),tt=rd+tt,xd=!0),Ed(Se,tt)){An(Se,g,Z);continue}if(!A.forceKeepAttr){if(!A.keepAttr){An(Se,g,Z);continue}if(!gl&&Ue(_m,tt)){An(Se,g,Z);continue}if(Ht&&(tt=sa(tt)),!yd(U,et,tt)){An(Se,g,Z);continue}tt=dg(U,et,Nt,tt),tt!==Sn&&fg(g,Se,Nt,tt)&&xd&&lm(e.removed)}}_t(ge.afterSanitizeAttributes,g,null),Dn(g,v)},So=function(g){let v=null,T=Nl(g);for(_t(ge.beforeSanitizeShadowDOM,g,null);v=T.nextNode();)if(_t(ge.uponSanitizeShadowNode,v,null),Ol(v,g),Rl(v,g),ar(v.content)&&So(v.content),N(v)===De.element){let A=_(v);ar(A)&&(Bl(A),So(A))}Ht&&wd(g),_t(ge.afterSanitizeShadowDOM,g,null)},Bl=function(g){let v=[{node:g,shadow:null}];for(;v.length>0;){let T=v.pop();if(T.shadow){So(T.shadow);continue}let A=T.node,M=N(A)===De.element,U=w(A);if(U)for(let Z=U.length-1;Z>=0;--Z)v.push({node:U[Z],shadow:null});if(M){let Z=S?S(A):null;if(typeof Z=="string"&&ke(Z)==="template"){let Se=A.content;ar(Se)&&v.push({node:Se,shadow:null})}}if(M){let Z=_(A);ar(Z)&&v.push({node:null,shadow:Z},{node:Z,shadow:null})}}};return e.sanitize=function(C){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=null,T=null,A=null,M=null;if(vl=!C,vl&&(C="<!-->"),typeof C!="string"&&!Do(C)&&(C=O2(C),typeof C!="string"))throw tr("dirty is not a string, aborting");if(!e.isSupported)return C;bl?(be=ta,we=ra):Tl(g),(ge.uponSanitizeElement.length>0||ge.uponSanitizeAttribute.length>0)&&(be=ct(be)),ge.uponSanitizeAttribute.length>0&&(we=ct(we)),e.removed=[];let U=yl&&typeof C!="string"&&Do(C),Z=[],Se=Pr;if(U){sg(C);let et=O(C);if(typeof et=="string"){let Sn=ke(et);if(!be[Sn]||To[Sn])throw Al(C),tr("root node is forbidden and cannot be sanitized in-place")}if(la(C))throw Al(C),tr("root node is clobbered and cannot be sanitized in-place");Z=Cl(C),Pr=hc()}else if(Do(C))v=bd("<!---->"),T=v.ownerDocument.importNode(C,!0),T.nodeType===De.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?v=T:v.appendChild(T),Bl(v);else{if(!En&&!Ht&&!Mr&&C.indexOf("<")===-1)return W&&oa?dt(C):C;if(v=bd(C),!v)return En?null:oa?se:""}v&&wl&&ir(v.firstChild);let Nt=U?C:v;try{U&&Bl(C);let et=Nl(Nt);for(;A=et.nextNode();)Ol(A,Nt),Rl(A,Nt),ar(A.content)&&So(A.content);U&&og(C,Z)}catch(et){throw U&&(Al(C),md(C,Z)),et}finally{Pr=Se}if(U){if(md(C,Z))throw tr("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ht&&Il(C),C}if(En){if(Ht&&Il(v),na)for(M=zt.call(v.ownerDocument);v.firstChild;)M.appendChild(v.firstChild);else M=v;return(we.shadowroot||we.shadowrootmode)&&(M=Fm.call(r,M,!0)),M}let Ye=Mr?v.outerHTML:v.innerHTML;return Mr&&be["!doctype"]&&v.ownerDocument&&v.ownerDocument.doctype&&v.ownerDocument.doctype.name&&Ue(z2,v.ownerDocument.doctype.name)&&(Ye="<!DOCTYPE "+v.ownerDocument.doctype.name+`>
|
|
206
|
+
`+Ye),Ht&&(Ye=sa(Ye)),W&&oa?dt(Ye):Ye},e.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Tl(C),bl=!0,ta=be,ra=we},e.clearConfig=function(){Tn=null,bl=!1,ta=null,ra=null,W=me,se=""},e.isValidAttribute=function(C,g,v){Tn||Tl({});let T=ke(C),A=ke(g);return typeof v=="string"&&(Ed(g,v)||!gl&&Ue(_m,v))?!1:yd(T,A,v)},e.addHook=function(C,g){typeof g=="function"&&at(ge,C)&&Wi(ge[C],g)},e.removeHook=function(C,g){if(at(ge,C)){if(g!==void 0){let v=T2(ge[C],g);return v===-1?void 0:D2(ge[C],v,1)[0]}return lm(ge[C])}},e.removeHooks=function(C){at(ge,C)&&(ge[C]=[])},e.removeAllHooks=function(){ge=ym()},e}var Z2=Am();function K2(){return import("@gramlot/gramlot/markdown")}var kc=class n extends At{static internalParams=new Set([...At.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:r,onError:o}){super({cacheTime:-1,onError:o}),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:o}=e,i,a=new Promise((s,l)=>{i=()=>l(o.reason),o.addEventListener("abort",i,{once:!0})});try{let s=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:o}),a]);if(o.aborted)throw o.reason;return s}finally{o.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof k))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 Tc(n){return class extends n{setLabelbox(e){let{box:t,labelBox:r,fieldLabel:o}=e;Object.assign(this,{box:t,labelBox:r,fieldLabel:o}),o.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),o=this.parameters.lbl??"";return o?this.control.setAttribute("aria-label",o):this.control.removeAttribute("aria-label"),r}}}Tc.labelbox=!0;Tc.parameters={lbl:{dtype:"T",qualification:"intl_str",nullable:!0,binding:"read"},lbl_position:{dtype:"T",default:"TL",binding:"read",enum:Vu}};var Sc=["select","notnull","empty","case","len","min","max","email","regex","call","remote"],J2=["nodup","exist","gridnodup"],nl=n=>n==null||n==="",Ac=(n,e)=>n instanceof Promise?n.then(e):e(n);function Cc(n,e,t={}){let r={value:n,modified:!1,error:null,warnings:[],issues:[],datachanges:[]},o=Object.fromEntries(Object.entries(e).map(([u,c])=>[u.slice(9),c])),i=u=>Object.hasOwn(e,`validate_${u}`)&&e[`validate_${u}`]!=null;for(let u of J2)if(i(u))throw new Error(`validate_${u} requires the DB/grid integration.`);let a=(u,c,d=!1)=>t.invoke(u,e[u],{...o,value:c,result:r,validations:o,userChange:!0,signal:t.signal},d),s=(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 k?Object.fromEntries(c.getNodes().map(b=>[b.label,b.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`]),p=e[`${d}_${f.errorcode}`]||e[`${d}_${h?"warning":"error"}`]||f.message||e[`${d}_${h?"error":"warning"}`]||String(f.errorcode),m=Yr(p,b=>b?{...o,...f,value:r.value}[b]:r.value);if(m==null)throw new Error("A validation message references a missing value.");let w={rule:u,code:f.errorcode,severity:h?"warning":"error",message:m};r.issues.push(w),h?r.warnings.push(m):(r.error=m,r.required=!!f.required)},l=u=>{if(t.signal?.aborted)throw t.signal.reason;if(r.error||u===Sc.length)return r;let c=Sc[u],d=`validate_${c}`,f=e[d];if(!i(c)||f===!1&&c!=="empty")return l(u+1);let h=m=>{if(!m)return l(u+1);let w;return c==="remote"&&r.value==null?l(u+1):(c==="call"?w=a(d,r.value):c==="remote"?w=t.remote(f,{...Q2(e),value:r.value},t.signal):w=e0(c,f,r.value,t),Ac(w,b=>{if(t.signal?.aborted)throw t.signal.reason;let _=()=>(s(c,b),l(u+1));return c==="remote"&&e.validate__onResult?Ac(t.invoke("validate__onResult",e.validate__onResult,{result:b,value:r.value,validations:o,signal:t.signal}),_):_()}))},p=e[`${d}_if`];return Ac(p==null?!0:typeof p=="boolean"?p:a(`${d}_if`,r.value,!0),h)};return l(0)}function Q2(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 Ki(n,e,t={}){return{errorcode:n,message:e,...t}}function e0(n,e,t,r){if(n==="select")return r.selection(t,r.signal);if(n==="notnull")return nl(t)&&e?Ki("notnull","A value is required.",{required:!0}):null;if(n==="empty")return nl(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[o,i]=e.split(":"),a=Number(o||0),s=i===void 0?a:i===""?1/0:Number(i);if(a>s)throw new Error("Invalid validate_len: minimum exceeds maximum.");if(nl(t))return;if(typeof t!="string")throw new TypeError("validate_len requires a text value.");return t.length<a||t.length>s?Ki(a===s?"wrong length":t.length<a?"too short":"too long",a===s?`Enter exactly ${a} characters.`:s===1/0?`Enter at least ${a} characters.`:a===0?`Enter no more than ${s} characters.`:`Enter between ${a} and ${s} characters.`):void 0}if(!nl(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,o=>o[0].toUpperCase()+o.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 o;if(r.isDecimal?.(t))o=t.comparedTo(e);else if(t instanceof Date&&e instanceof Date)o=t.getTime()-e.getTime();else if(typeof t=="number"&&Number.isFinite(t)&&typeof e=="number"&&Number.isFinite(e))o=t-e;else throw new TypeError(`validate_${n} requires matching numeric or date/time values.`);return(n==="min"?o<0:o>0)?Ki(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:Ki("email","Check email format.",{iswarning:!0})}if(n==="regex"){if(typeof t!="string"||typeof e!="string")throw new TypeError("validate_regex requires text.");let o=e.trim(),i=o.startsWith("!");return new RegExp(i?o.slice(1):o,"u").test(t)!==i?null:Ki("regex","The value does not match the required pattern.")}}}var Ji={dtype:"T",nullable:!0,binding:"read"},ol={dtype:"B",nullable:!0,binding:"read"},Dc={dtype:["T","L","N","R","B","D","H","DH","DHZ"],nullable:!0,binding:"read"},Dm={validate_select:ol,validate_notnull:{...ol,default:!1},validate_empty:Dc,validate_case:{...Ji,enum:["upper","lower","title","capitalize","u","l","t","c"]},validate_len:Ji,validate_min:Dc,validate_max:Dc,validate_email:ol,validate_regex:Ji,validate_call:{dtype:"T",nullable:!0},validate_remote:Ji,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(Sc.flatMap(n=>[[`validate_${n}_if`,{dtype:["T","B"],nullable:!0}],[`validate_${n}_iswarning`,ol],...["error","warning"].map(e=>[`validate_${n}_${e}`,{...Ji,qualification:"intl_str"}])]))};var t0=1800,Sm=200;function Cm(n){return class extends n{get supportsFormValidation(){return!0}static validationParameters(e){let t={...Gu(this.gramlotComponent,e),...e};return this.constrained&&t.validate_select==null&&(t.validate_select=!0),t}static get validationExecutor(){return Cc}get validationExecutor(){return this.constructor.validationExecutor}connectedCallback(){super.connectedCallback(),this.pageContext?.form&&this.pageContext.formValidate()}#e=!1;#t;#r;#n;#o=new co;#a;#i={};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)}
|
|
207
207
|
input#control[aria-invalid="true"],textarea#control[aria-invalid="true"]{color:var(--gramlot-error,#8c1d18)}
|
|
208
208
|
#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);
|
|
209
209
|
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);
|
|
210
|
-
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 ${
|
|
210
|
+
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 ${Sm}ms ease-out}
|
|
211
211
|
#field-message[data-severity="warning"]{color:var(--gramlot-warning,#805600);border-color:var(--gramlot-warning,#805600);background:var(--gramlot-warning-background,#fff8df)}
|
|
212
212
|
#field-message[data-fading]{opacity:0}
|
|
213
|
-
@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.#l()),this.control.addEventListener("mouseenter",()=>this.#l()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#s())})}#s(){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")}#l(){if(!this.message.textContent||!this.isConnected)return;this.#s();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),
|
|
214
|
-
`),this.#l())}validateCandidate(e,t){if(this.pageContext.form){let r=this.validationSelection();return t(e),this.pageContext.formValidateCandidate(e,r)}return this.cancelValidation(),this.#a=this.pageContext.validationCurrent(),this.#o.start(e,this.#i,{...this.pageContext,selection:r=>this.validateSelection(r)},
|
|
213
|
+
@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.#l()),this.control.addEventListener("mouseenter",()=>this.#l()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#s())})}#s(){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")}#l(){if(!this.message.textContent||!this.isConnected)return;this.#s();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),oo(this.message,this.control),this.#r=e.setTimeout(()=>{this.message.hidden||(this.message.setAttribute("data-fading",""),this.#r=e.setTimeout(()=>this.#s(),Sm))},t0),this.#n=new e.AbortController;let t={capture:!0,signal:this.#n.signal};e.addEventListener("scroll",()=>this.#s(),t),e.addEventListener("resize",()=>this.#s(),t)}releaseControl(){this.#o.cancel(),this.#s(),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.#l():this.#s()}restoreFormValue(e){this.error(""),this.#e=!1,super.restoreFormValue(e)}cancelValidation(){this.pageContext?.form&&this.pageContext.formCancelValidation(),this.#o.cancel(),this.#a=null,this.control.setAttribute("aria-busy","false")}presentValidation(e){this.validationResult=e,this.control.setAttribute("aria-busy","false"),this.error(e.error||""),this.message.dataset.severity=e.error?"error":"warning",this.#e=!!e.error,!e.error&&e.warnings.length&&(this.message.textContent=e.warnings.join(`
|
|
214
|
+
`),this.#l())}validateCandidate(e,t){if(this.pageContext.form){let r=this.validationSelection();return t(e),this.pageContext.formValidateCandidate(e,r)}return this.cancelValidation(),this.#a=this.pageContext.validationCurrent(),this.#o.start(e,this.#i,{...this.pageContext,selection:r=>this.validateSelection(r)},Cc,r=>{if(this.#a=null,r.ok)try{t(r.value)}catch(o){r.ok=!1,r.result.error=o.message}this.presentValidation(r.result),r.ok||this.finishValidation(r)},()=>this.control.setAttribute("aria-busy","true"))}finishValidation(e){e.result&&this.pageContext.finishValidation(e)}shouldProjectControlValue(e){!this.pageContext?.form&&this.#a&&!this.#a()&&this.cancelValidation();let t=this.sameControlValue(e,this.#t);return t&&this.#e?!1:(!t&&!this.pageContext?.form&&this.cancelValidation(),this.#t=e,!t&&this.#e&&this.error(""),!0)}projectAttributes(e,t){let r=super.projectAttributes(e,t),o=Object.fromEntries(Object.entries(e).filter(([l])=>l.startsWith("validate_"))),i=new Set([...Object.keys(o),...Object.keys(this.#i)]);!this.pageContext?.form&&([...i].some(l=>!Object.is(o[l],this.#i[l]))||e.disabled||e.readonly)&&this.cancelValidation();let a=[...i].some(l=>!Object.is(o[l],this.#i[l]));this.#i=o,a&&this.pageContext?.form&&this.pageContext.formValidate();for(let l of Object.keys(o))delete r[l];let s=!!this.parameters.validate_notnull;return this.control.setAttribute("aria-required",String(s)),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.required=s),r}}}Cm.parameters=Dm;var ko=new TextEncoder,Nm=n=>`export {default} from "./collection.js";
|
|
215
215
|
export * from "./collection.js";
|
|
216
216
|
export const buildId = "${n}";
|
|
217
|
-
`,
|
|
217
|
+
`,Nc=n=>typeof n=="string"&&n.length>0&&!/[\\\x00-\x1f:?#%]/.test(n)&&!n.split("/").some(e=>!e||e==="."||e==="..");function Im(n,e){if(!n||typeof n.name!="string"||!n.name||!["grammar","commands","module"].every(t=>Nc(n[t]))||!Array.isArray(n.css)||!n.css.every(Nc)||!Array.isArray(n.dependencies)||!n.dependencies.every(t=>typeof t=="string"&&t.length>0)||!Array.isArray(n.files)||!n.files.every(Nc)||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 Om(n,e){Im(n,e);let t=[ko.encode("gramlot-build-v1\0")],r=(l,u)=>{let c=typeof u=="string"?ko.encode(u):u;t.push(ko.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 o=(l,u)=>{let c=ko.encode(l),d=ko.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(o))r("path",l),r("content",l===n.module?Nm("__GRAMLOT_BUILD_ID__"):e.get(l));let i=new Uint8Array(t.reduce((l,u)=>l+u.length,0)),a=0;for(let l of t)i.set(l,a),a+=l.length;let s=await crypto.subtle.digest("SHA-256",i);return"sha256:"+[...new Uint8Array(s)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function r0(n,e){if(Im(n,e),typeof n.buildId!="string"||!/^sha256:[a-f0-9]{64}$/.test(n.buildId))throw new TypeError("Invalid collection buildId");let t=ko.encode(Nm(n.buildId)),r=e.get(n.module);if(r.length!==t.length||r.some((o,i)=>o!==t[i]))throw new Error("Invalid collection wrapper");if(await Om(n,e)!==n.buildId)throw new Error(`Collection fingerprint mismatch: ${n.name}`)}function Rm(n,e){if(!e.videoWidth||!e.videoHeight)throw new Error("Video image is not ready");let t=n.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;let r=t.getContext("2d");if(!r)throw new Error("Video image is unavailable");return r.drawImage(e,0,0),t}function rr(n,e,t){return Object.assign(new Error(e,t?{cause:t}:void 0),{code:n})}function il(n){return n.name==="NotAllowedError"||n.name==="SecurityError"?rr("PERMISSION_DENIED","Camera permission was denied",n):n.name==="NotFoundError"||n.name==="OverconstrainedError"?rr("UNAVAILABLE","Camera is unavailable",n):rr("FAILED",n.message||"Camera failed",n)}var al=()=>rr("CANCELLED","Photo capture cancelled"),Ic=class{constructor({document:e}){if(!e?.defaultView)throw new TypeError("BrowserCameraProvider requires a document");this.document=e,this.capabilities=Object.freeze(e.defaultView.navigator.mediaDevices?.getUserMedia?["camera"]:[])}takePhoto(e){if(e.aborted)return Promise.reject(al());if(!this.capabilities.includes("camera"))return Promise.reject(rr("UNAVAILABLE","Camera is unavailable"));let t=this.document,r=t.defaultView;return new Promise((o,i)=>{let a=!1,s=null,l=new r.AbortController,u={signal:l.signal},c=t.createElement("dialog");c.className="gramlot-camera-dialog",c.setAttribute("aria-label","Take photo");let d=t.createElement("style");d.textContent=`
|
|
218
218
|
.gramlot-camera-dialog{max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem);border:1px solid var(--gramlot-border,#d5dde6);
|
|
219
219
|
border-radius:14px;padding:20px;color:var(--gramlot-ink,#202a35);background:var(--gramlot-surface,#fff);
|
|
220
220
|
box-shadow:0 24px 64px #14243a42;font:14px/1.4 system-ui,sans-serif}
|
|
@@ -224,7 +224,8 @@ export const buildId = "${n}";
|
|
|
224
224
|
.gramlot-camera-dialog .actions{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}
|
|
225
225
|
.gramlot-camera-dialog button{font:inherit;cursor:pointer;padding:.4em .8em;border:1px solid var(--gramlot-border-control,#aab4c0);border-radius:6px;background:var(--gramlot-button-background,#fff);color:var(--gramlot-button-color,#202a35)}
|
|
226
226
|
.gramlot-camera-dialog button.primary{background:var(--gramlot-action,#3766b5);color:#fff}.gramlot-camera-dialog button:disabled{opacity:.55}
|
|
227
|
-
`;let f=t.createElement("h2");f.textContent="Take photo";let h=t.createElement("video");h.muted=!0,h.autoplay=!0,h.playsInline=!0;let m=t.createElement("p");m.setAttribute("role","status"),m.textContent="Waiting for camera\u2026";let p=t.createElement("div");p.className="actions";let w=t.createElement("button");w.type="button",w.textContent="Cancel";let b=t.createElement("button");b.type="button",b.textContent="Capture",b.className="primary",b.disabled=!0,p.append(w,b),c.append(d,f,h,m,p);let _=k=>{for(let C of k.getTracks())C.stop()},y=(k,C)=>{a||(a=!0,l.abort(),e.removeEventListener("abort",E),s&&(_(s),s=null),h.srcObject=null,c.open&&c.close(),c.remove(),k?i(k):o(C))},E=()=>y(rl());e.addEventListener("abort",E,{once:!0}),w.addEventListener("click",E,u),c.addEventListener("cancel",k=>{k.preventDefault(),E()},u),c.addEventListener("close",()=>{a||E()},u);let N=()=>{!a&&h.videoWidth>0&&h.videoHeight>0&&(b.disabled=!1,m.textContent="")};h.addEventListener("loadedmetadata",N,u),b.addEventListener("click",()=>{try{let C=xm(t,h).toDataURL("image/jpeg",.9);if(!C.startsWith("data:image/jpeg;"))throw new Error("Camera image encoding failed");y(null,{url:C,format:"jpeg"})}catch(k){y(tl(k))}},u),t.body.append(c);try{c.showModal()}catch(k){y(tl(k));return}if(e.aborted){E();return}Promise.resolve().then(()=>a?null:r.navigator.mediaDevices.getUserMedia({video:!0,audio:!1})).then(async k=>{if(k){if(a){_(k);return}s=k,h.srcObject=s;for(let C of s.getTracks())C.addEventListener("ended",()=>y(Jt("UNAVAILABLE","Camera stopped")),u);try{await h.play(),N()}catch(C){y(tl(C))}}},k=>y(tl(k)))})}choosePhoto(e){if(e.aborted)return Promise.reject(rl());let t=this.document,r=t.defaultView;return new Promise((o,i)=>{let a=!1,s=null,l=new r.AbortController,u={signal:l.signal},c=t.createElement("input");c.type="file",c.accept="image/png,image/jpeg,image/webp",c.hidden=!0;let d=(h,m)=>{a||(a=!0,l.abort(),e.removeEventListener("abort",f),s&&s.readyState===1&&s.abort(),c.remove(),h?i(h):o(m))},f=()=>d(rl());if(e.addEventListener("abort",f,{once:!0}),c.addEventListener("cancel",f,u),c.addEventListener("change",()=>{let h=c.files[0];if(!h||!["image/png","image/jpeg","image/webp"].includes(h.type)){d(Jt("FAILED","Select a PNG, JPEG or WebP image"));return}s=new r.FileReader,s.onload=()=>d(null,{url:s.result,format:h.type.slice(6)}),s.onerror=()=>d(Jt("FAILED","Photo could not be read",s.error)),s.readAsDataURL(h)},u),t.body.append(c),e.aborted){f();return}try{c.click()}catch(h){d(Jt("FAILED","Photo selection failed",h))}})}};var xc=new WeakMap,G2=/^m_[a-f0-9]+$/;function Tc(n,e,{messages:t}){if(!(t instanceof x)||t instanceof I)throw new TypeError("Chat messages require a Data Bag");let r=e.parentNode,o=n.dom.getDomNode(r);if(!o)return;let i=xc.get(r);i||(i={rows:new Map,active:!0},xc.set(r,i),n.src.renderer.onDispose(r,()=>{i.active=!1;for(let c of i.rows.keys())r.getRelativeData(".messageData").popNode(c);i.rows.clear(),xc.delete(r)}));let a=t.getNodes();for(let c of a)if(!G2.test(c.label)||!["user","assistant"].includes(c.attr.role)||typeof c.attr.author!="string"||!(typeof c.staticValue=="string"||c.staticValue instanceof Te))throw new TypeError("Chat messages require a stable label, role, author and string or Gramlot Source");let s=o.scrollHeight-o.clientHeight-o.scrollTop<48,l=[];for(let c of a){let d=i.rows.get(c.label);if(d&&d.value===c.staticValue&&d.role===c.attr.role&&d.author===c.attr.author)continue;let f=new Ie,h=f.root.article({node_label:c.label,datapath:r.absDatapath(".messageData."+c.label),"data-role":c.attr.role,"aria-label":c.attr.author}),m=ae(h.div());typeof c.staticValue=="string"?f.wrapSource(m).div("=="+JSON.stringify(c.staticValue),{white_space:"pre-wrap"}):m.setValue(n.src.prepareSource(c.staticValue.toTytx()));let p=n.src.prepareSource(f.source);n.src.renderer.validateCandidate(p),l.push({message:c,old:d,child:p.getNode(c.label)})}let u=new Set(a.map(c=>c.label));for(let[c]of i.rows)u.has(c)||(r.value.popNode(c),r.getRelativeData(".messageData").popNode(c),i.rows.delete(c));for(let{message:c,old:d,child:f}of l)d&&r.value.popNode(c.label),d||r.setRelativeData(".messageData."+c.label,new x),n.src.builder.setChild(r.value,f.nodeTag,f.value,{...f.attr,node_label:c.label}),i.rows.set(c.label,{value:c.staticValue,role:c.attr.role,author:c.attr.author});s&&queueMicrotask(()=>{i.active&&(o.scrollTop=o.scrollHeight)})}function Tm(n,e,t=null){if(n.getRelativeData(".pending")||n.getRelativeData(".picking")||!n.getRelativeData(".conversation.ready"))return;let r=ee();n.SET(".requestId",r),n.SET(".pending",!0),n.SET(".error",""),n.SET(".conversation.request",new x({id:r,action:e,text:t,attachments:j(F(n.getRelativeData(".attachments")))}))}function Ac(n,e){let t=e.getRelativeData(".draft");typeof t!="string"||!t.trim()&&!e.getRelativeData(".attachments").length||Tm(e,"send",t)}function Dc(n,e){Tm(e,"reset")}function Sc(n,e,{response:t}){if(t!==null){if(!(t instanceof x))throw new TypeError("Chat response requires a Data Bag");t.getItem("id")===e.getRelativeData(".requestId")&&(t.getItem("accepted")&&t.getItem("submitted")===e.getRelativeData(".draft")&&e.SET(".draft",""),t.getItem("accepted")&&t.getItem("submitted")!==null&&e.SET(".attachments",new x),e.SET(".pending",!1),e.SET(".error",t.getItem("error")))}}var kc=new WeakMap;function Cc(n,e){let t=e.parentNode,r=kc.get(t);if(!r){let o=n.dom.getDomNode(t);if(!o)return;let i=o.closest("[data-chat-composer]"),a=o.querySelector("textarea"),s=i.querySelector("[data-chat-top]"),l=i.querySelector("[data-chat-toolbar]"),u=o.ownerDocument.defaultView,c=0,d=!0,f=()=>{if(c=0,!d)return;a.style.height="0px";let p=u.getComputedStyle(a),w=parseFloat(p.borderTopWidth)+parseFloat(p.borderBottomWidth),b=Math.max(44,Math.min(180,a.scrollHeight+w));a.style.height=b+"px",a.style.overflowY=a.scrollHeight+w>b?"auto":"hidden";let _=Math.ceil(o.getBoundingClientRect().height+s.getBoundingClientRect().height+l.getBoundingClientRect().height+2);e.getRelativeData(".composerHeight")!==_&&e.SET(".composerHeight",_)},h=()=>{d&&!c&&(c=u.requestAnimationFrame(f))},m=new u.ResizeObserver(h);for(let p of[o,s,l])m.observe(p);n.src.renderer.onDispose(t,()=>{d=!1,m.disconnect(),c&&u.cancelAnimationFrame(c),kc.delete(t)}),r={schedule:h},kc.set(t,r)}r.schedule()}var W2=["txt","md","csv","json","py","js","ts","jsx","tsx","html","css","sql","yaml","yml","xml","sh","toml","log"],km={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",pdf:"application/pdf",...Object.fromEntries(W2.map(n=>[n,"text/plain"]))};function Y2(n,e){return new Promise((t,r)=>{let o=new e.FileReader;o.onload=()=>t(o.result.slice(o.result.indexOf(",")+1)),o.onerror=()=>r(new Error("Could not read the selected file.")),o.readAsDataURL(n)})}async function Nc(n,e){if(e.getRelativeData(".pending")||e.getRelativeData(".picking"))return;let t=n.dom.getDomNode(e.parentNode).ownerDocument,r=t.createElement("input");r.type="file",r.multiple=!0,r.accept=Object.keys(km).map(s=>"."+s).join(","),r.style.display="none",t.body.append(r);let o=!0,i,a=n.src.renderer.onDispose(e.parentNode,()=>{o=!1,r.remove(),i([])});e.SET(".picking",!0),e.SET(".error","");try{let s=await new Promise(c=>{i=c,r.addEventListener("cancel",()=>c([]),{once:!0}),r.addEventListener("change",()=>c([...r.files]),{once:!0}),r.click()});if(!o||!s.length)return;let l=j(F(e.getRelativeData(".attachments")));if(l.length+s.length>5)throw new Error("Choose at most 5 files.");let u=l.getNodes().reduce((c,d)=>c+d.staticValue.getItem("size"),0);for(let c of s){let d=km[c.name.split(".").pop().toLowerCase()];if(!d)throw new Error("Supported files: PNG, JPEG, WebP, PDF and UTF-8 text/code.");let f=d==="text/plain"?1024*1024:2*1024*1024;if(u+=c.size,!c.size||c.size>f||u>4*1024*1024)throw new Error("Limits: 2 MiB per file, 1 MiB for text, 4 MiB total.");let h=await Y2(c,t.defaultView);if(d==="text/plain"){let m=Uint8Array.from(atob(h),p=>p.charCodeAt(0));if(new TextDecoder("utf-8",{fatal:!0}).decode(m),m.includes(0))throw new Error("The selected file is not UTF-8 text.")}l.setItem("a_"+ee(),new x({name:c.name,mediaType:d,size:c.size,data:h}))}o&&e.SET(".attachments",l)}catch(s){o&&e.SET(".error",s.message)}finally{a(),r.remove(),o&&e.SET(".picking",!1)}}function Ic(n,e){e.getRelativeData(".pending")||e.getRelativeData(".attachments").popNode(e.getAttr("attachment_id"))}function Oc(n,e,{attachments:t}){let r=e.parentNode;for(let a of[...r.value.getNodes()])a.label.startsWith("a_")&&r.value.popNode(a.label);let o=new Ie;for(let a of t.getNodes()){let s=a.staticValue,l=o.root.div({node_label:a.label,display:"flex",align_items:"center",gap:"6px",padding:"4px 8px",border:"1px solid var(--gramlot-border-control,#aaa)",border_radius:"10px",flex_shrink:0});s.getItem("mediaType").startsWith("image/")&&l.img({src:"data:"+s.getItem("mediaType")+";base64,"+s.getItem("data"),alt:"Attachment preview",width:"36px",height:"36px",object_fit:"cover",border_radius:"6px"}),l.span("=="+JSON.stringify(s.getItem("name")),{font_size:"12px",max_width:"180px",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap"}),l.button({icon:"\xD7","aria-label":"Remove "+s.getItem("name"),disabled:"^.pending",class:"button--quiet"}).dataController({func:"chatRemoveAttachment",attachment_id:a.label})}let i=n.src.prepareSource(o.source);n.src.renderer.validateCandidate(i);for(let a of i.getNodes())n.src.builder.setChild(r.value,a.nodeTag,a.value,{...a.attr,node_label:a.label})}var Zi=class{#e;#t;#r;#n;#o;#a=null;#i=null;#s=null;#l=!1;constructor({renderer:e,root:t,onSelect:r}){if(!t?.parentNode||typeof r!="function")throw new TypeError("SourcePicker requires a mounted Source root and onSelect");let o=e.records.get(t.parentNode)?.presentation;if(!o||o.nodeType!==1)throw new TypeError("SourcePicker requires a mounted preview");this.#e=e,this.#t=t,this.#r=o,this.#n=r,o.addEventListener("pointerdown",this,!0),o.addEventListener("click",this,!0),this.#o=new o.ownerDocument.defaultView.MutationObserver(()=>this.#c()),this.#o.observe(o,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]}),this.#s=e.onDispose(t.parentNode,()=>this.dispose())}handleEvent(e){if(this.#l)return;let t=this.#t.fullpath+".",r=e.composedPath().map(i=>this.#e.elements.get(i)).find(i=>i?.node.fullpath.startsWith(t));if(!r)return;e.composedPath().some(i=>i.nodeType===1&&(i.matches("input:not([type=button]):not([type=submit]):not([type=reset]):not([type=image]), textarea, select, label")||i.isContentEditable))||(e.preventDefault(),e.stopImmediatePropagation()),this.#n(r.node)}select(e){if(!this.#l){if(e===null)this.#a=null;else{let t=this.#t.fullpath+".";if(!e.fullpath.startsWith(t))throw new TypeError("Selected node must be inside the preview Source root");this.#a=e.fullpath.slice(t.length)}this.#c()}}#c(){if(this.#l)return;let e=this.#a?this.#t.staticValue.getNode(this.#a):null,t=e?this.#e.records.get(e)?.presentation:null,r=t?.nodeType===1?t:null;this.#i!==r&&(this.#i?.classList.remove("gramlot-source-selected"),this.#i=r),r&&!r.classList.contains("gramlot-source-selected")&&r.classList.add("gramlot-source-selected")}dispose(){this.#l||(this.#l=!0,this.#o.disconnect(),this.#r.removeEventListener("pointerdown",this,!0),this.#r.removeEventListener("click",this,!0),this.#i?.classList.remove("gramlot-source-selected"),this.#s?.(),this.#s=null,this.#i=null)}};var Rc={base:"",compact:`/* gramlot-compact: professional density profile; load after Base. */
|
|
227
|
+
`;let f=t.createElement("h2");f.textContent="Take photo";let h=t.createElement("video");h.muted=!0,h.autoplay=!0,h.playsInline=!0;let p=t.createElement("p");p.setAttribute("role","status"),p.textContent="Waiting for camera\u2026";let m=t.createElement("div");m.className="actions";let w=t.createElement("button");w.type="button",w.textContent="Cancel";let b=t.createElement("button");b.type="button",b.textContent="Capture",b.className="primary",b.disabled=!0,m.append(w,b),c.append(d,f,h,p,m);let _=x=>{for(let N of x.getTracks())N.stop()},y=(x,N)=>{a||(a=!0,l.abort(),e.removeEventListener("abort",E),s&&(_(s),s=null),h.srcObject=null,c.open&&c.close(),c.remove(),x?i(x):o(N))},E=()=>y(al());e.addEventListener("abort",E,{once:!0}),w.addEventListener("click",E,u),c.addEventListener("cancel",x=>{x.preventDefault(),E()},u),c.addEventListener("close",()=>{a||E()},u);let S=()=>{!a&&h.videoWidth>0&&h.videoHeight>0&&(b.disabled=!1,p.textContent="")};h.addEventListener("loadedmetadata",S,u),b.addEventListener("click",()=>{try{let N=Rm(t,h).toDataURL("image/jpeg",.9);if(!N.startsWith("data:image/jpeg;"))throw new Error("Camera image encoding failed");y(null,{url:N,format:"jpeg"})}catch(x){y(il(x))}},u),t.body.append(c);try{c.showModal()}catch(x){y(il(x));return}if(e.aborted){E();return}Promise.resolve().then(()=>a?null:r.navigator.mediaDevices.getUserMedia({video:!0,audio:!1})).then(async x=>{if(x){if(a){_(x);return}s=x,h.srcObject=s;for(let N of s.getTracks())N.addEventListener("ended",()=>y(rr("UNAVAILABLE","Camera stopped")),u);try{await h.play(),S()}catch(N){y(il(N))}}},x=>y(il(x)))})}choosePhoto(e){if(e.aborted)return Promise.reject(al());let t=this.document,r=t.defaultView;return new Promise((o,i)=>{let a=!1,s=null,l=new r.AbortController,u={signal:l.signal},c=t.createElement("input");c.type="file",c.accept="image/png,image/jpeg,image/webp",c.hidden=!0;let d=(h,p)=>{a||(a=!0,l.abort(),e.removeEventListener("abort",f),s&&s.readyState===1&&s.abort(),c.remove(),h?i(h):o(p))},f=()=>d(al());if(e.addEventListener("abort",f,{once:!0}),c.addEventListener("cancel",f,u),c.addEventListener("change",()=>{let h=c.files[0];if(!h||!["image/png","image/jpeg","image/webp"].includes(h.type)){d(rr("FAILED","Select a PNG, JPEG or WebP image"));return}s=new r.FileReader,s.onload=()=>d(null,{url:s.result,format:h.type.slice(6)}),s.onerror=()=>d(rr("FAILED","Photo could not be read",s.error)),s.readAsDataURL(h)},u),t.body.append(c),e.aborted){f();return}try{c.click()}catch(h){d(rr("FAILED","Photo selection failed",h))}})}};var Oc=new WeakMap,n0=/^m_[a-f0-9]+$/;function Bc(n,e,{messages:t}){if(!(t instanceof k)||t instanceof I)throw new TypeError("Chat messages require a Data Bag");let r=e.parentNode,o=n.dom.getDomNode(r);if(!o)return;let i=Oc.get(r);i||(i={rows:new Map,active:!0},Oc.set(r,i),n.src.renderer.onDispose(r,()=>{i.active=!1;for(let c of i.rows.keys())r.getRelativeData(".messageData").popNode(c);i.rows.clear(),Oc.delete(r)}));let a=t.getNodes();for(let c of a)if(!n0.test(c.label)||!["user","assistant"].includes(c.attr.role)||typeof c.attr.author!="string"||!(typeof c.staticValue=="string"||c.staticValue instanceof Ae))throw new TypeError("Chat messages require a stable label, role, author and string or Gramlot Source");let s=o.scrollHeight-o.clientHeight-o.scrollTop<48,l=[];for(let c of a){let d=i.rows.get(c.label);if(d&&d.value===c.staticValue&&d.role===c.attr.role&&d.author===c.attr.author)continue;let f=new Oe,h=f.root.article({node_label:c.label,datapath:r.absDatapath(".messageData."+c.label),"data-role":c.attr.role,"aria-label":c.attr.author}),p=ie(h.div());typeof c.staticValue=="string"?f.wrapSource(p).div("=="+JSON.stringify(c.staticValue),{white_space:"pre-wrap"}):p.setValue(n.src.prepareSource(c.staticValue.toTytx()));let m=n.src.prepareSource(f.source);n.src.renderer.validateCandidate(m),l.push({message:c,old:d,child:m.getNode(c.label)})}let u=new Set(a.map(c=>c.label));for(let[c]of i.rows)u.has(c)||(r.value.popNode(c),r.getRelativeData(".messageData").popNode(c),i.rows.delete(c));for(let{message:c,old:d,child:f}of l)d&&r.value.popNode(c.label),d||r.setRelativeData(".messageData."+c.label,new k),n.src.builder.setChild(r.value,f.nodeTag,f.value,{...f.attr,node_label:c.label}),i.rows.set(c.label,{value:c.staticValue,role:c.attr.role,author:c.attr.author});s&&queueMicrotask(()=>{i.active&&(o.scrollTop=o.scrollHeight)})}function $m(n,e,t=null){if(n.getRelativeData(".pending")||n.getRelativeData(".picking")||!n.getRelativeData(".conversation.ready"))return;let r=ee();n.SET(".requestId",r),n.SET(".pending",!0),n.SET(".error",""),n.SET(".conversation.request",new k({id:r,action:e,text:t,attachments:j(L(n.getRelativeData(".attachments")))}))}function $c(n,e){let t=e.getRelativeData(".draft");typeof t!="string"||!t.trim()&&!e.getRelativeData(".attachments").length||$m(e,"send",t)}function Mc(n,e){$m(e,"reset")}function Pc(n,e,{response:t}){if(t!==null){if(!(t instanceof k))throw new TypeError("Chat response requires a Data Bag");t.getItem("id")===e.getRelativeData(".requestId")&&(t.getItem("accepted")&&t.getItem("submitted")===e.getRelativeData(".draft")&&e.SET(".draft",""),t.getItem("accepted")&&t.getItem("submitted")!==null&&e.SET(".attachments",new k),e.SET(".pending",!1),e.SET(".error",t.getItem("error")))}}var Rc=new WeakMap;function Lc(n,e){let t=e.parentNode,r=Rc.get(t);if(!r){let o=n.dom.getDomNode(t);if(!o)return;let i=o.closest("[data-chat-composer]"),a=o.querySelector("textarea"),s=i.querySelector("[data-chat-top]"),l=i.querySelector("[data-chat-toolbar]"),u=o.ownerDocument.defaultView,c=0,d=!0,f=()=>{if(c=0,!d)return;a.style.height="0px";let m=u.getComputedStyle(a),w=parseFloat(m.borderTopWidth)+parseFloat(m.borderBottomWidth),b=Math.max(44,Math.min(180,a.scrollHeight+w));a.style.height=b+"px",a.style.overflowY=a.scrollHeight+w>b?"auto":"hidden";let _=Math.ceil(o.getBoundingClientRect().height+s.getBoundingClientRect().height+l.getBoundingClientRect().height+2);e.getRelativeData(".composerHeight")!==_&&e.SET(".composerHeight",_)},h=()=>{d&&!c&&(c=u.requestAnimationFrame(f))},p=new u.ResizeObserver(h);for(let m of[o,s,l])p.observe(m);n.src.renderer.onDispose(t,()=>{d=!1,p.disconnect(),c&&u.cancelAnimationFrame(c),Rc.delete(t)}),r={schedule:h},Rc.set(t,r)}r.schedule()}var o0=["txt","md","csv","json","py","js","ts","jsx","tsx","html","css","sql","yaml","yml","xml","sh","toml","log"],Bm={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",pdf:"application/pdf",...Object.fromEntries(o0.map(n=>[n,"text/plain"]))};function i0(n,e){return new Promise((t,r)=>{let o=new e.FileReader;o.onload=()=>t(o.result.slice(o.result.indexOf(",")+1)),o.onerror=()=>r(new Error("Could not read the selected file.")),o.readAsDataURL(n)})}async function Fc(n,e){if(e.getRelativeData(".pending")||e.getRelativeData(".picking"))return;let t=n.dom.getDomNode(e.parentNode).ownerDocument,r=t.createElement("input");r.type="file",r.multiple=!0,r.accept=Object.keys(Bm).map(s=>"."+s).join(","),r.style.display="none",t.body.append(r);let o=!0,i,a=n.src.renderer.onDispose(e.parentNode,()=>{o=!1,r.remove(),i([])});e.SET(".picking",!0),e.SET(".error","");try{let s=await new Promise(c=>{i=c,r.addEventListener("cancel",()=>c([]),{once:!0}),r.addEventListener("change",()=>c([...r.files]),{once:!0}),r.click()});if(!o||!s.length)return;let l=j(L(e.getRelativeData(".attachments")));if(l.length+s.length>5)throw new Error("Choose at most 5 files.");let u=l.getNodes().reduce((c,d)=>c+d.staticValue.getItem("size"),0);for(let c of s){let d=Bm[c.name.split(".").pop().toLowerCase()];if(!d)throw new Error("Supported files: PNG, JPEG, WebP, PDF and UTF-8 text/code.");let f=d==="text/plain"?1024*1024:2*1024*1024;if(u+=c.size,!c.size||c.size>f||u>4*1024*1024)throw new Error("Limits: 2 MiB per file, 1 MiB for text, 4 MiB total.");let h=await i0(c,t.defaultView);if(d==="text/plain"){let p=Uint8Array.from(atob(h),m=>m.charCodeAt(0));if(new TextDecoder("utf-8",{fatal:!0}).decode(p),p.includes(0))throw new Error("The selected file is not UTF-8 text.")}l.setItem("a_"+ee(),new k({name:c.name,mediaType:d,size:c.size,data:h}))}o&&e.SET(".attachments",l)}catch(s){o&&e.SET(".error",s.message)}finally{a(),r.remove(),o&&e.SET(".picking",!1)}}function jc(n,e){e.getRelativeData(".pending")||e.getRelativeData(".attachments").popNode(e.getAttr("attachment_id"))}function qc(n,e,{attachments:t}){let r=e.parentNode;for(let a of[...r.value.getNodes()])a.label.startsWith("a_")&&r.value.popNode(a.label);let o=new Oe;for(let a of t.getNodes()){let s=a.staticValue,l=o.root.div({node_label:a.label,display:"flex",align_items:"center",gap:"6px",padding:"4px 8px",border:"1px solid var(--gramlot-border-control,#aaa)",border_radius:"10px",flex_shrink:0});s.getItem("mediaType").startsWith("image/")&&l.img({src:"data:"+s.getItem("mediaType")+";base64,"+s.getItem("data"),alt:"Attachment preview",width:"36px",height:"36px",object_fit:"cover",border_radius:"6px"}),l.span("=="+JSON.stringify(s.getItem("name")),{font_size:"12px",max_width:"180px",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap"}),l.button({icon:"\xD7","aria-label":"Remove "+s.getItem("name"),disabled:"^.pending",class:"button--quiet"}).dataController({func:"chatRemoveAttachment",attachment_id:a.label})}let i=n.src.prepareSource(o.source);n.src.renderer.validateCandidate(i);for(let a of i.getNodes())n.src.builder.setChild(r.value,a.nodeTag,a.value,{...a.attr,node_label:a.label})}var sl=class{constructor({app:e,editor:t,design:r}){this.renderer=e.src.renderer,this.design=r;let o=this.renderer.records.get(r).presentation;this.frame=o.ownerDocument.createElement("iframe"),this.frame.title="Page canvas",this.frame.className="visual-editor-canvas-frame",this.frame.style.cssText="display:block;width:100%;height:100%;min-height:240px;border:0;background:white",o.before(this.frame);let i=this.frame.contentDocument;e.registerDocument(i);let a=i.createElement("style");a.textContent="html,body{margin:0;min-height:100%;} .visual-editor-canvas{min-height:100vh;}",this.styles=i.createElement("style");let s=i.createElement("style");s.textContent=".gramlot-source-selected{outline:2px solid #8ab4f8!important;outline-offset:-2px!important;}",i.head.append(a,this.styles,s),this.body=i.body,this.renderer.mountDestination(r,this.body),this.release=this.renderer.onDispose(t,()=>this.dispose())}setCss(e){this.styles.textContent=e.join(`
|
|
228
|
+
`)}dispose(){this.release?.(),this.release=null,this.frame.remove()}};var Mm=["string","number","integer","boolean","date","time","datetime","null"];function Uc(n){if(n===null)return"null";if(["string","boolean"].includes(typeof n))return typeof n;if(typeof n=="number"&&Number.isFinite(n))return Number.isSafeInteger(n)?"integer":"number";if(n instanceof Date&&Number.isFinite(n.getTime())){let e=n.toISOString();return e.slice(0,10)==="1970-01-01"?"time":e.endsWith("T00:00:00.000Z")?"date":"datetime"}return null}function ll(n,e){if(e==="null")return"";if(n instanceof Date){let t=n.toISOString();return e==="date"?t.slice(0,10):e==="time"?t.slice(11,23):t}return String(n)}function Vc(n,e){if(n==="string")return e;if(n==="null")return null;if(n==="boolean"&&["true","false"].includes(e))return e==="true";if((n==="number"||n==="integer")&&/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e.trim())){let t=Number(e);if(Number.isFinite(t)&&(n!=="integer"||Number.isSafeInteger(t)))return t}if(["date","time","datetime"].includes(n)&&(n==="date"?/^\d{4}-\d{2}-\d{2}$/:n==="time"?/^\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?$/:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?Z$/).test(e)){let r=n==="date"?`${e}T00:00:00Z`:n==="time"?`1970-01-01T${e}Z`:e,o=new Date(r);if(Number.isFinite(o.getTime())){let i=o.toISOString(),a=r.replace(/Z$/,"").split(/[T:.]/),s=i.replace(/Z$/,"").split(/[T:.]/);if(a.every((l,u)=>u===4?Number(l.padEnd(3,"0"))===Number(s[u]):l===s[u]))return o}}throw new Error(`Invalid ${n} value: ${e||"(empty)"}`)}var Qi=class{#e;#t;#r;#n;#o;#a=null;#i=null;#s=null;#l=!1;constructor({renderer:e,root:t,onSelect:r,canvas:o=e.records.get(t.parentNode)?.presentation}){if(!t?.parentNode||typeof r!="function")throw new TypeError("SourcePicker requires a mounted Source root and onSelect");if(!o||o.nodeType!==1)throw new TypeError("SourcePicker requires a mounted preview");this.#e=e,this.#t=t,this.#r=o,this.#n=r,o.addEventListener("pointerdown",this,!0),o.addEventListener("click",this,!0),this.#o=new o.ownerDocument.defaultView.MutationObserver(()=>this.#c()),this.#o.observe(o,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]}),this.#s=e.onDispose(t.parentNode,()=>this.dispose())}handleEvent(e){if(this.#l)return;let t=this.#t.fullpath+".",r=e.composedPath().map(i=>this.#e.elements.get(i)).find(i=>i?.node.fullpath.startsWith(t));if(!r)return;e.composedPath().some(i=>i.nodeType===1&&(i.matches("input:not([type=button]):not([type=submit]):not([type=reset]):not([type=image]), textarea, select, label")||i.isContentEditable))||(e.preventDefault(),e.stopImmediatePropagation()),this.#n(r.node)}select(e){if(!this.#l){if(e===null)this.#a=null;else{let t=this.#t.fullpath+".";if(!e.fullpath.startsWith(t))throw new TypeError("Selected node must be inside the preview Source root");this.#a=e.fullpath.slice(t.length)}this.#c()}}#c(){if(this.#l)return;let e=this.#a?this.#t.staticValue.getNode(this.#a):null,t=e?this.#e.records.get(e)?.presentation:null,r=t?.nodeType===1?t:null;this.#i!==r&&(this.#i?.classList.remove("gramlot-source-selected"),this.#i=r),r&&!r.classList.contains("gramlot-source-selected")&&r.classList.add("gramlot-source-selected")}dispose(){this.#l||(this.#l=!0,this.#o.disconnect(),this.#r.removeEventListener("pointerdown",this,!0),this.#r.removeEventListener("click",this,!0),this.#i?.classList.remove("gramlot-source-selected"),this.#s?.(),this.#s=null,this.#i=null)}};var zc={base:"",compact:`/* gramlot-compact: professional density profile; load after Base. */
|
|
228
229
|
@layer gramlot.tokens {
|
|
229
230
|
:root {
|
|
230
231
|
color-scheme: light;
|
|
@@ -1472,7 +1473,7 @@ export const buildId = "${n}";
|
|
|
1472
1473
|
:where([role="toolbar"]) { background:Canvas; color:CanvasText; backdrop-filter:none; }
|
|
1473
1474
|
}
|
|
1474
1475
|
}
|
|
1475
|
-
`},
|
|
1476
|
+
`},Hc={default:"",compact:`/* Color-only override: load after the chosen appearance profile. */
|
|
1476
1477
|
@layer gramlot.tokens {
|
|
1477
1478
|
:root {
|
|
1478
1479
|
color-scheme: light;
|
|
@@ -1748,8 +1749,8 @@ export const buildId = "${n}";
|
|
|
1748
1749
|
--gramlot-warning-background: #413820;
|
|
1749
1750
|
}
|
|
1750
1751
|
}
|
|
1751
|
-
`};function bt(n){for(let e=n;e;e=e.parentNode)if(e.getAttr("visualEditorId"))return e;throw new Error("Operation requires a VisualEditor Source ancestor")}function me(n){return bt(n).fullpath.split(".").slice(1).join(".")+".layout.center.design"}function it(n){return bt(n).absDatapath(".")}function $c(n,e){return n.rootBuilder.binding.nodeIds.get(bt(n).getAttr("visualEditorId")+e)}var Am=[["html.structure","Structure","main header footer nav section article aside div address search"],["html.text","Text and headings","h1 h2 h3 h4 h5 h6 hgroup p span a b strong i em small s u mark abbr cite code pre blockquote q br wbr hr time data dfn kbd samp var bdi bdo ruby rt rp sub sup ins del_"],["html.lists","Lists","ul ol li dl dt dd"],["html.forms","Forms","form input textarea select selectedcontent option optgroup datalist label fieldset legend output progress meter html_button"],["html.tables","Tables","table caption colgroup col thead tbody tfoot tr th td"],["html.media","Media and embedded content","img picture source audio video track canvas iframe embed object param map area"],["html.interaction","Disclosure and menus","details summary html_dialog html_menu"],["html.document","Document and metadata","html head body title base meta link style script noscript template slot"],["components.layout.containers","Containers","borderContainer contentPane framePane stackContainer tabContainer"],["components.layout.windows","Windows","dialog floatingPane"],["components.layout.composition","Composition","formlet groupBox trayPane transformPane"],["components.inputs.text","Text","textbox textBoxArea passwordbox"],["components.inputs.choices","Choices","checkbox radioButton radioButtonText checkBoxText filteringSelect comboBox callbackSelect dbSelect dbComboBox"],["components.inputs.numbers","Numbers and colors","numberTextBox horizontalSlider verticalSlider colorpicker"],["components.inputs.dates","Dates and times","dateTextBox timeTextBox dateCalendar"],["components.commands","Buttons and menus","button toggleButton dropDownButton menu menuline spacer"],["components.data","Trees and grids","tree grid searchBox"],["components.editors","Editors and previews","codeMirror htmlEditor htmlPreview markdownEditor markdownPreview typstPreview"]],X2={html:"HTML",components:"Gramlot","components.layout":"Layout","components.inputs":"Inputs"},ol=Object.fromEntries(["class","style","width","height","padding","margin","color","background"].map(n=>[n,{dtype:"T",nullable:!0}])),Sm=Object.fromEntries(["lbl_","box_"].flatMap(n=>Object.entries(ol).map(([e,t])=>[n+e,t]))),Mc=[["general","General"],["behaviour","Behaviour"],["validation","Validation"],["styles","Styles"],["container","Container"]],nl=["T","B","L","R","N","D","H"];function Dm(n,e){return/^(lbl|box)(_|$)/.test(n)?"general":e.has(n)?"container":n.startsWith("validate_")?"validation":Object.hasOwn(ol,n)||/^(icon|tab)/.test(n)||["design","labelPosition","switch_color","orientation"].includes(n)?"styles":/^(on[A-Z]|get[A-Z]|drag|drop)/.test(n)||["action","command","disabled","readonly","live","beforeClose","open","collapsed","closable","movable","resizable","collapsible","maximizable","maximized","persist","autoCollapse","openOnClick"].includes(n)?"behaviour":"general"}var Or=(n,e,t=null)=>{let r=n.builder.schema[e];if(!r)throw new Error(`Unknown widget: ${e}`);let o=r._meta?.gramlot_component;return{...(!t||!(t.getValue(!0)instanceof t.builder.source.constructor))&&(!o||o.command&&!Object.hasOwn(o.parameters,"caption"))?{_text:{dtype:"T",nullable:!0}}:{},...ol,...o?.labelbox?Sm:{},...o?.parameters??{},...n._getMeta("gramlot_component")?.childParameters??{}}},Pc=new WeakMap,Lc=class{chatRender(e,t){return Tc(this.page,e,t)}chatCompleted(e,t){Sc(this.page,e,t),e.GET(`${it(e)}.assistant.active`)&&e.SET(".pending",!0)}chatReset(e){return Dc(this.page,e)}chatResize(e){return Cc(this.page,e)}chatPickAttachments(e){return Nc(this.page,e)}chatRenderAttachments(e,t){return Oc(this.page,e,t)}chatRemoveAttachment(e){return Ic(this.page,e)}chatSend(e){if(e.GET(".pending")||!e.GET(".conversation.ready")||!e.GET(".draft")?.trim())return;let t=bt(e),r=t.GET(".editingMode"),o=e.builder.source.getNode(me(e)).value.toTytx(),i=r==="code"?t.GET(".codeDocument.content"):o;if(r==="code"&&!t.GET(".codeDocument.writable")){e.SET(".error","Page code editing is disabled by the host");return}let a=(t.GET(".assistantRun.run")??0)+1,s={commonParameters:ol,labelboxParameters:Sm,widgets:{}};for(let[l,u]of Object.entries(e.builder.schema)){if(u._meta?.data_element||u._meta?.subbuilder||u._meta?.container)continue;let c=u._meta?.gramlot_component;s.widgets[l]={parameters:c?.parameters??{},labelbox:!!c?.labelbox,childParameters:c?.childParameters??{}}}return t.SET(".assistantRun",new x({run:a,mode:r,next:0,expected:i,blocked:!1})),t.SET(".assistantStatus","Waiting for editing instructions\u2026"),t.SET(".assistant.context",new x({run:a,mode:r,language:t.GET(".codeDocument.language")??null,codeWritable:t.GET(".codeDocument.writable")===!0,code:r==="code"?i:null,source:o,selected:t.GET(".selection"),schema:JSON.stringify(s)})),Ac(this.page,e)}assistantState(e,{active:t}){if(t===!1){e.SET(`${it(e)}.chat.pending`,!1);let r=bt(e);r.GET(".assistantRun.next")===0&&r.SET(".assistantStatus","")}}assistantApply(e,{operations:t}){if(!(t instanceof x))return;let r=bt(e);for(let o of t.getNodes()){if(o.attr.run!==r.GET(".assistantRun.run")||o.attr.index<r.GET(".assistantRun.next"))continue;let i=e.builder.source.getNode(me(e)).value,a=r.GET(".assistantRun.mode"),s=a==="code"?r.GET(".codeDocument.content"):i.toTytx(),l=!1,u=!1,c="";try{if(r.GET(".assistantRun.blocked"))throw u=!0,new Error("The document was replaced during editing");if(o.attr.index!==r.GET(".assistantRun.next"))throw u=!0,new Error("Editing sequence is incomplete");if(s!==r.GET(".assistantRun.expected"))throw u=!0,new Error("Source changed during the request. Remaining edits stopped; send a new instruction.");let d=JSON.parse(o.value);if(a==="code"){if(d.operation!=="replace_code"||typeof d.content!="string")throw new Error("Expected a Page code draft operation");if(!r.GET(".codeDocument.writable")||r.GET(".codeDocument.busy"))throw new Error("Page code draft is not editable now");r.SET(".codeDocument.content",d.content),r.SET(".codeDocument.status","AI draft \xB7 Save to apply"),r.SET(".codeOpen",!0)}else this.applySourceEdit(r,d);l=!0,r.SET(".assistantRun.expected",a==="code"?r.GET(".codeDocument.content"):i.toTytx()),r.SET(".assistantStatus",`Applied ${o.attr.index+1}: ${a==="code"?"Page code draft":d.operation+" "+d.path}`)}catch(d){c=d.message,(a==="code"?r.GET(".codeDocument.content"):i.toTytx())!==s&&(u=!0),r.SET(".assistantRun.blocked",u),r.SET(".assistantStatus",`${u?"Editing stopped":"Rejected"}: ${c}`)}r.SET(".assistantRun.next",o.attr.index+1),r.SET(".assistant.ack",new x({run:o.attr.run,index:o.attr.index,applied:l,stop:u,error:c,mode:a,code:a==="code"?r.GET(".codeDocument.content"):null,source:i.toTytx(),selected:r.GET(".selection")}))}}applySourceEdit(e,t){let{operation:r,path:o,parent:i,tag:a,label:s,attributes:l={},text:u}=t,c=y=>typeof y=="string"&&/^pageRoot(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(y);if(!c(o)||r==="move"&&!c(i))throw new Error(`Use dot-separated paths inside pageRoot: ${JSON.stringify(o)}`);if(!["insert","update","remove","move"].includes(r))throw new Error("Unknown Source editing operation");if(["remove","move"].includes(r)&&o==="pageRoot")throw new Error("The page root is protected");if(r==="insert"&&(typeof s!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)))throw new Error("Choose an explicit node label");if(!l||typeof l!="object"||Array.isArray(l))throw new Error("Expected scalar attributes");for(let[y,E]of Object.entries(l))if(y.startsWith("_")||/^(connect_|on[A-Z]|script$|formula$|action$|func$|remote_)/.test(y)||["constructor","prototype"].includes(y)||E!==null&&typeof E=="object"||typeof E=="string"&&(E.startsWith("==")||E.includes(":=")))throw new Error(`Unsupported generated attribute: ${y}`);if(u!==void 0&&typeof u!="string")throw new Error("Text must be literal text");let d=e.builder.source.getNode(me(e)),f=e.rootBuilder.binding.gramlot,h=f.src.prepareSource(d.value.toTytx(),d.builder),m=h.getNode(o);if(!m)throw new Error("The Source target no longer exists");let p=m;if(r==="insert"){if(!e.builder.schema[a]||["script","style","iframe","object","embed"].includes(a)||e.builder.schema[a]._meta?.data_element)throw new Error("Choose a visual widget from the catalogue");if(m.value instanceof h.constructor&&m.value.getNode(s))throw new Error("This node label is already in use");p=m.builder.commandOnNode(m,a,u??null,{...l,node_label:s})}else if(r==="update"){if(u!==void 0&&m.value instanceof h.constructor)throw new Error("Text cannot replace a populated container");let y={...m.getAttr()};for(let[E,N]of Object.entries(l))N===null?delete y[E]:y[E]=N;m.setAttr(y,!0,!1,!1),u!==void 0&&m.setValue(u)}else if(r==="remove")m.parentBag.popNode(m.label);else{if(Object.keys(l).length||u!==void 0)throw new Error("Move and property edits must be separate operations");if(i===o||i.startsWith(o+"."))throw new Error("Cannot move a node into itself");let y=h.getNode(i);if(!y)throw new Error("The destination no longer exists");if(y.value instanceof h.constructor&&y.value.getNode(m.label))throw new Error("The destination already contains this label");p=this.appendBranch(y,m,m.label)}let w=y=>{if(y.value instanceof h.constructor){y.builder.validateChildren(y.nodeTag,y.value.getNodes().map(E=>E.nodeTag));for(let E of y.value.getNodes()){for(let[N,k]of Object.entries(Or(y,E.nodeTag,E)))this.validateParameter(y,E,N,k,E.getAttr(N));w(E)}}};h.getNodes().forEach(w),f.src.renderer.validateCandidate(h,{replacingNode:d});let b=e.builder.source.getNode(`${me(e)}.${o}`),_=o;r==="insert"?(this.appendBranch(b,p,s),_=`${o}.${s}`):r==="update"?(b.setAttr({...p.getAttr()},!0,!1,!1),u!==void 0&&b.setValue(u)):r==="remove"?(_=o.slice(0,o.lastIndexOf(".")),b.parentBag.popNode(b.label)):(this.applyDrop(e,{item:e.builder.source.getNode(`${me(e)}.${i}`),path:i,dropValues:{"app/source":{path:o}}}),_=`${i}.${b.label}`),e.SET(".sourceSearch",""),e.SET(".selection",_)}initializeCanvasSelection(e){let t=e.rootBuilder.binding.renderer,r=e.builder.source.getNode(me(e)),o=new Zi({renderer:t,root:r,onSelect:i=>{e.SET(".sourceSearch",""),e.SET(".selection",i.fullpath.slice(r.fullpath.length+1))}});Pc.set(r,o),t.onDispose(r.parentNode,()=>Pc.delete(r)),this.highlightSelection(e)}highlightSelection(e){let t=e.builder.source.getNode(me(e)),r=e.GET(".selection");Pc.get(t)?.select(r?t.staticValue.getNode(r):null)}clipboardShortcut(e,t){if(t.defaultPrevented||t.repeat||e.GET(".clipboardOpen")||e.GET(".insertionOpen")||e.GET(".uploadOpen")||t.composedPath().some(i=>i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)))return;let r=t.key.toLowerCase(),o=r==="f8"?"cutBranch":r==="f9"?"pasteBranch":null;!o||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),this[o](e))}clipboardModifiers(e,t){e.SET(".clipboardDropEffect",t.altKey?"copy":"move")}cutBranch(e){this.beginClipboard(e,e.GET(".selection"),!1)}copyBranch(e){this.beginClipboard(e,e.GET(".selection"),!0)}dropClipboard(e,{dropValues:t,dropEffect:r}){this.beginClipboard(e,t["app/source"].path,r==="copy")}prepareClipboard(e,{path:t,dragValues:r}){e.SET(".sourceDropEffect","copy"),r["app/clipboard"]={path:t}}branchSnapshot(e,t){let r=e.builder.source.getNode(me(e)),i=e.rootBuilder.binding.gramlot.src.prepareSource(r.getValue(!0).toTytx(),r.builder).getNode(t);if(!i)throw new Error("The Source branch no longer exists");let a=l=>{if(l.resolver)throw new Error("Resolver-backed branches cannot be stored in this trial");l.value instanceof e.builder.source.constructor&&l.value.getNodes().forEach(a)};a(i);let s=new e.builder.source.constructor(null,i.builder);return i.parentBag.popNode(i.label),s.setItem(i.label,i.getValue(!0),{...i.getAttr()},">",!1,!1,"editor",!1,!0,null,i.nodeTag),s.toTytx()}beginClipboard(e,t,r){e.SET(".error","");try{if(!t||t==="pageRoot")throw new Error("Choose a branch below the page root");let o=e.builder.source.getNode(`${me(e)}.${t}`);if(!o)throw new Error("The Source branch no longer exists");let i=this.branchSnapshot(e,t);e.SET(".clipboardDraft",new x({path:t,copy:r,name:o.label,wire:i,parentTag:o.parentNode.nodeTag})),e.SET(".clipboardOpen",!0)}catch(o){e.SET(".error",o.message)}}saveClipboard(e){e.SET(".error","");try{let t=e.GET(".clipboardDraft.name")?.trim();if(!t)throw new Error("Choose a name for the branch");let r=e.GET(".clipboardDraft.path"),o=e.GET(".clipboardDraft.wire"),i=e.GET(".clipboardDraft.copy"),a=e.builder.source.getNode(`${me(e)}.${r}`);if(!i&&(!a||this.branchSnapshot(e,r)!==o))throw new Error("The branch changed; select it again before cutting");let s=e.GET(".clipboard"),l=1;for(;s.getNode(`branch_${l}`);)l++;let u=`branch_${l}`;s.setItem(u,o,{name:t,parentTag:e.GET(".clipboardDraft.parentTag")}),e.SET(".clipboardSelection",u),e.SET(".clipboardVisible",!0),i||(e.SET(".selection",r.slice(0,r.lastIndexOf("."))),a.parentBag.popNode(a.label)),e.SET(".clipboardOpen",!1),e.SET(".fileStatus",`${i?"Copied":"Cut"}: ${t}`)}catch(t){e.SET(".error",t.message)}}pasteBranch(e){e.SET(".error","");try{this.beginPaste(e,e.GET(".clipboardSelection"),e.GET(".selection"))}catch(t){e.SET(".error",t.message)}}beginPaste(e,t,r){let o=t?e.GET(".clipboard").getNode(t):null;if(!o)throw new Error("Choose a saved branch in the clipboard");let i=r?e.builder.source.getNode(`${me(e)}.${r}`):null;if(!i)throw new Error("Choose a destination in the Source tree");let a=e.rootBuilder.binding.gramlot.src.prepareSource(o.getValue(!0),i.builder),s=a.getNodes()[0];i.builder.validateParent(s.nodeTag,i.nodeTag);let l=i.getValue(!0);i.builder.validateChildren(i.nodeTag,[...l instanceof e.builder.source.constructor?l.getNodes().map(b=>b.nodeTag):[],s.nodeTag]);let u={...s.getAttr()},c=i.builder.schema[s.nodeTag]._meta?.gramlot_component?.parameters??{},d=i.builder.schema[o.getAttr("parentTag")]?._meta?.gramlot_component?.childParameters??{};for(let b of Object.keys(d))b in c||delete u[b];s.setAttr(u,!0,!1,!1),e.SET(".insertion",new x({parentPath:r,tag:s.nodeTag,clipboard:a.toTytx()}));let f=Or(i,s.nodeTag),h=Object.entries(f).filter(([b,_])=>_.required&&(u[b]==null||u[b]===""||_.unique));if(!h.length){this.finishPaste(e);return}let m=$c(e,"InsertFields");m.getValue(!0).clear();let p=e.builder.wrapSource(m);p.p(`Paste ${o.getAttr("name")} into ${i.label} [${i.nodeTag}]`,{class:"visual-editor-hint"});let w=p.formlet({columns:2,gap:"8px 10px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});for(let[b,_]of h)this.parameterField(e,w,s.nodeTag,b,_,"insertion",_.default);e.SET(".insertionOpen",!0)}appendBranch(e,t,r){let o=e.builder.source.constructor,i=e.getValue(!0);if(!(i instanceof o)){let a=i;i=new o(null,e.builder),e.builder.promoteNodeValue(e,a,i)}return t.parentBag.popNode(t.label),i.setItem(r,t.getValue(!0),{...t.getAttr()},">",!1,!1,"editor",!1,!0,null,t.nodeTag),i.getNode(r)}finishPaste(e){let t=e.GET(".insertion.parentPath"),r=e.builder.source.getNode(`${me(e)}.${t}`);if(!r)throw new Error("The destination no longer exists");let o=e.rootBuilder.binding.gramlot,a=o.src.prepareSource(e.GET(".insertion.clipboard"),r.builder).getNodes()[0],s={...a.getAttr()};for(let[w,b]of Object.entries(Or(r,a.nodeTag))){if(!b.required)continue;let _=e.GET(`.insertion.types.${w}`),y=e.GET(`.insertion.parameters.${w}${b.enum?"":_?"."+_:""}`);y!=null&&(s[w]=y),this.validateParameter(r,null,w,b,s[w])}a.setAttr(s,!0,!1,!1);let l=r.getValue(!0),u=a.label,c=1;for(;l instanceof e.builder.source.constructor&&l.getNode(u);)u=`${a.label}_${c++}`;let d=e.builder.source.getNode(me(e)),f=o.src.prepareSource(d.getValue(!0).toTytx(),d.builder),h=f.getNode(t);h.builder.validateParent(a.nodeTag,h.nodeTag);let m=h.getValue(!0);h.builder.validateChildren(h.nodeTag,[...m instanceof e.builder.source.constructor?m.getNodes().map(w=>w.nodeTag):[],a.nodeTag]);let p=this.appendBranch(h,a,u);o.src.renderer.validateCandidate(f,{replacingNode:d}),this.appendBranch(r,p,u),e.SET(".insertionOpen",!1),e.SET(".sourceSearch",""),e.SET(".selection",`${t}.${u}`),e.SET(".fileStatus","Branch pasted")}openCode(e){let t=bt(e);t.SET(".codeOpen",!0),t.SET(".editingMode","code")}async codeSave(e){let t=bt(e),r=t.GET(".codeDocument");if(r.getItem("busy")||!r.getItem("writable"))return;let o=r.getItem("content"),i=r.getItem("revision"),a=!1;if(o===r.getItem("saved"))return;let s=new AbortController,l=this.page.src.renderer.onDispose(t,()=>s.abort());r.setItem("busy",!0),r.setItem("status","Saving Page code\u2026");let u=t.value.getNode("layout.center.design"),c=u.value.toTytx();try{let d=await this.page.rpc.call("data","editor_document_save",{key:t.getAttr("codeDocumentKey"),content:o,revision:i},{signal:s.signal});if(s.signal.aborted)return;r.setItem("revision",d.revision),r.setItem("saved",o),a=!0,r.setItem("status","Page code saved"),c!==u.value.toTytx()?r.setItem("status","Page code saved; Source changed meanwhile. Use Preview saved to replace it."):await this.codeLoadPreview(t,s)}catch(d){s.signal.aborted||r.setItem("status",`${a?"Page code saved; preview failed":"Save failed"}: ${d.message}`)}finally{l(),s.signal.aborted||r.setItem("busy",!1)}}async codePreview(e){let t=bt(e),r=t.GET(".codeDocument");if(r.getItem("busy"))return;let o=new AbortController,i=this.page.src.renderer.onDispose(t,()=>o.abort());r.setItem("busy",!0);try{await this.codeLoadPreview(t,o)}catch(a){o.signal.aborted||r.setItem("status",`Preview failed: ${a.message}`)}finally{i(),o.signal.aborted||r.setItem("busy",!1)}}async codeLoadPreview(e,t){let r=e.GET(".codeDocument"),o=e.value.getNode("layout.center.design"),i=o.value.toTytx(),a=await this.page.rpc.call("source","editor_document_preview",{key:e.getAttr("codeDocumentKey"),revision:r.getItem("revision"),data_root:e.GET(".dataRoot")},{signal:t.signal});if(t.signal.aborted)return;if(o.value.toTytx()!==i)throw new Error("Source changed while preparing preview; it was retained");let s=this.page.src.prepareSource(a,o.builder);this.page.src.renderer.validateCandidate(s,{replacingNode:o}),e.GET(".assistantRun")&&e.SET(".assistantRun.blocked",!0),e.SET(".selection",null),o.setValue(s,!0,{_text:null},!0),e.SET(".selection","pageRoot"),r.setItem("status",r.getItem("content")===r.getItem("saved")?"Saved Page code \xB7 preview updated":"Preview updated from saved page code; newer draft retained")}newPage(e){e.GET(".assistantRun")&&e.SET(".assistantRun.blocked",!0),e.SET(".selection",null),e.SET(".insertionOpen",!1),e.SET(".error","");let t=e.builder.source.getNode(me(e));t.getValue(!0).clear();let r=e.GET(".dataRoot");if(r)e.SET(r,new x);else for(let o of e.rootBuilder.data.getNodes())o.label!=="__editor"&&e.rootBuilder.data.popNode(o.label);e.builder.wrapSource(t).div({node_label:"pageRoot",...r?{datapath:r}:{}}),e.SET(".filename","page.grmlt"),e.SET(".fileStatus",""),e.SET(".sourceSearch",""),e.SET(".dataSearch",""),e.SET(".selection","pageRoot")}async copySource(e){e.SET(".fileStatus","");try{let t=e.builder.source.getNode(me(e)).getValue(!0);await e.rootBuilder.binding.gramlot.utl.inout.copyText(t.toTytx()),e.SET(".fileStatus","Source copied")}catch(t){e.SET(".fileStatus",`Copy failed: ${t.message}`)}}downloadPage(e){let t=e.builder.source.getNode(me(e)).getValue(!0);e.rootBuilder.binding.gramlot.utl.inout.saveText(t.toTytx(),e.GET(".filename"),"application/json")}openUpload(e){e.SET(".uploadOpen",!0)}sourceUploaded(e,{item:t,result:r}){try{let o=e.rootBuilder.binding.gramlot,i=e.builder.source.getNode(me(e)),a=o.src.prepareSource(r,i.builder),s=a.getNodes();if(s.length!==1||s[0].label!=="pageRoot")throw new Error("Expected one pageRoot Source");o.src.renderer.validateCandidate(a,{replacingNode:i}),e.GET(".assistantRun")&&e.SET(".assistantRun.blocked",!0),i.setValue(a,!0,{_text:null},!0),e.SET(".filename",t.value.getItem("name")),e.SET(".selection","pageRoot"),e.SET(".fileStatus","Source opened"),e.SET(".uploadOpen",!1)}catch(o){throw e.SET(".fileStatus",`Open failed: ${o.message}`),o}}toggleNavigation(e){e.SET(".navigationOpen",e.GET(".navigationOpen")==="close"?!0:"close")}openCatalogue(e){e.SET(`${it(e)}.catalogueOpen`,!0)}openProperties(e){this.showProperties(e,{path:e.GET(".selection")})}sourceLabel(e,{item:t}){return{text:`${t.label} [${t.nodeTag}]`}}dropNode(e,t){e.SET(".error","");try{this.applyDrop(e,t)}catch(r){e.SET(".error",r.message)}}insertWidget(e){e.SET(".error","");try{this.applyInsert(e)}catch(t){e.SET(".error",t.message)}}initializeEditorAppearance(e){let t=bt(e),r=e.rootBuilder.binding.renderer.destination.ownerDocument;t.SET(".appearanceProfile","compact"),t.SET(".appearancePalette","joanna"),t.SET(".appearanceMode",r.documentElement.getAttribute("data-theme")||"dark")}applyEditorAppearance(e,{profile:t,palette:r,mode:o}){if(!t||!r||!o)return;if(!Object.hasOwn(Rc,t)||!Object.hasOwn(Bc,r)||!["light","dark"].includes(o))throw new Error("Choose a declared theme, palette and color mode");bt(e).SET(".appearanceCss",Rc[t]+`
|
|
1752
|
-
`+Bc[r]),e.rootBuilder.binding.renderer.destination.ownerDocument.documentElement.setAttribute("data-theme",o)}initializeEditor(e,{dataRoot:t}){if(e.SET(".editingMode","source"),e.SET(".clipboard",new x),e.SET(".clipboardVisible",!1),e.SET(".clipboardDropEffect","move"),e.SET(".sourceDropEffect","move"),e.SET(".dataRoot",t),e.SET(".filename","page.grmlt"),e.SET(".fileStatus",""),e.SET(".selection","pageRoot"),t)e.GET(t)==null&&e.SET(t,new x);else{let a=it(e),s=a.split(".").map(()=>"#parent").join(".");e.builder.source.getNode(me(e)).setAttr({datapath:`${a}.${s}`})}let r=new x,o=new Map([["",r]]),i=(a,s)=>{if(o.has(a))return o.get(a);let l=a.split("."),u=l.pop(),c=l.join("."),d=i(c,X2[c]),f=new x;return d.setItem(u,f,{caption:s}),o.set(a,f),f};for(let[a,s,l]of Am)l.split(" ").some(u=>e.builder.schema[u])&&i(a,s);for(let[a,s]of Object.entries(e.builder.schema).sort(([l],[u])=>l.localeCompare(u))){if(s._meta?.data_element||s._meta?.subbuilder||s._meta?.container)continue;let l=s._meta?.gramlot_component?"components":"html",u=Am.find(([d,,f])=>d.startsWith(l+".")&&f.split(" ").includes(a)),c=u?u[0]:`${l}.other`;i(c,u?u[1]:"Other elements").setItem(a,null,{caption:a,tag:a})}e.SET(".catalogue",r)}prepareWidget(e,{item:t,dragValues:r}){if(e.SET(".sourceDropEffect","copy"),!t.attr.tag)return!1;r["app/widget"]={tag:t.attr.tag}}prepareSource(e,{path:t,dragValues:r}){e.SET(".sourceDropEffect","move"),r["app/source"]={path:t}}applyDrop(e,{item:t,path:r,dropValues:o}){if(o["app/clipboard"]){this.beginPaste(e,o["app/clipboard"].path,r);return}if(o["app/source"]){let f=`${me(e)}.${o["app/source"].path}`,h=`${me(e)}.${r}`,m=e.builder.source.getNode(f);if(!m||f===`${me(e)}.pageRoot`)throw new Error("The page root cannot be moved");if(m.resolver)throw new Error("Resolver-backed Source nodes cannot be moved in this trial");if(f===h||h.startsWith(f+"."))throw new Error("A node cannot be moved into itself");let p=t,w=m.parentBag,b=e.builder.source.constructor;if(m.builder!==p.builder)throw new Error("Nodes cannot cross builder dialects");let _=p.getValue(!0),y=_ instanceof b?_.getNodes().filter(N=>N!==m):[];if(_ instanceof b&&_!==w&&_.getNode(m.label))throw new Error("The target already contains this label");let E=p._getMeta("gramlot_component")?.childParameters??{};for(let[N,k]of Object.entries(E)){let C=m.getAttr(N);if(k.required&&C==null)throw new Error(`The moved node requires ${N}`);if(k.enum&&C!=null&&!k.enum.includes(C))throw new Error(`Invalid ${N}`);if(k.unique&&C!=null&&y.some(O=>O.getAttr(N)===C))throw new Error(`${N} is already in use`)}if(p.builder.validateParent(m.nodeTag,p.nodeTag),p.builder.validateChildren(p.nodeTag,[...y.map(N=>N.nodeTag),m.nodeTag]),_===w)w.move(w.getNodes().indexOf(m),y.length);else{let N=_ instanceof b?_:new b(null,p.builder);_ instanceof b||p.builder.promoteNodeValue(p,_,N);let k={label:m.label,tag:m.nodeTag,value:m.getValue(!0),attrs:{...m.getAttr()}};w.popNode(k.label),N.setItem(k.label,k.value,k.attrs,N.getNodes().length,!1,!1,"editor",!1,!0,null,k.tag)}e.SET(".selection",`${r}.${m.label}`);return}let i=o["app/widget"].tag;t.builder.validateParent(i,t.nodeTag);let a=t.getValue(!0);t.builder.validateChildren(t.nodeTag,[...a instanceof e.builder.source.constructor?a.getNodes().map(f=>f.nodeTag):[],i]);let s=Or(t,i),l=Object.entries(s).filter(([,f])=>f.required);if(e.SET(".insertion",new x),e.SET(".insertion.parentPath",r),e.SET(".insertion.tag",i),!l.length){this.applyInsert(e);return}let u=$c(e,"InsertFields");u.getValue(!0).clear();let c=e.builder.wrapSource(u);c.p(`Insert ${i} into ${t.label} [${t.nodeTag}]`,{class:"visual-editor-hint"});let d=c.formlet({columns:2,gap:"8px 10px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});for(let[f,h]of l)this.parameterField(e,d,i,f,h,"insertion",h.default);e.SET(".insertionOpen",!0)}showProperties(e,{path:t}){let r=$c(e,"EditorFields");if(r.getValue(!0).clear(),e.SET(".propertyError",""),e.SET(".properties",new x),!t){e.SET(".propertiesOpen",!1);return}let o=e.builder.source.getNode(`${me(e)}.${t}`);if(!o){e.SET(".propertiesOpen",!1);return}let i=o.parentNode,a=Or(i,o.nodeTag,o);e.SET(".properties.path",t),e.SET(".propertiesTitle",`${o.label} [${o.nodeTag}]`),e.SET(".propertiesHeight",`${Math.min(340,120+Math.ceil(Object.keys(a).filter(d=>Dm(d,new Set)==="general").length/2)*48)}px`);let s=e.builder.wrapSource(r);t!=="pageRoot"&&s.p(t,{class:"visual-editor-destination"});let l=new Set(Object.keys(i._getMeta("gramlot_component")?.childParameters??{})),u=new Map(Mc.map(([d])=>[d,[]]));for(let d of Object.entries(a))u.get(Dm(d[0],l)).push(d);e.SET(".parameterTab",Mc.find(([d])=>u.get(d).length)[0]);let c=s.tabContainer({selectedPage:`^${it(e)}.parameterTab`,class:"visual-parameter-tabs",tabMode:"underline",height:"100%",min_height:0,flex:1});for(let[d,f]of Mc){if(!u.get(d).length)continue;let h=c.contentPane({pageName:d,title:f,overflow:"auto",padding:"10px",min_height:0});d==="container"&&h.p(`Child parameters of ${i.nodeTag}`,{class:"visual-editor-hint"}),d==="behaviour"&&Object.hasOwn(a,"action")&&h.p("action: use a named Logic method, for example openCatalogue.",{class:"visual-editor-hint"}),d==="behaviour"&&o.nodeTag==="borderContainer"&&h.p("persist remembers splitter sizes and requires a stable container id.",{class:"visual-editor-hint"});let m=h.formlet({columns:2,gap:"8px 10px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});d==="general"&&o._getMeta("gramlot_component")?.labelbox&&this.labelboxFields(e,m,o,a);let p,w=([,b])=>{let _=Array.isArray(b.dtype)?b.dtype:[b.dtype];return!b.enum&&!_.some(y=>nl.includes(y))?2:b.dtype==="B"?1:0};for(let[b,_]of[...u.get(d)].sort((y,E)=>w(y)-w(E))){if(o._getMeta("gramlot_component")?.labelbox&&/^(lbl|box)(_|$)/.test(b))continue;let y=m;if(d==="validation"&&/(_if|_error|_warning|_iswarning)$/.test(b)){if(!p){let N=h.details({class:"visual-validation-advanced"});N.summary("Conditions and messages"),p=N.formlet({columns:2,gap:"8px 10px",lbl_position:"TL",box_c_width:"100%",align_items:"start"})}y=p}let E=b==="_text"?o.getValue(!0):o.getAttr(b);this.parameterField(e,y,o.nodeTag,b,_,"properties",E??_.default)}}e.SET(".propertiesOpen",!0)}toggleLabelboxAttributes(e,{prefix:t}){e.SET(`.properties.${t}Hidden`,!e.GET(`.properties.${t}Hidden`))}labelboxFields(e,t,r,o){for(let i of["lbl","box"]){let a=i==="lbl"?"Label":"Box",s=t.div({class:"visual-labelbox-section",grid_column:"1 / -1"}),l=s.div({class:"visual-labelbox-heading"});i==="lbl"?this.parameterField(e,l,r.nodeTag,"lbl",o.lbl,"properties",r.getAttr("lbl")):l.span(a,{class:"visual-labelbox-title"}),l.button({iconSrc:He.properties,title:`Edit ${a.toLowerCase()} attributes`,"aria-label":`Edit ${a.toLowerCase()} attributes`,class:"button--quiet",action:"toggleLabelboxAttributes",prefix:i});let u=Object.entries(o).filter(([f])=>f.startsWith(i+"_"));e.SET(`.properties.${i}Hidden`,!0),e.SET(`.properties.${i}Attribute`,"");let c=s.div({class:"visual-labelbox-attribute",hidden:`^${it(e)}.properties.${i}Hidden`}),d=c.select({"aria-label":`${a} attribute`,value:`^${it(e)}.properties.${i}Attribute`});d.option("Which attribute?",{value:""});for(let[f]of u)d.option(f.slice(i.length+1),{value:f});c.div({node_label:"attributeValue"}).span(""),c.dataController({func:"renderLabelboxAttribute",_init:!0,parameterName:`^${it(e)}.properties.${i}Attribute`,editingPath:e.GET(".properties.path")})}}renderLabelboxAttribute(e,{parameterName:t,editingPath:r}){let o=e.parentBag.getNode("attributeValue");if(o.getValue(!0).clear(),!t||r!==e.GET(".selection"))return;let i=e.builder.source.getNode(`${me(e)}.${r}`),a=Or(i.parentNode,i.nodeTag,i)[t];this.parameterField(e,e.builder.wrapSource(o),i.nodeTag,t,a,"properties",i.getAttr(t)??a.default,!0)}parameterField(e,t,r,o,i,a,s,l=!1){let u=o==="lbl"?"Label":o==="_text"&&e.builder.schema[r]._meta?.gramlot_component?.command?"caption":o==="_text"?"Text":o,c=`${it(e)}.${a}.parameters.${o}`;if(i.enum){e.SET(c,s??"");let w=t.select({lbl:l?null:u,lbl_position:"TL",value:`^${c}`,"aria-label":o});w.option("",{value:""});for(let b of i.enum)w.option(String(b),{value:b});a==="properties"&&t.dataController({func:"changeProperty",value:`^${c}`,_userChanges:!0,parameterName:o,editingPath:e.GET(".properties.path")});return}let d=Array.isArray(i.dtype)?i.dtype:i.dtype?[i.dtype]:[],f=d.filter(w=>nl.includes(w));if(!f.length){t.p(`${u}: no editor is available for this declared type`,{class:"visual-editor-hint",grid_column:"1 / -1"});return}let h="";if(s==null?h=f.length===1?f[0]:"":typeof s=="boolean"&&f.includes("B")?h="B":typeof s=="string"&&f.includes("T")?h="T":typeof s=="number"?h=f.find(w=>["L","R","N"].includes(w))??"":s instanceof Date?h=f.find(w=>["D","H"].includes(w))??"":f.length===1&&f[0]==="N"&&(h="N"),s!=null&&!h){t.p(`${u}: the current value is not editable with these scalar types`,{class:"visual-editor-hint",grid_column:"1 / -1"});return}e.SET(`${it(e)}.${a}.types.${o}`,h);for(let w of f)e.SET(`${c}.${w}`,w===h?s??null:null);let m=!l&&(d.length>1||/^(tooltip|_text|action|placeholder|value)$|(_error|_warning|_if)$/.test(o)),p=t.div({class:"visual-parameter-field",grid_column:m?"1 / -1":"auto",grid_template_columns:d.length>1?"minmax(100px, 1fr) minmax(0, 2fr)":"minmax(0, 1fr)",align_items:"start"});if(d.length>1){let w=p.select({lbl:`${u} type`,lbl_position:"TL",value:`^${it(e)}.${a}.types.${o}`,"aria-label":`${o} type`});w.option("Not set",{value:""});for(let b of d)w.option(nl.includes(b)?b:`${b} (unavailable)`,{value:b,disabled:!nl.includes(b)});a==="properties"&&p.dataController({func:"changePropertyType",type:`^${it(e)}.${a}.types.${o}`,_userChanges:!0,parameterName:o,editingPath:e.GET(".properties.path")})}p.div({node_label:"input"}).span(""),p.dataController({func:"renderParameterInput",_init:!0,type:`^${it(e)}.${a}.types.${o}`,parameterName:o,parameterLabel:u,scope:a,compact:l,multiple:d.length>1})}renderParameterInput(e,{type:t,parameterName:r,parameterLabel:o,scope:i,multiple:a,compact:s}){let l=e.parentBag.getNode("input");if(l.getValue(!0).clear(),!t)return;let u=e.builder.wrapSource(l),c=a?`${o} (${t})`:o,d=`^${it(e)}.${i}.parameters.${r}.${t}`,f={lbl:s?null:c,lbl_position:"TL",value:d,"aria-label":c};if(t==="B")u.checkbox(f);else if(["L","R","N"].includes(t))u.numberTextBox({...f,dtype:t});else if(t==="D")u.dateTextBox(f);else if(t==="H")u.timeTextBox(f);else if(t==="T"&&/^(lbl|box)_color$/.test(r))u.colorpicker(f);else if(t==="T")u.textbox(f);else throw new Error(`No parameter editor for ${t}`);i==="properties"&&u.dataController({func:"changeProperty",value:d,_userChanges:!0,parameterName:r,editingPath:e.GET(".properties.path")})}changePropertyType(e,{type:t,parameterName:r,editingPath:o}){this.changeProperty(e,{parameterName:r,editingPath:o,value:t?e.GET(`.properties.parameters.${r}.${t}`):null})}changeProperty(e,{value:t,parameterName:r,editingPath:o}){if(o===e.GET(".selection")){e.SET(".propertyError","");try{let i=e.builder.source.getNode(`${me(e)}.${o}`);if(!i)throw new Error("The selected Source node no longer exists");let s=Or(i.parentNode,i.nodeTag,i)[r];if(!s)throw new Error(`Unknown parameter: ${r}`);if(this.validateParameter(i.parentNode,i,r,s,t),r==="_text")i.setValue(t??"");else{let l={...i.getAttr()};t==null||t===""?delete l[r]:l[r]=t,i.setAttr(l,!0,!1,!1)}}catch(i){e.SET(".propertyError",i.message)}}}validateParameter(e,t,r,o,i){let a=i==null||i==="";if(o.required&&a)throw new Error(`Choose ${r}`);if(!a&&o.enum&&!o.enum.includes(i))throw new Error(`Invalid ${r}`);let s=e.getValue(!0);if(!a&&o.unique&&s instanceof e.builder.source.constructor&&s.getNodes().some(l=>l!==t&&l.getAttr(r)===i))throw new Error(`${r} is already in use`)}applyInsert(e){if(e.GET(".insertion.clipboard")){this.finishPaste(e);return}let t=e.GET(".insertion.parentPath"),r=e.builder.source.getNode(`${me(e)}.${t}`);if(!r)throw new Error("The target Source node is no longer available");let o=e.GET(".insertion.tag"),i={};for(let[s,l]of Object.entries(Or(r,o)).filter(([,u])=>u.required)){let u=e.GET(`.insertion.types.${s}`),c=e.GET(`.insertion.parameters.${s}${l.enum?"":u?"."+u:""}`);this.validateParameter(r,null,s,l,c),i[s]=c}let a=r.builder.commandOnNode(r,o,null,i);e.SET(".insertionOpen",!1),e.SET(".selection",`${t}.${a.label}`)}};export{x as Bag,Et as BagNode,Ec as BrowserCameraProvider,np as ChoiceGroup,Do as CommandRegistry,vr as ComponentCollection,Bi as DeviceHandler,qi as DirectoryResolver,Ri as DomHandler,Us as Exposed,_m as FieldState,Ui as FileSystemController,gn as FileSystemLogic,go as FramePage,Pi as Gramlot,Ie as GramlotBuilder,ln as GramlotHtmlRenderer,Ii as GramlotRenderer,vi as GramlotSvgRenderer,Ke as Handler,So as HttpTransport,Ws as IdeLogic,$i as InOut,Vs as IndexLogic,ji as IndexPage,gc as Labelbox,Ao as MobileEnvironment,rp as NativeControl,mc as NavigationResolver,Fi as Page,tc as PageBootstrap,fi as References,rn as RpcError,hi as RpcHandler,nr as ServerAdapter,Oi as SourceHandler,Zs as SourceImport,Zi as SourcePicker,Vi as TreeStore,Ys as TreeStoreLogic,Nr as TreeStoreResolver,bo as UploadTarget,Mi as UtilitiesHandler,Xs as VisualEditor,Lc as VisualEditorLogic,Sc as chatCompleted,Nc as chatPickAttachments,Ic as chatRemoveAttachment,Tc as chatRender,Oc as chatRenderAttachments,Dc as chatReset,Cc as chatResize,Ac as chatSend,zs as codeMirrorWithOptions,Em as collectionBuildId,F2 as createDOMPurify,Pt as createDecimal,Pu as defineCollection,Er as defineComponent,Xp as fileSystemTree,j as fromTytx,fh as fromTytxIter,j2 as loadMarkdown,nc as mountIndexPage,ws as parseDateExpression,ae as sourceTarget,F as toTytx,H2 as verifyCollectionArtifact,bt as visualEditorScope};
|
|
1752
|
+
`};function ae(n){for(let e=n;e;e=e.parentNode)if(e.getAttr("visualEditorId"))return e;throw new Error("Operation requires a VisualEditor Source ancestor")}function fe(n){return ae(n).fullpath.split(".").slice(1).join(".")+".layout.center.design"}function Qe(n){return ae(n).absDatapath(".")}function ul(n,e){return n.rootBuilder.binding.nodeIds.get(ae(n).getAttr("visualEditorId")+e)}var Pm=[["html.structure","Structure","main header footer nav section article aside div address search"],["html.text","Text and headings","h1 h2 h3 h4 h5 h6 hgroup p span a b strong i em small s u mark abbr cite code pre blockquote q br wbr hr time data dfn kbd samp var bdi bdo ruby rt rp sub sup ins del_"],["html.lists","Lists","ul ol li dl dt dd"],["html.forms","Forms","form input textarea select selectedcontent option optgroup datalist label fieldset legend output progress meter html_button"],["html.tables","Tables","table caption colgroup col thead tbody tfoot tr th td"],["html.media","Media and embedded content","img picture source audio video track canvas iframe embed object param map area"],["html.interaction","Disclosure and menus","details summary html_dialog html_menu"],["html.document","Document and metadata","html head body title base meta link style script noscript template slot"],["components.layout.containers","Containers","borderContainer contentPane framePane stackContainer tabContainer"],["components.layout.windows","Windows","dialog floatingPane"],["components.layout.composition","Composition","formlet groupBox trayPane transformPane"],["components.inputs.text","Text","textbox textBoxArea passwordbox"],["components.inputs.choices","Choices","checkbox radioButton radioButtonText checkBoxText filteringSelect comboBox callbackSelect dbSelect dbComboBox"],["components.inputs.numbers","Numbers and colors","numberTextBox horizontalSlider verticalSlider colorpicker"],["components.inputs.dates","Dates and times","dateTextBox timeTextBox dateCalendar"],["components.commands","Buttons and menus","button toggleButton dropDownButton menu menuline spacer"],["components.data","Trees and grids","tree grid searchBox"],["components.editors","Editors and previews","codeMirror htmlEditor htmlPreview markdownEditor markdownPreview typstPreview"]],a0={html:"HTML",components:"Gramlot","components.layout":"Layout","components.inputs":"Inputs"},fl=Object.fromEntries(["class","style","width","height","padding","margin","color","background"].map(n=>[n,{dtype:"T",nullable:!0}])),Lm=Object.fromEntries(["lbl_","box_"].flatMap(n=>Object.entries(fl).map(([e,t])=>[n+e,t]))),Gc=[["general","General"],["behaviour","Behaviour"],["validation","Validation"],["styles","Styles"],["container","Container"]],cl=["T","B","L","R","N","D","H"];function Wc(n,e){return/^(lbl|box)(_|$)/.test(n)?"general":e.has(n)?"container":n.startsWith("validate_")?"validation":Object.hasOwn(fl,n)||/^(icon|tab)/.test(n)||["design","labelPosition","switch_color","orientation"].includes(n)?"styles":/^(on[A-Z]|get[A-Z]|drag|drop)/.test(n)||["action","command","disabled","readonly","live","beforeClose","open","collapsed","closable","movable","resizable","collapsible","maximizable","maximized","persist","autoCollapse","openOnClick"].includes(n)?"behaviour":"general"}var nr=(n,e,t=null)=>{let r=n.builder.schema[e];if(!r)throw new Error(`Unknown widget: ${e}`);let o=r._meta?.gramlot_component;return{...(!t||!(t.getValue(!0)instanceof t.builder.source.constructor))&&(!o||o.command&&!Object.hasOwn(o.parameters,"caption"))?{_text:{dtype:"T",nullable:!0}}:{},...fl,...o?.labelbox?Lm:{},...o?.parameters??{},...n._getMeta("gramlot_component")?.childParameters??{}}},dl=new WeakMap,ea=new WeakMap,Yc=class{chatRender(e,t){return Bc(this.page,e,t)}chatCompleted(e,t){Pc(this.page,e,t),e.GET(`${Qe(e)}.assistant.active`)&&e.SET(".pending",!0)}chatReset(e){return Mc(this.page,e)}chatResize(e){return Lc(this.page,e)}chatPickAttachments(e){return Fc(this.page,e)}chatRenderAttachments(e,t){return qc(this.page,e,t)}chatRemoveAttachment(e){return jc(this.page,e)}chatSend(e){if(e.GET(".pending")||!e.GET(".conversation.ready")||!e.GET(".draft")?.trim())return;let t=ae(e),r=t.GET(".editingMode"),o=e.builder.source.getNode(fe(e)).value.toTytx(),i=r==="code"?t.GET(".codeDocument.content"):o;if(r==="code"&&!t.GET(".codeDocument.writable")){e.SET(".error","Page code editing is disabled by the host");return}let a=(t.GET(".assistantRun.run")??0)+1,s=t.GET(".catalogueScope"),l={commonParameters:fl,labelboxParameters:Lm,widgets:{}};for(let[u,c]of Object.entries(e.builder.schema)){if(!vo(s,u,c._meta??{})||c._meta?.data_element||c._meta?.subbuilder||c._meta?.container)continue;let d=c._meta?.gramlot_component;l.widgets[u]={parameters:d?.parameters??{},labelbox:!!d?.labelbox,childParameters:d?.childParameters??{}}}return t.SET(".assistantRun",new k({run:a,mode:r,next:0,expected:i,blocked:!1})),t.SET(".assistantStatus","Waiting for editing instructions\u2026"),t.SET(".assistant.context",new k({run:a,mode:r,language:t.GET(".codeDocument.language")??null,codeWritable:t.GET(".codeDocument.writable")===!0,code:r==="code"?i:null,source:o,selected:t.GET(".selection"),schema:JSON.stringify(l)})),$c(this.page,e)}assistantState(e,{active:t}){if(t===!1){e.SET(`${Qe(e)}.chat.pending`,!1);let r=ae(e);r.GET(".assistantRun.next")===0&&r.SET(".assistantStatus","")}}assistantApply(e,{operations:t}){if(!(t instanceof k))return;let r=ae(e);for(let o of t.getNodes()){if(o.attr.run!==r.GET(".assistantRun.run")||o.attr.index<r.GET(".assistantRun.next"))continue;let i=e.builder.source.getNode(fe(e)).value,a=r.GET(".assistantRun.mode"),s=a==="code"?r.GET(".codeDocument.content"):i.toTytx(),l=!1,u=!1,c="";try{if(r.GET(".assistantRun.blocked"))throw u=!0,new Error("The document was replaced during editing");if(o.attr.index!==r.GET(".assistantRun.next"))throw u=!0,new Error("Editing sequence is incomplete");if(s!==r.GET(".assistantRun.expected"))throw u=!0,new Error("Source changed during the request. Remaining edits stopped; send a new instruction.");let d=JSON.parse(o.value);if(a==="code"){if(d.operation!=="replace_code"||typeof d.content!="string")throw new Error("Expected a Page code draft operation");if(!r.GET(".codeDocument.writable")||r.GET(".codeDocument.busy"))throw new Error("Page code draft is not editable now");r.SET(".codeDocument.content",d.content),r.SET(".codeDocument.status","AI draft \xB7 Save to apply"),r.SET(".codeOpen",!0)}else this.applySourceEdit(r,d);l=!0,r.SET(".assistantRun.expected",a==="code"?r.GET(".codeDocument.content"):i.toTytx()),r.SET(".assistantStatus",`Applied ${o.attr.index+1}: ${a==="code"?"Page code draft":d.operation+" "+d.path}`)}catch(d){c=d.message,(a==="code"?r.GET(".codeDocument.content"):i.toTytx())!==s&&(u=!0),r.SET(".assistantRun.blocked",u),r.SET(".assistantStatus",`${u?"Editing stopped":"Rejected"}: ${c}`)}r.SET(".assistantRun.next",o.attr.index+1),r.SET(".assistant.ack",new k({run:o.attr.run,index:o.attr.index,applied:l,stop:u,error:c,mode:a,code:a==="code"?r.GET(".codeDocument.content"):null,source:i.toTytx(),selected:r.GET(".selection")}))}}applySourceEdit(e,t){let{operation:r,path:o,parent:i,tag:a,label:s,attributes:l={},text:u}=t,c=y=>typeof y=="string"&&/^pageRoot(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(y);if(!c(o)||r==="move"&&!c(i))throw new Error(`Use dot-separated paths inside pageRoot: ${JSON.stringify(o)}`);if(!["insert","update","remove","move"].includes(r))throw new Error("Unknown Source editing operation");if(["remove","move"].includes(r)&&o==="pageRoot")throw new Error("The page root is protected");if(r==="insert"&&(typeof s!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)))throw new Error("Choose an explicit node label");if(!l||typeof l!="object"||Array.isArray(l))throw new Error("Expected scalar attributes");for(let[y,E]of Object.entries(l))if(y.startsWith("_")||/^(connect_|on[A-Z]|script$|formula$|action$|func$|remote_)/.test(y)||["constructor","prototype"].includes(y)||E!==null&&typeof E=="object"||typeof E=="string"&&(E.startsWith("==")||E.includes(":=")))throw new Error(`Unsupported generated attribute: ${y}`);if(u!==void 0&&typeof u!="string")throw new Error("Text must be literal text");let d=e.builder.source.getNode(fe(e)),f=e.rootBuilder.binding.gramlot,h=f.src.prepareSource(d.value.toTytx(),d.builder),p=h.getNode(o);if(!p)throw new Error("The Source target no longer exists");let m=p;if(r==="insert"){if(!e.builder.schema[a]||["script","style","iframe","object","embed"].includes(a)||e.builder.schema[a]._meta?.data_element)throw new Error("Choose a visual widget from the catalogue");if(p.value instanceof h.constructor&&p.value.getNode(s))throw new Error("This node label is already in use");m=p.builder.commandOnNode(p,a,u??null,{...l,node_label:s})}else if(r==="update"){if(u!==void 0&&p.value instanceof h.constructor)throw new Error("Text cannot replace a populated container");let y={...p.getAttr()};for(let[E,S]of Object.entries(l))S===null?delete y[E]:y[E]=S;p.setAttr(y,!0,!1,!1),u!==void 0&&p.setValue(u)}else if(r==="remove")p.parentBag.popNode(p.label);else{if(Object.keys(l).length||u!==void 0)throw new Error("Move and property edits must be separate operations");if(i===o||i.startsWith(o+"."))throw new Error("Cannot move a node into itself");let y=h.getNode(i);if(!y)throw new Error("The destination no longer exists");if(y.value instanceof h.constructor&&y.value.getNode(p.label))throw new Error("The destination already contains this label");m=this.appendBranch(y,p,p.label)}let w=y=>{if(y.value instanceof h.constructor){y.builder.validateChildren(y.nodeTag,y.value.getNodes().map(E=>E.nodeTag));for(let E of y.value.getNodes()){for(let[S,x]of Object.entries(nr(y,E.nodeTag,E)))this.validateParameter(y,E,S,x,E.getAttr(S));w(E)}}};h.getNodes().forEach(w),Dt(ae(e).GET(".catalogueScope"),h),f.src.renderer.validateCandidate(h,{replacingNode:d});let b=e.builder.source.getNode(`${fe(e)}.${o}`),_=o;r==="insert"?(this.appendBranch(b,m,s),_=`${o}.${s}`):r==="update"?(b.setAttr({...m.getAttr()},!0,!1,!1),u!==void 0&&b.setValue(u)):r==="remove"?(_=o.slice(0,o.lastIndexOf(".")),b.parentBag.popNode(b.label)):(this.applyDrop(e,{item:e.builder.source.getNode(`${fe(e)}.${i}`),path:i,dropValues:{"app/source":{path:o}}}),_=`${i}.${b.label}`),e.SET(".sourceSearch",""),e.SET(".selection",_)}initializeCanvasSelection(e){let t=e.rootBuilder.binding.renderer,r=e.builder.source.getNode(fe(e)),o=ae(e),i=o.GET(".canvasCss");i!=null&&this.applyCanvasCss(o,i);let a=dl.get(r);a?.dispose();let s=new Qi({renderer:t,root:r,...ea.has(r)?{canvas:ea.get(r).body}:{},onSelect:l=>{e.SET(".sourceSearch",""),e.SET(".selection",l.fullpath.slice(r.fullpath.length+1))}});dl.set(r,s),a||t.onDispose(r.parentNode,()=>{dl.delete(r),ea.delete(r)}),this.highlightSelection(e)}applyCanvasCss(e,t){if(!Array.isArray(t)||t.some(a=>typeof a!="string"))throw new TypeError("canvas CSS must be a list of CSS texts");let r=ae(e),o=r.builder.source.getNode(fe(r)),i=ea.get(o);i||(i=new sl({app:r.rootBuilder.binding.gramlot,editor:r,design:o}),ea.set(o,i)),i.setCss(t)}setCanvasCss(e,t){let r=ae(e);this.applyCanvasCss(r,t),r.SET(".canvasCss",t),this.initializeCanvasSelection(r)}highlightSelection(e){let t=e.builder.source.getNode(fe(e)),r=e.GET(".selection");dl.get(t)?.select(r?t.staticValue.getNode(r):null)}clipboardShortcut(e,t){if(t.defaultPrevented||t.repeat||e.GET(".clipboardOpen")||e.GET(".insertionOpen")||e.GET(".uploadOpen")||t.composedPath().some(i=>i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)))return;let r=t.key.toLowerCase(),o=r==="f8"?"cutBranch":r==="f9"?"pasteBranch":null;!o||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),this[o](e))}clipboardModifiers(e,t){e.SET(".clipboardDropEffect",t.altKey?"copy":"move")}cutBranch(e){this.beginClipboard(e,e.GET(".selection"),!1)}copyBranch(e){this.beginClipboard(e,e.GET(".selection"),!0)}dropClipboard(e,{dropValues:t,dropEffect:r}){this.beginClipboard(e,t["app/source"].path,r==="copy")}prepareClipboard(e,{path:t,dragValues:r}){e.SET(".sourceDropEffect","copy"),r["app/clipboard"]={path:t}}branchSnapshot(e,t){let r=e.builder.source.getNode(fe(e)),i=e.rootBuilder.binding.gramlot.src.prepareSource(r.getValue(!0).toTytx(),r.builder).getNode(t);if(!i)throw new Error("The Source branch no longer exists");let a=l=>{if(l.resolver)throw new Error("Resolver-backed branches cannot be stored in this trial");l.value instanceof e.builder.source.constructor&&l.value.getNodes().forEach(a)};a(i);let s=new e.builder.source.constructor(null,i.builder);return i.parentBag.popNode(i.label),s.setItem(i.label,i.getValue(!0),{...i.getAttr()},">",!1,!1,"editor",!1,!0,null,i.nodeTag),s.toTytx()}beginClipboard(e,t,r){e.SET(".error","");try{if(!t||t==="pageRoot")throw new Error("Choose a branch below the page root");let o=e.builder.source.getNode(`${fe(e)}.${t}`);if(!o)throw new Error("The Source branch no longer exists");let i=this.branchSnapshot(e,t);e.SET(".clipboardDraft",new k({path:t,copy:r,name:o.label,wire:i,parentTag:o.parentNode.nodeTag})),e.SET(".clipboardOpen",!0)}catch(o){e.SET(".error",o.message)}}saveClipboard(e){e.SET(".error","");try{let t=e.GET(".clipboardDraft.name")?.trim();if(!t)throw new Error("Choose a name for the branch");let r=e.GET(".clipboardDraft.path"),o=e.GET(".clipboardDraft.wire"),i=e.GET(".clipboardDraft.copy"),a=e.builder.source.getNode(`${fe(e)}.${r}`);if(!i&&(!a||this.branchSnapshot(e,r)!==o))throw new Error("The branch changed; select it again before cutting");let s=e.GET(".clipboard"),l=1;for(;s.getNode(`branch_${l}`);)l++;let u=`branch_${l}`;s.setItem(u,o,{name:t,parentTag:e.GET(".clipboardDraft.parentTag")}),e.SET(".clipboardSelection",u),e.SET(".clipboardVisible",!0),i||(e.SET(".selection",r.slice(0,r.lastIndexOf("."))),a.parentBag.popNode(a.label)),e.SET(".clipboardOpen",!1),e.SET(".fileStatus",`${i?"Copied":"Cut"}: ${t}`)}catch(t){e.SET(".error",t.message)}}pasteBranch(e){e.SET(".error","");try{this.beginPaste(e,e.GET(".clipboardSelection"),e.GET(".selection"))}catch(t){e.SET(".error",t.message)}}beginPaste(e,t,r){let o=t?e.GET(".clipboard").getNode(t):null;if(!o)throw new Error("Choose a saved branch in the clipboard");let i=r?e.builder.source.getNode(`${fe(e)}.${r}`):null;if(!i)throw new Error("Choose a destination in the Source tree");let a=e.rootBuilder.binding.gramlot.src.prepareSource(o.getValue(!0),i.builder);Dt(ae(e).GET(".catalogueScope"),a);let s=a.getNodes()[0];i.builder.validateParent(s.nodeTag,i.nodeTag);let l=i.getValue(!0);i.builder.validateChildren(i.nodeTag,[...l instanceof e.builder.source.constructor?l.getNodes().map(b=>b.nodeTag):[],s.nodeTag]);let u={...s.getAttr()},c=i.builder.schema[s.nodeTag]._meta?.gramlot_component?.parameters??{},d=i.builder.schema[o.getAttr("parentTag")]?._meta?.gramlot_component?.childParameters??{};for(let b of Object.keys(d))b in c||delete u[b];s.setAttr(u,!0,!1,!1),e.SET(".insertion",new k({parentPath:r,tag:s.nodeTag,clipboard:a.toTytx()}));let f=nr(i,s.nodeTag),h=Object.entries(f).filter(([b,_])=>_.required&&(u[b]==null||u[b]===""||_.unique));if(!h.length){this.finishPaste(e);return}let p=ul(e,"InsertFields");p.getValue(!0).clear();let m=e.builder.wrapSource(p);m.p(`Paste ${o.getAttr("name")} into ${i.label} [${i.nodeTag}]`,{class:"visual-editor-hint"});let w=m.formlet({columns:2,gap:"4px 6px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});for(let[b,_]of h)this.parameterField(e,w,s.nodeTag,b,_,"insertion",_.default);e.SET(".insertionOpen",!0)}appendBranch(e,t,r){let o=e.builder.source.constructor,i=e.getValue(!0);if(!(i instanceof o)){let a=i;i=new o(null,e.builder),e.builder.promoteNodeValue(e,a,i)}return t.parentBag.popNode(t.label),i.setItem(r,t.getValue(!0),{...t.getAttr()},">",!1,!1,"editor",!1,!0,null,t.nodeTag),i.getNode(r)}finishPaste(e){let t=e.GET(".insertion.parentPath"),r=e.builder.source.getNode(`${fe(e)}.${t}`);if(!r)throw new Error("The destination no longer exists");let o=e.rootBuilder.binding.gramlot,i=o.src.prepareSource(e.GET(".insertion.clipboard"),r.builder);Dt(ae(e).GET(".catalogueScope"),i);let a=i.getNodes()[0],s={...a.getAttr()};for(let[w,b]of Object.entries(nr(r,a.nodeTag))){if(!b.required)continue;let _=e.GET(`.insertion.types.${w}`),y=e.GET(`.insertion.parameters.${w}${b.enum?"":_?"."+_:""}`);y!=null&&(s[w]=y),this.validateParameter(r,null,w,b,s[w])}a.setAttr(s,!0,!1,!1);let l=r.getValue(!0),u=a.label,c=1;for(;l instanceof e.builder.source.constructor&&l.getNode(u);)u=`${a.label}_${c++}`;let d=e.builder.source.getNode(fe(e)),f=o.src.prepareSource(d.getValue(!0).toTytx(),d.builder),h=f.getNode(t);h.builder.validateParent(a.nodeTag,h.nodeTag);let p=h.getValue(!0);h.builder.validateChildren(h.nodeTag,[...p instanceof e.builder.source.constructor?p.getNodes().map(w=>w.nodeTag):[],a.nodeTag]);let m=this.appendBranch(h,a,u);Dt(ae(e).GET(".catalogueScope"),f),o.src.renderer.validateCandidate(f,{replacingNode:d}),this.appendBranch(r,m,u),e.SET(".insertionOpen",!1),e.SET(".sourceSearch",""),e.SET(".selection",`${t}.${u}`),e.SET(".fileStatus","Branch pasted")}openCode(e){let t=ae(e);t.SET(".codeOpen",!0),t.SET(".editingMode","code")}async codeSave(e){let t=ae(e),r=t.GET(".codeDocument");if(r.getItem("busy")||!r.getItem("writable"))return;let o=r.getItem("content"),i=r.getItem("revision"),a=!1;if(o===r.getItem("saved"))return;let s=new AbortController,l=this.page.src.renderer.onDispose(t,()=>s.abort());r.setItem("busy",!0),r.setItem("status","Saving Page code\u2026");let u=t.value.getNode("layout.center.design"),c=u.value.toTytx();try{let d=await this.page.rpc.call("data","editor_document_save",{key:t.getAttr("codeDocumentKey"),content:o,revision:i},{signal:s.signal});if(s.signal.aborted)return;r.setItem("revision",d.revision),r.setItem("saved",o),a=!0,r.setItem("status","Page code saved"),c!==u.value.toTytx()?r.setItem("status","Page code saved; Source changed meanwhile. Use Preview saved to replace it."):await this.codeLoadPreview(t,s)}catch(d){s.signal.aborted||r.setItem("status",`${a?"Page code saved; preview failed":"Save failed"}: ${d.message}`)}finally{l(),s.signal.aborted||r.setItem("busy",!1)}}async codePreview(e){let t=ae(e),r=t.GET(".codeDocument");if(r.getItem("busy"))return;let o=new AbortController,i=this.page.src.renderer.onDispose(t,()=>o.abort());r.setItem("busy",!0);try{await this.codeLoadPreview(t,o)}catch(a){o.signal.aborted||r.setItem("status",`Preview failed: ${a.message}`)}finally{i(),o.signal.aborted||r.setItem("busy",!1)}}async codeLoadPreview(e,t){let r=e.GET(".codeDocument"),o=e.value.getNode("layout.center.design"),i=o.value.toTytx(),a=await this.page.rpc.call("source","editor_document_preview",{key:e.getAttr("codeDocumentKey"),revision:r.getItem("revision"),data_root:e.GET(".dataRoot")},{signal:t.signal});if(t.signal.aborted)return;if(o.value.toTytx()!==i)throw new Error("Source changed while preparing preview; it was retained");let s=this.page.src.prepareSource(a,o.builder);Dt(e.GET(".catalogueScope"),s),this.page.src.renderer.validateCandidate(s,{replacingNode:o}),e.GET(".assistantRun")&&e.SET(".assistantRun.blocked",!0),e.SET(".selection",null),o.setValue(s,!0,{_text:null},!0),e.SET(".selection","pageRoot"),r.setItem("status",r.getItem("content")===r.getItem("saved")?"Saved Page code \xB7 preview updated":"Preview updated from saved page code; newer draft retained")}newPage(e){e.GET(".assistantRun")&&e.SET(".assistantRun.blocked",!0),e.SET(".selection",null),e.SET(".insertionOpen",!1),e.SET(".error","");let t=e.builder.source.getNode(fe(e));t.getValue(!0).clear();let r=e.GET(".dataRoot");if(r)e.SET(r,new k);else for(let o of e.rootBuilder.data.getNodes())o.label!=="__editor"&&e.rootBuilder.data.popNode(o.label);e.builder.wrapSource(t).div({node_label:"pageRoot",...r?{datapath:r}:{}}),e.SET(".filename","page.grmlt"),e.SET(".fileStatus",""),e.SET(".sourceSearch",""),e.SET(".dataSearch",""),e.SET(".selection","pageRoot")}async copySource(e){e.SET(".fileStatus","");try{await e.rootBuilder.binding.gramlot.utl.inout.copyText(this.currentSource(e)),e.SET(".fileStatus","Source copied")}catch(t){e.SET(".fileStatus",`Copy failed: ${t.message}`)}}downloadPage(e){e.rootBuilder.binding.gramlot.utl.inout.saveText(this.currentSource(e),e.GET(".filename"),"application/json")}openUpload(e){e.SET(".uploadOpen",!0)}sourceUploaded(e,{item:t,result:r}){try{this.loadSource(e,{source:r,filename:t.value.getItem("name")}),e.SET(".fileStatus","Source opened"),e.SET(".uploadOpen",!1)}catch(o){throw e.SET(".fileStatus",`Open failed: ${o.message}`),o}}initializeDocument(e){let t=ae(e),r=t.builder.source,o=fe(t).split("."),i=`${t.getAttr("visualEditorId")}-document`;t.SET(".modified",!1),r.subscribe(i,{any:a=>{o.every((s,l)=>a.pathlist[l]===s)&&t.SET(".modified",!0)}}),t.rootBuilder.binding.renderer.onDispose(t,()=>r.unsubscribe(i,{any:!0}))}currentSource(e){let t=ae(e);return t.builder.source.getNode(fe(t)).getValue(!0).toTytx()}markSaved(e){ae(e).SET(".modified",!1)}loadSource(e,{source:t,filename:r}){let o=ae(e);if(typeof t!="string")throw new TypeError("source must be Source TYTX");if(typeof r!="string"||!r.trim())throw new TypeError("filename must be a non-empty string");let i=o.rootBuilder.binding.gramlot,a=o.builder.source.getNode(fe(o)),s=i.src.prepareSource(t,a.builder),l=s.getNodes();if(l.length!==1||l[0].label!=="pageRoot")throw new Error("Expected one pageRoot Source");Dt(o.GET(".catalogueScope"),s),i.src.renderer.validateCandidate(s,{replacingNode:a}),o.GET(".assistantRun")&&o.SET(".assistantRun.blocked",!0),o.SET(".selection",null),a.setValue(s,!0,{_text:null},!0),o.SET(".filename",r),o.SET(".insertionOpen",!1),o.SET(".sourceSearch",""),o.SET(".selection","pageRoot"),this.markSaved(o)}toggleNavigation(e){e.SET(".navigationOpen",e.GET(".navigationOpen")==="close"?!0:"close")}openCatalogue(e){e.SET(`${Qe(e)}.catalogueOpen`,!0)}openProperties(e){this.showProperties(e,{path:e.GET(".selection")})}sourceLabel(e,{item:t}){return{text:`${t.label} [${t.nodeTag}]`}}dropNode(e,t){e.SET(".error","");try{this.applyDrop(e,t)}catch(r){e.SET(".error",r.message)}}insertWidget(e){e.SET(".error","");try{this.applyInsert(e)}catch(t){e.SET(".error",t.message)}}initializeEditorAppearance(e){let t=ae(e),r=e.rootBuilder.binding.renderer.destination.ownerDocument;t.SET(".appearanceProfile","compact"),t.SET(".appearancePalette","joanna"),t.SET(".appearanceMode",r.documentElement.getAttribute("data-theme")||"dark")}applyEditorAppearance(e,{profile:t,palette:r,mode:o}){if(!t||!r||!o)return;if(!Object.hasOwn(zc,t)||!Object.hasOwn(Hc,r)||!["light","dark"].includes(o))throw new Error("Choose a declared theme, palette and color mode");ae(e).SET(".appearanceCss",zc[t]+`
|
|
1753
|
+
`+Hc[r]),e.rootBuilder.binding.renderer.destination.ownerDocument.documentElement.setAttribute("data-theme",o)}initializeEditor(e,{dataRoot:t}){let r=e.GET(".catalogueScope");if(yo(r),Array.isArray(r)){for(let s of r)if(!e.builder.schema[s])throw new Error(`Unknown catalogue tag: ${s}`)}if(e.SET(".editingMode","source"),e.SET(".clipboard",new k),e.SET(".clipboardVisible",!1),e.SET(".clipboardDropEffect","move"),e.SET(".sourceDropEffect","move"),e.SET(".dataRoot",t),e.SET(".filename","page.grmlt"),e.SET(".fileStatus",""),e.SET(".selection","pageRoot"),t)e.GET(t)==null&&e.SET(t,new k);else{let s=Qe(e),l=s.split(".").map(()=>"#parent").join(".");e.builder.source.getNode(fe(e)).setAttr({datapath:`${s}.${l}`})}let o=new k,i=new Map([["",o]]),a=(s,l)=>{if(i.has(s))return i.get(s);let u=s.split("."),c=u.pop(),d=u.join("."),f=a(d,a0[d]),h=new k;return f.setItem(c,h,{caption:l}),i.set(s,h),h};for(let[s,l,u]of Pm)u.split(" ").some(c=>e.builder.schema[c]&&vo(r,c,e.builder.schema[c]._meta??{}))&&a(s,l);for(let[s,l]of Object.entries(e.builder.schema).sort(([u],[c])=>u.localeCompare(c))){if(!vo(r,s,l._meta??{})||l._meta?.data_element||l._meta?.subbuilder||l._meta?.container)continue;let u=l._meta?.gramlot_component?"components":"html",c=Pm.find(([f,,h])=>f.startsWith(u+".")&&h.split(" ").includes(s)),d=c?c[0]:`${u}.other`;a(d,c?c[1]:"Other elements").setItem(s,null,{caption:s,tag:s})}e.SET(".catalogue",o)}prepareWidget(e,{item:t,dragValues:r}){if(e.SET(".sourceDropEffect","copy"),!t.attr.tag)return!1;r["app/widget"]={tag:t.attr.tag}}prepareSource(e,{path:t,dragValues:r}){e.SET(".sourceDropEffect","move"),r["app/source"]={path:t}}applyDrop(e,{item:t,path:r,dropValues:o}){if(o["app/clipboard"]){this.beginPaste(e,o["app/clipboard"].path,r);return}if(o["app/source"]){let f=`${fe(e)}.${o["app/source"].path}`,h=`${fe(e)}.${r}`,p=e.builder.source.getNode(f);if(!p||f===`${fe(e)}.pageRoot`)throw new Error("The page root cannot be moved");if(Dt(ae(e).GET(".catalogueScope"),p.parentBag),p.resolver)throw new Error("Resolver-backed Source nodes cannot be moved in this trial");if(f===h||h.startsWith(f+"."))throw new Error("A node cannot be moved into itself");let m=t,w=p.parentBag,b=e.builder.source.constructor;if(p.builder!==m.builder)throw new Error("Nodes cannot cross builder dialects");let _=m.getValue(!0),y=_ instanceof b?_.getNodes().filter(S=>S!==p):[];if(_ instanceof b&&_!==w&&_.getNode(p.label))throw new Error("The target already contains this label");let E=m._getMeta("gramlot_component")?.childParameters??{};for(let[S,x]of Object.entries(E)){let N=p.getAttr(S);if(x.required&&N==null)throw new Error(`The moved node requires ${S}`);if(x.enum&&N!=null&&!x.enum.includes(N))throw new Error(`Invalid ${S}`);if(x.unique&&N!=null&&y.some(O=>O.getAttr(S)===N))throw new Error(`${S} is already in use`)}if(m.builder.validateParent(p.nodeTag,m.nodeTag),m.builder.validateChildren(m.nodeTag,[...y.map(S=>S.nodeTag),p.nodeTag]),_===w)w.move(w.getNodes().indexOf(p),y.length);else{let S=_ instanceof b?_:new b(null,m.builder);_ instanceof b||m.builder.promoteNodeValue(m,_,S);let x={label:p.label,tag:p.nodeTag,value:p.getValue(!0),attrs:{...p.getAttr()}};w.popNode(x.label),S.setItem(x.label,x.value,x.attrs,S.getNodes().length,!1,!1,"editor",!1,!0,null,x.tag)}e.SET(".selection",`${r}.${p.label}`);return}let i=o["app/widget"].tag;this.validateCatalogueTag(e,i),t.builder.validateParent(i,t.nodeTag);let a=t.getValue(!0);t.builder.validateChildren(t.nodeTag,[...a instanceof e.builder.source.constructor?a.getNodes().map(f=>f.nodeTag):[],i]);let s=nr(t,i),l=Object.entries(s).filter(([,f])=>f.required);if(e.SET(".insertion",new k),e.SET(".insertion.parentPath",r),e.SET(".insertion.tag",i),!l.length){this.applyInsert(e);return}let u=ul(e,"InsertFields");u.getValue(!0).clear();let c=e.builder.wrapSource(u);c.p(`Insert ${i} into ${t.label} [${t.nodeTag}]`,{class:"visual-editor-hint"});let d=c.formlet({columns:2,gap:"4px 6px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});for(let[f,h]of l)this.parameterField(e,d,i,f,h,"insertion",h.default);e.SET(".insertionOpen",!0)}showProperties(e,{path:t}){let r=ul(e,"EditorFields");if(r.getValue(!0).clear(),e.SET(".propertyError",""),e.SET(".properties",new k),!t){e.SET(".propertiesOpen",!1);return}let o=e.builder.source.getNode(`${fe(e)}.${t}`);if(!o){e.SET(".propertiesOpen",!1);return}let i=o.parentNode,a=nr(i,o.nodeTag,o);e.SET(".properties.path",t),this.attributeRows(e,o),e.SET(".propertiesTitle",`${o.label} [${o.nodeTag}]`),e.SET(".propertiesHeight",`${Math.min(300,Math.max(180,80+Math.ceil(Object.keys(a).filter(f=>Wc(f,new Set)==="general").length/2)*38))}px`);let s=e.builder.wrapSource(r);t!=="pageRoot"&&s.p(t,{class:"visual-editor-destination"});let l=new Set(Object.keys(i._getMeta("gramlot_component")?.childParameters??{})),u=new Map(Gc.map(([f])=>[f,[]]));for(let f of Object.entries(a))u.get(Wc(f[0],l)).push(f);e.SET(".parameterTab",Gc.find(([f])=>u.get(f).length)[0]);let c=s.tabContainer({selectedPage:`^${Qe(e)}.parameterTab`,class:"visual-parameter-tabs",tabMode:"underline",height:"100%",min_height:0,flex:1});for(let[f,h]of Gc){if(!u.get(f).length)continue;let p=c.contentPane({pageName:f,title:h,overflow:"auto",padding:"4px",min_height:0,...f==="styles"?{nodeId:ae(e).getAttr("visualEditorId")+"StyleAttributes"}:{}});if(f==="styles"){this.attributeFields(e,p,o,"styles");continue}f==="container"&&p.p(`Child parameters of ${i.nodeTag}`,{class:"visual-editor-hint"}),f==="behaviour"&&Object.hasOwn(a,"action")&&p.p("action: use a named Logic method, for example openCatalogue.",{class:"visual-editor-hint"}),f==="behaviour"&&o.nodeTag==="borderContainer"&&p.p("persist remembers splitter sizes and requires a stable container id.",{class:"visual-editor-hint"});let m=p.formlet({columns:2,gap:"4px 6px",lbl_position:"TL",box_c_width:"100%",align_items:"start"});f==="general"&&o._getMeta("gramlot_component")?.labelbox&&this.labelboxFields(e,m,o,a);let w,b=([,_])=>{let y=Array.isArray(_.dtype)?_.dtype:[_.dtype];return!_.enum&&!y.some(E=>cl.includes(E))?2:_.dtype==="B"?1:0};for(let[_,y]of[...u.get(f)].sort((E,S)=>b(E)-b(S))){if(o._getMeta("gramlot_component")?.labelbox&&/^(lbl|box)(_|$)/.test(_))continue;let E=m;if(f==="validation"&&/(_if|_error|_warning|_iswarning)$/.test(_)){if(!w){let x=p.details({class:"visual-validation-advanced"});x.summary("Conditions and messages"),w=x.formlet({columns:2,gap:"4px 6px",lbl_position:"TL",box_c_width:"100%",align_items:"start"})}E=w}let S=_==="_text"?o.getValue(!0):o.getAttr(_);this.parameterField(e,E,o.nodeTag,_,y,"properties",S??y.default)}}let d=c.contentPane({nodeId:ae(e).getAttr("visualEditorId")+"MoreAttributes",pageName:"attributes",title:"More attributes",overflow:"auto",padding:"4px",min_height:0});this.attributeFields(e,d,o),e.SET(".propertiesOpen",!0)}attributeRows(e,t){let r=new k;for(let[o,i]of Object.entries(t.getAttr())){if(o==="_meta")continue;let a=Uc(i),s=a?ll(i,a):"[non-scalar value]";r.setItem(`r${r.length}`,new k({name:o,type:a??"readonly",text:s,original:s}))}e.SET(".properties.attributeRows",r),e.SET(".properties.attributeDraft",new k({name:"",type:"string",text:""})),e.SET(".properties.attributeDraftHidden",!0)}attributeFields(e,t,r,o="attributes"){let i=e.GET(".properties.path"),a=`${Qe(e)}.properties`,s=e.rootBuilder.binding.gramlot.src.renderer,l=new Set(Object.keys(r.parentNode._getMeta("gramlot_component")?.childParameters??{})),u=t.div({class:"visual-editor-attribute-list","aria-label":o==="styles"?"Style attributes":"Node attributes"}),c=u.div({class:"visual-editor-attribute-row visual-editor-attribute-heading"});c.span("Attribute",{class:"visual-editor-attribute-name"});let d=c.div({class:"visual-editor-attribute-value"});d.span("Value"),d.button("+",{action:"beginAttribute",editingPath:i,"aria-label":o==="styles"?"Add style attribute":"Add attribute",title:"Add attribute",class:"visual-editor-attribute-command"});for(let w of e.GET(".properties.attributeRows").getNodes()){let b=w.value.getItem("name"),_=w.value.getItem("type"),y=w.label;if(o==="styles"&&Wc(b,l)!=="styles"&&!s._isStyleContribution(b))continue;let E=_!=="readonly",S=u.div({class:"visual-editor-attribute-row"});S.span(b,{class:"visual-editor-attribute-name",title:b});let x=S.div({class:"visual-editor-attribute-value"});x.input({value:`^${a}.attributeRows.${y}.text`,disabled:!E,"aria-label":`${b} attribute value`,title:E?_:"Non-scalar values are read-only"}),x.button("\xD7",{action:"removeAttribute",attributeRow:y,editingPath:i,disabled:!E,"aria-label":`Remove ${b} attribute`,title:`Remove ${b}`,class:"visual-editor-attribute-command"}),E&&o==="attributes"&&S.dataController({func:"changeAttribute",value:`^${a}.attributeRows.${y}.text`,attributeRow:y,editingPath:i,_userChanges:!0})}let f=u.div({class:"visual-editor-attribute-row",hidden:`^${a}.attributeDraftHidden`,connect_onkeydown:"attributeDraftKey"});f.div({class:"visual-editor-attribute-name"}).input({value:`^${a}.attributeDraft.name`,live:!0,"aria-label":"New attribute name",placeholder:"Attribute name"});let p=f.div({class:"visual-editor-attribute-value"});p.input({value:`^${a}.attributeDraft.text`,live:!0,"aria-label":"New attribute value",placeholder:"Value"});let m=p.select({value:`^${a}.attributeDraft.type`,"aria-label":"New attribute type"});for(let w of Mm)m.option(w,{value:w});p.button("\u2713",{action:"addAttribute",editingPath:i,"aria-label":"Apply new attribute",title:"Apply (Enter)",class:"visual-editor-attribute-command"}),p.button("\xD7",{action:"cancelAttribute","aria-label":"Cancel new attribute",title:"Cancel (Escape)",class:"visual-editor-attribute-command"})}beginAttribute(e,{editingPath:t}){let r=ae(e);t===r.GET(".selection")&&(r.SET(".properties.attributeDraft",new k({name:"",type:"string",text:""})),r.SET(".properties.attributeDraftHidden",!1),r.SET(".propertyError",""))}cancelAttribute(e){ae(e).SET(".properties.attributeDraftHidden",!0)}attributeDraftKey(e,t){if(t.isComposing||!["Enter","Escape"].includes(t.key))return;t.preventDefault(),t.stopPropagation();let r=ae(e);t.key==="Escape"?this.cancelAttribute(r):this.addAttribute(r,{editingPath:r.GET(".properties.path")})}addAttribute(e,{editingPath:t}){let r=ae(e);if(t===r.GET(".selection")){r.SET(".propertyError","");try{let o=r.GET(".properties.attributeDraft"),i=o.getItem("name");if(!i||!/^[^\s"'<>/=]+$/.test(i))throw new Error("Enter a valid attribute name.");if(["_meta","__proto__","constructor","prototype"].includes(i))throw new Error("Unsupported attribute name.");let a=r.builder.source.getNode(`${fe(r)}.${t}`);if(!a)throw new Error("The selected Source node no longer exists");if(Object.hasOwn(a.getAttr(),i))throw new Error(`Duplicate attribute: ${i}`);let s=Vc(o.getItem("type"),String(o.getItem("text")??""));this.writeAttribute(r,a,t,i,s,!1)}catch(o){r.SET(".propertyError",o.message)}}}changeAttribute(e,{attributeRow:t,editingPath:r,value:o}){this.editAttribute(e,{attributeRow:t,editingPath:r,value:o,remove:!1})}removeAttribute(e,{attributeRow:t,editingPath:r}){this.editAttribute(e,{attributeRow:t,editingPath:r,remove:!0})}editAttribute(e,{attributeRow:t,editingPath:r,value:o,remove:i}){let a=ae(e);if(r===a.GET(".selection")){a.SET(".propertyError","");try{let s=a.GET(".properties.attributeRows").getItem(t);if(!s||s.getItem("type")==="readonly")throw new Error("This attribute is not editable");let l=s.getItem("name");if(["_meta","__proto__","constructor","prototype"].includes(l))throw new Error("Unsupported attribute name.");let u=a.builder.source.getNode(`${fe(a)}.${r}`);if(!u)throw new Error("The selected Source node no longer exists");let c=u.getAttr(),d=Uc(c[l]);if(!Object.hasOwn(c,l)||d!==s.getItem("type")||ll(c[l],d)!==s.getItem("original"))throw new Error("Attribute changed; select the node again before editing.");let f=i?null:Vc(d,String(o??""));this.writeAttribute(a,u,r,l,f,i,s)}catch(s){a.SET(".propertyError",s.message)}}}writeAttribute(e,t,r,o,i,a,s=null){let l={...t.getAttr()};a?delete l[o]:l[o]=i;let u=nr(t.parentNode,t.nodeTag,t);u[o]&&this.validateParameter(t.parentNode,t,o,u[o],a?null:i);let c=e.builder.source.getNode(fe(e)),d=e.rootBuilder.binding.gramlot,f=d.src.prepareSource(c.getValue(!0).toTytx(),c.builder);if(f.getNode(r).setAttr(l,!0,!1,!1),Dt(e.GET(".catalogueScope"),f),d.src.renderer.validateCandidate(f,{replacingNode:c}),t.setAttr(l,!0,!1,!1),s&&!a){let h=ll(i,s.getItem("type"));s.setItem("original",h),s.setItem("text",h);let p=e.GET(`.properties.types.${o}`);u[o]?.enum?e.SET(`.properties.parameters.${o}`,i):p&&e.SET(`.properties.parameters.${o}.${p}`,i)}else{let h=e.GET(".parameterTab")==="styles"?"styles":"attributes";this.showProperties(e,{path:r}),e.SET(".parameterTab",h)}}toggleLabelboxAttributes(e,{prefix:t}){e.SET(`.properties.${t}Hidden`,!e.GET(`.properties.${t}Hidden`))}labelboxFields(e,t,r,o){for(let i of["lbl","box"]){let a=i==="lbl"?"Label":"Box",s=t.div({class:"visual-labelbox-section",grid_column:"1 / -1"}),l=s.div({class:"visual-labelbox-heading"});i==="lbl"?this.parameterField(e,l,r.nodeTag,"lbl",o.lbl,"properties",r.getAttr("lbl")):l.span(a,{class:"visual-labelbox-title"}),l.button({iconSrc:We.properties,title:`Edit ${a.toLowerCase()} attributes`,"aria-label":`Edit ${a.toLowerCase()} attributes`,class:"button--quiet",action:"toggleLabelboxAttributes",prefix:i});let u=Object.entries(o).filter(([f])=>f.startsWith(i+"_"));e.SET(`.properties.${i}Hidden`,!0),e.SET(`.properties.${i}Attribute`,"");let c=s.div({class:"visual-labelbox-attribute",hidden:`^${Qe(e)}.properties.${i}Hidden`}),d=c.select({"aria-label":`${a} attribute`,value:`^${Qe(e)}.properties.${i}Attribute`});d.option("Which attribute?",{value:""});for(let[f]of u)d.option(f.slice(i.length+1),{value:f});c.div({node_label:"attributeValue"}).span(""),c.dataController({func:"renderLabelboxAttribute",_init:!0,parameterName:`^${Qe(e)}.properties.${i}Attribute`,editingPath:e.GET(".properties.path")})}}renderLabelboxAttribute(e,{parameterName:t,editingPath:r}){let o=e.parentBag.getNode("attributeValue");if(o.getValue(!0).clear(),!t||r!==e.GET(".selection"))return;let i=e.builder.source.getNode(`${fe(e)}.${r}`),a=nr(i.parentNode,i.nodeTag,i)[t];this.parameterField(e,e.builder.wrapSource(o),i.nodeTag,t,a,"properties",i.getAttr(t)??a.default,!0)}parameterField(e,t,r,o,i,a,s,l=!1){let u=o==="lbl"?"Label":o==="_text"&&e.builder.schema[r]._meta?.gramlot_component?.command?"caption":o==="_text"?"Text":o,c=`${Qe(e)}.${a}.parameters.${o}`;if(i.enum){e.SET(c,s??"");let w=t.select({lbl:l?null:u,lbl_position:"TL",value:`^${c}`,"aria-label":o});w.option("",{value:""});for(let b of i.enum)w.option(String(b),{value:b});a==="properties"&&t.dataController({func:"changeProperty",value:`^${c}`,_userChanges:!0,parameterName:o,editingPath:e.GET(".properties.path")});return}let d=Array.isArray(i.dtype)?i.dtype:i.dtype?[i.dtype]:[],f=d.filter(w=>cl.includes(w));if(!f.length){t.p(`${u}: no editor is available for this declared type`,{class:"visual-editor-hint",grid_column:"1 / -1"});return}let h="";if(s==null?h=f.length===1?f[0]:"":typeof s=="boolean"&&f.includes("B")?h="B":typeof s=="string"&&f.includes("T")?h="T":typeof s=="number"?h=f.find(w=>["L","R","N"].includes(w))??"":s instanceof Date?h=f.find(w=>["D","H"].includes(w))??"":f.length===1&&f[0]==="N"&&(h="N"),s!=null&&!h){t.p(`${u}: the current value is not editable with these scalar types`,{class:"visual-editor-hint",grid_column:"1 / -1"});return}e.SET(`${Qe(e)}.${a}.types.${o}`,h);for(let w of f)e.SET(`${c}.${w}`,w===h?s??null:null);let p=!l&&(d.length>1||/^(tooltip|_text|action|placeholder|value)$|(_error|_warning|_if)$/.test(o)),m=t.div({class:"visual-parameter-field",grid_column:p?"1 / -1":"auto",grid_template_columns:d.length>1?"minmax(100px, 1fr) minmax(0, 2fr)":"minmax(0, 1fr)",align_items:"start"});if(d.length>1){let w=m.select({lbl:`${u} type`,lbl_position:"TL",value:`^${Qe(e)}.${a}.types.${o}`,"aria-label":`${o} type`});w.option("Not set",{value:""});for(let b of d)w.option(cl.includes(b)?b:`${b} (unavailable)`,{value:b,disabled:!cl.includes(b)});a==="properties"&&m.dataController({func:"changePropertyType",type:`^${Qe(e)}.${a}.types.${o}`,_userChanges:!0,parameterName:o,editingPath:e.GET(".properties.path")})}m.div({node_label:"input"}).span(""),m.dataController({func:"renderParameterInput",_init:!0,type:`^${Qe(e)}.${a}.types.${o}`,parameterName:o,parameterLabel:u,scope:a,compact:l,multiple:d.length>1})}renderParameterInput(e,{type:t,parameterName:r,parameterLabel:o,scope:i,multiple:a,compact:s}){let l=e.parentBag.getNode("input");if(l.getValue(!0).clear(),!t)return;let u=e.builder.wrapSource(l),c=a?`${o} (${t})`:o,d=`^${Qe(e)}.${i}.parameters.${r}.${t}`,f={lbl:s?null:c,lbl_position:"TL",value:d,"aria-label":c};if(t==="B")u.checkbox(f);else if(["L","R","N"].includes(t))u.numberTextBox({...f,dtype:t});else if(t==="D")u.dateTextBox(f);else if(t==="H")u.timeTextBox(f);else if(t==="T"&&/^(lbl|box)_color$/.test(r))u.colorpicker(f);else if(t==="T")u.textbox(f);else throw new Error(`No parameter editor for ${t}`);i==="properties"&&u.dataController({func:"changeProperty",value:d,_userChanges:!0,parameterName:r,editingPath:e.GET(".properties.path")})}changePropertyType(e,{type:t,parameterName:r,editingPath:o}){this.changeProperty(e,{parameterName:r,editingPath:o,value:t?e.GET(`.properties.parameters.${r}.${t}`):null})}changeProperty(e,{value:t,parameterName:r,editingPath:o}){if(o===e.GET(".selection")){e.SET(".propertyError","");try{let i=e.builder.source.getNode(`${fe(e)}.${o}`);if(!i)throw new Error("The selected Source node no longer exists");if(r!=="_text"&&Object.is(i.getAttr(r),t))return;let s=nr(i.parentNode,i.nodeTag,i)[r];if(!s)throw new Error(`Unknown parameter: ${r}`);if(this.validateParameter(i.parentNode,i,r,s,t),r==="_text")i.setValue(t??"");else{let l={...i.getAttr()};t==null||t===""?delete l[r]:l[r]=t,i.setAttr(l,!0,!1,!1)}this.attributeRows(e,i);for(let[l,u]of[["MoreAttributes","attributes"],["StyleAttributes","styles"]]){let c=ul(e,l);c.getValue(!0).clear(),this.attributeFields(e,e.builder.wrapSource(c),i,u)}}catch(i){e.SET(".propertyError",i.message)}}}validateParameter(e,t,r,o,i){let a=i==null||i==="";if(o.required&&a)throw new Error(`Choose ${r}`);if(!a&&o.enum&&!o.enum.includes(i))throw new Error(`Invalid ${r}`);let s=e.getValue(!0);if(!a&&o.unique&&s instanceof e.builder.source.constructor&&s.getNodes().some(l=>l!==t&&l.getAttr(r)===i))throw new Error(`${r} is already in use`)}validateCatalogueTag(e,t){let r=ae(e).GET(".catalogueScope");if(!vo(r,t,e.builder.schema[t]?._meta??{}))throw new Error(`Tag ${t} is outside the editor catalogue`)}applyInsert(e){if(e.GET(".insertion.clipboard")){this.finishPaste(e);return}let t=e.GET(".insertion.parentPath"),r=e.builder.source.getNode(`${fe(e)}.${t}`);if(!r)throw new Error("The target Source node is no longer available");let o=e.GET(".insertion.tag");this.validateCatalogueTag(e,o);let i={};for(let[s,l]of Object.entries(nr(r,o)).filter(([,u])=>u.required)){let u=e.GET(`.insertion.types.${s}`),c=e.GET(`.insertion.parameters.${s}${l.enum?"":u?"."+u:""}`);this.validateParameter(r,null,s,l,c),i[s]=c}let a=r.builder.commandOnNode(r,o,null,i);e.SET(".insertionOpen",!1),e.SET(".selection",`${t}.${a.label}`)}};export{k as Bag,xt as BagNode,Ic as BrowserCameraProvider,hp as ChoiceGroup,No as CommandRegistry,Tr as ComponentCollection,Pi as DeviceHandler,zi as DirectoryResolver,Mi as DomHandler,Gs as Exposed,Cm as FieldState,Hi as FileSystemController,bn as FileSystemLogic,wo as FramePage,ji as Gramlot,Oe as GramlotBuilder,un as GramlotHtmlRenderer,Bi as GramlotRenderer,ki as GramlotSvgRenderer,Je as Handler,Io as HttpTransport,Ks as IdeLogic,Li as InOut,Ws as IndexLogic,Vi as IndexPage,Tc as Labelbox,Co as MobileEnvironment,fp as NativeControl,kc as NavigationResolver,Ui as Page,cc as PageBootstrap,mi as References,nn as RpcError,gi as RpcHandler,lr as ServerAdapter,$i as SourceHandler,el as SourceImport,Qi as SourcePicker,Gi as TreeStore,Js as TreeStoreLogic,Rr as TreeStoreResolver,_o as UploadTarget,Fi as UtilitiesHandler,Qs as VisualEditor,Yc as VisualEditorLogic,Pc as chatCompleted,Fc as chatPickAttachments,jc as chatRemoveAttachment,Bc as chatRender,qc as chatRenderAttachments,Mc as chatReset,Lc as chatResize,$c as chatSend,Ys as codeMirrorWithOptions,Om as collectionBuildId,Z2 as createDOMPurify,Lt as createDecimal,Hu as defineCollection,Ar as defineComponent,im as fileSystemTree,j as fromTytx,Eh as fromTytxIter,K2 as loadMarkdown,fc as mountIndexPage,Es as parseDateExpression,ie as sourceTarget,L as toTytx,r0 as verifyCollectionArtifact,ae as visualEditorScope};
|
|
1753
1754
|
/*! Bundled license information:
|
|
1754
1755
|
|
|
1755
1756
|
decimal.js/decimal.mjs:
|