@gramlot/gramlot 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/components/audio/__init__.py +1 -1
  2. package/dist/components/audio/assets/collection.js +2 -2
  3. package/dist/components/audio/assets/index.js +1 -1
  4. package/dist/components/charts/__init__.py +2 -2
  5. package/dist/components/charts/assets/collection.js +24 -43
  6. package/dist/components/charts/assets/index.js +1 -1
  7. package/dist/components/charts/assets/modules/chunk-USZCUBTC.js +1 -0
  8. package/dist/components/charts/assets/modules/echarts-gl.min-N6L67H2M.js +4282 -0
  9. package/dist/components/charts/assets/modules/echarts.esm.min-VHLRZDVQ.js +61 -0
  10. package/dist/components/charts/assets/modules/{plotly.min-4LB7HE7P.js → plotly.min-SSDU2DOH.js} +1 -1
  11. package/dist/components/charts/assets/modules/{uPlot.esm-5JJNHHRF.js → uPlot.esm-Q2UYUQHJ.js} +1 -1
  12. package/dist/components/charts/assets/modules/{uPlot.min-N3E3FA74.js → uPlot.min-XXHNQFXH.js} +1 -1
  13. package/dist/components/charts/assets/modules/{vega.module-2QCOVQ3A.js → vega.module-Y5CWNSZO.js} +1 -1
  14. package/dist/components/charts/grammar.json +15482 -232
  15. package/dist/components/chat/__init__.py +1 -1
  16. package/dist/components/chat/assets/collection.js +3 -3
  17. package/dist/components/chat/assets/index.js +1 -1
  18. package/dist/components/drawing/__init__.py +1 -1
  19. package/dist/components/drawing/assets/collection.js +3 -24
  20. package/dist/components/drawing/assets/index.js +1 -1
  21. package/dist/components/editors/__init__.py +2 -2
  22. package/dist/components/editors/assets/collection.js +2 -47
  23. package/dist/components/editors/assets/index.js +1 -1
  24. package/dist/components/editors/assets/modules/{jodit-engine-MTSA4GZ3.js → jodit-engine-CXRSFV47.js} +6 -6
  25. package/dist/components/grid/__init__.py +2 -2
  26. package/dist/components/grid/assets/collection.js +6 -28
  27. package/dist/components/grid/assets/index.js +1 -1
  28. package/dist/components/grid/assets/modules/{browser-LVJHKBBV.js → browser-Y2BRNI3P.js} +1 -1
  29. package/dist/components/grid/assets/modules/chunk-BLMUM44K.js +1 -0
  30. package/dist/components/grouplets/__init__.py +1 -1
  31. package/dist/components/grouplets/assets/collection.js +3 -3
  32. package/dist/components/grouplets/assets/index.js +1 -1
  33. package/dist/components/inputs/__init__.py +1 -1
  34. package/dist/components/inputs/assets/collection.js +8 -65
  35. package/dist/components/inputs/assets/index.js +1 -1
  36. package/dist/components/layout/__init__.py +1 -1
  37. package/dist/components/layout/assets/collection.js +9 -30
  38. package/dist/components/layout/assets/index.js +1 -1
  39. package/dist/components/selection_trial/__init__.py +1 -1
  40. package/dist/components/selection_trial/assets/collection.js +3 -3
  41. package/dist/components/selection_trial/assets/index.js +1 -1
  42. package/dist/components/tree/__init__.py +1 -1
  43. package/dist/components/tree/assets/collection.js +6 -27
  44. package/dist/components/tree/assets/index.js +1 -1
  45. package/dist/components/typst/__init__.py +1 -1
  46. package/dist/components/typst/assets/collection.js +3 -3
  47. package/dist/components/typst/assets/index.js +1 -1
  48. package/dist/components/uploads/__init__.py +1 -1
  49. package/dist/components/uploads/assets/collection.js +3 -30
  50. package/dist/components/uploads/assets/index.js +1 -1
  51. package/dist/components/vizabi/__init__.py +1 -1
  52. package/dist/components/vizabi/assets/collection.js +3 -21
  53. package/dist/components/vizabi/assets/index.js +1 -1
  54. package/dist/gramlot.js +1599 -59
  55. package/dist/gramlot.min.js +49 -48
  56. package/dist/libraries.json +126 -0
  57. package/dist/runtime-notices.json +4 -0
  58. package/dist/standard-collections.js +1 -1
  59. package/package.json +2 -2
  60. package/src/components/chart-boxplot-options.js +22 -0
  61. package/src/components/chart-candlestick-options.js +27 -0
  62. package/src/components/chart-controls.js +28 -6
  63. package/src/components/chart-domains.js +1 -1
  64. package/src/components/chart-engines/echarts.js +28 -4
  65. package/src/components/chart-engines/plotly.js +3 -2
  66. package/src/components/chart-engines/uplot.js +5 -3
  67. package/src/components/chart-engines/vega.js +2 -1
  68. package/src/components/chart-fields.js +11 -1
  69. package/src/components/chart-funnel-options.js +19 -0
  70. package/src/components/chart-gauge-options.js +98 -0
  71. package/src/components/chart-gauge.js +109 -0
  72. package/src/components/chart-heatmap-options.js +29 -0
  73. package/src/components/chart-notice.js +126 -0
  74. package/src/components/chart-pane.js +7 -1
  75. package/src/components/chart-parallel-options.js +24 -0
  76. package/src/components/chart-radar-options.js +29 -0
  77. package/src/components/chart-renderer.js +3 -9
  78. package/src/components/chart-sankey-options.js +43 -0
  79. package/src/components/chart-sunburst-options.js +12 -0
  80. package/src/components/chart-syntax.js +82 -0
  81. package/src/components/chart-time.js +2 -1
  82. package/src/components/chart-treemap-options.js +16 -0
  83. package/src/components/chart-type-data.js +62 -0
  84. package/src/components/chart-types/area.js +6 -1
  85. package/src/components/chart-types/bar.js +6 -1
  86. package/src/components/chart-types/bar3D.js +7 -1
  87. package/src/components/chart-types/boxplot.js +11 -0
  88. package/src/components/chart-types/candlestick.js +10 -0
  89. package/src/components/chart-types/donut.js +6 -1
  90. package/src/components/chart-types/funnel.js +7 -0
  91. package/src/components/chart-types/heatmap.js +8 -0
  92. package/src/components/chart-types/horizontalBar.js +6 -1
  93. package/src/components/chart-types/index.js +21 -1
  94. package/src/components/chart-types/line.js +6 -1
  95. package/src/components/chart-types/line3D.js +7 -1
  96. package/src/components/chart-types/lines3D.js +7 -1
  97. package/src/components/chart-types/map.js +7 -1
  98. package/src/components/chart-types/map3D.js +6 -1
  99. package/src/components/chart-types/mapBar3D.js +6 -1
  100. package/src/components/chart-types/parallel.js +7 -0
  101. package/src/components/chart-types/pie.js +6 -1
  102. package/src/components/chart-types/polygons3D.js +7 -1
  103. package/src/components/chart-types/radar.js +7 -0
  104. package/src/components/chart-types/sankey.js +8 -0
  105. package/src/components/chart-types/scatter.js +6 -1
  106. package/src/components/chart-types/scatter3D.js +7 -1
  107. package/src/components/chart-types/stackedArea.js +6 -1
  108. package/src/components/chart-types/stackedBar.js +6 -1
  109. package/src/components/chart-types/sunburst.js +7 -0
  110. package/src/components/chart-types/surface.js +7 -1
  111. package/src/components/chart-types/treemap.js +7 -0
  112. package/src/components/charts.js +60 -13
  113. package/src/components/code-mirror.js +2 -1
  114. package/src/components/grid-tools.js +2 -1
  115. package/src/components/html-editor.js +2 -1
  116. package/src/components/markdown-editor.js +2 -1
  117. package/src/components/registry.js +9 -5
  118. package/src/components/typst-preview.js +2 -1
  119. package/src/index.d.ts +16 -0
  120. package/src/index.js +5 -0
  121. package/src/libraries.js +83 -0
  122. package/src/page-store-connection.js +15 -5
  123. package/src/server/gramlot-server.d.ts +8 -0
  124. package/src/server/gramlot-server.js +40 -4
  125. package/src/shared-modules.js +79 -0
  126. package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +0 -76
  127. package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +0 -1
  128. package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +0 -4409
  129. package/dist/components/grid/assets/modules/chunk-RMRBEYTI.js +0 -1
@@ -1,47 +1,28 @@
1
- import{a as Cu}from"./modules/chunk-2CCTLZE7.js";import{a as Ge,b as Es,c as Kt,d as ni}from"./modules/chunk-RMRBEYTI.js";var ht=Ge(ae=>{"use strict";function Wl(t,e,r){if(r===void 0&&(r=Array.prototype),t&&typeof r.find=="function")return r.find.call(t,e);for(var n=0;n<t.length;n++)if(ft(t,n)){var i=t[n];if(e.call(void 0,i,n,t))return i}}function Ct(t,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(t=e.create(null,e.getOwnPropertyDescriptors(t))),e&&typeof e.freeze=="function"?e.freeze(t):t}function ft(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Jl(t,e){if(t===null||typeof t!="object")throw new TypeError("target is not an object");for(var r in e)ft(e,r)&&(t[r]=e[r]);return t}var Qs=Ct({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 Zl(t){return ft(Qs,t.toLowerCase())}var Ks=Ct({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 Ql(t){return ft(Ks,t.toLowerCase())}var ar=Ct({script:!1,style:!1,textarea:!0,title:!0});function Kl(t){var e=t.toLowerCase();return ft(ar,e)&&!ar[e]}function ec(t){var e=t.toLowerCase();return ft(ar,e)&&ar[e]}function eo(t){return t===ur.HTML}function tc(t){return eo(t)||t===ur.XML_XHTML_APPLICATION}var ur=Ct({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),rc=Object.keys(ur).map(function(t){return ur[t]});function nc(t){return rc.indexOf(t)>-1}var ic=Ct({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/"});ae.assign=Jl;ae.find=Wl;ae.freeze=Ct;ae.HTML_BOOLEAN_ATTRIBUTES=Qs;ae.HTML_RAW_TEXT_ELEMENTS=ar;ae.HTML_VOID_ELEMENTS=Ks;ae.hasDefaultHTMLNamespace=tc;ae.hasOwn=ft;ae.isHTMLBooleanAttribute=Zl;ae.isHTMLRawTextElement=Kl;ae.isHTMLEscapableRawTextElement=ec;ae.isHTMLMimeType=eo;ae.isHTMLVoidElement=Ql;ae.isValidMimeType=nc;ae.MIME_TYPE=ur;ae.NAMESPACE=ic});var dr=Ge(hr=>{"use strict";var sc=ht();function ro(t,e){t.prototype=Object.create(Error.prototype,{constructor:{value:t},name:{value:t.name,enumerable:!0,writable:e}})}var cr=sc.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"}),no=Object.keys(cr);function io(t){return typeof t=="number"&&t>=1&&t<=25}function oc(t){return typeof t=="string"&&t.substring(t.length-cr.Error.length)===cr.Error}function fr(t,e){io(t)?(this.name=no[t],this.message=e||""):(this.message=t,this.name=oc(e)?e:cr.Error),Error.captureStackTrace&&Error.captureStackTrace(this,fr)}ro(fr,!0);Object.defineProperties(fr.prototype,{code:{enumerable:!0,get:function(){var t=no.indexOf(this.name);return io(t)?t:0}}});var so={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},bi=Object.entries(so);for(lr=0;lr<bi.length;lr++)to=bi[lr][0],fr[to]=bi[lr][1];var to,lr;function Di(t,e,r){this.message=t,this.locator=e,this.cause=r,Error.captureStackTrace&&Error.captureStackTrace(this,Di)}ro(Di);hr.DOMException=fr;hr.DOMExceptionName=cr;hr.ExceptionCode=so;hr.ParseError=Di});var Si=Ge(M=>{"use strict";function fo(t){try{typeof t!="function"&&(t=RegExp);var e=new t("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var Nt=fo();function Qe(t){if(t.source[0]!=="[")throw new Error(t+" can not be used with chars");return t.source.slice(1,t.source.lastIndexOf("]"))}function _t(t,e){if(t.source[0]!=="[")throw new Error("/"+t.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(t.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+t.source+"/");if(e==="-"&&t.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+t.source+"/");return new RegExp(t.source.replace(e,""),Nt?"u":"")}function R(t){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(r){var n=typeof r=="string";if(n&&e===void 0&&r==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?r:r.source}).join(""),Nt?"u":"")}function N(t){if(arguments.length===0)throw new Error("no parameters provided");return R.apply(N,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var ac="\uFFFD",Ke=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;Nt&&(Ke=R("[",Qe(Ke),"\\u{10000}-\\u{10FFFF}","]"));var uc=new RegExp("[^"+Qe(Ke)+"]",Nt?"u":""),nn=/[\x20\x09\x0D\x0A]/,lc=Qe(nn),j=R(nn,"+"),G=R(nn,"*"),pr=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;Nt&&(pr=R("[",Qe(pr),"\\u{10000}-\\u{10FFFF}","]"));var cc=Qe(pr),xi=R("[",cc,Qe(/[-.0-9\xB7]/),Qe(/[\u0300-\u036F\u203F-\u2040]/),"]"),we=R(pr,xi,"*"),fc=R("^",we,"$"),oo=R(xi,"+"),hc=R("&",we,";"),dc=N(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),mr=N(hc,"|",dc),gr=R("%",we,";"),Ai=N(R('"',N(/[^%&"]/,"|",gr,"|",mr),"*",'"'),"|",R("'",N(/[^%&']/,"|",gr,"|",mr),"*","'")),pc=N('"',N(/[^<&"]/,"|",mr),"*",'"',"|","'",N(/[^<&']/,"|",mr),"*","'"),mc=_t(pr,":"),gc=_t(xi,":"),vi=R(mc,gc,"*"),yc=R("^",vi,"$"),yr=R(vi,N(":",vi),"?"),wc=R("^",yr,"$"),Ec=R("(",yr,")"),St=N(/"[^"]*"|'[^']*'/),bc=R(/^<\?/,"(",we,")",N(j,"(?!",nn,")(",Ke,"*?)"),"?",/\?>/),ao=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,wr=N('"',ao,'*"',"|","'",_t(ao,"'"),"*'"),ho="<!--",po="-->",Dc=R(ho,N(_t(Ke,"-"),"|",R("-",_t(Ke,"-"))),"*",po),uo="#PCDATA",vc=N(R(/\(/,G,uo,N(G,/\|/,G,yr),"*",G,/\)\*/),"|",R(/\(/,G,uo,G,/\)/)),Tc=/[?*+]?/,xc=R(/\([^>]+\)/,Tc),Ac=N("EMPTY","|","ANY","|",vc,"|",xc),Cc="<!ELEMENT",_c=R(Cc,j,N(yr,"|",gr),j,N(Ac,"|",gr),G,">"),Sc=R("NOTATION",j,/\(/,G,we,N(G,/\|/,G,we),"*",G,/\)/),Nc=R(/\(/,G,oo,N(G,/\|/,G,oo),"*",G,/\)/),Ic=N(Sc,"|",Nc),Oc=N(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Ic),Bc=N(/#REQUIRED|#IMPLIED/,"|",N(N("#FIXED",j),"?",pc)),Mc=N(j,we,j,Oc,j,Bc),kc="<!ATTLIST",Fc=R(kc,j,we,Mc,"*",G,">"),Ti="about:legacy-compat",Rc=N('"'+Ti+'"',"|","'"+Ti+"'"),Ci="SYSTEM",sn="PUBLIC",on=N(N(Ci,j,St),"|",N(sn,j,wr,j,St)),Lc=R("^",N(N(Ci,j,"(?<SystemLiteralOnly>",St,")"),"|",N(sn,j,"(?<PubidLiteral>",wr,")",j,"(?<SystemLiteral>",St,")"))),Pc=R("^",wr,"$"),Uc=R("^",St,"$"),$c=N(j,"NDATA",j,we),qc=N(Ai,"|",N(on,$c,"?")),mo="<!ENTITY",Vc=R(mo,j,we,j,qc,G,">"),zc=N(Ai,"|",on),jc=R(mo,j,"%",j,we,j,zc,G,">"),Hc=N(Vc,"|",jc),Gc=R(sn,j,wr),Xc=R("<!NOTATION",j,we,j,N(on,"|",Gc),G,">"),_i=R(G,"=",G),lo=/1[.]\d+/,Yc=R(j,"version",_i,N("'",lo,"'","|",'"',lo,'"')),co=/[A-Za-z][-A-Za-z0-9._]*/,Wc=N(j,"encoding",_i,N('"',co,'"',"|","'",co,"'")),Jc=N(j,"standalone",_i,N("'",N("yes","|","no"),"'","|",'"',N("yes","|","no"),'"')),Zc=R(/^<\?xml/,Yc,Wc,"?",Jc,"?",G,/\?>/),Qc="<!DOCTYPE",Kc="<![CDATA[",ef="]]>",tf=/<!\[CDATA\[/,rf=/\]\]>/,nf=R(Ke,"*?",rf),sf=R(tf,nf);M.chars=Qe;M.chars_without=_t;M.detectUnicodeSupport=fo;M.reg=R;M.regg=N;M.ABOUT_LEGACY_COMPAT=Ti;M.ABOUT_LEGACY_COMPAT_SystemLiteral=Rc;M.AttlistDecl=Fc;M.CDATA_START=Kc;M.CDATA_END=ef;M.CDSect=sf;M.Char=Ke;M.Comment=Dc;M.COMMENT_START=ho;M.COMMENT_END=po;M.DOCTYPE_DECL_START=Qc;M.elementdecl=_c;M.EntityDecl=Hc;M.EntityValue=Ai;M.ExternalID=on;M.ExternalID_match=Lc;M.Name=we;M.Name_exact=fc;M.NCName_exact=yc;M.NotationDecl=Xc;M.Reference=mr;M.PEReference=gr;M.PI=bc;M.PUBLIC=sn;M.PubidLiteral=wr;M.PubidLiteral_match=Pc;M.QName=yr;M.QName_exact=wc;M.QName_group=Ec;M.S=j;M.SChar_s=lc;M.S_OPT=G;M.SYSTEM=Ci;M.SystemLiteral=St;M.SystemLiteral_match=Uc;M.InvalidChar=uc;M.UNICODE_REPLACEMENT_CHARACTER=ac;M.UNICODE_SUPPORT=Nt;M.XMLDecl=Zc});var Pi=Ge(W=>{"use strict";var Te=ht(),ke=Te.find,of=Te.hasDefaultHTMLNamespace,Ot=Te.hasOwn,af=Te.isHTMLMimeType,uf=Te.isHTMLRawTextElement,lf=Te.isHTMLVoidElement,Er=Te.MIME_TYPE,Fe=Te.NAMESPACE,de=Symbol(),vo=dr(),A=vo.DOMException,he=vo.DOMExceptionName,Y=Si();function me(t){if(t!==de)throw new TypeError("Illegal constructor")}function cf(t){return t!==""}function ff(t){return t?t.split(/[\t\n\f\r ]+/).filter(cf):[]}function hf(t,e){return Ot(t,e)||(t[e]=!0),t}function go(t){if(!t)return[];var e=ff(t);return Object.keys(e.reduce(hf,{}))}function df(t){return function(e){return t&&t.indexOf(e)!==-1}}function To(t){if(!Y.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+t+'"')}function Ii(t,e){To(e),t=t||null;var r=null,n=e;if(e.indexOf(":")>=0){var i=e.split(":");r=i[0],n=i[1]}if(r!==null&&t===null)throw new A(A.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(r==="xml"&&t!==Te.NAMESPACE.XML)throw new A(A.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((r==="xmlns"||e==="xmlns")&&t!==Te.NAMESPACE.XMLNS)throw new A(A.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(t===Te.NAMESPACE.XMLNS&&r!=="xmlns"&&e!=="xmlns")throw new A(A.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[t,r,n]}function kt(t,e){for(var r in t)Ot(t,r)&&(e[r]=t[r])}function ge(t,e){var r=t.prototype;if(!(r instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,kt(r,n),t.prototype=r=n}r.constructor!=t&&(typeof t!="function"&&console.error("unknown Class:"+t),r.constructor=t)}var ye={},ve=ye.ELEMENT_NODE=1,Bt=ye.ATTRIBUTE_NODE=2,br=ye.TEXT_NODE=3,xo=ye.CDATA_SECTION_NODE=4,Ao=ye.ENTITY_REFERENCE_NODE=5,pf=ye.ENTITY_NODE=6,Oi=ye.PROCESSING_INSTRUCTION_NODE=7,Bi=ye.COMMENT_NODE=8,It=ye.DOCUMENT_NODE=9,Co=ye.DOCUMENT_TYPE_NODE=10,et=ye.DOCUMENT_FRAGMENT_NODE=11,mf=ye.NOTATION_NODE=12,X=Te.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 _o(t,e){if(e.length<t.length)return _o(e,t);var r=null;for(var n in t){if(t[n]!==e[n])return r;r=t[n]}return r}function yo(t){return t.guid||(t.guid=Math.random()),t.guid}function te(){}te.prototype={length:0,item:function(t){return t>=0&&t<this.length?this[t]:null},toString:function(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var r=[],n=0;n<this.length;n++)Li(this[n],r,null,e);return r.join("")},filter:function(t){return Array.prototype.filter.call(this,t)},indexOf:function(t){return Array.prototype.indexOf.call(this,t)}};te.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Me(t,e){this._node=t,this._refresh=e,cn(this)}function cn(t){var e=t._node._inc||t._node.ownerDocument._inc;if(t._inc!==e){var r=t._refresh(t._node);if(Po(t,"length",r.length),!t.$$length||r.length<t.$$length)for(var n=r.length;n in t;n++)Ot(t,n)&&delete t[n];kt(r,t),t._inc=e}}Me.prototype.item=function(t){return cn(this),this[t]||null};ge(Me,te);function Mt(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function So(t,e){for(var r=0;r<t.length;){if(t[r]===e)return r;r++}}function Mi(t,e,r){if(!e)return t._noNsIndex;var n=t._nsIndex[e];return!n&&r&&(n=t._nsIndex[e]=Object.create(null)),n}function gf(t,e,r){var n=Mi(t,e,!1),i=n&&n[r];return i||null}function yf(t,e){Mi(t,e.namespaceURI,!0)[e.localName]=e}function wf(t,e){var r=Mi(t,e.namespaceURI,!1);r&&delete r[e.localName]}function Ef(t,e,r,n){if(n?e[So(e,n)]=r:(e[e.length]=r,e.length++),yf(e,r),t){r.ownerElement=t;var i=t.ownerDocument;i&&(n&&Oo(i,t,n),bf(i,t,r))}}function wo(t,e,r){var n=So(e,r);if(n>=0){for(var i=e.length-1;n<=i;)e[n]=e[++n];if(e.length=i,wf(e,r),t){var s=t.ownerDocument;s&&Oo(s,t,r),r.ownerElement=null}}}Mt.prototype={length:0,item:te.prototype.item,getNamedItem:function(t){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());for(var e=0;e<this.length;){var r=this[e];if(r.nodeName===t)return r;e++}return null},setNamedItem:function(t){var e=t.ownerElement;if(e&&e!==this._ownerElement)throw new A(A.INUSE_ATTRIBUTE_ERR);var r=gf(this,t.namespaceURI,t.localName);return r===t?t:(Ef(this._ownerElement,this,t,r),r)},setNamedItemNS:function(t){return this.setNamedItem(t)},removeNamedItem:function(t){var e=this.getNamedItem(t);if(!e)throw new A(A.NOT_FOUND_ERR,t);return wo(this._ownerElement,this,e),e},removeNamedItemNS:function(t,e){var r=this.getNamedItemNS(t,e);if(!r)throw new A(A.NOT_FOUND_ERR,t?t+" : "+e:e);return wo(this._ownerElement,this,r),r},getNamedItemNS:function(t,e){t||(t=null);for(var r=0;r<this.length;){var n=this[r];if(n.localName===e&&n.namespaceURI===t)return n;r++}return null}};Mt.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function No(){}No.prototype={hasFeature:function(t,e){return!0},createDocument:function(t,e,r){var n=Er.XML_APPLICATION;t===Fe.HTML?n=Er.XML_XHTML_APPLICATION:t===Fe.SVG&&(n=Er.XML_SVG_IMAGE);var i=new qe(de,{contentType:n});if(i.implementation=this,i.childNodes=new te,i.doctype=r||null,r&&i.appendChild(r),e){var s=i.createElementNS(t,e);i.appendChild(s)}return i},createDocumentType:function(t,e,r,n){To(t);var i=new dn(de);return i.name=t,i.nodeName=t,i.publicId=e||"",i.systemId=r||"",i.internalSubset=n||"",i.childNodes=new te,i},createHTMLDocument:function(t){var e=new qe(de,{contentType:Er.HTML});if(e.implementation=this,e.childNodes=new te,t!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var r=e.createElement("html");e.appendChild(r);var n=e.createElement("head");if(r.appendChild(n),typeof t=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(t)),n.appendChild(i)}r.appendChild(e.createElement("body"))}return e}};function P(t){me(t)}P.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 t=this.getRootNode();return t&&t.nodeType===t.DOCUMENT_NODE},contains:function(t){if(!t)return!1;var e=t;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(t){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(t){if(!t)return!1;for(var e=[{node:this,other:t}];e.length>0;){var r=e.pop(),n=r.node,i=r.other;if(n.nodeType!==i.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==i.name||n.publicId!==i.publicId||n.systemId!==i.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==i.namespaceURI||n.prefix!==i.prefix||n.localName!==i.localName||n.attributes.length!==i.attributes.length)return!1;for(var s=0;s<n.attributes.length;s++){var o=n.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==i.namespaceURI||n.localName!==i.localName||n.value!==i.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==i.target||n.data!==i.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==i.data)return!1;break}if(n.childNodes.length!==i.childNodes.length)return!1;for(var s=n.childNodes.length-1;s>=0;s--)e.push({node:n.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(t){return this===t},insertBefore:function(t,e){return ln(this,t,e)},replaceChild:function(t,e){ln(this,t,e,ko),e&&this.removeChild(e)},removeChild:function(t){return Bo(this,t)},appendChild:function(t){return this.insertBefore(t,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(t){return Lo(this.ownerDocument||this,this,t)},normalize:function(){ue(this,null,{enter:function(t){for(var e=t.firstChild;e;){var r=e.nextSibling;if(r!==null&&r.nodeType===br&&e.nodeType===br){for(var n=[],i=r;i!==null&&i.nodeType===br;)n.push(i.data),i=i.nextSibling;for(var s=e.nextSibling;s!==i;){var o=s.nextSibling;s.parentNode=null,s.previousSibling=null,s.nextSibling=null,s=o}e.nextSibling=i,i!==null?i.previousSibling=e:t.lastChild=e,e.appendData(n.join("")),ki(t.ownerDocument,t),e=i}else e=r}return!0}})},isSupported:function(t,e){return this.ownerDocument.implementation.hasFeature(t,e)},lookupPrefix:function(t){for(var e=this;e;){var r=e._nsMap;if(r){for(var n in r)if(Ot(r,n)&&r[n]===t)return n}e=e.nodeType==Bt?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(t){for(var e=this;e;){var r=e._nsMap;if(r&&Ot(r,t))return r[t];e=e.nodeType==Bt?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(t){var e=this.lookupPrefix(t);return e==null},compareDocumentPosition:function(t){if(this===t)return 0;var e=t,r=this,n=null,i=null;if(e instanceof dt&&(n=e,e=n.ownerElement),r instanceof dt&&(i=r,r=i.ownerElement,n&&e&&r===e))for(var s=0,o;o=r.attributes[s];s++){if(o===n)return X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+X.DOCUMENT_POSITION_PRECEDING;if(o===i)return X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+X.DOCUMENT_POSITION_FOLLOWING}if(!e||!r||r.ownerDocument!==e.ownerDocument)return X.DOCUMENT_POSITION_DISCONNECTED+X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(yo(r.ownerDocument)>yo(e.ownerDocument)?X.DOCUMENT_POSITION_FOLLOWING:X.DOCUMENT_POSITION_PRECEDING);if(i&&e===r)return X.DOCUMENT_POSITION_CONTAINS+X.DOCUMENT_POSITION_PRECEDING;if(n&&e===r)return X.DOCUMENT_POSITION_CONTAINED_BY+X.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===r)return X.DOCUMENT_POSITION_CONTAINED_BY+X.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=r.parentNode;c;){if(!n&&c===e)return X.DOCUMENT_POSITION_CONTAINS+X.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var f=_o(a,u);for(var h in f.childNodes){var d=f.childNodes[h];if(d===r)return X.DOCUMENT_POSITION_FOLLOWING;if(d===e)return X.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(d)>=0)return X.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(d)>=0)return X.DOCUMENT_POSITION_PRECEDING}return 0}};function Io(t){return t=="<"&&"&lt;"||t==">"&&"&gt;"||t=="&"&&"&amp;"||t=='"'&&"&quot;"||"&#"+t.charCodeAt()+";"}kt(ye,P);kt(ye,P.prototype);kt(X,P);kt(X,P.prototype);function un(t,e){ue(t,null,{enter:function(r){return e(r)?ue.STOP:!0}})}function ue(t,e,r){for(var n=[{node:t,context:e,phase:ue.ENTER}];n.length>0;){var i=n.pop();if(i.phase===ue.ENTER){var s=r.enter(i.node,i.context);if(s===ue.STOP)return ue.STOP;if(n.push({node:i.node,context:s,phase:ue.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)n.push({node:o,context:s,phase:ue.ENTER}),o=o.previousSibling}else r.exit&&r.exit(i.node,i.context)}}ue.STOP=Symbol("walkDOM.STOP");ue.ENTER=0;ue.EXIT=1;function qe(t,e){me(t);var r=e||{};this.ownerDocument=this,this.contentType=r.contentType||Er.XML_APPLICATION,this.type=af(this.contentType)?"html":"xml"}function bf(t,e,r){t&&t._inc++;var n=r.namespaceURI;n===Fe.XMLNS&&(e._nsMap[r.prefix?r.localName:""]=r.value)}function Oo(t,e,r,n){t&&t._inc++;var i=r.namespaceURI;i===Fe.XMLNS&&delete e._nsMap[r.prefix?r.localName:""]}function ki(t,e,r){if(t&&t._inc){t._inc++;var n=e.childNodes;if(r&&!r.nextSibling)n[n.length++]=r;else{for(var i=e.firstChild,s=0;i;)n[s++]=i,i=i.nextSibling;n.length=s,delete n[n.length]}}}function Bo(t,e){if(t!==e.parentNode)throw new A(A.NOT_FOUND_ERR,"child's parent is not parent");var r=e.previousSibling,n=e.nextSibling;return r?r.nextSibling=n:t.firstChild=n,n?n.previousSibling=r:t.lastChild=r,ki(t.ownerDocument,t),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function Df(t){return t&&(t.nodeType===P.DOCUMENT_NODE||t.nodeType===P.DOCUMENT_FRAGMENT_NODE||t.nodeType===P.ELEMENT_NODE)}function vf(t){return t&&(t.nodeType===P.CDATA_SECTION_NODE||t.nodeType===P.COMMENT_NODE||t.nodeType===P.DOCUMENT_FRAGMENT_NODE||t.nodeType===P.DOCUMENT_TYPE_NODE||t.nodeType===P.ELEMENT_NODE||t.nodeType===P.PROCESSING_INSTRUCTION_NODE||t.nodeType===P.TEXT_NODE)}function tt(t){return t&&t.nodeType===P.DOCUMENT_TYPE_NODE}function $e(t){return t&&t.nodeType===P.ELEMENT_NODE}function Mo(t){return t&&t.nodeType===P.TEXT_NODE}function Eo(t,e){var r=t.childNodes||[];if(ke(r,$e)||tt(e))return!1;var n=ke(r,tt);return!(e&&n&&r.indexOf(n)>r.indexOf(e))}function bo(t,e){var r=t.childNodes||[];function n(s){return $e(s)&&s!==e}if(ke(r,n))return!1;var i=ke(r,tt);return!(e&&i&&r.indexOf(i)>r.indexOf(e))}function Tf(t,e,r){if(!Df(t))throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+t.nodeType);if(r&&r.parentNode!==t)throw new A(A.NOT_FOUND_ERR,"child not in parent");if(!vf(e)||tt(e)&&t.nodeType!==P.DOCUMENT_NODE)throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+t.nodeType)}function xf(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===P.DOCUMENT_FRAGMENT_NODE){var s=i.filter($e);if(s.length>1||ke(i,Mo))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Eo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if($e(e)&&!Eo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(tt(e)){if(ke(n,tt))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ke(n,$e);if(r&&n.indexOf(o)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!r&&o)throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function ko(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===P.DOCUMENT_FRAGMENT_NODE){var s=i.filter($e);if(s.length>1||ke(i,Mo))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!bo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if($e(e)&&!bo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(tt(e)){if(ke(n,function(l){return tt(l)&&l!==r}))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ke(n,$e);if(r&&n.indexOf(o)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function ln(t,e,r,n){Tf(t,e,r),t.nodeType===P.DOCUMENT_NODE&&(n||xf)(t,e,r);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===et){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=r?r.previousSibling:t.lastChild;s.previousSibling=a,o.nextSibling=r,a?a.nextSibling=s:t.firstChild=s,r==null?t.lastChild=o:r.previousSibling=o;do s.parentNode=t;while(s!==o&&(s=s.nextSibling));return ki(t.ownerDocument||t,t,e),e.nodeType==et&&(e.firstChild=e.lastChild=null),e}qe.prototype={implementation:null,nodeName:"#document",nodeType:It,doctype:null,documentElement:null,_inc:1,insertBefore:function(t,e){if(t.nodeType===et){for(var r=t.firstChild;r;){var n=r.nextSibling;this.insertBefore(r,e),r=n}return t}return ln(this,t,e),t.ownerDocument=this,this.documentElement===null&&t.nodeType===ve&&(this.documentElement=t),t},removeChild:function(t){var e=Bo(this,t);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(t,e){ln(this,t,e,ko),t.ownerDocument=this,e&&this.removeChild(e),$e(t)&&(this.documentElement=t)},importNode:function(t,e){return Af(this,t,e)},getElementById:function(t){var e=null;return un(this.documentElement,function(r){if(r.nodeType==ve&&r.getAttribute("id")==t)return e=r,!0}),e},createElement:function(t){var e=new Ve(de);e.ownerDocument=this,this.type==="html"&&(t=t.toLowerCase()),of(this.contentType)&&(e.namespaceURI=Fe.HTML),e.nodeName=t,e.tagName=t,e.localName=t,e.childNodes=new te;var r=e.attributes=new Mt;return r._ownerElement=e,e},createDocumentFragment:function(){var t=new Ft(de);return t.ownerDocument=this,t.childNodes=new te,t},createTextNode:function(t){var e=new Dr(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createComment:function(t){var e=new fn(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createCDATASection:function(t){if(t.indexOf("]]>")!==-1)throw new A(A.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new hn(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createProcessingInstruction:function(t,e){var r=new mn(de);return r.ownerDocument=this,r.childNodes=new te,r.nodeName=r.target=t,r.nodeValue=r.data=e,r},createAttribute:function(t){if(!Y.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in name "'+t+'"');return this.type==="html"&&(t=t.toLowerCase()),this._createAttribute(t)},_createAttribute:function(t){var e=new dt(de);return e.ownerDocument=this,e.childNodes=new te,e.name=t,e.nodeName=t,e.localName=t,e.specified=!0,e},createEntityReference:function(t){if(!Y.Name_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'not a valid xml name "'+t+'"');if(this.type==="html")throw new A("document is an html document",he.NotSupportedError);var e=new pn(de);return e.ownerDocument=this,e.childNodes=new te,e.nodeName=t,e},createElementNS:function(t,e){var r=Ii(t,e),n=new Ve(de),i=n.attributes=new Mt;return n.childNodes=new te,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],i._ownerElement=n,n},createAttributeNS:function(t,e){var r=Ii(t,e),n=new dt(de);return n.ownerDocument=this,n.childNodes=new te,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],n}};ge(qe,P);function Ve(t){me(t),this._nsMap=Object.create(null)}Ve.prototype={nodeType:ve,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Fe.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(t){return!!this.getAttributeNode(t)},getAttribute:function(t){var e=this.getAttributeNode(t);return e?e.value:null},getAttributeNode:function(t){return this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase()),this.attributes.getNamedItem(t)},setAttribute:function(t,e){this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());var r=this.getAttributeNode(t);r?r.value=r.nodeValue=""+e:(r=this.ownerDocument._createAttribute(t),r.value=r.nodeValue=""+e,this.setAttributeNode(r))},removeAttribute:function(t){var e=this.getAttributeNode(t);e&&this.removeAttributeNode(e)},setAttributeNode:function(t){return this.attributes.setNamedItem(t)},setAttributeNodeNS:function(t){return this.attributes.setNamedItemNS(t)},removeAttributeNode:function(t){return this.attributes.removeNamedItem(t.nodeName)},removeAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);r&&this.removeAttributeNode(r)},hasAttributeNS:function(t,e){return this.getAttributeNodeNS(t,e)!=null},getAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);return r?r.value:null},setAttributeNS:function(t,e,r){var n=Ii(t,e),i=n[2],s=this.getAttributeNodeNS(t,i);s?s.value=s.nodeValue=""+r:(s=this.ownerDocument.createAttributeNS(t,e),s.value=s.nodeValue=""+r,this.setAttributeNode(s))},getAttributeNodeNS:function(t,e){return this.attributes.getNamedItemNS(t,e)},getElementsByClassName:function(t){var e=go(t);return new Me(this,function(r){var n=[];return e.length>0&&un(r,function(i){if(i!==r&&i.nodeType===ve){var s=i.getAttribute("class");if(s){var o=t===s;if(!o){var a=go(s);o=e.every(df(a))}o&&n.push(i)}}}),n})},getElementsByTagName:function(t){var e=(this.nodeType===It?this:this.ownerDocument).type==="html",r=t.toLowerCase();return new Me(this,function(n){var i=[];return un(n,function(s){if(!(s===n||s.nodeType!==ve))if(t==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Fe.HTML?r:t;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(t,e){return new Me(this,function(r){var n=[];return un(r,function(i){i!==r&&i.nodeType===ve&&(t==="*"||i.namespaceURI===t)&&(e==="*"||i.localName==e)&&n.push(i)}),n})}};qe.prototype.getElementsByClassName=Ve.prototype.getElementsByClassName;qe.prototype.getElementsByTagName=Ve.prototype.getElementsByTagName;qe.prototype.getElementsByTagNameNS=Ve.prototype.getElementsByTagNameNS;ge(Ve,P);function dt(t){me(t),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}dt.prototype.nodeType=Bt;ge(dt,P);function rt(t){me(t)}rt.prototype={data:"",substringData:function(t,e){return this.data.substring(t,t+e)},appendData:function(t){t=this.data+t,this.nodeValue=this.data=t,this.length=t.length},insertData:function(t,e){this.replaceData(t,0,e)},deleteData:function(t,e){this.replaceData(t,e,"")},replaceData:function(t,e,r){var n=this.data.substring(0,t),i=this.data.substring(t+e);r=n+r+i,this.nodeValue=this.data=r,this.length=r.length}};ge(rt,P);function Dr(t){me(t)}Dr.prototype={nodeName:"#text",nodeType:br,splitText:function(t){var e=this.data,r=e.substring(t);e=e.substring(0,t),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(r);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};ge(Dr,rt);function fn(t){me(t)}fn.prototype={nodeName:"#comment",nodeType:Bi};ge(fn,rt);function hn(t){me(t)}hn.prototype={nodeName:"#cdata-section",nodeType:xo};ge(hn,Dr);function dn(t){me(t)}dn.prototype.nodeType=Co;ge(dn,P);function Fi(t){me(t)}Fi.prototype.nodeType=mf;ge(Fi,P);function Ri(t){me(t)}Ri.prototype.nodeType=pf;ge(Ri,P);function pn(t){me(t)}pn.prototype.nodeType=Ao;ge(pn,P);function Ft(t){me(t)}Ft.prototype.nodeName="#document-fragment";Ft.prototype.nodeType=et;ge(Ft,P);function mn(t){me(t)}mn.prototype.nodeType=Oi;ge(mn,rt);function Fo(){}Fo.prototype.serializeToString=function(t,e){return Ro.call(t,e)};P.prototype.toString=Ro;function Ro(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t!=null?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var r=[],n=this.nodeType===It&&this.documentElement||this,i=n.prefix,s=n.namespaceURI;if(s&&i==null){var i=n.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return Li(this,r,o,e),r.join("")}function Do(t,e,r){var n=t.prefix||"",i=t.namespaceURI;if(!i||n==="xml"&&i===Fe.XML||i===Fe.XMLNS)return!1;for(var s=r.length;s--;){var o=r[s];if(o.prefix===n)return o.namespace!==i}return!0}function an(t,e,r,n){if(n&&!Y.QName_exact.test(e))throw new A('The attribute name "'+e+'" is not a valid XML QName',he.InvalidStateError);t.push(" ",e,'="',r.replace(/[<>&"\t\n\r]/g,Io),'"')}function Li(t,e,r,n){r||(r=[]);var i=n.nodeFilter,s=n.requireWellFormed,o=n.splitCDATASections,a=t.nodeType===It?t:t.ownerDocument,l=a.type==="html";ue(t,{ns:r},{enter:function(u,c){var f=c.ns;if(i)if(u=i(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case ve:var h=u.attributes,d=h.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var g,y=0;y<h.length;y++)if(h.item(y).name==="xmlns"){g=h.item(y).value;break}if(!g)for(var E=f.length-1;E>=0;E--){var w=f[E];if(w.prefix===""&&w.namespace===u.namespaceURI){g=w.namespace;break}}if(g!==u.namespaceURI)for(var E=f.length-1;E>=0;E--){var w=f[E];if(w.namespace===u.namespaceURI){w.prefix&&(m=w.prefix+":"+p);break}}}if(s&&!Y.QName_exact.test(m))throw new A('The element name "'+m+'" is not a valid XML QName',he.InvalidStateError);e.push("<",m);for(var v=f.slice(),x=0;x<d;x++){var T=h.item(x);T.prefix=="xmlns"?v.push({prefix:T.localName,namespace:T.value}):T.nodeName=="xmlns"&&v.push({prefix:"",namespace:T.value})}for(var x=0;x<d;x++){var T=h.item(x);if(Do(T,l,v)){var b=T.prefix||"",C=T.namespaceURI;an(e,b?"xmlns:"+b:"xmlns",C,s),v.push({prefix:b,namespace:C})}var I=i?i(T):T;I&&(typeof I=="string"?e.push(I):an(e,I.name,I.value,s))}if(p===m&&Do(u,l,v)){var O=u.prefix||"",C=u.namespaceURI;an(e,O?"xmlns:"+O:"xmlns",C,s),v.push({prefix:O,namespace:C})}var L=!u.firstChild;if(L&&(l||u.namespaceURI===Fe.HTML)&&(L=lf(p)),L)return e.push("/>"),null;if(e.push(">"),l&&uf(p)){for(var $=u.firstChild;$;)$.data?e.push($.data):Li($,e,v.slice(),n),$=$.nextSibling;return e.push("</",m,">"),null}return{ns:v,tag:m};case It:case et:if(s&&u.nodeType===It&&u.documentElement==null)throw new A("The Document has no documentElement",he.InvalidStateError);return{ns:f};case Bt:return an(e,u.name,u.value,s),null;case br:if(s&&Y.InvalidChar.test(u.data))throw new A("The Text node data contains characters outside the XML Char production",he.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Io)),null;case xo:if(s&&u.data.indexOf("]]>")!==-1)throw new A('The CDATASection data contains "]]>"',he.InvalidStateError);return o?e.push(Y.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Y.CDATA_END):e.push(Y.CDATA_START,u.data,Y.CDATA_END),null;case Bi:if(s){if(Y.InvalidChar.test(u.data))throw new A("The comment node data contains characters outside the XML Char production",he.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new A('The comment node data contains "--" or ends with "-"',he.InvalidStateError)}return e.push(Y.COMMENT_START,u.data,Y.COMMENT_END),null;case Co:var se=u.publicId,V=u.systemId;if(s){if(!Y.Name_exact.test(u.name))throw new A('The doctype name "'+u.name+'" is not a valid XML Name',he.InvalidStateError);if(se&&!Y.PubidLiteral_match.test(se))throw new A("DocumentType publicId is not a valid PubidLiteral",he.InvalidStateError);if(V&&V!=="."&&!Y.SystemLiteral_match.test(V))throw new A("DocumentType systemId is not a valid SystemLiteral",he.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new A('DocumentType internalSubset contains "]>"',he.InvalidStateError)}return e.push(Y.DOCTYPE_DECL_START," ",u.name),se?(e.push(" ",Y.PUBLIC," ",se),V&&V!=="."&&e.push(" ",V)):V&&V!=="."&&e.push(" ",Y.SYSTEM," ",V),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Oi:if(s){if(!Y.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new A('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',he.InvalidStateError);if(Y.InvalidChar.test(u.data))throw new A("The ProcessingInstruction data contains characters outside the XML Char production",he.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new A('The ProcessingInstruction data contains "?>"',he.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Ao:if(s&&!Y.Name_exact.test(u.nodeName))throw new A('The entity reference name "'+u.nodeName+'" is not a valid XML Name',he.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 Af(t,e,r){var n;return ue(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=t,o.parentNode=null,s===null?n=o:s.appendChild(o);var a=i.nodeType===Bt||r;return a?o:null}}),n}function Lo(t,e,r){var n;return ue(e,null,{enter:function(i,s){var o=new i.constructor(de);for(var a in i)if(Ot(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new te),o.ownerDocument=t;var u=r;switch(o.nodeType){case ve:var c=i.attributes,f=o.attributes=new Mt,h=c.length;f._ownerElement=o;for(var d=0;d<h;d++)o.setAttributeNode(Lo(t,c.item(d),!0));break;case Bt:u=!0}return s!==null?s.appendChild(o):n=o,u?o:null}}),n}function Po(t,e,r){t[e]=r}function Ni(t){for(var e=[],r=t.firstChild;r;)r.nodeType===ve&&e.push(r),r=r.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Me.prototype,"length",{get:function(){return cn(this),this.$$length}}),Object.defineProperty(P.prototype,"textContent",{get:function(){if(this.nodeType===ve||this.nodeType===et){var t=[];return ue(this,null,{enter:function(e){if(e.nodeType===ve||e.nodeType===et)return!0;if(e.nodeType===Oi||e.nodeType===Bi)return null;t.push(e.nodeValue)}}),t.join("")}return this.nodeValue},set:function(t){switch(this.nodeType){case ve:case et:for(;this.firstChild;)this.removeChild(this.firstChild);(t||String(t))&&this.appendChild(this.ownerDocument.createTextNode(t));break;default:this.data=t,this.value=t,this.nodeValue=t}}}),Object.defineProperty(rt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(t){this._data=t,this.length=typeof t=="string"?t.length:0}}),Object.defineProperty(rt.prototype,"nodeValue",{get:function(){return this.data},set:function(t){this.data=t},enumerable:!0,configurable:!0}),Object.defineProperty(Ve.prototype,"children",{get:function(){return new Me(this,Ni)}}),Object.defineProperty(qe.prototype,"children",{get:function(){return new Me(this,Ni)}}),Object.defineProperty(Ft.prototype,"children",{get:function(){return new Me(this,Ni)}}),Po=function(t,e,r){t["$$"+e]=r})}catch{}W._updateLiveList=cn;W.Attr=dt;W.CDATASection=hn;W.CharacterData=rt;W.Comment=fn;W.Document=qe;W.DocumentFragment=Ft;W.DocumentType=dn;W.DOMImplementation=No;W.Element=Ve;W.Entity=Ri;W.EntityReference=pn;W.LiveNodeList=Me;W.NamedNodeMap=Mt;W.Node=P;W.NodeList=te;W.Notation=Fi;W.Text=Dr;W.ProcessingInstruction=mn;W.walkDOM=ue;W.XMLSerializer=Fo});var $o=Ge(vr=>{"use strict";var Uo=ht().freeze;vr.XML_ENTITIES=Uo({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});vr.HTML_ENTITIES=Uo({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:`
2
- `,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"});vr.entityMap=vr.HTML_ENTITIES});var Wo=Ge(yn=>{"use strict";var $t=ht(),k=Si(),jo=dr(),Cf=$t.isHTMLEscapableRawTextElement,_f=$t.isHTMLMimeType,Sf=$t.isHTMLRawTextElement,Ar=$t.hasOwn,qo=$t.NAMESPACE,Nf=jo.ParseError,If=jo.DOMException,Rt=0,nt=1,Lt=2,Tr=3,Pt=4,Ut=5,xr=6,gn=7;function Ho(){}Ho.prototype={parse:function(t,e,r){var n=this.domBuilder;n.startDocument(),kf(e,e=Object.create(null)),Of(t,e,r,n,this.errorHandler),n.endDocument()}};var Ui=/&#?\w+;?/g;function Of(t,e,r,n,i){var s=_f(n.mimeType);t.indexOf(k.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(q){if(q>65535){q-=65536;var be=55296+(q>>10),$r=56320+(q&1023);return String.fromCharCode(be,$r)}else return String.fromCharCode(q)}function a(q){var be=q[q.length-1]===";"?q:q+";";if(!s&&be!==q)return i.error("EntityRef: expecting ;"),q;var $r=k.Reference.exec(be);if(!$r||$r[0].length!==be.length)return i.error("entity not matching Reference production: "+q),q;var qr=be.slice(1,-1);return Ar(r,qr)?r[qr]:qr.charAt(0)==="#"?o(parseInt(qr.substring(1).replace("x","0x"))):(i.error("entity not found:"+q),q)}function l(q){if(q>g){var be=t.substring(g,q).replace(Ui,a);h&&d(g),n.characters(be,0,q-g),g=q}}var u=0,c=0,f=/\r\n?|\n|$/g,h=n.locator;function d(q,be){for(;q>=c&&(be=f.exec(t));)u=c,c=be.index+be[0].length,h.lineNumber++;h.columnNumber=q-u+1}for(var p=[{currentNSMap:e}],m=[],g=0;;){try{var y=t.indexOf("<",g);if(y<0){if(!s&&m.length>0)return i.fatalError("unclosed xml tag(s): "+m.join(", "));if(!t.substring(g).match(/^\s*$/)){var E=n.doc,w=E.createTextNode(t.substring(g));if(E.documentElement)return i.error("Extra content at the end of the document");E.appendChild(w),n.currentElement=w}return}if(y>g){var v=t.substring(g,y);!s&&m.length===0&&(v=v.replace(new RegExp(k.S_OPT.source,"g"),""),v&&i.error("Unexpected content outside root element: '"+v+"'")),l(y)}switch(t.charAt(y+1)){case"/":var F=t.indexOf(">",y+2),x=t.substring(y+2,F>0?F:void 0);if(!x)return i.fatalError("end tag name missing");var T=k.reg("^",k.QName_group,k.S_OPT,"$"),b=F>0&&T.exec(x);if(!b){var C=F>0&&k.reg("^",k.QName_group).exec(x);if(s&&C)i.warning('end tag name contains invalid trailing characters: "'+x+'"'),b=C;else if(C&&new RegExp(T.source,T.flags+"m").test(x))i.error('end tag name is followed by a line break and trailing content: "'+x+'"'),b=C;else return i.fatalError('end tag name contains invalid characters: "'+x+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var I=m[m.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(I!==b[1]){var O=b[1].toLowerCase();if(!s||I.toLowerCase()!==O)return i.fatalError('Opening and ending tag mismatch: "'+I+'" != "'+x+'"')}var L=p.pop();m.pop();var $=L.localNSMap;if(n.endElement(L.uri,L.localName,I),$)for(var se in $)Ar($,se)&&n.endPrefixMapping(se);F++;break;case"?":h&&d(y),F=Rf(t,y,n,i);break;case"!":h&&d(y),F=Xo(t,y,n,i,s);break;default:h&&d(y);var V=new Yo,Q=p[p.length-1].currentNSMap,F=Bf(t,y,V,Q,a,i,s),ys=V.length;if(V.closed||(s&&$t.isHTMLVoidElement(V.tagName)?V.closed=!0:m.push(V.tagName)),h&&ys){for(var Au=Vo(h,{}),ri=0;ri<ys;ri++){var ws=V[ri];d(ws.offset),ws.locator=Vo(h,{})}n.locator=Au,zo(V,n,Q)&&p.push(V),n.locator=h}else zo(V,n,Q)&&p.push(V);s&&!V.closed?F=Mf(t,F,V.tagName,a,n):F++}}catch(q){if(q instanceof Nf)throw q;if(q instanceof If)return i.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);i.error("element parse error: "+q),F=-1}F>g?g=F:l(Math.max(y,g)+1)}}function Vo(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function Bf(t,e,r,n,i,s,o){function a(d,p,m){if(Ar(r.attributeNames,d))return s.fatalError("Attribute "+d+" redefined");if(!o&&p.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");r.addValue(d,p.replace(/[\t\n\r]/g," ").replace(Ui,i),m)}for(var l,u,c=++e,f=Rt;;){var h=t.charAt(c);if(f===Rt&&h==="<")throw new Error("unexpected < in tag name: "+t.slice(e,c));switch(h){case"=":if(f===nt)l=t.slice(e,c),f=Tr;else if(f===Lt)f=Tr;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(f===Tr||f===nt)if(f===nt&&(s.warning('attribute value must after "="'),l=t.slice(e,c)),e=c+1,c=t.indexOf(h,e),c>0)u=t.slice(e,c),a(l,u,e-1),f=Ut;else throw new Error("attribute value no end '"+h+"' match");else if(f==Pt)u=t.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+h+")!!"),e=c+1,f=Ut;else throw new Error('attribute value must after "="');break;case"/":switch(f){case Rt:r.setTagName(t.slice(e,c));case Ut:case xr:case gn:f=gn,r.closed=!0;case Pt:case nt:break;case Lt:r.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),f==Rt&&r.setTagName(t.slice(e,c)),c;case">":switch(f){case Rt:r.setTagName(t.slice(e,c));case Ut:case xr:case gn:break;case Pt:case nt:u=t.slice(e,c),u.slice(-1)==="/"&&(r.closed=!0,u=u.slice(0,-1));case Lt:f===Lt&&(u=l),f==Pt?(s.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||s.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case Tr:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":h=" ";default:if(h<=" ")switch(f){case Rt:r.setTagName(t.slice(e,c)),f=xr;break;case nt:l=t.slice(e,c),f=Lt;break;case Pt:var u=t.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Ut:f=xr;break}else switch(f){case Lt:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,f=nt;break;case Ut:s.warning('attribute space is required"'+l+'"!!');case xr:f=nt,e=c;break;case Tr:f=Pt,e=c;break;case gn:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function zo(t,e,r){for(var n=t.tagName,i=null,f=t.length;f--;){var s=t[f],o=s.qName,a=s.value,h=o.indexOf(":");if(h>0)var l=s.prefix=o.slice(0,h),u=o.slice(h+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),r=Object.create(r)),r[c]=i[c]=a,s.uri=qo.XMLNS,e.startPrefixMapping(c,a))}for(var f=t.length;f--;)s=t[f],s.prefix&&(s.prefix==="xml"&&(s.uri=qo.XML),s.prefix!=="xmlns"&&(s.uri=r[s.prefix]));var h=n.indexOf(":");h>0?(l=t.prefix=n.slice(0,h),u=t.localName=n.slice(h+1)):(l=null,u=t.localName=n);var d=t.uri=r[l||""];if(e.startElement(d,u,n,t),t.closed){if(e.endElement(d,u,n),i)for(l in i)Ar(i,l)&&e.endPrefixMapping(l)}else return t.currentNSMap=r,t.localNSMap=i,!0}function Mf(t,e,r,n,i){var s=Cf(r);if(s||Sf(r)){var o=new RegExp("</"+r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(t),l=a?a.index:-1;if(l<0)return e+1;var u=t.substring(e+1,l);return s&&(u=u.replace(Ui,n)),i.characters(u,0,u.length),l}return e+1}function kf(t,e){for(var r in t)Ar(t,r)&&(e[r]=t[r])}function Go(t,e){var r=e;function n(c){return c=c||0,t.charAt(r+c)}function i(c){c=c||1,r+=c}function s(){for(var c=0;r<t.length;){var f=n();if(f!==" "&&f!==`
3
- `&&f!==" "&&f!=="\r")return c;c++,i()}return-1}function o(){return t.substring(r)}function a(c){return t.substring(r,r+c.length)===c}function l(c){return t.substring(r,r+c.length).toUpperCase()===c.toUpperCase()}function u(c){var f=k.reg("^",c),h=f.exec(o());return h?(i(h[0].length),h[0]):null}return{char:n,getIndex:function(){return r},getMatch:u,getSource:function(){return t},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function Ff(t,e){function r(a,l){var u=k.PI.exec(a.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+a.getIndex()):(a.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+a.getIndex())}var n=t.getSource();if(t.char()==="["){t.skip(1);for(var i=t.getIndex();t.getIndex()<n.length;){if(t.skipBlanks(),t.char()==="]"){var s=n.substring(i,t.getIndex());return t.skip(1),s}var o=null;if(t.char()==="<"&&t.char(1)==="!")switch(t.char(2)){case"E":t.char(3)==="L"?o=t.getMatch(k.elementdecl):t.char(3)==="N"&&(o=t.getMatch(k.EntityDecl));break;case"A":o=t.getMatch(k.AttlistDecl);break;case"N":o=t.getMatch(k.NotationDecl);break;case"-":o=t.getMatch(k.Comment);break}else if(t.char()==="<"&&t.char(1)==="?")o=r(t,e);else if(t.char()==="%")o=t.getMatch(k.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+t.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Xo(t,e,r,n,i){var s=Go(t,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(k.Comment);return o?(r.comment(o,k.COMMENT_START.length,o.length-k.COMMENT_START.length-k.COMMENT_END.length),s.getIndex()):n.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(k.CDSect);return a?!i&&!r.currentElement?n.fatalError("CDATA outside of element"):(r.startCDATA(),r.characters(a,k.CDATA_START.length,a.length-k.CDATA_START.length-k.CDATA_END.length),r.endCDATA(),s.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(r.doc&&r.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(k.DOCTYPE_DECL_START):!s.substringStartsWith(k.DOCTYPE_DECL_START))return n.fatalError("Expected "+k.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(k.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.DOCTYPE_DECL_START+" at position "+s.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=s.getMatch(k.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(k.PUBLIC)||s.substringStartsWith(k.SYSTEM)){var u=k.ExternalID_match.exec(s.substringFromIndex());if(!u)return n.fatalError("doctype external id is not well-formed at position "+s.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),s.skip(u[0].length)}else if(i&&s.substringStartsWithCaseInsensitive(k.SYSTEM)){if(s.skip(k.SYSTEM.length),s.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(k.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+k.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+k.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!k.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=Ff(s,n)),s.skipBlanks(),s.char()!==">"?n.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),r.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),r.endDTD(),s.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Rf(t,e,r,n){var i=t.substring(e).match(k.PI);if(!i)return n.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!k.XMLDecl.test(t.substring(e)))return n.fatalError("xml declaration is not well-formed")}return r.processingInstruction(i[1],i[2]),e+i[0].length}function Yo(){this.attributeNames=Object.create(null)}Yo.prototype={setTagName:function(t){if(!k.QName_exact.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},addValue:function(t,e,r){if(!k.QName_exact.test(t))throw new Error("invalid attribute:"+t);this.attributeNames[t]=this.length,this[this.length++]={qName:t,value:e,offset:r}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}};yn.XMLReader=Ho;yn.parseUtils=Go;yn.parseDoctypeCommentOrCData=Xo});var ra=Ge(Vt=>{"use strict";var pt=ht(),Lf=Pi(),Pf=dr(),Jo=$o(),Uf=Wo(),$f=Lf.DOMImplementation,qf=pt.hasDefaultHTMLNamespace,Vf=pt.isHTMLMimeType,zf=pt.isValidMimeType,Ko=pt.MIME_TYPE,$i=pt.NAMESPACE,Zo=Pf.ParseError,jf=Uf.XMLReader;function ea(t){return t.replace(/\r[\n\u0085]/g,`
4
- `).replace(/[\r\u0085\u2028\u2029]/g,`
5
- `)}function ta(t){if(t=t||{},t.locator===void 0&&(t.locator=!0),this.assign=t.assign||pt.assign,this.domHandler=t.domHandler||En,this.onError=t.onError||t.errorHandler,t.errorHandler&&typeof t.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");t.errorHandler&&t.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=t.normalizeLineEndings||ea,this.locator=!!t.locator,this.xmlns=this.assign(Object.create(null),t.xmlns)}ta.prototype.parseFromString=function(t,e){if(!zf(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var r=this.assign(Object.create(null),this.xmlns),n=Jo.XML_ENTITIES,i=r[""]||null;qf(e)?(n=Jo.HTML_ENTITIES,i=$i.HTML):e===Ko.XML_SVG_IMAGE&&(i=$i.SVG),r[""]=i,r.xml=r.xml||$i.XML;var s=new this.domHandler({mimeType:e,defaultNamespace:i,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&s.setDocumentLocator(o);var a=new jf;a.errorHandler=s,a.domBuilder=s;var l=!pt.isHTMLMimeType(e);return l&&typeof t!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(t)),r,n),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function En(t){var e=t||{};this.mimeType=e.mimeType||Ko.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 qt(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}En.prototype={startDocument:function(){var t=new $f;this.doc=Vf(this.mimeType)?t.createHTMLDocument(!1):t.createDocument(this.defaultNamespace,"")},startElement:function(t,e,r,n){var i=this.doc,s=i.createElementNS(t,r||e),o=n.length;wn(this,s),this.currentElement=s,this.locator&&qt(this.locator,s);for(var a=0;a<o;a++){var t=n.getURI(a),l=n.getValue(a),r=n.getQName(a),u=i.createAttributeNS(t,r);this.locator&&qt(n.getLocator(a),u),u.value=u.nodeValue=l,s.setAttributeNode(u)}},endElement:function(t,e,r){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var r=this.doc.createProcessingInstruction(t,e);this.locator&&qt(this.locator,r),wn(this,r)},ignorableWhitespace:function(t,e,r){},characters:function(t,e,r){if(t=Qo.apply(this,arguments),t){if(this.cdata)var n=this.doc.createCDATASection(t);else var n=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(t)&&this.doc.appendChild(n),this.locator&&qt(this.locator,n)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){t&&(t.lineNumber=0),this.locator=t},comment:function(t,e,r){t=Qo.apply(this,arguments);var n=this.doc.createComment(t);this.locator&&qt(this.locator,n),wn(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,r,n){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(t,e,r,n);this.locator&&qt(this.locator,s),wn(this,s),this.doc.doctype=s}},reportError:function(t,e){if(typeof this.onError=="function")try{this.onError(t,e,this)}catch(r){throw new Zo("Reporting "+t+' "'+e+'" caused '+r,this.locator)}else console.error("[xmldom "+t+"] "+e,Hf(this.locator))},warning:function(t){this.reportError("warning",t)},error:function(t){this.reportError("error",t)},fatalError:function(t,e){throw this.reportError("fatalError",t),new Zo(t,this.locator,e)}};function Hf(t){if(t)return`
6
- @#[line:`+t.lineNumber+",col:"+t.columnNumber+"]"}function Qo(t,e,r){return typeof t=="string"?t.substr(e,r):t.length>=e+r||e?new java.lang.String(t,e,r)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){En.prototype[t]=function(){return null}});function wn(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}function Gf(t){if(t==="error")throw"onErrorStopParsing"}function Xf(){throw"onWarningStopParsing"}Vt.__DOMHandler=En;Vt.DOMParser=ta;Vt.normalizeLineEndings=ea;Vt.onErrorStopParsing=Gf;Vt.onWarningStopParsing=Xf});var qi=Ge(U=>{"use strict";var zt=ht();U.assign=zt.assign;U.hasDefaultHTMLNamespace=zt.hasDefaultHTMLNamespace;U.isHTMLMimeType=zt.isHTMLMimeType;U.isValidMimeType=zt.isValidMimeType;U.MIME_TYPE=zt.MIME_TYPE;U.NAMESPACE=zt.NAMESPACE;var bn=dr();U.DOMException=bn.DOMException;U.DOMExceptionName=bn.DOMExceptionName;U.ExceptionCode=bn.ExceptionCode;U.ParseError=bn.ParseError;var re=Pi();U.Attr=re.Attr;U.CDATASection=re.CDATASection;U.CharacterData=re.CharacterData;U.Comment=re.Comment;U.Document=re.Document;U.DocumentFragment=re.DocumentFragment;U.DocumentType=re.DocumentType;U.DOMImplementation=re.DOMImplementation;U.Element=re.Element;U.Entity=re.Entity;U.EntityReference=re.EntityReference;U.LiveNodeList=re.LiveNodeList;U.NamedNodeMap=re.NamedNodeMap;U.Node=re.Node;U.NodeList=re.NodeList;U.Notation=re.Notation;U.ProcessingInstruction=re.ProcessingInstruction;U.Text=re.Text;U.XMLSerializer=re.XMLSerializer;var Dn=ra();U.DOMParser=Dn.DOMParser;U.normalizeLineEndings=Dn.normalizeLineEndings;U.onErrorStopParsing=Dn.onErrorStopParsing;U.onWarningStopParsing=Dn.onWarningStopParsing});var De={"assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt":new URL("./files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt",import.meta.url),"assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt":new URL("./files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt",import.meta.url),"assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt":new URL("./files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt",import.meta.url),"assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt":new URL("./files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt",import.meta.url),"assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt":new URL("./files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt",import.meta.url)};/*!
7
- * decimal.js v10.6.0
8
- * An arbitrary-precision Decimal type for JavaScript.
9
- * https://github.com/MikeMcl/decimal.js
10
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
11
- * MIT Licence
12
- */var Tt=9e15,Je=1e9,ii="0123456789abcdef",jr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Hr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",si={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Tt,maxE:Tt,crypto:!1},Ts,Ue,B=!0,Xr="[DecimalError] ",We=Xr+"Invalid argument: ",xs=Xr+"Precision limit exceeded",As=Xr+"crypto unavailable",Cs="[object Decimal]",ce=Math.floor,ee=Math.pow,_u=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Su=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Nu=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,_s=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ae=1e7,S=7,Iu=9007199254740991,Ou=jr.length-1,oi=Hr.length-1,D={toStringTag:Cs};D.absoluteValue=D.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),_(t)};D.ceil=function(){return _(new this.constructor(this),this.e+1,2)};D.clampedTo=D.clamp=function(t,e){var r,n=this,i=n.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(We+e);return r=n.cmp(t),r<0?t:n.cmp(e)>0?e:new i(n)};D.comparedTo=D.cmp=function(t){var e,r,n,i,s=this,o=s.d,a=(t=new s.constructor(t)).d,l=s.s,u=t.s;if(!o||!a)return!l||!u?NaN:l!==u?l:o===a?0:!o^l<0?1:-1;if(!o[0]||!a[0])return o[0]?l:a[0]?-u:0;if(l!==u)return l;if(s.e!==t.e)return s.e>t.e^l<0?1:-1;for(n=o.length,i=a.length,e=0,r=n<i?n:i;e<r;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1};D.cosine=D.cos=function(){var t,e,r=this,n=r.constructor;return r.d?r.d[0]?(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+S,n.rounding=1,r=Bu(n,Bs(n,r)),n.precision=t,n.rounding=e,_(Ue==2||Ue==3?r.neg():r,t,e,!0)):new n(1):new n(NaN)};D.cubeRoot=D.cbrt=function(){var t,e,r,n,i,s,o,a,l,u,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(B=!1,s=c.s*ee(c.s*c,1/3),!s||Math.abs(s)==1/0?(r=oe(c.d),t=c.e,(s=(t-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=ee(r,1/3),t=ce((t+1)/3)-(t%3==(t<0?-1:2)),s==1/0?r="5e"+t:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+t),n=new f(r),n.s=c.s):n=new f(s.toString()),o=(t=f.precision)+3;;)if(a=n,l=a.times(a).times(a),u=l.plus(c),n=H(u.plus(c).times(a),u.plus(l),o+2,1),oe(a.d).slice(0,o)===(r=oe(n.d)).slice(0,o))if(r=r.slice(o-3,o+1),r=="9999"||!i&&r=="4999"){if(!i&&(_(a,t+1,0),a.times(a).times(a).eq(c))){n=a;break}o+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(_(n,t+1,1),e=!n.times(n).times(n).eq(c));break}return B=!0,_(n,t,f.rounding,e)};D.decimalPlaces=D.dp=function(){var t,e=this.d,r=NaN;if(e){if(t=e.length-1,r=(t-ce(this.e/S))*S,t=e[t],t)for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r};D.dividedBy=D.div=function(t){return H(this,new this.constructor(t))};D.dividedToIntegerBy=D.divToInt=function(t){var e=this,r=e.constructor;return _(H(e,new r(t),0,1,1),r.precision,r.rounding)};D.equals=D.eq=function(t){return this.cmp(t)===0};D.floor=function(){return _(new this.constructor(this),this.e+1,3)};D.greaterThan=D.gt=function(t){return this.cmp(t)>0};D.greaterThanOrEqualTo=D.gte=function(t){var e=this.cmp(t);return e==1||e===0};D.hyperbolicCosine=D.cosh=function(){var t,e,r,n,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;r=o.precision,n=o.rounding,o.precision=r+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(t=Math.ceil(i/3),e=(1/Wr(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),s=xt(o,1,s.times(e),new o(1),!0);for(var l,u=t,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return _(s,o.precision=r,o.rounding=n,!0)};D.hyperbolicSine=D.sinh=function(){var t,e,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,r=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<3)i=xt(s,2,i,i,!0);else{t=1.4*Math.sqrt(n),t=t>16?16:t|0,i=i.times(1/Wr(5,t)),i=xt(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);t--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=r,_(i,e,r,!0)};D.hyperbolicTangent=D.tanh=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+7,n.rounding=1,H(r.sinh(),r.cosh(),n.precision=t,n.rounding=e)):new n(r.s)};D.inverseCosine=D.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Ie(e,n,i):new e(0):new e(NaN):t.isZero()?Ie(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=n,e.rounding=i,t.times(2))};D.inverseHyperbolicCosine=D.acosh=function(){var t,e,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(t=n.precision,e=n.rounding,n.precision=t+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,B=!1,r=r.times(r).minus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln()):new n(r)};D.inverseHyperbolicSine=D.asinh=function(){var t,e,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,B=!1,r=r.times(r).plus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln())};D.inverseHyperbolicTangent=D.atanh=function(){var t,e,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=s.precision,e=s.rounding,n=i.sd(),Math.max(n,t)<2*-i.e-1?_(new s(i),t,e,!0):(s.precision=r=n-i.e,i=H(i.plus(1),new s(1).minus(i),r+t,1),s.precision=t+4,s.rounding=1,i=i.ln(),s.precision=t,s.rounding=e,i.times(.5))):new s(NaN)};D.inverseSine=D.asin=function(){var t,e,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),r=s.precision,n=s.rounding,e!==-1?e===0?(t=Ie(s,r+4,n).times(.5),t.s=i.s,t):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))};D.inverseTangent=D.atan=function(){var t,e,r,n,i,s,o,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&f+4<=oi)return o=Ie(c,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(f+4<=oi)return o=Ie(c,f+4,h).times(.5),o.s=u.s,o}for(c.precision=a=f+10,c.rounding=1,r=Math.min(28,a/S+2|0),t=r;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,e=Math.ceil(a/S),n=1,l=u.times(u),o=new c(u),i=u;t!==-1;)if(i=i.times(l),s=o.minus(i.div(n+=2)),i=i.times(l),o=s.plus(i.div(n+=2)),o.d[e]!==void 0)for(t=e;o.d[t]===s.d[t]&&t--;);return r&&(o=o.times(2<<r-1)),B=!0,_(o,c.precision=f,c.rounding=h,!0)};D.isFinite=function(){return!!this.d};D.isInteger=D.isInt=function(){return!!this.d&&ce(this.e/S)>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(t){return this.cmp(t)<0};D.lessThanOrEqualTo=D.lte=function(t){return this.cmp(t)<1};D.logarithm=D.log=function(t){var e,r,n,i,s,o,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding,d=5;if(t==null)t=new c(10),e=!0;else{if(t=new c(t),r=t.d,t.s<0||!r||!r[0]||t.eq(1))return new c(NaN);e=t.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new c(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(e)if(r.length>1)s=!0;else{for(i=r[0];i%10===0;)i/=10;s=i!==1}if(B=!1,a=f+d,o=Ye(u,a),n=e?Gr(c,a+10):Ye(t,a),l=H(o,n,a,1),er(l.d,i=f,h))do if(a+=10,o=Ye(u,a),n=e?Gr(c,a+10):Ye(t,a),l=H(o,n,a,1),!s){+oe(l.d).slice(i+1,i+15)+1==1e14&&(l=_(l,f+1,0));break}while(er(l.d,i+=10,h));return B=!0,_(l,f,h)};D.minus=D.sub=function(t){var e,r,n,i,s,o,a,l,u,c,f,h,d=this,p=d.constructor;if(t=new p(t),!d.d||!t.d)return!d.s||!t.s?t=new p(NaN):d.d?t.s=-t.s:t=new p(t.d||d.s!==t.s?d:NaN),t;if(d.s!=t.s)return t.s=-t.s,d.plus(t);if(u=d.d,h=t.d,a=p.precision,l=p.rounding,!u[0]||!h[0]){if(h[0])t.s=-t.s;else if(u[0])t=new p(d);else return new p(l===3?-0:0);return B?_(t,a,l):t}if(r=ce(t.e/S),c=ce(d.e/S),u=u.slice(),s=c-r,s){for(f=s<0,f?(e=u,s=-s,o=h.length):(e=h,r=c,o=u.length),n=Math.max(Math.ceil(a/S),o)+2,s>n&&(s=n,e.length=1),e.reverse(),n=s;n--;)e.push(0);e.reverse()}else{for(n=u.length,o=h.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(u[n]!=h[n]){f=u[n]<h[n];break}s=0}for(f&&(e=u,u=h,h=e,t.s=-t.s),o=u.length,n=h.length-o;n>0;--n)u[o++]=0;for(n=h.length;n>s;){if(u[--n]<h[n]){for(i=n;i&&u[--i]===0;)u[i]=Ae-1;--u[i],u[n]+=Ae}u[n]-=h[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(t.d=u,t.e=Yr(u,r),B?_(t,a,l):t):new p(l===3?-0:0)};D.modulo=D.mod=function(t){var e,r=this,n=r.constructor;return t=new n(t),!r.d||!t.s||t.d&&!t.d[0]?new n(NaN):!t.d||r.d&&!r.d[0]?_(new n(r),n.precision,n.rounding):(B=!1,n.modulo==9?(e=H(r,t.abs(),0,3,1),e.s*=t.s):e=H(r,t,0,n.modulo,1),e=e.times(t),B=!0,r.minus(e))};D.naturalExponential=D.exp=function(){return ai(this)};D.naturalLogarithm=D.ln=function(){return Ye(this)};D.negated=D.neg=function(){var t=new this.constructor(this);return t.s=-t.s,_(t)};D.plus=D.add=function(t){var e,r,n,i,s,o,a,l,u,c,f=this,h=f.constructor;if(t=new h(t),!f.d||!t.d)return!f.s||!t.s?t=new h(NaN):f.d||(t=new h(t.d||f.s===t.s?f:NaN)),t;if(f.s!=t.s)return t.s=-t.s,f.minus(t);if(u=f.d,c=t.d,a=h.precision,l=h.rounding,!u[0]||!c[0])return c[0]||(t=new h(f)),B?_(t,a,l):t;if(s=ce(f.e/S),n=ce(t.e/S),u=u.slice(),i=s-n,i){for(i<0?(r=u,i=-i,o=c.length):(r=c,n=s,o=u.length),s=Math.ceil(a/S),o=s>o?s+1:o+1,i>o&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,r=c,c=u,u=r),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/Ae|0,u[i]%=Ae;for(e&&(u.unshift(e),++n),o=u.length;u[--o]==0;)u.pop();return t.d=u,t.e=Yr(u,n),B?_(t,a,l):t};D.precision=D.sd=function(t){var e,r=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(We+t);return r.d?(e=Ss(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e};D.round=function(){var t=this,e=t.constructor;return _(new e(t),t.e+1,e.rounding)};D.sine=D.sin=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+S,n.rounding=1,r=ku(n,Bs(n,r)),n.precision=t,n.rounding=e,_(Ue>2?r.neg():r,t,e,!0)):new n(NaN)};D.squareRoot=D.sqrt=function(){var t,e,r,n,i,s,o=this,a=o.d,l=o.e,u=o.s,c=o.constructor;if(u!==1||!a||!a[0])return new c(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(B=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=oe(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ce((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new c(e)):n=new c(u.toString()),r=(l=c.precision)+3;;)if(s=n,n=s.plus(H(o,s,r+2,1)).times(.5),oe(s.d).slice(0,r)===(e=oe(n.d)).slice(0,r))if(e=e.slice(r-3,r+1),e=="9999"||!i&&e=="4999"){if(!i&&(_(s,l+1,0),s.times(s).eq(o))){n=s;break}r+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(_(n,l+1,1),t=!n.times(n).eq(o));break}return B=!0,_(n,l,c.rounding,t)};D.tangent=D.tan=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+10,n.rounding=1,r=r.sin(),r.s=1,r=H(r,new n(1).minus(r.times(r)).sqrt(),t+10,0),n.precision=t,n.rounding=e,_(Ue==2||Ue==4?r.neg():r,t,e,!0)):new n(NaN)};D.times=D.mul=function(t){var e,r,n,i,s,o,a,l,u,c=this,f=c.constructor,h=c.d,d=(t=new f(t)).d;if(t.s*=c.s,!h||!h[0]||!d||!d[0])return new f(!t.s||h&&!h[0]&&!d||d&&!d[0]&&!h?NaN:!h||!d?t.s/0:t.s*0);for(r=ce(c.e/S)+ce(t.e/S),l=h.length,u=d.length,l<u&&(s=h,h=d,d=s,o=l,l=u,u=o),s=[],o=l+u,n=o;n--;)s.push(0);for(n=u;--n>=0;){for(e=0,i=l+n;i>n;)a=s[i]+d[n]*h[i-n-1]+e,s[i--]=a%Ae|0,e=a/Ae|0;s[i]=(s[i]+e)%Ae|0}for(;!s[--o];)s.pop();return e?++r:s.shift(),t.d=s,t.e=Yr(s,r),B?_(t,f.precision,f.rounding):t};D.toBinary=function(t,e){return ui(this,2,t,e)};D.toDecimalPlaces=D.toDP=function(t,e){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(pe(t,0,Je),e===void 0?e=n.rounding:pe(e,0,8),_(r,t+r.e+1,e))};D.toExponential=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Oe(n,!0):(pe(t,0,Je),e===void 0?e=i.rounding:pe(e,0,8),n=_(new i(n),t+1,e),r=Oe(n,!0,t+1)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toFixed=function(t,e){var r,n,i=this,s=i.constructor;return t===void 0?r=Oe(i):(pe(t,0,Je),e===void 0?e=s.rounding:pe(e,0,8),n=_(new s(i),t+i.e+1,e),r=Oe(n,!1,t+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};D.toFraction=function(t){var e,r,n,i,s,o,a,l,u,c,f,h,d=this,p=d.d,m=d.constructor;if(!p)return new m(d);if(u=r=new m(1),n=l=new m(0),e=new m(n),s=e.e=Ss(p)-d.e-1,o=s%S,e.d[0]=ee(10,o<0?S+o:o),t==null)t=s>0?e:u;else{if(a=new m(t),!a.isInt()||a.lt(u))throw Error(We+a);t=a.gt(e)?s>0?e:u:a}for(B=!1,a=new m(oe(p)),c=m.precision,m.precision=s=p.length*S*2;f=H(a,e,0,1,1),i=r.plus(f.times(n)),i.cmp(t)!=1;)r=n,n=i,i=u,u=l.plus(f.times(i)),l=i,i=e,e=a.minus(f.times(i)),a=i;return i=H(t.minus(r),n,0,1,1),l=l.plus(i.times(u)),r=r.plus(i.times(n)),l.s=u.s=d.s,h=H(u,n,s,1).minus(d).abs().cmp(H(l,r,s,1).minus(d).abs())<1?[u,n]:[l,r],m.precision=c,B=!0,h};D.toHexadecimal=D.toHex=function(t,e){return ui(this,16,t,e)};D.toNearest=function(t,e){var r=this,n=r.constructor;if(r=new n(r),t==null){if(!r.d)return r;t=new n(1),e=n.rounding}else{if(t=new n(t),e===void 0?e=n.rounding:pe(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(B=!1,r=H(r,t,0,e,1).times(t),B=!0,_(r)):(t.s=r.s,r=t),r};D.toNumber=function(){return+this};D.toOctal=function(t,e){return ui(this,8,t,e)};D.toPower=D.pow=function(t){var e,r,n,i,s,o,a=this,l=a.constructor,u=+(t=new l(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new l(ee(+a,u));if(a=new l(a),a.eq(1))return a;if(n=l.precision,s=l.rounding,t.eq(1))return _(a,n,s);if(e=ce(t.e/S),e>=t.d.length-1&&(r=u<0?-u:u)<=Iu)return i=Ns(l,a,r,n),t.s<0?new l(1).div(i):_(i,n,s);if(o=a.s,o<0){if(e<t.d.length-1)return new l(NaN);if((t.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return r=ee(+a,u),e=r==0||!isFinite(r)?ce(u*(Math.log("0."+oe(a.d))/Math.LN10+a.e+1)):new l(r+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(B=!1,l.rounding=a.s=1,r=Math.min(12,(e+"").length),i=ai(t.times(Ye(a,n+r)),n),i.d&&(i=_(i,n+5,1),er(i.d,n,s)&&(e=n+10,i=_(ai(t.times(Ye(a,e+r)),e),e+5,1),+oe(i.d).slice(n+1,n+15)+1==1e14&&(i=_(i,n+1,0)))),i.s=o,B=!0,l.rounding=s,_(i,n,s))};D.toPrecision=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Oe(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(pe(t,1,Je),e===void 0?e=i.rounding:pe(e,0,8),n=_(new i(n),t,e),r=Oe(n,t<=n.e||n.e<=i.toExpNeg,t)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toSignificantDigits=D.toSD=function(t,e){var r=this,n=r.constructor;return t===void 0?(t=n.precision,e=n.rounding):(pe(t,1,Je),e===void 0?e=n.rounding:pe(e,0,8)),_(new n(r),t,e)};D.toString=function(){var t=this,e=t.constructor,r=Oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r};D.truncated=D.trunc=function(){return _(new this.constructor(this),this.e+1,1)};D.valueOf=D.toJSON=function(){var t=this,e=t.constructor,r=Oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};function oe(t){var e,r,n,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)n=t[e]+"",r=S-n.length,r&&(s+=Xe(r)),s+=n;o=t[e],n=o+"",r=S-n.length,r&&(s+=Xe(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function pe(t,e,r){if(t!==~~t||t<e||t>r)throw Error(We+t)}function er(t,e,r,n){var i,s,o,a;for(s=t[0];s>=10;s/=10)--e;return--e<0?(e+=S,i=0):(i=Math.ceil((e+1)/S),e%=S),s=ee(10,S-e),a=t[i]%s|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),o=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):o=(r<4&&a+1==s||r>3&&a+1==s/2)&&(t[i+1]/s/100|0)==ee(10,e-2)-1||(a==s/2||a==0)&&(t[i+1]/s/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(n||r<4)&&a==9999||!n&&r>3&&a==4999):o=((n||r<4)&&a+1==s||!n&&r>3&&a+1==s/2)&&(t[i+1]/s/1e3|0)==ee(10,e-3)-1,o}function Vr(t,e,r){for(var n,i=[0],s,o=0,a=t.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=ii.indexOf(t.charAt(o++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function Bu(t,e){var r,n,i;if(e.isZero())return e;n=e.d.length,n<32?(r=Math.ceil(n/3),i=(1/Wr(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=xt(t,1,e.times(i),new t(1));for(var s=r;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return t.precision-=r,e}var H=(function(){function t(n,i,s){var o,a=0,l=n.length;for(n=n.slice();l--;)o=n[l]*i+a,n[l]=o%s|0,a=o/s|0;return a&&n.unshift(a),n}function e(n,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(n[a]!=i[a]){l=n[a]>i[a]?1:-1;break}return l}function r(n,i,s,o){for(var a=0;s--;)n[s]-=a,a=n[s]<i[s]?1:0,n[s]=a*o+n[s]-i[s];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,s,o,a,l){var u,c,f,h,d,p,m,g,y,E,w,v,x,T,b,C,I,O,L,$,se=n.constructor,V=n.s==i.s?1:-1,Q=n.d,F=i.d;if(!Q||!Q[0]||!F||!F[0])return new se(!n.s||!i.s||(Q?F&&Q[0]==F[0]:!F)?NaN:Q&&Q[0]==0||!F?V*0:V/0);for(l?(d=1,c=n.e-i.e):(l=Ae,d=S,c=ce(n.e/d)-ce(i.e/d)),L=F.length,I=Q.length,y=new se(V),E=y.d=[],f=0;F[f]==(Q[f]||0);f++);if(F[f]>(Q[f]||0)&&c--,s==null?(T=s=se.precision,o=se.rounding):a?T=s+(n.e-i.e)+1:T=s,T<0)E.push(1),p=!0;else{if(T=T/d+2|0,f=0,L==1){for(h=0,F=F[0],T++;(f<I||h)&&T--;f++)b=h*l+(Q[f]||0),E[f]=b/F|0,h=b%F|0;p=h||f<I}else{for(h=l/(F[0]+1)|0,h>1&&(F=t(F,h,l),Q=t(Q,h,l),L=F.length,I=Q.length),C=L,w=Q.slice(0,L),v=w.length;v<L;)w[v++]=0;$=F.slice(),$.unshift(0),O=F[0],F[1]>=l/2&&++O;do h=0,u=e(F,w,L,v),u<0?(x=w[0],L!=v&&(x=x*l+(w[1]||0)),h=x/O|0,h>1?(h>=l&&(h=l-1),m=t(F,h,l),g=m.length,v=w.length,u=e(m,w,g,v),u==1&&(h--,r(m,L<g?$:F,g,l))):(h==0&&(u=h=1),m=F.slice()),g=m.length,g<v&&m.unshift(0),r(w,m,v,l),u==-1&&(v=w.length,u=e(F,w,L,v),u<1&&(h++,r(w,L<v?$:F,v,l))),v=w.length):u===0&&(h++,w=[0]),E[f++]=h,u&&w[0]?w[v++]=Q[C]||0:(w=[Q[C]],v=1);while((C++<I||w[0]!==void 0)&&T--);p=w[0]!==void 0}E[0]||E.shift()}if(d==1)y.e=c,Ts=p;else{for(f=1,h=E[0];h>=10;h/=10)f++;y.e=f+c*d-1,_(y,a?s+y.e+1:s,o,p)}return y}})();function _(t,e,r,n){var i,s,o,a,l,u,c,f,h,d=t.constructor;e:if(e!=null){if(f=t.d,!f)return t;for(i=1,a=f[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=S,o=e,c=f[h=0],l=c/ee(10,i-o-1)%10|0;else if(h=Math.ceil((s+1)/S),a=f.length,h>=a)if(n){for(;a++<=h;)f.push(0);c=l=0,i=1,s%=S,o=s-S+1}else break e;else{for(c=a=f[h],i=1;a>=10;a/=10)i++;s%=S,o=s-S+i,l=o<0?0:c/ee(10,i-o-1)%10|0}if(n=n||e<0||f[h+1]!==void 0||(o<0?c:c%ee(10,i-o-1)),u=r<4?(l||n)&&(r==0||r==(t.s<0?3:2)):l>5||l==5&&(r==4||n||r==6&&(s>0?o>0?c/ee(10,i-o):0:f[h-1])%10&1||r==(t.s<0?8:7)),e<1||!f[0])return f.length=0,u?(e-=t.e+1,f[0]=ee(10,(S-e%S)%S),t.e=-e||0):f[0]=t.e=0,t;if(s==0?(f.length=h,a=1,h--):(f.length=h+1,a=ee(10,S-s),f[h]=o>0?(c/ee(10,i-o)%ee(10,o)|0)*a:0),u)for(;;)if(h==0){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(t.e++,f[0]==Ae&&(f[0]=1));break}else{if(f[h]+=a,f[h]!=Ae)break;f[h--]=0,a=1}for(s=f.length;f[--s]===0;)f.pop()}return B&&(t.e>d.maxE?(t.d=null,t.e=NaN):t.e<d.minE&&(t.e=0,t.d=[0])),t}function Oe(t,e,r){if(!t.isFinite())return Os(t);var n,i=t.e,s=oe(t.d),o=s.length;return e?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+Xe(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(t.e<0?"e":"e+")+t.e):i<0?(s="0."+Xe(-i-1)+s,r&&(n=r-o)>0&&(s+=Xe(n))):i>=o?(s+=Xe(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+Xe(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=Xe(n))),s}function Yr(t,e){var r=t[0];for(e*=S;r>=10;r/=10)e++;return e}function Gr(t,e,r){if(e>Ou)throw B=!0,r&&(t.precision=r),Error(xs);return _(new t(jr),e,1,!0)}function Ie(t,e,r){if(e>oi)throw Error(xs);return _(new t(Hr),e,r,!0)}function Ss(t){var e=t.length-1,r=e*S+1;if(e=t[e],e){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function Xe(t){for(var e="";t--;)e+="0";return e}function Ns(t,e,r,n){var i,s=new t(1),o=Math.ceil(n/S+4);for(B=!1;;){if(r%2&&(s=s.times(e),Ds(s.d,o)&&(i=!0)),r=ce(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}e=e.times(e),Ds(e.d,o)}return B=!0,s}function bs(t){return t.d[t.d.length-1]&1}function Is(t,e,r){for(var n,i,s=new t(e[0]),o=0;++o<e.length;){if(i=new t(e[o]),!i.s){s=i;break}n=s.cmp(i),(n===r||n===0&&s.s===r)&&(s=i)}return s}function ai(t,e){var r,n,i,s,o,a,l,u=0,c=0,f=0,h=t.constructor,d=h.rounding,p=h.precision;if(!t.d||!t.d[0]||t.e>17)return new h(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(e==null?(B=!1,l=p):l=e,a=new h(.03125);t.e>-2;)t=t.times(a),f+=5;for(n=Math.log(ee(2,f))/Math.LN10*2+5|0,l+=n,r=s=o=new h(1),h.precision=l;;){if(s=_(s.times(t),l,1),r=r.times(++c),a=o.plus(H(s,r,l,1)),oe(a.d).slice(0,l)===oe(o.d).slice(0,l)){for(i=f;i--;)o=_(o.times(o),l,1);if(e==null)if(u<3&&er(o.d,l-n,d,u))h.precision=l+=10,r=s=a=new h(1),c=0,u++;else return _(o,h.precision=p,d,B=!0);else return h.precision=p,o}o=a}}function Ye(t,e){var r,n,i,s,o,a,l,u,c,f,h,d=1,p=10,m=t,g=m.d,y=m.constructor,E=y.rounding,w=y.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(B=!1,c=w):c=e,y.precision=c+=p,r=oe(g),n=r.charAt(0),Math.abs(s=m.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)m=m.times(t),r=oe(m.d),n=r.charAt(0),d++;s=m.e,n>1?(m=new y("0."+r),s++):m=new y(n+"."+r.slice(1))}else return u=Gr(y,c+2,w).times(s+""),m=Ye(new y(n+"."+r.slice(1)),c-p).plus(u),y.precision=w,e==null?_(m,w,E,B=!0):m;for(f=m,l=o=m=H(m.minus(1),m.plus(1),c,1),h=_(m.times(m),c,1),i=3;;){if(o=_(o.times(h),c,1),u=l.plus(H(o,new y(i),c,1)),oe(u.d).slice(0,c)===oe(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(Gr(y,c+2,w).times(s+""))),l=H(l,new y(d),c,1),e==null)if(er(l.d,c-p,E,a))y.precision=c+=p,u=o=m=H(f.minus(1),f.plus(1),c,1),h=_(m.times(m),c,1),i=a=1;else return _(l,y.precision=w,E,B=!0);else return y.precision=w,l;l=u,i+=2}}function Os(t){return String(t.s*t.s/0)}function zr(t,e){var r,n,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;e.charCodeAt(n)===48;n++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,t.e=r=r-n-1,t.d=[],n=(r+1)%S,r<0&&(n+=S),n<i){for(n&&t.d.push(+e.slice(0,n)),i-=S;n<i;)t.d.push(+e.slice(n,n+=S));e=e.slice(n),n=S-e.length}else n-=i;for(;n--;)e+="0";t.d.push(+e),B&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Mu(t,e){var r,n,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),_s.test(e))return zr(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(Su.test(e))r=16,e=e.toLowerCase();else if(_u.test(e))r=2;else if(Nu.test(e))r=8;else throw Error(We+e);for(s=e.search(/p/i),s>0?(l=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),s=e.indexOf("."),o=s>=0,n=t.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Ns(n,new n(r),s,s*2)),u=Vr(e,r,Ae),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new n(t.s*0):(t.e=Yr(u,c),t.d=u,B=!1,o&&(t=H(t,i,a*4)),l&&(t=t.times(Math.abs(l)<54?ee(2,l):tr.pow(2,l))),B=!0,t)}function ku(t,e){var r,n=e.d.length;if(n<3)return e.isZero()?e:xt(t,2,e,e);r=1.4*Math.sqrt(n),r=r>16?16:r|0,e=e.times(1/Wr(5,r)),e=xt(t,2,e,e);for(var i,s=new t(5),o=new t(16),a=new t(20);r--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function xt(t,e,r,n,i){var s,o,a,l,u=1,c=t.precision,f=Math.ceil(c/S);for(B=!1,l=r.times(r),a=new t(n);;){if(o=H(a.times(l),new t(e++*e++),c,1),a=i?n.plus(o):n.minus(o),n=H(o.times(l),new t(e++*e++),c,1),o=a.plus(n),o.d[f]!==void 0){for(s=f;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=n,n=o,o=s,u++}return B=!0,o.d.length=f+1,o}function Wr(t,e){for(var r=t;--e;)r*=t;return r}function Bs(t,e){var r,n=e.s<0,i=Ie(t,t.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return Ue=n?4:1,e;if(r=e.divToInt(i),r.isZero())Ue=n?3:2;else{if(e=e.minus(r.times(i)),e.lte(s))return Ue=bs(r)?n?2:3:n?4:1,e;Ue=bs(r)?n?1:4:n?3:2}return e.minus(i).abs()}function ui(t,e,r,n){var i,s,o,a,l,u,c,f,h,d=t.constructor,p=r!==void 0;if(p?(pe(r,1,Je),n===void 0?n=d.rounding:pe(n,0,8)):(r=d.precision,n=d.rounding),!t.isFinite())c=Os(t);else{for(c=Oe(t),o=c.indexOf("."),p?(i=2,e==16?r=r*4-3:e==8&&(r=r*3-2)):i=e,o>=0&&(c=c.replace(".",""),h=new d(1),h.e=c.length-o,h.d=Vr(Oe(h),10,i),h.e=h.d.length),f=Vr(c,10,i),s=l=f.length;f[--l]==0;)f.pop();if(!f[0])c=p?"0p+0":"0";else{if(o<0?s--:(t=new d(t),t.d=f,t.e=s,t=H(t,h,r,n,0,i),f=t.d,s=t.e,u=Ts),o=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(t.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&f[r-1]&1||n===(t.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++s,f.unshift(1));for(l=f.length;!f[l-1];--l);for(o=0,c="";o<l;o++)c+=ii.charAt(f[o]);if(p){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(f=Vr(c,i,e),l=f.length;!f[l-1];--l);for(o=1,c="1.";o<l;o++)c+=ii.charAt(f[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)c="0"+c;c="0."+c}else if(++s>l)for(s-=l;s--;)c+="0";else s<l&&(c=c.slice(0,s)+"."+c.slice(s))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return t.s<0?"-"+c:c}function Ds(t,e){if(t.length>e)return t.length=e,!0}function Fu(t){return new this(t).abs()}function Ru(t){return new this(t).acos()}function Lu(t){return new this(t).acosh()}function Pu(t,e){return new this(t).plus(e)}function Uu(t){return new this(t).asin()}function $u(t){return new this(t).asinh()}function qu(t){return new this(t).atan()}function Vu(t){return new this(t).atanh()}function zu(t,e){t=new this(t),e=new this(e);var r,n=this.precision,i=this.rounding,s=n+4;return!t.s||!e.s?r=new this(NaN):!t.d&&!e.d?(r=Ie(this,s,1).times(e.s>0?.25:.75),r.s=t.s):!e.d||t.isZero()?(r=e.s<0?Ie(this,n,i):new this(0),r.s=t.s):!t.d||e.isZero()?(r=Ie(this,s,1).times(.5),r.s=t.s):e.s<0?(this.precision=s,this.rounding=1,r=this.atan(H(t,e,s,1)),e=Ie(this,s,1),this.precision=n,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(H(t,e,s,1)),r}function ju(t){return new this(t).cbrt()}function Hu(t){return _(t=new this(t),t.e+1,2)}function Gu(t,e,r){return new this(t).clamp(e,r)}function Xu(t){if(!t||typeof t!="object")throw Error(Xr+"Object expected");var e,r,n,i=t.defaults===!0,s=["precision",1,Je,"rounding",0,8,"toExpNeg",-Tt,0,"toExpPos",0,Tt,"maxE",0,Tt,"minE",-Tt,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(r=s[e],i&&(this[r]=si[r]),(n=t[r])!==void 0)if(ce(n)===n&&n>=s[e+1]&&n<=s[e+2])this[r]=n;else throw Error(We+r+": "+n);if(r="crypto",i&&(this[r]=si[r]),(n=t[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(As);else this[r]=!1;else throw Error(We+r+": "+n);return this}function Yu(t){return new this(t).cos()}function Wu(t){return new this(t).cosh()}function Ms(t){var e,r,n;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,vs(s)){u.s=s.s,B?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;B?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return zr(u,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),_s.test(s)?zr(u,s):Mu(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,zr(u,s.toString());throw Error(We+s)}if(i.prototype=D,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Xu,i.clone=Ms,i.isDecimal=vs,i.abs=Fu,i.acos=Ru,i.acosh=Lu,i.add=Pu,i.asin=Uu,i.asinh=$u,i.atan=qu,i.atanh=Vu,i.atan2=zu,i.cbrt=ju,i.ceil=Hu,i.clamp=Gu,i.cos=Yu,i.cosh=Wu,i.div=Ju,i.exp=Zu,i.floor=Qu,i.hypot=Ku,i.ln=el,i.log=tl,i.log10=nl,i.log2=rl,i.max=il,i.min=sl,i.mod=ol,i.mul=al,i.pow=ul,i.random=ll,i.round=cl,i.sign=fl,i.sin=hl,i.sinh=dl,i.sqrt=pl,i.sub=ml,i.sum=gl,i.tan=yl,i.tanh=wl,i.trunc=El,t===void 0&&(t={}),t&&t.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)t.hasOwnProperty(r=n[e++])||(t[r]=this[r]);return i.config(t),i}function Ju(t,e){return new this(t).div(e)}function Zu(t){return new this(t).exp()}function Qu(t){return _(t=new this(t),t.e+1,3)}function Ku(){var t,e,r=new this(0);for(B=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return B=!0,new this(1/0);r=e}return B=!0,r.sqrt()}function vs(t){return t instanceof tr||t&&t.toStringTag===Cs||!1}function el(t){return new this(t).ln()}function tl(t,e){return new this(t).log(e)}function rl(t){return new this(t).log(2)}function nl(t){return new this(t).log(10)}function il(){return Is(this,arguments,-1)}function sl(){return Is(this,arguments,1)}function ol(t,e){return new this(t).mod(e)}function al(t,e){return new this(t).mul(e)}function ul(t,e){return new this(t).pow(e)}function ll(t){var e,r,n,i,s=0,o=new this(1),a=[];if(t===void 0?t=this.precision:pe(t,1,Je),n=Math.ceil(t/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));s<n;)i=e[s],i>=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);s<n;)i=e[s]+(e[s+1]<<8)+(e[s+2]<<16)+((e[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,s):(a.push(i%1e7),s+=4);s=n/4}else throw Error(As);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],t%=S,n&&t&&(i=ee(10,S-t),a[s]=(n/i|0)*i);a[s]===0;s--)a.pop();if(s<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=S)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<S&&(r-=S-n)}return o.e=r,o.d=a,o}function cl(t){return _(t=new this(t),t.e+1,this.rounding)}function fl(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function hl(t){return new this(t).sin()}function dl(t){return new this(t).sinh()}function pl(t){return new this(t).sqrt()}function ml(t,e){return new this(t).sub(e)}function gl(){var t=0,e=arguments,r=new this(e[t]);for(B=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return B=!0,_(r,this.precision,this.rounding)}function yl(t){return new this(t).tan()}function wl(t){return new this(t).tanh()}function El(t){return _(t=new this(t),t.e+1,1)}D[Symbol.for("nodejs.util.inspect.custom")]=D.toString;D[Symbol.toStringTag]="Decimal";var tr=D.constructor=Ms(si);jr=new tr(jr);Hr=new tr(Hr);var ks=tr;var bl=20,Dl=1,at=1e6,Fs=1e6,vl=-7,Tl=21,xl=!1,rr="[big.js] ",ut=rr+"Invalid ",Jr=ut+"decimal places",Al=ut+"rounding mode",Rs=rr+"Division by zero",z={},Be=void 0,Cl=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Ls(){function t(e){var r=this;if(!(r instanceof t))return e===Be?Ls():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(ut+"value");e=e===0&&1/e<0?"-0":String(e)}_l(r,e)}r.constructor=t}return t.prototype=z,t.DP=bl,t.RM=Dl,t.NE=vl,t.PE=Tl,t.strict=xl,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function _l(t,e){var r,n,i;if(!Cl.test(e))throw Error(ut+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function lt(t,e,r,n){var i=t.c;if(r===Be&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(Al);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==Be))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==Be||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function ct(t,e,r){var n=t.e,i=t.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>s)for(n-=s;n--;)i+="0";else n<s&&(i=i.slice(0,n)+"."+i.slice(n));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}z.abs=function(){var t=new this.constructor(this);return t.s=1,t};z.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,l=t.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=n.length)<(l=i.length)?a:l,s=-1;++s<o;)if(n[s]!=i[s])return n[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};z.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,s=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>at)throw Error(Jr);if(!i[0])throw Error(Rs);if(!n[0])return t.s=s,t.c=[t.e=0],t;var a,l,u,c,f,h=i.slice(),d=a=i.length,p=n.length,m=n.slice(0,a),g=m.length,y=t,E=y.c=[],w=0,v=o+(y.e=e.e-t.e)+1;for(y.s=s,s=v<0?0:v,h.unshift(0);g++<a;)m.push(0);do{for(u=0;u<10;u++){if(a!=(g=m.length))c=a>g?1:-1;else for(f=-1,c=0;++f<a;)if(i[f]!=m[f]){c=i[f]>m[f]?1:-1;break}if(c<0){for(l=g==a?i:h;g;){if(m[--g]<l[g]){for(f=g;f&&!m[--f];)m[f]=9;--m[f],m[g]+=10}m[g]-=l[g]}for(;!m[0];)m.shift()}else break}E[w++]=c?u:++u,m[0]&&c?m[g]=n[d]||0:m=[n[d]]}while((d++<p||m[0]!==Be)&&s--);return!E[0]&&w!=1&&(E.shift(),y.e--,v--),w>v&&lt(y,v,r.RM,m[0]!==Be),y};z.eq=function(t){return this.cmp(t)===0};z.gt=function(t){return this.cmp(t)>0};z.gte=function(t){return this.cmp(t)>-1};z.lt=function(t){return this.cmp(t)<0};z.lte=function(t){return this.cmp(t)<1};z.minus=z.sub=function(t){var e,r,n,i,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);var u=s.c.slice(),c=s.e,f=t.c,h=t.e;if(!u[0]||!f[0])return f[0]?t.s=-l:u[0]?t=new o(s):t.s=1,t;if(a=c-h){for((i=a<0)?(a=-a,n=u):(h=c,n=f),n.reverse(),l=a;l--;)n.push(0);n.reverse()}else for(r=((i=u.length<f.length)?u:f).length,a=l=0;l<r;l++)if(u[l]!=f[l]){i=u[l]<f[l];break}if(i&&(n=u,u=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;r>a;){if(u[--r]<f[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=f[r]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--h;return u[0]||(t.s=1,u=[h=0]),t.c=u,t.e=h,t};z.mod=function(t){var e,r=this,n=r.constructor,i=r.s,s=(t=new n(t)).s;if(!t.c[0])throw Error(Rs);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=s,e?new n(r):(i=n.DP,s=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=s,this.minus(r.times(t)))};z.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};z.plus=z.add=function(t){var e,r,n,i=this,s=i.constructor;if(t=new s(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,l=t.e,u=t.c;if(!a[0]||!u[0])return u[0]||(a[0]?t=new s(i):t.s=i.s),t;if(a=a.slice(),e=o-l){for(e>0?(l=o,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++l),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=l,t};z.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-Fs||t>Fs)throw Error(ut+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n};z.prec=function(t,e){if(t!==~~t||t<1||t>at)throw Error(ut+"precision");return lt(new this.constructor(this),t,e)};z.round=function(t,e){if(t===Be)t=0;else if(t!==~~t||t<-at||t>at)throw Error(Jr);return lt(new this.constructor(this),t+this.e+1,e)};z.sqrt=function(){var t,e,r,n=this,i=n.constructor,s=n.s,o=n.e,a=new i("0.5");if(!n.c[0])return new i(n);if(s<0)throw Error(rr+"No square root");s=Math.sqrt(+ct(n,!0,!0)),s===0||s===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):t=new i(s+""),o=t.e+(i.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return lt(t,(i.DP-=4)+t.e+1,i.RM)};z.times=z.mul=function(t){var e,r=this,n=r.constructor,i=r.c,s=(t=new n(t)).c,o=i.length,a=s.length,l=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!s[0])return t.c=[t.e=0],t;for(t.e=l+u,o<a&&(e=i,i=s,s=e,u=o,o=a,a=u),e=new Array(u=o+a);u--;)e[u]=0;for(l=a;l--;){for(a=0,u=o+l;u>l;)a=e[u]+s[l]*i[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t};z.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Be){if(t!==~~t||t<0||t>at)throw Error(Jr);for(r=lt(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return ct(r,!0,!!n)};z.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==Be){if(t!==~~t||t<0||t>at)throw Error(Jr);for(r=lt(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return ct(r,!1,!!n)};z[Symbol.for("nodejs.util.inspect.custom")]=z.toJSON=z.toString=function(){var t=this,e=t.constructor;return ct(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};z.toNumber=function(){var t=+ct(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(rr+"Imprecise conversion");return t};z.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Be){if(t!==~~t||t<1||t>at)throw Error(ut+"precision");for(r=lt(new n(r),t,e);r.c.length<t;)r.c.push(0)}return ct(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)};z.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(rr+"valueOf disallowed");return ct(t,t.e<=e.NE||t.e>=e.PE,!0)};var Sl=Ls(),Ps=Sl;var Ei={};Es(Ei,{DecodeError:()=>fe,Decoder:()=>_e,EXT_TIMESTAMP:()=>ci,Encoder:()=>At,ExtData:()=>Ce,ExtensionCodec:()=>Ze,decode:()=>Xs,decodeArrayStream:()=>Js,decodeAsync:()=>Ws,decodeMulti:()=>Ys,decodeMultiStream:()=>Zs,decodeTimestampExtension:()=>mi,decodeTimestampToTimeSpec:()=>pi,encode:()=>Kr,encodeDateToTimeSpec:()=>hi,encodeTimeSpecToTimestamp:()=>fi,encodeTimestampExtension:()=>di});function Us(t){let e=t.length,r=0,n=0;for(;n<e;){let i=t.charCodeAt(n++);if((i&4294967168)===0){r++;continue}else if((i&4294965248)===0)r+=2;else{if(i>=55296&&i<=56319&&n<e){let s=t.charCodeAt(n);(s&64512)===56320&&(++n,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?r+=3:r+=4}}return r}function Nl(t,e,r){let n=t.length,i=r,s=0;for(;s<n;){let o=t.charCodeAt(s++);if((o&4294967168)===0){e[i++]=o;continue}else if((o&4294965248)===0)e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<n){let a=t.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128):(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128)}e[i++]=o&63|128}}var Il=new TextEncoder,Ol=50;function Bl(t,e,r){Il.encodeInto(t,e.subarray(r))}function $s(t,e,r){t.length>Ol?Bl(t,e,r):Nl(t,e,r)}var Ml=4096;function li(t,e,r){let n=e,i=n+r,s=[],o="";for(;n<i;){let a=t[n++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=t[n++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=t[n++]&63,u=t[n++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=t[n++]&63,u=t[n++]&63,c=t[n++]&63,f=(a&7)<<18|l<<12|u<<6|c;f>65535&&(f-=65536,s.push(f>>>10&1023|55296),f=56320|f&1023),s.push(f)}else s.push(a);s.length>=Ml&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var kl=new TextDecoder,Fl=200;function Rl(t,e,r){let n=t.subarray(e,e+r);return kl.decode(n)}function qs(t,e,r){return r>Fl?Rl(t,e,r):li(t,e,r)}var Ce=class{type;data;constructor(e,r){this.type=e,this.data=r}};var fe=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};function Vs(t,e,r){let n=r/4294967296,i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function Zr(t,e,r){let n=Math.floor(r/4294967296),i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function Qr(t,e){let r=t.getInt32(e),n=t.getUint32(e+4);return r*4294967296+n}function zs(t,e){let r=t.getUint32(e),n=t.getUint32(e+4);return r*4294967296+n}var ci=-1,Ll=4294967296-1,Pl=17179869184-1;function fi({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Pl)if(e===0&&t<=Ll){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,n=t&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|r&3),s.setUint32(4,n),i}else{let r=new Uint8Array(12),n=new DataView(r.buffer);return n.setUint32(0,e),Zr(n,4,t),r}}function hi(t){let e=t.getTime(),r=Math.floor(e/1e3),n=(e-r*1e3)*1e6,i=Math.floor(n/1e9);return{sec:r+i,nsec:n-i*1e9}}function di(t){if(t instanceof Date){let e=hi(t);return fi(e)}else return null}function pi(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),n=e.getUint32(4),i=(r&3)*4294967296+n,s=r>>>2;return{sec:i,nsec:s}}case 12:{let r=Qr(e,4),n=e.getUint32(0);return{sec:r,nsec:n}}default:throw new fe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function mi(t){let e=pi(t);return new Date(e.sec*1e3+e.nsec/1e6)}var js={type:ci,encode:di,decode:mi};var Ze=class t{static defaultCodec=new t;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(js)}register({type:e,encode:r,decode:n}){if(e>=0)this.encoders[e]=r,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}}tryToEncode(e,r){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let s=i(e,r);if(s!=null){let o=-1-n;return new Ce(o,s)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let s=i(e,r);if(s!=null){let o=n;return new Ce(o,s)}}}return e instanceof Ce?e:null}decode(e,r,n){let i=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return i?i(e,r,n):new Ce(r,e)}};function Ul(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function nr(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Ul(t)?new Uint8Array(t):Uint8Array.from(t)}var $l=100,ql=2048,At=class t{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ze.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??$l,this.initialBufferSize=e?.initialBufferSize??ql,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 t({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,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);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,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),n=new Uint8Array(r),i=new DataView(r);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Us(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),$s(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,r){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let n=nr(e);this.writeU8a(n)}encodeArray(e,r){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,r+1)}countWithoutUndefined(e,r){let n=0;for(let i of r)e[i]!==void 0&&n++;return n}encodeMap(e,r){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let s of n){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}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),Vs(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Zr(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 Kr(t,e){return new At(e).encodeSharedRef(t)}function en(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}var Vl=16,zl=16,tn=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Vl,r=zl){this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,n){let i=this.caches[n-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<n;a++)if(o[a]!==e[r+a])continue e;return s.str}return null}store(e,r){let n=this.caches[e.length-1],i={bytes:e,str:r};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,r,n){let i=this.find(e,r,n);if(i!=null)return this.hit++,i;this.miss++;let s=li(e,r,n),o=Uint8Array.prototype.slice.call(e,r,r+n);return this.store(o,s),s}};var gi="array",or="map_key",Gs="map_value",jl=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new fe("The type of key must be string or number but "+typeof t)},yi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=gi,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=or,r.readCount=0,r.size=e,r.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===gi){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===or||e.type===Gs){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},sr=-1,wi=new DataView(new ArrayBuffer(0)),Hl=new Uint8Array(wi.buffer);try{wi.getInt8(0)}catch(t){if(!(t 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 Hs=new RangeError("Insufficient data"),Gl=new tn,_e=class t{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=wi;bytes=Hl;headByte=sr;stack=new yi;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ze.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:Gl,this.mapKeyConverter=e?.mapKeyConverter??jl}clone(){return new t({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=sr,this.stack.reset()}setBuffer(e){let r=nr(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===sr&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),n=nr(e),i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:n}=this;return new RangeError(`Extra ${r.byteLength-n} of ${r.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 r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}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 r=!1,n;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),r=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${en(i)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let n=r,i=-1;for await(let s of e){if(r&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else{let i=e-160;r=this.decodeString(i,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let i=this.lookU8();r=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();r=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();r=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===196){let i=this.lookU8();r=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();r=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();r=this.decodeBinary(i,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();r=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();r=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();r=this.decodeExtension(i,4)}else throw new fe(`Unrecognized type byte: ${en(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===gi)if(i.array[i.position]=r,i.position++,i.position===i.size)r=i.array,n.release(i);else continue e;else if(i.type===or){if(r==="__proto__")throw new fe("The key __proto__ is not allowed");i.key=this.mapKeyConverter(r),i.type=Gs;continue e}else if(i.map[i.key]=r,i.readCount++,i.readCount===i.size)r=i.map,n.release(i);else{i.key=null,i.type=or;continue e}}return r}}readHeadByte(){return this.headByte===sr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=sr}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 fe(`Unrecognized array type byte: ${en(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new fe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new fe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new fe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Hs;let n=this.pos+r,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=qs(this.bytes,n,e),this.pos+=r+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===or:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new fe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Hs;let n=this.pos+r,i=this.bytes.subarray(n,n+e);return this.pos+=r+e,i}decodeExtension(e,r){if(e>this.maxExtLength)throw new fe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+r),i=this.decodeBinary(e,r+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=zs(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Qr(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 Xs(t,e){return new _e(e).decode(t)}function Ys(t,e){return new _e(e).decodeMulti(t)}function Xl(t){return t[Symbol.asyncIterator]!=null}async function*Yl(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}function rn(t){return Xl(t)?t:Yl(t)}async function Ws(t,e){let r=rn(t);return new _e(e).decodeAsync(r)}function Js(t,e){let r=rn(t);return new _e(e).decodeArrayStream(r)}function Zs(t,e){let r=rn(t);return new _e(e).decodeStream(r)}var vn=ni(qi(),1),Vi=ks,zi=Ps,Re=Ei,na=vn.DOMParser,ia=vn.XMLSerializer;var sa=Re!==null;function oa(){if(!sa)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var aa=Yf();function Yf(){if(!sa)return null;let t=new TextEncoder,e=new TextDecoder,r=new Re.ExtensionCodec;return r.register({type:-1,encode:n=>{if(n instanceof Date){let i=Le(n);if(i==="D"||i==="H")return null}return Re.encodeTimestampExtension(n)},decode:n=>Re.decodeTimestampExtension(n)}),r.register({type:1,encode:n=>ie(n)?t.encode(n.toString()):null,decode:n=>jt(e.decode(n))}),r.register({type:2,encode:n=>{if(n instanceof Date&&Le(n)==="D"){let i=n.getUTCFullYear(),s=String(n.getUTCMonth()+1).padStart(2,"0"),o=String(n.getUTCDate()).padStart(2,"0");return t.encode(`${i}-${s}-${o}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),r.register({type:3,encode:n=>{if(n instanceof Date&&Le(n)==="H"){let i=String(n.getUTCHours()).padStart(2,"0"),s=String(n.getUTCMinutes()).padStart(2,"0"),o=String(n.getUTCSeconds()).padStart(2,"0"),a=String(n.getUTCMilliseconds()).padStart(3,"0");return t.encode(`${i}:${s}:${o}.${a}`)}return null},decode:n=>{let i=e.decode(n),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+1):"0",[l,u,c]=o.split(":"),f=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,f))}}),r.register({type:4,encode:n=>{let i=ji(n);if(i!==null){let[s,o]=i;return t.encode(`${s}:${o(n)}`)}return null},decode:n=>{let i=e.decode(n),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=it[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),r}function ua(t){return oa(),Re.encode(t,{extensionCodec:aa})}function la(t){return oa(),Re.decode(t,{extensionCodec:aa})}function xn(t,e=!1){let r=An(t);if(r===null)return[!1,String(t)];let[n,i,s]=r;return s&&!e?[!1,String(t)]:[!0,`${i(t)}::${n}`]}function Hi(t){if(!t.includes("::"))return[!1,t];let e=t.lastIndexOf("::"),r=t.slice(0,e),n=t.slice(e+2),i=it[n];if(i===void 0)return[!1,t];let[,s]=i;return[!0,s(r)]}function Tn(t,e,r){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n={};for(let[i,s]of Object.entries(t))n[i]=Tn(s,e,r);return n}return Array.isArray(t)?t.map(n=>Tn(n,e,r)):r(t)?e(t):t}function Gi(t){let e=An(t);if(e!==null){let[r,n,i]=e;return i?[t,!1]:[`${n(t)}::${r}`,!0]}if(Array.isArray(t)){let r=!1;return[t.map(i=>{let[s,o]=Gi(i);return o&&(r=!0),s}),r]}if(t!==null&&typeof t=="object"){let r=!1,n={};for(let[i,s]of Object.entries(t)){let[o,a]=Gi(s);a&&(r=!0),n[i]=o}return[n,r]}return[t,!1]}function Wf(t,e=!1){let[r,n]=xn(t,e);if(r)return n;let[i,s]=Gi(t),o=JSON.stringify(i);return s?`${o}::JS`:o}function Jf(t){return JSON.stringify(t)}function Zf(t){if(!Re)throw new Error("@msgpack/msgpack is required for MessagePack support");return Re.encode(t)}function xe(t,e=null,{raw:r=!1,qs:n=!1,_forceSuffix:i=!1}={}){if(n)return`${fa(t)}::QS`;if(r){if(e===null||e==="json")return Jf(t);if(e==="msgpack")return Zf(t);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let s=Wf(t,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${ca(t)}</tytx_root>`;if(e==="msgpack")return ua(t);throw new Error(`Unknown transport: ${e}`)}}var Ht,Xi;typeof window<"u"&&window.DOMParser?(Ht=window.DOMParser,Xi=window.XMLSerializer):(Ht=na,Xi=ia);function ha(t){if(t===null||typeof t!="object"||Array.isArray(t))return!1;let e=Object.keys(t);if(e.length!==1)return!1;let r=t[e[0]];return r!==null&&typeof r=="object"&&"value"in r}function da(t,e,r){let n=t.createElement(e),i=r.attrs||{},s=r.value;for(let[o,a]of Object.entries(i))n.setAttribute(o,xe(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(ha(o)){let[a]=Object.keys(o),l=o[a],u=da(t,a,l);n.appendChild(u)}else{n.textContent=xe(s);break}else n.textContent=xe(s);return n}function ca(t){if(!Ht)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(ha(t)){let[e]=Object.keys(t),r=t[e],n=new Ht().parseFromString("<root/>","text/xml"),i=da(n,e,r);return new Xi().serializeToString(i)}else return xe(t)}function Yi(t){let e={};for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=K(i.value)}let r=[];for(let n=0;n<t.childNodes.length;n++){let i=t.childNodes[n];i.nodeType===1&&r.push(i)}if(r.length>0)if(r.length===1){let n=r[0],i=Yi(n);return{attrs:e,value:{[n.tagName]:i}}}else{let n=[];for(let i of r){let s=Yi(i);n.push({[i.tagName]:s})}return{attrs:e,value:n}}return{attrs:e,value:K(t.textContent)}}function pa(t){if(!Ht)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Ht().parseFromString(t,"text/xml").documentElement;if(n.tagName==="tytx_root"){let s=null;for(let o=0;o<n.childNodes.length;o++)if(n.childNodes[o].nodeType===1){s=n.childNodes[o];break}if(!s)return K(n.textContent);n=s}let i=Yi(n);return{[n.tagName]:i}}function Qf(t){return typeof t=="string"}function Kf(t){let[e,r]=Hi(t);if(e)return r;let n=t;n.endsWith("::JS")&&(n=n.slice(0,-4));let i;try{i=JSON.parse(n)}catch{return t}return Tn(i,eh,Qf)}function eh(t){return t.includes("::")?Hi(t)[1]:t}function th(t){let e=pa(t);return typeof e=="string"?K(e):e}function rh(t){return la(t)}function K(t,e=null){if(t===null)return null;if(e===null||e==="json"){let r=t;return e==="json"&&t.startsWith('"')&&t.endsWith('"')&&(r=t.slice(1,-1)),Kf(r)}else{if(e==="xml")return th(t);if(e==="msgpack")return rh(t);throw new Error(`Unknown transport: ${e}`)}}function fa(t){if(Array.isArray(t))return t.map(e=>String(e)).join("&");if(t!==null&&typeof t=="object"){let e=[];for(let[r,n]of Object.entries(t)){let[i,s]=xn(n,!0);i?e.push(`${r}=${s}`):e.push(`${r}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof t}`)}function ma(t){if(!t)return[];let e=t.split("&"),r=e.map(o=>o.includes("=")),n=r.every(Boolean),i=!r.some(Boolean);if(!n&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>K(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=K(u)}return s}var ya=Vi||zi||Number,nh=Vi?"decimal.js":zi?"big.js":"number";function jt(t){return new ya(t)}function ie(t){return nh==="number"?!1:t instanceof ya}function Le(t){let e=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,r=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;return e&&!r?"H":r&&!e?"D":"DHZ"}function ih(t){return t.toString()}function sh(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0");return`${e}-${r}-${n}`}function oh(t){return t.toISOString()}function ah(t){let e=String(t.getUTCHours()).padStart(2,"0"),r=String(t.getUTCMinutes()).padStart(2,"0"),n=String(t.getUTCSeconds()).padStart(2,"0"),i=String(t.getUTCMilliseconds()).padStart(3,"0");return`${e}:${r}:${n}.${i}`}function uh(t){return t?"true":"false"}function lh(t){return t.toString()}function ch(t){return t.toString()}function fh(t){let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode.apply(null,t.subarray(r,r+32768));return btoa(e)}var Cn=[],Wi=new Map;function ji(t){if(t===null||typeof t!="object")return null;for(let e=Object.getPrototypeOf(t);e!==null;e=Object.getPrototypeOf(e))for(let[r,n,i,s]of Cn)if(r.prototype===e)return[n,i,s];return null}function An(t){if(t===null)return["NN",()=>"",!0];if(ie(t))return["N",ih,!1];if(t instanceof Uint8Array)return["RAW",fh,!1];if(t instanceof Date){let e=Le(t);return e==="D"?["D",sh,!1]:e==="H"?["H",ah,!1]:["DHZ",oh,!1]}return typeof t=="boolean"?["B",uh,!0]:typeof t=="number"?Number.isInteger(t)?["L",lh,!0]:["R",ch,!0]:ji(t)}function hh(t){return jt(t)}function dh(t){let[e,r,n]=t.split("-").map(Number);return new Date(Date.UTC(e,r-1,n,0,0,0,0))}function ga(t){return new Date(t)}function ph(t){let[e,r,n]=t.split(":"),[i,s]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(r),Number(i),Number(s||0)))}function mh(t){return t.toLowerCase()==="true"}function gh(t){return parseInt(t,10)}function yh(t){return parseFloat(t)}function wh(t){return t}function Eh(t){return null}var bh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function Dh(t){if(!bh.test(t))throw new Error(`RAW payload is not standard padded base64: '${t}'`);let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function vh(t){return ma(t)}var Th=/^[A-Z]+$/,it={N:[Object,hh],D:[Date,dh],DH:[Date,ga],DHZ:[Date,ga],H:[Date,ph],L:[Number,gh],R:[Number,yh],T:[String,wh],B:[Boolean,mh],QS:[Object,vh],NN:[null,Eh],RAW:[Uint8Array,Dh]};function Ji(t){return Object.hasOwn(it,t)?it[t][0]:null}function Zi(t,e,r,n,i=!1){if(typeof e!="string"||!Th.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=it[e];if(s!==void 0&&s[0]!==t){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}Cn=Cn.filter(([o])=>o!==t),Cn.push([t,e,r,i]),it[e]=[t,n]}function Qi(t,e){Wi.set(t,e)}function Gt(t){return Wi.has(t)?Wi.get(t):{}}function ne(t,e,r,n){let i=null,s=[];for(let o of t.getRows()){let a=t.value(o,e),l=a instanceof Date&&Number.isFinite(a.getTime())?"time":typeof a=="string"||typeof a=="boolean"?"category":typeof a=="number"&&Number.isFinite(a)?"value":null;if(!l||i&&l!==i)throw new TypeError("Choose a column with consistent text, numeric, boolean or date values");i=l;let u=l==="time"?a.getTime():typeof a=="boolean"?String(a):a,c=r.map(f=>t.value(o,f));if(c.some(f=>typeof f!="number"||!Number.isFinite(f)))throw new TypeError("Selected measures require finite numeric values");s.push([u,...c])}return{source:s,kind:i??n?.kind??"category"}}function Xt(t,e,r,n,i){if(!e||!r||e===r)throw new TypeError("Choose two different dimensions for 3D bars");if(!n)throw new TypeError("Choose a measure for 3D bars");let s=i?i.dimensions.map(l=>l.values.map(u=>l.kind==="time"?new Date(u).toISOString():String(u))):[[],[]],o=s.map(l=>new Map(l.map((u,c)=>[u,c]))),a=[];for(let l of t.getRows()){let u=[e,r].map((f,h)=>{let d=t.value(l,f),p=d instanceof Date&&Number.isFinite(d.getTime())?d.toISOString():["string","boolean"].includes(typeof d)||typeof d=="number"&&Number.isFinite(d)?String(d):null;if(p===null)throw new TypeError("3D dimensions require text, numeric, boolean or date values");return o[h].has(p)||(o[h].set(p,s[h].length),s[h].push(p)),o[h].get(p)}),c=t.value(l,n);if(typeof c!="number"||!Number.isFinite(c))throw new TypeError("Selected measure requires finite numeric values");a.push([...u,c])}return{dimensions:s,source:a}}var st=["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"];function mt(t,e=!1){let r=e?0:1/0,n=e?0:-1/0;for(let i of t)Number.isFinite(i)&&(r=Math.min(r,i),n=Math.max(n,i));if(r===1/0)return[0,1];if(r===n){let i=Math.abs(r)*.05||1;return e&&r===0?[0,1]:[r-i,n+i]}return[r,n]}function Cr(t,e){return e==="time"?new Date(t).toISOString().slice(0,10):String(t)}function _n(t,{category:e,fields:r,settings:n,structure:i,type:s}){let{source:o,kind:a}=ne(t,e,r),l=[...new Set(o.map(b=>b[0]))],u={kind:a,values:l,range:mt(l)},c={};for(let b of["left","right"]){let C=r.map((O,L)=>L).filter(O=>n[O].axis===b),I=[];for(let O of o)if(["stackedBar","stackedArea"].includes(s.id))I.push(C.reduce((L,$)=>L+Math.max(0,O[$+1]),0),C.reduce((L,$)=>L+Math.min(0,O[$+1]),0));else for(let L of C)I.push(O[L+1]);c[b]=mt(I,!0)}let f=s.controls.includes("secondDimension")?i.getItem("secondCaptionField"):null,h=f?ne(t,f,[]):null,d=[u,...h?[{kind:h.kind,values:[...new Set(h.source.map(b=>b[0]))],range:mt(h.source.map(b=>b[0]))}]:[]],p=s.id==="map"?i.getItem("mapValueField"):null,m=p?i.getItem("geoJSON"):null,g=m?new Set(m.features.map(b=>b.properties.name)):null,y=p?t.getRows().filter(b=>!g||g.has(String(t.value(b,e)))).map(b=>t.value(b,p)):[];if(y.some(b=>typeof b!="number"||!Number.isFinite(b)))throw new TypeError("Selected map measure requires finite numeric values");let E=y.some(b=>b<0),[w,v]=mt(y);E?(v=Math.max(Math.abs(w),Math.abs(v)),w=-v):w=Math.max(0,w);let x=s.id==="mapBar3D"?new Set(i.getItem("geoJSON").features.map(b=>b.properties.name)):null,T=o.filter(b=>!x||x.has(String(b[0]))).flatMap(b=>b.slice(1));return{dimension:u,dimensions:d,axes:c,z:mt(T,s.id!=="mapBar3D"||i.getItem("mapBarScale")!=="extent"),labels:l.map(b=>Cr(b,a)),map:{min:w,max:v,signed:E},count:l.length}}var Sn=864e5,Nn={minute:6e4,hour:36e5,day:Sn,week:7*Sn},wa=4*Sn;function ze(t,e){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Temporal snapshots require Date values");if(Object.hasOwn(Nn,e))return Math.floor((t.getTime()-(e==="week"?wa:0))/Nn[e]);if(e==="month")return t.getUTCFullYear()*12+t.getUTCMonth();if(e==="year")return t.getUTCFullYear();throw new TypeError("Time step must be minute, hour, day, week, month or year")}function Ki(t,e){if(Object.hasOwn(Nn,e))return new Date(t*Nn[e]+(e==="week"?wa:0));let r=new Date(0);if(e==="month")r.setUTCFullYear(Math.floor(t/12),t-Math.floor(t/12)*12,1);else if(e==="year")r.setUTCFullYear(t,0,1);else throw new TypeError("Time step must be minute, hour, day, week, month or year");return r}function Ea(t,e){let r=1/0,n=-1/0,i=!1;for(let u of e?t.getRows():[]){let c=t.value(u,e);c!=null&&(ze(c,"day"),r=Math.min(r,c.getTime()),n=Math.max(n,c.getTime()),i||=Le(c)!=="D")}let s=i?["minute","hour","day","week","month","year"]:["day","week","month","year"],o=r===1/0?null:new Date(r),a=r===1/0?null:new Date(n),l=o?s.find(u=>ze(a,u)-ze(o,u)<=36)??"year":"day";return{hasClock:i,steps:s,suggested:l,first:o,last:a}}function In(t,e){let r=t.toISOString();return e==="week"?`${r.slice(0,10)} \u2013 ${new Date(t.getTime()+6*Sn).toISOString().slice(0,10)} UTC`:e==="hour"||e==="minute"?`${r.slice(0,16).replace("T"," ")} UTC`:r.slice(0,e==="year"?4:e==="month"?7:10)}var _r=class{constructor(e){this.view=e,this.field=""}invalidateDomains(){this.domainKey=null}domains(e){if(!this.field)return null;let r=JSON.stringify([this.field,this.step,e.category,e.fields,e.settings,e.type.id,e.structure.getItem("secondCaptionField"),e.structure.getItem("mapValueField"),e.structure.getItem("mapBarScale")]),n=e.structure.getItem("geoJSON");if(r!==this.domainKey||n!==this.domainGeoJSON){let i=this.view.getRows().filter(s=>this.value(s,this.field)!=null);this.domainValue=_n({getRows:()=>i,value:(s,o)=>this.value(s,o)},e),this.domainKey=r,this.domainGeoJSON=n}return this.domainValue}setPeriod(e,r,n,i="previous"){if(!["previous","empty"].includes(i))throw new TypeError("Empty periods require previous or empty");this.field=e,this.date=r,this.step=n,this.empty=i}value(e,r){return this.view.value(e,r)}getRows(){let e=this.view.getRows();if(this.snapshotDate=null,!this.field)return e;if(this.date==null)return[];let r=ze(this.date,this.step),n=this.empty==="empty"?r:-1/0,i=e.map(o=>{let a=this.value(o,this.field);return{row:o,period:a==null?null:ze(a,this.step)}});if(this.empty==="previous")for(let o of i)o.period!==null&&o.period<=r&&(n=Math.max(n,o.period));let s=i.filter(o=>o.period===n).map(o=>o.row);return s.length&&(this.snapshotDate=Ki(n,this.step)),s}};var J={};Es(J,{defineCollection:()=>es});Kt(J,hm);import*as hm from"@gramlot/gramlot/components";import{defineCollection as Ah}from"@gramlot/gramlot/components";function es(t){if(t.name!=="charts")throw new Error("Unexpected bundled collection");let e=[],r={echartsGlLicense:De["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:De["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:De["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:De["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:De["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]};t.css?.forEach((n,i)=>{n.href=e[i].href});for(let[n,i]of Object.entries(t.assets??{}))i.href=r[n].href;return Ah({...t,css:e,assets:r})}function On(t,e){return t.parameters=Ch(t.constructor.gramlotComponent,e),Object.fromEntries(Object.entries(e).filter(([r])=>!Object.hasOwn(t.parameters,r)))}function Ch(t,e){return Object.fromEntries(Object.entries(t.parameters).map(([r,n])=>[r,Object.hasOwn(e,r)?e[r]:n.default]))}function je(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{box-sizing:border-box;display:block;min-width:0;font:inherit;color:var(--gramlot-ink,CanvasText)}
1
+ import{b as er,c as te}from"./modules/chunk-USZCUBTC.js";var A={"assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt":new URL("./files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt",import.meta.url),"assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt":new URL("./files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt",import.meta.url),"assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt":new URL("./files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt",import.meta.url),"assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt":new URL("./files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt",import.meta.url),"assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt":new URL("./files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt",import.meta.url)};import{sharedModules as tr}from"@gramlot/gramlot";var rr=a=>tr["@genrojs/tytx"][a];var Le=rr("getDateType");function k(a,e,t,r){let o=null,i=[];for(let n of a.getRows()){let s=a.value(n,e),l=s instanceof Date&&Number.isFinite(s.getTime())?"time":typeof s=="string"||typeof s=="boolean"?"category":typeof s=="number"&&Number.isFinite(s)?"value":null;if(!l||o&&l!==o)throw new TypeError("Choose a column with consistent text, numeric, boolean or date values");o=l;let c=l==="time"?s.getTime():typeof s=="boolean"?String(s):s,p=t.map(g=>a.value(n,g));if(p.some(g=>typeof g!="number"||!Number.isFinite(g)))throw new TypeError("Selected measures require finite numeric values");i.push([c,...p])}return{source:i,kind:o??r?.kind??"category"}}function U(a,e,t,r,o){if(!e||!t||e===t)throw new TypeError("Choose two different dimensions for 3D bars");if(!r)throw new TypeError("Choose a measure for 3D bars");let i=o?o.dimensions.map(l=>l.values.map(c=>l.kind==="time"?new Date(c).toISOString():String(c))):[[],[]],n=i.map(l=>new Map(l.map((c,p)=>[c,p]))),s=[];for(let l of a.getRows()){let c=[e,t].map((g,u)=>{let h=a.value(l,g),b=h instanceof Date&&Number.isFinite(h.getTime())?h.toISOString():["string","boolean"].includes(typeof h)||typeof h=="number"&&Number.isFinite(h)?String(h):null;if(b===null)throw new TypeError("3D dimensions require text, numeric, boolean or date values");return n[u].has(b)||(n[u].set(b,i[u].length),i[u].push(b)),n[u].get(b)}),p=a.value(l,r);if(typeof p!="number"||!Number.isFinite(p))throw new TypeError("Selected measure requires finite numeric values");s.push([...c,p])}return{dimensions:i,source:s}}var E=["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"];function J(a,e=!1){let t=e?0:1/0,r=e?0:-1/0;for(let o of a)Number.isFinite(o)&&(t=Math.min(t,o),r=Math.max(r,o));if(t===1/0)return[0,1];if(t===r){let o=Math.abs(t)*.05||1;return e&&t===0?[0,1]:[t-o,r+o]}return[t,r]}function re(a,e){return e==="time"?new Date(a).toISOString().slice(0,10):String(a)}function se(a,{category:e,fields:t,settings:r,structure:o,type:i}){let{source:n,kind:s}=k(a,e,t),l=[...new Set(n.map(w=>w[0]))],c={kind:s,values:l,range:J(l)},p={};for(let w of["left","right"]){let S=t.map((F,D)=>D).filter(F=>r[F].axis===w),M=[];for(let F of n)if(["stackedBar","stackedArea"].includes(i.id))M.push(S.reduce((D,$)=>D+Math.max(0,F[$+1]),0),S.reduce((D,$)=>D+Math.min(0,F[$+1]),0));else for(let D of S)M.push(F[D+1]);p[w]=J(M,!0)}let g=i.syntax.some(w=>w.parameter==="secondCaptionField")?o.getItem("secondCaptionField"):null,u=g?k(a,g,[]):null,h=[c,...u?[{kind:u.kind,values:[...new Set(u.source.map(w=>w[0]))],range:J(u.source.map(w=>w[0]))}]:[]],b=i.id==="map"?o.getItem("mapValueField"):null,m=b?o.getItem("geoJSON"):null,f=m?new Set(m.features.map(w=>w.properties.name)):null,d=b?a.getRows().filter(w=>!f||f.has(String(a.value(w,e)))).map(w=>a.value(w,b)):[];if(d.some(w=>typeof w!="number"||!Number.isFinite(w)))throw new TypeError("Selected map measure requires finite numeric values");let y=d.some(w=>w<0),[x,v]=J(d);y?(v=Math.max(Math.abs(x),Math.abs(v)),x=-v):x=Math.max(0,x);let T=i.id==="mapBar3D"?new Set(o.getItem("geoJSON").features.map(w=>w.properties.name)):null,C=n.filter(w=>!T||T.has(String(w[0]))).flatMap(w=>w.slice(1));return{dimension:c,dimensions:h,axes:p,z:J(C,i.id!=="mapBar3D"||o.getItem("mapBarScale")!=="extent"),labels:l.map(w=>re(w,s)),map:{min:x,max:v,signed:y},count:l.length}}var le=864e5,ce={minute:6e4,hour:36e5,day:le,week:7*le},Be=4*le;function L(a,e){if(!(a instanceof Date)||!Number.isFinite(a.getTime()))throw new TypeError("Temporal snapshots require Date values");if(Object.hasOwn(ce,e))return Math.floor((a.getTime()-(e==="week"?Be:0))/ce[e]);if(e==="month")return a.getUTCFullYear()*12+a.getUTCMonth();if(e==="year")return a.getUTCFullYear();throw new TypeError("Time step must be minute, hour, day, week, month or year")}function $e(a,e){if(Object.hasOwn(ce,e))return new Date(a*ce[e]+(e==="week"?Be:0));let t=new Date(0);if(e==="month")t.setUTCFullYear(Math.floor(a/12),a-Math.floor(a/12)*12,1);else if(e==="year")t.setUTCFullYear(a,0,1);else throw new TypeError("Time step must be minute, hour, day, week, month or year");return t}function je(a,e){let t=1/0,r=-1/0,o=!1;for(let c of e?a.getRows():[]){let p=a.value(c,e);p!=null&&(L(p,"day"),t=Math.min(t,p.getTime()),r=Math.max(r,p.getTime()),o||=Le(p)!=="D")}let i=o?["minute","hour","day","week","month","year"]:["day","week","month","year"],n=t===1/0?null:new Date(t),s=t===1/0?null:new Date(r),l=n?i.find(c=>L(s,c)-L(n,c)<=36)??"year":"day";return{hasClock:o,steps:i,suggested:l,first:n,last:s}}function de(a,e){let t=a.toISOString();return e==="week"?`${t.slice(0,10)} \u2013 ${new Date(a.getTime()+6*le).toISOString().slice(0,10)} UTC`:e==="hour"||e==="minute"?`${t.slice(0,16).replace("T"," ")} UTC`:t.slice(0,e==="year"?4:e==="month"?7:10)}var ae=class{constructor(e){this.view=e,this.field=""}invalidateDomains(){this.domainKey=null}domains(e){if(!this.field||e.type.domains===!1)return null;let t=JSON.stringify([this.field,this.step,e.category,e.fields,e.settings,e.type.id,e.structure.getItem("secondCaptionField"),e.structure.getItem("mapValueField"),e.structure.getItem("mapBarScale")]),r=e.structure.getItem("geoJSON");if(t!==this.domainKey||r!==this.domainGeoJSON){let o=this.view.getRows().filter(i=>this.value(i,this.field)!=null);this.domainValue=se({getRows:()=>o,value:(i,n)=>this.value(i,n)},e),this.domainKey=t,this.domainGeoJSON=r}return this.domainValue}setPeriod(e,t,r,o="previous"){if(!["previous","empty"].includes(o))throw new TypeError("Empty periods require previous or empty");this.field=e,this.date=t,this.step=r,this.empty=o}get rowMode(){return this.view.rowMode}value(e,t){return this.view.value(e,t)}getRows(){let e=this.view.getRows();if(this.snapshotDate=null,!this.field)return e;if(this.date==null)return[];let t=L(this.date,this.step),r=this.empty==="empty"?t:-1/0,o=e.map(n=>{let s=this.value(n,this.field);return{row:n,period:s==null?null:L(s,this.step)}});if(this.empty==="previous")for(let n of o)n.period!==null&&n.period<=t&&(r=Math.max(r,n.period));let i=o.filter(n=>n.period===r).map(n=>n.row);return i.length&&(this.snapshotDate=$e(r,this.step)),i}};var I={};er(I,{defineCollection:()=>ke});te(I,Yr);import*as Yr from"@gramlot/gramlot/components";import{defineCollection as ar}from"@gramlot/gramlot/components";function ke(a){if(a.name!=="charts")throw new Error("Unexpected bundled collection");let e=[],t={echartsGlLicense:A["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:A["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:A["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:A["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:A["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]};a.css?.forEach((r,o)=>{r.href=e[o].href});for(let[r,o]of Object.entries(a.assets??{}))o.href=t[r].href;return ar({...a,css:e,assets:t})}import{sharedModules as or}from"@gramlot/gramlot";var ir=a=>or["./components/parameters.js"][a];var Ge=ir("projectParameters");function z(a){return class extends a{constructor(){super();let e=this.attachShadow({mode:"open"}),t=this.ownerDocument.createElement("style");t.textContent=`:host{box-sizing:border-box;display:block;min-width:0;font:inherit;color:var(--gramlot-ink,CanvasText)}
13
2
  *,*::before,*::after{box-sizing:border-box}.control-box{min-width:0}slot{display:contents}
14
- ::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),e.append(r,this.controlBox)}projectAttributes(e){return On(this,e)}}}je.parameters={};function He(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("")}var ts=new WeakMap;function ba(t){if(!ts.has(t)){let e=`chart_time_${He()}`;class r{tick(i){let s=i.getAttr("configpath"),o=i.getRelativeData(s);if(!o.getItem("timePlaying")||!o.getItem("timeField"))return;let a=o.getItem("timeIndex")+1,l=o.getItem("timeMax");a<=l&&i.setRelativeData(`${s}.timeIndex`,a),a>=l&&i.setRelativeData(`${s}.timePlaying`,!1)}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),ts.set(t,`${e}.tick`)}return ts.get(t)}var Da=(0,J.defineComponent)({name:"chartTimeline",tag:"gramlot-chart-timeline",base:je,sourceContext:!0,bagStore:!0,parameters:{storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},timeField:{dtype:"T",binding:"read"},timeStep:{dtype:"T",binding:"read"},timeIndex:{dtype:"R",binding:"read"}},implementation:t=>class extends t{#e;#t;#s;#r;#n=!1;#i=!1;#o;#u;#c;#a;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#n&&this.#f(),n}connectedCallback(){this.#n=!0,this.#f()}#f(){let e=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);e!==this.#s&&(this.#r?.(),this.#s=e,this.#c=null,this.#r=e.subscribe(()=>{this.#c=null,this.#l()})),this.#l()}#l(){if(!this.#i){this.#i=!0;try{let e=this.#e.sourceNode,r=this.parameters.configpath,n=e.getRelativeData(r),i=(m,g)=>{let y=n.getItem(m);(y instanceof Date&&g instanceof Date?y.getTime()!==g.getTime():y!==g)&&e.setRelativeData(`${r}.${m}`,g)},{timeField:s,timeStep:o}=this.parameters;(!this.#c||s!==this.#a)&&(this.#c=Ea(this.#s,s),this.#a=s);let a=this.#c,l=o==="auto"?a.suggested:o;i("timeHasClock",a.hasClock),i("timeUnit",l);let u=JSON.stringify([s,l]),c=n.getItem("timeIndex"),f=this.#o!==void 0&&u!==this.#o;f&&(c=0,i("timePlaying",!1)),this.#o=u;let h=s&&a.first?{min:ze(a.first,l),max:ze(a.last,l)}:null;!f&&h&&this.#u!==void 0&&h.min!==this.#u&&n.getItem("timeValue")instanceof Date&&(c=ze(n.getItem("timeValue"),l)-h.min),this.#u=h?.min;let d=h?h.max-h.min:0;if(!Number.isInteger(c))throw new TypeError("Time index requires an integer");c=Math.max(0,Math.min(d,c));let p=h?Ki(h.min+c,l):null;i("timeMax",d),i("timeIndex",c),i("timeValue",p),i("timeLabel",p?In(p,l):"No temporal data"),(!h||d===0)&&i("timePlaying",!1)}finally{this.#i=!1}}}disconnectedCallback(){this.#n=!1,this.#r?.(),this.#r=null,this.#s=null;let e=this.parameters.configpath;this.#e.sourceNode.setRelativeData(`${e}.timePlaying`,!1)}}});import{Bag as Ir,fromTytx as Fh,toTytx as Rh}from"@gramlot/gramlot";var _h,rs,Bn=class{static label="Vega";static async load(){rs=await(_h??=import("./modules/vega.module-2QCOVQ3A.js"))}#e;#t;#s;#r=!1;#n=Promise.resolve();#i;#o;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=JSON.stringify({...r,data:r.data.map(({values:a,...l})=>l)}),s=async()=>{if(this.#r||!n())return;if(i!==this.#s)this.#t?.finalize(),this.#e.replaceChildren(),this.#t=new rs.View(rs.parse(r),{renderer:"svg",container:this.#e,hover:!0}),this.#s=i;else for(let l of r.data)l.values&&this.#t.data(l.name,l.values);let a=this.#e.getBoundingClientRect();this.#i=Math.max(1,Math.round(a.width)),this.#o=Math.max(1,Math.round(a.height)),await this.#t.width(this.#i).height(this.#o).runAsync(),this.#r&&this.#t.finalize()},o=this.#n.then(s);return this.#n=o.catch(()=>{}),o}render_bar(e){return this.#u(e,!0)}render_line(e){return this.#u(e,!1)}#u({view:e,category:r,fields:n,settings:i,domains:s},o){let{source:a,kind:l}=ne(e,r,n,s?.dimension),u=o&&l!=="time",c=this.#c();c.data=[{name:"rows",values:a.map((f,h)=>({x:f[0],index:h}))},...n.map((f,h)=>({name:`series${h}`,values:a.map(d=>({x:d[0],y:d[h+1],label:l==="time"?new Date(d[0]).toISOString().slice(0,10):String(d[0])}))}))],c.scales=[{name:"x",type:u?"band":l==="time"?"utc":l==="category"?"point":"linear",domain:s?u||l==="category"?s.dimension.values:s.dimension.range:{data:"rows",field:"x"},range:"width",...u?{padding:.2}:{zero:!1,padding:.5}},{name:"color",type:"ordinal",domain:n,range:i.map(f=>f.color)}],c.axes=[{orient:"bottom",scale:"x",labelOverlap:!0,title:r}];for(let f of["left","right"]){let h=n.map((d,p)=>p).filter(d=>i[d].axis===f);h.length&&(c.scales.push({name:f,type:"linear",domain:s?s.axes[f]:{fields:h.map(d=>({data:`series${d}`,field:"y"}))},range:"height",zero:!0,nice:!0}),c.axes.push({orient:f,scale:f,grid:f==="left",title:h.map(d=>n[d]).join(", "),format:"~s"}))}return c.legends=[{fill:"color",orient:"bottom",direction:"horizontal",title:null}],o&&(c.signals=[{name:"groupWidth",update:u?"bandwidth('x')":"min(60, width / max(1, length(data('rows'))) * 0.7)"}]),c.marks=n.flatMap((f,h)=>{let d={scale:i[h].axis,field:"y"};if(o)return{name:`measure${h}`,type:"rect",from:{data:`series${h}`},encode:{update:{x:{signal:`scale('x',datum.x) ${u?"":"- groupWidth / 2"} + groupWidth * ${h} / ${n.length}`},width:{signal:`groupWidth / ${n.length} * 0.9`},y:{signal:`scale('${i[h].axis}',max(0,datum.y))`},y2:{signal:`scale('${i[h].axis}',min(0,datum.y))`},fill:{value:i[h].color},tooltip:{signal:'datum.label + ": " + datum.y'}}}};let p={x:{scale:"x",field:"x"},y:d,tooltip:{signal:'datum.label + ": " + datum.y'}};return[{name:`measure${h}`,type:"line",from:{data:`series${h}`},encode:{update:{...p,stroke:{value:i[h].color},strokeWidth:{value:2}}}},{name:`points${h}`,type:"symbol",from:{data:`series${h}`},encode:{update:{...p,fill:{value:i[h].color},size:{signal:`length(data('series${h}')) === 1 ? 36 : 0`}}}}]}),c}render_pie({view:e,category:r,fields:n,domains:i}){let{source:s,kind:o}=ne(e,r,n,i?.dimension);if(s.some(u=>u[1]<0))throw new TypeError("Pie requires nonnegative values. Configuration retained.");let a=this.#c();a.data=[{name:"slices",values:n.length?s.map((u,c)=>({index:c,label:o==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]),value:u[1]})):[],transform:[{type:"pie",field:"value",sort:!1}]}],a.scales=[{name:"color",type:"ordinal",domain:i?i.labels:{data:"slices",field:"label"},range:i?st:{scheme:"tableau10"}}],a.legends=[{fill:"color",orient:"bottom",direction:"horizontal",columns:3,title:null}];let l={x:{signal:"width / 2"},y:{signal:"height / 2"}};return a.marks=[{name:"pieSlices",type:"arc",from:{data:"slices"},encode:{update:{...l,startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},outerRadius:{signal:"min(width,height) * 0.46"},fill:{scale:"color",field:"label"},stroke:{value:"#fff"},tooltip:{signal:'datum.label + ": " + datum.value'}}}},{name:"sliceLabels",type:"text",from:{data:"slices"},encode:{update:{...l,radius:{signal:"min(width,height) * 0.30"},theta:{signal:"(datum.startAngle + datum.endAngle) / 2"},text:{field:"label"},align:{value:"center"},baseline:{value:"middle"},fill:{value:"#222"},limit:{signal:"min(width,height) * 0.25"}}}}],a}#c(){return{background:"#fff",autosize:{type:"fit",contains:"padding",resize:!0},padding:12,data:[],scales:[],axes:[],marks:[],config:{axis:{labelColor:"#333",titleColor:"#333",gridColor:"#eee"},legend:{labelColor:"#333"}}}}resize(){if(this.#r||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));if(r===this.#i&&n===this.#o)return;this.#i=r,this.#o=n;let i=async()=>{this.#r||await this.#t.width(this.#i).height(this.#o).resize().runAsync()};this.#n=this.#n.then(i).catch(()=>{})}dispose(){this.#r=!0,this.#t?.finalize()}};var Sh,va,Ta,Mn=class{static label="uPlot";static async load(){await(Sh??=Promise.all([import("./modules/uPlot.esm-5JJNHHRF.js"),import("./modules/uPlot.min-N3E3FA74.js")]).then(([e,r])=>{va=e.default,Ta=r.default}))}#e;#t;#s;#r;#n=!1;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}render_line({view:e,category:r,fields:n,settings:i,domains:s}){let{source:o,kind:a}=ne(e,r,n,s?.dimension);if(o.length&&a==="category")throw new TypeError("uPlot requires a numeric or date X field. Configuration retained.");if(o.some((l,u)=>u>0&&l[0]<=o[u-1][0]))throw new TypeError("uPlot requires distinct X values in ascending order. Prepare the store upstream. Configuration retained.");return{category:r,fields:n,settings:i,domains:s,time:a==="time",data:[o.map(l=>a==="time"?l[0]/1e3:l[0]),...n.map((l,u)=>o.map(c=>c[u+1]))]}}update(e,r,n=()=>!0){if(this.#n||!n())return;let{data:i,...s}=r,o=JSON.stringify(s);if(this.#s||(this.#s=this.#e.ownerDocument.createElement("style"),this.#s.textContent=Ta+`
15
- .uplot{color:#333;background:#fff;font-size:12px}.u-legend{font-size:12px;max-height:90px;overflow:auto}`,this.#e.append(this.#s)),o!==this.#r){this.#t?.destroy();let{category:a,fields:l,settings:u,time:c,domains:f}=r,h=this.#e.getBoundingClientRect(),d={x:{time:c,...f?{range:()=>f.dimension.range.map(m=>c?m/1e3:m)}:{}}},p=[{label:a,stroke:"#333",font:"12px sans-serif"}];for(let m of["left","right"]){let g=l.filter((y,E)=>u[E].axis===m);g.length&&(d[m]={time:!1,...f?{range:()=>f.axes[m]}:{}},p.push({scale:m,side:m==="left"?3:1,label:g.join(", "),stroke:"#333",font:"12px sans-serif",grid:{show:m==="left",stroke:"#e5e7eb"}}))}this.#t=new va({width:Math.max(1,Math.round(h.width)),height:Math.max(1,Math.round(h.height)-50),pxAlign:!1,scales:d,axes:p,series:[{label:a},...l.map((m,g)=>({label:m,stroke:u[g].color,scale:u[g].axis,width:1.5}))]},i,this.#e),this.#r=o}else this.#t.setData(i);this.resize()}resize(){if(this.#n||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=this.#t.root.querySelector(".u-legend"),n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.floor(e.height-r.getBoundingClientRect().height));(this.#t.width!==n||this.#t.height!==i)&&this.#t.setSize({width:n,height:i})}dispose(){this.#n=!0,this.#t?.destroy(),this.#t=null,this.#s?.remove()}};var Yt=ni(Cu(),1);var xa={id:"bar",label:"Bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Aa={id:"line",label:"Lines",controls:["category","measures"],threeD:!1,measureLimit:null};var Ca={id:"area",label:"Area",controls:["category","measures"],threeD:!1,measureLimit:null};var _a={id:"stackedBar",label:"Stacked bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Sa={id:"stackedArea",label:"Stacked area",controls:["category","measures"],threeD:!1,measureLimit:null};var Na={id:"horizontalBar",label:"Horizontal bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Ia={id:"pie",label:"Pie",controls:["category","measures"],threeD:!1,measureLimit:1};var Oa={id:"donut",label:"Donut",controls:["category","measures"],threeD:!1,measureLimit:1};var Ba={id:"scatter",label:"Scatter",controls:["category","measures"],threeD:!1,measureLimit:null};var Ma={id:"bar3D",label:"3D bars",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var ka={id:"line3D",label:"3D lines",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var Fa={id:"scatter3D",label:"3D scatter",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var Ra={id:"surface",label:"Surface",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var La={id:"map",label:"2D map",controls:["category","geoJSON","mapMeasure"],threeD:!1,measureLimit:null};var Pa={id:"mapBar3D",label:"3D bars on map",controls:["category","geoJSON","mapBarScale","measures"],threeD:!0,measureLimit:null};var Ua={id:"map3D",label:"3D map",controls:["category","geoJSON","measures"],threeD:!0,measureLimit:null};var $a={id:"lines3D",label:"3D paths",controls:["category","geoJSON","geometry","measures"],threeD:!0,measureLimit:null};var qa={id:"polygons3D",label:"3D polygons",controls:["category","geometry","measures"],threeD:!0,measureLimit:null};var kn=[xa,Aa,Ca,_a,Sa,Na,Ia,Oa,Ba,Ma,ka,Fa,Ra,La,Pa,Ua,$a,qa],Nh=new Map(kn.map(t=>[t.id,t]));function Fn(t){let e=Nh.get(t);if(!e)throw new TypeError("Choose a supported chart type");return e}function Pe({view:t,category:e,fields:r,settings:n,domains:i},{seriesType:s,radial:o=!1,horizontal:a=!1,stacked:l=!1,scatter:u=!1,area:c=!1,donut:f=!1}){let{source:h,kind:d}=ne(t,e,r,i?.dimension);if(l&&new Set(n.map(g=>g.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(u&&!["value","time"].includes(d))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(o&&h.some(g=>g[1]<0))throw new TypeError("Pie and donut require nonnegative values.");let p=["left","right"].map((g,y)=>({type:"value",position:a?["bottom","top"][y]:g,show:n.some(E=>E.axis===g),name:r.filter((E,w)=>n[w].axis===g).join(", "),...i?{min:i.axes[g][0],max:i.axes[g][1]}:{},splitLine:{show:y===0}})),m={backgroundColor:"#ffffff",useUTC:!0,legend:{show:!0},tooltip:{trigger:o||u?"item":"axis"},grid:{left:80,right:75,top:65,bottom:65}};if(o)m.legend={show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24},m.series=r.map(g=>({id:g,name:g,type:"pie",top:12,bottom:64,left:12,right:12,label:{alignTo:"edge",edgeDistance:10,overflow:"truncate"},labelLayout:{hideOverlap:!0},radius:f?["35%","65%"]:"65%",data:h.map(y=>({name:d==="time"?new Date(y[0]).toISOString().slice(0,10):String(y[0]),value:y[1],...i?{itemStyle:{color:st[i.labels.indexOf(Cr(y[0],d))%st.length]}}:{}}))}));else{let g=a&&d==="time"?h.map(E=>[new Date(E[0]).toISOString().slice(0,10),...E.slice(1)]):h;m.dataset={source:g,sourceHeader:!1};let y={type:a||d==="value"&&s==="bar"?"category":d};y.type==="value"&&(y.scale=!0),i&&(y.type==="category"?(y.data=i.dimension.values.map(E=>Cr(E,d)),m.dataset.source=h.map(E=>[Cr(E[0],d),...E.slice(1)])):(y.min=i.dimension.range[0],y.max=i.dimension.range[1])),m.xAxis=a?p:y,m.yAxis=a?y:p,m.series=r.map((E,w)=>({id:E,name:E,type:s,...s==="line"?{showSymbol:h.length===1}:{},...a?{xAxisIndex:n[w].axis==="right"?1:0}:{yAxisIndex:n[w].axis==="right"?1:0},...l?{stack:"measures"}:{},...c?{areaStyle:{opacity:.3}}:{},itemStyle:{color:n[w].color},lineStyle:{color:n[w].color},encode:a?{x:w+1,y:0}:{x:0,y:w+1}}))}return m}function Va(t,e,r,n,i,s){let o=n.map(d=>Xt(t,e,r,d,s)),a=o[0]?.dimensions??[[],[]],l=n.length,u=.72,c=l?u/l:0,f=100,h=80;return{backgroundColor:"#ffffff",legend:{show:!0,type:"scroll",left:12,right:12,bottom:10,height:24,data:n},tooltip:{renderMode:"richText",formatter:d=>{let[p,m,g]=d.value;return`${e}: ${a[0][Math.round(p)-1]}
16
- ${r}: ${a[1][m]}
17
- ${d.seriesName}: ${g}`}},xAxis3D:{type:"value",name:e,nameGap:35,min:0,max:Math.max(2,a[0].length+1),interval:1,axisLabel:{formatter:d=>a[0][d-1]??""}},yAxis3D:{type:"category",name:r,nameGap:35,data:a[1]},zAxis3D:{type:"value",name:"Value",nameGap:40,...s?{min:s.z[0],max:s.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:f,boxDepth:h,viewControl:{projection:"perspective"},light:{main:{intensity:1.2},ambient:{intensity:.4}}},series:n.map((d,p)=>({id:d,name:d,type:"bar3D",shading:"lambert",barSize:[f/Math.max(2,a[0].length+1)*c*.85,h/Math.max(1,a[1].length)*.55],data:o[p].source.map(([m,g,y])=>[m+1+(p-(l-1)/2)*c,g,y]),itemStyle:{color:i[p].color}}))}}function za(t,e,r,n,i,s,o){let a=t.getRows(),l=m=>a.every(g=>{let y=t.value(g,m);return typeof y=="number"&&Number.isFinite(y)||y instanceof Date&&Number.isFinite(y.getTime())}),u=[r,n].map((m,g)=>({numeric:o?o.dimensions[g].kind!=="category":l(m),date:o?o.dimensions[g].kind==="time":a.length>0&&t.value(a[0],m)instanceof Date}));if(["scatter3D","surface"].includes(e)&&u.some(m=>!m.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let c=i.map(m=>Xt(t,r,n,m,o)),f=c[0]?.dimensions??[[],[]],h=f.map((m,g)=>m.map((y,E)=>u[g].numeric?u[g].date?Date.parse(y):Number(y):E)),d=m=>({type:u[m].numeric?"value":"category",name:[r,n][m],nameGap:35,...u[m].numeric?o?{min:o.dimensions[m].range[0],max:o.dimensions[m].range[1]}:{}:{data:f[m]},...u[m].date?{axisLabel:{formatter:g=>new Date(g).toISOString().slice(0,10)}}:{}}),p=[];return c.forEach((m,g)=>{let y={name:i[g],type:e,itemStyle:{color:s[g].color},lineStyle:{color:s[g].color,width:3}},E=m.source.map(([w,v,x])=>[h[0][w],h[1][v],x]);if(e==="line3D")f[1].forEach((w,v)=>{let x=m.source.filter(T=>T[1]===v).map(([T,,b])=>[h[0][T],h[1][v],b]).sort((T,b)=>T[0]-b[0]);p.push({...y,id:`${i[g]}:${v}`,data:x})});else if(e==="surface"){let w=[...h[0]].sort((T,b)=>T-b),v=[...h[1]].sort((T,b)=>T-b),x=new Map;for(let[T,b,C]of E){let I=JSON.stringify([T,b]);if(x.has(I))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");x.set(I,C)}if(w.length<2||v.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");p.push({...y,id:i[g],dataShape:[v.length,w.length],shading:"lambert",itemStyle:{color:s[g].color,opacity:i.length>1?.7:1},data:v.flatMap(T=>w.map(b=>[b,T,x.get(JSON.stringify([b,T]))??NaN]))})}else p.push({...y,id:i[g],symbolSize:9,data:E})}),{backgroundColor:"#fff",legend:{type:"scroll",left:12,right:12,bottom:10,data:i},tooltip:{renderMode:"richText"},xAxis3D:d(0),yAxis3D:d(1),zAxis3D:{type:"value",name:"Value",nameGap:40,...o?{min:o.z[0],max:o.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:100,boxDepth:80,viewControl:{projection:"perspective"}},series:p}}function ns(t){return Array.isArray(t)&&t.length>=2&&t.length<=3&&t.every(Number.isFinite)}function Rn(t){return Array.isArray(t)&&t.length>0&&t.every(e=>Array.isArray(e)&&e.length>=4&&e.every(ns)&&JSON.stringify(e[0])===JSON.stringify(e.at(-1)))}function ja(t,e,r){if(!r)throw new TypeError("Choose the coordinate field");let n=new Set;return{type:"FeatureCollection",features:t.getRows().map(s=>{let o=String(t.value(s,e)),a=t.value(s,r);if(n.has(o))throw new TypeError("Polygon names must be unique");if(n.add(o),!Rn(a))throw new TypeError("Polygons require closed coordinate rings, including any holes");return{type:"Feature",properties:{name:o},geometry:{type:"Polygon",coordinates:a}}})}}function Ha(t,e,r,n,i,s,o,a){if(!a||a.type!=="FeatureCollection"||!Array.isArray(a.features))throw new TypeError("Provide a GeoJSON FeatureCollection in configuration.geoJSON");for(let p of a.features)if(p.type!=="Feature"||!["Polygon","MultiPolygon"].includes(p.geometry?.type)||typeof p.properties?.name!="string")throw new TypeError("Map features require Polygon/MultiPolygon geometry and properties.name");let l=t.getRows();if(e!=="map3D"&&!n)throw new TypeError("Choose the coordinate field");let u=e==="map3D"?ne(t,r,i).source:null;if(u&&new Set(u.map(p=>p[0])).size!==u.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let c=e==="lines3D"?l.map(p=>{let m=t.value(p,n);if(!Array.isArray(m)||m.length<2||!m.every(ns))throw new TypeError("Paths require a list of at least two longitude/latitude/altitude coordinates");return m}):[],f=[],h=[],d=[];return i.forEach((p,m)=>{let g={left:`${m*100/i.length}%`,width:`${100/i.length}%`,top:35,bottom:60,height:null};d.push({text:p,left:`${(m+.5)*100/i.length}%`,top:8,textAlign:"center",textStyle:{fontSize:13,color:"#333"}});let y=e==="map3D"?u.map(w=>({name:String(w[0]),value:w[m+1]})):l.map(w=>({name:String(t.value(w,r)),value:t.value(w,p)}));if(y.some(w=>typeof w.value!="number"||!Number.isFinite(w.value)||w.value<0))throw new TypeError("Geographic measures require finite nonnegative values");let E={id:p,name:p,type:e,itemStyle:{color:s[m].color},shading:"lambert"};if(e!=="lines3D")f.push({...E,type:"map3D",...g,map:o,label:{show:!0},data:y.map(w=>({...w,height:w.value})),viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});else{h.push({...g,map:o,regionHeight:0,itemStyle:{color:"#e8edf1",opacity:.5},viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});let w=y.map((v,x)=>({...v,coords:c[x],height:v.value}));f.push({...E,coordinateSystem:"geo3D",geo3DIndex:m,data:w,polyline:!0,silent:!1,lineStyle:{color:s[m].color,width:4,opacity:1}})}}),{backgroundColor:"#fff",title:d,legend:{type:"scroll",data:i,left:12,right:12,bottom:10},tooltip:{renderMode:"richText"},geo3D:h,series:f}}function Ga(t,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(t==="")return[];let r=new Set;return t.split(e).map(n=>{let i=n.indexOf(":"),s=i<0?n:n.slice(0,i),o=i<0?n:n.slice(i+1);if(!s||r.has(s))throw new Error("Invalid or duplicate choice code");return r.add(s),{id:s,caption:o}})}function Ln(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
18
- input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
19
- input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
20
- appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
21
- border-radius:var(--gramlot-field-radius,var(--gramlot-radius-sm,4px));background:var(--gramlot-field-background,Canvas);color:var(--gramlot-ink,CanvasText);
22
- height:var(--gramlot-field-block-size,auto);min-height:var(--gramlot-field-height,28px);padding:var(--gramlot-field-padding,.25em .5em);font-size:var(--gramlot-field-font-size,1em);line-height:var(--gramlot-field-line-height,inherit)}
23
- input:read-only:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea:read-only{
24
- background:var(--gramlot-field-readonly-background,Canvas)}
25
- input:disabled,textarea:disabled{opacity:.6;cursor:not-allowed}
26
- input::placeholder,textarea::placeholder{color:var(--gramlot-text-secondary,GrayText)}
27
- input:focus-visible,textarea:focus-visible,button:focus-visible{outline:var(--gramlot-field-focus-outline,2px solid var(--gramlot-focus-ring,Highlight));outline-offset:var(--gramlot-field-focus-offset,1px)}
28
- textarea{resize:var(--gramlot-field-resize,both)}
29
- input[type=checkbox],input[type=radio],input[type=range]{accent-color:var(--gramlot-brand-blue,Highlight)}
30
- input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
31
- input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
32
- .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)}
33
- .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(r,this.controlBox)}projectAttributes(e){return On(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,r){return r(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(r,n)=>{if(r==null&&!e)throw new TypeError("This component requires a non-null value.");if(r!=null&&n!=null&&typeof r!=typeof n)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,r=>{this.validationValueCheck()(r,e),this.sameControlValue(e,r)||this.writeControlValue(r)})}restoreFormDraft(e){this.control.value=e}restoreFormValue(e){this.writeControlValue(e)}sameControlValue(e,r){return Object.is(e,r)}focus(e){this.control.focus(e)}}}function Ih(t){return class extends Ln(t){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,r){let n=super.projectAttributes(e,r),{disabled:i,readonly:s}=this.parameters;this.control.disabled=!!i,this.control.readOnly=!!s;for(let[o,a]of Object.entries(this.constructor.gramlotComponent.parameters)){if(a.target==="control"){let l=this.parameters[o]??"";String(this.control[o])!==String(l)&&(this.control[o]=l)}a.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[o]??"")}return n}}}Ih.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function Oh(t){return class extends Ln(t){#e=new Map;#t;#s=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 r=[...this.control.querySelectorAll("input:not(:disabled)")],n=r.indexOf(e.target);if(n<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?r.length-1:Math.max(0,Math.min(r.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));r[i].focus()})}choiceOptions(){return Ga(this.parameters.values??"")}projectAttributes(e,r){let n=super.projectAttributes(e,r),i=this.choiceOptions(),s=JSON.stringify(i);if(s!==this.#t){let a=i,l=new Set,u=null;for(let{id:c,caption:f}of a){let h=this.#e.get(c);if(!h){let p=this.ownerDocument.createElement("label");p.className="option";let m=this.ownerDocument.createElement("input");m.type=this.choiceType,m.name="choice",m.value=c;let g=this.ownerDocument.createElement("span");p.append(m,g),h={label:p,input:m,text:g},this.#e.set(c,h)}h.text.textContent=f;let d=u?u.nextSibling:this.control.firstChild;d!==h.label&&this.control.insertBefore(h.label,d),u=h.label,l.add(c)}for(let[c,f]of this.#e)l.has(c)||(f.label.remove(),this.#e.delete(c));this.#t=s}let o=this.parameters.cols;if(!Number.isInteger(o)||o<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${o}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return n}readControlValue(){if(this.multiple){let r=(this.#s?this.#s.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:i}]of this.#e)i.checked&&!r.includes(n)&&r.push(n);return r.join(",")||null}for(let[e,{input:r}]of this.#e)if(r.checked)return e;return null}writeControlValue(e){this.#s=e;let r=this.multiple?new Set(e?e.split(","):[]):null;for(let[n,{input:i}]of this.#e)i.checked=this.multiple?r.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,r=>this.writeControlValue(r))}focus(e){let r=[...this.#e.values()];(r.find(({input:n})=>n.checked&&!n.disabled)??r.find(({input:n})=>!n.disabled))?.input.focus(e)}}}Oh.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Sr(t){if(t?.type!=="FeatureCollection"||!Array.isArray(t.features)||!t.features.length)throw new TypeError("Choose a GeoJSON FeatureCollection containing territories.");let e=new Set;for(let r of t.features){let n=r.properties?.name,i=r.geometry;if(r.type!=="Feature"||typeof n!="string"||!n.trim())throw new TypeError("Every territory needs a nonempty properties.name.");if(e.has(n))throw new TypeError(`Duplicate territory name: ${n}`);if(e.add(n),!i||!["Polygon","MultiPolygon"].includes(i.type))throw new TypeError("Territories must use Polygon or MultiPolygon geometry.");let s=i.type==="Polygon"?[i.coordinates]:i.coordinates;if(!Array.isArray(s)||!s.length||!s.every(Rn))throw new TypeError(`Invalid or unclosed coordinate rings: ${n}`)}return t}var Xa=(0,J.defineComponent)({name:"chartGeoJSON",tag:"gramlot-chart-geo-json",base:Ln,sourceContext:!0,parameters:{value:{dtype:"X",nullable:!0,default:null,binding:"twoWay"}},implementation:t=>class extends t{#e;#t=0;constructor(){super();let e=this.ownerDocument;this.control=e.createElement("input"),this.control.type="file",this.control.accept=".geojson,.json,application/geo+json,application/json",this.control.setAttribute("aria-label","Load GeoJSON"),this.control.style.cssText="width:100%;min-width:0;font:inherit",this.message=e.createElement("div"),this.message.setAttribute("role","status"),this.message.style.cssText="font-size:11px;overflow-wrap:anywhere",this.controlBox.append(this.control,this.message),this.control.addEventListener("change",r=>{r.stopPropagation(),this.#r()})}readControlValue(){return this.parameters.value}writeControlValue(e){this.parameters.value=e,this.#s()}setSourceContext(e){this.#e=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#t++,this.#s(),n}#s(){let e=this.parameters.value;this.message.textContent=e?`${e.features.length} territories${e.features.length<=3?": "+e.features.map(r=>r.properties.name).join(", "):" loaded"}`:"No GeoJSON loaded"}async#r(){let e=this.control.files[0];if(!e)return;let r=++this.#t;try{let n=Sr(JSON.parse(await e.text()));if(r!==this.#t||!this.isConnected)return;this.control.value="",this.#e.writeParameter("value",n)}catch(n){r===this.#t&&this.isConnected&&(this.message.textContent=`GeoJSON not loaded: ${n.message}`)}finally{r===this.#t&&(this.control.value="")}}disconnectedCallback(){this.#t++}}});function Pn(t){let e=r=>Math.abs(r.slice(1).reduce((n,i,s)=>n+r[s][0]*i[1]-i[0]*r[s][1],0));return new Map(t.features.map(r=>{let i=[...r.geometry.type==="Polygon"?[r.geometry.coordinates]:r.geometry.coordinates].sort((u,c)=>e(c[0])-e(u[0]))[0],s=i[0].map(u=>u[1]),o=[...new Set(s)].sort((u,c)=>u-c),a=(o[0]+o.at(-1))/2,l=o.slice(1).map((u,c)=>(o[c]+u)/2).sort((u,c)=>Math.abs(u-a)-Math.abs(c-a));for(let u of l){let c=[];for(let h of i)for(let d=1;d<h.length;d++){let p=h[d-1],m=h[d];p[1]>u!=m[1]>u&&c.push(p[0]+(u-p[1])*(m[0]-p[0])/(m[1]-p[1]))}c.sort((h,d)=>h-d);let f=null;for(let h=0;h+1<c.length;h+=2)c[h+1]>c[h]&&(!f||c[h+1]-c[h]>f[1]-f[0])&&(f=[c[h],c[h+1]]);if(f)return[r.properties.name,[(f[0]+f[1])/2,u]]}throw new TypeError(`Territory has no drawable interior: ${r.properties.name}`)}))}function Ya({view:t,category:e,fields:r,settings:n,structure:i,seriesOptions:s,domains:o},a){let l=Sr(i.getItem("geoJSON")),u=i.getItem("mapBarScale")??"zero";if(!["zero","extent"].includes(u))throw new TypeError("Choose zero or extent for geographic bar heights");let c=Pn(l),{source:f}=ne(t,e,r);if(new Set(f.map(O=>String(O[0]))).size!==f.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let h=f.filter(O=>c.has(String(O[0])));if(f.length&&!h.length)throw new TypeError("No store territories match GeoJSON properties.name");let d=h.flatMap(O=>O.slice(1));if(d.some(O=>!Number.isFinite(O)||O<0))throw new TypeError("Geographic bars require finite nonnegative measures");let p=o?o.z:mt(d,u==="zero"),m=u==="zero"?0:p[0],g=p[1],y=l.features.flatMap(O=>(O.geometry.type==="Polygon"?[O.geometry.coordinates]:O.geometry.coordinates).flatMap(L=>L[0].map($=>$[0]))),[E,w]=y.reduce(([O,L],$)=>[Math.min(O,$),Math.max(L,$)],[1/0,-1/0]),v=w-E,x=.45,T=v/100*x*1.25,b=O=>s.getItem(O).getItem("caption")||O,C=r.map((O,L)=>({id:O,name:b(O),type:"bar3D",coordinateSystem:"geo3D",geo3DIndex:0,barSize:x,shading:"lambert",itemStyle:{color:n[L].color},label:{show:!1},emphasis:{label:{show:!0,formatter:$=>Number($.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}},data:h.map($=>{let[se,V]=c.get(String($[0]));return{name:String($[0]),value:[se+(L-(r.length-1)/2)*T,V,$[L+1]]}})})),I=c.values().next().value;return C.push({id:"map-height-reference",type:"scatter3D",coordinateSystem:"geo3D",geo3DIndex:0,silent:!0,symbolSize:0,itemStyle:{opacity:0},label:{show:!1},tooltip:{show:!1},data:[[...I,m],[...I,g]]}),{backgroundColor:"#fff",legend:{type:"scroll",data:r.map(b),bottom:8},title:{text:u==="zero"?"Geographic bars \xB7 baseline 0":"Geographic bars \xB7 truncated baseline",left:"center",top:8,textStyle:{fontSize:14,color:"#27344b"}},tooltip:{renderMode:"richText",formatter:O=>`${O.name}
34
- ${O.seriesName}: ${Number(O.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}`},geo3D:{map:a,top:35,bottom:45,boxWidth:100,boxHeight:35,regionHeight:.15,itemStyle:{color:"#d9e3eb",borderColor:"#8e9ca9",borderWidth:.3},label:{show:!1},shading:"lambert",viewControl:{projection:"perspective",distance:145,minDistance:30,maxDistance:300,alpha:45,beta:0}},series:C}}function Un(t,e,r="value"){if(!["none","name","value","nameValue"].includes(r))throw new TypeError("Choose a supported map label mode");if(r==="none"||!Number.isFinite(e))return"";let n=e.toLocaleString("en-GB",{notation:"compact",maximumFractionDigits:1});return r==="name"?t:r==="value"?n:`${t}
35
- ${n}`}var $n=["#77bce4","#307eb9","#083e80"];function qn(t,e,r,n,i){if(Sr(i),!r)throw new TypeError("Choose a map measure");let{source:s}=ne(t,e,[r]);if(new Set(s.map(d=>String(d[0]))).size!==s.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let o=new Map;for(let d of t.getRows()){let p=String(t.value(d,e)),m=t.value(d,n);if(typeof m!="string"&&typeof m!="number")throw new TypeError("Choose a text or numeric map label field");if(o.has(p)&&o.get(p)!==String(m))throw new TypeError("Map labels must be consistent for each territory");o.set(p,String(m))}let a=new Set(i.features.map(d=>d.properties.name)),l=s.filter(d=>a.has(String(d[0]))).map(([d,p])=>({name:String(d),value:p}));if(s.length&&!l.length)throw new TypeError("No store territories match GeoJSON properties.name");let u=l.map(d=>d.value),c=u.some(d=>d<0),f=u.length?Math.min(...u):0,h=u.length?Math.max(...u):1;if(c)h=Math.max(Math.abs(f),Math.abs(h)),f=-h;else if(f===h){let d=Math.abs(h)*.01||1;f=Math.max(0,f-d),h+=d}return{data:l,labels:o,min:f,max:h,signed:c}}function Wa(t,e,r,n,i,s,o,a,l="value"){let{data:u,labels:c,...f}=qn(t,e,r,n,s),{min:h,max:d,signed:p}=a?a.map:f,m=y=>Number(y).toLocaleString("en-GB",{maximumFractionDigits:2}),g=o||r;return{backgroundColor:"#fff",title:{text:g,left:"center",top:8,textStyle:{color:"#27344b",fontSize:14}},tooltip:{trigger:"item",renderMode:"richText",formatter:y=>`${c.get(y.name)||y.name}
36
- ${g}: ${Number.isFinite(y.value)?m(y.value):"No data"}`},visualMap:{type:"continuous",min:h,max:d,seriesIndex:0,dimension:0,calculable:!0,orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:180,precision:2,formatter:m,textStyle:{color:"#27344b"},inRange:{color:p?["#b73548","#f7f7f7","#2166ac"]:$n},outOfRange:{color:"#e2e5e9"}},series:[{name:g,type:"map",map:i,preserveAspect:"contain",aspectScale:1,roam:!0,top:42,bottom:70,left:20,right:20,itemStyle:{areaColor:"#e2e5e9",borderColor:"#fff",borderWidth:.45},label:{show:!0,color:"#182c46",fontSize:11,textBorderColor:"#fff",textBorderWidth:3,formatter:y=>Un(c.get(y.name)||y.name,y.value,l)},labelLayout:{hideOverlap:!0},emphasis:{label:{show:!0},itemStyle:{borderColor:"#1b273d",borderWidth:2}},data:u}]}}var Bh,Vn=class{static label="ECharts";static async load(e){Fn(e).threeD&&await(Bh??=import("./modules/echarts-gl-CXVTZA6G.js"))}#e;#t;#s;#r;#n;#i=`chart_${He()}`;#o;constructor(e,r={}){this.#s=e,this.#r=r,this.#n=r.renderer??"canvas",this.#e=Yt.init(e,null,r),this.#u()}#u(){this.#e.on("click",e=>{this.#t==="mapBar3D"&&e.seriesType==="bar3D"&&this.#r.onTerritorySelect?.(e.name),this.#t==="map"&&e.componentType==="series"&&e.seriesType==="map"&&this.#r.onTerritorySelect?.(e.name)})}validate(e){return this[`render_${e.type.id}`](e)}update(e,r){this.#t=e.type.id;let n=e.type.threeD?"canvas":this.#r.renderer??"canvas";n!==this.#n&&(this.#e.dispose(),this.#e=Yt.init(this.#s,null,{...this.#r,renderer:n}),this.#n=n,this.#u()),this.#e.setOption(r,{notMerge:!0})}render_bar(e){return Pe(e,{seriesType:"bar"})}render_line(e){return Pe(e,{seriesType:"line"})}render_area(e){return Pe(e,{seriesType:"line",area:!0})}render_stackedBar(e){return Pe(e,{seriesType:"bar",stacked:!0})}render_stackedArea(e){return Pe(e,{seriesType:"line",area:!0,stacked:!0})}render_horizontalBar(e){return Pe(e,{seriesType:"bar",horizontal:!0})}render_pie(e){return Pe(e,{seriesType:"pie",radial:!0})}render_donut(e){return Pe(e,{seriesType:"pie",radial:!0,donut:!0})}render_scatter(e){return Pe(e,{seriesType:"scatter",scatter:!0})}render_bar3D({view:e,category:r,structure:n,fields:i,settings:s,domains:o}){return Va(e,r,n.getItem("secondCaptionField"),i,s,o)}render_line3D(e){return this.#c(e,"line3D")}render_scatter3D(e){return this.#c(e,"scatter3D")}render_surface(e){return this.#c(e,"surface")}#c({view:e,category:r,structure:n,fields:i,settings:s,domains:o},a){return za(e,a,r,n.getItem("secondCaptionField"),i,s,o)}#a(e){return e!==this.#o&&(Yt.registerMap(this.#i,e),this.#o=e),this.#i}render_map({view:e,category:r,structure:n,seriesOptions:i,domains:s}){let o=n.getItem("mapValueField"),a=n.getItem("geoJSON"),l=Wa(e,r,o,n.getItem("mapLabelField"),this.#i,a,i.getItem(o)?.getItem("caption"),s,n.getItem("mapLabelMode")??"value");return this.#a(a),l}render_mapBar3D(e){let r=e.structure.getItem("geoJSON"),n=Ya(e,this.#i);return this.#a(r),n}render_map3D(e){return this.#f(e,"map3D",e.structure.getItem("geoJSON"))}render_lines3D(e){return this.#f(e,"lines3D",e.structure.getItem("geoJSON"))}render_polygons3D(e){return this.#f(e,"polygons3D",ja(e.view,e.category,e.structure.getItem("geometryField")))}#f({view:e,category:r,structure:n,fields:i,settings:s},o,a){let l=Ha(e,o,r,n.getItem("geometryField"),i,s,this.#i,a);return this.#a(a),l}svg(){return this.#e.renderToSVGString()}resize(){this.#e.resize()}dispose(){this.#e.dispose(),this.#o&&Yt.registerMap(this.#i,{type:"FeatureCollection",features:[]})}};function zn({view:t,category:e,structure:r,fields:n,settings:i,domains:s},o,a){let l=r.getItem("secondCaptionField"),u=t.getRows(),c=[e,l].map((g,y)=>({field:g,numeric:s?s.dimensions[y].kind!=="category":u.every(E=>{let w=t.value(E,g);return typeof w=="number"&&Number.isFinite(w)||w instanceof Date&&Number.isFinite(w.getTime())}),date:s?s.dimensions[y].kind==="time":u.length>0&&t.value(u[0],g)instanceof Date}));if(o!=="line3D"&&c.some(g=>!g.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let f=n.map(g=>Xt(t,e,l,g,s)),h=f[0]?.dimensions??[[],[]],d=h.map((g,y)=>g.map((E,w)=>c[y].numeric?c[y].date?Date.parse(E):Number(E):w)),p=g=>({title:{text:c[g].field},type:c[g].date?"date":"linear",...c[g].numeric?s?{range:s.dimensions[g].range,autorange:!1}:{}:{tickvals:d[g],ticktext:h[g],...s?{range:[-.5,h[g].length-.5],autorange:!1}:{}}});a.scene={xaxis:p(0),yaxis:p(1),zaxis:{title:{text:"Value"},...s?{range:s.z,autorange:!1}:{}},aspectmode:"cube"};let m=[];return f.forEach((g,y)=>{let E=i[y].color,w={name:n[y],legendgroup:n[y],showlegend:!0},v=g.source.map(([x,T,b])=>[d[0][x],d[1][T],b]);if(o==="surface"){let x=[...d[0]].sort((C,I)=>C-I),T=[...d[1]].sort((C,I)=>C-I),b=new Map;for(let[C,I,O]of v){let L=JSON.stringify([C,I]);if(b.has(L))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");b.set(L,O)}if(x.length<2||T.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");m.push({...w,type:"surface",x,y:T,z:T.map(C=>x.map(I=>b.get(JSON.stringify([I,C]))??null)),connectgaps:!1,colorscale:[[0,E],[1,E]],showscale:!1,opacity:n.length>1?.7:1})}else o==="line3D"?h[1].forEach((x,T)=>{let b=g.source.filter(C=>C[1]===T).map(([C,,I])=>[d[0][C],d[1][T],I]).sort((C,I)=>C[0]-I[0]);m.push({...w,showlegend:T===0,type:"scatter3d",mode:b.length===1?"lines+markers":"lines",x:b.map(C=>C[0]),y:b.map(C=>C[1]),z:b.map(C=>C[2]),line:{color:E,width:4},marker:{color:E,size:4}})}):m.push({...w,type:"scatter3d",mode:"markers",x:v.map(x=>x[0]),y:v.map(x=>x[1]),z:v.map(x=>x[2]),marker:{color:E,size:4}})}),{data:m,layout:a}}function Ja({view:t,category:e,structure:r,seriesOptions:n,domains:i},s){let o=r.getItem("mapValueField"),a=r.getItem("geoJSON"),{data:l,labels:u,...c}=qn(t,e,o,r.getItem("mapLabelField"),a),{min:f,max:h,signed:d}=i?i.map:c,p=b=>b.map((C,I)=>{let O=C.slice(1).reduce((L,$,se)=>L+C[se][0]*$[1]-$[0]*C[se][1],0);return(I===0?O>0:O<0)?[...C].reverse():C}),m={...a,features:a.features.map(b=>({...b,geometry:{...b.geometry,coordinates:b.geometry.type==="Polygon"?p(b.geometry.coordinates):b.geometry.coordinates.map(p)}}))},g=n.getItem(o)?.getItem("caption")||o;s.title={text:g},s.showlegend=!1,s.margin={l:10,r:70,t:45,b:20},s.geo={visible:!1,showframe:!1,showcoastlines:!1,showland:!1,showocean:!1,showcountries:!1,showlakes:!1,showrivers:!1,fitbounds:"geojson",projection:{type:"mercator"},bgcolor:"#fff"};let y=d?["#b73548","#f7f7f7","#2166ac"]:$n,E={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:l.map(b=>b.name),z:l.map(b=>b.value),zmin:f,zmax:h,colorscale:y.map((b,C)=>[C/2,b]),marker:{line:{color:"#fff",width:.45}},colorbar:{title:{text:g},thickness:14},hovertemplate:"%{location}<br>%{z:.2f}<extra></extra>"},w=Pn(a),v=l.map(b=>({name:b.name,value:b.value,point:w.get(b.name)})),x=a.features.map(b=>b.properties.name).filter(b=>!l.some(C=>C.name===b)),T={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:x,z:x.map(()=>0),colorscale:[[0,"#e2e5e9"],[1,"#e2e5e9"]],showscale:!1,marker:{line:{color:"#fff",width:.45}},hovertemplate:"%{location}<br>No data<extra></extra>"};return{layout:s,data:[T,E,{type:"scattergeo",mode:"text",showlegend:!1,hoverinfo:"skip",lon:v.map(b=>b.point[0]),lat:v.map(b=>b.point[1]),text:v.map(b=>Un(u.get(b.name)||b.name,b.value,r.getItem("mapLabelMode")??"value")),textfont:{color:"#182c46",size:11}}]}}var Mh,Nr,jn=class{static label="Plotly";static async load(){Nr=await(Mh??=import("./modules/plotly.min-4LB7HE7P.js").then(e=>e.default))}#e;#t;#s;#r=!1;#n;#i=!1;#o=Promise.resolve();#u=!1;constructor(e,r={}){this.#e=e,this.#t=r}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=async()=>{if(this.#i||!n())return;this.#n||(this.#n=this.#e.ownerDocument.createElement("style"),this.#n.textContent=`.js-plotly-plot,.js-plotly-plot div{margin:0;padding:0;border:0}
3
+ ::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),e.append(t,this.controlBox)}projectAttributes(e){return Ge(this,e)}}}z.parameters={};import{sharedModules as nr}from"@gramlot/gramlot";var sr=a=>nr["./random-id.js"][a],B=sr("randomId");var Ne=new WeakMap;function Je(a){if(!Ne.has(a)){let e=`chart_time_${B()}`;class t{tick(o){let i=o.getAttr("configpath"),n=o.getRelativeData(i);if(!n.getItem("timePlaying")||!n.getItem("timeField"))return;let s=n.getItem("timeIndex")+1,l=n.getItem("timeMax");s<=l&&o.setRelativeData(`${i}.timeIndex`,s),s>=l&&o.setRelativeData(`${i}.timePlaying`,!1)}}a.logicRegistry.register(t,{group:e,resource:"gramlot:charts"}),Ne.set(a,`${e}.tick`)}return Ne.get(a)}var Ve=(0,I.defineComponent)({name:"chartTimeline",tag:"gramlot-chart-timeline",base:z,sourceContext:!0,bagStore:!0,parameters:{storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},timeField:{dtype:"T",binding:"read"},timeStep:{dtype:"T",binding:"read"},timeIndex:{dtype:"R",binding:"read"}},implementation:a=>class extends a{#e;#t;#a;#r;#i=!1;#o=!1;#n;#c;#d;#l;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){this.#t=e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#i&&this.#m(),r}connectedCallback(){this.#i=!0,this.#m()}#m(){let e=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);e!==this.#a&&(this.#r?.(),this.#a=e,this.#d=null,this.#r=e.subscribe(()=>{this.#d=null,this.#s()})),this.#s()}#s(){if(!this.#o){this.#o=!0;try{let e=this.#e.sourceNode,t=this.parameters.configpath,r=e.getRelativeData(t),o=(m,f)=>{let d=r.getItem(m);(d instanceof Date&&f instanceof Date?d.getTime()!==f.getTime():d!==f)&&e.setRelativeData(`${t}.${m}`,f)},{timeField:i,timeStep:n}=this.parameters;(!this.#d||i!==this.#l)&&(this.#d=je(this.#a,i),this.#l=i);let s=this.#d,l=n==="auto"?s.suggested:n;o("timeHasClock",s.hasClock),o("timeUnit",l);let c=JSON.stringify([i,l]),p=r.getItem("timeIndex"),g=this.#n!==void 0&&c!==this.#n;g&&(p=0,o("timePlaying",!1)),this.#n=c;let u=i&&s.first?{min:L(s.first,l),max:L(s.last,l)}:null;!g&&u&&this.#c!==void 0&&u.min!==this.#c&&r.getItem("timeValue")instanceof Date&&(p=L(r.getItem("timeValue"),l)-u.min),this.#c=u?.min;let h=u?u.max-u.min:0;if(!Number.isInteger(p))throw new TypeError("Time index requires an integer");p=Math.max(0,Math.min(h,p));let b=u?$e(u.min+p,l):null;o("timeMax",h),o("timeIndex",p),o("timeValue",b),o("timeLabel",b?de(b,l):"No temporal data"),(!u||h===0)&&o("timePlaying",!1)}finally{this.#o=!1}}}disconnectedCallback(){this.#i=!1,this.#r?.(),this.#r=null,this.#a=null;let e=this.parameters.configpath;this.#e.sourceNode.setRelativeData(`${e}.timePlaying`,!1)}}});import{Bag as Z,fromTytx as wr,toTytx as xr}from"@gramlot/gramlot";import{sharedModules as lr}from"@gramlot/gramlot";var cr=a=>lr["./libraries.js"][a];var P=cr("loadLibrary");var dr,Oe,me=class{static label="Vega";static async load(e,t){Oe=await(dr??=P("vega",t,()=>import("./modules/vega.module-Y5CWNSZO.js")))}#e;#t;#a;#r=!1;#i=Promise.resolve();#o;#n;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}update(e,t,r=()=>!0){let o=JSON.stringify({...t,data:t.data.map(({values:s,...l})=>l)}),i=async()=>{if(this.#r||!r())return;if(o!==this.#a)this.#t?.finalize(),this.#e.replaceChildren(),this.#t=new Oe.View(Oe.parse(t),{renderer:"svg",container:this.#e,hover:!0}),this.#a=o;else for(let l of t.data)l.values&&this.#t.data(l.name,l.values);let s=this.#e.getBoundingClientRect();this.#o=Math.max(1,Math.round(s.width)),this.#n=Math.max(1,Math.round(s.height)),await this.#t.width(this.#o).height(this.#n).runAsync(),this.#r&&this.#t.finalize()},n=this.#i.then(i);return this.#i=n.catch(()=>{}),n}render_bar(e){return this.#c(e,!0)}render_line(e){return this.#c(e,!1)}#c({view:e,category:t,fields:r,settings:o,domains:i},n){let{source:s,kind:l}=k(e,t,r,i?.dimension),c=n&&l!=="time",p=this.#d();p.data=[{name:"rows",values:s.map((g,u)=>({x:g[0],index:u}))},...r.map((g,u)=>({name:`series${u}`,values:s.map(h=>({x:h[0],y:h[u+1],label:l==="time"?new Date(h[0]).toISOString().slice(0,10):String(h[0])}))}))],p.scales=[{name:"x",type:c?"band":l==="time"?"utc":l==="category"?"point":"linear",domain:i?c||l==="category"?i.dimension.values:i.dimension.range:{data:"rows",field:"x"},range:"width",...c?{padding:.2}:{zero:!1,padding:.5}},{name:"color",type:"ordinal",domain:r,range:o.map(g=>g.color)}],p.axes=[{orient:"bottom",scale:"x",labelOverlap:!0,title:t}];for(let g of["left","right"]){let u=r.map((h,b)=>b).filter(h=>o[h].axis===g);u.length&&(p.scales.push({name:g,type:"linear",domain:i?i.axes[g]:{fields:u.map(h=>({data:`series${h}`,field:"y"}))},range:"height",zero:!0,nice:!0}),p.axes.push({orient:g,scale:g,grid:g==="left",title:u.map(h=>r[h]).join(", "),format:"~s"}))}return p.legends=[{fill:"color",orient:"bottom",direction:"horizontal",title:null}],n&&(p.signals=[{name:"groupWidth",update:c?"bandwidth('x')":"min(60, width / max(1, length(data('rows'))) * 0.7)"}]),p.marks=r.flatMap((g,u)=>{let h={scale:o[u].axis,field:"y"};if(n)return{name:`measure${u}`,type:"rect",from:{data:`series${u}`},encode:{update:{x:{signal:`scale('x',datum.x) ${c?"":"- groupWidth / 2"} + groupWidth * ${u} / ${r.length}`},width:{signal:`groupWidth / ${r.length} * 0.9`},y:{signal:`scale('${o[u].axis}',max(0,datum.y))`},y2:{signal:`scale('${o[u].axis}',min(0,datum.y))`},fill:{value:o[u].color},tooltip:{signal:'datum.label + ": " + datum.y'}}}};let b={x:{scale:"x",field:"x"},y:h,tooltip:{signal:'datum.label + ": " + datum.y'}};return[{name:`measure${u}`,type:"line",from:{data:`series${u}`},encode:{update:{...b,stroke:{value:o[u].color},strokeWidth:{value:2}}}},{name:`points${u}`,type:"symbol",from:{data:`series${u}`},encode:{update:{...b,fill:{value:o[u].color},size:{signal:`length(data('series${u}')) === 1 ? 36 : 0`}}}}]}),p}render_pie({view:e,category:t,fields:r,domains:o}){let{source:i,kind:n}=k(e,t,r,o?.dimension);if(i.some(c=>c[1]<0))throw new TypeError("Pie requires nonnegative values. Configuration retained.");let s=this.#d();s.data=[{name:"slices",values:r.length?i.map((c,p)=>({index:p,label:n==="time"?new Date(c[0]).toISOString().slice(0,10):String(c[0]),value:c[1]})):[],transform:[{type:"pie",field:"value",sort:!1}]}],s.scales=[{name:"color",type:"ordinal",domain:o?o.labels:{data:"slices",field:"label"},range:o?E:{scheme:"tableau10"}}],s.legends=[{fill:"color",orient:"bottom",direction:"horizontal",columns:3,title:null}];let l={x:{signal:"width / 2"},y:{signal:"height / 2"}};return s.marks=[{name:"pieSlices",type:"arc",from:{data:"slices"},encode:{update:{...l,startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},outerRadius:{signal:"min(width,height) * 0.46"},fill:{scale:"color",field:"label"},stroke:{value:"#fff"},tooltip:{signal:'datum.label + ": " + datum.value'}}}},{name:"sliceLabels",type:"text",from:{data:"slices"},encode:{update:{...l,radius:{signal:"min(width,height) * 0.30"},theta:{signal:"(datum.startAngle + datum.endAngle) / 2"},text:{field:"label"},align:{value:"center"},baseline:{value:"middle"},fill:{value:"#222"},limit:{signal:"min(width,height) * 0.25"}}}}],s}#d(){return{background:"#fff",autosize:{type:"fit",contains:"padding",resize:!0},padding:12,data:[],scales:[],axes:[],marks:[],config:{axis:{labelColor:"#333",titleColor:"#333",gridColor:"#eee"},legend:{labelColor:"#333"}}}}resize(){if(this.#r||!this.#t)return;let e=this.#e.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),r=Math.max(1,Math.round(e.height));if(t===this.#o&&r===this.#n)return;this.#o=t,this.#n=r;let o=async()=>{this.#r||await this.#t.width(this.#o).height(this.#n).resize().runAsync()};this.#i=this.#i.then(o).catch(()=>{})}dispose(){this.#r=!0,this.#t?.finalize()}};var mr,We,Ue,ue=class{static label="uPlot";static async load(e,t){await(mr??=Promise.all([P("uplot",t,()=>import("./modules/uPlot.esm-Q2UYUQHJ.js")),P("uplotStyle",t,()=>import("./modules/uPlot.min-XXHNQFXH.js"))]).then(([r,o])=>{We=r.default,Ue=o}))}#e;#t;#a;#r;#i=!1;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}render_line({view:e,category:t,fields:r,settings:o,domains:i}){let{source:n,kind:s}=k(e,t,r,i?.dimension);if(n.length&&s==="category")throw new TypeError("uPlot requires a numeric or date X field. Configuration retained.");if(n.some((l,c)=>c>0&&l[0]<=n[c-1][0]))throw new TypeError("uPlot requires distinct X values in ascending order. Prepare the store upstream. Configuration retained.");return{category:t,fields:r,settings:o,domains:i,time:s==="time",data:[n.map(l=>s==="time"?l[0]/1e3:l[0]),...r.map((l,c)=>n.map(p=>p[c+1]))]}}update(e,t,r=()=>!0){if(this.#i||!r())return;let{data:o,...i}=t,n=JSON.stringify(i);if(this.#a||(this.#a=this.#e.ownerDocument.createElement("style"),this.#a.textContent=Ue+`
4
+ .uplot{color:#333;background:#fff;font-size:12px}.u-legend{font-size:12px;max-height:90px;overflow:auto}`,this.#e.append(this.#a)),n!==this.#r){this.#t?.destroy();let{category:s,fields:l,settings:c,time:p,domains:g}=t,u=this.#e.getBoundingClientRect(),h={x:{time:p,...g?{range:()=>g.dimension.range.map(m=>p?m/1e3:m)}:{}}},b=[{label:s,stroke:"#333",font:"12px sans-serif"}];for(let m of["left","right"]){let f=l.filter((d,y)=>c[y].axis===m);f.length&&(h[m]={time:!1,...g?{range:()=>g.axes[m]}:{}},b.push({scale:m,side:m==="left"?3:1,label:f.join(", "),stroke:"#333",font:"12px sans-serif",grid:{show:m==="left",stroke:"#e5e7eb"}}))}this.#t=new We({width:Math.max(1,Math.round(u.width)),height:Math.max(1,Math.round(u.height)-50),pxAlign:!1,scales:h,axes:b,series:[{label:s},...l.map((m,f)=>({label:m,stroke:c[f].color,scale:c[f].axis,width:1.5}))]},o,this.#e),this.#r=n}else this.#t.setData(o);this.resize()}resize(){if(this.#i||!this.#t)return;let e=this.#e.getBoundingClientRect(),t=this.#t.root.querySelector(".u-legend"),r=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.floor(e.height-t.getBoundingClientRect().height));(this.#t.width!==r||this.#t.height!==o)&&this.#t.setSize({width:r,height:o})}dispose(){this.#i=!0,this.#t?.destroy(),this.#t=null,this.#a?.remove()}};var He={id:"bar",label:"Bars",controls:[],threeD:!1,doc:"Compares values across categories with vertical bars.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar group per value of this column."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var Ye={id:"line",label:"Lines",controls:[],threeD:!1,doc:"Shows how values change along an ordered category, such as time.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var Xe={id:"area",label:"Area",controls:[],threeD:!1,doc:"Shows how values change along an ordered category, filling the area under each line.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var Ke={id:"stackedBar",label:"Stacked bars",controls:[],threeD:!1,doc:"Shows the parts of a total for each category, with the measures stacked in one bar.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar per value of this column."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one segment of the bar."}]};var Ze={id:"stackedArea",label:"Stacked area",controls:[],threeD:!1,doc:"Shows the parts of a total along an ordered category, with the areas stacked.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one stacked layer."}]};var Qe={id:"horizontalBar",label:"Horizontal bars",controls:[],threeD:!1,doc:"Compares values across categories with horizontal bars; suited to long category names.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar group per value of this column, on the vertical axis."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var et={id:"pie",label:"Pie",controls:[],threeD:!1,doc:"Shows the share of each category in a total.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Slice",doc:"One slice per row, named by this column."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The size of each slice; values must not be negative."}]};var tt={id:"donut",label:"Donut",controls:[],threeD:!1,doc:"Shows the share of each category in a total, as a ring.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Slice",doc:"One slice per row, named by this column."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The size of each slice; values must not be negative."}]};var rt={id:"scatter",label:"Scatter",controls:[],threeD:!1,doc:"Shows each row as a point, to reveal relations and clusters.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal position of each point."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of points, at its height."}]};var at={id:"bar3D",label:"3D bars",controls:[],threeD:!0,doc:"Shows a value for each pair of two dimensions as 3D columns.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis of the grid."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis of the grid; it must differ from the first."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of heights on the grid of the two dimensions."}]};var ot={id:"line3D",label:"3D lines",controls:[],threeD:!0,doc:"Shows values along two dimensions as lines in 3D space.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; it must differ from the first."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of heights on the grid of the two dimensions."}]};var it={id:"scatter3D",label:"3D scatter",controls:[],threeD:!0,doc:"Shows each row as a point in 3D space.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis; numeric or date values."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; numeric or date values."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of points, at its height."}]};var nt={id:"surface",label:"Surface",controls:[],threeD:!0,doc:"Shows a measured surface over a grid of two numeric dimensions.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis; numeric or date values, at least two distinct."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; numeric or date values, at least two distinct."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one surface; each coordinate pair appears once."}]};var st={id:"map",label:"2D map",controls:["geoJSON"],threeD:!1,doc:"Colours each territory of a GeoJSON map by one measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name; one row per territory."},{name:"mapValueField",parameter:"mapValueField",count:1,required:!0,dtype:"numeric",caption:"Map measure",doc:"The value that colours each territory."},{name:"mapLabelField",parameter:"mapLabelField",count:1,required:!1,dtype:null,caption:"Map label",doc:"Text or number shown on each territory."}]};var lt={id:"mapBar3D",label:"3D bars on map",controls:["geoJSON","mapBarScale"],threeD:!0,doc:"Raises 3D columns on the territories of a GeoJSON map.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name; one row per territory."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one column per territory; values must not be negative."}]};var ct={id:"map3D",label:"3D map",controls:["geoJSON"],threeD:!0,doc:"Draws the territories of a GeoJSON map in 3D, one map per measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one map; values must not be negative."}]};var dt={id:"lines3D",label:"3D paths",controls:["geoJSON"],threeD:!0,doc:"Draws paths of coordinates on a 3D map.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Path",doc:"The name of each path."},{name:"geometryField",parameter:"geometryField",count:1,required:!0,dtype:null,caption:"Coordinates",doc:"A list of at least two longitude/latitude/altitude coordinates per row."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one set of paths; values must not be negative."}]};var mt={id:"polygons3D",label:"3D polygons",controls:[],threeD:!0,doc:"Draws polygons of coordinates as 3D shapes.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Polygon",doc:"The unique name of each polygon."},{name:"geometryField",parameter:"geometryField",count:1,required:!0,dtype:null,caption:"Coordinates",doc:"Closed coordinate rings per row, including any holes."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one set of polygons; values must not be negative."}]};var ut={id:"funnel",label:"Funnel",controls:[],threeD:!1,domains:!1,doc:"Shows how a quantity shrinks through ordered stages.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Stage",doc:"One stage per row, in row order."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The quantity at each stage; values must not be negative."}]};var pt={id:"radar",label:"Radar",controls:[],threeD:!1,domains:!1,doc:"Compares items on several measures; each measure is an axis, each row a polygon.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Item",doc:"One polygon per row; a row with any empty measure is left out."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one axis of the radar."}]};var ht={id:"parallel",label:"Parallel coordinates",controls:[],threeD:!1,domains:!1,doc:"Compares rows on several measures; each measure is a vertical axis, each row a line across them.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Item",doc:"One line per row."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one axis."}]};var ft={id:"heatmap",label:"Heatmap",controls:[],threeD:!1,domains:!1,doc:"Colours each cell of a grid of two categories by one measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"X category",doc:"The columns of the grid."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Y category",doc:"The rows of the grid; it must differ from the X category."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The colour of each cell; one row per pair of categories."}]};var gt={id:"sankey",label:"Sankey",controls:[],threeD:!1,domains:!1,doc:"Shows flows between nodes; the width of each link is its value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Source",doc:"The node a link starts from."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Target",doc:"The node a link ends at; it must differ from the source column, and links must not form a cycle."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The width of each link; values must not be negative."}]};var yt={id:"candlestick",label:"Candlestick",controls:[],threeD:!1,domains:!1,doc:"Shows the open, high, low and close of each period, as used for prices.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Period",doc:"One candle per row, in row order."},{name:"open",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Open",doc:"The value at the start of the period."},{name:"high",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"High",doc:"The highest value of the period."},{name:"low",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Low",doc:"The lowest value of the period."},{name:"close",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Close",doc:"The value at the end of the period."}]};var bt={id:"boxplot",label:"Boxplot",controls:[],threeD:!1,domains:!1,doc:"Shows the spread of each group with five statistics: minimum, quartiles, median and maximum.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Group",doc:"One box per row."},{name:"min",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Minimum",doc:"The lowest value."},{name:"q1",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"First quartile",doc:"The value below which a quarter of the data falls."},{name:"median",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Median",doc:"The middle value."},{name:"q3",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Third quartile",doc:"The value below which three quarters of the data fall."},{name:"max",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Maximum",doc:"The highest value."}]};var wt={id:"treemap",label:"Treemap",controls:[],threeD:!1,domains:!1,doc:"Shows a hierarchy as nested rectangles whose area is the value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Label",doc:"The attribute that names each node of the nested Bag."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"Carried by the leaves; a parent is the sum of its children. Values must not be negative."}]};var xt={id:"sunburst",label:"Sunburst",controls:[],threeD:!1,domains:!1,doc:"Shows a hierarchy as rings; the angle of each sector is the value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Label",doc:"The attribute that names each node of the nested Bag."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"Carried by the leaves; a parent is the sum of its children. Values must not be negative."}]};var q=[He,Ye,Xe,Ke,Ze,Qe,et,tt,rt,at,ot,it,nt,st,lt,ct,dt,mt,ut,pt,ht,ft,gt,yt,bt,wt,xt],ur=new Map(q.map(a=>[a.id,a]));function pe(a){let e=ur.get(a);if(!e)throw new TypeError("Choose a supported chart type");return e}function G(a,e){return a.syntax.filter(t=>t.parameter===e)}function H(a){let e=G(a,"valueFields");return e.every(t=>t.count===1)?e.map(t=>t.name):[]}function R({view:a,category:e,fields:t,settings:r,domains:o},{seriesType:i,radial:n=!1,horizontal:s=!1,stacked:l=!1,scatter:c=!1,area:p=!1,donut:g=!1}){let{source:u,kind:h}=k(a,e,t,o?.dimension);if(l&&new Set(r.map(f=>f.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(c&&!["value","time"].includes(h))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(n&&u.some(f=>f[1]<0))throw new TypeError("Pie and donut require nonnegative values.");let b=["left","right"].map((f,d)=>({type:"value",position:s?["bottom","top"][d]:f,show:r.some(y=>y.axis===f),name:t.filter((y,x)=>r[x].axis===f).join(", "),...o?{min:o.axes[f][0],max:o.axes[f][1]}:{},splitLine:{show:d===0}})),m={backgroundColor:"#ffffff",useUTC:!0,legend:{show:!0},tooltip:{trigger:n||c?"item":"axis"},grid:{left:80,right:75,top:65,bottom:65}};if(n)m.legend={show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24},m.series=t.map(f=>({id:f,name:f,type:"pie",top:12,bottom:64,left:12,right:12,label:{alignTo:"edge",edgeDistance:10,overflow:"truncate"},labelLayout:{hideOverlap:!0},radius:g?["35%","65%"]:"65%",data:u.map(d=>({name:h==="time"?new Date(d[0]).toISOString().slice(0,10):String(d[0]),value:d[1],...o?{itemStyle:{color:E[o.labels.indexOf(re(d[0],h))%E.length]}}:{}}))}));else{let f=s&&h==="time"?u.map(y=>[new Date(y[0]).toISOString().slice(0,10),...y.slice(1)]):u;m.dataset={source:f,sourceHeader:!1};let d={type:s||h==="value"&&i==="bar"?"category":h};d.type==="value"&&(d.scale=!0),o&&(d.type==="category"?(d.data=o.dimension.values.map(y=>re(y,h)),m.dataset.source=u.map(y=>[re(y[0],h),...y.slice(1)])):(d.min=o.dimension.range[0],d.max=o.dimension.range[1])),m.xAxis=s?b:d,m.yAxis=s?d:b,m.series=t.map((y,x)=>({id:y,name:y,type:i,...i==="line"?{showSymbol:u.length===1}:{},...s?{xAxisIndex:r[x].axis==="right"?1:0}:{yAxisIndex:r[x].axis==="right"?1:0},...l?{stack:"measures"}:{},...p?{areaStyle:{opacity:.3}}:{},itemStyle:{color:r[x].color},lineStyle:{color:r[x].color},encode:s?{x:x+1,y:0}:{x:0,y:x+1}}))}return m}function vt(a,e,t,r,o,i){let n=r.map(h=>U(a,e,t,h,i)),s=n[0]?.dimensions??[[],[]],l=r.length,c=.72,p=l?c/l:0,g=100,u=80;return{backgroundColor:"#ffffff",legend:{show:!0,type:"scroll",left:12,right:12,bottom:10,height:24,data:r},tooltip:{renderMode:"richText",formatter:h=>{let[b,m,f]=h.value;return`${e}: ${s[0][Math.round(b)-1]}
5
+ ${t}: ${s[1][m]}
6
+ ${h.seriesName}: ${f}`}},xAxis3D:{type:"value",name:e,nameGap:35,min:0,max:Math.max(2,s[0].length+1),interval:1,axisLabel:{formatter:h=>s[0][h-1]??""}},yAxis3D:{type:"category",name:t,nameGap:35,data:s[1]},zAxis3D:{type:"value",name:"Value",nameGap:40,...i?{min:i.z[0],max:i.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:g,boxDepth:u,viewControl:{projection:"perspective"},light:{main:{intensity:1.2},ambient:{intensity:.4}}},series:r.map((h,b)=>({id:h,name:h,type:"bar3D",shading:"lambert",barSize:[g/Math.max(2,s[0].length+1)*p*.85,u/Math.max(1,s[1].length)*.55],data:n[b].source.map(([m,f,d])=>[m+1+(b-(l-1)/2)*p,f,d]),itemStyle:{color:o[b].color}}))}}function St(a,e,t,r,o,i,n){let s=a.getRows(),l=m=>s.every(f=>{let d=a.value(f,m);return typeof d=="number"&&Number.isFinite(d)||d instanceof Date&&Number.isFinite(d.getTime())}),c=[t,r].map((m,f)=>({numeric:n?n.dimensions[f].kind!=="category":l(m),date:n?n.dimensions[f].kind==="time":s.length>0&&a.value(s[0],m)instanceof Date}));if(["scatter3D","surface"].includes(e)&&c.some(m=>!m.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let p=o.map(m=>U(a,t,r,m,n)),g=p[0]?.dimensions??[[],[]],u=g.map((m,f)=>m.map((d,y)=>c[f].numeric?c[f].date?Date.parse(d):Number(d):y)),h=m=>({type:c[m].numeric?"value":"category",name:[t,r][m],nameGap:35,...c[m].numeric?n?{min:n.dimensions[m].range[0],max:n.dimensions[m].range[1]}:{}:{data:g[m]},...c[m].date?{axisLabel:{formatter:f=>new Date(f).toISOString().slice(0,10)}}:{}}),b=[];return p.forEach((m,f)=>{let d={name:o[f],type:e,itemStyle:{color:i[f].color},lineStyle:{color:i[f].color,width:3}},y=m.source.map(([x,v,T])=>[u[0][x],u[1][v],T]);if(e==="line3D")g[1].forEach((x,v)=>{let T=m.source.filter(C=>C[1]===v).map(([C,,w])=>[u[0][C],u[1][v],w]).sort((C,w)=>C[0]-w[0]);b.push({...d,id:`${o[f]}:${v}`,data:T})});else if(e==="surface"){let x=[...u[0]].sort((C,w)=>C-w),v=[...u[1]].sort((C,w)=>C-w),T=new Map;for(let[C,w,S]of y){let M=JSON.stringify([C,w]);if(T.has(M))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");T.set(M,S)}if(x.length<2||v.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");b.push({...d,id:o[f],dataShape:[v.length,x.length],shading:"lambert",itemStyle:{color:i[f].color,opacity:o.length>1?.7:1},data:v.flatMap(C=>x.map(w=>[w,C,T.get(JSON.stringify([w,C]))??NaN]))})}else b.push({...d,id:o[f],symbolSize:9,data:y})}),{backgroundColor:"#fff",legend:{type:"scroll",left:12,right:12,bottom:10,data:o},tooltip:{renderMode:"richText"},xAxis3D:h(0),yAxis3D:h(1),zAxis3D:{type:"value",name:"Value",nameGap:40,...n?{min:n.z[0],max:n.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:100,boxDepth:80,viewControl:{projection:"perspective"}},series:b}}function qe(a){return Array.isArray(a)&&a.length>=2&&a.length<=3&&a.every(Number.isFinite)}function he(a){return Array.isArray(a)&&a.length>0&&a.every(e=>Array.isArray(e)&&e.length>=4&&e.every(qe)&&JSON.stringify(e[0])===JSON.stringify(e.at(-1)))}function Tt(a,e,t){if(!t)throw new TypeError("Choose the coordinate field");let r=new Set;return{type:"FeatureCollection",features:a.getRows().map(i=>{let n=String(a.value(i,e)),s=a.value(i,t);if(r.has(n))throw new TypeError("Polygon names must be unique");if(r.add(n),!he(s))throw new TypeError("Polygons require closed coordinate rings, including any holes");return{type:"Feature",properties:{name:n},geometry:{type:"Polygon",coordinates:s}}})}}function Ct(a,e,t,r,o,i,n,s){if(!s||s.type!=="FeatureCollection"||!Array.isArray(s.features))throw new TypeError("Provide a GeoJSON FeatureCollection in configuration.geoJSON");for(let b of s.features)if(b.type!=="Feature"||!["Polygon","MultiPolygon"].includes(b.geometry?.type)||typeof b.properties?.name!="string")throw new TypeError("Map features require Polygon/MultiPolygon geometry and properties.name");let l=a.getRows();if(e!=="map3D"&&!r)throw new TypeError("Choose the coordinate field");let c=e==="map3D"?k(a,t,o).source:null;if(c&&new Set(c.map(b=>b[0])).size!==c.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let p=e==="lines3D"?l.map(b=>{let m=a.value(b,r);if(!Array.isArray(m)||m.length<2||!m.every(qe))throw new TypeError("Paths require a list of at least two longitude/latitude/altitude coordinates");return m}):[],g=[],u=[],h=[];return o.forEach((b,m)=>{let f={left:`${m*100/o.length}%`,width:`${100/o.length}%`,top:35,bottom:60,height:null};h.push({text:b,left:`${(m+.5)*100/o.length}%`,top:8,textAlign:"center",textStyle:{fontSize:13,color:"#333"}});let d=e==="map3D"?c.map(x=>({name:String(x[0]),value:x[m+1]})):l.map(x=>({name:String(a.value(x,t)),value:a.value(x,b)}));if(d.some(x=>typeof x.value!="number"||!Number.isFinite(x.value)||x.value<0))throw new TypeError("Geographic measures require finite nonnegative values");let y={id:b,name:b,type:e,itemStyle:{color:i[m].color},shading:"lambert"};if(e!=="lines3D")g.push({...y,type:"map3D",...f,map:n,label:{show:!0},data:d.map(x=>({...x,height:x.value})),viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});else{u.push({...f,map:n,regionHeight:0,itemStyle:{color:"#e8edf1",opacity:.5},viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});let x=d.map((v,T)=>({...v,coords:p[T],height:v.value}));g.push({...y,coordinateSystem:"geo3D",geo3DIndex:m,data:x,polyline:!0,silent:!1,lineStyle:{color:i[m].color,width:4,opacity:1}})}}),{backgroundColor:"#fff",title:h,legend:{type:"scroll",data:o,left:12,right:12,bottom:10},tooltip:{renderMode:"richText"},geo3D:u,series:g}}import{sharedModules as pr}from"@gramlot/gramlot";var hr=a=>pr["./components/bases.js"][a];var Ft=hr("controlElement");function oe(a){if(a?.type!=="FeatureCollection"||!Array.isArray(a.features)||!a.features.length)throw new TypeError("Choose a GeoJSON FeatureCollection containing territories.");let e=new Set;for(let t of a.features){let r=t.properties?.name,o=t.geometry;if(t.type!=="Feature"||typeof r!="string"||!r.trim())throw new TypeError("Every territory needs a nonempty properties.name.");if(e.has(r))throw new TypeError(`Duplicate territory name: ${r}`);if(e.add(r),!o||!["Polygon","MultiPolygon"].includes(o.type))throw new TypeError("Territories must use Polygon or MultiPolygon geometry.");let i=o.type==="Polygon"?[o.coordinates]:o.coordinates;if(!Array.isArray(i)||!i.length||!i.every(he))throw new TypeError(`Invalid or unclosed coordinate rings: ${r}`)}return a}var Dt=(0,I.defineComponent)({name:"chartGeoJSON",tag:"gramlot-chart-geo-json",base:Ft,sourceContext:!0,parameters:{value:{dtype:"X",nullable:!0,default:null,binding:"twoWay"}},implementation:a=>class extends a{#e;#t=0;constructor(){super();let e=this.ownerDocument;this.control=e.createElement("input"),this.control.type="file",this.control.accept=".geojson,.json,application/geo+json,application/json",this.control.setAttribute("aria-label","Load GeoJSON"),this.control.style.cssText="width:100%;min-width:0;font:inherit",this.message=e.createElement("div"),this.message.setAttribute("role","status"),this.message.style.cssText="font-size:11px;overflow-wrap:anywhere",this.controlBox.append(this.control,this.message),this.control.addEventListener("change",t=>{t.stopPropagation(),this.#r()})}readControlValue(){return this.parameters.value}writeControlValue(e){this.parameters.value=e,this.#a()}setSourceContext(e){this.#e=e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#t++,this.#a(),r}#a(){let e=this.parameters.value;this.message.textContent=e?`${e.features.length} territories${e.features.length<=3?": "+e.features.map(t=>t.properties.name).join(", "):" loaded"}`:"No GeoJSON loaded"}async#r(){let e=this.control.files[0];if(!e)return;let t=++this.#t;try{let r=oe(JSON.parse(await e.text()));if(t!==this.#t||!this.isConnected)return;this.control.value="",this.#e.writeParameter("value",r)}catch(r){t===this.#t&&this.isConnected&&(this.message.textContent=`GeoJSON not loaded: ${r.message}`)}finally{t===this.#t&&(this.control.value="")}}disconnectedCallback(){this.#t++}}});function fe(a){let e=t=>Math.abs(t.slice(1).reduce((r,o,i)=>r+t[i][0]*o[1]-o[0]*t[i][1],0));return new Map(a.features.map(t=>{let o=[...t.geometry.type==="Polygon"?[t.geometry.coordinates]:t.geometry.coordinates].sort((c,p)=>e(p[0])-e(c[0]))[0],i=o[0].map(c=>c[1]),n=[...new Set(i)].sort((c,p)=>c-p),s=(n[0]+n.at(-1))/2,l=n.slice(1).map((c,p)=>(n[p]+c)/2).sort((c,p)=>Math.abs(c-s)-Math.abs(p-s));for(let c of l){let p=[];for(let u of o)for(let h=1;h<u.length;h++){let b=u[h-1],m=u[h];b[1]>c!=m[1]>c&&p.push(b[0]+(c-b[1])*(m[0]-b[0])/(m[1]-b[1]))}p.sort((u,h)=>u-h);let g=null;for(let u=0;u+1<p.length;u+=2)p[u+1]>p[u]&&(!g||p[u+1]-p[u]>g[1]-g[0])&&(g=[p[u],p[u+1]]);if(g)return[t.properties.name,[(g[0]+g[1])/2,c]]}throw new TypeError(`Territory has no drawable interior: ${t.properties.name}`)}))}function Mt({view:a,category:e,fields:t,settings:r,structure:o,seriesOptions:i,domains:n},s){let l=oe(o.getItem("geoJSON")),c=o.getItem("mapBarScale")??"zero";if(!["zero","extent"].includes(c))throw new TypeError("Choose zero or extent for geographic bar heights");let p=fe(l),{source:g}=k(a,e,t);if(new Set(g.map(F=>String(F[0]))).size!==g.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let u=g.filter(F=>p.has(String(F[0])));if(g.length&&!u.length)throw new TypeError("No store territories match GeoJSON properties.name");let h=u.flatMap(F=>F.slice(1));if(h.some(F=>!Number.isFinite(F)||F<0))throw new TypeError("Geographic bars require finite nonnegative measures");let b=n?n.z:J(h,c==="zero"),m=c==="zero"?0:b[0],f=b[1],d=l.features.flatMap(F=>(F.geometry.type==="Polygon"?[F.geometry.coordinates]:F.geometry.coordinates).flatMap(D=>D[0].map($=>$[0]))),[y,x]=d.reduce(([F,D],$)=>[Math.min(F,$),Math.max(D,$)],[1/0,-1/0]),v=x-y,T=.45,C=v/100*T*1.25,w=F=>i.getItem(F).getItem("caption")||F,S=t.map((F,D)=>({id:F,name:w(F),type:"bar3D",coordinateSystem:"geo3D",geo3DIndex:0,barSize:T,shading:"lambert",itemStyle:{color:r[D].color},label:{show:!1},emphasis:{label:{show:!0,formatter:$=>Number($.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}},data:u.map($=>{let[j,Qt]=p.get(String($[0]));return{name:String($[0]),value:[j+(D-(t.length-1)/2)*C,Qt,$[D+1]]}})})),M=p.values().next().value;return S.push({id:"map-height-reference",type:"scatter3D",coordinateSystem:"geo3D",geo3DIndex:0,silent:!0,symbolSize:0,itemStyle:{opacity:0},label:{show:!1},tooltip:{show:!1},data:[[...M,m],[...M,f]]}),{backgroundColor:"#fff",legend:{type:"scroll",data:t.map(w),bottom:8},title:{text:c==="zero"?"Geographic bars \xB7 baseline 0":"Geographic bars \xB7 truncated baseline",left:"center",top:8,textStyle:{fontSize:14,color:"#27344b"}},tooltip:{renderMode:"richText",formatter:F=>`${F.name}
7
+ ${F.seriesName}: ${Number(F.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}`},geo3D:{map:s,top:35,bottom:45,boxWidth:100,boxHeight:35,regionHeight:.15,itemStyle:{color:"#d9e3eb",borderColor:"#8e9ca9",borderWidth:.3},label:{show:!1},shading:"lambert",viewControl:{projection:"perspective",distance:145,minDistance:30,maxDistance:300,alpha:45,beta:0}},series:S}}function ge(a,e,t="value"){if(!["none","name","value","nameValue"].includes(t))throw new TypeError("Choose a supported map label mode");if(t==="none"||!Number.isFinite(e))return"";let r=e.toLocaleString("en-GB",{notation:"compact",maximumFractionDigits:1});return t==="name"?a:t==="value"?r:`${a}
8
+ ${r}`}var ye=["#77bce4","#307eb9","#083e80"];function be(a,e,t,r,o){if(oe(o),!t)throw new TypeError("Choose a map measure");let{source:i}=k(a,e,[t]);if(new Set(i.map(h=>String(h[0]))).size!==i.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let n=new Map;for(let h of a.getRows()){let b=String(a.value(h,e)),m=a.value(h,r);if(typeof m!="string"&&typeof m!="number")throw new TypeError("Choose a text or numeric map label field");if(n.has(b)&&n.get(b)!==String(m))throw new TypeError("Map labels must be consistent for each territory");n.set(b,String(m))}let s=new Set(o.features.map(h=>h.properties.name)),l=i.filter(h=>s.has(String(h[0]))).map(([h,b])=>({name:String(h),value:b}));if(i.length&&!l.length)throw new TypeError("No store territories match GeoJSON properties.name");let c=l.map(h=>h.value),p=c.some(h=>h<0),g=c.length?Math.min(...c):0,u=c.length?Math.max(...c):1;if(p)u=Math.max(Math.abs(g),Math.abs(u)),g=-u;else if(g===u){let h=Math.abs(u)*.01||1;g=Math.max(0,g-h),u+=h}return{data:l,labels:n,min:g,max:u,signed:p}}function It(a,e,t,r,o,i,n,s,l="value"){let{data:c,labels:p,...g}=be(a,e,t,r,i),{min:u,max:h,signed:b}=s?s.map:g,m=d=>Number(d).toLocaleString("en-GB",{maximumFractionDigits:2}),f=n||t;return{backgroundColor:"#fff",title:{text:f,left:"center",top:8,textStyle:{color:"#27344b",fontSize:14}},tooltip:{trigger:"item",renderMode:"richText",formatter:d=>`${p.get(d.name)||d.name}
9
+ ${f}: ${Number.isFinite(d.value)?m(d.value):"No data"}`},visualMap:{type:"continuous",min:u,max:h,seriesIndex:0,dimension:0,calculable:!0,orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:180,precision:2,formatter:m,textStyle:{color:"#27344b"},inRange:{color:b?["#b73548","#f7f7f7","#2166ac"]:ye},outOfRange:{color:"#e2e5e9"}},series:[{name:f,type:"map",map:o,preserveAspect:"contain",aspectScale:1,roam:!0,top:42,bottom:70,left:20,right:20,itemStyle:{areaColor:"#e2e5e9",borderColor:"#fff",borderWidth:.45},label:{show:!0,color:"#182c46",fontSize:11,textBorderColor:"#fff",textBorderWidth:3,formatter:d=>ge(p.get(d.name)||d.name,d.value,l)},labelLayout:{hideOverlap:!0},emphasis:{label:{show:!0},itemStyle:{borderColor:"#1b273d",borderWidth:2}},data:c}]}}import{Bag as fr}from"@gramlot/gramlot";function _(a,e,t){let r=a.value(e,t);if(r==null)return null;if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Measure ${t} requires finite numeric values or empty cells`);return r}function O(a,e){if(a instanceof Date&&Number.isFinite(a.getTime()))return a.toISOString().slice(0,10);if(["string","number","boolean"].includes(typeof a)&&!(typeof a=="number"&&!Number.isFinite(a)))return String(a);throw new TypeError(`Choose a ${e} column with text, numeric, boolean or date values`)}function N(a,e){let t=a?.getItem(e)?.getItem("caption");return typeof t=="string"&&t?t:e}function Y(a,e,t){let r=a?.getItem(e)?.getItem(t);return typeof r=="number"&&Number.isFinite(r)?r:null}function _e(a,e,t){let r=a?.getItem(e)?.getItem(t);return typeof r=="string"&&r?r:null}function we({view:a,category:e,fields:t},r,o){if(a.rowMode!=="attributes")throw new TypeError(`${r} needs rowMode='attributes': each node carries the caption and the measure as attributes.`);let[i]=t,n={value:(c,p)=>c.getAttr(p)},s=(c,p,g)=>c.flatMap(u=>{let h=O(p.value(u,e),e),b=u.staticValue;if(b instanceof fr){if(u.getAttr(i)!=null)throw new TypeError(`Node ${h} has children and carries ${i}: the value of a parent is the sum of its children. Remove the attribute from ${h}.`);let f=s(b.getNodes(),n,g);return f.length?[{name:h,value:f.reduce((d,y)=>d+y.value,0),children:f,itemStyle:{color:g}}]:[]}let m=_(p,u,i);if(m===null)return[];if(m<0)throw new TypeError(`Node ${h} has a negative ${i}: areas cannot be negative.`);return[{name:h,value:m,itemStyle:{color:g}}]});return a.getRows().flatMap((c,p)=>s([c],a,o[p%o.length]))}function Et({view:a,category:e,fields:t,seriesOptions:r}){let[o]=t,i=[];for(let n of a.getRows()){let s=_(a,n,o);if(s===null)continue;if(s<0)throw new TypeError("Funnel requires nonnegative values.");let l=O(a.value(n,e),e);i.push({name:l,value:s,itemStyle:{color:E[i.length%E.length]}})}return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},legend:{show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24,data:i.map(n=>n.name)},series:[{id:o,name:N(r,o),type:"funnel",top:20,bottom:64,left:"10%",width:"80%",sort:"none",gap:2,label:{show:!0,position:"inside"},data:i}]}}function $t({view:a,category:e,fields:t,seriesOptions:r}){let o=[];for(let n of a.getRows()){let s=t.map(l=>_(a,n,l));s.some(l=>l===null)||o.push({name:O(a.value(n,e),e),values:s})}let i=t.map((n,s)=>{let l=o.map(g=>g.values[s]).filter(g=>g!==null),c=Y(r,n,"min")??Math.min(0,...l),p=Y(r,n,"max")??(l.length?Math.max(...l):1);return p<=c&&(p=c+1),{name:N(r,n),min:c,max:p}});return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},legend:{show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24,data:o.map(n=>n.name)},radar:{indicator:i,center:["50%","48%"],radius:"62%"},series:[{type:"radar",areaStyle:{opacity:.15},data:o.map((n,s)=>({name:n.name,value:n.values,itemStyle:{color:E[s%E.length]},lineStyle:{color:E[s%E.length]}}))}]}}function kt({view:a,category:e,fields:t,seriesOptions:r}){let o=[];for(let n of a.getRows()){let s=t.map(l=>_(a,n,l));s.every(l=>l===null)||o.push({name:O(a.value(n,e),e),values:s})}let i=t.map((n,s)=>{let l={dim:s,name:N(r,n)},c=Y(r,n,"min"),p=Y(r,n,"max");return c!==null&&(l.min=c),p!==null&&(l.max=p),l});return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},parallel:{left:60,right:60,top:60,bottom:40,parallelAxisDefault:{type:"value",nameLocation:"start",nameGap:20}},parallelAxis:i,series:[{type:"parallel",lineStyle:{width:2,opacity:.7},emphasis:{lineStyle:{width:4,opacity:1}},data:o.map((n,s)=>({name:n.name,value:n.values,lineStyle:{color:E[s%E.length]}}))}]}}function Nt({view:a,category:e,structure:t,fields:r,settings:o,seriesOptions:i}){let n=t.getItem("secondCaptionField"),[s]=r,l=[],c=[],p=new Map,g=new Map,u=new Set,h=[],b=(y,x,v)=>(x.has(v)||(x.set(v,y.length),y.push(v)),x.get(v));for(let y of a.getRows()){let x=b(l,p,O(a.value(y,e),e)),v=b(c,g,O(a.value(y,n),n)),T=_(a,y,s);if(T===null)continue;let C=`${x}:${v}`;if(u.has(C))throw new TypeError(`Heatmap has two cells for ${l[x]} / ${c[v]}. Prepare one row per pair upstream.`);u.add(C),h.push([x,v,T])}let m=h.length?Math.min(...h.map(y=>y[2])):0,f=h.length?Math.max(...h.map(y=>y[2])):1;m===f&&(m-=1,f+=1);let d=N(i,s);return{backgroundColor:"#ffffff",tooltip:{trigger:"item",position:"top"},grid:{left:80,right:40,top:36,bottom:110},xAxis:{type:"category",data:l,name:e,splitArea:{show:!0}},yAxis:{type:"category",data:c,name:n,splitArea:{show:!0}},visualMap:{type:"continuous",min:m,max:f,calculable:!0,orient:"horizontal",left:"center",bottom:10,inRange:{color:["#f3f6fb",o[0].color]}},series:[{id:s,name:d,type:"heatmap",data:h,emphasis:{itemStyle:{borderColor:"#333",borderWidth:1}}}]}}function gr(a){let e=new Map;for(let{source:i,target:n}of a)e.has(i)||e.set(i,[]),e.get(i).push(n);let t=new Map,r=[],o=i=>{t.set(i,1),r.push(i);for(let n of e.get(i)??[]){if(t.get(n)===1)return[...r.slice(r.indexOf(n)),n];if(!t.has(n)){let s=o(n);if(s)return s}}return r.pop(),t.set(i,2),null};for(let i of e.keys())if(!t.has(i)){let n=o(i);if(n)return n}return null}function Ot({view:a,category:e,structure:t,fields:r,seriesOptions:o}){let i=t.getItem("secondCaptionField"),[n]=r,s=new Set,l=[];for(let p of a.getRows()){let g=O(a.value(p,e),e),u=O(a.value(p,i),i),h=_(a,p,n);if(h!==null){if(h<0)throw new TypeError("Sankey requires nonnegative link values.");s.add(g),s.add(u),l.push({source:g,target:u,value:h})}}let c=gr(l);if(c)throw new TypeError(`Sankey links contain a cycle: ${c.join(" \u2192 ")}. Remove or reverse one link.`);return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},series:[{id:n,name:N(o,n),type:"sankey",left:20,right:120,top:20,bottom:20,emphasis:{focus:"adjacency"},lineStyle:{color:"gradient",curveness:.5},data:[...s].map(p=>({name:p})),links:l}]}}function qt({view:a,category:e,fields:t,seriesOptions:r}){let[o,i,n,s]=t,l=[],c=[];for(let h of a.getRows()){let b=t.map(m=>_(a,h,m));b.some(m=>m===null)||(l.push(O(a.value(h,e),e)),c.push([b[0],b[3],b[2],b[1]]))}let p=_e(r,o,"upColor"),g=_e(r,o,"downColor"),u={};return p&&(u.color=p,u.borderColor=p),g&&(u.color0=g,u.borderColor0=g),{backgroundColor:"#ffffff",tooltip:{trigger:"axis",axisPointer:{type:"cross"}},grid:{left:60,right:30,top:30,bottom:70},xAxis:{type:"category",data:l,name:e,boundaryGap:!0},yAxis:{type:"value",scale:!0},dataZoom:[{type:"inside"}],series:[{id:o,name:N(r,o),type:"candlestick",data:c,itemStyle:u}]}}function _t({view:a,category:e,fields:t,seriesOptions:r}){let o=[],i=[];for(let n of a.getRows()){let s=t.map(c=>_(a,n,c));if(s.some(c=>c===null))continue;let l=O(a.value(n,e),e);if(s.some((c,p)=>p>0&&c<s[p-1]))throw new TypeError(`Boxplot row ${l} must satisfy min <= q1 <= median <= q3 <= max.`);o.push(l),i.push(s)}return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},grid:{left:60,right:30,top:30,bottom:50},xAxis:{type:"category",data:o,name:e,boundaryGap:!0},yAxis:{type:"value",scale:!0},series:[{id:t[0],name:N(r,t[0]),type:"boxplot",data:i}]}}function At(a){let e=we(a,"Treemap",E),[t]=a.fields;return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},series:[{id:t,name:N(a.seriesOptions,t),type:"treemap",left:10,right:10,top:10,bottom:30,roam:!1,nodeClick:"zoomToNode",breadcrumb:{show:!0,bottom:4},label:{show:!0,formatter:"{b}"},itemStyle:{borderColor:"#ffffff",borderWidth:1,gapWidth:1},levels:[{itemStyle:{borderWidth:0,gapWidth:6},upperLabel:{show:!0,height:24,color:"#333333",fontWeight:"bold"}},{itemStyle:{borderWidth:0,gapWidth:3},upperLabel:{show:!0,height:20,color:"#555555"}},{itemStyle:{gapWidth:1}}],data:e}]}}function Pt(a){let e=we(a,"Sunburst",E),[t]=a.fields;return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},series:[{id:t,name:N(a.seriesOptions,t),type:"sunburst",radius:[0,"92%"],center:["50%","50%"],sort:null,nodeClick:"rootToNode",label:{rotate:"radial",minAngle:8},itemStyle:{borderColor:"#ffffff",borderWidth:1},data:e}]}}var X,xe=class{static label="ECharts";static async load(e,t){X=await P("echarts",t,()=>import("./modules/echarts.esm.min-VHLRZDVQ.js")),pe(e).threeD&&(t.defaultView.echarts=X,await P("echartsGl",t,()=>import("./modules/echarts-gl.min-N6L67H2M.js")))}#e;#t;#a;#r;#i;#o=`chart_${B()}`;#n;constructor(e,t={}){this.#a=e,this.#r=t,this.#i=t.renderer??"canvas",this.#e=X.init(e,null,t),this.#c()}#c(){this.#e.on("click",e=>{this.#t==="mapBar3D"&&e.seriesType==="bar3D"&&this.#r.onTerritorySelect?.(e.name),this.#t==="map"&&e.componentType==="series"&&e.seriesType==="map"&&this.#r.onTerritorySelect?.(e.name)})}validate(e){return this[`render_${e.type.id}`](e)}update(e,t){this.#t=e.type.id;let r=e.type.threeD?"canvas":this.#r.renderer??"canvas";r!==this.#i&&(this.#e.dispose(),this.#e=X.init(this.#a,null,{...this.#r,renderer:r}),this.#i=r,this.#c()),this.#e.setOption(t,{notMerge:!0})}render_bar(e){return R(e,{seriesType:"bar"})}render_line(e){return R(e,{seriesType:"line"})}render_area(e){return R(e,{seriesType:"line",area:!0})}render_stackedBar(e){return R(e,{seriesType:"bar",stacked:!0})}render_stackedArea(e){return R(e,{seriesType:"line",area:!0,stacked:!0})}render_horizontalBar(e){return R(e,{seriesType:"bar",horizontal:!0})}render_pie(e){return R(e,{seriesType:"pie",radial:!0})}render_donut(e){return R(e,{seriesType:"pie",radial:!0,donut:!0})}render_scatter(e){return R(e,{seriesType:"scatter",scatter:!0})}render_bar3D({view:e,category:t,structure:r,fields:o,settings:i,domains:n}){return vt(e,t,r.getItem("secondCaptionField"),o,i,n)}render_line3D(e){return this.#d(e,"line3D")}render_scatter3D(e){return this.#d(e,"scatter3D")}render_surface(e){return this.#d(e,"surface")}#d({view:e,category:t,structure:r,fields:o,settings:i,domains:n},s){return St(e,s,t,r.getItem("secondCaptionField"),o,i,n)}#l(e){return e!==this.#n&&(X.registerMap(this.#o,e),this.#n=e),this.#o}render_map({view:e,category:t,structure:r,seriesOptions:o,domains:i}){let n=r.getItem("mapValueField"),s=r.getItem("geoJSON"),l=It(e,t,n,r.getItem("mapLabelField"),this.#o,s,o.getItem(n)?.getItem("caption"),i,r.getItem("mapLabelMode")??"value");return this.#l(s),l}render_mapBar3D(e){let t=e.structure.getItem("geoJSON"),r=Mt(e,this.#o);return this.#l(t),r}render_map3D(e){return this.#m(e,"map3D",e.structure.getItem("geoJSON"))}render_lines3D(e){return this.#m(e,"lines3D",e.structure.getItem("geoJSON"))}render_polygons3D(e){return this.#m(e,"polygons3D",Tt(e.view,e.category,e.structure.getItem("geometryField")))}#m({view:e,category:t,structure:r,fields:o,settings:i},n,s){let l=Ct(e,n,t,r.getItem("geometryField"),o,i,this.#o,s);return this.#l(s),l}render_funnel(e){return Et(e)}render_radar(e){return $t(e)}render_parallel(e){return kt(e)}render_heatmap(e){return Nt(e)}render_sankey(e){return Ot(e)}render_candlestick(e){return qt(e)}render_boxplot(e){return _t(e)}render_treemap(e){return At(e)}render_sunburst(e){return Pt(e)}svg(){return this.#e.renderToSVGString()}resize(){this.#e.resize()}dispose(){this.#e.dispose(),this.#n&&X.registerMap(this.#o,{type:"FeatureCollection",features:[]})}};function ve({view:a,category:e,structure:t,fields:r,settings:o,domains:i},n,s){let l=t.getItem("secondCaptionField"),c=a.getRows(),p=[e,l].map((f,d)=>({field:f,numeric:i?i.dimensions[d].kind!=="category":c.every(y=>{let x=a.value(y,f);return typeof x=="number"&&Number.isFinite(x)||x instanceof Date&&Number.isFinite(x.getTime())}),date:i?i.dimensions[d].kind==="time":c.length>0&&a.value(c[0],f)instanceof Date}));if(n!=="line3D"&&p.some(f=>!f.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let g=r.map(f=>U(a,e,l,f,i)),u=g[0]?.dimensions??[[],[]],h=u.map((f,d)=>f.map((y,x)=>p[d].numeric?p[d].date?Date.parse(y):Number(y):x)),b=f=>({title:{text:p[f].field},type:p[f].date?"date":"linear",...p[f].numeric?i?{range:i.dimensions[f].range,autorange:!1}:{}:{tickvals:h[f],ticktext:u[f],...i?{range:[-.5,u[f].length-.5],autorange:!1}:{}}});s.scene={xaxis:b(0),yaxis:b(1),zaxis:{title:{text:"Value"},...i?{range:i.z,autorange:!1}:{}},aspectmode:"cube"};let m=[];return g.forEach((f,d)=>{let y=o[d].color,x={name:r[d],legendgroup:r[d],showlegend:!0},v=f.source.map(([T,C,w])=>[h[0][T],h[1][C],w]);if(n==="surface"){let T=[...h[0]].sort((S,M)=>S-M),C=[...h[1]].sort((S,M)=>S-M),w=new Map;for(let[S,M,F]of v){let D=JSON.stringify([S,M]);if(w.has(D))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");w.set(D,F)}if(T.length<2||C.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");m.push({...x,type:"surface",x:T,y:C,z:C.map(S=>T.map(M=>w.get(JSON.stringify([M,S]))??null)),connectgaps:!1,colorscale:[[0,y],[1,y]],showscale:!1,opacity:r.length>1?.7:1})}else n==="line3D"?u[1].forEach((T,C)=>{let w=f.source.filter(S=>S[1]===C).map(([S,,M])=>[h[0][S],h[1][C],M]).sort((S,M)=>S[0]-M[0]);m.push({...x,showlegend:C===0,type:"scatter3d",mode:w.length===1?"lines+markers":"lines",x:w.map(S=>S[0]),y:w.map(S=>S[1]),z:w.map(S=>S[2]),line:{color:y,width:4},marker:{color:y,size:4}})}):m.push({...x,type:"scatter3d",mode:"markers",x:v.map(T=>T[0]),y:v.map(T=>T[1]),z:v.map(T=>T[2]),marker:{color:y,size:4}})}),{data:m,layout:s}}function zt({view:a,category:e,structure:t,seriesOptions:r,domains:o},i){let n=t.getItem("mapValueField"),s=t.getItem("geoJSON"),{data:l,labels:c,...p}=be(a,e,n,t.getItem("mapLabelField"),s),{min:g,max:u,signed:h}=o?o.map:p,b=w=>w.map((S,M)=>{let F=S.slice(1).reduce((D,$,j)=>D+S[j][0]*$[1]-$[0]*S[j][1],0);return(M===0?F>0:F<0)?[...S].reverse():S}),m={...s,features:s.features.map(w=>({...w,geometry:{...w.geometry,coordinates:w.geometry.type==="Polygon"?b(w.geometry.coordinates):w.geometry.coordinates.map(b)}}))},f=r.getItem(n)?.getItem("caption")||n;i.title={text:f},i.showlegend=!1,i.margin={l:10,r:70,t:45,b:20},i.geo={visible:!1,showframe:!1,showcoastlines:!1,showland:!1,showocean:!1,showcountries:!1,showlakes:!1,showrivers:!1,fitbounds:"geojson",projection:{type:"mercator"},bgcolor:"#fff"};let d=h?["#b73548","#f7f7f7","#2166ac"]:ye,y={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:l.map(w=>w.name),z:l.map(w=>w.value),zmin:g,zmax:u,colorscale:d.map((w,S)=>[S/2,w]),marker:{line:{color:"#fff",width:.45}},colorbar:{title:{text:f},thickness:14},hovertemplate:"%{location}<br>%{z:.2f}<extra></extra>"},x=fe(s),v=l.map(w=>({name:w.name,value:w.value,point:x.get(w.name)})),T=s.features.map(w=>w.properties.name).filter(w=>!l.some(S=>S.name===w)),C={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:T,z:T.map(()=>0),colorscale:[[0,"#e2e5e9"],[1,"#e2e5e9"]],showscale:!1,marker:{line:{color:"#fff",width:.45}},hovertemplate:"%{location}<br>No data<extra></extra>"};return{layout:i,data:[C,y,{type:"scattergeo",mode:"text",showlegend:!1,hoverinfo:"skip",lon:v.map(w=>w.point[0]),lat:v.map(w=>w.point[1]),text:v.map(w=>ge(c.get(w.name)||w.name,w.value,t.getItem("mapLabelMode")??"value")),textfont:{color:"#182c46",size:11}}]}}var yr,ie,Se=class{static label="Plotly";static async load(e,t){ie=await(yr??=P("plotly",t,()=>import("./modules/plotly.min-SSDU2DOH.js")).then(r=>r.default))}#e;#t;#a;#r=!1;#i;#o=!1;#n=Promise.resolve();#c=!1;constructor(e,t={}){this.#e=e,this.#t=t}validate(e){return this[`render_${e.type.id}`](e)}update(e,t,r=()=>!0){let o=async()=>{if(this.#o||!r())return;this.#i||(this.#i=this.#e.ownerDocument.createElement("style"),this.#i.textContent=`.js-plotly-plot,.js-plotly-plot div{margin:0;padding:0;border:0}
37
10
  .js-plotly-plot .main-svg{position:absolute;top:0;left:0;pointer-events:none}
38
11
  .js-plotly-plot .main-svg .draglayer{pointer-events:all}
39
12
  .js-plotly-plot .user-select-none{user-select:none;-webkit-user-select:none}
40
- .js-plotly-plot .crisp{shape-rendering:crispEdges}`,this.#e.parentElement.append(this.#n));let o=this.#e.getBoundingClientRect();await Nr.react(this.#e,r.data,{...r.layout,width:Math.max(1,o.width),height:Math.max(1,o.height)},{displayModeBar:!1,responsive:!1,displaylogo:!1,scrollZoom:e.type.id==="map"}),this.#i?Nr.purge(this.#e):(this.#u=!0,this.#s=e.type.id,this.#r||(this.#e.on("plotly_click",a=>{let l=a.points[0];this.#s==="map"&&l?.data.type==="choropleth"&&this.#t.onTerritorySelect?.(l.location)}),this.#e.on("plotly_afterplot",()=>this.#c()),this.#r=!0),this.#c())},s=this.#o.then(i);return this.#o=s.catch(()=>{}),s}#c(){if(this.#s!=="map"||this.#i)return;let e=[],r=this.#e.getBoundingClientRect();for(let n of this.#e.querySelectorAll(".scattergeo text")){n.style.visibility="visible",n.style.pointerEvents="none";let i=n.getBoundingClientRect(),s=e.some(a=>i.left<a.right+4&&i.right>a.left-4&&i.top<a.bottom+2&&i.bottom>a.top-2),o=i.left<r.left||i.right>r.right||i.top<r.top||i.bottom>r.bottom;s||o?n.style.visibility="hidden":n.textContent&&e.push(i)}}render_bar(e){return this.#a(e,{type:"bar"})}render_line(e){return this.#a(e,{type:"scatter"})}render_area(e){return this.#a(e,{type:"scatter",area:!0})}render_stackedBar(e){return this.#a(e,{type:"bar",stacked:!0})}render_stackedArea(e){return this.#a(e,{type:"scatter",area:!0,stacked:!0})}render_horizontalBar(e){return this.#a(e,{type:"bar",horizontal:!0})}render_pie(e){return this.#f(e,!1)}render_donut(e){return this.#f(e,!0)}render_scatter(e){return this.#a(e,{type:"scatter",points:!0})}render_line3D(e){return zn(e,"line3D",this.#l())}render_scatter3D(e){return zn(e,"scatter3D",this.#l())}render_surface(e){return zn(e,"surface",this.#l())}render_map(e){return Ja(e,this.#l())}#a({view:e,category:r,fields:n,settings:i,domains:s},{type:o,area:a=!1,stacked:l=!1,horizontal:u=!1,points:c=!1}){let{source:f,kind:h}=ne(e,r,n,s?.dimension);if(c&&!["value","time"].includes(h))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(l&&new Set(i.map(E=>E.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(l&&new Set(f.map(E=>E[0])).size!==f.length)throw new TypeError("Plotly stacked series require distinct X values. Prepare the store upstream. Configuration retained.");if(l&&a&&f.some(E=>E.slice(1).some(w=>w<0)))throw new TypeError("Plotly stacked areas do not implement separate positive/negative stacks. Choose another type or engine. Configuration retained.");let d=f.map(E=>h==="time"?new Date(E[0]).toISOString():E[0]),p=this.#l(),m=u?"y":"x",g=u?"x":"y";p.barmode=l?"relative":"group",p[m+"axis"]={type:h==="time"&&!u?"date":h==="category"||o==="bar"?"category":"linear",automargin:!0};for(let[E,w]of["left","right"].entries())p[g+"axis"+(E?"2":"")]={side:u?E?"top":"bottom":w,visible:i.some(v=>v.axis===w),automargin:!0,title:{text:n.filter((v,x)=>i[x].axis===w).join(", ")},...E?{overlaying:g}:{},rangemode:"tozero"};if(s){let E=p[m+"axis"];E.type==="category"?(E.categoryorder="array",E.categoryarray=s.dimension.values.map(w=>h==="time"?new Date(w).toISOString():w),E.range=[-.5,E.categoryarray.length-.5]):E.range=s.dimension.range.map(w=>h==="time"?new Date(w).toISOString():w),E.autorange=!1;for(let[w,v]of["left","right"].entries())Object.assign(p[g+"axis"+(w?"2":"")],{range:s.axes[v],autorange:!1})}return{data:n.map((E,w)=>({type:o,name:E,[m]:[...d],[g]:f.map(v=>v[w+1]),[g+"axis"]:g+(i[w].axis==="right"?"2":""),marker:{color:i[w].color},...o==="scatter"?{mode:c?"markers":f.length===1?"lines+markers":"lines",line:{color:i[w].color},...a?{fill:l?"tonexty":"tozeroy",fillcolor:i[w].color+"4d"}:{},...l?{stackgroup:"measures",stackgaps:"infer zero"}:{}}:{orientation:u?"h":"v",...l?{}:{offsetgroup:E},alignmentgroup:"measures"}})),layout:p}}#f({view:e,category:r,fields:n,domains:i},s){let{source:o,kind:a}=ne(e,r,n,i?.dimension),l=o.map(u=>a==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]));if(new Set(l).size!==o.length)throw new TypeError("Plotly pie/donut requires distinct category labels. Prepare the store upstream or choose another engine. Configuration retained.");if(o.some(u=>u[1]<0))throw new TypeError("Pie and donut require nonnegative values. Configuration retained.");return{layout:this.#l(),data:n.map(u=>({type:"pie",name:u,sort:!1,hole:s?.5:0,labels:l,...i?{marker:{colors:l.map(c=>st[i.labels.indexOf(c)%st.length])}}:{},values:o.map(c=>c[1]),textposition:"inside",textinfo:"label+percent",automargin:!0}))}}#l(){return{paper_bgcolor:"#fff",plot_bgcolor:"#fff",font:{color:"#333"},showlegend:!0,margin:{l:70,r:70,t:40,b:75},legend:{orientation:"h",y:-.18,x:0},autosize:!0}}resize(){if(this.#i||!this.#u)return;let e=this.#e.getBoundingClientRect();if(this.#e.layout.width===Math.round(e.width)&&this.#e.layout.height===Math.round(e.height))return;let r=()=>{if(this.#i)return;let n=this.#e.getBoundingClientRect();return Nr.relayout(this.#e,{width:Math.max(1,Math.round(n.width)),height:Math.max(1,Math.round(n.height))})};this.#o=this.#o.then(r).catch(()=>{})}dispose(){this.#i=!0,this.#n?.remove(),this.#u&&Nr.purge(this.#e)}};var Wt={echarts:Vn,plotly:jn,vega:Bn,uplot:Mn};function kh(t){let e=Wt[t];if(!Object.hasOwn(Wt,t))throw new TypeError(`Unknown chart engine: ${t}`);return e}function Hn(t){return Object.getOwnPropertyNames(t.prototype).filter(e=>e.startsWith("render_")&&typeof t.prototype[e]=="function").map(e=>e.slice(7))}function is(t,e){let r=kh(t);if(!Hn(r).includes(e))throw new TypeError(`${r.label} does not support ${e}. Choose another type or engine. Configuration retained.`);return r}function Za(t,{configpath:e,storepath:r,rowMode:n,prefix:i}){let s={};function o(d,p,m,g,y){let E=`${i}-${m}`;d.html_label(p,{for:E});let w={id:E,value:`^${e}.${m}`};y&&(w.nodeId=`${i}_${y}`,s[y]=w.nodeId);let v=d.select(w);for(let[x,T]of g){let b={value:x};if(m==="timeStep"&&["minute","hour"].includes(x))b.disabled=`^${e}.timeHasClock:=!{}`;else if(m==="chartType"){let C=Object.entries(Wt).filter(([,I])=>Hn(I).includes(x)).map(([I])=>I);b.disabled=`^${e}.engine:=!${JSON.stringify(C)}.includes({})`,b.hidden=b.disabled}else if(m==="engine"){let C=Hn(Wt[x]);b.disabled=`^${e}.chartType:=!${JSON.stringify(C)}.includes({})`,b.hidden=b.disabled}v.option(T,b)}return v}let a=[["","No columns"]];o(t,"Engine","engine",Object.entries(Wt).map(([d,p])=>[d,p.label])),o(t,"Chart type","chartType",kn.map(d=>[d.id,d.label]));let l=t.details({id:`${i}-animation`});l.summary("Temporal animation");let u=l.div({display:"grid",gap:"4px"});o(u,"Date field","timeField",[["","Off"]],"timeFieldId");let c=u.div({display:`^${e}.timeField:={} ? 'grid' : 'none'`,gap:"4px"});o(c,"Period","timeStep",[["auto","Automatic"],["minute","Minute"],["hour","Hour"],["day","Day"],["week","Week \xB7 Mon\u2013Sun"],["month","Month"],["year","Year"]]),o(c,"Empty periods","timeEmpty",[["previous","Keep previous snapshot"],["empty","Show empty"]]);let f=c.div();f.span("Current period (UTC): "),f.span(`^${e}.timeUnit`),c.html_label("Seconds per frame",{for:`${i}-time-speed`}),c.numberTextBox({id:`${i}-time-speed`,value:`^${e}.timeSpeed`,min:.1,max:10}),t.chartTimeline({storepath:r,rowMode:n,configpath:e,timeField:`^${e}.timeField`,timeStep:`^${e}.timeStep`,timeIndex:`^${e}.timeIndex`});let h={category(d){o(d,"Category / territory field","captionField",a,"categoryId")},geoJSON(d){d.chartGeoJSON({value:`^${e}.geoJSON`}),d.div("Link the category / territory field to GeoJSON properties.name.",{style:"font-size:11px"})},mapMeasure(d){o(d,"Map measure","mapValueField",[["","No measures"]],"mapMeasureId"),o(d,"Map label field","mapLabelField",a,"mapLabelId"),o(d,"Map labels","mapLabelMode",[["none","None"],["name","Names"],["value","Values"],["nameValue","Names and values"]]),d.div("Calculated measures must be supplied as store columns.",{style:"font-size:11px"})},mapBarScale(d){o(d,"Height scale","mapBarScale",[["zero","From zero"],["extent","Data range"]]),d.div("Selected measures share one height scale. Data range truncates the baseline; tooltip values are unchanged.",{style:"font-size:11px"})},secondDimension(d){o(d,"Second dimension","secondCaptionField",a,"secondCategoryId")},geometry(d){o(d,"Coordinate field","geometryField",a,"geometryId")},measures(d){let p=d.menu({presentation:"bar",aria_label:"Measures toolbar"}).menuline({caption:"Measures",aria_label:"Choose measures"}).menu({nodeId:`${i}_measureMenuId`});s.measureMenuId=`${i}_measureMenuId`,p.menuline({caption:"No measures",disabled:!0});let g=d.grid({id:`${i}-measures`,storepath:`${e}.seriesOptions`,rowMode:"values",height:"120px",style:"--gramlot-grid-row-height:24px;--gramlot-grid-font-size:12px;--gramlot-grid-cell-padding:2px 5px",filter:{value:"^true",columns:["selected"],dtype:"T"}}).struct();g.column({field:"caption",name:"Measure",width:"40%"}),g.column({field:"color",name:"Color",width:"30%",edit:{tag:"colorpicker"}}),g.column({field:"axis",name:"Axis",width:"30%",edit:{tag:"filteringSelect",values:"left:Left,right:Right",validate_select:!0}})}};for(let[d,p]of Object.entries(h)){let m=kn.filter(y=>y.controls.includes(d)).map(y=>y.id),g=t.div({display:`^${e}.chartType:=${JSON.stringify(m)}.includes({}) ? "grid" : "none"`,gap:"4px"});p(g)}t.chartFields({storepath:r,rowMode:n,configpath:e,...s})}var Qa=(0,J.defineComponent)({name:"chartPane",tag:"gramlot-chart-pane",base:je,sourceContext:!0,subTags:"*",parameters:{configDefaults:{dtype:"X",nullable:!0},storepath:{dtype:"T"},configpath:{dtype:"T"},rowMode:{dtype:"T",default:"attributes"},gridId:{dtype:"T",nullable:!0}},implementation:t=>class extends t{#e;#t=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}connectedCallback(){if(this.#t)return;let e=this.#e.sourceNode;if(e.value!==null&&e.value.getNode("frame"))return;let r=e.absDatapath(this.parameters.storepath),n=e.absDatapath(this.parameters.configpath),i=e.getRelativeData(n);i==null&&(i=new Ir,e.setRelativeData(n,i));let s=this.parameters.configDefaults;if(s!=null){if(!(s instanceof Ir))throw new TypeError("configDefaults requires a Bag");let T=Fh(Rh(s));for(let b of T.getNodes())i.getNode(b.label)||i.setItem(b.label,b.getValue())}if(!(i instanceof Ir))throw new TypeError("chartPane requires a configuration Bag");let o={mapLabelMode:"value",mapBarScale:"zero",selectedTerritory:"",timeField:"",timeEmpty:"previous",timeSnapshotLabel:"",timeStep:"auto",timeUnit:"month",timeHasClock:!1,timeIndex:0,timeMax:0,timeAtEnd:!0,timeValue:null,timeLabel:"",timePlaying:!1,timeSpeed:.8,engine:"echarts",chartType:"bar",captionField:"",secondCaptionField:"",geometryField:"",mapValueField:"",mapLabelField:"",geoJSON:null,drawer:"close"};for(let[T,b]of Object.entries(o))i.getNode(T)||i.setItem(T,b);if(i.getNode("seriesOptions")||i.setItem("seriesOptions",new Ir),!(i.getItem("seriesOptions")instanceof Ir))throw new TypeError("seriesOptions must be a Bag");let a=new e.builder.source.constructor(null,e.builder),l=e.builder.wrapSource(a).framePane({node_label:"frame",height:"100%"});l.dataFormula({result_path:`${n}.valueFields`,formula:"options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')",options:`^${n}.seriesOptions`,_onBuilt:!0});let u=l.top.contentPane({display:"flex",justify_content:"flex-end",align_items:"center",padding:"2px 6px"}),c=JSON.stringify(`${n}.drawer`);u.button({icon:"\u2699",aria_label:"Chart settings",title:"Chart settings",action:`this.SET(${c},this.GET(${c}) === 'close' ? true : 'close');`});let f=e.getAttr("id")??`chart-${He()}`,h=l.center.borderContainer({id:`${f}-layout`,height:"100%"}),d=h.contentPane({region:"right",width:"260px",drawer:`^${n}.drawer`,drawer_style:"display:none",detachable:!0,title:"Chart configuration",padding:"8px",border_left:"1px solid var(--gramlot-border)",background:"var(--gramlot-surface)",overflow:"auto",display:"grid",gap:"4px",align_content:"start",style:"font-size:12px;--gramlot-field-height:26px;--gramlot-field-padding:2px 5px;--gramlot-grid-row-height:26px"}),p={id:`${f}-view`,configpath:n,storepath:r,rowMode:this.parameters.rowMode};for(let T of["mapLabelMode","mapBarScale","selectedTerritory","timeEmpty","timeField","timeValue","timeStep","engine","mapValueField","mapLabelField","geoJSON","geometryField","chartType","captionField","secondCaptionField","valueFields","seriesOptions"])p[T]=`^${n}.${T==="timeStep"?"timeUnit":T}`;this.parameters.gridId&&(p.gridId=this.parameters.gridId),h.contentPane({region:"center",min_width:"0"}).chartView(p),Za(d,{configpath:n,storepath:r,rowMode:this.parameters.rowMode,prefix:f}),l.dataFormula({result_path:`${n}.timeInterval`,formula:"playing ? speed : 0",playing:`^${n}.timePlaying`,speed:`^${n}.timeSpeed`,_onBuilt:!0}),l.dataController({func:ba(e.rootBuilder.binding),configpath:n,_timing:`^${n}.timeInterval`}),l.dataFormula({result_path:`${n}.timeAtEnd`,formula:"index >= max",index:`^${n}.timeIndex`,max:`^${n}.timeMax`,_onBuilt:!0});let m=l.bottom.contentPane({display:`^${n}.timeField:={} ? 'flex' : 'none'`,align_items:"center",flex_wrap:"wrap",gap:"10px",padding:"8px 12px",role:"toolbar",aria_label:"Playback controls",background:"var(--gramlot-surface-subtle)",border_top:"1px solid var(--gramlot-border)"}),g=T=>JSON.stringify(`${n}.${T}`),y=m.div({display:"flex",align_items:"center",gap:"2px",flex_shrink:"0"});y.button({icon:"\u2190",aria_label:"Previous period",title:"Previous period",id:`${f}-time-previous`,disabled:`^${n}.timeIndex:={} <= 0`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},Math.max(0,this.GET(${g("timeIndex")})-1));`}),y.button({icon:`^${n}.timePlaying:={} ? '\u23F8\uFE0E' : '\u25B6'`,aria_label:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,title:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,aria_pressed:`^${n}.timePlaying`,id:`${f}-time-play`,disabled:`^${n}.timeMax:={} === 0`,action:`if(!this.GET(${g("timePlaying")}) && this.GET(${g("timeIndex")}) >= this.GET(${g("timeMax")}))this.SET(${g("timeIndex")},0);this.SET(${g("timePlaying")},!this.GET(${g("timePlaying")}));`}),y.button({icon:"\u25A0",aria_label:"Stop",title:"Stop and return to the beginning",id:`${f}-time-stop`,disabled:`^${n}.timeMax:={} === 0`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},0);`}),y.button({icon:"\u2192",aria_label:"Next period",title:"Next period",id:`${f}-time-next`,disabled:`^${n}.timeAtEnd`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},Math.min(this.GET(${g("timeMax")}),this.GET(${g("timeIndex")})+1));`}),m.div({flex:"1",min_width:"120px"}).horizontalSlider({width:"100%",id:`${f}-time-slider`,aria_label:"Temporal snapshot",value:`^${n}.timeIndex`,min:0,max:`^${n}.timeMax`,step:1,live:!0,flex:"1",connect_oninput:`this.SET(${g("timePlaying")},false);`});let w=m.div({display:"grid",gap:"2px",white_space:"nowrap",text_align:"right",font_size:"12px",font_variant_numeric:"tabular-nums"});w.span(`^${n}.timeLabel`,{id:`${f}-time-label`,font_weight:"600"}),w.small(`^${n}.timeSnapshotLabel`,{id:`${f}-snapshot-label`,color:"var(--gramlot-text-secondary)",display:`^${n}.timeSnapshotLabel:={} ? '' : 'none'`});let v=e.rootBuilder.binding.gramlot,x=v.src.prepareSource(a);v.src.renderer.validateCandidate(x),this.#t=!0,e.setValue(x)}}});import{Bag as gs}from"@gramlot/gramlot";var ss=class{#e=new Set;view=null;#t;columns=[];update(e,r){if(!(this.view===e&&this.#t===e.bag&&this.columns===r)){this.view=e,this.#t=e.bag,this.columns=r;for(let n of this.#e)n()}}detach(e){if(this.view===e){this.view=null,this.#t=null,this.columns=[];for(let r of this.#e)r()}}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}};function Ka(t){return Object.hasOwn(t,"gridSearch")||Object.defineProperty(t,"gridSearch",{value:new ss,configurable:!0}),t.gridSearch}var Gn=class{bind(e,r,n,i,s){if(!Array.isArray(e)||e.some(o=>typeof o!="number"||!Number.isFinite(o)))throw new TypeError("Sample chart requires an array of finite numbers");if(!Number.isFinite(r)||r<=0||!Number.isFinite(n))throw new TypeError("Sample chart requires a positive step and finite start");if(typeof i!="string"||!i||typeof s!="string"||!s||s.includes(",")||i===s)throw new TypeError("Sample chart requires distinct captionField and one valueFields name");this.samples=e,this.step=r,this.start=n,this.category=i,this.measure=s,this.rows?.length!==e.length&&(this.rows=Array.from(e.keys()))}domains(e,r,n){if(r==null&&n==null)return null;if(!Number.isFinite(r)||!Number.isFinite(n)||r>=n)throw new TypeError("Sample bounds require finite sampleMin < sampleMax");let i=_n(this,e);return i.dimension.range=[this.start,this.start+Math.max(1,this.samples.length-1)*this.step],i.axes={left:[r,n],right:[r,n]},i.z=[r,n],i}getRows(){return this.rows}value(e,r){if(r===this.category)return this.start+e*this.step;if(r===this.measure)return this.samples[e];throw new TypeError(`Unknown sample field: ${r}`)}};function os(t){if(t==null||t==="")return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)||t instanceof Date&&Number.isFinite(t.getTime())||ie(t)&&t.isFinite())return t;throw new TypeError("Column filters require loaded scalar values")}function gt(t){return xe(os(t))}function eu(t){if(!Array.isArray(t))throw new TypeError("Column selection requires an array or null");return Object.freeze([...new Map(t.map(e=>{let r=gt(e);return[r,K(r)]})).values()])}function tu(t){if(t===null)return null;let{from:e,to:r,dtype:n,timeZone:i}=t;if(!["D","DH","DHZ"].includes(n))throw new TypeError("Date range requires a date column");for(let s of[e,r])if(s!==null&&(!(s instanceof Date)||!Number.isFinite(s.getTime())||s.getUTCHours()||s.getUTCMinutes()||s.getUTCSeconds()||s.getUTCMilliseconds()))throw new TypeError("Date bounds require civil dates");if(e&&r&&e>r)throw new RangeError("From must not be after To.");if(n==="DHZ"&&!i)throw new TypeError("DHZ requires a timeZone");return e||r?Object.freeze({from:e?.toISOString().slice(0,10)??null,to:r?.toISOString().slice(0,10)??null,dtype:n,timeZone:i}):null}function Xn(t,e){if(!e)return!0;if(t==null||t==="")return!1;if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Date range requires date values");let r;if(e.dtype==="DHZ"){let n=new Intl.DateTimeFormat("en",{timeZone:e.timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t),i=s=>n.find(o=>o.type===s).value;r=`${i("year")}-${i("month")}-${i("day")}`}else r=t.toISOString().slice(0,10);return(!e.from||r>=e.from)&&(!e.to||r<=e.to)}function yt(t,e){return e===2?t%4===0&&(t%100!==0||t%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ee(t,e,r){if(![t,e,r].every(Number.isInteger)||t<1||t>9999||e<1||e>12||r<1||r>yt(t,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(r).padStart(2,"0")}`}function wt(t){if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=t.split("-").map(Number);return Ee(...e),e}function Or(t,e,r){let n=t-1,i=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+r-1;for(let s=1;s<e;s++)i+=yt(t,s);return i}function Br(t,e){let r=Or(...wt(t))+e;if(!Number.isSafeInteger(r)||r<0||r>Or(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,i=1e4;for(;i-n>1;){let o=Math.floor((n+i)/2);Or(o,1,1)<=r?n=o:i=o}r-=Or(n,1,1);let s=1;for(;r>=yt(n,s);)r-=yt(n,s++);return Ee(n,s,r+1)}function as(t){return Br(t,-(Or(...wt(t))%7))}function ru(t,e,r=0,n=1){let i=t*12+e-1+r,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+n-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Ee(s,o,1),end:Ee(l,u,yt(l,u))}}var Yn={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 nu(t){if(typeof t!="string")throw new RangeError("A supported locale is required.");let e=t.replaceAll("-","_"),r=e.indexOf("_"),n=(r<0?e:e.slice(0,r)).toLowerCase(),i=(r<0?"":e.slice(r+1)).toUpperCase();if(!Object.hasOwn(Yn,n))throw new RangeError(`Unsupported locale: ${t}`);let s=Yn[n];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...Yn.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var Et=/^(?:\d{4}|\d{2})$/,iu=/^\d{1,2}$/,Mr=(t,e)=>({ok:!1,error:{code:t,message:e}}),Dt=(t="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:t})},au=(t,e)=>Object.hasOwn(t,e);function bt(t,e){if(t.length===4)return Number(t);let r=e.year+e.twoDigitYearAhead-100;return r+((Number(t)-r)%100+100)%100}function Lh(t,e){if(t.includes(";")){let i=t.split(";").map(s=>s.trim());return i.length!==2?Dt("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(t))return{bounds:["",""],range:!0};let r=e.phrases("to"),n=e.phrases("from");for(let i of r)if(t.startsWith(`${i} `))return{bounds:["",t.slice(i.length+1).trim()],range:!0};for(let i of r){let s=` ${i} `;if(!t.includes(s))continue;for(let a of n)if(t.startsWith(`${a} `)){t=t.slice(a.length+1);break}let o=t.split(s).map(a=>a.trim());return o.length!==2?Dt("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of n)if(t.startsWith(`${i} `))return{bounds:[t.slice(i.length+1).trim(),""],range:!0};return{bounds:[t,t],range:!1}}function Ph(t,e,r){let n=[[t,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(t);i&&n.push([i[1],Number(i[2]+i[3])]);let s={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[o,a]of n)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return Br(as(e.workdate),(u+a)*7+(r?6:0));if(l.endsWith("_month")){let c=ru(e.year,e.month,u+a);return r?c.end:c.start}return Br(e.workdate,u+a)}return null}function Uh(t,e,r){let n=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of n){let o;if(t===i)o=null;else if(t.startsWith(i)&&Et.test(t.slice(i.length).trim()))o=bt(t.slice(i.length).trim(),e);else if(t.endsWith(i)&&Et.test(t.slice(0,-i.length).trim()))o=bt(t.slice(0,-i.length).trim(),e);else continue;return{year:o,month:r?s*3:s*3-2}}return null}function su(t,e){if(au(e.months,t))return e.months[t];let r=/^m(\d{1,2})$/.exec(t);return r&&Number(r[1])>=1&&Number(r[1])<=12?Number(r[1]):null}function $h(t,e){let r=t.split(/\s+/),n=r.map((u,c)=>su(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return Dt();let i=n[0],s=su(r[i],e.dictionary),o=r.slice(0,i),a=r.slice(i+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(s>e.month?1:0),month:s};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(s<e.month?1:0),month:s};if(!l.length)return{year:null,month:s};if(!o.length&&a.length===1&&Et.test(a[0]))return{year:bt(a[0],e),month:s};if(o.length===1&&iu.test(o[0])){if(!a.length)return Ee(e.year,s,Number(o[0]));if(a.length===1&&Et.test(a[0]))return Ee(bt(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&iu.test(a[0])&&Et.test(a[1])?Ee(bt(a[1],e),s,Number(a[0])):Dt()}function qh(t,e){let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(r)return Ee(...r.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(t),i={};if(n)e.order.split("").forEach((a,l)=>{i[a]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(t)){let a=t.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=t.slice(0,u),t=t.slice(u)}}else return null;if(!Et.test(i.Y)||i.D.length>2||i.M.length>2)return Dt();let s=Number(i.D),o=Number(i.M);return n&&o>12&&s<=12&&([s,o]=[o,s]),Ee(bt(i.Y,e),o,s)}function ou(t,e,r){if(!t)return null;let n=e.phrases("articles");if(t=t.split(/\s+/).filter(s=>!n.includes(s)).join(" "),!t)return Dt();if(Et.test(t))return Ee(bt(t,e),r?12:1,r?31:1);let i=Ph(t,e,r)??Uh(t,e,r)??$h(t,e);return i!==null?i:au(e.dictionary.weekdays,t)?Br(as(e.workdate),e.dictionary.weekdays[t]):qh(t,e)??Dt()}function Vh(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year,i=typeof e=="string"?wt(e)[0]:e?.year,s=typeof e=="string"?wt(e)[1]:e?.month;return i&&(n>i&&(n=i),n===i&&t.month>s&&n--),Ee(n,t.month,1)}function zh(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year;if(e!==null){let[i,s]=wt(e);n<i&&(n=i),n===i&&s>t.month&&n++}return Ee(n,t.month,yt(n,t.month))}function us(t,e={}){if(!e||typeof e!="object"||Array.isArray(e))return Mr("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let r;try{let{locale:n="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=wt(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");r={...nu(n),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(n){return Mr("INVALID_CONTEXT",n.message)}if(typeof t!="string")return Mr("INVALID_INPUT","Expression must be a string.");try{let n=t.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=Lh(n,r),o=ou(i[1],r,!0),a=ou(i[0],r,!1),l=Vh(a,o,r),u=zh(o,l,r);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return Mr("INVALID_DATE",n.message);if(n instanceof SyntaxError)return Mr(n.code,n.message);throw n}}var Jt=new Map;function Wn(t,e,r){let n=JSON.stringify([t,e,r]),i=Jt.get(n);if(i)Jt.delete(n);else{let s=t?Intl.DateTimeFormat:Intl.NumberFormat;if(!s.supportedLocalesOf([e]).length)throw new RangeError(`Unsupported format locale: ${e}`);i=new s(e,r),Jt.size===64&&Jt.delete(Jt.keys().next().value)}return Jt.set(n,i),i}function lu(t){if(t!=null&&(typeof t!="string"||/[{}]/.test(t.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function uu(t,e){return lu(e),e==null?t:e.replaceAll("{}",()=>t)}function jh(t){if(t instanceof Date)return Le(t);if(ie(t))return"N";if(typeof t=="number")return Number.isInteger(t)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function Hh(t,e,{pattern:r="short",locale:n,timeZone:i}){if(!["short","medium","long","full"].includes(r))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof i!="string"||!i))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let s={timeZone:e==="DHZ"?i:"UTC"};return e!=="H"&&(s.dateStyle=r),e!=="D"&&(s.timeStyle=r),Wn(!0,n,s).format(t)}function Jn(t){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(t);if(!e||e[1]==="("!=(e[4]===")")||t.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${t}`);let r=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:r.replaceAll("#","").length,maximumFractionDigits:r.length}}}function Gh(t){let e=t.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let r=Jn(e[0]);if(r.prefix||r.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&Jn(n);let i=e.length>1?Jn(e.at(-1)):null;return{positive:r,zero:n,negative:i}}function cu(t,e={},r={}){if(t===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let g of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(g))throw new RangeError(`Unsupported format option: ${g}`);e={...e,locale:e.locale??r.locale,timeZone:e.timeZone??r.timeZone};let n=e.dtype===void 0?jh(t):e.dtype,i=["D","H","DHZ"].includes(n);if(!i&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(i){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof t=="number"&&Number.isFinite(t))&&!(ie(t)&&!["NaN","Infinity","-Infinity"].includes(t.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(t))throw new TypeError("L formatting requires an integer");let{pattern:s,locale:o,mask:a}=e;if(!i&&typeof s!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof o!="string"||!o)throw new TypeError("Formatting currently requires an explicit locale");if(lu(a),i){let g=Hh(t,n,e);return uu(g,a)}let{positive:l,zero:u,negative:c}=Gh(s),f=Wn(!1,o,l.intl),h=ie(t),d=h?t.eq(0):t===0,p=h?t.lt(0):t<0;if(h&&Wn(!1,"en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(d&&u!==null){if(u==="")return"";if(u==="-")m="-";else{let g=Jn(u);m=g.prefix+Wn(!1,o,g.intl).format(0)+g.suffix}}else{let g=p&&c?c:l,y=h?(p&&c?t.abs():t).toString():p&&c?-t:t===0?0:t;m=g.prefix+f.format(y)+g.suffix}return uu(m,a)}function fu(t){if(t===null)return null;let{value:e,columns:r,dtype:n,locale:i}=t;if(typeof e!="string"||!Array.isArray(r)||!r.length||r.some(u=>typeof u!="string"||!u||u==="rowidx")||!["T","L","R","N","D"].includes(n))throw new TypeError("Invalid collection filter");if(!e.trim())return null;if(n==="T"){let u=t.literal===!0?e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):e,c=new RegExp(u,"i");return f=>c.test(r.map(h=>Xh(f(h),i,t.timeZone)).join(" "))}if(r.length!==1)throw new TypeError("Typed filters require one column");let s=/^\s*(<=|>=|==|!=|[<>=!#])\s*(.+?)\s*$/.exec(e);if(!s)throw new Error("Enter a comparison, for example > 100 or = 12.");let[,o,a]=s,l;if(n==="D"){let u=new Date,c=`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,f=us(a,{locale:i,workdate:c});if(!f.ok||f.kind!=="date")throw new Error("Enter one complete date after the comparison.");l=new Date(`${f.date}T00:00:00Z`)}else l=Yh(a,i);return u=>{let c=u(r[0]);if(c==null)return!1;if(n==="D"?!(c instanceof Date)||!Number.isFinite(c.getTime()):!(typeof c=="number"&&Number.isFinite(c)||ie(c)&&c.isFinite()))throw new TypeError(`Filter value does not match ${n}`);let f=ie(l)?-l.comparedTo(c):c<l?-1:c>l?1:0;switch(o){case"=":case"==":return f===0;case"!":case"#":case"!=":return f!==0;case"<":return f<0;case">":return f>0;case"<=":return f<=0;case">=":return f>=0}}}function Xh(t,e,r){return t==null?"":typeof t=="string"||typeof t=="boolean"?String(t):cu(t,{pattern:t instanceof Date?"short":"#,##0.####################"},{locale:e,timeZone:r})}function Yh(t,e){let r=new Intl.NumberFormat(e).formatToParts(-12345.6),n=r.find(l=>l.type==="decimal").value,i=r.find(l=>l.type==="group")?.value,s=r.find(l=>l.type==="minusSign").value,o=t.replaceAll(s,"-");if(i&&o.includes(i)){let u=o.split(n)[0].replace(/^[+-]/,"").split(i),c=new Intl.NumberFormat(e).formatToParts(1234567890123).filter(d=>d.type==="integer").map(d=>d.value.length),f=c.at(-1),h=c.at(-2);if(o.split(n).slice(1).some(d=>d.includes(i))||!/^\d+$/.test(u[0])||u[0].length>h||u.slice(1).some((d,p)=>!/^\d+$/.test(d)||d.length!==(p===u.length-2?f:h)))throw new Error("Invalid numeric grouping.");o=o.replaceAll(i,"")}if(o=o.replace(n,"."),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(o))throw new Error("Enter a complete number.");let a=jt(o);if(!ie(a)||!a.isFinite())throw new Error("A finite Decimal backend is required.");return a}function hu(t,e){return(","+t+",").includes(","+e+",")}function du(t){if(typeof t!="string")throw new TypeError("grid checked must refer to a string (empty string for an empty set)");return t}function pu(t){if(typeof t!="string"||!t||t.includes(","))throw new TypeError("grid checkedField requires nonempty text IDs without commas");return t}var mu={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 Wh(t){let e=t._retryPolicy;return e==null?null:typeof e=="string"?mu[e]||null:e}function Jh(t,e){return e.some(r=>r==="Error"?!0:t.name===r||t.constructor.name===r)}function Zh(t){return new Promise(e=>setTimeout(e,t))}async function Qh(t,e){if(!e)return t();let r=e.maxAttempts||3,n=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=n*1e3;for(let u=0;u<r;u++)try{let c=t();return c instanceof Promise?await c:c}catch(c){if(a=c,u<r-1&&Jh(c,o)){let f=l;s&&(f*=1+Math.random()*.1),await Zh(f),l*=i}else throw c}throw a}var le=class t{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(n,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(n))i.has(s)||(this._kw[s]=o);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}_buildEffectiveKw(){let e={...this._kw};if(this._node&&this._node.attr)for(let r of Object.keys(this._kw))Object.hasOwn(this._node.attr,r)&&(e[r]=this._node.attr[r]);return e}resolve(e={}){let{static:r=!1,...n}=e;if(r)return this._node?this._node._value:this.cachedValue;let i=this._buildEffectiveKw();if(Object.keys(n).length>0)return this._load({...i,...n},o=>this._prepareValue(o));let s=this._computeEffectiveFingerprint(i);return s===this._lastEffectiveFingerprint&&!this.expired?this.cachedValue:(this._lastEffectiveFingerprint=s,this._load(i,o=>this._finalize(o)))}_load(e,r){let n=Wh(this),i=()=>this.load(e);if(n)return Qh(i,n).then(r);let s=i();return s&&typeof s.then=="function"?s.then(r):r(s)}_finalize(e){return e=this._prepareValue(e),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_prepareValue(e){let r;return this._asBag===!0?r=!0:this._asBag===!1?r=!1:r=!this._readOnly,r&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),e}_convertToBag(e){let r=t._BagClass;if(!r||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&r.fromXml)return r.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&r.fromTytx)return r.fromTytx(e)}return e}static registerBagClass(e){t._BagClass=e}load(e){return null}};le._BagClass=null;var kr=class extends le{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 vt=class t{constructor(e,r,n=null,i=null,s=null,o=null,a=null,l=!0){this.label=r,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=o,this.xmlTag=a,this._compiled=null,this.parentBag=e,i&&this.setAttr(i,!1,!0,l),n!==null&&this.setValue(n,!1),s&&(this.resolver=s)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,r=null,n={}){if(r!==null){let i=K(`${r}::QS`);if(Array.isArray(i)){let s=i.length?i:Object.keys(this._attr),o=s.map(l=>{let u=this.getAttr(l);return!e&&u instanceof le?u.resolve():u}),a=l=>i.length===0?Object.fromEntries(s.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return o.some(l=>l&&typeof l.then=="function")?Promise.all(o).then(a):a(o)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,r=!0,n=null,i=null,s=!0,o=null,a=!1){e instanceof le?(this.resolver=e,e=null):e instanceof t&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=r??!0,f=null;if(n!==null){let d={...this._attr};this.setAttr(n,!1,i,s);let p=this._buildAttrDiff(d,this._attr);f=Object.keys(p).length>0?p:null}r=c&&(u||f!==null);let h=f?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),r){let d=f!==null?{oldvalue:l,attrs_diff:f}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:d,evt:h})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),r&&this._parentBag._onNodeChanged(this,[this.label],h,l,f,o,a))}replace(e){if(!(e instanceof t))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let r=e.staticValue;r&&typeof r._htraverse=="function"&&(r=r.createChildBag().replace(r));let n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=n,this.setValue(r,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==r||o!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",f=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};for(let h of Object.values(this._nodeSubscribers))h({node:this,info:f,evt:c});this._parentBag!==null&&this._parentBag.backref&&this._parentBag._onNodeChanged(this,[this.label],c,i,l)}return this}get staticValue(){return this._value}set staticValue(e){this._value=e}get resolver(){return this._resolver}set resolver(e){this._resolver=e,e&&e.setNode&&e.setNode(this)}resetResolver(){if(!this._resolver)throw new Error("Cannot reset resolver: node has no resolver");this._resolver.reset(),this.setValue(null)}get attr(){return this._attr}getAttr(e=null,r=null){return e?e in this._attr?this._attr[e]:r:this._attr}_buildAttrDiff(e,r){let n={},i=new Set([...Object.keys(e),...Object.keys(r)]);for(let s of i){let o=s in e?e[s]:null,a=s in r?r[s]:null;o!==a&&(n[s]={old:o,new:a})}return n}setAttr(e=null,r=!0,n=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=r&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,s):this._attr={...s},i)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(r&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&o)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=r===!0?"true":String(r);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let r of e)if(typeof r=="string"&&r.includes(","))for(let n of r.split(","))delete this._attr[n.trim()];else delete this._attr[r]}hasAttr(e,r=null){return e in this._attr?r!==null?this._attr[e]===r:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,r){this._nodeSubscribers[e]=r}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,r=null){let n=this;if(r===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==r;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof t)||this.label!==e.label)return!1;let r=Object.keys(this._attr),n=Object.keys(e._attr);if(r.length!==n.length)return!1;for(let i of r)if(this._attr[i]!==e._attr[i])return!1;return this._resolver!==null?this._resolver===e._resolver:this._value&&typeof this._value.equalTo=="function"?this._value.equalTo(e._value):this._value&&typeof this._value.isEqual=="function"?this._value.isEqual(e._value):this._value===e._value}diff(e){if(this.label!==e.label)return`Other label: ${e.label}`;let r=Object.keys(this._attr),n=Object.keys(e._attr);return r.length!==n.length||r.some(i=>this._attr[i]!==e._attr[i])?`attributes self:${JSON.stringify(this._attr)} --- other:${JSON.stringify(e._attr)}`:this._value!==e._value?`value self:${this._value} --- other:${e._value}`:null}toJson(e=!0){let r=this.value;return r&&typeof r.toJson=="function"&&(r=r.toJson(e,!0)),{label:this.label,value:r,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var Fr=class t{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let r=e.match(/^#(\d+)$/);if(r){let n=parseInt(r[1],10);return n<this._list.length?n:-1}if(r=e.match(/^#(\w*)=(.*)$/),r){let[,n,i]=r,s=i.includes("::")?K(i):i;return n?this._list.findIndex(o=>o.getAttr(n)===s):this._list.findIndex(o=>o._value===s)}return-1}_parsePosition(e){let r=this._list.length;if(e==null||e===">")return r;if(typeof e=="number")return e<0&&(e=r+e),Math.max(0,Math.min(e,r));if(e==="<")return 0;if(e.startsWith("#")){let n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,r)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let s=this._parseSharpIndex(n.slice(1),e);return Math.min(s,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let s=this._parseSharpIndex(n.slice(1),e);return Math.min(s+1,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,r){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${r}': '${e}' is not an integer`);let n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${r}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let r=this.index(e);return r>=0?this._list[r]:null}return this._dict[e]||null}set(e,r,n=">",i=null,s=null,o=null,a=!1,l=!0,u=null,c=!0,f=!1,h=null){let d=null;if(e.includes("?")&&([e,d]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(d){let m=d.split("&");if(m.length===1)i={[m[0]]:r};else{if(!Array.isArray(r)||r.length!==m.length)throw new Error("Wrong attributes assignment");i={};for(let g=0;g<m.length;g++)i[m[g]]=r[g]}r=null}let p=this._dict[e];if(p)h&&(p.nodeTag=h),o!==null&&(o===!1?p.resolver=null:p.resolver=o),d?p.setAttr(i,c,!0,l):p.setValue(r,c,i,a,l,u,f);else{let m=s&&s.nodeClass?s.nodeClass:vt;p=new m(s,e,d?null:r,i,o,h,null,l);let g=this._parsePosition(n);this._dict[e]=p,this._list.splice(g,0,p),c&&s&&s.backref&&s._onNodeInserted(p,g,null,u,f)}return f&&p.setValue(null,!1),p}pop(e){let r=this.get(e);if(r){delete this._dict[r.label];let n=this._list.indexOf(r);return n>=0&&this._list.splice(n,1),r}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,r,n=!0){if(r<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||r>=this._list.length)return;let s=this._list[r].label;if(i.length>1){let o=[...i].sort((c,f)=>c-f),a=o[0]<r?1:0,l=[];for(let c=o.length-1;c>=0;c--){let f=o[c];if(f>=0&&f<this._list.length){let h=this._list[f];this._list.splice(f,1),l.push(h),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(h,f)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===r||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(r,0,a),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,r)}}isEqual(e){if(!(e instanceof t)||this._list.length!==e._list.length)return!1;for(let r=0;r<this._list.length;r++){let n=this._list[r],i=e._list[r];if(!n.isEqual(i))return!1}return!0}};var Eu=ni(qi(),1);var ls="::RSLV:",Kh=new Map,ed=new Map,Zn=new WeakMap,Z=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Rr=class extends le{constructor(e){super({asBag:!1}),Zn.set(this,e)}get payload(){return Zn.get(this)}load(){throw new Z("This resolver is opaque; local execution is unavailable")}};function gu(t){if(!t||typeof t!="object"||Array.isArray(t)||typeof t.resolver_module!="string"||typeof t.resolver_class!="string"||!Array.isArray(t.args??[])||!t.kwargs||typeof t.kwargs!="object"||Array.isArray(t.kwargs))throw new Z("Invalid resolver description")}function yu(t,e=new Set){if(!(t===null||typeof t=="string"||typeof t=="boolean")&&!(typeof t=="number"&&Number.isFinite(t))){if(typeof t!="object"||e.has(t)||!Array.isArray(t)&&Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw new Z("Resolver parameters must be JSON data; callbacks cannot travel");e.add(t);for(let r of Object.values(t))yu(r,e);e.delete(t)}}function Lr(t){if(Zn.has(t))return Zn.get(t);let e=ed.get(t.constructor);if(!e)throw new Z(`Unregistered resolver: ${t.constructor.name}`);let r=e.encode(t),n={resolver_module:e.module,resolver_class:e.name,args:r.args??[],kwargs:r.kwargs??{}};return gu(n),yu(n),ls+JSON.stringify(n)}function Qn(t){if(typeof t!="string"||!t.startsWith(ls))return null;let e=t.slice(ls.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Rr(t);let r;try{r=JSON.parse(e)}catch{throw new Z("Invalid resolver JSON or signed token")}gu(r);let n=Kh.get(JSON.stringify([r.resolver_module,r.resolver_class]));if(!n)return new Rr(t);let i=n.decode({args:r.args??[],kwargs:r.kwargs});if(!(i instanceof n.cls))throw new Z("Resolver decoder returned an incompatible instance");return i}function Kn(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,r instanceof le?Lr(r):r]))}function cs(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,Qn(r)??r]))}var Se="__cls";function Zt(t,e){return t!==null&&t.tytxSuffix===e?t:Ji(e)}function td(t){let e=t.tytxSuffix,r=Object.entries(Gt(e)).filter(([,n])=>n===t).map(([n])=>n);if(r.length===0)throw new Z(`${t.name} is not in the TYTX subtype dictionary of '${e}'`);if(r.length>1)throw new Z(`${t.name} is in the TYTX subtype dictionary of '${e}' under several names: ${r.sort().join(", ")}`);return r[0]}function fs(t,e){let r=Gt(t);if(!Object.hasOwn(r,e))throw new Z(`Unknown Bag class '${e}' for TYTX type '${t}'`);return r[e]}function hs(t,e){return t===e?null:td(t)}function*bu(t,e=[]){for(let r of t){let n=[...e,r.label];yield[n,r];let i=r.getValue(!0);!r.resolver&&i instanceof Ne&&(yield*bu(i,n))}}function rd(t){let e=t.toISOString(),r=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,n=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;if(n&&!r)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return r&&!n?i.slice(i.indexOf("T")+1):i}function Qt(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function ot(t){return typeof t=="string"?t.includes("::")?`${t}::T`:t:Array.isArray(t)?t.map(ot):Qt(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,ot(r)])):t}function ds(t){if(!Qt(t))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=t;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var wu=!1,Ne=class t{static tytxSuffix="X";constructor(e=null,r={}){this._nodes=new Fr,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},ds(r),e!=null&&this.fillFrom(e,r)}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 vt}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 r=[],n=e;for(;n!==null;){if(n.parentBag===this)return r.push(n.label),r.reverse(),r.join(".");r.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let r=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(i=>i)):n=[...e];n.length&&n[0]==="#parent"&&r!==null;)n.shift(),r=r.parent;return[r,n]}_htraverse(e,r=!1,n=!0){let[i,s]=this._htraverseBefore(e);if(i===null)return[null,null];if(s.length===0)return[i,""];for(;s.length>1&&i instanceof t;){let o=s[0];if(o==="#parent"){if(i.parent===null||i.parent===void 0)break;s.shift(),i=i.parent;continue}let a=i._nodes.get(o);if(!a)break;let l=a.getValue(n);if(l instanceof t)s.shift(),i=l;else if(r){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!r)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new Pr("Not existing index in #n syntax");let a=i.createChildBag();i._nodes.set(o,a,">",null,i,null,!1,!0,"autocreate"),i=a}return[i,s[0]]}get(e,r=null,n=!0,i={}){if(!e)return this;if(e==="#parent")return this.parent;let s=null;e.includes("?")&&([e,s]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(n,s,i):r}getItem(e,r=null,n=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,n);return s instanceof t?s.get(o,r,n,i):r}setItem(e,r,n=null,i=">",s=!1,o=!0,a=null,l=!1,u=!0,c=null,f=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[h,d]=this._htraverse(e,!0);return h._nodes.set(d,r,i,n,h,c,s,o,a,u,l,f)}_pop(e,r=null){let n=this._nodes.index(e);if(n>=0){let i=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(i,n,null,r),i}return null}pop(e,r=null,n=null){let i=this.popNode(e,n);return i?i.value:r}delItem(e,r=null,n=null){return this.pop(e,r,n)}popNode(e,r=null){let[n,i]=this._htraverse(e,!1,!0);if(!n||!i)return null;let s=n._nodes.get(i);if(!s)return null;try{return n._pop(i,r)}finally{s.parentBag===n&&n._nodes._dict[s.label]!==s&&(s.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let r of e)r.parentBag=null}getNode(e,r=!0,n=!1,i=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[s,o]=this._htraverse(e,n,r);if(s instanceof t&&o){let a=s._nodes.get(o);if(a)return a;if(n)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,r=null){let n=this._backref;if(this._backref=!0,this._parent=r,this._parentNode=e,!n){this._nodes._parentBag=this;for(let i of this)i.parentBag=this}}delParentRef(){this._parent=null,this._parentNode=null,this._backref=!1}clearBackref(){if(this._backref){this._backref=!1,this._parent=null,this._parentNode=null,this._nodes._parentBag=null;for(let e of this){e.parentBag=null;let r=e.getValue(!0);r instanceof t&&r.clearBackref()}}}_onNodeChanged(e,r,n,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:r,oldvalue:i,attrs_diff:s,evt:n,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...r],n,i,s,o,a)}_onNodeInserted(e,r,n=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof t&&a.setBackref(e,o),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:r,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,r,[this._parentNode.label,...n],i,s)}_onNodeDeleted(e,r,n=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:n,ind:r,evt:"del",reason:i});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,r,[this._parentNode.label,...n],i))}_subscribe(e,r,n){n!=null&&(r[e]=n)}subscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=null,insert:i=null,delete:s=null,any:o=null}=r;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||o)}unsubscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=!1,insert:i=!1,delete:s=!1,any:o=!1}=r;(n||o)&&delete this._updSubscribers[e],(i||o)&&delete this._insSubscribers[e],(s||o)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,r=null,n=!0){let i=t.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(r,!0,!0,n)}getAttr(e=null,r=null,n=null){let i=this.getNode(e);return i?i.getAttr(r,n):n}delAttr(e=null,...r){let n=this.getNode(e);n&&n.delAttr(...r)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(r=>e(r)):[...this._nodes]}getNodeByValue(e,r){for(let n of this._nodes){let i=n.value;if(i instanceof t){if(i.getItem(e)===r)return n}else if(i&&i.get&&i.get(e)===r)return n}return null}getNodeByAttr(e,r,n=!1,i=!1){let s=r===void 0,o=n&&typeof r=="string"?r.toLowerCase():r,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let f=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||f==o)return c}if(c._value instanceof t)if(i){let f=a(c._value);if(f)return f}else u.push(c._value)}for(let c of u){let f=a(c);if(f)return f}return null};return a(this)}isEmpty(e=!1,r=!1){if(this._nodes.length===0)return!0;for(let n of this._nodes){if(n._resolver!==null)return!1;let i=n.getValue(!0);if(i!=null&&!(e&&i===0)&&!(r&&i===""))return!1}return!0}query(e=null,r=null,n=!1,i=!1,s=!0,o=!0,a=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[d,p]=e.split(":");u=this.getItem(d),e=p}c=e.split(",").map(d=>d.trim())}else c=e;let f=(d,p,m,g,y)=>{if(p==="#k")return d.label;if(p==="#p")return m;if(p==="#n")return d;if(typeof p=="function")return p(d);if(p==="#v"){let E=y();return g&&E instanceof t?null:E}else if(p.startsWith("#v.")){let E=p.split(".").slice(1).join("."),w=y();return w&&w.getItem?w.getItem(E):null}else{if(p==="#__v")return d.getValue(!0);if(p.startsWith("#a")){let E=p.includes(".")?p.split(".").slice(1).join("."):null;return d.getAttr(E)}else{let E=y();return E&&E.getItem?E.getItem(p):null}}};function*h(){let d=0;function*p(m,g){for(let y of m._nodes){let E=g?`${g}.${y.label}`:y.label,w=!1,v,x=()=>(w||(v=y.getValue(l),w=!0),v);if((s&&o||(x()instanceof t?o:s))&&(r===null||r(y))&&(yield c.length===1?f(y,c[0],E,i,x):c.map(b=>f(y,b,E,i,x)),d++,a!==null&&d>=a))return;if(i){let b=x();if(b instanceof t&&(yield*p(b,E),a!==null&&d>=a))return}}}yield*p(u,"")}return n?h():[...h()]}getLeaves(){let e=[],r=(n,i)=>{for(let s of n._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof t?r(a,o):e.push([o,a])}};return r(this,""),e}digest(e=null,r=null,n=!1){typeof r=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=r,r=null);let i=this.query(e,r,!1,!1,!0,!0,null,!1);if(n){if(!i||i.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let s=[...i];if(s.length&&Array.isArray(s[0])){let o=s[0].length,a=[];for(let l=0;l<o;l++)a.push(s.map(u=>u[l]));return a}return[s]}return[...i]}columns(e,r=!1){typeof e=="string"&&(e=e.split(","));let n=r?"#a.":"",i=e.map(s=>`${n}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",r=!1,n=null){if(r!=null&&typeof r!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let i=s=>{let o=0,a=!1;for(let l of this.query(s,n)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(r)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}o+=l}return r&&a?null:o};return e.includes(",")?e.split(",").map(s=>i(s.trim())):i(e)}sort(e="#k:a"){let r=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],n=(i,s)=>i[0]!==s[0]?i[0]-s[0]:i[1]<s[1]?-1:i[1]>s[1]?1:0;if(typeof e=="function")this._nodes._list.sort((i,s)=>{let o=e(i),a=e(s);return o<a?-1:o>a?1:0});else{let i=e.split(",");i.reverse();for(let s of i){let o,a;s.includes(":")?[o,a]=s.split(":",2):(o=s,a="a"),o=o.trim(),a=a.trim();let l=a==="d"||a==="D",u=a==="a"||a==="d",c;if(o.toLowerCase()==="#k")c=f=>r(f.label,u);else if(o.toLowerCase()==="#v")c=f=>r(f.value,u);else if(o.toLowerCase().startsWith("#a.")){let f=o.slice(3);c=h=>r(h.getAttr(f),u)}else c=f=>{let h=f.value,d=h instanceof t?h.getItem(o):h?h[o]:null;return r(d,u)};this._nodes._list.sort((f,h)=>{let d=n(c(f),c(h));return l?-d:d})}}return this}equalTo(e){return e instanceof t?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let r=null;e.includes("?")&&([e,r]=e.split("?",2));let n=this.getNode(e);return n===null?!1:r===null?!0:r.split("&").every(i=>i in n.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let r=this.getNode(e);return r?r.resolver:null}setResolver(e,r){let n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=r}setCallbackItem(e,r,n={}){let i=new kr({callback:r,...n});this.setResolver(e,i)}move(e,r,n=!0){this._nodes.move(e,r,n)}asDict(e=!1,r=!1,n=!1,i=!1){let s={};for(let o of this._nodes){let a=o.value;if(i&&a==null)continue;let l=o.label;e&&(l=String(l)),r&&(l=l.toLowerCase()),n&&a instanceof t&&(a=t.prototype.asDict.call(a,e,r,n,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,r=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,r),r)}deepcopy(e=!1){let r=this.createChildBag();for(let n of this._nodes){let i=n.getValue(!e);i instanceof t&&(i=i.deepcopy(e));let s=new r.nodeClass(r,n.label,i);s.setAttr({...n.attr},!1,!1,!1),s.nodeTag=n.nodeTag,s.xmlTag=n.xmlTag,r._nodes._list.push(s),r._nodes._dict[s.label]=s}return r}update(e,r=null,n=null,i=!1){if(!(e instanceof t)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,n,!1,n!==!1)}return}for(let s of[...e]){let o=s.label,a=r==="static"?s.resolver:null,l=a?null:s.getValue(),u=s.attr.__replace;delete s.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(s.attr,n===null?!0:n,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,n===null?!0:n,null,null,!1,n);else{s.resolver&&(c.resolver=null);let f=c.getValue();l instanceof t&&f instanceof t&&!u?f.update(l,r,n,i):(!i||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let f=this.setItem(o,a||l,s.attr,">",!1,!1,n,!1,n!==!1);f.nodeTag=s.nodeTag,f.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let r of e){let n=new this.nodeClass(this,r.label);n.replace(r),n.nodeTag=r.nodeTag,n.xmlTag=r.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,r,n=null,i=null,s=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,n,i,s,null,!1);return r instanceof le?o.resolver=r:o._value=r,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,r={}){let n=ds(r);if(e!=null&&!Qt(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let i=this.createChildBag(),s=new Set,o=(a,l,u)=>{if(s.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);s.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,f=Array.isArray(l)?Array.from(l,(h,d)=>[`r_${String(d).padStart(c,"0")}`,h]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(h=>Object.prototype.propertyIsEnumerable.call(l,h)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[h,d]of f){let p=d;n&&(Qt(p)||Array.isArray(p))&&(p=this.createChildBag(),o(p,d,`${u}[${JSON.stringify(h)}]`)),a._appendLiteral(h,p)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,r={}){return this.fillFrom(e,r)}replace(e){if(!(e instanceof t))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let r=this.createChildBag();return r._fillFromBag(e),this._replacePrepared(r)}_replacePrepared(e){for(let n of this._nodes){n.parentBag=null;let i=n.getValue(!0);i instanceof t&&i.clearBackref()}let r=this._nodes;this._nodes=e._nodes,e._nodes=r,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:r=!0,deep:n=!1,kwargs:i={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let s=(o,a)=>{for(let l=0;l<o._nodes.length;l++){let u=o._nodes._list[l],c={...a};"_pathlist"in a&&(c._pathlist=[...a._pathlist,u.label]),"_indexlist"in a&&(c._indexlist=[...a._indexlist,l]);let f=e(u,c,l);if(f)return f;if(f==null&&n){let h=u.getValue(r);if(h instanceof t){let d=s(h,c);if(d)return d}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let r=e.getValue(!0);r instanceof t&&(yield*r.traverse())}}*_iterNodesWithPaths(e=!0,r=""){for(let n of this._nodes){let i=r?`${r}.${n.label}`:n.label;yield[i,n];let s=n.getValue(e);s instanceof t&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let r=e!==null,n=r?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of bu(this)){let l=o.slice(0,-1),u=JSON.stringify(o),c=JSON.stringify(l),f=a.getValue(!0),h,d=null;if(a.resolver)h=Lr(a.resolver);else if(f instanceof t){let g=f.constructor,y=g.tytxSuffix;s.set(u,g),d=hs(g,Zt(s.get(c),y)),h=`::${y}`}else f===null?h="::NN":h=ot(f);if(a.attr&&Object.hasOwn(a.attr,Se))throw new Z(`node '${o}': the attribute '${Se}' is reserved for the Bag class name`);let p=Kn(ot(a.attr));d!==null&&(p[Se]=d);let m=a.nodeTag;r?(yield[l.length?n[c]:null,a.label,m,h,p],f instanceof t&&(n[u]=i,e[i]=o,i++)):yield[l,a.label,m,h,p]}}toTytx(e="json",r=!1){let n=this._toTytxPayload(r),i=this.constructor.tytxSuffix;if(e==="json")return`${n}::${i}`;if(e==="msgpack")return Kr(new Ce(4,new TextEncoder().encode(`${i}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let r;if(e){let s={};r={rows:[...this._nodeFlattener(s)],paths:s}}else r={rows:[...this._nodeFlattener(null)]};let n=this.constructor,i=hs(n,Zt(null,n.tytxSuffix));return i!==null&&(r[Se]=i),r.rows=r.rows.map(([s,o,a,l,u])=>[ot(s),ot(o),ot(a),l,u]),r.paths&&(r.paths=ot(r.paths)),xe(r)}static fromTytx(e,r="json",n={}){if(Qt(r)&&(n=r,r="json"),ds(n),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(r!=="json"&&r!=="msgpack")throw new TypeError(`Unsupported transport: ${r}`);r==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let i=K(e,r==="json"?null:r);if(i instanceof t)return i;if(!Qt(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,n)}static _fromTytxPayload(e){let r=this.tytxSuffix;if(e==="")return new(Zt(null,r));let n=K(e);if(!n||!Array.isArray(n.rows))throw new Z("Invalid TYTX Bag: expected rows");let i=n.paths,s=i!=null,o=Object.hasOwn(n,Se)?fs(r,n[Se]):Zt(null,r),a=new o,l=new Map([["[]",a]]);for(let u of n.rows){if(!Array.isArray(u)||u.length!==5)throw new Z("Invalid TYTX Bag row");let[c,f,h,d,p]=u,m=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new Z(`Unknown TYTX parent reference: ${c}`);m=c===null?"":i[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new Z("Invalid TYTX parent path");let g=JSON.stringify(m);if(!l.has(g))throw new Z(`Missing or undecodable TYTX parent branch: ${m}`);let y=l.get(g),E=JSON.stringify([...m,f]),w=d,v=Qn(w),x=cs(p),T=Object.hasOwn(x,Se)?x[Se]:null;if(delete x[Se],w instanceof t){let C=w.constructor.tytxSuffix,I=T!==null?fs(C,T):Zt(y.constructor,C);w=new I,l.set(E,w)}else if(T!==null)throw new Z(`node '${E}': the attribute '${Se}' is reserved for the Bag class name of a branch`);let b=y._appendLiteral(f,v?null:w,x,v);b.nodeTag=h??null}return a}toXml(e={}){let{pretty:r=!1,encoding:n="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,r);return i===!0?o=`<?xml version='1.0' encoding='${n}'?>
41
- ${o}`:typeof i=="string"&&(o=`${i}
42
- ${o}`),o}_bagToXml(e=null,r=!1,n=0){let i=[];for(let s of this._nodes)i.push((r?" ".repeat(n):"")+this._nodeToXml(s,e,r,n));return i.join(r?`
43
- `:"")}_nodeToXml(e,r=null,n=!1,i=0){let s=e.xmlTag||e.nodeTag||e.label,o=this._sanitizeTag(s),a=[];if(o!==s&&a.push(`_tag="${this._escapeAttr(s)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(Lr(e.resolver))}"`),e.attr)for(let[h,d]of Object.entries(Kn(e.attr)))d!==null&&d!==!1&&d!==void 0&&a.push(`${h}="${this._escapeAttr(String(d))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){n=n&&e.attr?.["xml:space"]!=="preserve";let h=u._bagToXml(r,n,i+1);return h?n?`<${o}${l}>
44
- ${h}
45
- ${" ".repeat(i)}</${o}>`:`<${o}${l}>${h}</${o}>`:r===null||r.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`}if(u==null||u==="")return r===null||r.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?rd(u):String(u),f=this._escapeXml(c);return`<${o}${l}>${f}</${o}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeAttr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}static fromXml(e,r={}){let{tagAttribute:n=null}=r,i;if(typeof DOMParser<"u"){i=new DOMParser().parseFromString(e,"application/xml");let o=i.querySelector("parsererror");if(o)throw new Error(`XML parse error: ${o.textContent}`)}else i=new Eu.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,n)}static _xmlElementToBag(e,r=null){let n=new this,i=Array.from(e.childNodes).filter(s=>s.nodeType===1);for(let s of i){let o=s.tagName,a={};for(let m=0;m<s.attributes.length;m++){let g=s.attributes[m];a[g.name]=g.value}let l=Qn(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,cs(a));let c=o;"_tag"in a&&(c=a._tag,delete a._tag),r&&r in a&&(c=a[r],delete a[r]);let f=c,h=1;for(;n.getNode(c);)c=`${f}_${h++}`;let d=Array.from(s.childNodes).filter(m=>m.nodeType===1),p;if(d.length>0||u){let m=this._xmlElementToBag(s,r);p=n.setItem(c,m,Object.keys(a).length>0?a:null)}else{let m=s.textContent||"";p=n.setItem(c,m,Object.keys(a).length>0?a:null)}l&&(p.resolver=l),p.xmlTag=o}return n}static async fromUrl(e,r={}){let{timeout:n=30}=r,i={};n&&(i.signal=AbortSignal.timeout(n*1e3));let s=await fetch(e,i),o=s.headers.get("content-type")||"",a=await s.text();if(o.includes("json"))return t.fromTytx(a);if(o.includes("xml"))return t.fromXml(a);let l=a.trim();if(l.startsWith("<"))return t.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return t.fromTytx(a);throw new Pr(`Unsupported content-type: ${o}`)}toJson(e=!0){let r=[];for(let n of this._nodes)r.push(this._nodeToJsonDict(n,e));return e?xe(r):JSON.stringify(r)}_nodeToJsonDict(e,r){let n=e.resolver?null:e.getValue(!0);if(n&&typeof n._nodeToJsonDict=="function"){let s=[];for(let o of n._nodes)s.push(n._nodeToJsonDict(o,r));n=s}let i={label:e.label,value:n,attr:Kn(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Lr(e.resolver)),i}static fromJson(e,r={}){return wu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),wu=!0),this.fromTytx(e,"json",r)}toStringTree(e=!0,r=null,n="",i=!0){r===null&&(r=new Map);let s=[],o=[...this._nodes];for(let a=0;a<o.length;a++){let l=o[a],u=a===o.length-1,c=l.getValue(e),f=l.getAttr(),h="",d=Object.keys(f);d.length>0&&(h=" ["+d.map(y=>`${y}=${JSON.stringify(f[y])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=n+(u?" ":"\u2502 ");if(c instanceof t){let g=l,y=c.backref?"(*)":"";if(r.has(g))s.push(`${n}${p}${l.label}${y}${h} \u2192 (circular ref)`);else{r.set(g,l.label),s.push(`${n}${p}${l.label}${y}${h}`);let E=c.toStringTree(e,r,m,u);E&&s.push(E)}}else{let g;if(c===null)g="null";else if(c===void 0)g="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let y=new TextDecoder("utf-8",{fatal:!1}),E=c instanceof ArrayBuffer?new Uint8Array(c):c;g=y.decode(E)}else typeof c=="string"?c.length>50?g=JSON.stringify(c.slice(0,47)+"..."):g=JSON.stringify(c):g=String(c);s.push(`${n}${p}${l.label}: ${g}${h}`)}}return s.join(`
46
- `)}toString(e=!0,r=null,n=""){r||(r=new Set);let i=[],s=[...this._nodes];for(let o=0;o<s.length;o++){let a=s[o],l=o===s.length-1,u=a.getValue(e),c="",f=a.attr;f&&Object.keys(f).length>0&&(c=` [${Object.entries(f).map(([m,g])=>`${m}=${JSON.stringify(g)}`).join(", ")}]`);let h=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",d=n+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=a;if(r.has(p))i.push(`${n}${h}${a.label}${c} \u2192 (circular ref)`);else{r.add(p),i.push(`${n}${h}${a.label}${c}`);let m=u.toString(e,r,d);m&&i.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),i.push(`${n}${h}${a.label}: ${p}${c}`)}}return i.join(`
47
- `)}},Pr=class extends Error{constructor(e){super(e),this.name="BagException"}};le.registerBagClass(Ne);Zi(Ne,"X",t=>t._toTytxPayload(),t=>Ne._fromTytxPayload(t));Qi(Ne.tytxSuffix,{...Gt(Ne.tytxSuffix),Bag:Ne});function ps(t,e){let r=[],n=Object.freeze({full:e.full,rows:Object.freeze([...e.rows]),event:e.event??null,field:e.field??null});for(let i of[...t])if(t.has(i))try{i(n)}catch(s){r.push(s)}if(r.length)throw new AggregateError(r,"Collection notification failed")}var ei=class{#e;#t=null;#s=new Set;#r=new Map;#n="";#i=new Map;#o=null;constructor(e){this.bindStore(e)}get bag(){return this.#e.bag}get rowMode(){return this.#e.rowMode}get sortedBy(){return this.#n}get criteria(){return Du(this.#n)}get filter(){return this.#i.get("search")?.definition??null}get filterSignature(){return JSON.stringify([...this.#i].map(([e,{definition:r}])=>[e,r]))}get filterContributions(){return Object.freeze([...this.#i].map(([e,r])=>Object.freeze([e,Object.freeze({...r})])))}copyFiltersFrom(e){this.filterSignature!==e.filterSignature&&this.#a(this.#u(),this.#n,new Map(e.filterContributions))}get filtered(){return this.#o===null?null:[...this.#o]}isFiltered(){return this.#o!==null}value(e,r){return this.#e.value(e,r)}subscribe(e){return this.#s.add(e),()=>this.#s.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 r=this.#t!==null;this.disconnect(),this.#e=e,this.#r.clear(),r?this.connect():this.synchronize()}getRows(e=!0){let r=this.#u();return e&&this.#o!==null?this.#o.map(n=>r[n]):r}#u(){return this.#e.getRows().toSorted((e,r)=>(this.#r.get(e)??1/0)-(this.#r.get(r)??1/0))}synchronize(e={full:!0,rows:[]}){if(!e.full&&!this.#n&&!this.#i.size){ps(this.#s,{full:e.full,rows:e.rows});return}this.#a(this.#f(this.#u(),this.criteria),this.#n,this.#i,e)}sort(e){let r=this.#f(this.#u(),Du(e));this.#a(r,e,this.#i)}moveRow(e,r,n=!1){if(e===r||e.parentBag!==this.bag||r.parentBag!==this.bag)return;let i=this.getRows(!1);i.splice(i.indexOf(e),1),i.splice(i.indexOf(r)+Number(n),0,e),this.#a(i,"",this.#i)}applyFilter(e,r="search"){if(!["base","search"].includes(r))throw new TypeError("Unknown collection filter contribution");let n=e===null?null:Object.freeze({...e,columns:Object.freeze([...e.columns])});this.#c(r,n,fu(n))}applySetFilter(e){let r=e===null?null:Object.freeze(e.map(({field:i,value:s})=>{if(typeof i!="string"||!i)throw new TypeError("Set filter requires an identity field");return du(s),Object.freeze({field:i,value:s})})),n=r===null?null:i=>r.every(({field:s,value:o})=>hu(o,pu(i(s))));this.#c("sets",r,n)}columnFilter(e){return this.#i.get(`column:${e}`)?.definition.values??null}columnRange(e){let r=this.#i.get(`column:${e}`)?.definition.range;return r?{...r,from:r.from&&new Date(r.from+"T00:00:00Z"),to:r.to&&new Date(r.to+"T00:00:00Z")}:null}applyColumnFilter(e,r,n=this.columnRange(e)){if(n=tu(n),typeof e!="string"||!e)throw new TypeError("Column filter requires a field");let i=r===null?null:eu(r),s=i?.map(gt),o=i===null&&n===null?null:Object.freeze({field:e,values:i,keys:s&&Object.freeze(s),range:n}),a=o===null?null:l=>Xn(l(e),n)&&(s===void 0||s.includes(gt(l(e))));this.#c(`column:${e}`,o,a)}columnFacets(e){let r=new Map,n=this.#i.get(`column:${e}`)?.definition.range??null,i=this.columnFilter(e),s=i?.map(gt),o=[...this.#i].filter(([a])=>a!==`column:${e}`).map(([,a])=>a.predicate).filter(a=>a!==null);for(let a of this.#u()){let l=os(this.value(a,e)),u=gt(l);r.has(u)||r.set(u,{key:u,value:l,count:0,selected:Xn(l,n)&&(s===void 0||s.includes(u))}),o.every(c=>c(f=>this.value(a,f)))&&r.get(u).count++}for(let a of i??[]){let l=gt(a);r.has(l)||r.set(l,{key:l,value:a,count:0,selected:!0})}return[...r.values()].filter(a=>Xn(a.value,n))}#c(e,r,n){if(JSON.stringify(this.#i.get(e)?.definition??null)===JSON.stringify(r))return;let i=new Map(this.#i);r===null?i.delete(e):i.set(e,{definition:r,predicate:n}),this.#a(this.#u(),this.#n,i)}#a(e,r,n,i={full:!1,rows:[]}){let s=[...n.values()].map(c=>c.predicate).filter(c=>c!==null),o=s.length?e.flatMap((c,f)=>s.every(h=>h(d=>this.value(c,d)))?[f]:[]):null,a=i.full||r!==this.#n||n!==this.#i||e.length!==this.#r.size||e.some((c,f)=>this.#r.get(c)!==f)||JSON.stringify(o)!==JSON.stringify(this.#o);this.#r=new Map(e.map((c,f)=>[c,f])),this.#n=r,this.#i=n,this.#o=o;let l=o===null?null:new Set(o),u=a?[]:i.rows.filter(c=>this.#r.has(c)&&(l===null||l.has(this.#r.get(c))));(a||u.length||i.rows.length)&&ps(this.#s,{full:a,rows:u})}#f(e,r){if(!r.length)return e;let n=e.map(i=>({node:i,keys:r.map(({field:s})=>this.value(i,s))}));for(let i=0;i<r.length;i++)if(new Set(n.map(o=>od(o.keys[i])).filter(o=>o!==null)).size>1)throw new TypeError(`collection view cannot compare mixed types in ${r[i].field}`);return n.sort((i,s)=>{for(let[o,{direction:a}]of r.entries()){let l=ad(i.keys[o],s.keys[o]);if(l)return a==="a"?l:-l}return 0}).map(i=>i.node)}};function Du(t){if(typeof t!="string")throw new TypeError("collection view sortedBy must be a string");if(t==="")return[];let e=new Set;return t.split(",").map(r=>{let n=/^([^,:]+):([ad])$/.exec(r);if(!n||e.has(n[1]))throw new TypeError(`Invalid collection view sort criterion: ${r}`);return e.add(n[1]),{field:n[1],direction:n[2]}})}function od(t){if(t==null)return null;if(typeof t=="number"&&Number.isFinite(t)||ie(t)&&t.isFinite())return"number";if(t instanceof Date&&Number.isFinite(t.getTime()))return"date";if(typeof t=="string"||typeof t=="boolean")return typeof t;throw new TypeError("collection view sort requires loaded finite scalar values")}function ad(t,e){return t==null||e==null?t==null?e==null?0:-1:1:ie(t)?t.comparedTo(e):ie(e)?-e.comparedTo(t):t<e?-1:t>e?1:0}var ti=class{#e=null;#t=null;#s;#r;constructor(e,r){this.#r=new ei(e),r&&this.follow(r),this.#r.connect()}bindStore(e){this.detach(),this.#r.bindStore(e)}get view(){return this.#r}follow(e){if(e.bag!==this.#r.bag||e.rowMode!==this.#r.rowMode)throw new TypeError("Chart and grid must use the same collection");this.#t?.(),this.#e=e,this.#s=void 0,this.#n(),this.#t=e.subscribe(()=>this.#n())}#n(){let e=this.#e.filterSignature;e!==this.#s&&(this.#r.copyFiltersFrom(this.#e),this.#s=e)}detach(){this.#t?.(),this.#t=null,this.#e=null}dispose(){this.detach(),this.#r.disconnect()}};import{Bag as vu}from"@gramlot/gramlot";var ms=new WeakMap;function ud(t){if(!ms.has(t)){let e=`chart_${He()}`;class r{toggleMeasure(i){let s=i.getAttr("selectionPath");i.setRelativeData(s,!i.getRelativeData(s))}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),ms.set(t,`${e}.toggleMeasure`)}return ms.get(t)}function ld(t){let e=t.getRows(),r=[...new Set(e.flatMap(s=>t.rowMode==="attributes"?Object.keys(s.getAttr()):s.staticValue.getNodes().map(o=>o.label)))],n=r.filter(s=>e.every(o=>{let a=t.value(o,s);return typeof a=="number"&&Number.isFinite(a)})),i=r.filter(s=>e.some(o=>t.value(o,s)instanceof Date)&&e.every(o=>{let a=t.value(o,s);return a==null||a instanceof Date&&Number.isFinite(a.getTime())}));return{fields:r,measures:n,dates:i}}var Tu=(0,J.defineComponent)({name:"chartFields",tag:"gramlot-chart-fields",base:je,sourceContext:!0,bagStore:!0,parameters:{timeFieldId:{dtype:"T"},storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},categoryId:{dtype:"T"},mapMeasureId:{dtype:"T"},mapLabelId:{dtype:"T"},secondCategoryId:{dtype:"T"},geometryId:{dtype:"T"},measureMenuId:{dtype:"T"}},implementation:t=>class extends t{#e;#t;#s;#r;#n;#i=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){if(!(e instanceof vu))throw new TypeError("chartFields requires a Data Bag");this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#i&&this.#o(),n}connectedCallback(){this.#i=!0,this.#o()}#o(){let r=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);r!==this.#s&&(this.#r?.(),this.#s=r,this.#n=void 0,this.#r=r.subscribe(()=>this.#u(r)),this.#u(r))}#u(e){if(!e.getRows().length)return;let{fields:r,measures:n,dates:i}=ld(e),s=JSON.stringify([r,n,i]);if(s===this.#n)return;let o=this.#e.sourceNode,a=o.getRelativeData(this.parameters.configpath),l=a.getItem("seriesOptions"),u=o.rootBuilder.binding,c=u.nodeIds.get(this.parameters.categoryId),f=u.nodeIds.get(this.parameters.measureMenuId),h=["#5470c6","#ee6666","#3ba272","#fac858","#9a60b4","#73c0de"];for(let p of[...l.getNodes()])n.includes(p.label)||l.popNode(p.label);n.forEach((p,m)=>{l.getNode(p)||l.setItem(p,new vu);let g=l.getItem(p);for(let[y,E]of Object.entries({axis:"left",color:h[m%h.length],caption:p.charAt(0).toUpperCase()+p.slice(1),selected:!0}))g.getNode(y)||g.setItem(y,E)});let d=(p,m,g=y=>y.charAt(0).toUpperCase()+y.slice(1))=>{let y=new Set;for(let E of[...p.value.getNodes()]){let w=E.getAttr("value");m.includes(w)?y.add(w):p.value.popNode(E.label)}m.forEach(E=>{y.has(E)||p.builder.wrapSource(p).option(g(E),{value:E,node_label:`field_${He()}`})}),m.length||p.builder.wrapSource(p).option("No columns",{value:"",node_label:"empty"})};d(c,r),this.parameters.timeFieldId&&(d(u.nodeIds.get(this.parameters.timeFieldId),["",...i],p=>p?p.charAt(0).toUpperCase()+p.slice(1):"Off"),a.getItem("timeField")&&!i.includes(a.getItem("timeField"))&&(a.setItem("timeField",""),a.setItem("timePlaying",!1))),d(u.nodeIds.get(this.parameters.mapMeasureId),n,p=>l.getItem(p).getItem("caption")),d(u.nodeIds.get(this.parameters.mapLabelId),r),n.includes(a.getItem("mapValueField"))||a.setItem("mapValueField",n.find(p=>l.getItem(p).getItem("selected"))??n[0]??""),r.includes(a.getItem("mapLabelField"))||a.setItem("mapLabelField",r.includes(a.getItem("captionField"))?a.getItem("captionField"):r[0]??""),d(u.nodeIds.get(this.parameters.geometryId),r),d(u.nodeIds.get(this.parameters.secondCategoryId),r);for(let p of[...f.value.getNodes()])f.value.popNode(p.label);n.forEach((p,m)=>{let g=`${this.parameters.configpath}.seriesOptions.${p}.selected`;f.builder.wrapSource(f).menuline({node_label:`measure_${m}`,caption:l.getItem(p).getItem("caption"),checked:`^${g}`,selectionPath:g,action:ud(u)})}),n.length||f.builder.wrapSource(f).menuline({caption:"No measures",disabled:!0,node_label:"empty"}),r.includes(a.getItem("captionField"))||a.setItem("captionField",r[0]??""),r.includes(a.getItem("secondCaptionField"))||a.setItem("secondCaptionField",r.find(p=>p!==a.getItem("captionField"))??""),r.includes(a.getItem("geometryField"))||a.setItem("geometryField",r.find(p=>e.getRows().every(m=>Array.isArray(e.value(m,p))))??""),this.#n=s}disconnectedCallback(){this.#i=!1,this.#r?.(),this.#r=null,this.#s=null,this.#n=void 0}}});import{Bag as xu}from"@gramlot/gramlot";function cd(t,e,r){if(!(r instanceof xu))throw new TypeError("seriesOptions requires a Bag");let n=Fn(e.getItem("chartType")),i=e.getItem("captionField"),s=e.getItem("valueFields");if(s!==null&&typeof s!="string")throw new TypeError("valueFields requires comma-separated codes or null");let o=s?s.split(","):[];if(o.some(l=>!l)||new Set(o).size!==o.length)throw new TypeError("valueFields requires distinct nonempty fields");if(typeof i!="string"||!i)throw new TypeError("Chart requires captionField");n.measureLimit!==null&&(o=o.slice(0,n.measureLimit));let a=o.map(l=>{let u=r.getItem(l);if(!(u instanceof xu))throw new TypeError(`Missing seriesOptions for ${l}`);let c=u.getItem("axis"),f=u.getItem("color");if(!["left","right"].includes(c)||typeof f!="string"||!/^#[0-9a-f]{6}$/i.test(f))throw new TypeError("Series requires left/right axis and a six-digit hex color");return{axis:c,color:f}});return{view:t,category:i,structure:e,fields:o,settings:a,seriesOptions:r,type:n}}var Ur=class{#e;#t;#s;#r;#n;#i;#o=0;constructor(e,r,n={}){this.#e=e,this.#t=r,this.#s=n}async prepare(e,r){await is(e,r).load(r)}invalidate(){this.#o++}update(e,r){let n=e.getItem("engine")??"echarts",i=cd(this.#t,e,r);i.domains=this.#s.domains?this.#s.domains(i):null;let s=is(n,i.type.id),o=++this.#o;n!==this.#n&&(this.#r?.dispose(),this.#i?.remove(),this.#i=null,this.#e&&(this.#i=this.#e.ownerDocument.createElement("div"),this.#i.style.cssText="width:100%;height:100%;position:relative",this.#e.append(this.#i)),this.#r=new s(this.#i,this.#s),this.#n=n);let a=this.#r.validate(i);return this.#r.update(i,a,()=>o===this.#o)}svg(){return this.#r.svg()}resize(){this.#r?.resize()}dispose(){this.invalidate(),this.#r?.dispose(),this.#r=null,this.#n=null,this.#i?.remove(),this.#i=null}};var fd=(0,J.defineComponent)({name:"chartView",tag:"gramlot-chart-view",base:je,sourceContext:!0,bagStore:!0,parameters:{sampleMin:{dtype:"R",nullable:!0,binding:"read"},sampleMax:{dtype:"R",nullable:!0,binding:"read"},sampleStep:{dtype:"R",default:1,binding:"read"},sampleStart:{dtype:"R",default:0,binding:"read"},mapLabelMode:{dtype:"T",default:"value",binding:"read"},mapBarScale:{dtype:"T",default:"zero",binding:"read"},selectedTerritory:{dtype:"T",default:"",binding:"twoWay"},configpath:{dtype:"T"},timeEmpty:{dtype:"T",default:"previous",binding:"read"},timeField:{dtype:"T",default:"",binding:"read"},timeValue:{dtype:"X",nullable:!0,binding:"read"},timeStep:{dtype:"T",default:"month",binding:"read"},engine:{dtype:"T",default:"echarts",binding:"read"},mapValueField:{dtype:"T",binding:"read"},mapLabelField:{dtype:"T",binding:"read"},geoJSON:{dtype:"X",nullable:!0,binding:"read"},geometryField:{dtype:"T",binding:"read"},secondCaptionField:{dtype:"T",binding:"read"},seriesOptions:{dtype:"X",binding:"read"},storepath:{dtype:"T"},rowMode:{dtype:"T"},gridId:{dtype:"T"},chartType:{dtype:"T",binding:"read"},captionField:{dtype:"T",binding:"read"},valueFields:{dtype:"T",nullable:!0,binding:"read"}},implementation:t=>class extends t{#e;#t;#s=0;#r=!1;#n;#i;#o;#u;#c;#a;#f;#l;#p;#h;#m=Symbol("chart-options");constructor(){super(),this.control.replaceChildren();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0;overflow:hidden}",this.shadowRoot.append(e),this.#n=this.ownerDocument.createElement("div"),this.#n.setAttribute("role","alert"),this.#n.hidden=!0,this.#n.style.cssText="padding:20px;white-space:normal",this.control=this.ownerDocument.createElement("div"),this.controlBox.append(this.#n,this.control),this.controlBox.style.backgroundColor="#fff",this.#n.style.color="#333",this.control.style.cssText="width:100%;height:100%;min-width:0;background:#fff",this.#p=new this.ownerDocument.defaultView.ResizeObserver(()=>this.#l?.resize())}setSourceContext(e){this.#i=e}setStoreBag(e){if(e!=null&&!(e instanceof gs)&&!Array.isArray(e))throw new TypeError("Chart requires a Data Bag or sample array");this.#o=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#g(),this.#r&&(this.#y(),this.#d()),n}#g(){let e=this.parameters.seriesOptions;if(!(e instanceof gs))throw new TypeError("seriesOptions requires a Bag");e!==this.#h&&(this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=e,e.subscribe(this.#m,{any:()=>this.#d()}))}connectedCallback(){this.#r=!0,this.#g();let e=this.#i.sourceNode.rootBuilder.binding;if(this.parameters.gridId){let r=e.nodeIds.get(this.parameters.gridId);if(!r||r.nodeTag!=="grid")throw new TypeError("gridId requires an existing grid nodeId");if(r.absDatapath(r.getAttr("storepath"))!==this.#i.sourceNode.absDatapath(this.parameters.storepath))throw new TypeError("Chart and grid must use the same storepath");this.#u=Ka(r),this.#c=this.#u.subscribe(()=>this.#w())}this.#y(),this.#d(),this.#p.observe(this.control)}#y(){if(this.parameters.rowMode==="samples"){if(this.parameters.gridId||this.parameters.timeField)throw new TypeError("Sample charts do not use grid filters or temporal playback");this.#e||(this.#f?.(),this.#f=null,this.#a?.dispose(),this.#a=null,this.#l?.dispose(),this.#l=null,this.#e=new Gn),this.#e.bind(this.#o??[],this.parameters.sampleStep,this.parameters.sampleStart,this.parameters.captionField,this.parameters.valueFields),this.#l||(this.#t=new _r(this.#e),this.#l=new Ur(this.control,this.#t,{renderer:"svg",domains:r=>this.#e.domains(r,this.parameters.sampleMin,this.parameters.sampleMax)}));return}this.#e&&(this.#l.dispose(),this.#l=null,this.#e=null);let e=this.#i.sourceNode.rootBuilder.binding.collectionStore(this.#o,this.parameters.rowMode);this.#a?this.#a.view.bag!==this.#o&&this.#a.bindStore(e):(this.#a=new ti(e),this.#t=new _r(this.#a.view),this.#l=new Ur(this.control,this.#t,{renderer:"svg",domains:r=>this.#t.domains(r),onTerritorySelect:r=>this.#i.writeParameter("selectedTerritory",r)}),this.#f=this.#a.view.subscribe(()=>{this.#t.invalidateDomains(),this.#d()})),this.#u&&this.#w()}#w(){let e=this.#u.view;if(!e){this.#a?.detach();return}!this.#a||e.bag!==this.#o||(this.#a.follow(e),this.#d())}async#d(){if(!this.#l)return;let{engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:s,geometryField:o,geoJSON:a,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f}=this.parameters,h=++this.#s;this.#l.invalidate();try{this.#t.setPeriod(this.parameters.timeField,this.parameters.timeValue,this.parameters.timeStep,this.parameters.timeEmpty);let d=this.#t.getRows(),p=this.#t.snapshotDate;if(this.parameters.configpath){let g=this.#i.sourceNode,y=`${this.parameters.configpath}.timeSnapshotLabel`,E=p&&p.getTime()!==this.parameters.timeValue.getTime()?`Showing: ${In(p,this.parameters.timeStep)}`:"";g.getRelativeData(y)!==E&&g.setRelativeData(y,E)}if(!d.length&&!(this.parameters.timeField&&this.#a.view.getRows().some(g=>this.#a.view.value(g,this.parameters.timeField)!=null))){this.control.hidden=!0,this.#n.setAttribute("role","status"),this.#n.textContent="No data to display",this.#n.hidden=!1;return}if(await this.#l.prepare(e,r),h!==this.#s||!this.#l)return;this.control.hidden=!1;let m=new gs({engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:s,geometryField:o,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f});if(m.setItem("geoJSON",a),await this.#l.update(m,this.#h),h!==this.#s||!this.#l)return;this.#n.setAttribute("role","alert"),this.#n.hidden=!0,this.#n.textContent="",this.#l.resize()}catch(d){if(h!==this.#s||!this.#l)return;this.control.hidden=!0,this.#n.setAttribute("role","alert"),this.#n.textContent=d.message,this.#n.hidden=!1}}disconnectedCallback(){this.#r=!1,this.#s++,this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=null,this.#p.disconnect(),this.#c?.(),this.#f?.(),this.#a?.dispose(),this.#l?.dispose(),this.#e=null,this.#u=this.#a=this.#l=this.#c=this.#f=null}}}),y1=es({name:"charts",assets:{echartsGlLicense:De["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:De["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:De["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:De["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:De["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]},components:[Qa,fd,Tu,Xa,Da]});export{y1 as default};
13
+ .js-plotly-plot .crisp{shape-rendering:crispEdges}`,this.#e.parentElement.append(this.#i));let n=this.#e.getBoundingClientRect();await ie.react(this.#e,t.data,{...t.layout,width:Math.max(1,n.width),height:Math.max(1,n.height)},{displayModeBar:!1,responsive:!1,displaylogo:!1,scrollZoom:e.type.id==="map"}),this.#o?ie.purge(this.#e):(this.#c=!0,this.#a=e.type.id,this.#r||(this.#e.on("plotly_click",s=>{let l=s.points[0];this.#a==="map"&&l?.data.type==="choropleth"&&this.#t.onTerritorySelect?.(l.location)}),this.#e.on("plotly_afterplot",()=>this.#d()),this.#r=!0),this.#d())},i=this.#n.then(o);return this.#n=i.catch(()=>{}),i}#d(){if(this.#a!=="map"||this.#o)return;let e=[],t=this.#e.getBoundingClientRect();for(let r of this.#e.querySelectorAll(".scattergeo text")){r.style.visibility="visible",r.style.pointerEvents="none";let o=r.getBoundingClientRect(),i=e.some(s=>o.left<s.right+4&&o.right>s.left-4&&o.top<s.bottom+2&&o.bottom>s.top-2),n=o.left<t.left||o.right>t.right||o.top<t.top||o.bottom>t.bottom;i||n?r.style.visibility="hidden":r.textContent&&e.push(o)}}render_bar(e){return this.#l(e,{type:"bar"})}render_line(e){return this.#l(e,{type:"scatter"})}render_area(e){return this.#l(e,{type:"scatter",area:!0})}render_stackedBar(e){return this.#l(e,{type:"bar",stacked:!0})}render_stackedArea(e){return this.#l(e,{type:"scatter",area:!0,stacked:!0})}render_horizontalBar(e){return this.#l(e,{type:"bar",horizontal:!0})}render_pie(e){return this.#m(e,!1)}render_donut(e){return this.#m(e,!0)}render_scatter(e){return this.#l(e,{type:"scatter",points:!0})}render_line3D(e){return ve(e,"line3D",this.#s())}render_scatter3D(e){return ve(e,"scatter3D",this.#s())}render_surface(e){return ve(e,"surface",this.#s())}render_map(e){return zt(e,this.#s())}#l({view:e,category:t,fields:r,settings:o,domains:i},{type:n,area:s=!1,stacked:l=!1,horizontal:c=!1,points:p=!1}){let{source:g,kind:u}=k(e,t,r,i?.dimension);if(p&&!["value","time"].includes(u))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(l&&new Set(o.map(y=>y.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(l&&new Set(g.map(y=>y[0])).size!==g.length)throw new TypeError("Plotly stacked series require distinct X values. Prepare the store upstream. Configuration retained.");if(l&&s&&g.some(y=>y.slice(1).some(x=>x<0)))throw new TypeError("Plotly stacked areas do not implement separate positive/negative stacks. Choose another type or engine. Configuration retained.");let h=g.map(y=>u==="time"?new Date(y[0]).toISOString():y[0]),b=this.#s(),m=c?"y":"x",f=c?"x":"y";b.barmode=l?"relative":"group",b[m+"axis"]={type:u==="time"&&!c?"date":u==="category"||n==="bar"?"category":"linear",automargin:!0};for(let[y,x]of["left","right"].entries())b[f+"axis"+(y?"2":"")]={side:c?y?"top":"bottom":x,visible:o.some(v=>v.axis===x),automargin:!0,title:{text:r.filter((v,T)=>o[T].axis===x).join(", ")},...y?{overlaying:f}:{},rangemode:"tozero"};if(i){let y=b[m+"axis"];y.type==="category"?(y.categoryorder="array",y.categoryarray=i.dimension.values.map(x=>u==="time"?new Date(x).toISOString():x),y.range=[-.5,y.categoryarray.length-.5]):y.range=i.dimension.range.map(x=>u==="time"?new Date(x).toISOString():x),y.autorange=!1;for(let[x,v]of["left","right"].entries())Object.assign(b[f+"axis"+(x?"2":"")],{range:i.axes[v],autorange:!1})}return{data:r.map((y,x)=>({type:n,name:y,[m]:[...h],[f]:g.map(v=>v[x+1]),[f+"axis"]:f+(o[x].axis==="right"?"2":""),marker:{color:o[x].color},...n==="scatter"?{mode:p?"markers":g.length===1?"lines+markers":"lines",line:{color:o[x].color},...s?{fill:l?"tonexty":"tozeroy",fillcolor:o[x].color+"4d"}:{},...l?{stackgroup:"measures",stackgaps:"infer zero"}:{}}:{orientation:c?"h":"v",...l?{}:{offsetgroup:y},alignmentgroup:"measures"}})),layout:b}}#m({view:e,category:t,fields:r,domains:o},i){let{source:n,kind:s}=k(e,t,r,o?.dimension),l=n.map(c=>s==="time"?new Date(c[0]).toISOString().slice(0,10):String(c[0]));if(new Set(l).size!==n.length)throw new TypeError("Plotly pie/donut requires distinct category labels. Prepare the store upstream or choose another engine. Configuration retained.");if(n.some(c=>c[1]<0))throw new TypeError("Pie and donut require nonnegative values. Configuration retained.");return{layout:this.#s(),data:r.map(c=>({type:"pie",name:c,sort:!1,hole:i?.5:0,labels:l,...o?{marker:{colors:l.map(p=>E[o.labels.indexOf(p)%E.length])}}:{},values:n.map(p=>p[1]),textposition:"inside",textinfo:"label+percent",automargin:!0}))}}#s(){return{paper_bgcolor:"#fff",plot_bgcolor:"#fff",font:{color:"#333"},showlegend:!0,margin:{l:70,r:70,t:40,b:75},legend:{orientation:"h",y:-.18,x:0},autosize:!0}}resize(){if(this.#o||!this.#c)return;let e=this.#e.getBoundingClientRect();if(this.#e.layout.width===Math.round(e.width)&&this.#e.layout.height===Math.round(e.height))return;let t=()=>{if(this.#o)return;let r=this.#e.getBoundingClientRect();return ie.relayout(this.#e,{width:Math.max(1,Math.round(r.width)),height:Math.max(1,Math.round(r.height))})};this.#n=this.#n.then(t).catch(()=>{})}dispose(){this.#o=!0,this.#i?.remove(),this.#c&&ie.purge(this.#e)}};var K={echarts:xe,plotly:Se,vega:me,uplot:ue};function br(a){let e=K[a];if(!Object.hasOwn(K,a))throw new TypeError(`Unknown chart engine: ${a}`);return e}function Te(a){return Object.getOwnPropertyNames(a.prototype).filter(e=>e.startsWith("render_")&&typeof a.prototype[e]=="function").map(e=>e.slice(7))}function Ae(a,e){let t=br(a);if(!Te(t).includes(e))throw new TypeError(`${t.label} does not support ${e}. Choose another type or engine. Configuration retained.`);return t}function Rt(a,{configpath:e,storepath:t,rowMode:r,prefix:o}){let i={};function n(d,y,x,v,T,C=`${o}-${x}`){d.html_label(y,{for:C});let w={id:C,value:`^${e}.${x}`};T&&(w.nodeId=`${o}_${T}`,i[T]=w.nodeId);let S=d.select(w);for(let[M,F]of v){let D={value:M};if(x==="timeStep"&&["minute","hour"].includes(M))D.disabled=`^${e}.timeHasClock:=!{}`;else if(x==="chartType"){let $=Object.entries(K).filter(([,j])=>Te(j).includes(M)).map(([j])=>j);D.disabled=`^${e}.engine:=!${JSON.stringify($)}.includes({})`,D.hidden=D.disabled}else if(x==="engine"){let $=Te(K[M]);D.disabled=`^${e}.chartType:=!${JSON.stringify($)}.includes({})`,D.hidden=D.disabled}S.option(F,D)}return S}let s=[["","No columns"]];n(a,"Engine","engine",Object.entries(K).map(([d,y])=>[d,y.label])),n(a,"Chart type","chartType",q.map(d=>[d.id,d.label]));let l=a.details({id:`${o}-animation`});l.summary("Temporal animation");let c=l.div({display:"grid",gap:"4px"});n(c,"Date field","timeField",[["","Off"]],"timeFieldId");let p=c.div({display:`^${e}.timeField:={} ? 'grid' : 'none'`,gap:"4px"});n(p,"Period","timeStep",[["auto","Automatic"],["minute","Minute"],["hour","Hour"],["day","Day"],["week","Week \xB7 Mon\u2013Sun"],["month","Month"],["year","Year"]]),n(p,"Empty periods","timeEmpty",[["previous","Keep previous snapshot"],["empty","Show empty"]]);let g=p.div();g.span("Current period (UTC): "),g.span(`^${e}.timeUnit`),p.html_label("Seconds per frame",{for:`${o}-time-speed`}),p.numberTextBox({id:`${o}-time-speed`,value:`^${e}.timeSpeed`,min:.1,max:10}),a.chartTimeline({storepath:t,rowMode:r,configpath:e,timeField:`^${e}.timeField`,timeStep:`^${e}.timeStep`,timeIndex:`^${e}.timeIndex`});let u={category(d){n(d,"Category / territory field","captionField",s,"categoryId")},geoJSON(d){d.chartGeoJSON({value:`^${e}.geoJSON`}),d.div("Link the category / territory field to GeoJSON properties.name.",{style:"font-size:11px"})},mapMeasure(d){n(d,"Map measure","mapValueField",[["","No measures"]],"mapMeasureId"),n(d,"Map label field","mapLabelField",s,"mapLabelId"),n(d,"Map labels","mapLabelMode",[["none","None"],["name","Names"],["value","Values"],["nameValue","Names and values"]]),d.div("Calculated measures must be supplied as store columns.",{style:"font-size:11px"})},mapBarScale(d){n(d,"Height scale","mapBarScale",[["zero","From zero"],["extent","Data range"]]),d.div("Selected measures share one height scale. Data range truncates the baseline; tooltip values are unchanged.",{style:"font-size:11px"})},secondDimension(d){n(d,"Second dimension","secondCaptionField",s,"secondCategoryId")},geometry(d){n(d,"Coordinate field","geometryField",s,"geometryId")},measures(d){let y=d.menu({presentation:"bar",aria_label:"Measures toolbar"}).menuline({caption:"Measures",aria_label:"Choose measures"}).menu({nodeId:`${o}_measureMenuId`});i.measureMenuId=`${o}_measureMenuId`,y.menuline({caption:"No measures",disabled:!0});let v=d.grid({id:`${o}-measures`,storepath:`${e}.seriesOptions`,rowMode:"values",height:"120px",style:"--gramlot-grid-row-height:24px;--gramlot-grid-font-size:12px;--gramlot-grid-cell-padding:2px 5px",filter:{value:"^true",columns:["selected"],dtype:"T"}}).struct();v.column({field:"caption",name:"Measure",width:"40%"}),v.column({field:"color",name:"Color",width:"30%",edit:{tag:"colorpicker"}}),v.column({field:"axis",name:"Axis",width:"30%",edit:{tag:"filteringSelect",values:"left:Left,right:Right",validate_select:!0}})}},h={category:d=>G(d,"captionField").length>0,secondDimension:d=>G(d,"secondCaptionField").length>0,geometry:d=>G(d,"geometryField").length>0,mapMeasure:d=>G(d,"mapValueField").length>0,measures:d=>G(d,"valueFields").some(y=>y.count==="many"),geoJSON:d=>d.controls.includes("geoJSON"),mapBarScale:d=>d.controls.includes("mapBarScale")},b=d=>`^${e}.chartType:=${JSON.stringify(d)}.includes({}) ? "grid" : "none"`;for(let[d,y]of Object.entries(u)){let x=a.div({display:b(q.filter(h[d]).map(v=>v.id)),gap:"4px"});y(x)}let m=new Map;for(let d of q)for(let y of H(d))m.has(y)||m.set(y,{role:G(d,"valueFields").find(x=>x.name===y),types:[]}),m.get(y).types.push(d.id);let f=[];for(let[d,{role:y,types:x}]of m){let v=a.div({display:b(x),gap:"4px"});n(v,y.caption,`measureRoles.${d}`,[["","Choose a column"]],`measureRole_${d}`,`${o}-role-${d}`),f.push(i[`measureRole_${d}`]),delete i[`measureRole_${d}`]}a.chartFields({storepath:t,rowMode:r,configpath:e,measureRoleIds:f.join(","),...i})}var Lt=(0,I.defineComponent)({name:"chartPane",tag:"gramlot-chart-pane",base:z,sourceContext:!0,subTags:"*",parameters:{configDefaults:{dtype:"X",nullable:!0},storepath:{dtype:"T"},configpath:{dtype:"T"},rowMode:{dtype:"T",default:"attributes"},gridId:{dtype:"T",nullable:!0}},implementation:a=>class extends a{#e;#t=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}connectedCallback(){if(this.#t)return;let e=this.#e.sourceNode;if(e.value!==null&&e.value.getNode("frame"))return;let t=e.absDatapath(this.parameters.storepath),r=e.absDatapath(this.parameters.configpath),o=e.getRelativeData(r);o==null&&(o=new Z,e.setRelativeData(r,o));let i=this.parameters.configDefaults;if(i!=null){if(!(i instanceof Z))throw new TypeError("configDefaults requires a Bag");let w=wr(xr(i));for(let S of w.getNodes())o.getNode(S.label)||o.setItem(S.label,S.getValue())}if(!(o instanceof Z))throw new TypeError("chartPane requires a configuration Bag");let n={mapLabelMode:"value",mapBarScale:"zero",selectedTerritory:"",timeField:"",timeEmpty:"previous",timeSnapshotLabel:"",timeStep:"auto",timeUnit:"month",timeHasClock:!1,timeIndex:0,timeMax:0,timeAtEnd:!0,timeValue:null,timeLabel:"",timePlaying:!1,timeSpeed:.8,engine:"echarts",chartType:"bar",captionField:"",secondCaptionField:"",geometryField:"",mapValueField:"",mapLabelField:"",geoJSON:null,drawer:"close"};for(let[w,S]of Object.entries(n))o.getNode(w)||o.setItem(w,S);if(o.getNode("seriesOptions")||o.setItem("seriesOptions",new Z),o.getNode("measureRoles")||o.setItem("measureRoles",new Z),!(o.getItem("seriesOptions")instanceof Z))throw new TypeError("seriesOptions must be a Bag");let s=new e.builder.source.constructor(null,e.builder),l=e.builder.wrapSource(s).framePane({node_label:"frame",height:"100%"}),c=JSON.stringify(Object.fromEntries(q.map(w=>[w.id,H(w)]).filter(([,w])=>w.length)));l.dataFormula({result_path:`${r}.valueFields`,formula:`(${c}[type] ?? null) ? ${c}[type].map(name => roles.getItem(name) || '').filter(Boolean).join(',') : options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')`,options:`^${r}.seriesOptions`,roles:`^${r}.measureRoles`,type:`^${r}.chartType`,_onBuilt:!0});let p=l.top.contentPane({display:"flex",justify_content:"flex-end",align_items:"center",padding:"2px 6px"}),g=JSON.stringify(`${r}.drawer`);p.button({icon:"\u2699",aria_label:"Chart settings",title:"Chart settings",action:`this.SET(${g},this.GET(${g}) === 'close' ? true : 'close');`});let u=e.getAttr("id")??`chart-${B()}`,h=l.center.borderContainer({id:`${u}-layout`,height:"100%"}),b=h.contentPane({region:"right",width:"260px",drawer:`^${r}.drawer`,drawer_style:"display:none",detachable:!0,title:"Chart configuration",padding:"8px",border_left:"1px solid var(--gramlot-border)",background:"var(--gramlot-surface)",overflow:"auto",display:"grid",gap:"4px",align_content:"start",style:"font-size:12px;--gramlot-field-height:26px;--gramlot-field-padding:2px 5px;--gramlot-grid-row-height:26px"}),m={id:`${u}-view`,configpath:r,storepath:t,rowMode:this.parameters.rowMode};for(let w of["mapLabelMode","mapBarScale","selectedTerritory","timeEmpty","timeField","timeValue","timeStep","engine","mapValueField","mapLabelField","geoJSON","geometryField","chartType","captionField","secondCaptionField","valueFields","seriesOptions"])m[w]=`^${r}.${w==="timeStep"?"timeUnit":w}`;this.parameters.gridId&&(m.gridId=this.parameters.gridId),h.contentPane({region:"center",min_width:"0"}).chartView(m),Rt(b,{configpath:r,storepath:t,rowMode:this.parameters.rowMode,prefix:u}),l.dataFormula({result_path:`${r}.timeInterval`,formula:"playing ? speed : 0",playing:`^${r}.timePlaying`,speed:`^${r}.timeSpeed`,_onBuilt:!0}),l.dataController({func:Je(e.rootBuilder.binding),configpath:r,_timing:`^${r}.timeInterval`}),l.dataFormula({result_path:`${r}.timeAtEnd`,formula:"index >= max",index:`^${r}.timeIndex`,max:`^${r}.timeMax`,_onBuilt:!0});let f=l.bottom.contentPane({display:`^${r}.timeField:={} ? 'flex' : 'none'`,align_items:"center",flex_wrap:"wrap",gap:"10px",padding:"8px 12px",role:"toolbar",aria_label:"Playback controls",background:"var(--gramlot-surface-subtle)",border_top:"1px solid var(--gramlot-border)"}),d=w=>JSON.stringify(`${r}.${w}`),y=f.div({display:"flex",align_items:"center",gap:"2px",flex_shrink:"0"});y.button({icon:"\u2190",aria_label:"Previous period",title:"Previous period",id:`${u}-time-previous`,disabled:`^${r}.timeIndex:={} <= 0`,action:`this.SET(${d("timePlaying")},false);this.SET(${d("timeIndex")},Math.max(0,this.GET(${d("timeIndex")})-1));`}),y.button({icon:`^${r}.timePlaying:={} ? '\u23F8\uFE0E' : '\u25B6'`,aria_label:`^${r}.timePlaying:={} ? 'Pause' : 'Play'`,title:`^${r}.timePlaying:={} ? 'Pause' : 'Play'`,aria_pressed:`^${r}.timePlaying`,id:`${u}-time-play`,disabled:`^${r}.timeMax:={} === 0`,action:`if(!this.GET(${d("timePlaying")}) && this.GET(${d("timeIndex")}) >= this.GET(${d("timeMax")}))this.SET(${d("timeIndex")},0);this.SET(${d("timePlaying")},!this.GET(${d("timePlaying")}));`}),y.button({icon:"\u25A0",aria_label:"Stop",title:"Stop and return to the beginning",id:`${u}-time-stop`,disabled:`^${r}.timeMax:={} === 0`,action:`this.SET(${d("timePlaying")},false);this.SET(${d("timeIndex")},0);`}),y.button({icon:"\u2192",aria_label:"Next period",title:"Next period",id:`${u}-time-next`,disabled:`^${r}.timeAtEnd`,action:`this.SET(${d("timePlaying")},false);this.SET(${d("timeIndex")},Math.min(this.GET(${d("timeMax")}),this.GET(${d("timeIndex")})+1));`}),f.div({flex:"1",min_width:"120px"}).horizontalSlider({width:"100%",id:`${u}-time-slider`,aria_label:"Temporal snapshot",value:`^${r}.timeIndex`,min:0,max:`^${r}.timeMax`,step:1,live:!0,flex:"1",connect_oninput:`this.SET(${d("timePlaying")},false);`});let v=f.div({display:"grid",gap:"2px",white_space:"nowrap",text_align:"right",font_size:"12px",font_variant_numeric:"tabular-nums"});v.span(`^${r}.timeLabel`,{id:`${u}-time-label`,font_weight:"600"}),v.small(`^${r}.timeSnapshotLabel`,{id:`${u}-snapshot-label`,color:"var(--gramlot-text-secondary)",display:`^${r}.timeSnapshotLabel:={} ? '' : 'none'`});let T=e.rootBuilder.binding.gramlot,C=T.src.prepareSource(s);T.src.renderer.validateCandidate(C),this.#t=!0,e.setValue(C)}}});import{Bag as Re}from"@gramlot/gramlot";var Pe=class{#e=new Set;view=null;#t;columns=[];update(e,t){if(!(this.view===e&&this.#t===e.bag&&this.columns===t)){this.view=e,this.#t=e.bag,this.columns=t;for(let r of this.#e)r()}}detach(e){if(this.view===e){this.view=null,this.#t=null,this.columns=[];for(let t of this.#e)t()}}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}};function Bt(a){return Object.hasOwn(a,"gridSearch")||Object.defineProperty(a,"gridSearch",{value:new Pe,configurable:!0}),a.gridSearch}var Ce=class{bind(e,t,r,o,i){if(!Array.isArray(e)||e.some(n=>typeof n!="number"||!Number.isFinite(n)))throw new TypeError("Sample chart requires an array of finite numbers");if(!Number.isFinite(t)||t<=0||!Number.isFinite(r))throw new TypeError("Sample chart requires a positive step and finite start");if(typeof o!="string"||!o||typeof i!="string"||!i||i.includes(",")||o===i)throw new TypeError("Sample chart requires distinct captionField and one valueFields name");this.samples=e,this.step=t,this.start=r,this.category=o,this.measure=i,this.rows?.length!==e.length&&(this.rows=Array.from(e.keys()))}domains(e,t,r){if(t==null&&r==null)return null;if(!Number.isFinite(t)||!Number.isFinite(r)||t>=r)throw new TypeError("Sample bounds require finite sampleMin < sampleMax");let o=se(this,e);return o.dimension.range=[this.start,this.start+Math.max(1,this.samples.length-1)*this.step],o.axes={left:[t,r],right:[t,r]},o.z=[t,r],o}getRows(){return this.rows}value(e,t){if(t===this.category)return this.start+e*this.step;if(t===this.measure)return this.samples[e];throw new TypeError(`Unknown sample field: ${t}`)}};import{sharedModules as vr}from"@gramlot/gramlot";var Sr=a=>vr["./stores/bag-collection-view.js"][a],jt=Sr("BagCollectionView");var Fe=class{#e=null;#t=null;#a;#r;constructor(e,t){this.#r=new jt(e),t&&this.follow(t),this.#r.connect()}bindStore(e){this.detach(),this.#r.bindStore(e)}get view(){return this.#r}follow(e){if(e.bag!==this.#r.bag||e.rowMode!==this.#r.rowMode)throw new TypeError("Chart and grid must use the same collection");this.#t?.(),this.#e=e,this.#a=void 0,this.#i(),this.#t=e.subscribe(()=>this.#i())}#i(){let e=this.#e.filterSignature;e!==this.#a&&(this.#r.copyFiltersFrom(this.#e),this.#a=e)}detach(){this.#t?.(),this.#t=null,this.#e=null}dispose(){this.detach(),this.#r.disconnect()}};import{Bag as De}from"@gramlot/gramlot";var ze=new WeakMap;function Tr(a){if(!ze.has(a)){let e=`chart_${B()}`;class t{toggleMeasure(o){let i=o.getAttr("selectionPath");o.setRelativeData(i,!o.getRelativeData(i))}}a.logicRegistry.register(t,{group:e,resource:"gramlot:charts"}),ze.set(a,`${e}.toggleMeasure`)}return ze.get(a)}function Cr(a){let e=a.getRows(),t=[...new Set(e.flatMap(i=>a.rowMode==="attributes"?Object.keys(i.getAttr()):i.staticValue.getNodes().map(n=>n.label)))],r=t.filter(i=>e.every(n=>{let s=a.value(n,i);return typeof s=="number"&&Number.isFinite(s)})),o=t.filter(i=>e.some(n=>a.value(n,i)instanceof Date)&&e.every(n=>{let s=a.value(n,i);return s==null||s instanceof Date&&Number.isFinite(s.getTime())}));return{fields:t,measures:r,dates:o}}var Gt=(0,I.defineComponent)({name:"chartFields",tag:"gramlot-chart-fields",base:z,sourceContext:!0,bagStore:!0,parameters:{timeFieldId:{dtype:"T"},storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},categoryId:{dtype:"T"},mapMeasureId:{dtype:"T"},mapLabelId:{dtype:"T"},secondCategoryId:{dtype:"T"},geometryId:{dtype:"T"},measureMenuId:{dtype:"T"},measureRoleIds:{dtype:"T"}},implementation:a=>class extends a{#e;#t;#a;#r;#i;#o=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){if(!(e instanceof De))throw new TypeError("chartFields requires a Data Bag");this.#t=e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#o&&this.#n(),r}connectedCallback(){this.#o=!0,this.#n()}#n(){let t=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);t!==this.#a&&(this.#r?.(),this.#a=t,this.#i=void 0,this.#r=t.subscribe(()=>this.#c(t)),this.#c(t))}#c(e){if(!e.getRows().length)return;let{fields:t,measures:r,dates:o}=Cr(e),i=JSON.stringify([t,r,o]);if(i===this.#i)return;let n=this.#e.sourceNode,s=n.getRelativeData(this.parameters.configpath),l=s.getItem("seriesOptions"),c=n.rootBuilder.binding,p=c.nodeIds.get(this.parameters.categoryId),g=c.nodeIds.get(this.parameters.measureMenuId),u=["#5470c6","#ee6666","#3ba272","#fac858","#9a60b4","#73c0de"];for(let m of[...l.getNodes()])r.includes(m.label)||l.popNode(m.label);r.forEach((m,f)=>{l.getNode(m)||l.setItem(m,new De);let d=l.getItem(m);for(let[y,x]of Object.entries({axis:"left",color:u[f%u.length],caption:m.charAt(0).toUpperCase()+m.slice(1),selected:!0}))d.getNode(y)||d.setItem(y,x)});let h=(m,f,d=y=>y.charAt(0).toUpperCase()+y.slice(1))=>{let y=new Set;for(let x of[...m.value.getNodes()]){let v=x.getAttr("value");f.includes(v)?y.add(v):m.value.popNode(x.label)}f.forEach(x=>{y.has(x)||m.builder.wrapSource(m).option(d(x),{value:x,node_label:`field_${B()}`})}),f.length||m.builder.wrapSource(m).option("No columns",{value:"",node_label:"empty"})};h(p,t),this.parameters.timeFieldId&&(h(c.nodeIds.get(this.parameters.timeFieldId),["",...o],m=>m?m.charAt(0).toUpperCase()+m.slice(1):"Off"),s.getItem("timeField")&&!o.includes(s.getItem("timeField"))&&(s.setItem("timeField",""),s.setItem("timePlaying",!1))),h(c.nodeIds.get(this.parameters.mapMeasureId),r,m=>l.getItem(m).getItem("caption")),h(c.nodeIds.get(this.parameters.mapLabelId),t),r.includes(s.getItem("mapValueField"))||s.setItem("mapValueField",r.find(m=>l.getItem(m).getItem("selected"))??r[0]??""),t.includes(s.getItem("mapLabelField"))||s.setItem("mapLabelField",t.includes(s.getItem("captionField"))?s.getItem("captionField"):t[0]??""),h(c.nodeIds.get(this.parameters.geometryId),t);for(let m of this.parameters.measureRoleIds.split(","))h(c.nodeIds.get(m),["",...r],f=>f?l.getItem(f).getItem("caption"):"Choose a column");s.getItem("measureRoles")instanceof De||s.setItem("measureRoles",new De);let b=s.getItem("measureRoles");for(let m of q)H(m).forEach((f,d)=>{r.includes(b.getItem(f))||b.setItem(f,r[d]??"")});h(c.nodeIds.get(this.parameters.secondCategoryId),t);for(let m of[...g.value.getNodes()])g.value.popNode(m.label);r.forEach((m,f)=>{let d=`${this.parameters.configpath}.seriesOptions.${m}.selected`;g.builder.wrapSource(g).menuline({node_label:`measure_${f}`,caption:l.getItem(m).getItem("caption"),checked:`^${d}`,selectionPath:d,action:Tr(c)})}),r.length||g.builder.wrapSource(g).menuline({caption:"No measures",disabled:!0,node_label:"empty"}),t.includes(s.getItem("captionField"))||s.setItem("captionField",t[0]??""),t.includes(s.getItem("secondCaptionField"))||s.setItem("secondCaptionField",t.find(m=>m!==s.getItem("captionField"))??""),t.includes(s.getItem("geometryField"))||s.setItem("geometryField",t.find(m=>e.getRows().every(f=>Array.isArray(e.value(f,m))))??""),this.#i=i}disconnectedCallback(){this.#o=!1,this.#r?.(),this.#r=null,this.#a=null,this.#i=void 0}}});import{Bag as Vt}from"@gramlot/gramlot";var W=class extends TypeError{constructor(e){super(e.message),this.name="ChartSyntaxError",this.diagnosis=e}};function Q(a){return a.join(", ")}function V(a,e,t,r,o,i){throw new W({type:a.id,role:e?e.name:null,message:t,expected:r,received:o,fix:i})}function Fr(a,e){let t=e.getItem("valueFields");t!=null&&typeof t!="string"&&V(a,null,"valueFields requires comma-separated codes or null","comma-separated column codes",String(t),'Pass the measures as one string, for example "open,high,low,close".');let r=t?t.split(","):[];return(r.some(o=>!o)||new Set(r).size!==r.length)&&V(a,null,"valueFields requires distinct nonempty fields","distinct column codes",t,"Remove the empty or repeated codes from valueFields."),r}function Dr(a,e,t){let[r]=e;if(r.count==="many"){r.required&&!t.length&&V(a,r,`${a.label} needs at least one measure.`,"one or more measures","none","Choose at least one numeric column as measure.");return}let o=e.map(n=>n.name),i=e.length===1?"one measure":`${e.length} measures in the order ${Q(o)}`;if(t.length<e.length){let n=e[t.length];V(a,n,`${a.label} needs ${i}; received ${t.length}.`,i,Q(t)||"none",e.length===1?"Choose one numeric column as measure.":`Choose a column for ${Q(o.slice(t.length))}.`)}t.length>e.length&&V(a,null,`${a.label} takes ${i}; received ${t.length}: ${Q(t)}.`,i,Q(t),`Remove ${Q(t.slice(e.length))} from the measures.`)}function Jt(a,e){for(let i of a.syntax){if(i.parameter==="valueFields"||!i.required)continue;let n=e.getItem(i.parameter);(typeof n!="string"||!n)&&V(a,i,`${a.label} needs ${i.caption} (${i.parameter}).`,`a column for ${i.caption}`,"none",`Choose the column for ${i.caption}: ${i.doc}`)}let t=a.syntax.find(i=>i.parameter==="secondCaptionField");if(t&&e.getItem("secondCaptionField")===e.getItem("captionField")){let i=a.syntax[0];V(a,t,`${a.label} needs ${t.caption} different from ${i.caption}.`,"two different columns",e.getItem("captionField"),`Choose another column for ${t.caption}.`)}let r=a.syntax.filter(i=>i.parameter==="valueFields");if(!r.length)return[];let o=Fr(a,e);return Dr(a,r,o),o}function Mr(a,e,t){if(!(t instanceof Vt))throw new TypeError("seriesOptions requires a Bag");let r=pe(e.getItem("chartType")),o=e.getItem("captionField"),i=Jt(r,e),n=i.map(s=>{let l=t.getItem(s);if(!(l instanceof Vt))throw new TypeError(`Missing seriesOptions for ${s}`);let c=l.getItem("axis"),p=l.getItem("color");if(!["left","right"].includes(c)||typeof p!="string"||!/^#[0-9a-f]{6}$/i.test(p))throw new TypeError("Series requires left/right axis and a six-digit hex color");return{axis:c,color:p}});return{view:a,category:o,structure:e,fields:i,settings:n,seriesOptions:t,type:r}}var ne=class{#e;#t;#a;#r;#i;#o;#n=0;constructor(e,t,r={}){this.#e=e,this.#t=t,this.#a=r}async prepare(e,t){await Ae(e,t).load(t,this.#e.ownerDocument)}invalidate(){this.#n++}update(e,t){let r=e.getItem("engine")??"echarts",o=Mr(this.#t,e,t);o.domains=this.#a.domains?this.#a.domains(o):null;let i=Ae(r,o.type.id),n=++this.#n;r!==this.#i&&(this.#r?.dispose(),this.#o?.remove(),this.#o=null,this.#e&&(this.#o=this.#e.ownerDocument.createElement("div"),this.#o.style.cssText="width:100%;height:100%;position:relative",this.#e.append(this.#o)),this.#r=new i(this.#o,this.#a),this.#i=r);let s=this.#r.validate(o);return this.#r.update(o,s,()=>n===this.#n)}svg(){return this.#r.svg()}resize(){this.#r?.resize()}dispose(){this.invalidate(),this.#r?.dispose(),this.#r=null,this.#i=null,this.#o?.remove(),this.#o=null}};var Wt=["needle","ring","arc"];function Ut(a){if(a==null||a==="")return null;let e=Number(a);if(!Number.isFinite(e))throw new TypeError(`gauge requires a number, received '${a}'`);return e}function Ht(a){if(a==null||a==="")return[];if(typeof a!="string")throw new TypeError("gauge thresholds requires a string of value:color pairs");let e=a.split(",").map(t=>{let r=/^\s*(-?\d+(?:\.\d+)?)\s*:\s*(\S+)\s*$/.exec(t);if(!r)throw new TypeError(`Invalid gauge threshold '${t.trim()}': use value:color`);return{value:Number(r[1]),color:r[2]}}).sort((t,r)=>t.value-r.value);for(let t=1;t<e.length;t++)if(e[t].value===e[t-1].value)throw new TypeError(`Duplicate gauge threshold ${e[t].value}`);return e}function Ir(a,e,t){let r=t;for(let o of a)e>=o.value&&(r=o.color);return r}function Er(a,e,t,r){let o=[r,...a.map(s=>s.color)],i=[...a.map(s=>Math.min(1,Math.max(0,(s.value-e)/(t-e)))),1],n=[];return o.forEach((s,l)=>{i[l]>(n.at(-1)?.[0]??0)&&n.push([i[l],s])}),n}function $r(a,e){let t=String(Math.round(a*100)/100);return(e??"{}").replaceAll("{}",()=>t)}var kr={needle:{startAngle:225,endAngle:-45,center:["50%","52%"],radius:"78%",width:14,detail:[0,"58%"],title:[0,"82%"]},ring:{startAngle:90,endAngle:-270,center:["50%","50%"],radius:"88%",width:16,detail:[0,"-6%"],title:[0,"28%"]},arc:{startAngle:180,endAngle:0,center:["50%","72%"],radius:"112%",width:16,detail:[0,"-22%"],title:[0,"14%"]}};function Yt({value:a,min:e,max:t,mask:r,thresholds:o,presentation:i,caption:n,palette:s}){if(!Wt.includes(i))throw new TypeError(`gauge presentation must be one of ${Wt.join(", ")}`);if(!(Number.isFinite(e)&&Number.isFinite(t)&&e<t))throw new TypeError("gauge requires min lower than max");if(a!=null&&!Number.isFinite(a))throw new TypeError("gauge requires a finite number");let l=kr[i],c=i==="needle",p=a==null?null:Math.min(t,Math.max(e,a)),g=a==null?"":$r(a,r);return{animationDuration:300,series:[{id:"gauge",type:"gauge",min:e,max:t,startAngle:l.startAngle,endAngle:l.endAngle,center:l.center,radius:l.radius,splitNumber:5,pointer:{show:c,length:"62%",width:5,itemStyle:{color:s.ink}},anchor:{show:c,size:10,showAbove:!0,itemStyle:{color:s.ink}},progress:{show:!c,width:l.width,roundCap:!0,itemStyle:{color:a==null?s.accent:Ir(o,a,s.accent)}},axisLine:{roundCap:!c,lineStyle:{width:l.width,color:c?Er(o,e,t,s.accent):[[1,s.track]]}},axisTick:{show:c,distance:-l.width-4,length:4,lineStyle:{color:s.muted,width:1}},splitLine:{show:c,distance:-l.width-6,length:8,lineStyle:{color:s.muted,width:2}},axisLabel:{show:c,distance:l.width+6,color:s.muted,fontSize:11},title:{show:!0,offsetCenter:l.title,color:s.muted,fontSize:13},detail:{show:!0,offsetCenter:l.detail,color:s.ink,fontSize:22,fontWeight:"bold",valueAnimation:!1,formatter:()=>g},data:p===null?[]:[{value:p,name:n??""}]}]}}var Nr={error:"!",info:"i"},Ie=`
14
+ .chart-notice{display:flex;align-items:flex-start;gap:10px;padding:16px 20px;font:13px/1.45 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-ink,#243449)}
15
+ .chart-notice[hidden]{display:none}
16
+ .chart-notice-icon{flex:none;display:grid;place-items:center;inline-size:20px;block-size:20px;border-radius:50%;font:700 13px/1 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-surface,#fff)}
17
+ .chart-notice[data-kind=error] .chart-notice-icon{background:var(--gramlot-error,#b13d48)}
18
+ .chart-notice[data-kind=info] .chart-notice-icon{background:var(--gramlot-text-secondary,#566579)}
19
+ .chart-notice-text{flex:1;min-inline-size:0;white-space:normal;overflow-wrap:anywhere}
20
+ .chart-notice button{flex:none;font:inherit;padding:2px 10px;border:1px solid var(--gramlot-border-control,#a9b4c2);border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-surface,#fff);color:inherit;cursor:pointer}
21
+ .chart-notice-dialog{max-inline-size:min(640px,calc(100vw - 32px));border:1px solid var(--gramlot-border,#d5dce5);border-radius:var(--gramlot-radius,6px);padding:20px 24px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#243449);font:13px/1.5 var(--gramlot-font-ui,system-ui,sans-serif)}
22
+ .chart-notice-dialog h2{margin:0 0 12px;font-size:16px}
23
+ .chart-notice-dialog h3{margin:14px 0 4px;font-size:13px}
24
+ .chart-notice-dialog p{margin:0 0 6px}
25
+ .chart-notice-dialog table{border-collapse:collapse;inline-size:100%}
26
+ .chart-notice-dialog th,.chart-notice-dialog td{border-block-end:1px solid var(--gramlot-border,#d5dce5);padding:4px 6px;text-align:start;vertical-align:top}
27
+ .chart-notice-dialog code{font-family:var(--gramlot-font-code,ui-monospace,monospace)}
28
+ .chart-notice-dialog form{margin-block-start:16px;text-align:end}`;function Or(a,e){if(a.parameter!=="valueFields"||a.count==="many")return a.parameter;let t=e.filter(r=>r.parameter==="valueFields");return t.length===1?"valueFields":`valueFields, position ${t.indexOf(a)+1}`}function Me(a){return[{title:`What ${a.label.toLowerCase()} shows`,paragraphs:[a.doc]},{title:"Columns it reads",table:[["Column","Parameter","Required","Description"],...a.syntax.map(e=>[e.caption,Or(e,a.syntax),e.required?"yes":"no",e.count==="many"?`One or more. ${e.doc}`:e.doc])]}]}function Xt(a,e){if(a instanceof W){let{expected:t,received:r,fix:o}=a.diagnosis;return[{title:"What is wrong",paragraphs:[a.message]},{title:"Expected",paragraphs:[t]},{title:"Received",paragraphs:[r]},{title:"How to fix it",paragraphs:[o]},...Me(e)]}return e?[{title:"What is wrong",paragraphs:[a.message]},...Me(e)]:[{title:"What is wrong",paragraphs:[a.message]},{title:"Supported chart types",paragraphs:[q.map(t=>`${t.id} (${t.label})`).join(", ")]}]}var ee=class{#e;#t;#a;#r;#i=[];constructor(e){this.#e=e.createElement("div"),this.#e.className="chart-notice",this.#e.hidden=!0,this.#t=e.createElement("span"),this.#t.className="chart-notice-icon",this.#t.setAttribute("aria-hidden","true"),this.#a=e.createElement("div"),this.#a.className="chart-notice-text",this.#a.hidden=!0,this.#a.setAttribute("role","alert");let t=e.createElement("button");t.type="button",t.textContent="More info",t.addEventListener("click",()=>this.open()),this.#r=e.createElement("dialog"),this.#r.className="chart-notice-dialog",this.#e.append(this.#t,this.#a,t,this.#r)}get element(){return this.#e}get hidden(){return this.#e.hidden}get dialog(){return this.#r}get text(){return this.#a}error(e,t,r){this.#o("error","alert",e,t,r)}info(e,t,r){this.#o("info","status",e,t,r)}hide(){this.#e.hidden=this.#a.hidden=!0,this.#a.textContent="",this.#r.open&&this.#r.close()}open(){let e=this.#r.ownerDocument,t=e.createElement("h2");t.textContent=this.#i.title;let r=[t];for(let n of this.#i.items){let s=e.createElement("h3");s.textContent=n.title,r.push(s);for(let l of n.paragraphs??[]){let c=e.createElement("p");c.textContent=l,r.push(c)}if(n.table){let l=e.createElement("table");n.table.forEach((c,p)=>{let g=l.insertRow();for(let u of c){let h=e.createElement(p?"td":"th");h.textContent=u,g.append(h)}}),r.push(l)}}let o=e.createElement("form");o.method="dialog";let i=e.createElement("button");i.textContent="Close",o.append(i),r.push(o),this.#r.replaceChildren(...r),this.#r.showModal()}#o(e,t,r,o,i){this.#e.dataset.kind=e,this.#a.setAttribute("role",t),this.#t.textContent=Nr[e],this.#a.textContent=r,this.#i={title:o,items:i},this.#e.hidden=this.#a.hidden=!1}};var Kt=[{title:"What a gauge shows",paragraphs:["One number on a dial, a ring or an arc, between min and max. The number is the value of the gauge node."]},{title:"Parameters",table:[["Parameter","Description"],["value","The node value: a finite number. Empty is no value, never zero."],["min, max","The range of the scale; defaults 0 and 100."],["mask","The text of the value, with {} for the number rounded to two decimals; default {}."],["thresholds","Ascending bands as value:color pairs, for example 65:#e6a23c,85:#c23531; a color is a name or a hex code."],["presentation","needle, ring or arc."],["caption","A label under the value."]]}],qr={accent:"#235db2",ink:"#202936",muted:"#526174",track:"#e9edf2"},_r={accent:"#6ea8fe",ink:"#e8edf3",muted:"#a3b0c0",track:"#3a4554"},Zt=(0,I.defineComponent)({name:"gauge",tag:"gramlot-gauge",base:z,parameters:{min:{dtype:"R",default:0,binding:"read"},max:{dtype:"R",default:100,binding:"read"},mask:{dtype:"T",default:"{}",binding:"read"},thresholds:{dtype:"T",default:"",nullable:!0,binding:"read"},presentation:{dtype:"T",default:"needle",binding:"read"},caption:{dtype:"T",default:"",nullable:!0,binding:"read"}},implementation:a=>class extends a{#e;#t;#a;#r;#i;#o;#n;#c=!1;constructor(){super();let e=this.ownerDocument;this.control.replaceChildren();let t=e.createElement("style");t.textContent=":host{height:100%;min-height:160px}.control-box{height:100%;min-height:160px;overflow:hidden}"+Ie,this.shadowRoot.append(t),this.#a=new ee(e),this.#t=e.createElement("div"),this.#t.style.cssText="width:100%;height:100%;min-height:160px",this.control.append(this.#a.element,this.#t);let r=e.defaultView;this.#r=new r.ResizeObserver(()=>this.#e?.resize()),this.#i=new r.MutationObserver(()=>this.#s()),this.#o=new r.MutationObserver(()=>this.#s()),this.#n=r.matchMedia("(prefers-color-scheme: dark)")}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#c&&this.#s(),r}connectedCallback(){this.#c=!0,this.#i.observe(this,{childList:!0,subtree:!0,characterData:!0}),this.#o.observe(this.ownerDocument.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}),this.#n.addEventListener("change",this.#d),this.#r.observe(this.#t),this.ready=P("echarts",this.ownerDocument,()=>import("./modules/echarts.esm.min-VHLRZDVQ.js")).then(e=>{!this.#c||this.#e||(this.#e=e.init(this.#t,null,{renderer:"svg"}),this.#s())})}#d=()=>this.#s();#l(){let t=this.#m()?_r:qr,r=this.ownerDocument.defaultView.getComputedStyle(this),o=(i,n)=>r.getPropertyValue(i).trim()||n;return{accent:o("--gramlot-brand-blue",t.accent),ink:o("--gramlot-ink",t.ink),muted:o("--gramlot-text-secondary",t.muted),track:o("--gramlot-surface-subtle",t.track)}}#m(){let e=this.ownerDocument.documentElement.getAttribute("data-theme");return e?e==="dark":this.#n.matches}#s(){if(this.#e)try{let{min:e,max:t,mask:r,thresholds:o,presentation:i,caption:n}=this.parameters,s=Ut(this.textContent),l=Yt({value:s,min:e,max:t,mask:r,thresholds:Ht(o),presentation:i,caption:n,palette:this.#l()});if(s===null){this.#t.hidden=!0,this.#a.info("No value","Gauge: no value",[{title:"Why there is no value",paragraphs:["The gauge node is empty. A missing value is shown as no value, never as zero.",'Bind the node to a number, for example gauge("^.cpu").']},...Kt]);return}this.#a.hide(),this.#t.hidden=!1,this.#e.setOption(l,{replaceMerge:["series"]})}catch(e){this.#t.hidden=!0,this.#a.error(e.message,"Gauge: the value cannot be shown",[{title:"What is wrong",paragraphs:[e.message]},...Kt])}}disconnectedCallback(){this.#c=!1,this.#i.disconnect(),this.#o.disconnect(),this.#r.disconnect(),this.#n.removeEventListener("change",this.#d),this.#e?.dispose(),this.#e=null}}});var Ee=(0,I.defineComponent)({name:"chartView",tag:"gramlot-chart-view",base:z,sourceContext:!0,bagStore:!0,parameters:{sampleMin:{dtype:"R",nullable:!0,binding:"read"},sampleMax:{dtype:"R",nullable:!0,binding:"read"},sampleStep:{dtype:"R",default:1,binding:"read"},sampleStart:{dtype:"R",default:0,binding:"read"},mapLabelMode:{dtype:"T",default:"value",binding:"read"},mapBarScale:{dtype:"T",default:"zero",binding:"read"},selectedTerritory:{dtype:"T",default:"",binding:"twoWay"},configpath:{dtype:"T"},timeEmpty:{dtype:"T",default:"previous",binding:"read"},timeField:{dtype:"T",default:"",binding:"read"},timeValue:{dtype:"X",nullable:!0,binding:"read"},timeStep:{dtype:"T",default:"month",binding:"read"},engine:{dtype:"T",default:"echarts",binding:"read"},mapValueField:{dtype:"T",binding:"read"},mapLabelField:{dtype:"T",binding:"read"},geoJSON:{dtype:"X",nullable:!0,binding:"read"},geometryField:{dtype:"T",binding:"read"},secondCaptionField:{dtype:"T",binding:"read"},seriesOptions:{dtype:"X",binding:"read"},storepath:{dtype:"T"},rowMode:{dtype:"T"},gridId:{dtype:"T"},chartType:{dtype:"T",binding:"read"},captionField:{dtype:"T",binding:"read"},valueFields:{dtype:"T",nullable:!0,binding:"read"}},implementation:a=>class extends a{#e;#t;#a=0;#r=!1;#i;#o;#n;#c;#d;#l;#m;#s;#h;#u;#f=Symbol("chart-options");constructor(){super(),this.control.replaceChildren();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0;overflow:hidden}"+Ie,this.shadowRoot.append(e),this.#i=new ee(this.ownerDocument),this.control=this.ownerDocument.createElement("div"),this.controlBox.append(this.#i.element,this.control),this.controlBox.style.backgroundColor="var(--gramlot-surface,#fff)",this.control.style.cssText="width:100%;height:100%;min-width:0;background:#fff",this.#h=new this.ownerDocument.defaultView.ResizeObserver(()=>this.#s?.resize())}setSourceContext(e){this.#o=e}setStoreBag(e){if(e!=null&&!(e instanceof Re)&&!Array.isArray(e))throw new TypeError("Chart requires a Data Bag or sample array");this.#n=e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#g(),this.#r&&(this.#y(),this.#p()),r}#g(){let e=this.parameters.seriesOptions;if(!(e instanceof Re))throw new TypeError("seriesOptions requires a Bag");e!==this.#u&&(this.#u?.unsubscribe(this.#f,{any:!0}),this.#u=e,e.subscribe(this.#f,{any:()=>this.#p()}))}connectedCallback(){this.#r=!0,this.#g();let e=this.#o.sourceNode.rootBuilder.binding;if(this.parameters.gridId){let t=e.nodeIds.get(this.parameters.gridId);if(!t||t.nodeTag!=="grid")throw new TypeError("gridId requires an existing grid nodeId");if(t.absDatapath(t.getAttr("storepath"))!==this.#o.sourceNode.absDatapath(this.parameters.storepath))throw new TypeError("Chart and grid must use the same storepath");this.#c=Bt(t),this.#d=this.#c.subscribe(()=>this.#b())}this.#y(),this.#p(),this.#h.observe(this.control)}#y(){if(this.parameters.rowMode==="samples"){if(this.parameters.gridId||this.parameters.timeField)throw new TypeError("Sample charts do not use grid filters or temporal playback");this.#e||(this.#m?.(),this.#m=null,this.#l?.dispose(),this.#l=null,this.#s?.dispose(),this.#s=null,this.#e=new Ce),this.#e.bind(this.#n??[],this.parameters.sampleStep,this.parameters.sampleStart,this.parameters.captionField,this.parameters.valueFields),this.#s||(this.#t=new ae(this.#e),this.#s=new ne(this.control,this.#t,{renderer:"svg",domains:t=>this.#e.domains(t,this.parameters.sampleMin,this.parameters.sampleMax)}));return}this.#e&&(this.#s.dispose(),this.#s=null,this.#e=null);let e=this.#o.sourceNode.rootBuilder.binding.collectionStore(this.#n,this.parameters.rowMode);this.#l?this.#l.view.bag!==this.#n&&this.#l.bindStore(e):(this.#l=new Fe(e),this.#t=new ae(this.#l.view),this.#s=new ne(this.control,this.#t,{renderer:"svg",domains:t=>this.#t.domains(t),onTerritorySelect:t=>this.#o.writeParameter("selectedTerritory",t)}),this.#m=this.#l.view.subscribe(()=>{this.#t.invalidateDomains(),this.#p()})),this.#c&&this.#b()}#b(){let e=this.#c.view;if(!e){this.#l?.detach();return}!this.#l||e.bag!==this.#n||(this.#l.follow(e),this.#p())}async#p(){if(!this.#s)return;let{engine:e,chartType:t,captionField:r,valueFields:o,secondCaptionField:i,geometryField:n,geoJSON:s,mapValueField:l,mapLabelField:c,mapLabelMode:p,mapBarScale:g}=this.parameters,u=++this.#a;this.#s.invalidate();try{this.#t.setPeriod(this.parameters.timeField,this.parameters.timeValue,this.parameters.timeStep,this.parameters.timeEmpty);let h=this.#t.getRows(),b=this.#t.snapshotDate;if(this.parameters.configpath){let f=this.#o.sourceNode,d=`${this.parameters.configpath}.timeSnapshotLabel`,y=b&&b.getTime()!==this.parameters.timeValue.getTime()?`Showing: ${de(b,this.parameters.timeStep)}`:"";f.getRelativeData(d)!==y&&f.setRelativeData(d,y)}if(!h.length&&!(this.parameters.timeField&&this.#l.view.getRows().some(f=>this.#l.view.value(f,this.parameters.timeField)!=null))){this.control.hidden=!0,this.#i.info("No data to display","No data to display",this.#w(t));return}if(await this.#s.prepare(e,t),u!==this.#a||!this.#s)return;this.control.hidden=!1;let m=new Re({engine:e,chartType:t,captionField:r,valueFields:o,secondCaptionField:i,geometryField:n,mapValueField:l,mapLabelField:c,mapLabelMode:p,mapBarScale:g});if(m.setItem("geoJSON",s),await this.#s.update(m,this.#u),u!==this.#a||!this.#s)return;this.#i.hide(),this.#s.resize()}catch(h){if(u!==this.#a||!this.#s)return;this.control.hidden=!0;let b=q.find(f=>f.id===t)??null,m=h instanceof W?`${b.label}: the configuration does not match the chart type`:`${b?.label??"Chart"}: the chart cannot be drawn`;this.#i.error(h.message,m,Xt(h,b))}}#w(e){let{storepath:t,rowMode:r,gridId:o,timeField:i}=this.parameters,n=[r==="samples"?"The chart reads its samples from the bound array, which is empty.":`The chart reads its rows from storepath ${t} (rowMode ${r}), which has no rows.`];o&&n.push(`It shows only the rows that pass the filter of grid ${o}: the filter may hide every row.`),i&&n.push(`Temporal animation is on: no row has a value in ${i}, its date field.`),n.push("Add rows to the store, or clear the filter, to draw the chart.");let s=q.find(l=>l.id===e);return[{title:"Why the chart is empty",paragraphs:n},...s?Me(s):[]]}disconnectedCallback(){this.#r=!1,this.#a++,this.#u?.unsubscribe(this.#f,{any:!0}),this.#u=null,this.#h.disconnect(),this.#d?.(),this.#m?.(),this.#l?.dispose(),this.#s?.dispose(),this.#e=null,this.#c=this.#l=this.#s=this.#d=this.#m=null}}});function Ar(a){let e=`chart${a.id[0].toUpperCase()}${a.id.slice(1)}`,t=`gramlot-chart-${a.id.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`,r=structuredClone(Ee.parameters);delete r.chartType,delete r.valueFields;let o=a.syntax.filter(i=>i.parameter==="valueFields");for(let i of a.syntax){let n=i.parameter==="valueFields"?{dtype:"T",binding:"read"}:r[i.parameter];delete n.default,delete n.nullable,i.required&&(n.required=!0),r[i.parameter==="valueFields"?i.name:i.parameter]=n}return(0,I.defineComponent)({name:e,tag:t,base:Ee.base,sourceContext:!0,bagStore:!0,parameters:r,doc:`${a.doc} chartView with chartType '${a.id}'.`,implementation:i=>Ee.implementation(class extends i{projectAttributes(n,s){let l=super.projectAttributes(n,s),c=o.map(p=>this.parameters[p.name]).filter(Boolean);return this.parameters={...this.parameters,chartType:a.id,valueFields:c.length?c.join(","):null},l}})})}var Pr=q.map(Ar),ms=ke({name:"charts",assets:{echartsGlLicense:A["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:A["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:A["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:A["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:A["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]},components:[Lt,Ee,Gt,Dt,Ve,Zt,...Pr]});export{ms as default};