Skip to content

Instantly share code, notes, and snippets.

@netoisc
Created May 24, 2017 19:17
Show Gist options
  • Select an option

  • Save netoisc/165912ff2ca96e91b86d22732b448a10 to your computer and use it in GitHub Desktop.

Select an option

Save netoisc/165912ff2ca96e91b86d22732b448a10 to your computer and use it in GitHub Desktop.
Use saxon-js to generate html (with interactions) from a xml and a xls
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<BOOKLIST>
<BOOKS>
<ITEM CAT="CR">
<TITLE>Pride and Prejudice</TITLE>
<AUTHOR>Jane Austen</AUTHOR>
<PUBLISHER>Modern Library</PUBLISHER>
<PUB-DATE>2002-12-31</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>8.95</PRICE>
<QUANTITY>187</QUANTITY>
<ISBN>0679601686</ISBN>
<PAGES>352</PAGES>
<DIMENSIONS UNIT="in">8.3 5.7 1.1</DIMENSIONS>
<WEIGHT UNIT="oz">6.1</WEIGHT>
</ITEM>
<ITEM CAT="CR">
<TITLE>Wuthering Heights</TITLE>
<AUTHOR>Charlotte Brontë</AUTHOR>
<PUBLISHER>Penguin Classics</PUBLISHER>
<PUB-DATE>2002-12-31</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>5.30</PRICE>
<QUANTITY>113</QUANTITY>
<ISBN>0141439556</ISBN>
<PAGES>430</PAGES>
<DIMENSIONS UNIT="in">1.0 5.2 7.8</DIMENSIONS>
<WEIGHT UNIT="oz">11.2</WEIGHT>
</ITEM>
<ITEM CAT="CR">
<TITLE>Tess of the d'Urbervilles</TITLE>
<AUTHOR>Thomas Hardy</AUTHOR>
<PUBLISHER>Bantam Classics</PUBLISHER>
<PUB-DATE>1984-05-01</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>12.65</PRICE>
<QUANTITY>85</QUANTITY>
<ISBN>0553211684</ISBN>
<PAGES>480</PAGES>
<DIMENSIONS UNIT="in">6.8 4.2 0.8</DIMENSIONS>
<WEIGHT UNIT="oz">7.7</WEIGHT>
</ITEM>
<ITEM CAT="CR">
<TITLE>Jude the Obscure</TITLE>
<AUTHOR>Thomas Hardy</AUTHOR>
<PUBLISHER>Penguin Classics</PUBLISHER>
<PUB-DATE>1998-09-01</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>15.99</PRICE>
<QUANTITY>129</QUANTITY>
<ISBN>0140435387</ISBN>
<PAGES>528</PAGES>
<DIMENSIONS UNIT="in">7.8 5.2 0.9</DIMENSIONS>
<WEIGHT UNIT="oz">10.9</WEIGHT>
</ITEM>
<ITEM CAT="F">
<TITLE>The Big Over Easy</TITLE>
<AUTHOR>Jasper Fforde</AUTHOR>
<PUBLISHER>Hodder & Stoughton</PUBLISHER>
<PUB-DATE>2005-07-11</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>7.50</PRICE>
<QUANTITY>129</QUANTITY>
<ISBN>0340835672</ISBN>
<PAGES>346</PAGES>
<DIMENSIONS UNIT="cm">22.5 18.0 3.5</DIMENSIONS>
<WEIGHT UNIT="g">390</WEIGHT>
</ITEM>
<ITEM CAT="F">
<TITLE>The Eyre Affair</TITLE>
<AUTHOR>Jasper Fforde</AUTHOR>
<PUBLISHER>Penguin</PUBLISHER>
<PUB-DATE>2003-02-25</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>7.65</PRICE>
<QUANTITY>129</QUANTITY>
<ISBN>0142001805</ISBN>
<PAGES>384</PAGES>
<DIMENSIONS UNIT="in">7.8 5.0 0.9</DIMENSIONS>
<WEIGHT UNIT="oz">9.0</WEIGHT>
</ITEM>
<ITEM CAT="PT">
<TITLE>XSLT 2.0 Programmer's Reference</TITLE>
<AUTHOR>Michael Kay</AUTHOR>
<PUBLISHER>Wrox</PUBLISHER>
<PUB-DATE>2004-10-13</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>41.99</PRICE>
<QUANTITY>129</QUANTITY>
<ISBN>0470192747</ISBN>
<PAGES>1330</PAGES>
<DIMENSIONS UNIT="in">9.4 7.6 2.1</DIMENSIONS>
<WEIGHT UNIT="lb">4.4</WEIGHT>
</ITEM>
<ITEM CAT="PT">
<TITLE>XSLT Cookbook</TITLE>
<AUTHOR>Sal Mangano</AUTHOR>
<PUBLISHER>O'Reilly</PUBLISHER>
<PUB-DATE>2005-12-14</PUB-DATE>
<LANGUAGE>English</LANGUAGE>
<PRICE>32.64</PRICE>
<QUANTITY>129</QUANTITY>
<ISBN>0596009747</ISBN>
<PAGES>784</PAGES>
<DIMENSIONS UNIT="in">9.2 7 1.4</DIMENSIONS>
<WEIGHT UNIT="lb">2.5</WEIGHT>
</ITEM>
</BOOKS>
<CATEGORIES DESC="Miscellaneous categories">
<CATEGORY CODE="F" DESC="Fantasy"/>
<CATEGORY CODE="CR" DESC="Classical Romance"/>
<CATEGORY CODE="PT" DESC="Professional Textbook"/>
</CATEGORIES>
</BOOKLIST>
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
extension-element-prefixes="ixsl"
version="2.0"
>
<!-- This style sheet displays the books.xml file. -->
<xsl:template match="/">
<xsl:result-document href="#title" method="ixsl:replace-content">
<xsl:value-of>Books available at <xsl:value-of select="format-date(current-date(), '[D] [MNn] [Y]')"/></xsl:value-of>
</xsl:result-document>
<xsl:result-document href="#books">
<table id="book-table">
<thead><tr><th>Author</th><th>Title</th><th data-type="number">Price</th></tr></thead>
<tbody>
<xsl:for-each select="//ITEM">
<tr data-genre="{@CAT}">
<td><xsl:value-of select="AUTHOR"/></td>
<td><xsl:value-of select="TITLE"/></td>
<td align="right"><xsl:value-of select="PRICE"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:result-document>
<xsl:result-document href="#genres">
<form>
<table id="genre-table">
<thead>
<tr><th>Code</th><th>Description</th></tr>
</thead>
<tbody>
<xsl:for-each select="//CATEGORY">
<tr>
<td><xsl:value-of select="@CODE"/></td>
<td><xsl:value-of select="@DESC"/></td>
<td><input type="checkbox" name="genre" value="{@CODE}" checked="checked"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</form>
</xsl:result-document>
</xsl:template>
<xsl:template match="th" mode="ixsl:onclick">
<xsl:variable name="colNr" as="xs:integer" select="count(preceding-sibling::th)+1"/>
<xsl:apply-templates select="ancestor::table[1]" mode="sort">
<xsl:with-param name="colNr" select="$colNr"/>
<xsl:with-param name="dataType" select="if (@data-type='number') then 'number' else 'text'"/>
<xsl:with-param name="ascending" select="not(../../@data-order=$colNr)"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="table" mode="sort">
<xsl:param name="colNr" as="xs:integer" required="yes"/>
<xsl:param name="dataType" as="xs:string" required="yes"/>
<xsl:param name="ascending" as="xs:boolean" required="yes"/>
<xsl:result-document href="#{@id}" method="ixsl:replace-content">
<thead data-order="{if ($ascending) then $colNr else -$colNr}">
<xsl:copy-of select="thead/tr"/>
</thead>
<tbody>
<xsl:perform-sort select="tbody/tr">
<xsl:sort select="td[$colNr]"
data-type="{$dataType}"
order="{if ($ascending) then 'ascending' else 'descending'}"/>
</xsl:perform-sort>
</tbody>
</xsl:result-document>
</xsl:template>
<xsl:template match="input[@type='checkbox'][@name='genre']" mode="ixsl:onclick">
<xsl:variable name="this" select="."/>
<!--<xsl:message>Checked <xsl:value-of select="ixsl:get($this, 'checked')"/></xsl:message>-->
<xsl:for-each select="//div[@id='books']//tr[@data-genre=$this/@value]">
<ixsl:set-style name="display"
select="if (ixsl:get($this,'checked'))
then 'table-row'
else 'none'"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="th" mode="ixsl:onmouseover">
<xsl:for-each select="//div[@id='sortToolTip']">
<ixsl:set-style name="left" select="concat(ixsl:get(ixsl:event(), 'clientX') + 30, 'px')"/>
<ixsl:set-style name="top" select="concat(ixsl:get(ixsl:event(), 'clientY') - 15, 'px')"/>
<ixsl:set-style name="visibility" select="'visible'"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="th" mode="ixsl:onmouseout">
<xsl:for-each select="//div[@id='sortToolTip']">
<ixsl:set-style name="visibility" select="'hidden'"/>
</xsl:for-each>
</xsl:template>
</xsl:transform>
<!DOCTYPE html>
<html>
<head>
<title>Book Catalogue</title>
<link rel="stylesheet" href="books.css" type="text/css">
<script type="text/javascript" language="javascript" src="../SaxonJS.min.js"></script>
<script>
window.onload = function() {
SaxonJS.transform({
stylesheetLocation: "books.sef.xml",
sourceLocation: "books.xml"
});
}
</script>
</head>
<body>
<h1 id="title">Book Catalogue</h1>
<p>Click the selection button next to a genre to view books for that genre.</p>
<p>Click on any column heading to sort the table.</p>
<h2>Genres</h2>
<div id="genres"></div>
<h2>Books</h2>
<div id="books"></div>
<div id="sortToolTip" class="tooltip" style="position:fixed; visibility:hidden; left:0px; top:0px">
Click to sort on this column
</div>
</body>
</html>
var SaxonJS=function(){function showValue(t){"use strict";if(null===t)return"#null";if("undefined"==typeof t)return"#undefined";var e;if(t instanceof Expr.XdmArray){e="[";var r;for(r=0;r<t.value.length&&3>r;r++)0!==r&&(e+=","),e+=showValue(t.value[r]);return t.value.length>=4&&(e+=",...("+t.value.length+")"),e+="]"}if(t instanceof HashTrie)return e="{",t.forAllPairs(function(t){e+=showValue(t.k),e+=": ",e+=showValue(t.v),e+=", "}),e+="}";if(!DomUtils.isNode(t)||DomUtils.isAttr(t)||DomUtils.isNSNode(t)){if(DomUtils.isAttr(t))return"attribute @"+t.name;if(DomUtils.isNSNode(t))return"ns:"+t.prefix+"="+t.uri;if(t.type)return"string"===t.type?'"'+t.toString()+'"':"integer"===t.type||"boolean"===t.type?t.toString():"xs:"+t.type+"("+t.toString()+")";if("object"==typeof t&&"length"in t){e="(";var n;for(n=0;n<t.length&&3>n;n++)0!==n&&(e+=","),e+=showValue(t[n]);return t.length>=4&&(e+=",...("+t.length+")"),e+=")"}return"??? "+t}if(e={1:"element <"+t.tagName+">",2:"attribute @"+t.name,3:"text",7:"pi",8:"comment",9:"document "+(t._saxonDocumentNumber?"#"+t._saxonDocumentNumber:"(No nr / #0)"),11:"docFrag"}[t.nodeType],"9"==t.nodeType){var o;for(o=0;o<t.childNodes.length;o++)e+="~>"+showValue(t.childNodes[o])}return e}function NamespaceNode(t,e,r){this.prefix=null===t?"":t,this.uri=null===e?"":e,r&&(this.parentNode=r)}function AttributeNode(t,e,r){this.qname=t,this.value=e,this.parent=r,this.name=this.qname.toString(),this.namespaceURI=this.qname.uri,this.localName=this.qname.local,this.prefix=this.qname.prefix}function XError(t,e,r){return this instanceof XError?(this.name="XError",this.message=t||"Default Message",this.code=e||"FORG0001",r&&this.setExpr(r),void(this.stack=(new Error).stack)):new XError(t,e,r)}function initialize(){"use strict";inBrowser?(console.log("Saxon-JS "+getProcessorInfo().productVersion+" in browser"),setPlatform(BrowserPlatform.platform)):(print("Saxon-JS "+getProcessorInfo().productVersion+" in Nashorn"),setPlatform(JSTestDriver.platform)),"function"==typeof platform.initialize&&platform.initialize()}function setPlatform(t){"use strict";platform=t}function getSaxonVersion(){return saxonVersion}function makeSpaceStripper(t){"use strict";function e(t){switch(t.nodeType){case DomUtils.DOCUMENT_NODE:e(t.documentElement);break;case DomUtils.DOCUMENT_FRAGMENT_NODE:case DomUtils.ELEMENT_NODE:for(var n=DomUtils.nameOfNode(t),o=DomUtils.getInheritedAttribute(t,"xml:space"),i=r(n.uri,n.local)&&!(o&&"preserve"==o),a=t.childNodes,u=0;u<a.length;){var s=a[u];if(s.nodeType==DomUtils.CDATA_SECTION){var c=DomUtils.ownerDocument(t).createTextNode(s.nodeValue);t.replaceChild(c,s),s=c}s.nodeType==DomUtils.TEXT_NODE?i&&""===Regex.trim(s.nodeValue)?t.removeChild(s):u++:(e(s),u++)}}}var r=new Function("uri","local",t?t.getAttribute("test"):"return false");return function(t){return e(t),t}}function applyStylesheet(t,e,r){"use strict";var n=Axis.child(t.documentElement).filter(function(t){return"stripJS"==t.tagName}).next();spaceStripper=makeSpaceStripper(n),e&&spaceStripper&&(e=spaceStripper(e)),r.saxonVersion=getSaxonVersion();var o=initializeContext(t,e,r);if(e){DomUtils.obtainDocumentNumber(e);var i=e._saxonDocumentUri;o.fixed.documentPool[i]=e,e._saxonBaseUri=i}var a=r.destination;a&&!/^(appendToBody|prependToBody|replaceBody|application)$/.test(a)&&print("Warning: supplied transformation option not recognised - destination: "+a),inBrowser&&a&&/^(appendToBody|prependToBody|replaceBody)$/.test(a)&&(o.resultDocument=window.document);var u,s=r.initialTemplate;s&&s.indexOf("Q{")<0&&(s="Q{}"+s);var c=r.initialMode;if(c?""!==c&&"Q{"!=c.substring(0,2)&&(c="Q{}"+c):c="",s){var l=o.fixed.namedTemplates[s];if(!l)throw XError("Unknown initial template "+s,"XTDE0040");o.fixed.globalContextItem?(o.focus=Iter.Tracker(Iter.Singleton(e)),o.focus.next()):(o.focus=Iter.Tracker(Iter.Empty),o.focus.next()),u=Expr.evalChild1(l,o)}else{var f=o.fixed.modes[c];if(!f)throw XError("Unknown initial mode "+c,"XTDE0045");if(!e)throw XError("No source document, initial template, or initial mode supplied","SXJS0006");o.focus=Iter.Tracker(Iter.Singleton(e)),u=f.applyTemplates(o)}Expr.makeComplexContent(o.resultRoot,u,o);var m=Axis.child(o.resultRoot);if(m)if(inBrowser){var p=window.document.body;if("appendToBody"==a)m.forEachItem(function(t){p.appendChild(t)});else if("prependToBody"==a){var h=p.firstChild;m.forEachItem(function(t){p.insertBefore(t,h)})}else if("replaceBody"==a){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0]);m.forEachItem(function(t){p.appendChild(t)})}else r.principalResult=o.resultRoot}else r.principalResult=o.resultRoot;inBrowser&&registerEventListeners(o)}function transform(t,e){"use strict";function r(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e+=r+", ");return e}function n(r,n){if(null===r)throw XError("No stylesheet supplied","SXJS0006");checksum(r),applyStylesheet(r,n,t),e&&e(t.principalResult)}print("Transform options supplied: "+r(t)),t.stylesheetParams||(t.stylesheetParams={}),"function"==typeof platform.deliverMessage&&platform.deliverMessage(t);var o,i;if(inBrowser){var a=[];t.stylesheetLocation&&a.push(t.stylesheetLocation),t.sourceLocation&&a.push(t.sourceLocation),o=t.stylesheetNode?t.stylesheetNode:null,i=t.sourceNode?t.sourceNode:t.sourceText?platform.parseXmlFromString(t.sourceText):null,0===a.length?n(o,i):platform.asyncGetMultipleXml(a,function(e){o=t.stylesheetLocation?e[t.stylesheetLocation]:o,i=t.sourceLocation?e[t.sourceLocation]:i,n(o,i)})}else{if(o=t.stylesheetNode,!o){var u=t.stylesheetText;if(!u){var s=t.stylesheetFileName;if(!s)throw XError("No stylesheet supplied","SXJS0006");u=platform.readFile(s)}o=platform.parseXmlFromString(u)}if(i=t.sourceNode,!i){var c=t.sourceText;if(!c){var l=t.sourceFileName;l&&(c=platform.readFile(l))}c&&(i=platform.parseXmlFromString(c),i._saxonDocumentUri=t.sourceLocation?t.sourceLocation:t.sourceFileName)}n(o,i)}}function checksum(t){"use strict";function e(t,e){for(var r=e<<8,n=0;n<t.length;n++)r=(r<<1)+t.charCodeAt(n);return r}function r(t,r){return e(t.local,r)^e(t.uri,r)}function n(t){o^=r(DomUtils.nameOfNode(t),i++),Axis.attribute(t).forEachItem(function(t){o^=r(DomUtils.nameOfNode(t),i),o^=e(t.value,i)}),Axis.child(t).filter(function(t){return t.nodeType==DomUtils.ELEMENT_NODE}).forEachItem(function(t){n(t)}),o^=1}var o=0,i=0,a=!1;if(Axis.child(t).forEachItem(function(t){if(t.nodeType==DomUtils.ELEMENT_NODE){if("package"==DomUtils.nameOfNode(t).local){var e=DomUtils.getAttribute(t,"target","not specified");if(saxonVersion=DomUtils.getAttribute(t,"saxonVersion","9.7.0.7"),relocatable=DomUtils.getAttribute(t,"relocatable","false"),print("SEF generated by Saxon-EE version "+saxonVersion+" with -target:"+e+" -relocate:"+relocatable),"9.7.0.7"!=saxonVersion&&"JS"!=e)throw XError("Supplied SEF is not customized for use with Saxon-JS. The option -target:JS should be set when generating the export. target is: "+e,"SXJS0006")}n(t)}else if(t.nodeType==DomUtils.PROCESSING_INSTRUCTION_NODE&&DomUtils.nameOfNode(t).local==String.fromCharCode(931)){var r=(0>o?4294967295+o+1:o).toString(16);if(r!=t.data)throw XError("Invalid checksum in SEF "+t.data+" != "+r,"SXJS0006");a=!0}}),!a)throw XError("No checksum found in SEF","SXJS0006")}function registerEventListeners(t){"use strict";function e(e,r){var n=function(r){var n=r.target,o=t.newContext(!0);o.currentEvent=r,o.focus=Iter.Tracker(Iter.Singleton(Expr.convertFromJS(n))),e.applyTemplates(o).expand()},o=["afterprint","beforeprint","beforeunload","hashchange","languagechange","message","offline","online","pagehide","pageshow","popstate","storage","unhandledrejection","unload"];-1==o.indexOf(r)?window.document.addEventListener(r,n,!1):window.addEventListener(r,n,!1)}var r=t.fixed.modes;for(var n in r)if(r.hasOwnProperty(n)){var o=n.split("}");"Q{http://saxonica.com/ns/interactiveXSLT"==o[0]&&e(r[n],o[1].replace(/^on/,""))}}function initializeContext(t,e,r){"use strict";function n(e,r){Axis.descendant(t).filter(function(t){return t.nodeType==DomUtils.ELEMENT_NODE&&t.tagName==e}).forEachItem(r)}function o(t){var e=DomUtils.getAttribute(t,"name");return e?/^Q\{/.test(e)?e:"Q{}"+e:null}var i=new Context;if(i.fixed={options:r,stylesheet:t,globalContextItem:e,globalVars:{},namedTemplates:{},modes:{},userFunctions:{},attributeSets:{},keys:{},decimalFormats:{},resultDocUris:{},_nextDocumentNumber:0,currentDate:{}},n("template",function(t){var e=o(t);null!==e&&(i.fixed.namedTemplates[e]=t)}),n("mode",function(t){var e=o(t);i.fixed.modes[null===e?"":e]=new Mode(t)}),n("globalVariable",function(t){var e=o(t);i.fixed.globalVars[e]={decl:t,value:null,isParam:!1}}),n("globalParam",function(t){var e=o(t);i.fixed.globalVars[e]={decl:t,value:null,isParam:!0}}),n("function",function(t){Expr.hasFlag(t,"m")&&Expr.notImplemented("memo function");var e=o(t),r=Axis.child(t).filter(function(t){return"arg"==t.tagName}).count();i.fixed.userFunctions[e+"#"+r]=Expr.argRole(t,"body"),i.fixed.userFunctions[e+"#-1"]=!0}),n("attributeSet",function(t){var e=o(t);i.fixed.attributeSets[e]=t}),n("key",function(t){var e=o(t);i.fixed.keys[e]=t}),n("decimalFormat",function(t){var e=o(t);i.fixed.decimalFormats[null===e?"Q{}":e]=t}),i.fixed.documentPool={},i.fixed._nextDocumentNumber=0,i.fixed.currentDate=new Date,inBrowser){var a=window.location.toString();i.fixed.htmlURI=a,i.fixed.javascriptURI=platform.baseUri(),i.fixed.staticBaseURI=platform.resolveUri(r.stylesheetLocation,a)}else i.fixed.staticBaseURI="true"===relocatable?r.stylesheetFileName:null;return i.resultDocument=inBrowser?document.implementation.createDocument(null,"html",null):new Document,i.resultRoot=i.resultDocument.createDocumentFragment(),i.localVars=[],i.localParams={},i.tunnelParams={},i}function Context(){}function getProcessorInfo(){return{version:3,vendor:"Saxonica",vendorURL:"http://www.saxonica.com/",productName:"Saxon-JS",productVersion:"1.0.0",isSchemaAware:!1,supportsSerialization:!1,supportsBackwardsCompatibility:!0,supportsNamespaceAxis:!0,supportsStreaming:!1,supportsDynamicEvaluation:!0,supportsHigherOrderFunctions:!1,xPathVersion:3.1,xsdVersion:1.1}}var BrowserPlatform=function(){"use strict";function t(t){return t.getElementsByTagNameNS(r,"parsererror").length>0}function e(){Math.trunc=Math.trunc||function(t){return 0>t?Math.ceil(t):Math.floor(t)},Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,r=Object(this),n=r.length>>>0,o=arguments[1],i=0;n>i;i++)if(e=r[i],t.call(o,e,i,r))return i;return-1},enumerable:!1,configurable:!1,writable:!1}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),e+t.length>this.length?!1:-1!==this.indexOf(t,e)})}var r;try{var n=new DOMParser,o=n.parseFromString("<","text/xml");r=o.getElementsByTagName("parsererror")[0].namespaceURI}catch(i){}var a={inBrowser:!0,asyncGet:function(t,e){var r=new XMLHttpRequest;r.open("GET",t,!0),r.onload=function(n){if(4===r.readyState){if(200!==r.status)throw XError(r.statusText+": "+t,"SXJS0006");e(r.responseText)}},r.onerror=function(e){throw XError(r.statusText+": "+t,"SXJS0006")},r.send(null)},asyncGetXml:function(t,e){a.asyncGet(t,function(r){var n=a.parseXmlFromString(r);n._saxonDocumentUri=t,e(t,n)})},asyncGetMultipleXml:function(t,e){function r(t,r){o[t]=r,--n<=0&&e(o)}for(var n=t.length,o={},i=0;i<t.length;i++)t[i]?a.asyncGetXml(t[i],r):n--},parseXmlFromString:function(e){e=e.replace(/\r\n|\r(?!\n)/g,"\n");try{if(/^.+<\?xml/i.test(e))throw new Error;var r=(new DOMParser).parseFromString(e,"application/xml");r.documentElement;if(t(r))throw new Error;return r}catch(n){throw XError("Misplaced or malformed XML","FODC0002")}},readResource:function(t){var e,r=new XMLHttpRequest,n=a.resolveUri(t,a.baseUri());if(r.open("GET",n,!1),r.send(null),200==r.status?e=r.responseText:console.log("Failed to read resource at "+t),"\ufeff"==e.charAt(0))throw XError(e.substring(1),"FODC0002");return e},readFile:function(t,e){var r,n=new XMLHttpRequest;try{n.open("GET",t,!1),n.send(null)}catch(o){throw XError("Get failure "+t,"FODC0002")}if(200!=n.status)throw XError("Failed to read file at "+t,"FODC0002");if(r=n.responseText,"\ufeff"==r.charAt(0))throw XError(r.substring(1),"FODC0002");if(r.indexOf("\x00")>=0)throw XError("External file contains non-XML characters","FOUT1190");return r},resolveUri:function(t,e){try{var r,n=document,o=n.getElementsByTagName("base")[0],i=o&&o.href,a=n.head||n.getElementsByTagName("head")[0],u=o||a.appendChild(n.createElement("base")),s=n.createElement("a");return u.href=e||"",s.href=t,r=s.href,o?o.href=i:a.removeChild(u),r}catch(c){throw XError("Illegal URI: href="+t+" base="+e,"FODC0005")}},baseUri:function(){for(var t=document.getElementsByTagName("script"),e=0;e<t.length;e++)if(/SaxonJS(\.min)?.js/.test(t[e].getAttribute("src")))return t[e].src;var r=t.length-1,n=t[r];return n.src},initialize:function(){e(),Atomic._init(),window.print=function(t){console.log(t)}},deliverMessage:function(t){"function"!=typeof t.deliverMessage&&(t.deliverMessage=function(t){console.log("xsl:message: "+t)})}};return{platform:a}}(),Atomic=function(){"use strict";function t(t,e){return t==e||1==C[t+"<"+e]}function e(t,e){throw new XError("Casting from xs:"+t.type+" to xs:"+e+" is not allowed","XPTY0004")}function r(t,e){throw new XError('Supplied value "'+t+'" is not a valid xs:'+e,"FORG0001")}function n(t,e){throw new XError("Cannot compare xs:"+t+" with xs:"+e,"XPTY0004")}function o(t,e){if(t=Regex.trim(t),/\.$/.test(t)&&(t+="0"),/^(\-|\+)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\-|\+)?[0-9]+)?$/.test(t))return parseFloat(t);if(/^(\-|\+)?NaN$/.test(t))return NaN;if(/^\-INF$/.test(t))return-(1/0);if(/^(\+)?INF$/.test(t))return 1/0;if(e)throw new XError("Cannot convert string '"+t+"' to a number","FORG0001");return NaN}function i(t){return t.toString(36)}function a(t){var e,r,n,o,i,a,u,s,c=0,l=0,f=[];if(!t)return t;do e=t.charCodeAt(c++),r=t.charCodeAt(c++),n=t.charCodeAt(c++),s=e<<16|r<<8|n,o=s>>18&63,i=s>>12&63,a=s>>6&63,u=63&s,f[l++]=O.charAt(o)+O.charAt(i)+O.charAt(a)+O.charAt(u);while(c<t.length);var m=f.join(""),p=t.length%3;return(p?m.slice(0,p-3):m)+"===".slice(p||3)}function u(t){t=t.replace(/\s/g,""),/^((([A-Za-z0-9+\/]){4})*(([A-Za-z0-9+\/]){3}[A-Za-z0-9+\/]|([A-Za-z0-9+\/]){2}[AEIMQUYcgkosw048]=|[A-Za-z0-9+\/][AQgw]==))?$/.test(t)||r(t,"base64Binary");var e,n,o,i,a,u,s,c,l=0,f=0,m=[];if(0===t.length)return t;t+="";do i=O.indexOf(t.charAt(l++)),a=O.indexOf(t.charAt(l++)),u=O.indexOf(t.charAt(l++)),s=O.indexOf(t.charAt(l++)),c=i<<18|a<<12|u<<6|s,e=c>>16&255,n=c>>8&255,o=255&c,64==u?m[f++]=String.fromCharCode(e):64==s?m[f++]=String.fromCharCode(e,n):m[f++]=String.fromCharCode(e,n,o);while(l<t.length);return m.join("")}function s(t){var e="";return Expr.stringToCodepoints(t).forEach(function(t){e+=(t+256).toString(16).substring(1).toUpperCase()}),e}function c(t){t=Regex.trim(t),/^([a-fA-F0-9][a-fA-F0-9])*$/.test(t)||r(t,"hexBinary");var e,n=[];for(e=0;e<t.length;e+=2)n.push(String.fromCharCode(parseInt(t.substring(e,e+2),16)));return n.join("")}function l(t,e){this.value=t,this.type=e||"string","string"!=typeof t&&Expr.internalError("bad input to string constructor "+showValue(t))}function f(t,e){this.value=t,this.type=e}function m(t,e){"number"!=typeof t&&Expr.internalError("type of value supplied to XdmDouble is not number: "+typeof t),this.value=t,this.type=e||"double"}function p(t,e){"number"!=typeof t&&Expr.internalError("type of value supplied to XdmInteger is not number: "+typeof t),this.value=t,this.type=e||"integer"}function h(t,e){this.value=new Big(t),this.type=e||"decimal"}function g(t){this.value=t,"boolean"!=typeof t&&Expr.internalError("type of value supplied to XdmBoolean is not boolean: "+typeof t)}function d(t,e,r){if(this.prefix=t?t:"",this.uri=e?e:"",this.local=r,""!==t&&!Regex.isNCName(t))throw new XError("Invalid prefix: '"+t+"'","FORG0001");if(!Regex.isNCName(r))throw new XError("Invalid local name: '"+r+"'","FORG0001")}function v(t,e,r){this.UTCdate=t,this.timezoneOffset=e,this.type=r||"dateTime",t instanceof Date||Expr.internalError("type of UTCdate supplied to XdmDateTime is not Date"),e&&"number"!=typeof e&&Expr.internalError("type of value for timezone offset supplied to XdmDateTime is not number: "+typeof value)}function x(t){return(100+t).toString().substring(1)}function E(t){return(1e4+t).toString().substring(1)}function S(t,e,r){if(this.months=t,this.milliseconds=e,("number"!=typeof t||"number"!=typeof e)&&Expr.internalError("type of value supplied to XdmDuration is not number: "+typeof t+", "+typeof e),t>0&&0>e||0>t&&e>0)throw new XError("Months/seconds must both be negative or both positive","FORG0001");this.type=r||"duration"}function N(t){var r=U[t]={};r.name=t,r.matches=function(e){return e instanceof v&&e.type==t},r.fromString=function(e){return w(e,t)},r.fromDate=function(e,r){return new v(e,r,t)},r.cast=function(r){if(U[t].matches(r))return r;if(Atomic.dateTime.matches(r)||Atomic.date.matches(r)){var n=U[t];return n.fromString(n.fromDate(r.UTCdate,r.timezoneOffset).toString())}return Atomic.string.matches(r)||Atomic.untypedAtomic.matches(r)?U[t].fromString(r.toString()):void e(r,t)}}function y(t){if(-1!=t.indexOf(".",t.length-4)){for(var e=t.split("."),r=e[1];r.length<3;)r+="0";t=e[0]+"."+r}return t}function A(t){var e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],u=e%4===0&&!(e%100===0&&e%400!==0);return!(1>r||r>12||1>n||n>[31,u?29:28,31,30,31,30,31,31,30,31,30,31][r-1]||o>=24||i>=60||a>=60)}function b(t,e){var r=t.split(/[\-T:]/).map(function(t){return parseFloat(t)});if(!A(r))throw new XError("Invalid date "+e,"FORG0001")}function w(t,e){var n=t.match(X[e]);null===n&&r(t,e);var o=n[2]?n[2]:"",i=_[e](n[1])+o;/24:00:00(\.0+)?([Z\+\-]|$)/.test(i)&&(i="time"==e?i.substring(0,10)+"T00:00:00":Calculate["t+u"](w(i.substring(0,10),"date"),I("P1D","dayTimeDuration")).toString()+"T00:00:00");var a,u,s="-"==i.charAt(0);if(s)b(i.substring(1,20),t),u=i.substr(1).split(/[\-T:]/).map(function(t){return parseFloat(t)}),a=new Date(Date.UTC(-u[0],u[1]-1,u[2],u[3],u[4],u[5]));else{b(i.substring(0,19),t);var c=i.split(/[\-T:]/);u=i.split(/[\-T:]/).map(function(t){return parseFloat(t)});var l=u[5],f=l-Math.floor(l);a=new Date(Date.UTC(c[0],u[1]-1,u[2],u[3],u[4],l,Math.round(1e3*f))),a.setUTCFullYear(c[0])}if(""===o){var m=new Date;a=new Date(a.getTime()+60*m.getTimezoneOffset()*1e3)}else a=new Date(a.getTime()-60*T(o)*1e3);return new v(a,T(n[2]?n[2]:""),e)}function T(t){if(""===t)return null;if("Z"==t)return 0;var e=t.split(":"),r=parseInt(e[0],10),n=/^\-.*/.test(e[0]),o=Math.abs(r),i=parseInt(e[1],10);if(o>14||i>59)throw XError("Invalid timezone "+t,"FORG0001");return(n?-1:1)*(60*o+i)}function I(t,e){var n=t.match(X[e]);return(null===n||!/\d/.test(t)||/T$/.test(t))&&r(t,e),new S(k[R[e][0]](n,t),k[R[e][1]](n,t),e)}function D(){function e(t){for(var e=U[t];e.base;)C[t+"<"+(void 0!==e.base.name?e.base.name:e.base)]=1,e=e.base;("decimal"==e||"double"==e||"float"==e)&&(C[t+"<numeric"]=1)}function n(n,o,i){var a=U[n]={},u=U[o];a.name=n,a.base=u,a.matches=function(e){return t(e.type,n)},a.downCast=function(t){return i(t)||r(t.toString(),n),t.type=n,t},a.fromString=function(t){return a.downCast(u.fromString(t))},a.cast=function(t){return a.downCast(u.cast(t))},e(n)}function o(t,e,o){function i(e){return o(e)||r(e.toString(),t),e.type=t,e}n(t,e,o);var a=U[t],u=U[e];a.fromNumber=function(t){return i(u.fromNumber(t))}}function i(t,e,o,i){n(t,e,o);var a=U[t],u=U[e];a.downCast=function(e){var n=i(e.toString());return o(n)||r(n,t),new l(n,t)},a.fromString=function(t){return a.downCast(u.fromString(i(t)))}}function a(t,e,o){n(t,e,o);var i=U[t],a=U[e];i.downCast=function(e){return e instanceof S?new S("yearMonthDuration"==t?e.months:0,"dayTimeDuration"==t?e.milliseconds:0,t):(o(e)||r(e.toString(),t),e.type=t,e)},i.fromMonthsMilliseconds=function(t,e){return i.downCast(a.fromMonthsMilliseconds(t,e))},i.cast=function(e){return a.matches(e)?i.downCast(e):Atomic.string.matches(e)||Atomic.untypedAtomic.matches(e)?I(e.toString(),t):i.downCast(a.cast(e))}}Atomic["double"].NaN=Atomic["double"].fromNumber(NaN),o("nonPositiveInteger","integer",function(t){return t.toNumber()<=0}),o("negativeInteger","nonPositiveInteger",function(t){return t.toNumber()<0}),o("long","integer",function(t){var e=t.toBig();return e.cmp(Big("-9223372036854775808"))>=0&&e.cmp(Big("9223372036854775807"))<=0}),o("int","long",function(t){return t.toNumber()>=-2147483648&&t.toNumber()<=2147483647}),o("short","int",function(t){return t.toNumber()>=-32768&&t.toNumber()<=32767}),o("byte","short",function(t){return t.toNumber()>=-128&&t.toNumber()<=127}),o("nonNegativeInteger","integer",function(t){return t.toNumber()>=0}),o("positiveInteger","nonNegativeInteger",function(t){return t.toNumber()>0}),o("unsignedLong","nonNegativeInteger",function(t){return t.toNumber()>=0&&t.toBig().cmp(Big("18446744073709551615"))<=0}),o("unsignedInt","unsignedLong",function(t){return t.toNumber()>=0&&t.toBig().cmp(Big("4294967295"))<=0}),o("unsignedShort","unsignedInt",function(t){return t.toNumber()>=0&&t.toNumber()<=65535}),o("unsignedByte","unsignedShort",function(t){return t.toNumber()>=0&&t.toNumber()<=255});var u=function(t){return t.replace(/[ \r\t\n]/g," ")},s=function(){return!0};i("normalizedString","string",s,u),i("token","normalizedString",s,Expr.wsCollapse),i("language","token",function(t){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(t)},Expr.wsCollapse),i("NMTOKEN","token",Regex.isNMTOKEN,Expr.wsCollapse),i("Name","token",Regex.isName,Expr.wsCollapse),i("NCName","Name",Regex.isNCName,Expr.wsCollapse),i("ID","NCName",Regex.isNCName,Expr.wsCollapse),i("IDREF","NCName",Regex.isNCName,Expr.wsCollapse),i("ENTITY","NCName",Regex.isNCName,Expr.wsCollapse),a("yearMonthDuration","duration",function(t){return 0===t.milliseconds}),a("dayTimeDuration","duration",function(t){return 0===t.months}),U.dayTimeDuration.fromNumberOfMinutes=function(t){return new S(0,60*t*1e3,"dayTimeDuration")},U.showValue=showValue,U._init=function(){}}var C={"integer<decimal":1,"decimal<numeric":1,"double<numeric":1,"float<numeric":1,"integer<numeric":1,"dateTimeStamp<dateTime":1},O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";l.prototype={value:null,type:"string",_hash:0,toString:function(){return this.value},toDouble:function(){return o(this.value,!0)},compareTo:function(t){if(t instanceof l){if(Expr.isAstral(this.value)||Expr.isAstral(t.value)){var e=Compare.codePointComparison(this.value,t.value);return 0>e?-1:0===e?0:1}return this.value<t.value?-1:this.value==t.value?0:1}return"untypedAtomic"==this.type?Atomic[t.type].cast(this).compareTo(t):void n(this.type,t.type)},equals:function(t){return 0===this.compareTo(t)},hashCode:function(){if(this.value.length<=4)return this.value;var t=this._hash,e=this.value.length;if(0===t&&e>0){var r;for(r=0;e>r;r++)t=31*t+this.value.charAt(r++);this._hash=t}return i(t)}},f.prototype={value:null,type:"hexBinary",toString:function(){return"hexBinary"==this.type?s(this.value):a(this.value)},compareTo:function(t){if(t instanceof f&&this.type==t.type){if(Expr.isAstral(this.value)||Expr.isAstral(t.value)){var e=Compare.codePointComparison(this.value,t.value);return 0>e?-1:0===e?0:1}return this.value<t.value?-1:this.value==t.value?0:1}n(this.type,t.type)},equals:function(t){return 0===this.compareTo(t)},hashCode:function(){return new l(this.value).hashCode()}},m.prototype={value:0,type:"double",_hash:0,toString:function(){if(0===this.value)return 1/this.value<0?"-0":"0";if(this.value==Number.POSITIVE_INFINITY)return"INF";if(this.value==Number.NEGATIVE_INFINITY)return"-INF";var t=this.value,e=Math.abs(t);if(e>=1e6||1e-6>e){var r=t.toExponential(),n=r.indexOf("e"),o=r.substring(0,n);o.includes(".")||(o+=".0");var i=r.substring(n+1);return o+"E"+i.replace("+","")}return t.toString()},equals:function(t){return 0===this.compareTo(t)},compareTo:function(t){return"toNumber"in t?this.value<t.toNumber()?-1:this.value==t.toNumber()?0:1:void n(this.type,t.type)},hashCode:function(){return i(this.value)},toNumber:function(){return this.value},toDouble:function(){return this},abs:function(){return new m(Math.abs(this.value),this.type)},negate:function(){return new m(-this.value,this.type)},ceiling:function(){return new m(Math.ceil(this.value),this.type)},floor:function(){return new m(Math.floor(this.value),this.type)},round:function(t){var e;if(0===t)e=Math.round(this.value);else{var r=Math.pow(10,-t);e=Math.round(this.value/r)*r}return new m(e,this.type)},roundHalfToEven:function(t){return isNaN(this.value)||!isFinite(this.value)?this:Atomic[this.type].cast(new h(Big(this.value)).roundHalfToEven(t))}},p.prototype={value:0,type:"integer",_hash:0,toString:function(){return this.value.toString()},equals:function(t){return 0===this.compareTo(t)},compareTo:function(t){return"toNumber"in t?this.value-t.toNumber():void n(this.type,t.type)},hashCode:function(){return i(this.value)},toDouble:function(){return new m(this.value)},toNumber:function(){return this.value},toBig:function(){return new Big(this.value)},abs:function(){return new p(Math.abs(this.value))},negate:function(){return new p(-this.value)},ceiling:function(){return this},floor:function(){return this},round:function(t){if(0>t){var e=Math.pow(10,-t);return new p(Math.round(this.value/e)*e)}return this},roundHalfToEven:function(t){if(0>t){var e=Math.pow(10,-t);return new p(parseInt(Big(this.value).div(e).round(0,2).times(e),10))}return this}},h.prototype={value:null,type:"decimal",_hash:0,toString:function(){return this.value.toFixed()},equals:function(t){return 0===this.compareTo(t)},compareTo:function(t){return t instanceof h?this.value.cmp(t.value):"toDouble"in t?this.value-t.toDouble().value:void n(this.type,t.type)},hashCode:function(){return i(this.toNumber())},toBig:function(){return this.value},toDouble:function(){return new m(parseFloat(this.value))},toNumber:function(){return parseFloat(this.value)},abs:function(){return new h(this.value.abs(),this.type)},negate:function(){var t=Big(this.value);return t.s=-t.s,new h(t,"decimal"==this.type?"decimal":"integer")},ceiling:function(){return new h(this.value.round(0,this.value.s<0?0:3),this.type)},floor:function(){return new h(this.value.round(0,this.value.s<0?3:0),this.type)},round:function(t){function e(t,e){var r=new Big(t);return r.e+=e,r}var r=this.value,n=0;0>t&&(n=t,t=0,r=e(r,n));var o=r.s>0?Big(0):this.floor().abs();return r=r.plus(o).round(t,1).minus(o),0!==e&&(r=e(r,-n)),new h(r,"decimal"==this.type?"decimal":"integer")},roundHalfToEven:function(t){var e;if(0>t){var r=Big(10).pow(-t);e=this.value.div(r).round(0,2).times(r)}else e=this.value.round(t,2);return new h(e,"decimal"==this.type?"decimal":"integer")}},g.prototype={value:null,type:"boolean",_hash:0,toString:function(){return this.value.toString()},toBoolean:function(){return this.value},compareTo:function(t){return t instanceof g?(this.value?1:0)-(t.value?1:0):void n(this.type,t.type)},equals:function(t){return 0===this.compareTo(t)},hashCode:function(){return this.value.toString()}},d.prototype={prefix:null,uri:null,local:null,type:"QName",toEQName:function(){return"Q{"+this.uri+"}"+this.local},toString:function(){return(this.prefix.length>0?this.prefix+":":"")+this.local},equals:function(t){return t instanceof d&&this.local==t.local&&this.uri==t.uri},compareTo:function(){throw new XError("QNames are not ordered","FORG0006")},hashCode:function(){return this.uri.substring(this.uri.length-3)+":"+this.local.substring(0,3)}},v.prototype={type:"dateTime",_hash:0,UTCdate:null,timezoneOffset:null,proxy:function(){var t=new Date,e=null!==this.timezoneOffset?this.timezoneOffset:-t.getTimezoneOffset();return new Date(this.UTCdate.getTime()+60*e*1e3)},_ISOEdit:function(t){if(t=t.substr(0,t.length-1),0===this.UTCdate.getUTCMilliseconds())t=t.replace(".000","");else for(;"0"==t.charAt(t.length-1);)t=t.substr(0,t.length-1);return t=t.replace(/^-0?0?/,"-")},toString:function(){function t(t){switch(t){case"dateTime":case"dateTimeStamp":return e;case"date":return e.substring(0,10+r);case"time":return e.substring(11+r);case"gYearMonth":return e.substring(0,7+r);case"gYear":return e.substring(0,4+r);case"gMonthDay":return"-"+e.substring(4+r,10+r);case"gMonth":return"-"+e.substring(4+r,7+r);case"gDay":return"--"+e.substring(7+r,10+r);default:throw"type not recognised "+t}}var e=this._ISOEdit(this.proxy().toISOString()),r="-"==e.charAt(0)?1:0;return t(this.type)+this.tzOffsetToString()},compareTo:function(t){return t instanceof v&&this.type==t.type?+this.UTCdate.getTime()-t.UTCdate.getTime():void n(this.type,t.type)},equals:function(t){return t instanceof v&&this.type==t.type&&this.UTCdate.getTime()==t.UTCdate.getTime()},hashCode:function(){return i(this.UTCdate.getTime()-1454346732296)},adjustByMinutes:function(t){return Atomic.dateTime.fromDate(new Date(this.UTCdate.getTime()+60*t*1e3),this.timezoneOffset)},addMonths:function(t){var e=this.toString(),r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(5,7),10),o=parseInt(e.substring(8,10),10),i=r+Math.floor((n+t-1)/12),a=0>i,u=(n+t-1)%12+1;for(0>=u&&(u+=12);!A([i,u,o,0,0,0]);)o-=1;return Atomic[this.type].fromString((a?"-"+E(-i):E(i))+"-"+x(u)+"-"+x(o)+e.substring(10))},tzOffsetToString:function(){var t=this.timezoneOffset;if(null===t)return"";if(0===t)return"Z";var e=Math.abs(t);return(0>t?"-":"+")+x(Math.floor(e/60))+":"+x(e%60)}},S.prototype={type:"duration",_hash:0,months:0,milliseconds:0,parts:function(){function t(t,r){r.forEach(function(r){1e3!=r?(e.push(Math.floor(t/r)),t%=r):e.push(t/r)})}var e=[];return t(Math.abs(this.months),[12,1]),t(Math.abs(this.milliseconds),[864e5,36e5,6e4,1e3]),e},signum:function(){var t=this.months+this.milliseconds;return 0>t?-1:t>0?1:0},toString:function(){var t,e=this.signum();return 0===e?t="yearMonthDuration"==this.type?"P0M":"PT0S":(t=0>e?"-P":"P",this.parts().forEach(function(e,r){3==r&&(t+="T"),0!==e&&(t+=6==r?e/1e3+"S":e+["Y","M","D","H","M","S"][r])}),t=t.replace(/T$/,"")),t},compareTo:function(t){if(Atomic.yearMonthDuration.matches(this)&&Atomic.yearMonthDuration.matches(t))return this.months-t.months;if(Atomic.dayTimeDuration.matches(this)&&Atomic.dayTimeDuration.matches(t))return this.milliseconds-t.milliseconds;throw new XError("Cannot compare durations that mix months and seconds","XPTY0004")},equals:function(t){return t instanceof S&&this.months==t.months&&this.milliseconds==t.milliseconds},hashCode:function(){return this.months.toString()+":"+this.milliseconds.toString()}};var U={hierarchy:C,isSubtype:t,anyAtomicType:{name:"anyAtomicType",matches:function(t){return t instanceof l||t instanceof h||t instanceof p||t instanceof m||t instanceof f||t instanceof g||t instanceof S||t instanceof v||t instanceof d}},untypedAtomic:{name:"untypedAtomic",fromString:function(t){return new l(t,"untypedAtomic")},matches:function(t){return"untypedAtomic"==t.type},cast:function(t){return new l(t.toString(),"untypedAtomic")}},string:{name:"string",fromString:function(t){return new l(t,"string")},matches:function(e){return t(e.type,"string")},cast:function(t){return new l(t.toString(),"string")}},anyURI:{name:"anyURI",fromString:function(t){return new l(t.replace(/[ \r\t\n]+/g," ").replace(/^[ ]|[ ]$/g,""),"anyURI")},matches:function(t){return"anyURI"==t.type},cast:function(t){return t instanceof l?Atomic.anyURI.fromString(t.toString()):void e(t,"anyURI")}},"double":{name:"double",fromString:function(t){return new m(o(t,!0))},fromStringUnfailing:function(t){return new m(o(t,!1))},fromNumber:function(t){return new m(t)},matches:function(t){return"double"==t.type},cast:function(t){return Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic["double"].fromString(t.toString()):Atomic.numeric.matches(t)?Atomic["double"].fromNumber(t.toNumber()):Atomic["boolean"].matches(t)?Atomic["double"].fromNumber(t.toBoolean()?1:0):"number"==typeof t?Atomic["double"].fromNumber(t):void e(t,"double");
}},decimal:{name:"decimal",fromString:function(t){return t=Regex.trim(t),/^(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/.test(t)?new h(new Big(t)):void r(t,"decimal")},fromBig:function(t){return new h(t)},fromNumber:function(t){if(isNaN(t)||!isFinite(t))throw new XError("Cannot convert NaN or INF to a decimal","FOCA0002");return new h(new Big(t))},matches:function(t){return t instanceof h||t instanceof p},cast:function(t){return Atomic.decimal.matches(t)?new h(t.value,"decimal"):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.decimal.fromString(t.toString()):Atomic.numeric.matches(t)?Atomic.decimal.fromNumber(t.toNumber()):Atomic["boolean"].matches(t)?Atomic.decimal.fromString(t.toBoolean()?"1":"0"):void e(t,"decimal")}},"float":{name:"float",fromString:function(t){return new m(o(t,!0),"float")},fromNumber:function(t){return Math.fround&&(t=Math.fround(t)),new m(t,"float")},matches:function(t){return"float"==t.type},cast:function(t){return Atomic["float"].fromNumber(Atomic["double"].cast(t).toNumber())}},"boolean":{name:"boolean",fromString:function(t){switch(Regex.trim(t)){case"true":case"1":return new g(!0);case"false":case"0":return new g(!1);default:r(t,"boolean")}},fromBoolean:function(t){return new g(t)},matches:function(t){return t instanceof g},cast:function(t){return Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic["boolean"].fromString(t.toString()):Atomic.numeric.matches(t)?Atomic["boolean"].fromBoolean(0!==t.toNumber()&&!isNaN(t.toNumber())):Atomic["boolean"].matches(t)?t:"boolean"==typeof t?Atomic["boolean"].fromBoolean(t):void e(t,"boolean")}},integer:{name:"integer",base:"decimal",matches:function(e){return t(e.type,"integer")},fromString:function(t){return/^\s*(\-|\+)?[0-9]+\s*$/.test(t)?t.length>9?new h(t,"integer"):new p(parseInt(t,10)):void r(t,"integer")},fromNumber:function(t){if(isNaN(t)||t==Number.NEGATIVE_INFINITY||t==Number.POSITIVE_INFINITY)throw new XError("Cannot convert NaN or INF to an integer","FOCA0002");return new p(Math.trunc(t))},fromBig:function(t){return new h(t,"integer")},valid:function(t){return 0===t.value.mod(1)},cast:function(t){return Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.integer.fromString(t.toString()):Atomic.numeric.matches(t)?Atomic.integer.fromNumber(t.toNumber()):Atomic["boolean"].matches(t)?Atomic.integer.fromNumber(t.toBoolean()?1:0):void e(t,"integer")},convertFromJS:function(t){return"number"==typeof t?Atomic.integer.fromNumber(t):"boolean"==typeof t?Atomic.integer.fromNumber(t?1:0):"string"==typeof t?Atomic.integer.fromString(t):Atomic.integer.fromString(t.toString())}},numeric:{name:"numeric",members:["double","decimal","float"],matches:function(t){return t instanceof m||t instanceof p||t instanceof h},cast:function(t){return Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic["double"].fromString(t.toString()):Atomic.numeric.matches(t)?Atomic["double"].fromNumber(t.toNumber()):Atomic["boolean"].matches(t)?Atomic["double"].fromNumber(t.toBoolean()?1:0):void e(t,"numeric")}},QName:{name:"QName",matches:function(t){return t instanceof d},fromParts:function(t,e,r){return new d(t,e,r)},fromString:function(t,e){if(t=Regex.trim(t),"Q{"==t.substring(0,2))return Atomic.QName.fromEQName(t);Regex.isQName(t)||r(t,"QName");var n=t.split(":");if(1==n.length)return Atomic.QName.fromParts("",e(""),n[0]);var o=e(n[0]);if(null===o)throw XError("Undeclared prefix: "+n[0],"FONS0004");return Atomic.QName.fromParts(n[0],o,n[1])},fromEQName:function(t){var e=t.indexOf("{"),r=t.indexOf("}"),n=Expr.wsCollapse(t.substring(e+1,r));if("http://www.w3.org/2000/xmlns/"==n)throw XError("Use of reserved namespace: "+n,"XQST0070");return new d("",n,t.substring(r+1))},cast:function(t,r){if(Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)){if(r)return Atomic.QName.fromString(t.toString(),r);throw XError("Casting to QName requires a namespace resolver","FORG0001")}return Atomic.QName.matches(t)?t:void e(t,"QName")}},dateTime:{name:"dateTime",matches:function(t){return t instanceof v&&("dateTime"==t.type||"dateTimeStamp"==t.type)},fromString:function(t){return w(t,"dateTime")},fromDate:function(t,e){return new v(t,e,"dateTime")},cast:function(t){return Atomic.dateTime.matches(t)?t:Atomic.date.matches(t)?Atomic.dateTime.fromDate(t.UTCdate,t.timezoneOffset):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.dateTime.fromString(t.toString()):void e(t,"dateTime")}},date:{name:"date",matches:function(t){return t instanceof v&&"date"==t.type},fromString:function(t){return w(t,"date")},fromDate:function(t,e){var r=new v(t,e,"date"),n=r.toString(),o="-"==n.charAt(0)?11:10,i=Atomic.dateTime.fromString(n.substring(0,o)+"T00:00:00"+n.substring(o));return new v(i.UTCdate,e,"date")},cast:function(t){return Atomic.date.matches(t)?t:Atomic.dateTime.matches(t)?Atomic.date.fromDate(t.UTCdate,t.timezoneOffset):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.date.fromString(t.toString()):void e(t,"date")}},time:{name:"time",matches:function(t){return t instanceof v&&"time"==t.type},fromString:function(t){return w(t,"time")},fromDate:function(t,e){var r=new v(t,e,"time"),n=Atomic.dateTime.fromString("1972-01-01T"+r.toString());return new v(n.UTCdate,e,"time")},cast:function(t){return Atomic.time.matches(t)?t:Atomic.dateTime.matches(t)?Atomic.time.fromDate(t.UTCdate,t.timezoneOffset):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.time.fromString(t.toString()):void e(t,"time")}},dateTimeStamp:{name:"dateTimeStamp",matches:function(t){return t instanceof v&&"dateTimeStamp"==t.type},fromString:function(t){return w(t,"dateTimeStamp")},fromDate:function(t,e){return new v(t,e,"dateTimeStamp")},cast:function(t){return Atomic.time.matches(t)?t:Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.dateTimeStamp.fromString(t.toString()):void e(t,"dateTimeStamp")}},duration:{name:"duration",matches:function(e){return t(e.type,"duration")},fromString:function(t){return I(t,"duration")},fromMonthsMilliseconds:function(t,e){return new S(t,e,"duration")},cast:function(t){return Atomic.duration.matches(t)?t:Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?Atomic.duration.fromString(t.toString()):void e(t,"duration")}},hexBinary:{name:"hexBinary",matches:function(t){return"hexBinary"===t.type},fromString:function(t){return new f(c(t),"hexBinary")},cast:function(t){return t instanceof f?new f(t.value,"hexBinary"):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?new f(c(t.toString()),"hexBinary"):void e(t,"hexBinary")}},base64Binary:{name:"base64Binary",matches:function(t){return"base64Binary"===t.type},fromString:function(t){return new f(u(t),"base64Binary")},encodeFromString:function(t){return new f(t,"base64Binary")},cast:function(t){return t instanceof f?new f(t.value,"base64Binary"):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?new f(u(t.toString()),"base64Binary"):void e(t,"base64Binary")}}};N("gYearMonth"),N("gYear"),N("gMonthDay"),N("gMonth"),N("gDay");var X={dateTime:/^\s*(-?[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?)(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,date:/^\s*(-?[0-9]{4}-[0-9]{2}-[0-9]{2})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,time:/^\s*([0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?)(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,dateTimeStamp:/^\s*(-?[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?)(Z|(\+|-)[0-9]{2}:[0-9]{2})\s*$/,gYearMonth:/^\s*(-?[0-9]{4}-[0-9]{2})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,gYear:/^\s*(-?[0-9]{4})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,gMonthDay:/^\s*--([0-9]{2}-[0-9]{2})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,gMonth:/^\s*--([0-9]{2})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,gDay:/^\s*---([0-9]{2})(Z|(\+|-)[0-9]{2}:[0-9]{2})?\s*$/,duration:/^\s*\-?P(?:([0-9]+)Y)?(?:([0-9]+)M)?(?:([0-9]+)D)?(?:T(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+(?:\.[0-9]*)?)S)?)?\s*$/,dayTimeDuration:/^\s*\-?P(?:([0-9]+)D)?(?:T(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+(?:\.[0-9]*)?)S)?)?\s*$/,yearMonthDuration:/^\s*\-?P(?:([0-9]+)Y)?(?:([0-9]+)M)?\s*$/},_={dateTime:function(t){return y(t)},date:function(t){return t+"T00:00:00"},time:function(t){return"1972-01-01T"+y(t)},dateTimeStamp:function(t){return y(t)},gYearMonth:function(t){return t+"-01T00:00:00"},gYear:function(t){return t+"-01-01T00:00:00"},gMonthDay:function(t){return"1972-"+t+"T00:00:00"},gMonth:function(t){return"1972-"+t+"-01T00:00:00"},gDay:function(t){return"1972-01-"+t+"T00:00:00"}},M=function(t,e){return e*(void 0===t?0:parseInt(t,10))},F=function(t,e){return e*(void 0===t?0:Math.round(1e3*parseFloat(t)))},P=function(t,e){return e?-t:t},k=[function(t,e){return P(M(t[1],12)+M(t[2],1),e.match(/^\s*\-.*/))},function(t,e){return P(M(t[3],864e5)+M(t[4],36e5)+M(t[5],6e4)+F(t[6],1),e.match(/^\s*\-.*/))},function(t,e){return P(M(t[1],864e5)+M(t[2],36e5)+M(t[3],6e4)+F(t[4],1),e.match(/^\s*\-.*/))},function(){return 0}],R={duration:[0,1],dayTimeDuration:[3,2],yearMonthDuration:[0,3]};return U._init=D,U}(),Compare=function(){"use strict";function t(t,e){return null===t?null===e:null===e?!1:t.equals(e)}function e(t,e,r,n){for(var o,i=Atomic.numeric.matches,a=Atomic.untypedAtomic.matches;null!==(o=t.next());)for(var u,s=Iter.ForArray(e);null!==(u=s.next());){var c=a(o)?a(u)?Atomic.string.cast(o):i(u)?Atomic["double"].cast(o):Atomic[u.type].cast(o):o,l=a(u)?a(o)?Atomic.string.cast(u):i(o)?Atomic["double"].cast(u):Atomic[o.type].cast(u):u;if(!(i(c)&&isNaN(c.value)||i(l)&&isNaN(l.value))&&g(r,n.compare(c,l)))return Iter.oneBoolean(!0)}return Iter.oneBoolean(!1)}function r(t,r,n){var o=Expr,i=o.evalChild1(t,r),a=o.evalChild2(t,r).expand(),u=p(t.getAttribute("comp"));return n||(n=t.getAttribute("op")),e(i,a,n,u)}function n(t,e){return t.compareTo(e)}function o(t){return function(e,r){return null===e||null===r?null===e?null===r?0:-1:1:t(e,r)}}function i(t){return function(e,r){return v(e)||v(r)?v(e)?v(r)?0:-1:1:t(e,r)}}function a(t){var e=Atomic.untypedAtomic,r=Atomic.string;return function(o,i){return r.matches(o)||e.matches(i)?t(o,i):n(o,i)}}function u(t,e){for(var r=Expr,n=r.stringToCodepoints(t.toString()),o=r.stringToCodepoints(e.toString()),i=0;;){if(i==n.length)return i==o.length?0:-1;if(i==o.length)return 1;if(n[i]!=o[i])return n[i]-o[i];i++}}function s(t,e){var r=DomUtils,n=Iter.Tracker(Expr.evalChild1(t,e)),o=[],i=r.getChildElements(t,"sortKey"),a=i.map(function(t){return h(t,e)}),u=e.newContext(!1);u.tempOutputState="sort key",u.focus=n;var s=i.map(function(t){var r=Expr.argRole(t,"dataType"),n=null===r?null:Expr.evaluate(r,e).next();return"number"==n?function(t){return null===t?null:Atomic["double"].fromStringUnfailing(t.toString())}:"text"==n?function(t){return null===t?null:Atomic.string.cast(t)}:function(t){return t}});return n.forEachItem(function(t){var e=i.map(function(t,e){return s[e](Expr.evalChild1(t,u).next())});o.push({item:t,keys:e})}),o.sort(function(t,e){var r;for(r=0;r<a.length;r++){var n=a[r](t.keys[r],e.keys[r]);if(0!==n)return n}return 0}),Iter.ForArray(o).mapOneToOne(function(t){return t.item})}function c(t,e){return null===t?Atomic["double"].NaN:Atomic.numeric.matches(t)?t.toNumber():e?Atomic["double"].fromString(t.toString()).toNumber():Atomic["double"].fromStringUnfailing(t.toString()).toNumber()}function l(t,e){var r=c(t,!0),n=c(e,!0);return v(r)?v(n)?0:-1:v(n)?1:r-n}function f(t,e){var r=c(t,!1),n=c(e,!1);return v(r)?v(n)?0:-1:v(n)?1:r-n}function m(t,e){return function(r,n){var o=r.toString(),i=n.toString(),a=o.toLowerCase(),u=i.toLowerCase(),s=t(a,u);if(0===s){for(var c=0;c<o.length;c++)if(o.charAt(c)!=i.charAt(c))return e==(o.charAt(c)==o.charAt(c).toLowerCase())?-1:1;return 0}return s}}function p(e){var r=e.split("|");if("DESC"==r[0]){var a=p(e.slice(5));return{equals:a.equals,compare:function(t,e){return a.compare(e,t)}}}var u={};switch(r[0]){case"NC":return u.compare=f,u.equals=function(t,e){var r=c(t,!1),n=c(e,!1);return isNaN(r)?isNaN(n):isNaN(n)?!1:r-n===0},u;case"QUNC":return u.compare=l,u.equals=function(t,e){var r=c(t,!0),n=c(e,!0);return isNaN(r)?isNaN(n):isNaN(n)?!1:r-n===0},u;case"DblSC":return u.compare=i(function(t,e){return t.toNumber()-e.toNumber()}),u.equals=function(t,e){var r=t.toNumber(),n=e.toNumber();return isNaN(r)?isNaN(n):isNaN(n)?!1:r-n===0},u;case"CCC":case"TEXT":return u.compare=o(function(t,e){return t.value.toString()<e.value.toString()?-1:t.value.toString()==e.value.toString()?0:1}),u.equals=function(t,e){return null===t?null===e:null===e?!1:t.value.toString()==e.value.toString()},u;case"CAVC":case"DecSC":case"GAC":case"AtSC":case"CalVC":return{compare:o(i(n)),equals:t};case"EQC":return u.equals=t,u.compare=function(t,e){return u.equals(t,e)?0:1},u;default:throw new XError("Unknown comparer "+e,"SXJS0003")}}function h(t,e){function r(t){return"descending"==l?function(e,r){return t(r,e)}:t}var s=Expr,c=null;t.hasAttribute("comp")&&(c=t.getAttribute("comp"),c=c.replace(/^DESC\|/,""));var l=s.evaluateIfPresent(s.argRole(t,"order"),e).next(),p=s.evaluateIfPresent(s.argRole(t,"lang"),e).next(),h=s.evaluateIfPresent(s.argRole(t,"caseOrder"),e).next(),g=s.evaluateIfPresent(s.argRole(t,"dataType"),e).next();l=null===l?"ascending":l.toString();try{p=null===p||""===p.toString()?null:Atomic.language.fromString(p.toString())}catch(d){throw XError("xsl:sort/@lang: "+d.message,"XTDE0030")}h=null===h?"#default":h.toString(),g=null===g?null:g.toString();var v=u;if("#default"!=h&&(v=m(v,"lower-first"==h)),"number"==g)return r(f);if("text"==g){var x=function(t,e){return v(Atomic.string.cast(t),Atomic.string.cast(e))};return r(o(x))}if(c){if("DblSC"==c)return r(o(i(n)));if("CalVC"==c||"DecSC"==c)return r(o(n));if("CCC"==c)return r(o(v))}return r(a(v))}function g(t,e){switch(t){case"=":case"eq":return 0===e;case"<":case"lt":return 0>e;case">":case"gt":return e>0;case">=":case"ge":return e>=0;case"<=":case"le":return 0>=e;case"!=":case"ne":return 0!==e;default:throw new XError("Unknown operator "+t,"SXJS0003")}}function d(t,e){switch(t){case"=":case"eq":return e;case"!=":case"ne":return!e;case"<":case"lt":case">":case"gt":case">=":case"ge":case"<=":case"le":throw new XError("Operator "+t+" not allowed for unordered types","SXJS0003");default:throw new XError("Unknown operator "+t,"SXJS0003")}}function v(t){return(Atomic["double"].matches(t)||Atomic["float"].matches(t))&&isNaN(t.toNumber())}function x(t,e){return v(t)&&v(e)}function E(t,e,r){var n=t.expand(),o=e.expand();t=Iter.ForArray(n),e=Iter.ForArray(o);for(var i,a;;){if(i=t.next(),a=e.next(),null===i)return null===a;if(null===a)return!1;if(!N(i,a,r))return!1}}function S(t,e){var r=DomUtils;return t==e||t==r.DOCUMENT_NODE&&e==r.DOCUMENT_FRAGMENT_NODE||e==r.DOCUMENT_NODE&&t==r.DOCUMENT_FRAGMENT_NODE}function N(t,e,r){var n=DomUtils;if(t===e)return!0;if(n.isNode(t)){if(!n.isNode(e)||!S(t.nodeType,e.nodeType))return!1;switch(t.nodeType){case n.DOCUMENT_NODE:case n.DOCUMENT_FRAGMENT_NODE:return E(Axis.child(t),Axis.child(e));case n.ELEMENT_NODE:if(!n.nameOfNode(t).equals(n.nameOfNode(e)))return!1;var o=Axis.attribute(t).expand();if(o.length!=Axis.attribute(e).count())return!1;var i;for(i=0;i<o.length;i++){var a=o[i],u=n.nameOfNode(a),s=u.uri?u.uri:"";if(!e.hasAttributeNS(s,u.local))return!1;if(e.getAttributeNS(s,u.local)!=a.value)return!1}return E(Axis.child(t),Axis.child(e));case n.ATTRIBUTE_NODE:return n.nameOfNode(t).equals(n.nameOfNode(e))&&t.value==e.value;case n.NAMESPACE_NODE:return t.prefix==e.prefix&&t.uri==e.uri;case n.PROCESSING_INSTRUCTION_NODE:return r?t.target==e.target&&r(t.textContent,e.textContent):t.target==e.target&&t.textContent==e.textContent;case n.TEXT_NODE:case n.COMMENT_NODE:return r?r(t.textContent,e.textContent):t.textContent==e.textContent;default:throw new XError("Unknown node type "+t.nodeType,"SXJS0003")}}else{if(Expr.isArray(t)){if(!Expr.isArray(e)||e.value.length!=t.value.length)return!1;for(var c=0;c<t.value.length;c++)if(!E(Iter.ForArray(t.value[c]),Iter.ForArray(e.value[c],r)))return!1;return!0}if(Expr.isMap(t)){if(!Expr.isMap(e))return!1;var l=t.keys(),f=e.keys();return l.length!=f.length?!1:Iter.ForArray(l).every(function(r){return e.containsKey(r)&&E(Iter.ForArray(t.get(r)),Iter.ForArray(e.get(r)))})}if(v(t)&&v(e))return!0;if(r&&Atomic.string.matches(t)&&Atomic.string.matches(e))return r(t.value,e.value);try{return t.equals(e)}catch(m){return!1}}}function y(t,e,r){for(var n=t.next(),o=e.next();;){if(null===n)return null===o?0:-1;if(null===o)return 1;if(r){if(!N(n,o,r.equals))return v(n)?-1:Atomic.string.matches(n)&&Atomic.string.matches(o)?r.compare(n.value,o.value):n.compareTo(o);n=t.next(),o=e.next()}else{if(!N(n,o))return v(n)?-1:n.compareTo(o);n=t.next(),o=e.next()}}}function A(t,e){function r(t){var e=[];return n.forEachItem(function(r){t(e,r)}),e}var n=Iter.Tracker(Expr.evaluate(Expr.argRole(t,"select"),e)),o=e.newContext(!1);o.focus=n;var i={starting:function(){var e=makePattern(Expr.argRole(t,"match"));return r(function(t,r){1==n.position||e(r,o)?t.push({group:[r]}):t[t.length-1].group.push(r)})},ending:function(){var e=makePattern(Expr.argRole(t,"match")),i=!1;return r(function(t,r){1==n.position||i?t.push({group:[r]}):t[t.length-1].group.push(r),i=e(r,o)})},adjacent:function(){var e=Expr.argRole(t,"key"),i=null;return r(function(t,r){var a=Expr.evaluate(e,o).expand();1!=n.position&&E(Iter.ForArray(a),Iter.ForArray(i))?t[t.length-1].group.push(r):(t.push({group:[r],key:a}),i=a)})},by:function(){var e=Expr.argRole(t,"key"),n=new HashTrie;return r(function(t,r){var i,a=[];Expr.evaluate(e,o).forEachItem(function(e){n.containsKey(e)?(i=n.get(e),a.findIndex(function(t){return t==i})<0&&(t[i].group.push(r),a.push(i))):(i=t.length,t.push({group:[r],key:[e]}),n.inSituPut(e,i),a.push(i))})})},by_c:function(){var e=Expr.argRole(t,"key"),n=new HashTrie;return n.options={sameKey:function(t,e){return E(Iter.ForArray(t),Iter.ForArray(e))},hash:function(t){return t.map(function(t){return t.hashCode()}).join()}},r(function(t,r){var i,a=Expr.evaluate(e,o).expand();n.containsKey(a)?(i=n.get(a),t[i].group.push(r)):(i=t.length,t.push({group:[r],key:a}),n.inSituPut(a,i))})}};i.adjacent_c=i.adjacent;var a=t.getAttribute("algorithm")+(Expr.hasFlag(t,"c")?"_c":""),u=i[a](),s=DomUtils.getChildElements(t,"sortKey");if(s.length>0){var c=Iter.Tracker(Iter.ForArray(u)),l=e.newContext(!1);l.focus=c;var f=s.map(function(t){return h(t,e)});c.forEachItem(function(t,e){t.sortKeys=s.map(function(r){var n=l.focus;return n.current=t.group[0],n.position=e+1,n.currentGroup=t.group,n.currentGroupingKey=t.key,Expr.evalChild1(r,l).next()})}),u.sort(function(t,e){for(var r=0;r<f.length;r++){var n=f[r](t.sortKeys[r],e.sortKeys[r]);if(0>n)return-1;if(n>0)return 1}return 0})}var m=e.newContext(!1);m.focus=Iter.Tracker(Iter.ForArray(u));for(var p,g=Expr.argRole(t,"content"),d=[],v=0;null!==(p=m.focus.next());){var x=u[v++],S=m.focus;S.current=x.group[0],S.position=v,m.currentGroup=x.group,m.currentGroupingKey=x.key,Array.prototype.push.apply(d,Expr.evaluate(g,m).expand())}return Iter.ForArray(d)}function b(t,e){return t.hasAttribute("collation")||e?!0:!1}function w(t,e){var r=t.hasAttribute("collation")?t.getAttribute("collation"):null;if(!r&&e&&(r=e.next().toString()),"http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive"==r||"http://www.w3.org/2010/09/qt-fots-catalog/collation/caseblind"==r)return I();if(!r||"http://www.w3.org/2005/xpath-functions/collation/codepoint"==r||T().startsWith(r,"http://www.w3.org/2013/collation/UCA"))return T();throw XError("Unrecognized collation","FOCH0002")}function T(){function t(t,e){if(Expr.isAstral(t)||Expr.isAstral(e)){var r=Compare.codePointComparison(t,e);return 0>r?-1:0===r?0:1}return e>t?-1:t==e?0:1}return{equals:function(e,r){return 0===t(e,r)},compare:function(e,r){return t(e,r)},containsToken:function(t,e){return t.split(/[ \n\r\t]+/).findIndex(function(t){return t==e})>=0},contains:function(t,e){return-1!=t.indexOf(e)},startsWith:function(t,e){return t.substring(0,e.length)==e},endsWith:function(t,e){return t.substring(t.length-e.length)==e},indexOf:function(t,e){return t.indexOf(e)},collationKey:function(t){return t},deepEqual:Compare.deepEqualSequences,deepEqualItems:Compare.deepEqualItems}}function I(){function t(t){return t.toUpperCase()}function e(e,r){return t(e)===t(r)}return{equals:e,compare:function(e,r){return T().compare(t(e),t(r))},containsToken:function(e,r){return e.split(/[ \n\r\t]+/).findIndex(function(e){return t(e)==t(r)})>=0},contains:function(e,r){return T().contains(t(e),t(r))},startsWith:function(e,r){return T().startsWith(t(e),t(r))},endsWith:function(e,r){return T().endsWith(t(e),t(r))},indexOf:function(e,r){return T().indexOf(t(e),t(r))},collationKey:function(e){return t(e)},deepEqual:function(t,r){return Compare.deepEqualSequences(t,r,e)},deepEqualItems:function(t,r){return Compare.deepEqualItems(t,r,e)}}}var D={"=":function(t,e){return t.equals(e)},"!=":function(t,e){return!t.equals(e)},"<":function(t,e){return e>t},">":function(t,e){return t>e},"<=":function(t,e){return e>=t},">=":function(t,e){return t>=e}};return D.eq=D["="],D.ne=D["!="],D.le=D["<="],D.ge=D[">="],D.lt=D["<"],D.gt=D[">"],{allocateCodedComparer:p,codePointComparison:u,deepEqualItems:N,deepEqualSequences:E,gc:e,generalComparison:r,grouping:A,itemIsNaN:v,lexicographicCompare:y,bothItemsAreNaN:x,sortSequence:s,testComparison:g,testEquality:d,getCollation:w,hasCollation:b,codepointCollation:T,caseblindCollation:I}}(),NAMESPACE_NODE=13;NamespaceNode.prototype={prefix:null,uri:null,parentNode:null,nodeType:NAMESPACE_NODE};var ATTRIBUTE_NODE=2;AttributeNode.prototype={qname:null,value:null,parent:null,nodeType:ATTRIBUTE_NODE};var DomUtils=function(){"use strict";var t=1;return{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NAMESPACE_NODE:13,shallowCopy:function(t,e,r,n){if(DomUtils.isNode(t)){var o,i;switch(t.nodeType){case DomUtils.DOCUMENT_NODE:case DomUtils.DOCUMENT_FRAGMENT_NODE:o=e.resultDocument.createDocumentFragment();var a=e.newContext(!1);Expr.makeComplexContent(o,n(a),e);break;case DomUtils.ELEMENT_NODE:i=DomUtils.nameOfNode(t),o=e.createElement(i.uri,i.toString()),r&&r.indexOf("c")>=0&&!(SaxonJS.getPlatform().inBrowser&&o instanceof HTMLElement)&&DomUtils.inScopeNamespaces(t).forEach(function(t){DomUtils.declareNS(o,t.prefix,t.uri)}),o._saxonBaseUri=DomUtils.baseURI(t),Expr.makeComplexContent(Expr.markLocal(o,r),n(e),e);break;case DomUtils.ATTRIBUTE_NODE:o=new AttributeNode(DomUtils.nameOfNode(t),t.value,null);break;case DomUtils.TEXT_NODE:o=e.resultDocument.createTextNode(t.textContent);break;case DomUtils.COMMENT_NODE:o=e.resultDocument.createComment(t.textContent);break;case DomUtils.PROCESSING_INSTRUCTION_NODE:o=e.resultDocument.createProcessingInstruction(t.target,t.textContent);break;case DomUtils.NAMESPACE_NODE:o=new NamespaceNode(t.prefix,t.uri);break;default:throw XError("Unknown node type "+t.nodeType,"SXJS0003")}return Iter.Singleton(Expr.markLocal(o,r))}return Iter.Singleton(t)},copyItem:function(t,e,r){if(!DomUtils.isNode(t))return t;var n,o,i;switch(t.nodeType){case DomUtils.DOCUMENT_NODE:case DomUtils.DOCUMENT_FRAGMENT_NODE:var a=e.resultDocument.createDocumentFragment();return n=DomUtils.obtainDocumentNumber(a),n._saxonBaseUri=t._saxonBaseUri,Expr.makeComplexContent(n,Axis.child(t).mapOneToOne(function(t){return DomUtils.copyItem(t,e,r)}),e),Expr.markLocal(n,r);case DomUtils.NAMESPACE_NODE:return new NamespaceNode(t.prefix,t.uri);case DomUtils.ELEMENT_NODE:return i=DomUtils.nameOfNode(t),o=e.createElement(i.uri,i.toString()),r&&r.indexOf("c")>=0&&!(SaxonJS.getPlatform().inBrowser&&o instanceof HTMLElement)&&DomUtils.inScopeNamespaces(t).forEach(function(t){DomUtils.declareNS(o,t.prefix,t.uri)}),Axis.attribute(t).forEachItem(function(t){o.setAttributeNS(t.namespaceURI,t.name,t.value)}),Axis.child(t).forEachItem(function(t){o.appendChild(DomUtils.copyItem(t,e,r))}),o._saxonBaseUri=DomUtils.baseURI(t),Expr.markLocal(o,r);case DomUtils.DOCUMENT_TYPE_NODE:return null;case DomUtils.ATTRIBUTE_NODE:return new AttributeNode(DomUtils.nameOfNode(t),t.value,null);default:return o=SaxonJS.getPlatform().inBrowser?window.document.importNode(t,!0):cloneNode(e.resultDocument,t,!0),Expr.markLocal(o,r)}},ownerDocument:function(t){return Axis.ancestorOrSelf(t).expand().pop()},obtainDocumentNumber:function(e){return"_saxonDocumentNumber"in e||(e._saxonDocumentNumber=t++),e},documentNumber:function(t){return DomUtils.obtainDocumentNumber(t)._saxonDocumentNumber},nameOfNode:function(t){if(!t||!t.nodeType)return null;switch(t.nodeType){case DomUtils.ELEMENT_NODE:return SaxonJS.getPlatform().inBrowser&&t instanceof HTMLElement&&"http://www.w3.org/1999/xhtml"==t.namespaceURI?Atomic.QName.fromParts("","",t.localName):Atomic.QName.fromParts(t.prefix,t.namespaceURI,t.localName);case DomUtils.ATTRIBUTE_NODE:return"xml"==t.prefix?Atomic.QName.fromParts(t.prefix,"http://www.w3.org/XML/1998/namespace",t.localName):t.qname;case DomUtils.PROCESSING_INSTRUCTION_NODE:return Atomic.QName.fromParts("","",t.target);case DomUtils.NAMESPACE_NODE:return t.prefix?Atomic.QName.fromParts("","",t.prefix):null;default:return null}},hasLocalName:function(t,e){return"undefined"!=typeof HTMLElement&&(t instanceof HTMLElement||t.nodeType==DomUtils.ATTRIBUTE_NODE&&t.parent instanceof HTMLElement)?t.localName.toUpperCase()===e.toUpperCase():t.localName===e},hasNamespace:function(t,e){return e==(DomUtils.isAttr(t)?t.namespaceURI:t.namespaceURI||"")},getChildElements:function(t,e){for(var r=[],n=t.firstChild;null!==n;)n.nodeType!=DomUtils.ELEMENT_NODE||e&&e!=n.tagName||r.push(n),n=n.nextSibling;return r},inDocumentOrder:function(t){var e=t.expand();return e.sort(DomUtils.compareDocumentOrder),Iter.ForArray(e).mapOneToOne(function(t,r){return r>0&&DomUtils.isSameNode(t,e[r-1])?null:t})},compareDocumentOrder:function(t,e){function r(t){return Axis.ancestor(t).count()}if(DomUtils.isSameNode(t,e))return 0;var n=DomUtils.xdmParentNode(t),o=DomUtils.xdmParentNode(e);if(null===n){if(null===o){var i=DomUtils.obtainDocumentNumber;return i(t)._saxonDocumentNumber<i(e)._saxonDocumentNumber?-1:1}return t===o?-1:DomUtils.compareDocumentOrder(t,o)}if(null===o)return e===n?1:DomUtils.compareDocumentOrder(n,e);if(n!==o){if(t===o)return-1;if(e===n)return 1;var a=r(n),u=r(o);return a==u?DomUtils.compareDocumentOrder(n,o):a>u?DomUtils.compareDocumentOrder(n,e):DomUtils.compareDocumentOrder(t,o)}var s=t.nodeType,c=e.nodeType;if(s==DomUtils.ATTRIBUTE_NODE){if(c==DomUtils.ATTRIBUTE_NODE){var l,f=n.attributes;for(l=0;l<f.length;l++){var m=new AttributeNode(Atomic.QName.fromParts(f[l].prefix,f[l].namespaceURI,f[l].localName),f[l].value,null),p=m.name;if(p.indexOf(":")<0){if(p==t.localName)return-1;if(p==e.localName)return 1}else{if(p=DomUtils.nameOfNode(m),p.equals(DomUtils.nameOfNode(t)))return-1;if(p.equals(DomUtils.nameOfNode(e)))return 1}}throw XError("Att not found in parent","SXJS0004")}return c==DomUtils.NAMESPACE_NODE?1:-1}if(s==DomUtils.NAMESPACE_NODE)return c==DomUtils.NAMESPACE_NODE?t.prefix<e.prefix?-1:1:-1;if(c==DomUtils.ATTRIBUTE_NODE||c==DomUtils.NAMESPACE_NODE)return 1;for(var h=t,g=e;;){if(h=h.previousSibling,null===h)return-1;if(h===e)return 1;if(g=g.previousSibling,null===g)return 1;if(g===t)return-1}},xdmParentNode:function(t){return DomUtils.isAttr(t)?t.parent:t.parentNode},declareNS:function(t,e,r){t.setAttributeNS("http://www.w3.org/2000/xmlns/",""===e?"xmlns":"xmlns:"+e,r)},inScopeNamespaces:function(t){for(var e,r=[{prefix:"xml",uri:"http://www.w3.org/XML/1998/namespace"}],n={xml:!0},o=Axis.ancestorOrSelf(t);null!==(e=o.next())&&e.nodeType==DomUtils.ELEMENT_NODE;){var i,a=e.attributes;for(i=0;i<a.length;i++){var u=a[i].name;if("xmlns"==u.substring(0,5))if(5!=u.length||n[""]){if(":"==u.charAt(5)){var s=u.substring(6);n[s]||(n[s]=!0,r.push({prefix:s,uri:a[i].value}))}}else n[""]=!0,""!==a[i].value&&r.push({prefix:"",uri:a[i].value})}}return r},getInheritedAttribute:function(t,e){for(var r=t;r&&r.nodeType==DomUtils.ELEMENT_NODE;){if(r.hasAttribute(e))return r.getAttribute(e);r=r.parentNode}return null},getAttribute:function(t,e,r){return t.hasAttribute(e)?t.getAttribute(e):arguments.length>2?r:null},getAttributeAsEQName:function(t,e,r){var n=DomUtils.getAttributeAsQName(t,e,r);return null===n?null:"Q{"+n.uri+"}"+n.local},getAttributeAsQName:function(t,e,r){return t.hasAttribute(e)?DomUtils.resolveLexicalQName(t,t.getAttribute(e),r):null},resolveLexicalQName:function(t,e,r){var n=Atomic.QName;if(/^Q\{/.test(e))return n.fromEQName(e);if(/:/.test(e)){var o=function(e){return"xml"==e?"http://www.w3.org/XML/1998/namespace":t.lookupNamespaceURI(e)};return n.fromString(e,o)}var i=r?t.lookupNamespaceURI(null)||"":"";return n.fromParts("",i,e)},isAttr:function(t){return t instanceof AttributeNode},isNSNode:function(t){return t instanceof NamespaceNode},isNode:function(t){return t instanceof Node&&!(t.nodeType==DomUtils.PROCESSING_INSTRUCTION_NODE&&"xml"==t.target)||DomUtils.isAttr(t)||DomUtils.isNSNode(t)},isSameNode:function(t,e){return t===e||DomUtils.isNSNode(t)&&DomUtils.isNSNode(e)&&t.parentNode&&e.parentNode&&t.parentNode==e.parentNode&&t.prefix==e.prefix||DomUtils.isAttr(t)&&DomUtils.isAttr(e)&&t.parent&&e.parent&&t.parent==e.parent&&DomUtils.nameOfNode(t).equals(DomUtils.nameOfNode(e))},isAbsoluteURI:function(t){return/^(?:[a-z]+:)?\/\//i.test(t)},baseURI:function(t){function e(t){var e=DomUtils.xdmParentNode(t);return e?DomUtils.baseURI(e):t._saxonBaseUri?t._saxonBaseUri:null}if(null===t||DomUtils.isNSNode(t))return null;if(t.nodeType==DomUtils.ELEMENT_NODE&&t.hasAttribute("xml:base")){var r=t.getAttribute("xml:base");return DomUtils.isAbsoluteURI(r)?r:SaxonJS.getPlatform().resolveUri(r.toString(),e(t)).toString()}return e(t)},xmlToString:function(t,e,r,n){function o(t,e,r,n){var a=[];"undefined"!=typeof r&&r.forEach(function(t){a[t]=!0});var u,s,c,l,f="undefined"!=typeof n?n:"",m="",p=!1,h=!1,g=!1;switch(t.nodeType){case DomUtils.DOCUMENT_NODE:c=t.documentElement,null!==c&&(m=o(c,""));break;case DomUtils.DOCUMENT_FRAGMENT_NODE:for(s=t.childNodes,l=0;l<s.length;++l)c=s[l],m+="\n"+o(c,"");break;case DomUtils.ELEMENT_NODE:u=DomUtils.nameOfNode(t),m+=("none"==e?"":e)+"<"+u;var d="",v=t.namespaceURI;v!=f&&(null!==v&&""!==v&&(d+=' xmlns="'+v+'"'),f=v);var x=t.attributes;for(l=0;l<x.length;++l){var E=new AttributeNode(Atomic.QName.fromParts(x[l].prefix,x[l].namespaceURI,x[l].localName),x[l].value,null),S=DomUtils.nameOfNode(E).toString();S.match(/^xmlns:xml/)||(S.match(/^xmlns/)?a[S]||(a[S]=!0,("xmlns"!=S||null!==f&&""!==f&&f!=E.value)&&(d+=" "+DomUtils.xmlToString(E,0))):d+=" "+DomUtils.xmlToString(E,0),d.length>i.headerLength&&l<x.length-1&&(m+=d,d="\n"+("none"==e?"":e)+" "))}if(m+=d,s=t.childNodes,0===s.length)m+="/>";else{for(m+=">",l=0;l<s.length;++l)c=s[l],p=c.nodeType==DomUtils.TEXT_NODE&&""!==c.nodeValue,g="none"==e||p||h,m+=g?"":"\n",m+=o(c,g?"none":e+i.indent,a,f),h=p;g||(m+="\n"+e),m+="</"+u+">"}break;case DomUtils.ATTRIBUTE_NODE:u=DomUtils.nameOfNode(t).toString(),m+=u+'="'+t.value.replace(/"/g,'""')+'"';break;case DomUtils.TEXT_NODE:m=t.nodeValue.replace(/&/g,"&amp;");break;case DomUtils.COMMENT_NODE:m+="<!--"+t.nodeValue+"-->";break;case DomUtils.PROCESSING_INSTRUCTION_NODE:m+="<?"+t.target+" "+t.nodeValue+"?>";break;case DomUtils.NAMESPACE_NODE:break;case DomUtils.CDATA_SECTION:return t.data;default:throw XError("Unknown node type "+t.nodeType,"SXJS0003")}return m}var i="undefined"!=typeof e?e:{headerLength:80,indent:" "};return o(t,"")}}}(),HashTrie=function(){"use strict";function t(e,r){if(""===r)return e.leafKVPs;var n=r.charAt(0);return e.subTries.hasOwnProperty(n)?t(e.subTries[n],r.substring(1)):[]}function e(e,r){for(var n=t(e,e.options.hash(r)),o=0;o<n.length;o++)if(e.options.sameKey(n[o].k,r))return n[o];return null}function r(t,e,n,o){if(""===o){for(var u=0;u<t.leafKVPs.length;u++)if(t.options.sameKey(t.leafKVPs[u].k,e))return void(t.leafKVPs[u]={k:e,v:n});t.leafKVPs.push({k:e,v:n})}else{var s,c=o.charAt(0);t.subTries.hasOwnProperty(c)?s=t.subTries[c]:(s=new i(t.options),
s.id=a++,t.subTries[c]=s),r(s,e,n,o.substring(1))}}function n(t,e,r,o){var a=new i(t.options),u=!1;if(""===o)return a.leafKVPs=t.leafKVPs.map(function(n){return t.options.sameKey(n.k,e)?(u=!0,{k:e,v:r}):n}),u||a.leafKVPs.push({k:e,v:r}),a.subTries=t.subTries,a;var s=o.charAt(0);for(var c in t.subTries)t.subTries.hasOwnProperty(c)&&(c==s?(a.subTries[c]=n(t.subTries[c],e,r,o.substring(1)),u=!0):a.subTries[c]=t.subTries[c]);if(!u){var l=new i(t.options);l=n(l,e,r,o.substring(1)),a.subTries[s]=l}return a.leafKVPs=t.leafKVPs,a}function o(t,e,r){var n=new i(t.options);if(""===r)return n.leafKVPs=t.leafKVPs.filter(function(r){return!t.options.sameKey(r.k,e)}),n.subTries=t.subTries,n;var a=r.charAt(0);for(var u in t.subTries)t.subTries.hasOwnProperty(u)&&(n.subTries[u]=u==a?o(t.subTries[u],e,r.substring(1)):t.subTries[u]);return n.leafKVPs=t.leafKVPs,n}function i(t){this.leafKVPs=[],this.subTries={},this.options=t||{hash:u.hash,sameKey:u.sameKey}}var a=0,u={hash:function(t){return t.hashCode()},sameKey:function(t,e){function r(t){return"timezoneOffset"in t&&null!==t.timezoneOffset}try{return(t.equals(e)||Compare.itemIsNaN(t)&&Compare.itemIsNaN(e))&&r(t)==r(e)}catch(n){return print(n),!1}}};return i.prototype={leafKVPs:[],subTries:{},options:u,containsKey:function(t){return null!==e(this,t)},get:function(t){var r=e(this,t);return null===r?[]:r.v},inSituPut:function(t,e){r(this,t,e,this.options.hash(t))},put:function(t,e){return n(this,t,e,this.options.hash(t))},remove:function(t){return o(this,t,this.options.hash(t))},forAllPairs:function(t){this.leafKVPs.forEach(t);for(var e in this.subTries)this.subTries.hasOwnProperty(e)&&this.subTries[e].forAllPairs(t)},display:function(){function t(e,r){r>0&&print("Subtrie "+r),e.leafKVPs.forEach(function(t){print(showValue(t.k)+": "+showValue(t.v))});for(var n in e.subTries)e.subTries.hasOwnProperty(n)&&t(e.subTries[n],r+1)}print("HashTrie:"),t(this,0)},keys:function(){var t=[];return this.forAllPairs(function(e){t.push(e.k)}),t},conforms:function(t,e,r){var n=this;return Iter.ForArray(n.keys()).every(function(o){var i=n.get(o);return t(o)&&r(i.length)&&Iter.ForArray(i).every(e)})}},i}(),Axis=function(){"use strict";var t=DomUtils,e={ancestor:function(e){var r;switch(e.nodeType){case t.DOCUMENT_NODE:case t.DOCUMENT_FRAGMENT_NODE:return Iter.Empty;case t.ATTRIBUTE_NODE:return e.parent?Iter.Stepping(e.parent,function(t){return t.parentNode}):Iter.Empty;default:return r=e.parentNode,r?Iter.Stepping(r,function(t){return t.parentNode}):Iter.Empty}},ancestorOrSelf:function(t){return Iter.Join([Iter.Singleton(t),Axis.ancestor(t)])},attribute:function(e){if(e.nodeType==t.ELEMENT_NODE){var r,n,o=e.attributes,i=[];for(r=0;r<o.length;r++)n=o[r].name,("xmlns"!=n.substring(0,5)||5!=n.length&&":"!=n.charAt(5))&&i.push(new AttributeNode(Atomic.QName.fromParts(o[r].prefix,o[r].namespaceURI,o[r].localName),o[r].value,e));return Iter.ForArray(i)}return Iter.Empty},child:function(e){function r(t){return Iter.Stepping(t.firstChild,function(t){return t.nextSibling})}if(null===e)return Iter.Empty;switch(e.nodeType){case t.DOCUMENT_NODE:return r(e).filter(function(e){return!(e.nodeType==t.PROCESSING_INSTRUCTION_NODE&&"xml"==e.target||e.nodeType==t.TEXT_NODE)});case t.DOCUMENT_FRAGMENT_NODE:case t.ELEMENT_NODE:return r(e);default:return Iter.Empty}},descendant:function(t){return Axis.child(t).mapOneToMany(function(t){return Axis.descendantOrSelf(t)})},descendantOrSelf:function(t){return Iter.Join([Iter.Singleton(t),Axis.descendant(t)])},following:function(e){switch(e.nodeType){case t.DOCUMENT_NODE:case t.DOCUMENT_FRAGMENT_NODE:return Iter.Empty;case t.ATTRIBUTE_NODE:case t.NAMESPACE_NODE:var r=t.xdmParentNode(e);return null===r?Iter.Empty:Iter.Join([Axis.descendant(r),Axis.following(r)]);default:return Axis.ancestorOrSelf(e).mapOneToMany(function(t){return Axis.followingSibling(t).mapOneToMany(Axis.descendantOrSelf)})}},followingSibling:function(e){switch(e.nodeType){case t.DOCUMENT_NODE:case t.DOCUMENT_FRAGMENT_NODE:case t.ATTRIBUTE_NODE:case t.NAMESPACE_NODE:return Iter.Empty;default:return Iter.Stepping(e.nextSibling,function(t){return t.nextSibling})}},namespace:function(e){return e.nodeType==t.ELEMENT_NODE?Iter.ForArray(t.inScopeNamespaces(e).map(function(t){return new NamespaceNode(t.prefix,t.uri,e)})):Iter.Empty},parent:function(e){return Iter.Singleton(t.xdmParentNode(e))},preceding:function(t){return Axis.ancestorOrSelf(t).mapOneToMany(function(t){return Axis.precedingSibling(t).mapOneToMany(function(t){return Iter.ForArray(Axis.descendantOrSelf(t).expand().reverse())})})},precedingSibling:function(e){switch(e.nodeType){case t.DOCUMENT_NODE:case t.DOCUMENT_FRAGMENT_NODE:case t.ATTRIBUTE_NODE:case t.NAMESPACE_NODE:return Iter.Empty;default:return Iter.Stepping(e.previousSibling,function(t){return t.previousSibling})}},self:function(t){return Iter.Singleton(t)}};return e["ancestor-or-self"]=e.ancestorOrSelf,e["descendant-or-self"]=e.descendantOrSelf,e["following-sibling"]=e.followingSibling,e["preceding-sibling"]=e.precedingSibling,e}();XError.prototype=Object.create(Error.prototype),XError.prototype.constructor=XError,XError.prototype.code=null,XError.prototype.xsltLineNr=null,XError.prototype.xsltModule=null,XError.prototype.compiledLineNr=null,XError.prototype.isGlobal=!1,XError.prototype.setExpr=function(t){this.xsltLineNr=DomUtils.getInheritedAttribute(t,"line"),this.xsltModule=DomUtils.getInheritedAttribute(t,"module"),this.compiledLineNr=t.lineNumber,null!==this.xsltLineNr&&(this.message+=" at "+this.xsltModule+"#"+this.xsltLineNr)},XError.test=function(t){if(t)throw XError.call(this,arguments[1],arguments[2],arguments[3])};var Expr=function(){"use strict";function t(){}function e(t){var e=t.split("|"),r=e[0],n=e[1],o=""===e[2]?"XPTY0004":e[2],i=e[3],a=["ancestor","ancestor-or-self","attribute","child","descendant","descendant-or-self","following","following-sibling","namespace","parent","preceding","preceding-sibling","self","preceding-or-ancestor"],u=function(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}},s=function(){switch(parseInt(r,10)){case 0:return u(+n+1)+" argument of "+(""===i?"anonymous function":i+"()");case 1:return u(+n+1)+" operand of '"+i+"'";case 9:return"operand of '-'";case 2:return"value in '"+i+"' expression";case 3:return"saxon:context-item"==i?"context item":"value of variable $"+i;case 4:var t=i.split("/");return"@"+t[1]+" attribute of "+("LRE"==t[0]?"a literal result element":t[0]);case 5:return"result of call to "+(""===i?"anonymous function":"function "+i);case 7:return"result of template "+i;case 6:return u(+n+1)+" sort key";case 8:return"value of parameter $"+i;case 11:return"value of the grouping key";case 13:return"the context item";case 14:return"the context item for the "+a[n]+" axis";case 15:return"the value of the "+i+" option";case 17:return"document-order sorter";default:return""}};return{required:s(),code:o}}function r(t,e,r,n,o){if(!r.match(/^[smijxq]*$/))throw XError("Illegal flags for regular expression: "+r,"FORX0001");var i=Regex.prepareRegex(e,r+"g",t);if(!n&&i.test(""))throw XError("Regular expression matches zero-length string","FORX0003");for(var a,u=[],s=0,c=0;null!==(a=i.exec(t));)if((a.index>s||a.index==s&&o)&&u.push({matching:!1,string:Atomic.string.fromString(t.substring(s,a.index))}),u.push({matching:!0,groups:a,string:Atomic.string.fromString(a[0])}),s=i.lastIndex,c++>1e3)throw XError("looping???","SXJS0004");return t.length>s&&u.push({matching:!1,string:Atomic.string.fromString(t.substring(s,t.length))}),u}function n(t){return t.replace(/[ \n\r\t]+/g," ").replace(/^[ ]|[ ]$/g,"")}function o(t){if(j.isNode(t))return Iter.Singleton(i(t));if(J(t))return Iter.Join(t.value.map(function(t){return Iter.ForArray(t)})).mapOneToMany(o);if(z(t))throw XError("Cannot atomize a map","FOTY0013");return Iter.Singleton(t)}function i(t){var e=Atomic.string.fromString,r=Atomic.untypedAtomic.fromString;switch(t.nodeType){case j.DOCUMENT_NODE:return r(t.documentElement.textContent);case j.DOCUMENT_FRAGMENT_NODE:case j.ELEMENT_NODE:case j.TEXT_NODE:return r(t.textContent||"");case j.ATTRIBUTE_NODE:return r(t.value);case j.COMMENT_NODE:return e(t.textContent);case j.PROCESSING_INSTRUCTION_NODE:return e(t.data);case j.NAMESPACE_NODE:return e(t.uri);default:throw XError("Unknown node type "+t.nodeType,"SXJS0003")}}function a(t){function e(t){throw XError("Effective boolean value is not defined for "+t,"FORG0006")}function r(){return null===t.next()?!0:void e("an atomic sequence of length > 1")}var n=t.next();if(null===n)return!1;if(j.isNode(n))return!0;if(Atomic["boolean"].matches(n))return r()&&n.toBoolean();if(Atomic.numeric.matches(n)){var o=n.toNumber();return r()&&!isNaN(o)&&0!==o}return Atomic.string.matches(n)||Atomic.untypedAtomic.matches(n)||Atomic.anyURI.matches(n)?r()&&0!==n.toString().length:void e("type "+n.type)}function u(t){return"untypedAtomic"===t.type?Atomic["double"].cast(t):t}function s(t,e){var r=Calculate["i+i"],n=Atomic.integer.fromNumber(1);return Iter.Stepping(t,function(t){var o=r(t,n);return o.compareTo(e)>0?null:o})}function c(t,e,r){var n=j.getChildElements(t,"withParam"),o=[{},{}];for(var i in e.tunnelParams)e.tunnelParams.hasOwnProperty(i)&&(o[1][i]=e.tunnelParams[i]);var a=e.tempOutputState;e.tempOutputState="template parameter",n.forEach(function(t){var r=j.getAttributeAsEQName(t,"name"),n=y(t,"t")?1:0;o[n][r]=E(t,e).expand()}),e.tempOutputState=a,r.localParams=o[0],r.tunnelParams=o[1]}function l(t,e){return e&&e.indexOf("l")>=0&&(t._saxonIsLocal=!0),t}function f(t,e,r){var n,o,i="compAtt"==t.tagName,a=Regex.trim(Y(N(t,"name"),e).next().toString()),u=N(t,"namespace");if(null===u){if(i&&"xmlns"==a)throw XError("Attribute must not be named xmlns","XTDE0855",t);o=b(t,a,!1),n=o.uri}else if(n=Y(u,e).next().value,i)if(""===n&&a.includes(":"))a=a.replace(/^.*:/,""),o=Atomic.QName.fromParts("",n,a);else if(a.includes(":")){var s=a.split(":");o=Atomic.QName.fromParts(s[0],n,s[1])}if("http://www.w3.org/2000/xmlns/"==n)throw XError("Disallowed namespace "+n,"XTDE0835",t);return i?Iter.Singleton(r(o)):Iter.Singleton(r(n,a))}function m(t,e,r){var n=E(t,e).next(),o=S(t,e).next();return null===n||null===o?null:r(n,o)}function p(t){if("xs:"==t.substring(0,3)){var e=Atomic[t.substring(3)];if(!e)throw XError("Unimplemented type "+t,"SXJS0002");return e}throw XError("Unknown type "+t,"SXJS0003")}function h(t,e){if(SaxonJS.getPlatform().inBrowser||null!==e.fixed.staticBaseURI)return e.fixed.staticBaseURI;for(var r=t;;){if(r.hasAttribute("baseUri"))return r.getAttribute("baseUri");if(r=j.xdmParentNode(r),null===r||r.nodeType!=j.ELEMENT_NODE)return null}}function g(t,e){var r=t.lookupNamespaceURI(e);if(null!==r)return r;if(r=j.getInheritedAttribute(t,"ns"),null===r)return null;var n,o=r.split(" ");for(n=0;n<o.length;n++){var i=o[n].split("=");if(i[0]==e)return i[1]}return null}function d(t,e,r){var n=e.resultDocument.createDocumentFragment(),o=j.obtainDocumentNumber(n);o._saxonBaseUri=h(t,e);var i=e.newContext(!1);return r&&(i.resultDocument=window.document),R(o,Y(t,i),i),o}function v(t,e){throw XError("The "+t+" construct is not implemented in Saxon-JS","SXJS0002",e)}function x(t,e){throw XError("The SEF is out of date, regenerate using Saxon-EE "+t+" or later","SXJS0002",e)}function E(t,e){var r=j.getChildElements(t)[0];if(!r)throw XError("Expr has no children","SXJS0004",t);return Y(r,e)}function S(t,e){return Y(j.getChildElements(t)[1],e)}function N(t,e){var r,n=t.childNodes;for(r=0;r<n.length;r++){var o=n[r];if(o.nodeType==j.ELEMENT_NODE&&o.getAttribute("role")==e)return o}return null}function y(t,e){return t.hasAttribute("flags")&&t.getAttribute("flags").indexOf(e)>=0}function A(t,e){var r=j.getInheritedAttribute(t,"ns");if(null===r)throw XError("Namespace context not available for "+t.tagName,"SXJS0004");return function(t){if(""===t&&!e)return"";var n,o=r.split(" ");for(n=0;n<o.length;n++){var i=o[n].split("=");if(i[0]==t)return i[1]}if(""===t)return"";throw XError("Undeclared prefix: "+t,"XTDE0290")}}function b(t,e,r){return Atomic.QName.fromString(e,A(t,r))}function w(t){return"undefined"==typeof t?void 0:T(t,"module",20)+"#"+T(t,"line",10)}function T(t,e,r){if(null!==t&&r>0){var n=j.getAttribute(t,e);return null!==n&&""!==n?n:T(t.parentNode,e,r-1)}return void 0}function I(t){throw print("*** Internal error: "+t),Error.dumpStack&&Error.dumpStack(),XError("Internal error: "+t,"SXJS0004")}function D(t,e){var r=K[t.tagName];r||I("Unknown expr: "+t.tagName);try{return r(t,e)}catch(n){throw n instanceof XError?(e.currentError=n,null===n.compiledLineNr&&null===n.xsltLineNr&&(n.setExpr(t),null!==n.xsltLineNr),n):n}}function C(t){var e=K[t.tagName];return e||I("Unknown expr: "+t.tagName),function(r){try{return e(t,r)}catch(n){throw n instanceof XError&&(r.currentError=n,null===n.compiledLineNr&&n.setExpr(t)),n}}}function O(t){return C(j.getChildElements(t)[1])}function U(t,e){return null===t?Iter.Empty:Y(t,e)}function X(t){if(1>t||t>55295&&57344>t||t>65533&&65536>t||t>1114111)throw XError("Invalid XML character 0x"+t.toString(16),"FOCH0001")}function _(t){for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r>=55296&&56319>=r)return!0}return!1}function M(t){var e="";return t.forEach(function(t){return X(t),e+=65536>t?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296)+String.fromCharCode((t-65536&1023)+56320)}),e}function F(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);e.push(n>=55296&&56319>=n?1024*(n-55296)+(t.charCodeAt(++r)-56320)+65536:n)}return e}function P(t,e){function r(t,e){return Atomic.decimal.matches(t)?"decimal"==e||"float"==e||"double"==e:Atomic["float"].matches(t)?"float"==e||"double"==e:!1}if(Atomic[e].matches(t))return t;if(r(t,e))return Atomic[e].cast(t);throw XError("Incompatible operands: "+t.type+" and "+e,"XPTY0004")}function k(t){var e="";return t.forEachItem(function(t){""!==e&&(e+=" "),e+=t.toString()}),e}function R(t,e,r){function n(e,r){function n(t){return t instanceof NamespaceNode?"a namespace":"an attribute"}if(r)throw XError("Cannot create "+n(e)+" node after creating children","XTDE0410");if(t.nodeType==j.DOCUMENT_FRAGMENT_NODE||t.nodeType==j.DOCUMENT_NODE)throw XError("Cannot add "+n(e)+" to a document node","XTDE0410")}function o(t,e){var u=e._saxonIsLocal?e._saxonIsLocal:!1;if(J(e))e.value.forEach(function(e){e.forEach(function(e){o(t,e)})});else{if(z(e))throw XError("A map can't be a child of an XML node","XPTY0004");if(j.isNode(e)?a=!1:(e=r.resultDocument.createTextNode((a?" ":"")+e.toString()),a=!0),t.nodeType==j.ELEMENT_NODE||t.nodeType==j.DOCUMENT_FRAGMENT_NODE)if(j.isNSNode(e))if(SaxonJS.getPlatform().inBrowser&&t instanceof HTMLElement)t.appendChild(t.ownerDocument.importNode(e,!0));else{if(n(e,i),e.prefix==t.prefix&&e.uri!=t.namespaceURI)throw XError("Saxon-JS restriction: namespace nodes in content clash with the element prefix","SXJS0002");if(""===e.prefix){if(""===t.namespaceURI)throw XError("Cannot add a default namespace to a no-namespace element","XTDE0440");if(t.hasAttributeNS("","xmlns")){if(t.getAttributeNS("","xmlns")!=e.uri)throw XError("Cannot have two different default namespaces","XTDE0430")}else SaxonJS.getPlatform().inBrowser&&t instanceof HTMLElement||t.setAttributeNS("","xmlns",e.uri)}else{var s="http://www.w3.org/2000/xmlns/",c="xmlns:"+e.prefix;if(t.hasAttributeNS(s,e.prefix)&&t.getAttributeNS(s,e.prefix)!=e.uri)throw XError("Cannot have two namespaces with the same prefix","XTDE0430");t.setAttributeNS(s,c,e.uri)}}else if(e.nodeType==j.ATTRIBUTE_NODE){if(n(e,i),""!==e.namespaceURI){var l=e.name.split(":");if(2!=l.length||t.lookupNamespaceURI(l[0])!=e.namespaceURI)if(2==l.length&&null===t.lookupNamespaceURI(l[0]))t.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:"+l[0],e.namespaceURI);else for(var f=2==l.length?l[0]:"ns";;){if(null===t.lookupNamespaceURI(f)){t.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:"+f,e.namespaceURI),e.name=f+":"+l[l.length-1];break}f+="_1"}}t.setAttributeNS(e.namespaceURI,e.name,e.value)}else if(e.nodeType==j.DOCUMENT_NODE||e.nodeType==j.DOCUMENT_FRAGMENT_NODE)Axis.child(e).forEachItem(function(e){o(t,e)});else{if(i=!0,!u||SaxonJS.getPlatform().inBrowser&&t instanceof HTMLElement!=e instanceof HTMLElement){var m=j.copyItem(e,r,"c");t.appendChild(m),m._saxonIsLocal=!1}else t.appendChild(e),e._saxonIsLocal=!1;if(!SaxonJS.getPlatform().inBrowser||r.resultDocument!=window.document){var p=e.prefix||"",h=e.namespaceURI||"";t.nodeType!=j.ELEMENT_NODE||e.nodeType!=j.ELEMENT_NODE||SaxonJS.getPlatform().inBrowser&&e instanceof HTMLElement||!e.lookupNamespaceURI(p!==h)||j.declareNS(e,p,h)}}else{if(t.nodeType!=j.DOCUMENT_NODE)throw XError("Unknown parent node type "+t.nodeType,"SXJS0003");null!==e&&(t.documentElement=e)}}}r||I("No context in makeComplexContent for "+showValue(t));var i=!1,a=!1;e.forEachItem(function(e){o(t,e)})}function B(t){this.value=t}function J(t){return t instanceof B}function z(t){return t instanceof HashTrie||t instanceof L}function $(t,e,r,n){function o(t){return j.isNode(t)||Atomic.untypedAtomic.matches(t)||Atomic.string.matches(t)||Atomic["boolean"].matches(t)||Atomic["double"].matches(t)}function i(t,e){return null===t||o(t)?t:q(t,e)}if(void 0===r)return t;if(Array.isArray(t)){if(!e(t.length))throw XError("Supplied value for parameter "+n+" has wrong cardinality","XTTE0590");return t.map(function(t){return i(r(t),!0)})}return i(r(t))}function L(t){this.value=t}function q(t,e){switch(typeof t){case"undefined":return[];case"string":return Atomic.string.fromString(t);case"number":return Atomic["double"].fromNumber(t);case"boolean":return Atomic["boolean"].fromBoolean(t);case"function":return new L(t);case"object":if(DomUtils.isNode(t))return t;if(t instanceof Date)return Atomic.dateTime.fromString(t.toISOString());if(Array.isArray(t)){var r=[];return e?(t.forEach(function(t){var e=q(t,!0),n=Array.isArray(e)?e:[e];r.push(n)}),new Expr.XdmArray(r)):(t.forEach(function(t){r.push(q(t,!0))}),r)}return null===t?[]:new L(t);default:return t}}function G(t){if(Atomic.string.matches(t)||Atomic.anyURI.matches(t)||Atomic.duration.matches(t)||Atomic.hexBinary.matches(t)||Atomic.base64Binary.matches(t)||Atomic.untypedAtomic.matches(t))return t.toString();if(Atomic.numeric.matches(t))return t.toNumber();if(Atomic["boolean"].matches(t))return t.toBoolean();if(Atomic.dateTime.matches(t)||Atomic.date.matches(t)||Atomic.dateTimeStamp.matches(t))return t.toString();if(Atomic.time.matches(t)||Atomic.gYearMonth.matches(t)||Atomic.gYear.matches(t)||Atomic.gMonthDay.matches(t)||Atomic.gMonth.matches(t)||Atomic.gDay.matches(t))return t.toString();if(Atomic.QName.matches(t))return t.toEQName();var e;if(j.isNode(t))return t;if(t instanceof Expr.XdmArray)return e=[],0===t.value.length||t.value.forEach(function(t){e.push(G(t))}),e;if(Array.isArray(t))return e=[],0===t.length?null:1==t.length?G(t[0]):(t.forEach(function(t){e.push(G(t))}),e);if(t instanceof HashTrie){var r={};return t.forAllPairs(function(t){r[t.k.toString()]=G(t.v)}),r}if(t instanceof L)return t.value;throw XError("convertToJS() not implemented for "+showValue(t)+", "+typeof t+", "+t.constructor.name,"SXJS0004")}function Q(t){return t.mapOneToMany(function(t){return J(t)?Iter.Join(t.value.map(function(t){return Q(Iter.ForArray(t))})):Iter.Singleton(t)})}function V(t,e){function r(t){if(J(t)){var o="[";return t.value.forEach(function(t){"["!=o&&(o+=","),o+=n(t)}),o+"]"}if(z(t)){var i="{";return t.forAllPairs(function(t){"{"!=i&&(i+=","),i+='"'+t.k+'":',i+=n(t.v)}),i+"}"}return j.isNode(t)?j.xmlToString(t,e):Atomic.string.matches(t)||Atomic.untypedAtomic.matches(t)?'"'+t.toString().replace(/&ZZZamp;/g,"&").replace(/""/g,'"').replace(/''/g,"'")+'"':Atomic.integer.matches(t)||Atomic.numeric.matches(t)||Atomic["boolean"].matches(t)?t.toString():t instanceof Iter.Singleton?r(t.next()):showValue(t)}function n(t){if(void 0===t)return"(undefined)";if(1==t.length)return r(t[0]);var e="(";return t.forEach(function(t){"("!=e&&(e+=","),e+=r(t)}),e+")"}return n(t.expand())}var j=DomUtils,K={analyzeString:function(t,e){var n=Y(N(t,"select"),e).next();if(null===n)return Iter.Empty;n=n.toString();var o=Y(N(t,"regex"),e).next().toString(),i=Y(N(t,"flags"),e).next().toString(),a=N(t,"matching"),u=N(t,"nonMatching"),s=r(n,o,i,!0,!1),c=e.newContext(!1),l=s.map(function(t){return t.string});return c.focus=Iter.Tracker(Iter.ForArray(l)),c.focus.mapOneToMany(function(t){var e=s[c.focus.position-1];return e.matching?(c.focus.regexGroups=e.groups,a?Y(a,c):Iter.Empty):(c.focus.regexGroups=[],u?Y(u,c):Iter.Empty)})},and:function(t,e){return Iter.oneBoolean(a(E(t,e))&&a(S(t,e)))},among:function(t,e){var r=E(t,e).next(),n=S(t,e);return n.filter(function(t){return t===r})},applyImports:function(t,e){var r=e.currentMode;if(null===r)throw XError("applyImports: no current mode","XTDE0560",t);if(!e.focus.current)throw XError("applyImports: no context item","XTDE0560",t);var n=e.newContext(!0);return c(t,e,n),n.focus=Iter.Tracker(Iter.Singleton(e.focus.current)),n.focus.next(),r.applyImports(n)},applyT:function(t,e){var r;if(y(t,"c"))r=e.currentMode;else{var n=j.getAttributeAsEQName(t,"mode");null===n&&(n=""),r=e.fixed.modes[n],null===r&&I("Mode "+n+" not found")}var o=e.newContext(!0);return c(t,e,o),o.focus=Iter.Tracker(E(t,e)),r.applyTemplates(o)},arith:function(t,e){var r=Calculate[t.getAttribute("calc")];return r||v("arithmetic ("+t.getAttribute("calc")+")",t),Iter.Singleton(m(t,e,r))},arith10:function(t,e){function r(t){var e=t.next();return null===e?Atomic["double"].fromNumber(NaN):Atomic["double"].cast(e)}var n=Calculate[t.getAttribute("calc")];return Iter.Singleton(n(r(E(t,e)),r(S(t,e))))},array:function(t,e){var r=j.getChildElements(t).map(function(t){return Y(t,e).expand()});return Iter.Singleton(new B(r))},arrayBlock:function(t,e){var r=j.getChildElements(t).map(function(t){return Y(t,e).expand()});return Iter.Singleton(new B(r))},atomic:function(t){var e=t.getAttribute("val"),r=t.getAttribute("type").substring(3);return Atomic[r]||I("Unknown type: "+r,t),Iter.Singleton(Atomic[r].fromString(e))},atomSing:function(t,r){var n=E(t,r).mapOneToMany(o);if(!t.hasAttribute("card")&&(n=Iter.LookAhead(n),null===n.peek())){var i=e(t.getAttribute("diag"));throw XError("The "+i.required+" is empty",i.code,t)}return n},att:function(t,e){var r=E(t,e),n=k(r),o=j.getAttributeAsQName(t,"name");if(null===o)throw XError("Invalid attribute name "+t.getAttribute("name"),"XTDE0850",t);var i=e.createAttributeFromQName(o);i.value=n;var a=t.hasAttribute("flags")?t.getAttribute("flags"):"";return Iter.Singleton(l(i,a))},attVal:function(t,e){var r=j.getAttributeAsQName(t,"name");if(!e.focus.current)throw XError("attVal: no context item","XPDY0002",t);var n=e.focus.current;if(!j.isNode(n))throw XError("Context item for 'attVal' must be a node","XPTY0020",t);if(n.nodeType!=j.ELEMENT_NODE)return Iter.Empty;var o;return o=""===r.uri?n.hasAttribute(r.local)?n.getAttribute(r.local):null:"http://www.w3.org/XML/1998/namespace"===r.uri?n.hasAttribute("xml:"+r.local)?n.getAttribute("xml:"+r.local):null:n.hasAttributeNS(r.uri,r.local)?n.getAttributeNS(r.uri,r.local):null,null===o?Iter.Empty:Iter.Singleton(Atomic.untypedAtomic.fromString(o))},axis:function(t,e){var r=new Function("item",t.getAttribute("jsTest")),n=t.getAttribute("name");if(!e.focus.current)throw XError("Context item is absent for "+n+" axis","XPDY0002",t);if(!j.isNode(e.focus.current))throw XError("Context item for "+n+" axis is not a node","XPTY0020",t);return Axis[n](e.focus.current).filter(r)},"break":function(e,r){return Iter.Join([Iter.Empty,Iter.Singleton(new t)])},callT:function(t,e){var r=j.getAttributeAsEQName(t,"name"),n=e.fixed.namedTemplates[r];null===n&&I("Template "+r+" not found",t);var o=e.newContext(!0);return c(t,e,o),E(n,o)},cast:function(t,e){var r=E(t,e),n=r.next(),o=t.getAttribute("as");if(null===n){if("?"==o.slice(-1)||"1"==t.getAttribute("emptiable"))return Iter.Empty;throw XError("Empty sequence casting to "+o,"XPTY0004",t)}if(null!==r.next())throw XError("Multiple sequence casting to "+o,"XPTY0004",t);try{o=o.replace(/(\?|\*)$/,"");var i=p(o),a="QName"==i.name?A(t,!0):null;return Iter.Singleton(i.cast(n,a))}catch(u){if(null!==u.code)throw u;throw XError("Failed to cast to type "+o,"XPTY0004",t)}},castable:function(t,e){var r,n=E(t,e).mapOneToMany(o).expand();if(0===n.length)r="1"==t.getAttribute("emptiable");else if(n.length>1)r=!1;else try{var i=p(t.getAttribute("as")),a="QName"==i.name?A(t,!0):null;i.cast(n[0],a),r=!0}catch(u){r=!1}return Iter.oneBoolean(r)},cfn:function(t,e){var r,n=t.getAttribute("name");return"_format-number_1"==n?(r=[E(t,e),Iter.oneString(t.getAttribute("pic"))],t.hasAttribute("format")&&r.push(Iter.oneString(t.getAttribute("format"))),CoreFn["format-number"](r,e,t)):"_translate_1"==n?(r=[E(t,e),Iter.oneString(t.getAttribute("a1")),Iter.oneString(t.getAttribute("a2"))],CoreFn.translate(r,e)):void I("Unimplemented: cfn "+n,t)},check:function(t,r){function n(r){var n=e(t.getAttribute("diag"));throw XError("Required cardinality of "+n.required+" is "+i[o]+"; supplied value "+r,n.code,t)}var o=t.getAttribute("card"),i={"*":"zero or more","+":"one or more","?":"zero or one","°":"zero",1:"exactly one"},a=E(t,r);if("*"==o)return a;var u=Iter.LookAhead(a),s=u.peek();if(null===s){if("?"==o||"°"==o)return Iter.Empty;n("is empty")}else"°"==o&&n("is not empty (first item "+showValue(s)+")");if("+"==o)return u;u.next();var c=u.next();if(null!==c){var l=u.count()+2;n("contains "+l+" items ("+showValue(s)+", "+showValue(c)+(l>2?",... )":")"))}return Iter.Singleton(s)},choose:function(t,e){var r,n=j.getChildElements(t);for(r=0;r<n.length;r+=2)if(a(Y(n[r],e)))return Y(n[r+1],e);return Iter.Empty},comment:function(t,e){var r=E(t,e),n=e.resultDocument.createComment(k(r)),o=t.hasAttribute("flags")?t.getAttribute("flags"):"";return Iter.Singleton(l(n,o))},compareToInt:function(t,e){var r=E(t,e).next();if(null===r)return Iter.Empty;var n=Atomic.integer.fromString(t.getAttribute("val"));return Iter.oneBoolean(Compare.testComparison(t.getAttribute("op"),r.compareTo(n)))},compAtt:function(t,e){var r=t.hasAttribute("flags")?t.getAttribute("flags"):"";return f(t,e,function(n){var o=e.createAttributeFromQName(n);return o=l(o,r),o.value=k(Y(N(t,"select"),e)),o})},compElem:function(t,e){var r=t.hasAttribute("flags")?t.getAttribute("flags"):"";return f(t,e,function(n,o){var i=e.createElement(n,o);if(""!==n){var a=o.split(":");j.declareNS(i,1==a.length?"":a[0],n)}return R(i,Y(N(t,"content"),e),e),l(i,r)})},condCont:function(t){v("xsl:where-populated",t)},condSeq:function(t){v("xsl:on-empty/on-non-empty",t)},conditionalSort:function(t,e){return a(E(t,e))?S(t,e):E(j.getChildElements(t)[1],e)},convert:function(t,e){var r=p(t.getAttribute("to"));return E(t,e).mapOneToOne(y(t,"p")?function(t){return P(t,r.name)}:r.cast)},copy:function(t,e){if(!e.focus.current)throw XError("copy: no context item","XTTE0945",t);var r=e.focus.current,n=t.getAttribute("flags");return j.shallowCopy(r,e,n,function(e){return E(t,e)})},copyOf:function(t,e){var r=t.getAttribute("flags");return E(t,e).mapOneToOne(function(t){return j.copyItem(t,e,r)})},currentGroup:function(t,e){if(e&&e.currentGroup)return Iter.ForArray(e.currentGroup);throw XError("There is no current group","XTDE1061",t)},currentGroupingKey:function(t,e){if(e&&e.currentGroupingKey)return Iter.ForArray(e.currentGroupingKey);throw XError("There is no current grouping key","XTDE1071",t)},cvUntyped:function(t,e){var r=E(t,e),n=t.getAttribute("to"),o=p(n).cast,i="xs:string"==n;return r.mapOneToOne(function(t){return Atomic.untypedAtomic.matches(t)||i&&Atomic.anyURI.matches(t)?o(t):t})},data:function(t,e){return E(t,e).mapOneToMany(o)},dbl:function(t){var e=t.getAttribute("val");return Iter.Singleton(Atomic["double"].fromString(e))},dec:function(t){var e=t.getAttribute("val");return Iter.oneDecimal(Big(e))},doc:function(t,e){var r=d(j.getChildElements(t)[0],e),n=t.hasAttribute("flags")?t.getAttribute("flags"):"";return Iter.Singleton(l(r,n))},docOrder:function(t,e){return j.inDocumentOrder(E(t,e))},dot:function(t,e){if(!e.focus.current)throw XError("dot: no context item","XPDY0002",t);return Iter.Singleton(e.focus.current)},elem:function(t,e){var r=!1,n=t.getAttribute("name"),o=n.split(":"),i=null;if(t.hasAttribute("nsuri")&&(i=t.getAttribute("nsuri"),r=!0),2==o.length&&null===i&&(i=g(t,o[0]),r=!0),null===i&&(i=""),"http://www.w3.org/2000/xmlns/"==i)throw XError("Disallowed namespace "+i,"XTDE0835",t);var a=e.createElement(i,n);if(t.hasAttribute("namespaces")){var u,s=t.getAttribute("namespaces").toString().split(" ");for(u=0;u<s.length;u++){var c=s[u].split("="),f=2==c.length?c[1]:g(t,c[0]);"#"!=c[0]&&(j.declareNS(a,c[0],f),c[0]==o[0]&&f==i&&(r=!0))}}r&&j.declareNS(a,2==o.length?o[0]:"",i),R(a,E(t,e),e);var m=t.hasAttribute("flags")?t.getAttribute("flags"):"";return Iter.Singleton(l(a,m))},empty:function(){return Iter.Empty},emptyTextNodeRemover:function(t,e){return E(t,e).filter(function(t){return!(t instanceof Node&&t.nodeType==j.TEXT_NODE&&""===t.textContent)})},error:function(t){throw XError(t.getAttribute("message"),t.getAttribute("code"),t)},evaluate:function(t,e){var r,n=Y(N(t,"xpath"),e).next().toString(),o=Y(N(t,"cxt"),e),i=Y(N(t,"wp"),e),a={},u=N(t,"nsCxt");if(u){var s=Y(u,e).next(),c=s.attributes;for(r=0;r<c.length;++r){var l=c[r];"xmlns"==l.prefix&&(a[l.localName]=l.value)}}else{var f=j.getInheritedAttribute(t,"ns");if(null!==f){var m=f.split(" ");for(r=0;r<m.length;r++){var p=m[r].split("=");a[p[0]]=p[1]}}}var h={params:i,namespaces:a},g=N(t,"baseUri");g&&(h.staticBaseURI=Y(g,e).next().toString());var d=SaxonJS.XPath.evaluateXDM(n,o,i,e,a,h);return d},every:function(t,e){var r=parseInt(t.getAttribute("slot"),10),n=E(t,e),o=O(t);return Iter.oneBoolean(!n.some(function(t){return e.localVars[r]=[t],!a(o(e))}))},except:function(t,e){var r=E(t,e),n=S(t,e);return Iter.Difference(r,n,j.compareDocumentOrder)},"false":function(){return Iter.oneBoolean(!1)},filter:function(t,e){var r=E(t,e),n=O(t);if(y(t,"i")){var o=n(e).expand();if(1==o.length&&Atomic.numeric.matches(o[0])){var i=o[0].toNumber();if(r instanceof Iter.ForArray)return Iter.Singleton(r.expand()[i-1]);var u=Iter.Tracker(r);return u.filter(function(){return u.position==i})}return a(Iter.ForArray(o))?r:Iter.Empty}var s=e.newContext(!1);s.focus=Iter.Tracker(r);var c;return c=y(t,"p")?function(){var t=n(s).expand();return 1==t.length&&Atomic.numeric.matches(t[0])?s.focus.position==t[0].toNumber():a(Iter.ForArray(t))}:function(){return a(n(s))},s.focus.filter(c)},first:function(t,e){return Iter.Singleton(E(t,e).next())},fnRef:function(t){throw XError("Saxon-JS does not support higher-order functions","XTSE3540",t)},follows:function(t,e){return Iter.Singleton(m(t,e,function(t,e){return Atomic["boolean"].fromBoolean(j.compareDocumentOrder(t,e)>0)}))},"for":function(t,e){var r=parseInt(t.getAttribute("slot"),10),n=O(t);return E(t,e).mapOneToMany(function(t){return e.localVars[r]=[t],n(e)})},forEach:function(t,e){var r=e.newContext(!1);r.focus=Iter.Tracker(E(t,e)),r.currentTemplate=null;var n=O(t),o=function(){return n(r)};return r.focus.mapOneToMany(o)},forEachGroup:function(t,e){return Compare.grouping(t,e)},fn:function(t,e){var r=CoreFn[t.getAttribute("name")];r||v(t.getAttribute("name")+"()",t);var n=j.getChildElements(t).map(function(t){return Y(t,e)});return r(n,e,t)},functionCall:function(t){v(t.getAttribute("name")+"()",t)},gc:Compare.generalComparison,gc10:function(t,e){function r(t){return 1==t.length&&Atomic["boolean"].matches(t[0])}function n(t){return[Atomic["boolean"].fromBoolean(a(Iter.ForArray(t)))]}var i=E(t,e).expand(),u=S(t,e).expand();r(i)?u=n(u):r(u)?i=n(i):(i=Iter.ForArray(i).mapOneToMany(o).expand(),u=Iter.ForArray(u).mapOneToMany(o).expand());var s=Compare.allocateCodedComparer(t.getAttribute("comp"));return Compare.gc(Iter.ForArray(i),u,t.getAttribute("op"),s)},gcEE:Compare.generalComparison,gVarRef:function(t,e){var r=t.getAttribute("name"),n=e.fixed.globalVars[r];
if(n.decl||I("Missing global $"+r,t),null===n.value){if("globalParam"==n.decl.tagName){var o=e.fixed.options.stylesheetParams[r];if(void 0===o&&/^Q\{\}/.test(r)&&(o=e.fixed.options.stylesheetParams[Atomic.QName.fromEQName(r).local]),void 0!==o){null===o&&(o=[]);var i=new Function("val",n.decl.getAttribute("jsAcceptor")),a=new Function("n",n.decl.getAttribute("jsCardCheck")+" return c(n);"),u=$(o,a,i,r);n.value=Array.isArray(u)?u:[u]}else{if(y(n.decl,"r"))throw XError("Parameter "+r+" is required","XTDE0050",n);if(y(n.decl,"i"))throw XError("Parameter "+r+" cannot be empty","XTDE0700",n);0===j.getChildElements(n.decl).length&&(n.value=[])}}if(null===n.value){var s=e.newContext(!0);s.tempOutputState="variable",s.currentMode=e.fixed.modes[""],s.currentTemplate=null,s.focus=Iter.Tracker(Iter.Singleton(e.fixed.globalContextItem)),s.focus.next();try{n.value=E(n.decl,s).expand()}catch(c){throw c instanceof XError&&"http://saxon.sf.net/generated-variable"!=Atomic.QName.fromEQName(r).uri&&(c.isGlobal=!0),c}}}return Iter.ForArray(n.value)},homCheck:function(t,e){var r=new Iter.LookAhead(E(t,e)),n=r.peek();if(null===n)return Iter.Empty;var o=j.isNode(n),i=r.filter(function(e){if(j.isNode(e)!=o)throw XError("Cannot mix nodes and atomic values in the result of a path expression","XPTY0018",t);return!0});return o?j.inDocumentOrder(i):i},ifCall:function(t,e){var r,n,o,i=j.getAttributeAsQName(t,"name",!1);if("schedule-action"==i.local){var a=3!=j.getChildElements(t).length;r=E(t,e).next().toNumber();var u=a?null:S(t,e).next();n=e.newContext(!1),n.clearGrouping(),e.focus&&(n.focus=new Iter.Tracker(new Iter.Singleton(e.focus.current)),n.focus.next());var s=j.getChildElements(t)[a?1:2],l=j.getAttributeAsEQName(s,"name"),f=e.fixed.namedTemplates[l];if(null===f&&I("Template "+l+" not found",s),c(s,e,n),o=function(){E(f,n).expand()},null!==u){var m=SaxonJS.getPlatform().resolveUri(u.toString(),Expr.staticBaseUri(t,e));e.fixed.documentPool[m]?o():SaxonJS.getPlatform().asyncGetXml(m,function(t,r){e.fixed.documentPool[t]=r,o()})}else 0!==r&&setTimeout(o,r);return Iter.Empty}var p=j.getChildElements(t).map(function(t,r){return Y(t,e)});return ExtraFn(i.uri,i.local,p,e,t)},indexedFilter:function(t,e){var r=e.newContext(!1);r.focus=Iter.Tracker(E(t,e));var n=O(t),o=function(){return a(n(r))};return r.focus.filter(o)},indexedLookup:function(t,e){return Compare.generalComparison(t,e,"=")},inlineFn:function(t){v("inline function",t)},instance:function(t,e){var r={"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1},"°":{min:0,max:0},1:{min:1,max:1}},n=E(t,e),o=t.getAttribute("of");if("empty-sequence()"==o)return Iter.oneBoolean(null===n.next());var i=o.charAt(o.length-1),a="*+?°".indexOf(i)>=0,u=r[a?i:"1"];a&&(o=o.substring(0,o.length-1));for(var s,c=new Function("item",t.getAttribute("jsTest")),l=0;null!==(s=n.next());)if(++l>u.max||!c(s))return Iter.oneBoolean(!1);return Iter.oneBoolean(l>=u.min)},"int":function(t){var e=t.getAttribute("val");return Iter.Singleton(Atomic.integer.fromString(e))},intersect:function(t,e){var r=E(t,e),n=S(t,e);return Iter.Intersect(r,n,j.compareDocumentOrder)},intRangeTest:function(t,e){var r=E(t,e),n=j.getChildElements(t),o=Y(n[1],e).next().toNumber(),i=Y(n[2],e).next().toNumber(),a=r.some(function(t){var e=t.value;return e>=o&&i>=e});return Iter.oneBoolean(a)},is:function(t,e){return Iter.Singleton(m(t,e,function(t,e){return Atomic["boolean"].fromBoolean(j.isSameNode(t,e))}))},isLast:function(t,e){return Iter.oneBoolean(e.focus.position==e.focus.last()==("1"==t.getAttribute("test")))},iterate:function(e,r){var n=j.getChildElements(j.getChildElements(e)[1]);n.forEach(function(t){Y(t,r)});var o=r.newContext(!1);o.focus=Iter.Tracker(E(e,r)),o.currentTemplate=null;for(var i,a=N(e,"action"),u=N(e,"on-completion"),s=[],c=!1;null!==(i=o.focus.next());){var l=o.newContext(!1);l.focus.current=i;var f=Expr.evaluate(a,l);if(Array.prototype.push.apply(s,f.expand()),s[s.length-1]instanceof t){s.pop(),c=!0;break}o.localVars=l.localVars}return c||null===u||Array.prototype.push.apply(s,Expr.evaluate(u,o).expand()),Iter.ForArray(s)},lastOf:function(t,e){var r=Iter.LookAhead(E(t,e));return r.filter(function(){return null===r.peek()})},let:function(t,e){var r=e.tempOutputState;e.tempOutputState="variable";var n=E(t,e).expand();e.tempOutputState=r;var o=parseInt(t.getAttribute("slot"),10);return e.localVars[o]=n,S(t,e)},literal:function(t,e){var r=j.getChildElements(t).map(function(t){return Y(t,e)});return Iter.Join(r)},map:function(t,e){var r=new HashTrie,n=null;return j.getChildElements(t).forEach(function(t){null===n?n=Y(t,e).next():(r.inSituPut(n,Y(t,e).expand()),n=null)}),Iter.Singleton(r)},merge:function(t){v("xsl:merge",t)},mergeAdj:function(t,e){function r(t){return t instanceof Node&&t.nodeType==j.TEXT_NODE}for(var n,o=[],i=E(t,e),a=!1;null!==(n=i.next());){var u=r(n);u&&""===n.nodeValue||(a&&u?o.push(e.resultDocument.createTextNode(o.pop().nodeValue+n.nodeValue)):(a=u,o.push(n)))}return Iter.ForArray(o)},message:function(t,e){var r="",n=e.tempOutputState;e.tempOutputState="variable",E(t,e).mapOneToMany(o).forEachItem(function(t){r+=" "+t.toString()});var i=Y(N(t,"terminate"),e).next(),a=Y(N(t,"error"),e).next();if("yes"==i||"true"==i||"1"==i)throw XError("Terminated with "+r,a.toString(),t);return e.fixed.options.deliverMessage&&e.fixed.options.deliverMessage(r),e.tempOutputState=n,Iter.Empty},minus:function(t,e){return E(t,e).mapOneToOne(function(t){return t.negate()})},namespace:function(t,e){var r=E(t,e).next().toString(),n=S(t,e).next().toString();if(""!==r&&!Regex.isNCName(r))throw XError("Prefix "+r+" is not an NCName","XTDE0920",t);if("xmlns"==r||"http://www.w3.org/2000/xmlns/"==n)throw XError("Disallowed prefix/namespace "+n,"XTDE0835",t);return Iter.Singleton(new NamespaceNode(r,n))},nextIteration:function(t,e){var r=j.getChildElements(t,"withParam"),n=[];r.forEach(function(t){var r=parseInt(t.getAttribute("slot"),10);n[r]=E(t,e).expand()});for(var o in n)e.localVars[o]=n[o];return Iter.Empty},nextMatch:function(t,e){var r=e.currentMode,n=e.currentTemplate;if(!n)throw XError("xsl:next-match: there is no current template","XTDE0560",t);var o=e.newContext(!0);return c(t,e,o),r.nextMatch(o)},nodeNum:function(t,e){return Numberer.nodeNum(t,e)},numSeqFmt:function(t,e){return Numberer.numSeqFmt(t,e)},or:function(t,e){return Iter.oneBoolean(a(E(t,e))||a(S(t,e)))},param:function(t,e){var r=j.getAttributeAsEQName(t,"name"),n=parseInt(t.getAttribute("slot"),10),o=y(t,"t"),i=o?e.tunnelParams:e.localParams,a=i[r];if(!a){var u=N(t,"select");if(!u||y(t,"r"))throw XError("Required parameter $"+r+" not supplied","XTDE0700",t);var s=e.tempOutputState;e.tempOutputState="xsl:param",a=Y(u,e).expand(),e.tempOutputState=s}if(!("object"==typeof a&&"length"in a))throw XError("Param value of $"+r+" is not an array","SXJS0004",t);e.localVars[n]=a;var c=N(t,"conversion");return null!==c&&(e.localVars[n]=Y(c,e).expand()),Iter.Empty},precedes:function(t,e){return Iter.Singleton(m(t,e,function(t,e){return Atomic["boolean"].fromBoolean(j.compareDocumentOrder(t,e)<0)}))},procInst:function(t,e){var r=E(t,e).next().value,n=S(t,e),o=e.resultDocument.createProcessingInstruction(r,k(n));return Iter.Singleton(o)},qName:function(t){var e=t.getAttribute("pre"),r=t.getAttribute("uri"),n=t.getAttribute("loc");return Iter.Singleton(Atomic.QName.fromParts(e,r,n))},range:function(t){var e=Atomic.integer.fromString(t.getAttribute("from")),r=Atomic.integer.fromString(t.getAttribute("to"));return s(e,r)},resultDoc:function(t,e){if(e.tempOutputState)throw XError("Cannot call xsl:result-document while evaluating "+e.tempOutputState,"XTDE1480",t);var r=N(t,"href"),n=null===r?"":Y(r,e).next().toString(),o=!1;t.getAttribute("local").split(/\r?\n/).forEach(function(t){/^method=/.test(t)&&(o=/interactiveXSLT\}replace-content$/.test(t))});var i,a="#"==n.charAt(0)||"?."==n,u=d(N(t,"content"),e,a),s=function(t,e){Axis.child(t).forEachItem(function(t){e.appendChild(t)})};if(""===n)return Iter.Singleton(u);if(a)return(i="?."==n?e.focus.current:window.document.getElementById(n.substring(1)))?(o&&(i.innerHTML=""),s(u,i),Iter.Empty):(print("Result document href="+n+": no such node"),Iter.Empty);if(e.fixed.resultDocUris[n])throw XError("A result document with URI "+n+" has already been created","XTDE1490",t);return e.fixed.resultDocUris[n]=!0,e.fixed.options.deliverResultDocument(n,u),Iter.Empty},root:function(t,e){if(!e.focus.current)throw XError("Focus is absent","XPDY0002",t);var r=e.focus.current;if(!j.isNode(r))throw XError("Context item for '/' must be a node","XPTY0020",t);var n=j.ownerDocument(r);if(n.nodeType!=j.DOCUMENT_NODE&&n.nodeType!=j.DOCUMENT_FRAGMENT_NODE)throw XError("Root node for '/' must be a document node","XPDY0050",t);return Iter.Singleton(j.ownerDocument(r))},sequence:function(t,e){var r=j.getChildElements(t),n=r.map(function(t){return Y(t,e)});return Iter.Join(n)},slash:function(t,e){var r=e.newContext(!1);r.focus=Iter.Tracker(E(t,e));var n=O(t),o=function(){return n(r)};return r.focus.mapOneToMany(o)},some:function(t,e){var r=parseInt(t.getAttribute("slot"),10),n=E(t,e),o=O(t);return Iter.oneBoolean(n.some(function(t){return e.localVars[r]=[t],a(o(e))}))},sort:Compare.sortSequence,str:function(t){var e=t.getAttribute("val");return Iter.oneString(e)},subscript:function(t,e){var r=E(t,e),n=S(t,e).next().value;if(r instanceof Iter.ForArray){var o=r.expand()[n-1];return void 0===o&&(o=null),Iter.Singleton(o)}var i=r.mapOneToOne(function(t,e){return e+1==n?t:null}).next();return Iter.Singleton(i)},supplied:function(t,e){var r=parseInt(t.getAttribute("slot"),10),n=e.localVars[r];return Iter.ForArray(n)},"switch":function(t,e){var r=e.fixed.options.saxonVersion;r&&"9.7.0"==r.substring(0,5)&&parseInt(r.split(".")[3],10)<15&&x("9.7.0.15",t);var n=E(t,e).next();if(null===n)return Iter.oneBoolean(!1);n=Atomic.base64Binary.cast(n);for(var o=j.getChildElements(t,"case"),i=0;i<o.length;i++){var a=E(o[i],e).next();if(a.equals(n))return S(o[i],e)}return Y(N(t,"default"),e)},tail:function(t,e){var r=parseInt(t.getAttribute("start"),10)-1;return E(t,e).filter(function(t){return r--<=0})},tailCallLoop:function(t,e){return E(t,e)},to:function(t,e){var r=E(t,e).next(),n=S(t,e).next();return null===r||null===n||r.compareTo(n)>0?Iter.Empty:s(r,n)},treat:function(t,r){var n=new Function("item",t.getAttribute("jsTest"));return E(t,r).mapOneToOne(function(r){if(n(r))return r;var o=e(t.getAttribute("diag"));throw XError("Required item type of "+o.required+" is "+t.getAttribute("as")+"; supplied value is "+showValue(r),o.code,t)})},"true":function(){return Iter.oneBoolean(!0)},"try":function(t,e){var r=!0;if(!r)return E(t,e);try{return Iter.ForArray(E(t,e).expand())}catch(n){if(n instanceof XError&&!n.isGlobal){e.currentError=n,null===n.compiledLineNr&&n.setExpr(t);for(var o,i=Atomic.QName.fromParts("","http://www.w3.org/2005/xqt-errors",n.code),a=Iter.ForArray(j.getChildElements(t,"catch"));null!==(o=a.next());){var u=new Function("q","return "+o.getAttribute("test")+";");if(u(i))return E(o,e)}throw n}throw n instanceof XError?n:(Error.dumpStack&&Error.dumpStack(),n)}},ufCall:function(t,e){var r=j.getAttributeAsEQName(t,"name"),n=j.getChildElements(t),o=e.fixed.userFunctions[r+"#"+n.length];null===o&&I("Function "+r+"#"+n.length+" not found");var i=e.newContext(!0);return i.clearGrouping(),i.tempOutputState="function",i.currentMode=e.fixed.modes[""],i.currentTemplate=null,i.localVars=n.map(function(t){return Y(t,e).expand()}),i.localParams={},Y(o,i)},union:function(t,e){var r=E(t,e),n=S(t,e);return Iter.Union(r,n,j.compareDocumentOrder)},useAS:function(t,e){var r=j.getAttributeAsEQName(t,"name"),n=e.fixed.attributeSets[r];null===n&&I("Attribute set "+r+" not found",t);var o=e.newContext(!0);return o.tempOutputState="attribute set",E(n,o)},vc:function(t,e){function r(t){return null===t?null:Atomic.untypedAtomic.matches(t)?Atomic.string.cast(t):t}var n=t.getAttribute("op"),o=t.getAttribute("onEmpty"),i=E(t,e),a=S(t,e),u=r(i.next()),s=r(a.next());if(null===u||null===s)return o?Iter.oneBoolean("1"==o):Iter.Empty;if(null!==i.next()||null!==a.next())throw XError("Value comparison only applicable to single values","XPTY0004",t);if(Atomic.isSubtype(u.type,"numeric")&&isNaN(u.value)||Atomic.isSubtype(s.type,"numeric")&&isNaN(s.value))return Iter.oneBoolean("ne"==n);var c=Compare.allocateCodedComparer(t.getAttribute("comp"));return"="==n||"eq"==n||"!="==n||"ne"==n?Iter.oneBoolean(Compare.testEquality(n,c.equals(u,s))):Iter.oneBoolean(Compare.testComparison(n,c.compare(u,s)))},valueOf:function(t,e){var r=E(t,e),n=e.resultDocument.createTextNode(k(r)),o=t.hasAttribute("flags")?t.getAttribute("flags"):"";return Iter.Singleton(l(n,o))},varRef:function(t,e){var r=parseInt(t.getAttribute("slot"),10),n=e.localVars[r];return Iter.ForArray(n)},xslNumber:function(t,e){return Numberer.xslNumber(t,e)},styleValue:function(t,e){var r=t.getAttribute("name");return Iter.oneString(e.focus.current.style[r])}},Y=D;return B.prototype={value:[],get:function(t){if("number"!=typeof t)throw XError("Array subscript is not numeric","XPTY0004");if(1>t||t>=this.value.length)throw XError("Array index ("+t+") out of bounds (1 to "+this.value.length+")","FOAY0001");return this.value[t-1]}},L.prototype={value:null,containsKey:function(t){return null!==this.value[t]},get:function(t){var e=q(this.value[t]);return Array.isArray(e)?e:[e]},inSituPut:function(t,e){throw XError("inSituPut() not allowed for JSValue","SXJS0005")},put:function(t,e){throw XError("put() not allowed for JSValue","SXJS0005")},remove:function(t){throw XError("remove() not allowed for JSValue","SXJS0005")},keys:function(){var t=[];for(var e in this.value)this.value.hasOwnProperty(e)&&t.push(Atomic.string.fromString(e));return t},forAllPairs:function(t){var e=this;e.keys().forEach(function(r){t({k:r,v:e.get(r)})})},conforms:function(t,e,r){var n=this;return Iter.ForArray(n.keys()).every(function(o){var i=n.get(o);return t(o)&&r(i.length)&&Iter.ForArray(i).every(e)})}},{analyze:r,argRole:N,atomize:o,codepointsToString:M,convertFromJS:q,convertToJS:G,ebv:a,evalChild1:E,evalChild2:S,evaluate:Y,evaluateIfPresent:U,flatten:Q,getSourceLoc:w,hasFlag:y,internalError:I,isArray:J,isAstral:_,isMap:z,JSValue:L,makeComplexContent:R,markLocal:l,notImplemented:v,promote:P,roleDiagnostic:e,serialize:V,staticBaseUri:h,stringToCodepoints:F,stylesheetResolver:A,untypedToDouble:u,wsCollapse:n,XdmArray:B}}(),Mode=function(){"use strict";function t(t,e){return t.prec==e.prec?t.prio==e.prio?t.seq-e.seq:t.prio-e.prio:t.prec-e.prec}function e(t){return JSON.stringify({prec:t.prec,prio:t.prio,seq:t.seq,line:t.line,match:t.pattern})}function r(t){return makePattern(Expr.argRole(t,"match"))}function n(e){this._expr=e,this.onNoMatch=e.getAttribute("onNo"),this._rules=DomUtils.getChildElements(e).map(function(t){return{rule:t,prec:parseInt(t.getAttribute("prec"),10),prio:parseFloat(t.getAttribute("prio")),seq:parseInt(t.getAttribute("seq"),10),minImp:parseInt(t.getAttribute("minImp"),10),pattern:r(t),action:Expr.argRole(t,"action")}}).sort(t).reverse()}var o={TC:function(t,e,r){if(!DomUtils.isNode(t))return Iter.Singleton(t);switch(t.nodeType){case DomUtils.DOCUMENT_NODE:case DomUtils.DOCUMENT_FRAGMENT_NODE:case DomUtils.ELEMENT_NODE:var n=r.newContext(!1);return n.focus=Iter.Tracker(Axis.child(t)),e.applyTemplates(n);case DomUtils.TEXT_NODE:case DomUtils.CDATA_SECTION:return Iter.Singleton(DomUtils.copyItem(t,r));case DomUtils.ATTRIBUTE_NODE:return Iter.Singleton(r.resultDocument.createTextNode(t.value));default:return Iter.Empty}},SC:function(t,e,r){function n(r){var n=r.newContext(!1),o=[];return o[0]=Iter.Tracker(Axis.attribute(t)),o[1]=Iter.Tracker(Axis.child(t)),n.focus=Iter.Join(o),e.applyTemplates(n)}return DomUtils.shallowCopy(t,r,"c",n)},DC:function(t,e,r){return Iter.Singleton(DomUtils.copyItem(t,r,"c"))},DS:function(t,e,r){return Iter.Empty},SS:function(t,e,r){if(!DomUtils.isNode(t))return Iter.Singleton(t);switch(t.nodeType){case DomUtils.DOCUMENT_NODE:case DomUtils.DOCUMENT_FRAGMENT_NODE:case DomUtils.ELEMENT_NODE:var n=r.newContext(!1),o=[];return o[0]=Iter.Tracker(Axis.attribute(t)),o[1]=Iter.Tracker(Axis.child(t)),n.focus=Iter.Join(o),e.applyTemplates(n);default:return Iter.Empty}},bubble:function(t,e,r){if(!DomUtils.isNode(t))return Iter.Singleton(t);switch(t.nodeType){case DomUtils.ELEMENT_NODE:var n=r.newContext(!1);return n.focus=Iter.Tracker(Axis.parent(t)),e.applyTemplates(n);default:return Iter.Empty}}};return n.prototype={_expr:null,_rules:null,onNoMatch:"TC",applyTemplates:function(t){var e=this;return t.focus.mapOneToMany(function(r){return e._processItem(r,t)})},applyImports:function(t){var e=t.currentTemplate;if(!e)throw XError("No current template rule","XTDE0560");return this._processItem(t.focus.current,t,function(t){return t.prec>=e.minImp&&t.prec<e.prec})},nextMatch:function(e){var r=e.currentTemplate;if(!r)throw XError("No current template rule","XTDE0560");return this._processItem(e.focus.current,e,function(e){return t(e,r)<0})},findBestRule:function(e,r,n){var o=this._rules,i=null;return o.forEach(function(o){n&&!n(o)||i&&!(t(o,i)>0)||!o.pattern(e,r)||(i=o)}),i},isNonDOMmode:function(t){return null!==this.findBestRule(Expr.JSValue(window),t)},_processItem:function(t,e,r){var n=this.findBestRule(t,e,r);if(null!==n)return e.currentTemplate=n,e.currentMode=this,Expr.evaluate(n.action,e);var i,a=DomUtils.getAttribute(this._expr,"name");i=null!==a&&"Q{http://saxonica.com/ns/interactiveXSLT"==a.split("}")[0]?"bubble":this.onNoMatch.split("+")[0];var u=o[i];if(u)return u(t,this,e);throw XError("No matching template rule for "+showValue(t)+" onNoMatch = "+this.onNoMatch,"XTDE0555")},printRules:function(){var t=this._rules,r="";return t.forEach(function(t){r+=e(t)}),r}},n}(),Iter=function(){"use strict";function t(){}function e(r){return this instanceof e?(t.call(this),void(this._item=r)):new e(r)}function r(e){return this instanceof r?(t.call(this),Array.isArray(e)||Expr.internalError("ForArray expects array"),void(this._array=e)):new r(e)}function n(e,r){return this instanceof n?(t.call(this),this._base=e,this._predicate=r,void(r||Expr.internalError("Filter iterator undefined predicate"))):new n(e,r)}function o(e,r){return this instanceof o?(t.call(this),this._base=e,void(this._mapper=r)):new o(e,r)}function i(e,r){return this instanceof i?(t.call(this),this._base=e,"object"==typeof e&&"next"in e||Expr.internalError("Base not an iterator"),void(this._mapper=r)):new i(e,r)}function a(e,r){return this instanceof a?(t.call(this),this._next=e,void(this._step=r)):new a(e,r)}function u(e){return this instanceof u?(t.call(this),Array.isArray(e)||Expr.internalError("JoinIterator expects array"),void(this._iterators=e)):new u(e)}function s(e,r,n){return this instanceof s?(t.call(this),this._iter1=Iter.LookAhead(e),this._iter2=Iter.LookAhead(r),void(this._compare=n)):new s(e,r,n)}function c(e,r,n){return this instanceof c?(t.call(this),this._iter1=Iter.LookAhead(e),this._iter2=Iter.LookAhead(r),void(this._compare=n)):new c(e,r,n)}function l(e,r,n){return this instanceof l?(t.call(this),this._iter1=Iter.LookAhead(e),this._iter2=Iter.LookAhead(r),void(this._compare=n)):new l(e,r,n)}function f(e){return"peek"in e?e:this instanceof f?(t.call(this),this._base=e,void(this._nextButOne=e.next())):new f(e)}function m(e){return this instanceof m?(t.call(this),void(this._base=e)):new m(e)}t.prototype={filter:function(t){return n(this,t)},mapOneToOne:function(t){return i(this,t)},mapOneToMany:function(t){return new o(this,t)},forEachItem:function(t){for(var e;null!==(e=this.next());)t(e)},some:function(t){for(var e;null!==(e=this.next());)if(t(e))return!0;return!1},every:function(t){for(var e;null!==(e=this.next());)if(!t(e))return!1;return!0},count:function(){var t=0;return this.forEachItem(function(){t++}),t},expand:function(){var t=[];return this.forEachItem(function(e){t.push(e)}),t}},e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype._item=null,e.prototype.next=function(){var t=this._item;return this._item=null,t},e.prototype.peek=function(){return this._item},e.prototype.expand=function(){return null===this._item?[]:[this._item]};var p={next:function(){return null},peek:function(){return null},expand:function(){return[]},count:function(){return 0},filter:function(){return p},mapOneToOne:function(){return p},mapOneToMany:function(){return p},forEachItem:function(){},some:function(){return!1}};return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype._array=null,r.prototype._index=0,r.prototype.next=function(){return this._index<this._array.length?this._array[this._index++]:null},r.prototype.peek=function(){return this._index<this._array.length?this._array[this._index]:null},r.prototype.expand=function(){return this._array},r.prototype.count=function(){return this._array.length},n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype._base=null,n.prototype._predicate=null,n.prototype.next=function(){for(;;){var t=this._base.next();if(!t)return null;if(this._predicate(t))return t}},o.prototype=Object.create(t.prototype),o.prototype.constructor=o,o.prototype._base=null,o.prototype._mapper=null,o.prototype._currentIter=null,o.prototype.next=function(){for(;;){if(null!==this._currentIter){var t=this._currentIter.next();if(t)return t}var e=this._base.next();if(null===e)return null;this._currentIter=this._mapper(e),this._currentIter&&!this._currentIter.next&&Expr.internalError("Result of mapper is not an iterator, mapper = "+this._mapper)}},i.prototype=Object.create(t.prototype),i.prototype.constructor=i,i.prototype._base=null,i.prototype._mapper=null,i.prototype._position=0,i.prototype.next=function(){for(;;){var t=this._base.next();if(!t)return null;var e=this._mapper(t,this._position++);if(e)return e}},a.prototype=Object.create(t.prototype),a.prototype.constructor=a,a.prototype._step=null,a.prototype._next=null,a.prototype.next=function(){var t=this._next;return t?(this._next=this._step(t),t):null},a.prototype.peek=function(){return this._next},u.prototype=Object.create(t.prototype),u.prototype.constructor=u,u.prototype._iterators=[],u.prototype.current=null,u.prototype.next=function(){for(;;){if(0===this._iterators.length)return this.current=null,null;var t=this._iterators[0].next();if(null!==t)return this.current=t,t;this._iterators.shift()}},s.prototype=Object.create(t.prototype),s.prototype.constructor=s,s.prototype._iter1=null,s.prototype._iter2=null,s.prototype._compare=null,s.prototype.current=null,s.prototype.next=function(){var t=this._iter1.peek(),e=this._iter2.peek();if(t&&e){var r=this._compare(t,e);return 0>r?(this.current=this._iter1.next(),this.current):r>0?(this.current=this._iter2.next(),this.current):(this.current=this._iter1.next(),this._iter2.next(),this.current)}return t?(this.current=this._iter1.next(),this.current):e?(this.current=this._iter2.next(),this.current):(this.current=null,null)},c.prototype=Object.create(t.prototype),c.prototype.constructor=c,c.prototype._iter1=null,c.prototype._iter2=null,c.prototype._compare=null,c.prototype.current=null,c.prototype.next=function(){for(var t=this._iter1.peek(),e=this._iter2.peek();t&&e;){var r=this._compare(t,e);if(0>r)this._iter1.next(),t=this._iter1.peek();else{if(!(r>0))return this.current=this._iter1.next(),this._iter2.next(),this.current;this._iter2.next(),e=this._iter2.peek()}}return this.current=null,null},l.prototype=Object.create(t.prototype),l.prototype.constructor=l,l.prototype._iter1=null,l.prototype._iter2=null,l.prototype._compare=null,l.prototype.current=null,l.prototype.next=function(){for(var t=this._iter1.peek(),e=this._iter2.peek();t&&e;){var r=this._compare(t,e);if(0>r)return this.current=this._iter1.next(),this.current;r>0?(this._iter2.next(),e=this._iter2.peek()):(this._iter1.next(),this._iter2.next(),t=this._iter1.peek(),e=this._iter2.peek())}return t&&!e?(this.current=this._iter1.next(),this.current):(this.current=null,null)},f.prototype=Object.create(t.prototype),f.prototype.constructor=f,f.prototype._base=null,f.prototype.next=function(){var t=this._nextButOne;return t&&(this._nextButOne=this._base.next()),t},f.prototype.peek=function(){return this._nextButOne},m.prototype=Object.create(t.prototype),m.prototype.constructor=m,m.prototype._base=null,m.prototype._last=-1,m.prototype.position=0,m.prototype.current=null,m.prototype.next=function(){return this.position++,this.current=this._base.next(),null===this.current&&(this.position=-1),this.current},m.prototype.last=function(){if(this._last<0)if(this._base instanceof r)this._last=this._base.expand().length;else{for(var t,e=[];null!==(t=this._base.next());)e.push(t);this._last=this.position+e.length,this._base=Iter.ForArray(e)}return this._last},{Empty:p,Singleton:e,Join:u,Stepping:a,LookAhead:f,Tracker:m,ForArray:r,Union:s,Intersect:c,Difference:l,AnyIterator:t,trace:function(t,e,r){for(var n,o=[];null!==(n=e.next());){var i;i="object"==typeof n?n instanceof Node?r?n.toString():n.nodeType+":"+(n.tagName||n.textContent):n instanceof NamespaceNode?"xmlns:"+n.prefix+"="+n.uri:n.toString():typeof n,print(t+": "+i),o.push(n)}return 0===o.length&&print(t+": <empty>"),Iter.ForArray(o)},oneString:function(t){return Iter.Singleton(Atomic.string.fromString(t))},oneInteger:function(t){return Iter.Singleton(Atomic.integer.fromNumber(t))},oneDouble:function(t){return Iter.Singleton(Atomic["double"].fromNumber(t))},oneFloat:function(t){return Iter.Singleton(Atomic["float"].fromNumber(t))},oneDecimal:function(t){return Iter.Singleton(Atomic.decimal.fromBig(t))},oneBoolean:function(t){return Iter.Singleton(Atomic["boolean"].fromBoolean(t))}}}(),makePattern=function(t){"use strict";var e={"p.any":function(t){return function(){return!0}},"p.booleanExp":function(t){return function(e,r){var n=r.newContext();return n.focus=Iter.Tracker(Iter.Singleton(e)),n.focus.next(),Expr.ebv(Expr.evalChild1(t,n))}},"p.genNode":function(t){var e=DomUtils.getChildElements(t)[0];return function(t,r){if(!DomUtils.isNode(t))return!1;for(var n,o=Axis.ancestorOrSelf(t);null!==(n=o.next());){var i=r.newContext(!1);i.focus=Iter.Tracker(Iter.Singleton(n)),i.focus.next();for(var a,u=Expr.evaluate(e,i);null!==(a=u.next());)if(a==t)return!0}return!1}},"p.nodeSet":function(t){return function(e,r){for(var n,o=Expr.evalChild1(t,r);null!==(n=o.next());)if(n==e)return!0;return!1}},"p.nodeTest":function(t){return new Function("item",t.getAttribute("jsTest"))},"p.simPos":function(t){var e=new Function("item",t.getAttribute("jsTest")),r=parseInt(t.getAttribute("pos"),10);return function(t,n){return e(t)&&Axis.precedingSibling(t).filter(e).count()==r-1}},"p.venn":function(t){var e=DomUtils.getChildElements(t),r=makePattern(e[0]),n=makePattern(e[1]),o=t.getAttribute("op");switch(o){case"union":return function(t,e){return r(t,e)||n(t,e)};case"intersect":return function(t,e){return r(t,e)&&n(t,e)};case"except":return function(t,e){return r(t,e)&&!n(t,e)};default:throw XError("unknown op "+o,"SXJS0003")}},"p.withCurrent":function(t){var e=makePattern(DomUtils.getChildElements(t)[0]);return function(t,r){var n=r.newContext(!0);return n.localVars[0]=[t],e(t,n)}},"p.withPredicate":function(t){var e=DomUtils.getChildElements(t),r=makePattern(e[0]),n=e[1];return function(t,e){if(!r(t,e))return!1;var o=e.newContext(!1);o.focus=Iter.Tracker(Iter.Singleton(t)),o.focus.next();var i=Expr.ebv(Expr.evaluate(n,o));return i}},"p.withUpper":function(t){var e=DomUtils.getChildElements(t),r=makePattern(e[0]),n=makePattern(e[1]),o=t.getAttribute("axis");return"parent"==o?"true"==t.getAttribute("upFirst")?function(t,e){var o=DomUtils.xdmParentNode(t);return o&&n(o,e)&&r(t,e)}:function(t,e){var o=DomUtils.xdmParentNode(t);return o&&r(t,e)&&n(o,e)}:function(t,e){if(!r(t,e))return!1;for(var i,a=Axis[o](t);null!==(i=a.next());)if(n(i,e))return!0;return!1}}},r=e[t.tagName];if(r)return r(t);throw XError("Unimplemented pattern "+t.tagName,"SXJS0002")},Regex=function(){"use strict";function t(){if(null===n){print("Loading categories.json");var t=SaxonJS.getPlatform().readResource("opt/categories.json");n=JSON.parse(t),print("Finished loading categories.json")}return n}function e(e,r,n){function i(e,r){function n(t){for(var e=t.toString(16);e.length<4;)e="0"+e;return"\\u"+(o&&e.length>4?"{"+e+"}":e)}function i(t){for(var e="",r=0;r<t.length;r+=2)(o||t[r+1]<65536)&&(e+=n(t[r]),t[r+1]>t[r]&&(e+="-"+n(t[r+1])));return e}function c(t){var e=[];0!==t[0]&&(e.push(0),e.push(t[0]-1));for(var r=2;r<t.length;r+=2)e.push(t[r-1]+1),e.push(t[r]-1);var n=t[t.length-1];return(o||65535>n)&&(e.push(n+1),e.push(o?1114111:65535)),e}function l(t,e,r){r&&(t=c(t));var n=i(t);return e||(n="["+n+"]"),n}function g(t,e,r){var n=[];return t.forEach(function(t){n.push(parseInt(t[0],16)),n.push(parseInt(t[1],16))}),l(n,e,r)}var v=e.charAt(r+1);if(s&&"nrt\\|.-^?*+{}()[]pPsSiIcCdDwW$".indexOf(v)<0&&(0!==m||!/[0-9]/.test(v))&&u("\\"+v+" is not allowed in XPath regular expressions"),"p"==v||"P"==v){var x=e.indexOf("}",r),E=e.substring(r+3,x);a("x")&&(E=E.replace(/[ \n\r\t]+/g,""));var S=t(),N=S[E];N||u("Unknown category "+E);var y;1==E.length?(y=[],N.split("|").forEach(function(t){y=y.concat(S[t])})):y=N,f+=g(y,m>0,"P"==v),r=x}else"d"==v?(f+=g(t().Nd,m>0,!1),r++):"i"==v?(f+=l(p,m>0,!1),r++):"c"==v?(f+=l(h,m>0,!1),r++):"I"==v?(f+=l(p,m>0,!0),r++):"C"==v?(f+=l(h,m>0,!0),r++):/[0-9]/.test(v)?m>0?u("Numeric escape within charclass"):(d[parseInt(v,10)]?print("Capture #"+v+" ok"):u("No capturing expression #"+v),f+="\\"+v,r++):"-"==v||"$"==v?(f+=v,r++):(f+="\\"+v,r++);return{output:f,i:r}}function a(t){return r.indexOf(t)>=0}function u(t){throw new XError("Invalid XPath regular expression: "+t,"FORX0002")}var s=!0;if(r=r?r.toString():"",!o&&n&&Expr.isAstral(n))throw new XError("Cannot handle non-BMP characters with regular expressions in this browser","SXJS0002");var c=(a("i")?"i":"")+(a("m")?"m":"")+(a("g")?"g":"")+(o?"u":"");if(a("j"))return new RegExp(e,r.replace("j",""));if(a("q"))return new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),c);var l,f="",m=0,p=[58,58,65,90,95,95,97,122,192,214,216,246,248,767,880,893,895,8191,8204,8205,8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,65536,983039],h=[45,46,48,58,65,90,95,95,97,122,183,183,192,214,216,246,248,893,895,8191,8204,8205,8255,8256,8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,65536,983039],g=[],d=[],v=1;for(l=0;l<e.length;l++){var x=e.charAt(l);switch(x){case"[":s&&m>0&&u("-"==e.charAt(l-1)?"Regex subtraction not implemented":"Nested square brackets"),"]"==e.charAt(l+1)&&u("Character group is empty"),m++,f+=x;break;case"]":0===m&&u("Unmatched ']'"),m--,f+=x;break;case"(":var E=!0;l+2<e.length&&"?"==e.charAt(l+1)&&(":"!=e.charAt(l+2)?u("'(?' must be followed by ':'"):E=!1),g.push(E?v++:-1),f+=x;break;case")":0===g.length&&u("Unmatched ')'");var S=g.pop();S>0&&(d[S]=!0),f+=x;break;case".":f+=0===m&&a("s")?"[^]":x;break;case"{":if(s&&","==e.charAt(l+1))throw XError("{,x} not allowed in XPath regex dialect","FORX0002");f+=x;break;case" ":case"\n":case"\r":case" ":(!a("x")||m>0)&&(f+=x);break;case"\\":if(a("q"))f+="\\\\";else{if(!(l+1<e.length))throw XError("No character for escape code in XPath regex","FORX0002");var N=i(e,l);f=N.output,l=N.i}break;default:f+=x}}m>0&&u("Unmatched '['"),0!==g.length&&u("Unmatched '(");try{return new RegExp(f,c)}catch(y){throw/^[imsxjqg]*$/.test(r)?new XError("Invalid regular expression /"+e+"/: "+y.message,"FORX0002"):new XError("Invalid regex flags: "+r,"FORX0001")}}function r(t,e){if(e=e.toString(),/j/.test(e))return t;if(/q/.test(e))return/\$['`]/.test(t)&&(t=t.replace(/\$'/g,"$$$$'").replace(/\$`/g,"$$$$`")),t.replace(/\$/g,"$$");if(/(^|[^\\])\$([^0-9]|$)/.test(t)||/(^|[^\\])\\([^\\\$]|$)/.test(t))throw new XError("Invalid replacement string: "+t,"FORX0004");return t.replace(/\\\\/g,"\\").replace(/\\\$/g,"$$$$").replace(/\$0/g,"$$&")}var n=null,o=!1;try{o=1=="🚀".match(new RegExp(".","gu")).length}catch(i){o=!1;
}var a=e("^\\i\\c*$",""),u=e("^\\c+$","");return{obtainCategoryEscapes:t,prepareRegex:e,convertReplacement:r,isNCName:function(t){return a.test(t)&&!/:/.test(t)},isName:function(t){return a.test(t)},isNMTOKEN:function(t){return u.test(t)},isQName:function(t){return a.test(t)&&/^[^:]+(:[^:]+)?$/.test(t)},trim:function(t){return t.replace(/^[ \t\r\n]+|[ \t\r\n]+$/g,"")}}}(),CoreFn=function(){"use strict";function t(t,e,r){var n=e.fixed.documentPool[t];if(!n){try{n=r()}catch(o){n=o}e.fixed.documentPool[t]=n}if(n instanceof XError)throw n;return n}function e(e,r){if(e.indexOf("#")>=0)throw XError("Fragments not supported in external document URIs","FODC0002");return t(e,r,function(){var t=SaxonJS.getPlatform().readFile(e),r=E.obtainDocumentNumber(SaxonJS.getPlatform().parseXmlFromString(t));return r._saxonDocumentUri=e,r._saxonBaseUri=e,r})}function r(e,r){if(e.indexOf("#")>=0)throw XError("Fragments not supported in external document URIs","FODC0002");return t(e,r,function(){return SaxonJS.getPlatform().readFile(e,"utf-8")})}function n(t,e,r){var n=x.staticBaseUri(r,e),o=t[0].next();return null===o?null:SaxonJS.getPlatform().resolveUri(o.toString(),n)}function o(e,r,o){var i;try{i=n(e,r,o)}catch(a){throw XError(a.message,"FOUT1170",o)}if(i.match(/#/))throw XError("Fragment identifier for uparsed-text"+i.toString(),"FOUT1170",o);var u="";if(e[1]&&(u=l(e[1]),"utf-8"!=u&&"utf-16"!=u))throw XError("Unrecognized encoding "+u,"FOUT1190");return null===i?null:t(i,r,function(){try{return SaxonJS.getPlatform().readFile(i,u)}catch(t){throw XError("Cannot retrieve unparsed-text "+i.toString(),"FOUT1170",o)}})}function i(t){try{return t(),Iter.oneBoolean(!0)}catch(e){return Iter.oneBoolean(!1)}}function a(t,e,r,n){var o=t.next();if(o){var i=Regex.trim(o.toString());if(n&&Regex.isNCName(i))return"Q{"+n+"}"+i;var a=Atomic.QName.fromString(i,x.stylesheetResolver(e,!1));if(null===a)throw new XError("Invalid QName "+i,r,e);return"Q{"+a.uri+"}"+a.local}return null}function u(t,e){var r=l(t[0]),n="";return Expr.stringToCodepoints(r).forEach(function(t){var r=Expr.codepointsToString([t]);n+=e(t,r)?encodeURIComponent(r):r}),Iter.oneString(n)}function s(t,e){if(2!=e.length&&5!=e.length)throw new XError("Wrong number of arguments ("+e.length+") for "+t,"XPST0017")}function c(t){var e=t[0].next(),r=t[1].next(),n=r.value[0][0];return e instanceof Expr.XdmArray&&(n=n.toNumber()),Iter.ForArray(e.get(n))}function l(t){var e=t.next();return e?e.value:""}function f(t){return x.stringToCodepoints(l(t))}function m(t,e,r){var n=Math.round(e.next().toNumber()),o=r?n+Math.round(r.next().toNumber()):t.length+1;return t.filter(function(t,e){return e+1>=n&&o>e+1})}function p(t,e,r){var n=e;return t.forEachItem(function(t){n=r(t,n)}),n}function h(t){function e(t){throw new XError(t,"FORG0006")}var r="max"==t?function(t){return t>0}:function(t){return 0>t};return function(n,o,i){var a=n[0];x.hasFlag(i,"i")&&(a=a.filter(function(t){return!Compare.itemIsNaN(t)}));var u=(Compare.getCollation(i,n[1]),Atomic.untypedAtomic.matches),s=Atomic.numeric.matches,c=Atomic["double"].matches,l=Atomic["float"].matches,f=Atomic.anyURI.matches,m=Atomic.string.matches,h=Atomic.duration.matches,g=Atomic.yearMonthDuration.matches,d=Atomic.dayTimeDuration.matches,v=Atomic.QName.matches,E=Atomic["double"].cast,S=Atomic["float"].cast,N=Atomic.string.cast;a=a.mapOneToOne(function(t){return u(t)?E(t):t});var y=a.next();if(null===y)return Iter.Empty;v(y)&&e(t+"() not defined over QName"),!h(y)||g(y)||d(y)||e(t+"() not defined over mixed duations");var A=Compare.allocateCodedComparer("GAC");return Iter.Singleton(p(a,y,function(t,n){return(m(t)&&s(n)||m(n)&&s(t))&&e("Cannot compare string with numeric"),(g(t)&&!g(n)||d(t)&&!d(n))&&e("Cannot compare mixed duations"),Compare.itemIsNaN(n)?c(t)?E(n):n:Compare.itemIsNaN(t)?c(n)?E(t):t:(c(n)&&!m(t)?t=E(t):c(t)&&!m(n)?n=E(n):l(n)&&!m(t)?t=S(t):l(t)&&!m(n)&&(n=S(n)),f(n)&&m(t)?n=N(n):f(t)&&m(n)&&(t=N(t)),r(A.compare(t,n))?t:n)}))}}function g(t,e){var r=t[0].next();if(null===r)return Iter.Empty;if("timezone"==e)return null===r.timezoneOffset?Iter.Empty:Iter.Singleton(Atomic.dayTimeDuration.fromNumberOfMinutes(r.timezoneOffset));if("seconds"==e){var n=r.proxy();return Iter.oneDecimal(n.getUTCSeconds()+n.getUTCMilliseconds()/1e3)}var o=r.proxy()[e]();return"getUTCMonth"==e&&o++,Iter.oneInteger(o)}function d(t,e){var r=t[0].next();return null===r?Iter.Empty:5!=e?Iter.oneInteger(r.parts()[e]*r.signum()):Iter.oneDecimal(r.parts()[e]*r.signum())}function v(t,e,r){function n(t,r){return Iter.Singleton(Atomic[e].fromDate(t,r))}var o=t[0].next();if(!o)return Iter.Empty;var i,a=r.fixed.currentDate.getTimezoneOffset();if(t[1]){var u=t[1].next();if(i=null!==u?u.milliseconds/6e4:null,null!==i&&(-840>i||i>840))throw new XError("timezone out of bounds "+u,"FODT0003")}else i=-a;var s=o.timezoneOffset;return null===s&&null===i?Iter.Singleton(o):null===s&&null!==i?n(o.adjustByMinutes(-a-i).UTCdate,i):null!==s&&null===i?n(o.adjustByMinutes(a+s).UTCdate,null):null!==s&&null!==i?n(o.UTCdate,i):void 0}var x=Expr,E=DomUtils;return{abs:function(t){var e=t[0].next();return null===e?Iter.Empty:Iter.Singleton(e.abs())},"adjust-date-to-timezone":function(t,e){return v(t,"date",e)},"adjust-dateTime-to-timezone":function(t,e){return v(t,"dateTime",e)},"adjust-time-to-timezone":function(t,e){return v(t,"time",e)},"analyze-string":function(t,e){var r=l(t[0]),n=e.resultDocument.createDocumentFragment(),o="http://www.w3.org/2005/xpath-functions",i=e.resultDocument.createElementNS(o,"analyze-string-result");if(n.appendChild(i),""===r)return Iter.Singleton(i);var a=t[1].next().toString(),u=t[2]?t[2].next().toString():"",s=Expr.analyze(r,a,u,!1,!1);return s.forEach(function(t){var r,n;if(t.matching){var a,u=t.groups;r=e.resultDocument.createElementNS(o,"match");var s,c=0;for(s=1;s<u.length;s++)if(u[s]){a=u[0].indexOf(u[s],c),a>c&&(n=e.resultDocument.createTextNode(u[0].substring(c,a)),r.appendChild(n));var l=e.resultDocument.createElementNS(o,"group");l.setAttribute("nr",s);var f=e.resultDocument.createTextNode(u[s]);l.appendChild(f),r.appendChild(l),c=a+u[s].length}c<u[0].length&&(n=e.resultDocument.createTextNode(u[0].substring(c,a)),r.appendChild(n)),i.appendChild(r)}else r=e.resultDocument.createElementNS(o,"non-match"),n=e.resultDocument.createTextNode(t.string),r.appendChild(n),i.appendChild(r)}),Iter.Singleton(i)},apply:c,_APPLY:c,"available-environment-variables":function(){return Iter.Empty},avg:function(t){var e=t[0].mapOneToOne(x.untypedToDouble),r=e.next();if(null===r)return Iter.Empty;var n={sum:r,count:1},o=Calculate["a+a"];try{var i=p(e,n,function(t,e){return{sum:o(e.sum,t),count:e.count+1}});return Iter.Singleton(Calculate["a/a"](i.sum,Atomic.integer.fromNumber(i.count)))}catch(a){throw new XError("Input to avg() contains a mix of numeric and non-numeric values ","FORG0006")}},"base-uri":function(t){return t[0].mapOneToOne(function(t){var e=E.baseURI(t);return null===e?null:Atomic.anyURI.fromString(e)})},"boolean":function(t){return Iter.oneBoolean(x.ebv(t[0]))},ceiling:function(t){var e=t[0].next();return Iter.Singleton(null===e?null:e.ceiling())},"codepoint-equal":function(t){var e=t[0].next(),r=t[1].next();return null===e||null===r?Iter.Empty:Iter.oneBoolean(e.toString()===r.toString())},"codepoints-to-string":function(t){return Iter.oneString(x.codepointsToString(t[0].expand().map(function(t){return t.toNumber()})))},"collation-key":function(t,e,r){var n=Compare.getCollation(r,t[1]),o=t[0].next(),i=n.collationKey(o.value);return Iter.Singleton(Atomic.base64Binary.encodeFromString(i))},collection:function(){return Iter.Empty},compare:function(t,e,r){var n=t[0].next(),o=t[1].next();if(null===n||null===o)return Iter.Empty;var i=Compare.getCollation(r,t[2]).compare(n.value,o.value);return Iter.oneInteger(i)},concat:function(t){return Iter.oneString(t.map(function(t){var e=t.next();return null===e?"":Atomic.string.cast(e)}).join(""))},contains:function(t,e,r){var n=l(t[0]),o=l(t[1]),i=Compare.getCollation(r,t[2]).contains(n,o);return Iter.oneBoolean(i)},"contains-token":function(t,e,r){var n=l(t[0]),o=l(t[1]);if(o=Regex.trim(o),""===o)return Iter.oneBoolean(!1);var i=Compare.getCollation(r,t[2]).containsToken(n,o);return Iter.oneBoolean(i)},count:function(t){return Iter.oneInteger(t[0].count())},"current-date":function(t,e){return Iter.Singleton(Atomic.date.fromDate(e.fixed.currentDate,-e.fixed.currentDate.getTimezoneOffset()))},"current-dateTime":function(t,e){return Iter.Singleton(Atomic.dateTime.fromDate(e.fixed.currentDate,-e.fixed.currentDate.getTimezoneOffset()))},"current-time":function(t,e){return Iter.Singleton(Atomic.time.fromDate(e.fixed.currentDate,-e.fixed.currentDate.getTimezoneOffset()))},data:function(t){return t[0].mapOneToOne(x.atomize)},dateTime:function(t){var e=t[0].next(),r=t[1].next();if(null===e||null===r)return Iter.Empty;var n="";if(null!==e.timezoneOffset)if(null===r.timezoneOffset)n=e.tzOffsetToString();else if(null!==r.timezoneOffset&&e.timezoneOffset!=r.timezoneOffset)throw new XError("timezones are incompatible ","FORG0005");return Iter.Singleton(Atomic.dateTime.fromString(e.toString().substring(0,10)+"T"+r.toString()+n))},"day-from-date":function(t){return g(t,"getUTCDate")},"day-from-dateTime":function(t){return g(t,"getUTCDate")},"days-from-duration":function(t){return d(t,2)},"deep-equal":function(t,e,r){var n=Compare.getCollation(r,t[2]).deepEqual(t[0],t[1]);return Iter.oneBoolean(n)},"default-collation":function(){return Iter.oneString("http://www.w3.org/2005/xpath-functions/collation/codepoint")},"default-language":function(){return Iter.oneString("en")},"distinct-values":function(t,e,r){var n=new HashTrie;return n.options.sameKey=Compare.getCollation(r,t[1]).deepEqualItems,t[0].filter(function(t){return n.containsKey(t)?!1:(n.inSituPut(t,!0),!0)})},doc:function(t,r,o){var i=n(t,r,o);if(null===i)return Iter.Singleton(null);var a=e(i,r),u=SaxonJS.getSpaceStripper();return null!==u&&(a=u(a)),Iter.Singleton(a)},"doc-available":function(t,r,o){var a=n(t,r,o);return null===a?Iter.oneBoolean(!1):i(function(){e(a,r)})},document:function(t,r,n){var o;if(t[1]){var i=E.baseURI(t[1].next());i&&(o=i)}return o||(o=x.staticBaseUri(n,r)),t[0].mapOneToMany(function(t){var n=E.isNode(t)?E.baseURI(t):o;return x.atomize(t).mapOneToOne(function(t){if(null===n)throw new XError("No base URI for document('"+t+"')","XTDE1162");return e(SaxonJS.getPlatform().resolveUri(t.toString(),n),r)})})},"document-uri":function(t){var e=t[0].next();return null!==e&&e.nodeType==E.DOCUMENT_NODE&&e._saxonDocumentUri?Iter.Singleton(Atomic.anyURI.fromString(e._saxonDocumentUri)):Iter.Empty},"element-available":function(t,e,r){a(t[0],r,"XTDE1440").split("}");return Iter.oneBoolean(!0)},"element-with-id":function(t,e){var r=l(t[0]);if(!e.focus.current)throw new XError("No context item for element-with-id()","XPDY0002");return Iter.Singleton(E.ownerDocument(e.focus.current).getElementById(r))},empty:function(t){return Iter.oneBoolean(null===t[0].next())},"encode-for-uri":function(t){var e=encodeURIComponent(l(t[0])).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()});return Iter.oneString(e)},"ends-with":function(t,e,r){var n=l(t[0]),o=l(t[1]),i=Compare.getCollation(r,t[2]).endsWith(n,o);return Iter.oneBoolean(i)},"environment-variable":function(){return Iter.Empty},error:function(){throw new XError("fn:error() invoked","FOER0000")},"escape-html-uri":function(t){return u(t,function(t){return 32>t||t>126})},"exactly-one":function(t){var e=t[0].expand();if(1!=e.length)throw new XError("Required length 1, actual length "+e.length,"FORG0005");return Iter.Singleton(e[0])},exists:function(t){return Iter.oneBoolean(null!==t[0].next())},"false":function(){return Iter.oneBoolean(!1)},floor:function(t){return t[0].mapOneToOne(function(t){return t.floor()})},"format-date":function(t){return s("format-date",t),t[2]?Iter.oneString(Numberer.formatDateTime("date",t[0].next(),t[1].next().toString(),t[2].next(),t[3].next(),t[4].next())):Iter.oneString(Numberer.formatDateTime("date",t[0].next(),t[1].next().toString()))},"format-dateTime":function(t){return s("format-dateTime",t),t[2]?Iter.oneString(Numberer.formatDateTime("dateTime",t[0].next(),t[1].next().toString(),t[2].next(),t[3].next(),t[4].next())):Iter.oneString(Numberer.formatDateTime("dateTime",t[0].next(),t[1].next().toString()))},"format-integer":function(t){var e=t[0].next();return null===e?Iter.oneString(""):Iter.oneString(Numberer.formatInteger(e,t[1].next().toString()))},"format-number":function(t,e,r){var n=null;t[2]&&(n=a(t[2],r,"XTDE1260"));var o=t[0].next();return o=null===o?Number.NaN:o.toDouble().value,Iter.oneString(Numberer.formatNumber(o,t[1].next().toString(),n,e))},"format-time":function(t){return s("format-time",t),t[2]?Iter.oneString(Numberer.formatDateTime("time",t[0].next(),t[1].next().toString(),t[2].next(),t[3].next(),t[4].next())):Iter.oneString(Numberer.formatDateTime("time",t[0].next(),t[1].next().toString()))},"function-available":function(t,e,r){var n=!1,o=a(t[0],r,"XTDE1400","http://www.w3.org/2005/xpath-functions"),i=t[1]?t[1].next().toNumber():-1;if(e.fixed.userFunctions[o+"#"+i])n=!0;else{var u=Atomic.QName.fromEQName(o),s=SaxonJS.getPlatform().readResource("opt/functions.json"),c=JSON.parse(s),l=c[u.uri];n=l&&l[u.local]?i>=0?l[u.local].indexOf(i)>=0:!0:!1}return Iter.oneBoolean(n)},"generate-id":function(t,e){var r=t[0].next();if(null===r)return Iter.oneString("");var n,o=Axis.ancestorOrSelf(r).expand().reverse(),i="";for(n=0;n<o.length;n++){var a;o[n]instanceof NamespaceNode?i+="N"+o[n].prefix:o[n].nodeType==E.ATTRIBUTE_NODE?i+="A"+E.nameOfNode(o[n]).local:(a=Axis.precedingSibling(o[n]).count()+1,i+=Numberer.formatInteger(a,n%2===0?"a":"A"))}return i="d"+E.documentNumber(o[0],e)+i,Iter.oneString(i)},"has-children":function(t){return Iter.oneBoolean(null!==Axis.child(t[0].next()).next())},head:function(t){return Iter.Singleton(t[0].next())},"hours-from-dateTime":function(t){return g(t,"getUTCHours")},"hours-from-duration":function(t){return d(t,3)},"hours-from-time":function(t){return g(t,"getUTCHours")},id:function(t,e){var r=l(t[0]),n=t[1]?t[1].next():E.ownerDocument(e.focus.current);if(!E.isNode(n))throw new XError("Context item is not a node for fn:id()","XPTY0004");return n.nodeType!=DomUtils.DOCUMENT_NODE&&n.nodeType!=DomUtils.DOCUMENT_FRAGMENT_NODE&&(n=E.ownerDocument(n)),Iter.Singleton(n.getElementById(r))},idref:function(){return Iter.Empty},"implicit-timezone":function(t,e){return Iter.Singleton(Atomic.dayTimeDuration.fromNumberOfMinutes(-e.fixed.currentDate.getTimezoneOffset()))},"index-of":function(t,e,r){var n=Iter.Tracker(t[0]),o=t[1].next(),i=Compare.hasCollation(r,t[2]),a=i?Compare.getCollation(r,t[2]):null;return n.mapOneToOne(function(t){try{return i?Atomic.string.matches(t)&&Atomic.string.matches(o)&&a.equals(t.value,o.value)?Atomic.integer.fromNumber(n.position):null:t.equals(o)?Atomic.integer.fromNumber(n.position):null}catch(e){return null}})},innermost:function(t){var e=[];return t[0].forEachItem(function(t){e.length>0&&Axis.ancestor(t).some(function(t){return t==e[e.length-1]})&&e.pop(),e.push(t)}),Iter.ForArray(e)},"in-scope-prefixes":function(t){var e=t[0].next();return Iter.ForArray(E.inScopeNamespaces(e).map(function(t){return Atomic.string.fromString(t.prefix)}))},"insert-before":function(t){var e=t[1].next().value,r=t[2],n=Iter.Tracker(t[0]);return 1>e?Iter.Join([r,n]):e>n.last()?Iter.Join([n,r]):n.mapOneToMany(function(r){return n.position==e?Iter.Join([t[2],Iter.Singleton(r)]):Iter.Singleton(r)})},"iri-to-uri":function(t){return u(t,function(t,e){return 32>=t||t>126||/[<>"{}|\\\^`]/.test(e)})},"json-doc":function(t,e,o){var i=n(t,e,o);if(!i)return Iter.Empty;var a=r(i,e),u=t[1]?t[1].next():null;return Iter.Singleton(ConvertJson.parseToMap(a,u))},"json-to-xml":function(t,e,r){var n=t[0].next();if(!n)return Iter.Empty;var o=t[1]?t[1].next():null,i=ConvertJson.parseToXml(n.toString(),o,e),a=e.resultDocument.createDocumentFragment();return a.appendChild(i),a._saxonBaseUri=x.staticBaseUri(r,e),Iter.Singleton(a)},key:function(t,e,r){var n=a(t[0],r,"XTDE1260"),o=e.fixed.keys[n];if(!o)throw new XError("Unknown key "+n,"XTDE1260",r);var i,u;if(t[2]?(i=t[2].next(),u=E.ownerDocument(i)):(i=E.ownerDocument(e.focus.current),u=i),null===u)throw new XError("No containing document for key()","XTDE1270",r);"_saxonIndexes"in u||(u._saxonIndexes={});var s=u._saxonIndexes,c=s[n];if(!c){c=new HashTrie,s[n]=c;var l,f=E.getChildElements(o)[0];if("p.nodeSet"==f.tagName){var m=e.newContext(!0);m.focus=Iter.Tracker(Iter.Singleton(u)),m.focus.next(),l=x.evaluate(E.getChildElements(f)[0],m)}else{var p=makePattern(f);l=Axis.descendantOrSelf(u).filter(function(t){return p(t,e)})}for(var h,g=E.getChildElements(o)[1],d=e.newContext(!0);null!==(h=l.next());){d.focus=Iter.Tracker(Iter.Singleton(h)),d.focus.next();for(var v,S=x.evaluate(g,d);null!==(v=S.next());)if(c.containsKey(v)){var N=c.get(v);-1==N.indexOf(h)&&c.get(v).push(h)}else c.inSituPut(v,[h])}}var y=t[1];return y.mapOneToMany(function(t){if(c.containsKey(t)){var e=Iter.ForArray(c.get(t));return u==i?e:e.filter(function(t){return null!==Axis.ancestorOrSelf(t).filter(function(t){return t==i}).next()})}return Iter.Empty})},lang:function(t,e){var r=t[1]?t[1].next():e.focus.current;if(!r)throw new XError("No context item for lang()","XPDY0002");if(!E.isNode(r))throw new XError("Context item is not a node in lang()","XPTY0004");var n=l(t[0]).toLowerCase(),o=Axis.ancestorOrSelf(r).filter(function(t){return t.nodeType==E.ELEMENT_NODE&&t.hasAttribute("xml:lang")}),i=o.next();if(!i)return Iter.oneBoolean(!1);var a=i.getAttribute("xml:lang").toLowerCase(),u=n==a||a.length>n.length+1&&a.substring(0,n.length)==n&&"-"==a.charAt(n.length);return Iter.oneBoolean(u)},last:function(t,e){if(!e.focus.current)throw new XError("No context item for last()","XPDY0002");return Iter.oneInteger(e.focus.last())},"load-xquery-module":function(){throw new XError("No XQuery processor available","FOQM0006")},"local-name":function(t){var e=E.nameOfNode(t[0].next());return Iter.oneString(e?e.local:"")},"local-name-from-QName":function(t){var e=t[0].next();return null===e?Iter.Empty:Iter.Singleton(Atomic.NCName.fromString(e.local))},"lower-case":function(t){return Iter.oneString(l(t[0]).toLowerCase())},matches:function(t){var e=l(t[0]),r=t[1].next().toString(),n=t[2]?t[2].next().toString():"";if(!n.match(/^[smijxq]*$/))throw new XError("Illegal flags for regular expression: "+n,"FORX0001");var o=Regex.prepareRegex(r,n,e);return Iter.oneBoolean(e.search(o)>=0)},max:h("max"),min:h("min"),"minutes-from-dateTime":function(t){return g(t,"getUTCMinutes")},"minutes-from-duration":function(t){return d(t,4)},"minutes-from-time":function(t){return g(t,"getUTCMinutes")},"month-from-date":function(t){return g(t,"getUTCMonth")},"month-from-dateTime":function(t){return g(t,"getUTCMonth")},"months-from-duration":function(t){return d(t,1)},name:function(t){var e=E.nameOfNode(t[0].next());return Iter.oneString(e?e.toString():"")},"namespace-uri":function(t){var e=E.nameOfNode(t[0].next());return Iter.Singleton(Atomic.anyURI.fromString(e?e.uri:""))},"namespace-uri-for-prefix":function(t){var e=l(t[0]),r=t[1].next(),n="xml"==e?"http://www.w3.org/XML/1998/namespace":r.lookupNamespaceURI(e);return n?Iter.Singleton(Atomic.anyURI.fromString(n)):Iter.Empty},"namespace-uri-from-QName":function(t){var e=t[0].next();return null===e?Iter.Empty:Iter.Singleton(Atomic.anyURI.fromString(e.uri))},nilled:function(t){var e=t[0].next();return e&&e.nodeType==E.ELEMENT_NODE?Iter.oneBoolean(!1):Iter.Empty},"node-name":function(t){return Iter.Singleton(E.nameOfNode(t[0].next()))},"normalize-space":function(t){var e=l(t[0]);return Iter.oneString(Expr.wsCollapse(e))},"normalize-unicode":function(t){if(String.normalize){var e=l(t[0]),r=t[1].next().toString();if("NFC"==r||"NFD"==r||"NFKC"==r||"NFKD"==r)return Iter.oneString(e.normalize(r));if(""===r)return Iter.oneString(e)}throw new XError("normalize-unicode(): not supported on this Javascript platform","FOCH0003")},not:function(t){return Iter.oneBoolean(!x.ebv(t[0]))},number:function(t){var e=t[0].next(),r=Atomic["double"];if(null===e)e=r.fromNumber(Number.NaN);else if(Atomic["boolean"].matches(e))e=Atomic["double"].fromNumber(e.toBoolean()?1:0);else try{e=r.fromString(e.toString())}catch(n){e=r.fromNumber(Number.NaN)}return Iter.Singleton(e)},"one-or-more":function(t){var e=Iter.LookAhead(t[0]);if(null===e.peek())throw new XError("Required length >= 1, actual length zero","FORG0004");return e},outermost:function(t,e,r){var n=x.hasFlag(r,"p"),o=t[0];n||(o=E.inDocumentOrder(o));var i=null;return o.filter(function(t){return null===i?(print("OK: first"),i=t,!0):null===Axis.ancestor(t).filter(function(t){return t===i}).next()?(i=t,!0):!1})},"parse-ietf-date":function(t){return t[0].mapOneToOne(function(t){var e=function(){throw new XError("Invalid IETF date/time "+t.toString(),"FORG0010")},r=function(t){return 1==t.length?"0"+t:t},n=t.toString().trim().toLowerCase();n=n.replace(/^(monday|tuesday|wednesday|thursday|friday|saturday|sunday|mon|tue|wed|thu|fri|sat|sun),?\s+/,"");var o,i,a,u,s,c,l;/^[a-z]/.test(n)?(o=/^([a-z]{3})(?:\s*\-\s*|\s+)(\d\d\d?\d?)\s+([\d:\.]+)\s*([a-z]+|[+\-]\d\d?:?(?:\d\d)?(?:\s*\(\s*[a-z]+\s*\))?)?\s+(\d+)$/,i=o.exec(n),null!==i?(a=i[1],u=i[2],c=i[3],l=i[4],s=i[5]):e()):(o=/^(\d+)(?:\s*\-\s*|\s+)([a-z]{3})(?:\s*\-\s*|\s+)(\d\d\d?\d?)\s+([\d:\.]+)\s*([a-z]+|[+\-]\d\d?:?(?:\d\d)?(?:\s*\(\s*[a-z]+\s*\))?)?$/,i=o.exec(n),null!==i?(u=i[1],a=i[2],s=i[3],c=i[4],l=i[5]):e()),2==s.length&&(s="19"+s);var f="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec".indexOf(a);0>f&&e();var m={ut:"Z",utc:"Z",gmt:"Z",est:"-05:00",edt:"-04:00",cst:"-06:00",cdt:"-05:00",mst:"-07:00",mdt:"-06:00",pst:"-08:00",pdt:"-07:00"};if(/^[0-9]:/.test(c)&&(c="0"+c),5==c.length&&(c+=":00"),l){var p=/([a-z]+)|([+\-]\d\d?:?(?:\d\d)?)(?:\s*\(\s*([a-z]+)\s*\))?$/.exec(l);(p[3]&&!(p[3]in m)||p[1]&&!(p[1]in m))&&e(),l=p[1]?p[1]:p[2],/^[+\-][0-9]((:|$)|[0-9]{2}$)/.test(l)&&(l=l.substring(0,1)+"0"+l.substring(1)),l in m?l=m[l]:3==l.length?l+=":00":4==l.length?l+="00":5==l.length&&(l=l.substring(0,3)+":"+l.substring(3))}var h=s+"-"+r((f/4+1).toString())+"-"+r(u)+"T"+c+(l||"Z");return Atomic.dateTime.fromString(h)})},"parse-json":function(t){var e=t[0].next().toString(),r=t[1]?t[1].next():null;return Iter.Singleton(ConvertJson.parseToMap(e,r))},"parse-xml":function(t,e,r){var n=t[0].next().toString();try{var o=SaxonJS.getPlatform().parseXmlFromString(n);return o._saxonBaseUri=x.staticBaseUri(r,e),Iter.Singleton(o)}catch(i){throw new XError("Misplaced or malformed XML:","FODC0006")}},"parse-xml-fragment":function(t,e,r){return t[0].mapOneToOne(function(t){var n=/^<\?xml(?:\s+version\s*=\s*(['"])1.[0-9]+['"])?\s+encoding\s*=\s*(['"][A-Za-z](?:[A-Za-z0-9._\-])*)['"]\s*\?>/,o=t.toString().replace(n,""),i=SaxonJS.getPlatform().parseXmlFromString("<z>"+o+"</z>"),a=e.resultDocument.createDocumentFragment();return Axis.child(i.documentElement).forEachItem(function(t){a.appendChild(t)}),a._saxonBaseUri=x.staticBaseUri(r,e),a})},path:function(t){return t[0].mapOneToOne(function(t){var e="";return Axis.ancestorOrSelf(t).forEachItem(function(t){var r,n=function(t){return Axis.precedingSibling(t).filter(function(e){return t.nodeType==e.nodeType})},o=function(t){return 1+n(t).count()};switch(t.nodeType){case E.DOCUMENT_NODE:case E.DOCUMENT_FRAGMENT_NODE:break;default:break;case E.ELEMENT_NODE:r=E.nameOfNode(t),e="/"+r.toEQName()+"["+(1+n(t).filter(function(t){return E.nameOfNode(t).equals(r)}).count())+"]"+e;break;case E.TEXT_NODE:e="/text()["+o(t)+"]";break;case E.COMMENT_NODE:e="/comment()["+o(t)+"]";break;case E.PROCESSING_INSTRUCTION_NODE:e="/processing-instruction("+t.target+")["+(1+n(t).filter(function(e){return t.target==e.target}).count())+"]";break;case E.ATTRIBUTE_NODE:e="/@"+(t.name.indexOf(":")<0?t.name:E.nameOfNode(t).toEQName());break;case E.NAMESPACE_NODE:e="/namespace::"+(""!==t.prefix?t.prefix:'*[Q{http://www.w3.org/2005/xpath-functions}local-name()=""]')}}),""===e&&(e="/"),Atomic.string.fromString(e)})},"prefix-from-QName":function(t){return t[0].mapOneToOne(function(t){return""===t.prefix?null:Atomic.string.fromString(t.prefix)})},position:function(t,e){if(!e.focus.current)throw new XError("No context item for position()","XPDY0002");return Iter.oneInteger(e.focus.position)},QName:function(t){var e=t[1].next().value.split(":"),r=2==e.length?e[0]:"",n=l(t[0]);if(""!==r&&""===n)throw new XError("Prefix but no URI for QName()","FOCA0002");if(2==e.length&&""===r)throw new XError("$paramQName not valid for QName()","FOCA0002");var o=2==e.length?e[1]:e[0];return Iter.Singleton(Atomic.QName.fromParts(r,n,o))},"regex-group":function(t,e){var r=t[0].next().toNumber();try{return Iter.oneString(e.focus.regexGroups[r]||"")}catch(n){return Iter.oneString("")}},remove:function(t){var e=t[1].next().toNumber(),r=Iter.Tracker(t[0]);return r.filter(function(t){return r.position!=e})},replace:function(t){var e=l(t[0]),r=t[3]?t[3].next().toString():"";if(!r.match(/^[smijxq]*$/))throw new XError("Illegal flags for regular expression: "+r,"FORX0001");var n=Regex.prepareRegex(t[1].next().toString(),r+"g");if(n.test(""))throw new XError("Regular expression matches zero-length string","FORX0003");var o=Regex.convertReplacement(t[2].next().toString(),r);return Iter.oneString(e.replace(n,o))},"resolve-QName":function(t){var e=t[1].next();return t[0].mapOneToOne(function(t){try{return E.resolveLexicalQName(e,t.toString(),!0)}catch(r){throw r instanceof XError&&"FORG0001"==r.code&&(r.code=Regex.isQName(t)?"FONS0004":"FOCA0002"),r}})},"resolve-uri":function(t,e,r){var n=t[1]?t[1].next().toString():x.staticBaseUri(r,e),o=t[0].next();if(null===o)return Iter.Empty;if(n=n.replace(/^file:\/(?!\/)/,"file:///"),!DomUtils.isAbsoluteURI(o.toString())&&!DomUtils.isAbsoluteURI(n))throw new XError("resolve-uri: invalid URI (base="+n+", relative="+o.toString()+")","FORG0002");if(!SaxonJS.getPlatform().inBrowser&&/#/.test(n))throw new XError("Base URI "+n+" contains a fragment identifier","FORG0002");var i;try{i=SaxonJS.getPlatform().resolveUri(o.toString(),n).toString()}catch(a){throw a}return Iter.Singleton(Atomic.anyURI.fromString(i))},reverse:function(t){return Iter.ForArray(t[0].expand().reverse())},root:function(t){return t[0].mapOneToMany(function(t){return Axis.ancestorOrSelf(t)}).filter(function(t){return null===E.xdmParentNode(t)})},round:function(t){return t[0].mapOneToOne(function(e){return e.round(t[1]?t[1].next().value:0)})},"round-half-to-even":function(t){return t[0].mapOneToOne(function(e){return e.roundHalfToEven(t[1]?t[1].next().value:0)})},"seconds-from-dateTime":function(t){return g(t,"seconds")},"seconds-from-duration":function(t){return d(t,5)},"seconds-from-time":function(t){return g(t,"seconds")},serialize:function(t){return Iter.oneString(x.serialize(t[0],t[1]?t[1]:void 0))},"starts-with":function(t,e,r){var n=l(t[0]),o=l(t[1]),i=Compare.getCollation(r,t[2]).startsWith(n,o);return Iter.oneBoolean(i)},"static-base-uri":function(t,e,r){return Iter.oneString(x.staticBaseUri(r,e))},"stream-available":function(){return Iter.oneBoolean(!1)},string:function(t){var e=t[0].next();if(!e)return Iter.oneString("");if(x.isArray(e)||x.isMap(e))throw new XError("Input to string() is a function item ","FOTY0014");return x.atomize(e).mapOneToOne(function(t){return Atomic.string.cast(t)})},"string-join":function(t){for(var e,r="",n=t[1]?t[1].next().value:"",o=!0;null!==(e=t[0].next());)o||(r+=n),r+=e.toString(),o=!1;return Iter.oneString(r)},"string-length":function(t){return Iter.oneInteger(f(t[0]).length)},"string-to-codepoints":function(t){return Iter.ForArray(f(t[0]).map(Atomic.integer.fromNumber))},subsequence:function(t){return Iter.ForArray(m(t[0].expand(),t[1],t[2]))},substring:function(t){var e=f(t[0]);return Iter.oneString(x.codepointsToString(m(e,t[1],t[2])))},"substring-after":function(t,e,r){var n,o="",i=l(t[0]),a=l(t[1]),u=Compare.getCollation(r,t[2]);return-1!=(n=u.indexOf(i,a))&&(o=i.substring(n+a.length)),Iter.oneString(o)},"substring-before":function(t,e,r){var n,o="",i=l(t[0]),a=l(t[1]),u=Compare.getCollation(r,t[2]);return-1!=(n=u.indexOf(i,a))&&(o=i.substring(0,n)),Iter.oneString(o)},sum:function(t){var e=t[0].mapOneToOne(x.untypedToDouble),r=e.next();return null===r?1==t.length?Iter.oneInteger(0):t[1]:(Calculate["a+a"](r,r),Iter.Singleton(p(e,r,Calculate["a+a"])))},"system-property":function(t,e,r){var n,o=Atomic.QName.fromEQName(a(t[0],r,"XTDE1390"));return"http://www.w3.org/1999/XSL/Transform"==o.uri&&(n={version:"3.0",vendor:"Saxonica","vendor-url":"http://www.saxonica.com/","product-name":"Saxon-JS","product-version":"9.8","is-schema-aware":"no","supports-serialization":"no","supports-backwards-compatibility":"yes","supports-namespace-axis":"yes","supports-streaming":"no","supports-dynamic-evaluation":"no","supports-higher-order-functions":"no","xpath-version":"3.1","xsd-version":"1.1"}[o.local]),Iter.oneString(n||"")},tail:function(t){var e=Iter.Tracker(t[0]);return e.filter(function(){return 1!=e.position})},"timezone-from-date":function(t){return g(t,"timezone")},"timezone-from-dateTime":function(t){return g(t,"timezone")},"timezone-from-time":function(t){return g(t,"timezone")},tokenize:function(t){var e=l(t[0]);if(t[1]||(e=Expr.wsCollapse(e)),""===e)return Iter.Empty;var r=t[1]?t[1].next().toString():"[ \\n\\r\\t]+",n=Expr.analyze(e,r,t[2]?t[2].next().toString():"",!1,!0),o=t[1]&&n[0].matching,i=n[n.length-1],a=t[1]&&i.matching,u=n.filter(function(t){return!t.matching}),s=u.map(function(t){return t.string});return o&&s.unshift(Atomic.string.fromString("")),a&&s.push(Atomic.string.fromString("")),Iter.ForArray(s)},trace:function(t){var e=t[0].expand();return print((t[1]?t[1].next().toString()+": ":"")+showValue(e)),Iter.ForArray(e)},transform:function(t){var e,r=t[0].next(),n=Iter.oneString("stylesheet-node"),o=Iter.oneString("source-node"),i=new Document;e=Iter.ForArray(r.get(n.next())).peek().cloneNode(!0),e instanceof XMLDocument&&(e=e.documentElement),i.appendChild(e);var a=new Document;e=Iter.ForArray(r.get(o.next())).peek().cloneNode(!0),e instanceof XMLDocument&&(e=e.documentElement),a.appendChild(e),r.stylesheetLocation="somewhere";SaxonJS.internalTransform(i,a,r);return SaxonJS.U.Iter.Singleton(r.principalResult)},translate:function(t){var e=f(t[0]),r=f(t[1]),n=f(t[2]),o=[];return e.forEach(function(t){var e;-1!=(e=r.indexOf(t))?e<n.length&&o.push(n[e]):o.push(t)}),Iter.oneString(x.codepointsToString(o))},"true":function(){return Iter.oneBoolean(!0)},"type-available":function(t,e,r){var n=a(t[0],r,"XTDE1428").split("}");return"Q{http://www.w3.org/2001/XMLSchema"==n[0]&&n[1]in Atomic},unordered:function(t){return t[0]},"unparsed-entity-public-id":function(){return Iter.Empty},"unparsed-entity-uri":function(){return Iter.Empty},"unparsed-text":function(t,e,r){return Iter.oneString(o(t,e,r))},"unparsed-text-available":function(t,e,r){return i(function(){o(t,e,r)})},"unparsed-text-lines":function(t,e,r){var n=o(t,e,r);return Iter.ForArray(n.split(/\r?\n/)).mapOneToOne(function(t){return Atomic.string.fromString(t)})},"upper-case":function(t){return Iter.oneString(l(t[0]).toUpperCase())},"uri-collection":function(){return Iter.Empty},"xml-to-json":function(t){var e=t[1]?t[1].next():new HashTrie;return t[0].mapOneToOne(function(t){return Atomic.string.fromString(ConvertJson.xmlToJson(t,e))})},"year-from-date":function(t){return g(t,"getUTCFullYear")},"year-from-dateTime":function(t){return g(t,"getUTCFullYear")},"years-from-duration":function(t){return d(t,0)},"zero-or-one":function(t){var e=t[0].expand();if(e.length>1)throw new XError("Required length 0-1, actual length "+e.length,"FORG0003");return Iter.Singleton(e[0]?e[0]:null)}}}(),ExtraFn=function(){"use strict";var t=function(t,e,r,n){function o(t){return null===t?(s=!0,Number.NaN):t.toNumber()}function i(){return o(Expr.evalChild1(n,r).next())}function a(){return o(Expr.evalChild2(n,r).next());
}function u(){switch(t){case"pi":return Math.PI;case"exp":return Math.exp(i());case"exp10":return Math.pow(10,i());case"log":return Math.log(i());case"log10":return Math.log(i())/Math.LN10;case"pow":var e=i(),r=a();return-1==e&&(r==1/0||r==-(1/0))||1==e?1:Math.pow(e,r);case"sqrt":return Math.sqrt(i());case"sin":return Math.sin(i());case"cos":return Math.cos(i());case"tan":return Math.tan(i());case"asin":return Math.asin(i());case"acos":return Math.acos(i());case"atan":return Math.atan(i());case"atan2":return Math.atan2(i(),a());default:throw XError("Unknown math function "+n.getAttribute("name"),"XPST0017",n)}}var s=!1,c=u();return s?Iter.Empty:Iter.oneDouble(c)},e=function(t,e,r,n){var o={contains:function(t){var e=t[0].next(),r=t[1].next();return Iter.oneBoolean(e.containsKey(r))},create:function(t){var e=new HashTrie;return t[0].forEachItem(function(t){t.forAllPairs(function(t){e.inSituPut(t.k,t.v)})}),Iter.Singleton(e)},entry:function(t){var e=new HashTrie;return e.inSituPut(t[0].next(),t[1].expand()),Iter.Singleton(e)},find:function(t){function e(t){Expr.isArray(t)?t.value.forEach(r):Expr.isMap(t)&&(t.containsKey(o)&&n.push(t.get(o)),t.keys().forEach(function(e){r(t.get(e))}))}function r(t){t.forEach(e)}var n=[],o=t[1].next();return r(t[0].expand()),Iter.Singleton(new Expr.XdmArray(n))},get:function(t){var e=t[0].next(),r=t[1].next();return Iter.ForArray(e.get(r))},keys:function(t){var e=t[0].next();return Iter.ForArray(e.keys())},merge:function(t){var e=new HashTrie,r=t[1]?t[1].next():null;return t[0].forEachItem(function(t){t.forAllPairs(function(t){var o=Atomic.string.fromString("duplicates"),i=r&&r.containsKey(o)?r.get(o).toString():"use-first";if(e.containsKey(t.k)&&"use-last"!=i&&"unspecified"!=i&&"use-any"!=i){if("reject"==i){var a=Atomic.string.fromString("duplicates-error-code"),u=r.containsKey(a)?r.get(a).toString():"FOJS0003";throw XError("Duplicate key value '"+t.k.toString()+"'",u,n)}if("combine"==i){var s=e.get(t.k);t.v.forEach(function(t){s.push(t)}),e.inSituPut(t.k,s)}}else e.inSituPut(t.k,t.v)})}),Iter.Singleton(e)},_new:function(t){var e=new HashTrie;return t[0]&&t[0].forEachItem(function(t){t.forAllPairs(function(t){if(e.containsKey(t.k))throw XError("Duplicate key value '"+t.k.toString()+"'","XQDY0137",n);e.inSituPut(t.k,t.v)})}),Iter.Singleton(e)},put:function(t){var e=t[0].next(),r=t[1].next(),n=t[2].expand();return Iter.Singleton(e.put(r,n))},remove:function(t){var e=t[0].next();return t[1].forEachItem(function(t){e=e.remove(t)}),Iter.Singleton(e)},size:function(t){var e=t[0].next(),r=0;return e.forAllPairs(function(){r++}),Iter.oneInteger(r)},"untyped-contains":function(t){var e=t[0].next(),r=t[1].next();return Iter.oneBoolean(e.containsKey(r))}};if(!o[t])throw XError("Unknown map function: "+t,"SXJS0003",n);return o[t](e,r,n)},r=function(t,e,r,n){function o(t,e){if(1>t||t>e)throw XError("Array index ("+t+") out of bounds (1 to "+e+")","FOAY0001",n)}function i(t){return t[0].next().value}function a(t){return t[1].next().toNumber()}function u(t){return Iter.Singleton(new Expr.XdmArray(t))}var s={append:function(t){return u(i(t).concat([t[1].expand()]))},flatten:function(t){return Expr.flatten(t[0])},"_from-sequence":function(t){var e=[];return t[0].forEachItem(function(t){e.push([t])}),u(e)},get:function(t){var e=i(t),r=a(t);return o(r,e.length),Iter.ForArray(e[r-1])},head:function(t){var e=i(t);return o(1,e.length),Iter.ForArray(e[0])},"insert-before":function(t){var e=i(t),r=a(t);o(r,e.length+1);var n=t[2].expand();return u(e.slice(0,r-1).concat([n]).concat(e.slice(r-1)))},join:function(t){var e=[];return t[0].forEachItem(function(t){t.value.forEach(function(t){e.push(t)})}),u(e)},put:function(t){var e=i(t),r=a(t);o(r,e.length);var n=t[2].expand();return u(e.slice(0,r-1).concat([n]).concat(e.slice(r)))},remove:function(t){var e=i(t),r=[];return t[1].forEachItem(function(t){var n=t.toNumber();o(n,e.length),r.push(n-1)}),u(e.filter(function(t,e){return r.indexOf(e)<0}))},reverse:function(t){return u(i(t).slice().reverse())},size:function(t){return Iter.oneInteger(i(t).length)},sort:function(t){function e(e,n){var o=function(t){return Iter.ForArray(t).mapOneToMany(Expr.atomize)};return t[1]?Compare.lexicographicCompare(o(e),o(n),r):Compare.lexicographicCompare(o(e),o(n))}var r=Compare.getCollation(n,t[1]);return u(i(t).slice().sort(e))},subarray:function(t){var e=i(t),r=a(t);o(r,e.length+1);var n=t[2]?t[2].next().toNumber():e.length-r+1;return XError.test(0>n,"Length is negative","FOAY0002"),o(r+n,e.length+1),u(e.slice(r-1,r+n-1))},tail:function(t){var e=i(t);return o(1,e.length),u(e.slice(1))},"_to-sequence":function(t){var e=[];return i(t).forEach(function(t){t.forEach(function(t){e.push(t)})}),Iter.ForArray(e)}};if(!s[t])throw XError("Unknown array function: "+t,"SXJS0003",n);return s[t](e,r,n)},n=function(t,e,r,n){function o(t,e){for(var r=t,o=0;o<e.length;o++){try{r=r[e[o]]}catch(i){if(null!==i.code)throw i;throw XError("Failed to get property "+e[o],"SXJS0007",n)}if("undefined"==typeof r)return void 0}return r}function i(t,e,r){var o;try{o=t.apply(r,e)}catch(i){if(null!==i.code)throw i;throw XError("Failed to call method "+t,"SXJS0007",n)}if(null===o||"undefined"==typeof o)return Iter.Empty;var a=Expr.convertFromJS(o);return Array.isArray(a)?Iter.ForArray(a):Iter.Singleton(a)}function a(t){return t instanceof Expr.JSValue?t.value:t}var u={apply:function(t){var e=a(t[0].next());if("function"!=typeof e)throw XError("ixsl:apply: first argument is not a function","SXJS0007",n);var r=Expr.convertToJS(t[1].next());return i(e,r,null)},call:function(t){var e=a(t[0].next()),r=t[1].next().toString(),u=r.split("."),s=o(e,u);if("undefined"==typeof s)throw XError("ixsl:call: object method '"+r+"' not found","SXJS0007",n);if("function"!=typeof s)throw XError("ixsl:call: property '"+r+"' is not a function","SXJS0007",n);var c=Expr.convertToJS(t[2].next());return i(s,c,e)},eval:function(t){var e=t[0].next().toString(),r=new Function("return "+e);return Iter.Singleton(Expr.convertFromJS(r()))},event:function(t,e){return Iter.Singleton(Expr.convertFromJS(e.currentEvent))},get:function(t){var e=a(t[0].next()),r=t[1].next().toString(),n=r.split("."),i=o(e,n);return"undefined"==typeof i?(print("Warning ixsl:get: object property '"+r+"' not found"),Iter.Empty):Iter.Singleton(Expr.convertFromJS(i))},location:function(){return Iter.Singleton(Expr.convertFromJS(window.location.toString()))},page:function(){return Iter.Singleton(Expr.convertFromJS(window.document))},"query-params":function(){for(var t,e=/\+/g,r=/([^&=]+)=?([^&]*)/g,n=function(t){return Atomic.string.fromString(decodeURIComponent(t.replace(e," ")))},o=window.location.search.substring(1),i=new HashTrie;null!==(t=r.exec(o));){var a=i.get(n(t[1]));a.push(n(t[2])),i.inSituPut(n(t[1]),a)}return Iter.Singleton(i)},source:function(t,e){return Iter.Singleton(Expr.convertFromJS(e.fixed.globalContextItem))},style:function(t){var e=t[0].next(),r=window.getComputedStyle(e);return Iter.Singleton(Expr.convertFromJS(r))},window:function(){return Iter.Singleton(Expr.convertFromJS(window))},"remove-attribute":function(t,e,r){var n=t[0].next().toString(),o=Atomic.QName.fromString(n,Expr.stylesheetResolver(r,!1));if(!e.focus.current)throw XError("No context item for ixsl:remove-attribute","SXJS0007",r);var i=e.focus.current;if(i.ownerDocument!=window.document)throw XError("Context item for ixsl:remove-attribute must be an element in the HTML page","SXJS0007",r);return i.removeAttribute(o.local),Iter.Empty},"schedule-action":function(){throw XError("ixsl:schedule-action - shouldn't be here","SXJS0007",n)},"set-attribute":function(t,e,r){var n=t[0].next().toString(),o=t[1].next().toString(),i=Atomic.QName.fromString(n,Expr.stylesheetResolver(r,!1));if(null===i)throw XError("Invalid attribute name "+n,"XTDE1260");if(!e.focus.current)throw XError("No context item for ixsl:set-attribute","SXJS0007",r);var a=e.focus.current;if(a.ownerDocument!=window.document)throw XError("Context item for ixsl:set-attribute must be an element in the HTML page","SXJS0007",r);return a.setAttribute(i.local,o),Iter.Empty},"set-property":function(t,e,r){var n=t[0].next().toString(),i=Expr.convertToJS(t[1].next()),u=a(t[2].next()),s=n.split("."),c=s.pop(),l=o(u,s);return"undefined"==typeof l||""===l?(print("Warning ixsl:set-property: '"+n+"' not found for supplied object"),Iter.Empty):(l[c]=i,Iter.Empty)},"set-style":function(t,e,r){var n=t[0].next().toString(),o=Expr.convertToJS(t[1].next()),i=t[2]?t[2].next():e.focus.current;if(!i)throw XError("No context item for ixsl:set-style","SXJS0007",r);return i.style[n]=o,Iter.Empty}};if(!u[t])throw XError("Unknown ixsl function: "+t,"SXJS0003",n);return u[t](e,r,n)},o=function(t,e,r,n){var o={apply:CoreFn.apply,"compile-XPath":function(t){var e,r,o=t[0].next().toString();t.length>1&&(e=t[1]),t.length>2&&(r=t[2]);var i=SaxonJS.XPath.compile(o,e,r,n);return i},"dynamic-error-info":function(t){var e=r.currentError;if(null===e)return Iter.Empty;var n=t[0].next().toString();switch(n){case"description":return Iter.oneString(e.message);case"code":return Iter.Singleton(Atomic.QName.fromParts("err","http://www.w3.org/2005/xqt-errors",e.code));case"value":return Iter.Empty;case"module":return Iter.oneString(e.xsltModule);case"line-number":return Iter.oneInteger(e.xsltLineNr);case"column-number":return Iter.oneInteger(-1);default:throw XError("unknown error info field "+n,"SXJS0003")}},"parse-XPath":function(t){var e,r=t[0].next().toString(),n="parse";t.length>1&&(n=t[1].next().toString()),t.length>2&&(e=t[2]);var o=SaxonJS.XPath.parse(r,n,e);return o}};if(!o[t])throw XError("Unknown saxon function: "+t,"SXJS0003",n);return o[t](e,r,n)};return function(i,a,u,s,c){switch(i){case"http://www.w3.org/2005/xpath-functions/math":return t(a,u,s,c);case"http://www.w3.org/2005/xpath-functions/map":return e(a,u,s,c);case"http://www.w3.org/2005/xpath-functions/array":return r(a,u,s,c);case"http://saxonica.com/ns/interactiveXSLT":return n(a,u,s,c);case"http://saxon.sf.net/":return o(a,u,s,c);default:throw XError("Unknown namespace "+i,"SXJS0003",c)}}}(),Calculate=function(){"use strict";function t(t){return Math.abs(t)<Math.pow(2,52)}function e(t,e){return u.matches(t)&&u.matches(e)?u:a}function r(t){throw new XError("Division by zero",t?t:"FOAR0001")}function n(t,e,r){throw new XError("Arithmetic operation '"+r+"' not available for operands "+t.type+" and "+e.type,"XPTY0004")}function o(t,e,r){function o(t){return Atomic.dateTime.matches(t)||Atomic.date.matches(t)||Atomic.time.matches(t)}var l,f,m,p=Atomic.dayTimeDuration,h=Atomic.yearMonthDuration;return(p.matches(t)||h.matches(t))&&Atomic.numeric.matches(e)?(m="u"+r+"n",l=t.type,f=e.type):(p.matches(e)||h.matches(e))&&Atomic.numeric.matches(t)?(m="n"+r+"u",l=t.type,f=e.type):u.matches(t)&&u.matches(e)?(m="i"+r+"i",l=f="integer"):i.matches(t)||i.matches(e)?(m="d"+r+"d",l=f="double"):s.matches(t)||s.matches(e)?(m="f"+r+"f",l=f="float"):a.matches(t)||a.matches(e)?(m="c"+r+"c",l=f="decimal"):o(t)&&o(e)?(m="t"+r+"t",l=t.type,f=e.type):o(t)&&(p.matches(e)||h.matches(e))?(m="t"+r+"u",l=t.type,f=e.type):(p.matches(t)||h.matches(t))&&o(e)?(m="u"+r+"t",l=t.type,f=e.type):p.matches(t)&&p.matches(e)||h.matches(t)&&h.matches(e)?(m="u"+r+"u",l=f=t.type):n(r,t,e),c[m]||n(r,t,e),c[m](Expr.promote(t,l),Expr.promote(e,f))}var i=Atomic["double"],a=Atomic.decimal,u=Atomic.integer,s=Atomic["float"],c={"d+d":function(t,e){var r=t.toNumber(),n=e.toNumber();return i.fromNumber(r+n)},"d-d":function(t,e){var r=t.toNumber(),n=e.toNumber();return i.fromNumber(r-n)},"d*d":function(t,e){var r=t.toNumber(),n=e.toNumber();return i.fromNumber(r*n)},"d/d":function(t,e){var r=t.toNumber(),n=e.toNumber();return i.fromNumber(r/n)},"d%d":function(t,e){var r=t.toNumber(),n=e.toNumber();return isNaN(r)||isNaN(n)||r==1/0||r==-(1/0)||0===n?i.fromNumber(NaN):n==1/0||n==-(1/0)||0===r?t:i.fromNumber(r%n)},"d~d":function(e,n){try{var o=e.toNumber(),a=n.toNumber(),s=i.fromNumber(Math.trunc(o/a));return(s==1/0||s==-(1/0)||isNaN(s))&&r(),t(s)?u.fromNumber(s):s}catch(c){r()}},"f+f":function(t,e){var r=t.toNumber(),n=e.toNumber();return s.fromNumber(r+n)},"f-f":function(t,e){var r=t.toNumber(),n=e.toNumber();return s.fromNumber(r-n)},"f*f":function(t,e){var r=t.toNumber(),n=e.toNumber();return s.fromNumber(r*n)},"f/f":function(t,e){var r=t.toNumber(),n=e.toNumber();return s.fromNumber(r/n)},"f%f":function(t,e){var n=t.toNumber(),o=e.toNumber();if(isNaN(n)||isNaN(o)||n==1/0||n==-(1/0)||0===o)return s.fromNumber(NaN);if(o==1/0||o==-(1/0)||0===n)return t;var i=s.fromNumber(n%o);return(i==1/0||i==-(1/0)||isNaN(i))&&r(),i},"f~f":function(e,n){try{var o=e.toNumber(),i=n.toNumber(),a=s.fromNumber(Math.trunc(o/i));return(a==1/0||a==-(1/0)||isNaN(a))&&r(),t(a)?u.fromNumber(a):a}catch(c){r()}},"i+i":function(e,r){var n=e.toNumber()+r.toNumber();return t(n)?u.fromNumber(n):u.fromBig(Big(e.toBig().plus(r.toBig())))},"i-i":function(e,r){var n=e.toNumber()-r.toNumber();return t(n)?u.fromNumber(n):u.fromBig(Big(e.toBig().minus(r.toBig())))},"i*i":function(e,r){var n=e.toNumber()*r.toNumber();return t(n)?u.fromNumber(n):u.fromBig(Big(e.toBig().times(r.toBig())))},"i/i":function(t,e){try{var n=t.toBig(),o=e.toBig();return a.fromBig(n.div(o))}catch(i){r()}},"i%i":function(e,n){var o=e.toNumber(),i=n.toNumber();if(isNaN(o)||isNaN(i)||o==1/0||o==-(1/0)||0===i)return u.fromNumber(NaN);if(i==1/0||i==-(1/0)||0===o)return e;var a=e.toNumber()%n.toNumber();return(a==1/0||a==-(1/0)||isNaN(a))&&r(),t(a)?u.fromNumber(a):u.fromBig(Big(e.toBig().mod(n.toBig())))},"i~i":function(e,n){var o=e.toNumber()/n.toNumber();return(o==1/0||o==-(1/0)||isNaN(o))&&r(),t(o)?u.fromNumber(Math.trunc(o)):u.fromBig(Big(e.toBig().div(n.toBig())).round(0,0))},"c+c":function(t,r){var n=t.toBig(),o=r.toBig();return e(t,r).fromBig(n.plus(o))},"c-c":function(t,r){var n=t.toBig(),o=r.toBig();return e(t,r).fromBig(n.minus(o))},"c*c":function(t,r){var n=t.toBig(),o=r.toBig();return e(t,r).fromBig(n.times(o))},"c/c":function(t,e){try{var n=t.toBig(),o=e.toBig();return a.fromBig(n.div(o))}catch(i){r()}},"c%c":function(t,e){try{var n=t.toBig(),o=e.toBig();return a.fromBig(n.mod(o))}catch(i){r()}},"c~c":function(e,n){try{var o=e.toBig(),i=n.toBig(),s=o.div(i).round(0,0);return t(s)?u.fromNumber(s):a.fromBig(s)}catch(c){r()}},"a+a":function(t,e){return o(t,e,"+")},"a-a":function(t,e){return o(t,e,"-")},"a*a":function(t,e){return o(t,e,"*")},"a/a":function(t,e){return o(t,e,"/")},"a%a":function(t,e){return o(t,e,"%")},"a~a":function(t,e){return o(t,e,"~")},"u+u":function(t,e){var r=Atomic.dayTimeDuration,o=Atomic.yearMonthDuration;return r.matches(t)&&r.matches(e)||o.matches(t)&&o.matches(e)||n(t,e,"+"),o.matches(t)?o.fromMonthsMilliseconds(t.months+e.months,0):r.fromMonthsMilliseconds(0,t.milliseconds+e.milliseconds)},"u-u":function(t,e){var r=Atomic.dayTimeDuration,o=Atomic.yearMonthDuration;return r.matches(t)&&r.matches(e)||o.matches(t)&&o.matches(e)||n(t,e,"-"),o.matches(t)?o.fromMonthsMilliseconds(t.months-e.months,0):r.fromMonthsMilliseconds(0,t.milliseconds-e.milliseconds)},"u*n":function(t,e){var r=Atomic.dayTimeDuration,o=Atomic.yearMonthDuration;r.matches(t)||o.matches(t)||n(t,e,"*");var i=e.toNumber();if(i==1/0||i==-(1/0))throw new XError("Cannot multiply duration by +/-INF","FODT0002");if(isNaN(i))throw new XError("Cannot multiply duration by NaN","FOCA0005");return o.matches(t)?o.fromMonthsMilliseconds(Math.round(t.months*i),0):r.fromMonthsMilliseconds(0,Math.round(t.milliseconds*i))},"n*u":function(t,e){return Calculate["u*n"](e,t)},"u/n":function(t,e){var o=Atomic.dayTimeDuration,i=Atomic.yearMonthDuration;o.matches(t)||i.matches(t)||n(t,e,"/");var a=i.matches(t)?t.months/e.toNumber():t.milliseconds/e.toNumber();return(a==1/0||a==-(1/0)||isNaN(a))&&r("FODT0002"),i.matches(t)?i.fromMonthsMilliseconds(Math.round(a),0):o.fromMonthsMilliseconds(0,Math.round(a))},"u/u":function(t,e){var o=Atomic.dayTimeDuration,i=Atomic.yearMonthDuration;o.matches(t)&&o.matches(e)||i.matches(t)&&i.matches(e)||n(t,e,"/");var u=new Big(i.matches(t)?t.months:t.milliseconds),s=new Big(i.matches(e)?e.months:e.milliseconds);try{return a.fromBig(u.div(s))}catch(c){r()}},"t+u":function(t,e){var r=Atomic.dayTimeDuration,o=Atomic.yearMonthDuration;return r.matches(e)||o.matches(e)||n(t,e,"+"),r.matches(e)?Atomic[t.type].fromDate(new Date(t.UTCdate.getTime()+e.milliseconds),t.timezoneOffset):t.addMonths(e.months)},"u+t":function(t,e){return Calculate["t+u"](e,t)},"t-u":function(t,e){var r=Atomic.dayTimeDuration,o=Atomic.yearMonthDuration;return r.matches(e)||o.matches(e)||n(t,e,"-"),r.matches(e)?Atomic[t.type].fromDate(new Date(t.UTCdate.getTime()-e.milliseconds),t.timezoneOffset):t.addMonths(-e.months)},"t-t":function(t,e){return Atomic.dayTimeDuration.fromMonthsMilliseconds(0,t.UTCdate.getTime()-e.UTCdate.getTime())}};return c}(),Numberer=function(){"use strict";function t(t,r){var n=t.getAttribute("level"),o=X.argRole(t,"select"),i=X.argRole(t,"count"),a=X.argRole(t,"from");return e(n,o,i,a,r)}function e(t,e,r,n,o){var i;if(e)i=X.evaluate(e,o).next();else{if(!o.focus.current)throw XError("No context item in Numberer","SXJS0004",e);i=o.focus.current}var a=_.nameOfNode(i),u=function(t){return null===_.xdmParentNode(t)},s=function(t){return t.nodeType==i.nodeType&&(null===a?!0:_.nameOfNode(t).equals(a))},c=s;if(null!==r){var l=makePattern(r);c=function(t){return l(t,o)}}var f;if(null===n)f=u;else{var m=makePattern(n);f=function(t){return u(t)||m(t,o)}}var p,h,g,d;switch(t){case"simple":return p=Axis.precedingSibling(i).filter(s),Iter.oneInteger(p.count()+1);case"single":return h=Axis.ancestorOrSelf(i).filter(c).next(),d=Axis.ancestorOrSelf(i).filter(f).next(),g=null===h?null:null!==Axis.ancestorOrSelf(h).filter(function(t){return _.isSameNode(t,d)}).next()?h:null,null===g?Iter.Empty:(p=Axis.precedingSibling(g).filter(c),Iter.oneInteger(p.count()+1));case"multi":h=Iter.ForArray(Axis.ancestorOrSelf(i).filter(c).expand().reverse()),d=Axis.ancestorOrSelf(i).filter(f).next(),g=h.filter(function(t){var e=Axis.ancestorOrSelf(t).filter(function(t){return _.isSameNode(t,d)});return null!==e.next()});var v=Atomic.integer.fromNumber;return g.mapOneToOne(function(t,e){return v(Axis.precedingSibling(t).filter(c).count()+1)});case"any":var x=function(t,e){return _.compareDocumentOrder(e,t)};h=Iter.Union(Axis.preceding(i).filter(c),Axis.ancestorOrSelf(i).filter(c),x),d=Iter.Union(Axis.preceding(i).filter(f),Axis.ancestorOrSelf(i).filter(f),x).next(),null===d&&Expr.internalError("from pattern selected empty"),g=h.filter(function(t){return _.compareDocumentOrder(t,d)>=0});var E=g.count();return 0===E?Iter.Empty:Iter.oneInteger(E);default:Expr.internalError("unknown xsl:number/@level "+t)}}function r(t,e){var r=X.argRole(t,"value"),i=X.argRole(t,"format"),a=X.evaluateIfPresent(X.argRole(t,"gpSep"),e).next(),u=X.evaluateIfPresent(X.argRole(t,"gpSize"),e).next(),s=X.evaluateIfPresent(X.argRole(t,"ordinal"),e).next(),c=X.evaluateIfPresent(X.argRole(t,"lang"),e).next(),l=t.getAttribute("flags")||"",f=X.argRole(t,"startAt"),m=/1/.test(l),p=X.evaluate(r,e),h=o(p,m,f,!0,e);return null===h?Iter.oneString("NaN"):n(h,i,a,u,s,c,e)}function n(t,e,r,n,o,i,a){function u(t){var e,r;if(""===t&&(t="1"),/^[\x01-\x7f]*$/.test(t))e=t.split(/\b/),r=function(t,e){return/\w+/.test(t)};else{if(t.length!=X.stringToCodepoints(t).length)throw XError("Cannot handle non-BMP characters in format-number picture","SXJS0002");var n=X.analyze(t,"[\\p{Nd}\\p{Nl}\\p{No}\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}]+","",!0,!1);r=function(t,e){return n[e].matching},e=n.map(function(t){return t.string.toString()})}var o,i={prefix:"",fTokens:[],suffix:""},a=".";for(o=0;o<e.length;o++){var u=e[o];r(u,o)?(i.fTokens.push({chars:u,sep:a}),a="."):(0===o&&(i.prefix=u),o==e.length-1?i.suffix=u:0!==o&&(a=u))}return 0===i.fTokens.length&&(i.fTokens.push({chars:"1",sep:"."}),i.suffix=i.prefix),i}function s(t){var i=null===e?"1":X.evaluate(e,a).next().toString(),s=u(i),c=s.prefix;return t.forEach(function(t,e){var i=e>=s.fTokens.length?s.fTokens[s.fTokens.length-1]:s.fTokens[e];0!==e&&(c+=i.sep);var a=i.chars;"yes"==o&&(a+=";o");var u=Numberer.formatInteger(t,a);null!==r&&null!==n&&(u=Numberer.addGroupingSeparators(u,r,n)),c+=u}),c+=s.suffix,Iter.oneString(c)}if(null!==i)try{Atomic.language.cast(i)}catch(c){throw XError("@lang="+i+": invalid language code","XTDE0030")}return s(t.expand())}function o(t,e,r,n,o){var i=[1];if(null!==r&&(i=X.evaluate(r,o).next().toString().split(/\s+/).map(function(t){return parseInt(t,10)})),e&&n){var a=t.next();if(null===a)return null;try{a=Atomic.integer.cast(a.round(0))}catch(u){return null}t=Iter.ForArray([a])}var s=function(t,e){if(t=Atomic.numeric.matches(t)?t.toDouble():Atomic["double"].fromStringUnfailing(t.toString()),t.toNumber()<0)throw XError("xsl:number/@value is less than zero","XTDE0980");try{t=Atomic.integer.cast(t.round(0))}catch(r){throw r.code="XTDE0980",r}var n=e>=i.length?i[i.length-1]:i[e];return 1!=n&&(t=Atomic.integer.fromNumber(t.toNumber()+(n-1))),t};return t.mapOneToOne(s)}function i(t,r){var i,a,u=X.argRole(t,"value"),s=X.argRole(t,"format"),c=X.evaluateIfPresent(X.argRole(t,"gpSep"),r).next(),l=X.evaluateIfPresent(X.argRole(t,"gpSize"),r).next(),f=X.evaluateIfPresent(X.argRole(t,"ordinal"),r).next(),m=X.evaluateIfPresent(X.argRole(t,"lang"),r).next(),p=t.getAttribute("flags")||"",h=/1/.test(p),g=X.argRole(t,"startAt");if(u)i=X.evaluate(u,r),a=o(i,h,g,!0,r);else{var d=t.getAttribute("level"),v=X.argRole(t,"select"),x=X.argRole(t,"count"),E=X.argRole(t,"from");i=e(d,v,x,E,r),a=o(i,h,g,!1,r)}return null===a?Iter.oneString("NaN"):n(a,s,c,l,f,m,r)}function a(t){if(1>t||t>4999)return t.toString();var e,r="",n=["m","cm","d","cd","c","xc","l","xl","x","ix","v","iv","i"],o=[1e3,900,500,400,100,90,50,40,10,9,5,4,1];for(e=0;e<n.length;e++)for(;t>=o[e];)r+=n[e],t-=o[e];return r}function u(t,e){function r(t){return(t>n?r(Math.floor((t-1)/n)):"")+e.charAt((t-1)%n)}if(1>t)return t.toString();var n=e.length;return r(t)}function s(t,e){return t<e.length?e[t]:t.toString()}function c(t,e){for(var r=Math.abs(t),n=999999>r?r.toString():Big(r).toFixed();n.length<e;)n="0"+n;return 0>t&&(n="-"+n),n}function l(t){var e,r,n=Expr,o=n.stringToCodepoints(t),i={},a=!0,u=0,s=Regex.prepareRegex("\\p{Nd}",null),c=t.search(s);if(0>c)a=!1;else{var l=Regex.obtainCategoryEscapes().Nd;for(r=0;r<l.length;r++){var f=l[r];if(e=parseInt(f[0],16),e<=o[c]&&o[c]<=e+10)break}for(r=0;r<o.length;r++)if(o[r]>=128){var m=String.fromCharCode(o[r]);if(s.test(m)){if(e>o[r]||o[r]>e+10)throw XError("Picture string mixes digits from different digit families: "+t,"FODF1310")}else{var p=Regex.prepareRegex("\\p{N}\\p{L}",null);if(p.test(m))throw XError("Picture string is invalid: "+t,"FODF1310")}}var h=[];u=e-48,o.forEach(function(t){t>=e&&e+10>=t?h.push(48):h.push(t)}),t=n.codepointsToString(h)}return i.isDecimalDigitPattern=a,i.format=t,i.diff=u,i.zeroDigit=e,i}function f(t,e){var r=[];return Expr.stringToCodepoints(t).forEach(function(t){t>=48&&57>=t?r.push(t+e):r.push(t)}),Expr.codepointsToString(r)}function m(t,e,r,n,o){var i,a=0,u=t;for(i=0;i<u.length;i++)if(i==e[a]){var s=o?i+1:u.length-i;s>0&&(u=u.substring(0,s)+(r?r[o?a:r.length-a-1]:n)+u.substring(s)),a++}return u}function p(t,e){function r(t,e){if(!/^(([0-9]|#|[^A-Za-z0-9])+?)$/.test(e))throw XError("The decimal digit pattern in the picture string is invalid: "+e,"FODF1310");var r,n,o=e,i=!0;if(/[^0-9A-Za-z#]/.test(o)){if(r=o.match(/[^0-9A-Za-z#]/g),r.length>1)for(n=1;n<r.length;n++)if(r[0]!=r[n]){i=!1;break}o=o.replace(/[^0-9A-Za-z#]/g,",")}if(/^,|,,|,$/.test(o))throw XError("Grouping in picture string is invalid: "+e,"FODF1310");if(/[0-9].*#/.test(o))throw XError("Picture string is invalid: "+e,"FODF1310");var a=o.replace(/[#,]/g,"").length,u=c(t,a);if(r){var s=Expr.stringToCodepoints(o).reverse(),l=[];for(n=0;n<s.length;n++)44==s[n]&&l.push(n);var f=!0;if(s.length-l[l.length-1]-1>l[0]&&(f=!1),f)for(n=1;n<l.length;n++)if((l[n]+1)%(l[0]+1)!==0){f=!1;break}u=f&&i?Numberer.addGroupingSeparators(u,r[0],l[0]):m(u,l,r)}return u}var n=Expr.stringToCodepoints(e),o=!0,i=!0,a=0;if(n.length!=e.length)throw XError("Cannot handle non-BMP characters in format-integer picture","SXJS0002");if(/^[\x01-\x7f]*$/.test(e)||(o=!1),o)i=/[0-9]/.test(e);else{var u=l(e);e=u.format,i=u.isDecimalDigitPattern,a=u.diff}i||(e="1");var s=r(t,e);return o||(s=f(s,a)),s}function h(t){var e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],r=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"];return 20>t?e[t]:100>t?r[Math.floor(t/10)]+(t%10===0?"":" "+e[t%10]):1e3>t?h(Math.floor(t/100))+" Hundred"+(t%100===0?"":" and "+h(t%100)):1e6>t?h(Math.floor(t/1e3))+" Thousand"+(t%1e3===0?"":(100>t%1e3?" and ":" ")+h(t%1e3)):1e9>t?h(Math.floor(t/1e6))+" Million"+(t%1e3===0?"":(100>t%1e3?" and ":" ")+h(t%1e6)):t.toString()}function g(t){var e=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],r=["","","Twent","Thirt","Fort","Fift","Sixt","Sevent","Eight","Ninet"];return 20>t?e[t]:100>t?r[Math.floor(t/10)]+(t%10===0?"ieth":"y "+e[t%10]):1e3>t?h(Math.floor(t/100))+" Hundred"+(t%100===0?"th":" and "+g(t%100)):1e6>t?h(Math.floor(t/1e3))+" Thousand"+(t%1e3===0?"th":(100>t%1e3?" and ":" ")+g(t%1e3)):1e9>t?h(Math.floor(t/1e6))+" Million"+(t%1e3===0?"th":(100>t%1e3?" and ":" ")+g(t%1e6)):t.toString()}function d(t){return t%10==1&&t%100!=11?"st":t%10==2&&t%100!=12?"nd":t%10==3&&t%100!=13?"rd":"th"}function v(t,e){function r(t,e){for(var r="",n=t.charCodeAt(0),o=0;e>o;n++,o++)r+=String.fromCharCode(n);return r}var n,o=null;if(-1!=(n=e.lastIndexOf(";"))){if(o=e.substring(n+1),!/^([co](\(.+\))?)?[at]?$/.test(o))throw XError("Invalid format modifier in picture string: "+o,"FODF1310");o=o.charAt(0),e=e.substring(0,n)}if(""===e)throw XError("In the picture string, the picture cannot be empty","FODF1310");var i=0>t?"-":"";if("o"==o)switch(e.toString()){case"a":case"A":case"i":case"I":break;case"Ww":return i+g(Math.abs(t));case"W":return i+g(Math.abs(t)).toUpperCase();case"w":return i+g(Math.abs(t)).toLowerCase();default:return p(t,e)+d(Math.abs(t))}switch(e.toString()){case"a":return u(t,r("a",26));case"A":return u(t,r("A",26));case"α":return u(t,r("α",25));case"Α":return u(t,r("Α",25));case"i":return a(t);case"I":return a(t).toUpperCase();case"Ww":return i+h(Math.abs(t));case"W":return i+h(Math.abs(t)).toUpperCase();case"w":return i+h(Math.abs(t)).toLowerCase();case"①":return s(t,"⓪"+r("①",20)+r("㉑",15)+r("㊱",15));case"⑴":return s(t,"0"+r("⑴",20));case"⒈":return s(t,"0"+r("⒈",20));default:return p(t,e)}}function x(t,e,r){var n,o="";for(n=0;n<t.length;n++){var i=t.charAt(n),a=e.indexOf(i);0>a?o+=i:a<r.length&&(o+=r.charAt(a))}return o}function E(t,e){var r=_.getAttribute(t,e,M[e]);return String.fromCharCode(parseInt(r,10))}function S(t,e){function r(t){var e=[["$gs","grouping separator"],["$es","exponent separator"],["$ds","decimal separator"],["$pc","non-prefix passive character"],["$pp","percent|permille"],["$od","optional digit"],["$md","mandatory digit"],["$ip","integer part"],["$fp","fractional part"]];throw e.forEach(function(e){t=t.replace(e[0],e[1])}),XError("Invalid picture: "+t,"FODF1310")}var n,o,i,a={},u=t.indexOf(e.decimalSeparator),s=u>=0,c=e.zeroDigit.charCodeAt(0),l=0,f=0,m=[],p=[],h=[],g=-1,d=-1,v=!1,x=!1,E=-1,S=0,N=s?u:t.length;for(n=0;N>n;n++)i=t.charCodeAt(n),i>=c&&c+10>i?(d>0&&r("digit follows $pc"),v?S++:(1>l&&0>g&&(g=n),l++,f++)):i==e.digit.charCodeAt(0)?(d>0&&r("digit follows $pc"),v&&r("$od follows $es"),l>0&&r("$od follows $md in $ip"),0>g&&(g=n,x=!0),f++):i==e.groupingSeparator.charCodeAt(0)?(0>g&&r("$gs before any digit"),h.length>0&&r("$gs follows $pc"),v&&r("$gs follows $es"),m.push(n)):i==e.percent.charCodeAt(0)||i==e.permille.charCodeAt(0)?s?r("$pp before $ds"):(0>g&&r("$pp before any digit"),d>0&&r("$pp follows $pc"),v&&r("$pp follows $es"),h.push(i),0>d&&(d=n),i==e.percent.charCodeAt(0)?a.percent=!0:a.permille=!0):!s&&g>=0&&i==e.exponentSeparator.charCodeAt(0)&&0>d?v?(h.push(i),S>0?0>d&&(d=n):(h.push(i),v=!1,E=-1,0>d&&(d=n-1))):(v=!0,E=n):g>=0&&s?r("$pc before $ds"):v&&0===S?(v=!1,E=-1,h.push(e.exponentSeparator.charCodeAt(0)),h.push(i),0>d&&(d=n-1)):g>=0?(h.push(i),0>d&&(d=n)):p.push(i);if(m.length>0){var y=s?u:v?E:d>0?d:t.length,A=m.map(function(t){return y-t-1});m=A.reverse()}if(0!==m.length)for(0===m[0]&&r("$gs at end of $ip"),o=0;o<m.length-1;o++)m[o]+1==m[o+1]&&r("consecutive $gs in $ip");var b=0,w=0,T=[];if(s){var I=-1,D=t.substring(u+1);for(n=0;n<D.length;n++)i=D.charCodeAt(n),i>=c&&c+10>i?v&&0>d?S++:I>=0||d>=0?r("$md follows $od or $pc in $fp"):(b++,w++):i==e.digit.charCodeAt(0)?((d>=0||v)&&r("$od follows $pc or $es"),0>I&&(I=n),w++):i==e.groupingSeparator.charCodeAt(0)?((d>=0||v)&&r("$gs follows $pc or $es"),T.push(n-u+1)):i==e.decimalSeparator.charCodeAt(0)?r("more than one $ds"):i==e.percent.charCodeAt(0)||i==e.permille.charCodeAt(0)?((d>=0||v)&&r("$pp follows $pc or $es"),h.push(i),d=n,i==e.percent.charCodeAt(0)?a.percent=!0:a.permille=!0):i==e.exponentSeparator.charCodeAt(0)&&0>d?v?(h.push(i),S>0?0>d&&(d=n):(h.push(i),v=!1,E=-1,0>d&&(d=n-1))):(v=!0,E=n):v&&0===S?(v=!1,E=-1,h.push(e.exponentSeparator.charCodeAt(0)),h.push(i),0>d&&(d=n-1)):(h.push(i),0>d&&(d=n))}if(0>g&&0===w&&r("mantissa contains no digits"),0!==T.length)for(0===T[0]&&r("$gs at beginning of $fp"),o=0;o<T.length-1;o++)T[o]+1==T[o+1]&&r("consecutive $gs in $fp");return 0===l&&0===w&&(v?(b=1,w=1):l=1),v&&0===l&&x&&(l=1),0===l&&0===b&&(b=1),a.minimumIntegerPartSize=l,a.prefix=p,a.intGpPos=m,a.picIntPartContainsOptDigit=x,a.picIntPartSize=f,a.minimumFractionalPartSize=b,a.maximumFractionalPartSize=w,a.fracGpPos=T,a.expPartSize=S,a.suffix=h,a}function N(t,e){var r=["January","February","March","April","May","June","July","August","September","October","November","December"],n=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];return"M"==e?r[t-1]:"F"==e?n[t-1]:t}function y(t){var e=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.floor((t.getTime()-e.getTime())/864e5)+1}function A(t,e){var r=e?y(t):t.getUTCDate(),n=new Date(Date.UTC(t.getUTCFullYear(),e?0:t.getUTCMonth(),1)),o=n.getUTCDay();if(0===o&&(o=7),o>4&&8>=o+r)return A(new Date(n.getTime()-864e5),e);var i=5>o?1:0;return Math.floor((r+o-2)/7)+i}function b(t){return A(t,!0)}function w(t){return A(t,!1)}function T(t){return t.getUTCHours()<13?0===t.getUTCHours()?12:t.getUTCHours():t.getUTCHours()-12}function I(t){return t.getUTCHours()<12?"Am":"Pm"}function D(t,e,r,n,o,i,a){if(""===t)return"Z"==r?"J":"";var u="z"==e?"GMT":"";if("t"==n&&"+00:00"==t&&"Z"!=r&&"N"!=r)return"Z";if(""===r)return u+t;var s,c=t.match(/^([+\-])([0-9])([0-9]):([0-9]{2})$/);if("Z"==r||"N"==r){if("Z"==r){var m=parseInt(c[1]+c[2]+c[3],10);s=-12>m||m>12||"00"!=c[4]?t:"YXWVUTSRQPONZABCDEFGHIKLM".charAt(m+12)}else if("N"==r)throw XError("Timezone names not implemented","SXJS0002")}else{a&&!/[0-9]+/.test(r)&&(r="00:00");var p=function(t,e){return"0"==e[2]&&1==t.length?e[3]:e[2]+e[3]},h=function(t,e){var r="0"!=e[2]||1!=t.length&&3!=t.length?e[2]+e[3]:e[3],n=t.length>2?e[4]:"00"!=e[4]?":"+e[4]:"";return r+n},g=0;if(!a){var d=l(r);r=d.format,g=d.diff}var v;/[^0-9A-Za-z]/.test(r)?(v=r.match(/^([0-9]+)([^0-9A-Za-z])([0-9]+)$/),s=c[1]+p(v[1],c)+v[2]+c[4]):(v=r.match(/^[0-9]+$/),s=c[1]+h(v[0],c)),a||(s=f(s,g))}return u+s}function C(t,e,r,n,o,i){function a(t,e,r,n,o){var i,a=0;if(!o){var u=l(e);e=u.format,a=u.diff}for(var s=t.toString();s.length<3;)s="0"+s;var c=Expr.stringToCodepoints(s),m=parseInt(Expr.codepointsToString(c.reverse()),10);if(!r&&!n&&/^[0-9]$/.test(e))for(;c.length>e.length;)e+="#";if(r&&"*"!=r){for(var p=/^([0-9]*)(#*)$/.exec(e),h=p[1]?p[1]:"",g=p[2]?p[2]:"";r>h.length;)h+="0",g=g.slice(0,-1);e=h+g}if(n)for("*"==n&&(n=c.length);e.length<n;)e+="#";
var d=Expr.codepointsToString(Expr.stringToCodepoints(e).reverse()),x=v(m,d);for(i=Expr.codepointsToString(Expr.stringToCodepoints(x).reverse());i.length>e.length;)i=i.slice(0,-1);return r&&"*"!=r||0!==parseInt(i,10)||(i="0"),o||(i=f(i,a)),i}var u,s=r.match(/^([YMDdWwFHhmsfZzPCE])(.*)$/);if(null===s)throw XError("Date/time component ["+r+"] not recognised","FOFD1340");var c=s[1],m=s[2]||"";if("date"==t&&/[HhPmsf]/.test(c)||"time"==t&&/[YMDdFWwCE]/.test(c))throw XError("Date/time component ["+r+"] not available in "+t,"FOFD1350");var p,h,g;if(-1!=(p=m.lastIndexOf(","))){var d=m.substring(p+1).split("-");if(m=m.substring(0,p),h=d[0],g=d[1]||"*","*"!=h&&1>h||"*"!=g&&1>g||"*"!=h&&"*"!=g&&h>g)throw XError("Invalid width modifier in date/time formatting picture","FOFD1340")}var x,E=null;m.length>1&&/[atco]/.test(m.charAt(m.length-1))?(x=m.substring(0,m.length-1),E=m.charAt(m.length-1)):x=m;var S=!0;if(/^[\x01-\x7f]*$/.test(x));else{if(x.length!=Expr.stringToCodepoints(x).length)throw XError("Cannot handle non-BMP characters in date/time formatting picture","SXJS0002");S=!1}if(/[Zz]/.test(c)){var y="Z"==e.tzOffsetToString()?"+00:00":e.tzOffsetToString();return D(y,c,x,E,h,g,S)}var A=e.proxy(),b=F[c]?A[F[c]]():P[c]?P[c](A):null;if(null===b)throw XError("Component specifier not implemented: ["+c+"]","SXJS0002");if("M"==c?b++:"F"==c&&0===b&&(b=7),""===x&&(x=/[FPCE]/.test(c)?"n":/[ms]/.test(c)?"01":"1"),"f"==c)return a(b,x,h,g,S);if(/[nN]/.test(x))u=N(b,c),"n"==x?u=u.toLowerCase():"N"==x&&(u=u.toUpperCase()),g&&"*"!=g&&u.length>g&&(u=u.substring(0,g));else{var w=/;/.test(x)?x+";":x;if(E&&(w+=(";"==w.charAt(w.length-1)?"":";")+E),u=v(b,w),"Y"==c&&/[^iIwWnN]/.test(x.charAt(x.length-1))&&(!h&&2==x.length||2==g))for(;u.length>2;)u=u.substring(1);if(h){var T="*"==h?0:parseInt(h,10);if(T>0&&u.length<T)if(/[YMDdWwHhms]/.test(c)&&/[^iIwWnN]/.test(x.charAt(x.length-1))){var I="0";for(S||(I=String.fromCharCode(l(w).zeroDigit));u.length<T;)u=I+u}else{if("Y"!=c||!/[iIwWnN]/.test(x.charAt(x.length-1)))throw XError("Not implemented min width modification with specifier "+c+" and format "+x,"SXJS0002");for(;u.length<T;)u+=" "}}}return u}function O(t,e,r,n){var o=0>t?!0:0===t?0>1/t:!1,i=n.fixed.decimalFormats[null!==r?r:"Q{}"];if(!i)throw XError("Unknown decimal format "+r,"FODF1280");var a={decimalSeparator:E(i,"decimal-separator"),groupingSeparator:E(i,"grouping-separator"),digit:E(i,"digit"),minusSign:E(i,"minus-sign"),percent:E(i,"percent"),permille:E(i,"per-mille"),zeroDigit:E(i,"zero-digit"),exponentSeparator:E(i,"exponent-separator"),patternSeparator:E(i,"pattern-separator"),infinity:_.getAttribute(i,"infinity",M.infinity),nan:_.getAttribute(i,"NaN",M.NaN)};if(isNaN(t))return a.nan;var u=e.includes(a.patternSeparator)?e.split(a.patternSeparator):[e];if(u.length>2)throw XError("Invalid picture: multiple pattern separators","FODF1310");var s,c,l=u.length>1&&0>t?u[1]:u[0],f=S(l,a);if(isFinite(t)){var p;if(f.expPartSize>0)p=U(t,f);else{var h=Math.abs(t);f.percent&&(h=Math.abs(100*t)),f.permille&&(h=Math.abs(1e3*t)),p=h+""=="Infinity"?h+"":999999>h?h.toString():Big(h).toFixed();var g=p.indexOf(".");0>g&&(g=p.length,f.minimumFractionalPartSize>0&&(p+=".")),f.maximumFractionalPartSize>=0&&"."!=p.substring(g)&&g!=p.length&&(f.maximumFractionalPartSize>0?(c=Big(p.substring(g)).round(f.maximumFractionalPartSize,1),p=p.substring(0,g)+c.toString().substring(1)):p=Big(p).round(0,1).toString());var d=p.length-1-g;if(f.minimumFractionalPartSize>0)for(;d<f.minimumFractionalPartSize;)p+="0",d++;for(;g<f.minimumIntegerPartSize;)p="0"+p,g++;d>0&&0===f.minimumIntegerPartSize&&"0"==p.substring(0,g)&&(p=p.substring(g)),"0"==p&&0===f.minimumIntegerPartSize&&0===f.minimumFractionalPartSize&&f.maximumFractionalPartSize>0&&(p=".0")}var v,N="";for(v=0;10>v;v++)N+=String.fromCharCode(a.zeroDigit.charCodeAt(0)+v);if(N+=a.decimalSeparator,s=x(p,"0123456789.",N),f.intGpPos.length>0||f.fracGpPos.length>0){var y=s.indexOf(a.decimalSeparator);0>y&&(y=s.length);var A=s.substring(0,y);if(c=s.substring(y),f.intGpPos.length>0){for(var b=!0,w=1;w<f.intGpPos.length;w++)if((f.intGpPos[w]+1)%(f.intGpPos[0]+1)!==0){b=!1;break}b&&f.picIntPartSize+f.intGpPos.length-f.intGpPos[f.intGpPos.length-1]-1>f.intGpPos[0]&&(b=!1),A=b?Numberer.addGroupingSeparators(A,a.groupingSeparator,f.intGpPos[0]):m(A,f.intGpPos,null,a.groupingSeparator)}f.fracGpPos.length>0&&(c=m(c,f.fracGpPos,null,a.groupingSeparator,!0)),s=A+c}}else s=a.infinity;return f.prefix.length>0&&(s=Expr.codepointsToString(f.prefix)+s),f.suffix.length>0&&(s+=Expr.codepointsToString(f.suffix)),o&&1==u.length&&(s=a.minusSign+s),s}function U(t,e){var r=e.minimumIntegerPartSize,n=e.minimumFractionalPartSize,o=e.maximumFractionalPartSize;1==r&&e.picIntPartContainsOptDigit&&(r=0,0===n&&(n=1,0===o&&(o=1)));var i=e.expPartSize,a=Big(t),u=a.c,s=0!==r?r+n:n,l=0!==r?r+o:o;for(u.length>l&&(a=Big(a.toPrecision(l))),r>1?a=a.div(Big(10).pow(r-1)):0===r&&(a=a.times(Big(10))),u=a.c;u.length<s;)u.push(0);var f="";if(!(u.length>0))throw XError("Empty mantissa","SXJS0004");if(0===r&&e.picIntPartContainsOptDigit)f+="0";else for(var m=0;r>m;m++)f+=u[m];return o>0&&u.length>r&&(f+="."+u.join("").slice(r)),f+"e"+c(a.e,i)}var X=Expr,_=DomUtils,M={"decimal-separator":"46","grouping-separator":"44",digit:"35","minus-sign":"45",percent:"37","per-mille":"8240","zero-digit":"48","exponent-separator":"101","pattern-separator":"59",infinity:"Infinity",NaN:"NaN"},F={Y:"getUTCFullYear",M:"getUTCMonth",D:"getUTCDate",F:"getUTCDay",H:"getUTCHours",m:"getUTCMinutes",s:"getUTCSeconds",f:"getUTCMilliseconds"},P={d:y,W:b,w:w,h:T,P:I,E:function(){return"AD"}};return{xslNumber:i,nodeNum:t,numSeqFmt:r,formatInteger:v,addGroupingSeparators:function(t,e,r){var n,o="";for(n=0;n<t.length;n++)o+=t.charAt(n),(1==r||(t.length-n)%r==1)&&n<t.length-1&&(o+=e);return o},formatNumber:O,formatDateTime:function(t,e,r,n,o,i){function a(r){return"[["==r?"[":"]]"==r?"]":C(t,e,r.substring(1,r.length-1).replace(/\s+/g,""),n,o,i)}if(!/\[(\[|[^\]]*\])|\]\]/g.test(r))throw XError("Date format picture doesn't match required syntax","FOFD1340");return r.replace(/\[(\[|[^\]]*\])|\]\]/g,a)}}}();!function(t){"use strict";function e(){function t(r){var o=this;return o instanceof t?(r instanceof t?(o.s=r.s,o.e=r.e,o.c=r.c.slice()):n(o,r),void(o.constructor=t)):void 0===r?e():new t(r)}return t.prototype=p,t.DP=u,t.RM=s,t.E_NEG=f,t.E_POS=m,t}function r(t,e,r){var n=t.constructor,i=e-(t=new n(t)).e,a=t.c;for(a.length>++e&&o(t,i,n.RM),a[0]?r?i=e:(a=t.c,i=t.e+i+1):++i;a.length<i;a.push(0));return i=t.e,1===r||r&&(i>=e||i<=n.E_NEG)?(t.s<0&&a[0]?"-":"")+(a.length>1?a[0]+"."+a.join("").slice(1):a[0])+(0>i?"e":"e+")+i:t.toString()}function n(t,e){var r,n,o;for(0===e&&0>1/e?e="-0":h.test(e+="")||i(NaN),t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(0>r&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):0>r&&(r=e.length),n=0;"0"==e.charAt(n);n++);if(n==(o=e.length))t.c=[t.e=0];else{for(;"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;o>=n;t.c[r++]=+e.charAt(n++));}return t}function o(t,e,r,n){var o,a=t.c,u=t.e+e+1;if(1===r?n=a[u]>=5:2===r?n=a[u]>5||5==a[u]&&(n||0>u||a[u+1]!==o||1&a[u-1]):3===r?n=n||a[u]!==o||0>u:(n=!1,0!==r&&i("!Big.RM!")),1>u||!a[0])n?(t.e=-e,t.c=[1]):t.c=[t.e=0];else{if(a.length=u--,n)for(;++a[u]>9;)a[u]=0,u--||(++t.e,a.unshift(1));for(u=a.length;!a[--u];a.pop());}return t}function i(t){var e=new Error(t);throw e.name="BigError",e}var a,u=20,s=1,c=1e6,l=1e6,f=-7,m=21,p={},h=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;p.abs=function(){var t=new this.constructor(this);return t.s=1,t},p.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,u=r.e,s=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=0>i,u!=s)return u>s^e?1:-1;for(i=-1,a=(u=n.length)<(s=o.length)?u:s;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return u==s?0:u>s^e?1:-1},p.div=function(t){var e=this,r=e.constructor,n=e.c,a=(t=new r(t)).c,u=e.s==t.s?1:-1,s=r.DP;if((s!==~~s||0>s||s>c)&&i("!Big.DP!"),!n[0]||!a[0])return n[0]==a[0]&&i(NaN),a[0]||i(u/0),new r(0*u);var l,f,m,p,h,g,d=a.slice(),v=l=a.length,x=n.length,E=n.slice(0,l),S=E.length,N=t,y=N.c=[],A=0,b=s+(N.e=e.e-t.e)+1;for(N.s=u,u=0>b?0:b,d.unshift(0);S++<l;E.push(0));do{for(m=0;10>m;m++){if(l!=(S=E.length))p=l>S?1:-1;else for(h=-1,p=0;++h<l;)if(a[h]!=E[h]){p=a[h]>E[h]?1:-1;break}if(!(0>p))break;for(f=S==l?a:d;S;){if(E[--S]<f[S]){for(h=S;h&&!E[--h];E[h]=9);--E[h],E[S]+=10}E[S]-=f[S]}for(;!E[0];E.shift());}y[A++]=p?m:++m,E[0]&&p?E[S]=n[v]||0:E=[n[v]]}while((v++<x||E[0]!==g)&&u--);return y[0]||1==A||(y.shift(),N.e--),A>b&&o(N,s,r.RM,E[0]!==g),N},p.eq=function(t){return!this.cmp(t)},p.gt=function(t){return this.cmp(t)>0},p.gte=function(t){return this.cmp(t)>-1},p.lt=function(t){return this.cmp(t)<0},p.lte=function(t){return this.cmp(t)<1},p.sub=p.minus=function(t){var e,r,n,o,i=this,a=i.constructor,u=i.s,s=(t=new a(t)).s;if(u!=s)return t.s=-s,i.plus(t);var c=i.c.slice(),l=i.e,f=t.c,m=t.e;if(!c[0]||!f[0])return f[0]?(t.s=-s,t):new a(c[0]?i:0);if(u=l-m){for((o=0>u)?(u=-u,n=c):(m=l,n=f),n.reverse(),s=u;s--;n.push(0));n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,u=s=0;r>s;s++)if(c[s]!=f[s]){o=c[s]<f[s];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(s=(r=f.length)-(e=c.length))>0)for(;s--;c[e++]=0);for(s=e;r>u;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];c[e]=9);--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--s];c.pop());for(;0===c[0];)c.shift(),--m;return c[0]||(t.s=1,c=[m=0]),t.c=c,t.e=m,t},p.mod=function(t){var e,r=this,n=r.constructor,o=r.s,a=(t=new n(t)).s;return t.c[0]||i(NaN),r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=a,e?new n(r):(o=n.DP,a=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=a,this.minus(r.times(t)))},p.add=p.plus=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(o!=i)return t.s=-i,r.minus(t);var a=r.e,u=r.c,s=t.e,c=t.c;if(!u[0]||!c[0])return c[0]?t:new n(u[0]?r:0*o);if(u=u.slice(),o=a-s){for(o>0?(s=a,e=c):(o=-o,e=u),e.reverse();o--;e.push(0));e.reverse()}for(u.length-c.length<0&&(e=c,c=u,u=e),o=c.length,i=0;o;)i=(u[--o]=u[o]+c[o]+i)/10|0,u[o]%=10;for(i&&(u.unshift(i),++s),o=u.length;0===u[--o];u.pop());return t.c=u,t.e=s,t},p.pow=function(t){var e=this,r=new e.constructor(1),n=r,o=0>t;for((t!==~~t||-l>t||t>l)&&i("!pow!"),t=o?-t:t;1&t&&(n=n.times(e)),t>>=1,t;)e=e.times(e);return o?r.div(n):n},p.round=function(t,e){var r=this,n=r.constructor;return null==t?t=0:(t!==~~t||0>t||t>c)&&i("!round!"),o(r=new n(r),t,null==e?n.RM:e),r},p.sqrt=function(){var t,e,r,n=this,a=n.constructor,u=n.c,s=n.s,c=n.e,l=new a("0.5");if(!u[0])return new a(n);0>s&&i(NaN),s=Math.sqrt(n.toString()),0===s||s===1/0?(t=u.join(""),t.length+c&1||(t+="0"),e=new a(Math.sqrt(t).toString()),e.e=((c+1)/2|0)-(0>c||1&c)):e=new a(s.toString()),s=e.e+(a.DP+=4);do r=e,e=l.times(r.plus(n.div(r)));while(r.c.slice(0,s).join("")!==e.c.slice(0,s).join(""));return o(e,a.DP-=4,a.RM),e},p.mul=p.times=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,u=i.length,s=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return new n(0*t.s);for(t.e=s+c,u>a&&(e=o,o=i,i=e,c=a,a=u,u=c),e=new Array(c=a+u);c--;e[c]=0);for(s=u;s--;){for(u=0,c=a+s;c>s;)u=e[c]+i[s]*o[c-s-1]+u,e[c--]=u%10,u=u/10|0;e[c]=(e[c]+u)%10}for(u&&++t.e,e[0]||e.shift(),s=e.length;!e[--s];e.pop());return t.c=e,t},p.toString=p.valueOf=p.toJSON=function(){var t=this,e=t.constructor,r=t.e,n=t.c.join(""),o=n.length;if(r<=e.E_NEG||r>=e.E_POS)n=n.charAt(0)+(o>1?"."+n.slice(1):"")+(0>r?"e":"e+")+r;else if(0>r){for(;++r;n="0"+n);n="0."+n}else if(r>0)if(++r>o)for(r-=o;r--;n+="0");else o>r&&(n=n.slice(0,r)+"."+n.slice(r));else o>1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&t.c[0]?"-"+n:n},p.toExponential=function(t){return null==t?t=this.c.length-1:(t!==~~t||0>t||t>c)&&i("!toExp!"),r(this,t,1)},p.toFixed=function(t){var e,n=this,o=n.constructor,a=o.E_NEG,u=o.E_POS;return o.E_NEG=-(o.E_POS=1/0),null==t?e=n.toString():t===~~t&&t>=0&&c>=t&&(e=r(n,n.e+t),n.s<0&&n.c[0]&&e.indexOf("-")<0&&(e="-"+e)),o.E_NEG=a,o.E_POS=u,e||i("!toFix!"),e},p.toPrecision=function(t){return null==t?this.toString():((t!==~~t||1>t||t>c)&&i("!toPre!"),r(this,t-1,2))},a=e(),"function"==typeof define&&define.amd?define(function(){return a}):"undefined"!=typeof module&&module.exports?module.exports=a:t.Big=a}(this);var ConvertJson=function(){"use strict";function t(t,e,r,n,o){var i=Atomic.string.fromString(e);if(t&&t.containsKey(i)){var a=t.get(i);if("function"==r)throw XError("Option "+i+" must be a function","XPTY0004");if(1==a.length&&Atomic[r].matches(a[0])){if(o&&o.indexOf(a[0].value)<0)throw XError("Invalid value "+i+"="+a[0],"FOJS0005");return a[0].value}throw XError("Invalid option: "+e+": must be "+r,"XPTY0004")}return n}function e(t,e,r){function n(t){throw XError(t,"FOJS0001")}function o(){return h=i()}function i(){var e,r;for(h="";;){if(p>=t.length)return["eof"];if(r=t.charAt(p++),!/[ \n\r\t]/.test(r))break}switch(r){case"[":case"{":case"]":case"}":case":":case",":return[r];case'"':for(var o=!1;;){if(e=t.charAt(p++),'"'==e&&!o)return["string",h];h+=e,o="\\"==e&&!o,p>=t.length&&n("Unclosed quotes in string literal")}return["string",h];case"-":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(h+=r;p<t.length;){if(e=t.charAt(p++),!/[0-9\-+\.eE]/.test(e)){p--;break}h+=e}return["number",a(h)];case"t":case"f":case"n":for(h+=r;;){if(e=t.charAt(p),!(e>="a"&&"z">=e))break;if(h+=e,++p>=t.length)break}if(/^(true|false|null)$/.test(h))return[h];n("Unknown constant "+h);break;default:return n("Unexpected character '"+r+"' ("+Expr.stringToCodepoints(r)+") at position "+p),-1}}function a(t){return/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(t)?t:n("Invalid JSON number "+t)}function u(t){h[0]!==t&&n("Expected "+t+", found "+h[0])}function s(t){return h[0]===t?(o(),!0):!1}function c(t){return h[0]===t?(o(),!0):","===h[0]?(o(),!1):void n("Expected ',' or '"+t+"', found '"+h[0]+"'")}function l(){switch(h[0]){case"[":o(),f();break;case"{":o(),m();break;case"string":r.emitString(h[1]),o();break;case"number":r.emitNumber(h[1]),o();break;case"true":case"false":r.emitBoolean(h[0]),o();break;case"null":r.emitNull(),o();break;default:n("Unexpected token "+h[0])}}function f(){if(r.startArray(),!s("]"))do l();while(!c("]"));r.endArray()}function m(){if(r.startMap(),!s("}"))do u("string"),r.emitKey(h[1]),o(),u(":"),o(),l();while(!c("}"));r.endMap()}var p=0,h=o();return l(),u("eof"),r.result()}function r(t){try{return JSON.parse('"'+t+'"')}catch(e){throw XError(e.toString(),"FOJS0001")}}function n(t){return t.replace(c,"�").replace(/[\uD800-\uDFFF]+/g,function(t){for(var e="",r=0;r<t.length;r++){var n=t.charAt(r);e+=r%2=="�">n||r==t.length-1&&"�">n?"�":n}return e})}function o(t){for(var e=t.charCodeAt(0).toString(16);e.length<4;)e="0"+e;return"\\u"+e.toUpperCase()}function i(e){this._valStack=[],this._keyStack=[],t(e,"liberal","boolean",!1),this._escape=t(e,"escape","boolean",!1),this._duplicates=t(e,"duplicates","string","use-first",["reject","use-first","use-last"])}function a(e,r){this._valStack=[],this._keyStack=[],this._mapStack=[],this._context=r,t(e,"liberal","boolean",!1),t(e,"validate","boolean",!1),t(e,"fallback","function"),this._escape=t(e,"escape","boolean",!1),this._duplicates=t(e,"duplicates","string","use-first",["reject","use-first","retain"])}function u(e,n){function i(t){throw new XError("Invalid input to xml-to-json(): "+t,"FOJS0006")}function a(t){0!==m.getChildElements(t).length&&i("node "+t.tagName+" must have no element children")}function u(t){Axis.child(t).filter(function(t){return t.nodeType==m.TEXT_NODE&&t.nodeValue&&""!==Regex.trim(t.nodeValue)}).next()&&i("node "+t.tagName+" must have no text content")}function c(t){try{return Atomic["boolean"].fromString(t).toBoolean()}catch(e){i("invalid boolean: '"+t+"'")}}function l(t){try{JSON.parse('"'+t+'"')}catch(e){throw XError("invalid escape sequence: "+e.toString(),"FOJS0007")}}function f(t){if(t.nodeType==m.DOCUMENT_NODE||t.nodeType==m.DOCUMENT_FRAGMENT_NODE){var e=m.getChildElements(t);return 1!=e.length&&i("document node has "+e.length+" element children"),f(e[0])}if(t.nodeType==m.ELEMENT_NODE){var n=!1;if(t.namespaceURI==s)switch(Axis.attribute(t).forEachItem(function(e){if(e.name.indexOf(":")<0||e.namespaceURI==s)if("key"==e.name||"escaped-key"==e.name){if(m.xdmParentNode(t)&&"map"==m.xdmParentNode(t).localName||i("@key/@escaped-key are allowed only on children of map"),"escaped-key"==e.name){var r=c(e.value);r&&l(t.getAttribute("key"))}}else"escaped"==e.name?("string"!=t.localName&&i("@escaped is allowed only on string"),n=c(e.value)):i("invalid attribute "+e.name)}),!t.hasAttribute("key")&&!t.hasAttribute("escaped-key")||m.xdmParentNode&&"map"!=m.xdmParentNode.localName||i("key/escaped-key are allowed only on children of map"),t.localName){case"null":return Axis.child(t).filter(function(t){return t.nodeType!=m.COMMENT_NODE&&t.nodeType!=m.PROCESSING_INSTRUCTION_NODE}).next()&&i("null element must have no content"),"null";case"string":a(t);var p=t.textContent;return n?(p=p.replace(/^"/g,'\\"').replace(/^[\b]/g,"\\b").replace(/^\f/g,"\\f").replace(/^\n/g,"\\n").replace(/^\r/g,"\\r").replace(/^\t/g,"\\t").replace(/^\//g,"\\/").replace(/([^\\])"/g,'$1\\"').replace(/([^\\])[\b]/g,"$1\\b").replace(/([^\\])\f/g,"$1\\f").replace(/([^\\])\n/g,"$1\\n").replace(/([^\\])\r/g,"$1\\r").replace(/([^\\])\t/g,"$1\\t").replace(/([^\\])\//g,"$1\\/").replace(/[\u0001-\u001F\u007F-\u009F]/g,o),l(p),'"'+p+'"'):JSON.stringify(p).replace(/\//g,"\\/");case"number":a(t);var h;try{h=Atomic["double"].fromString(t.textContent)}catch(g){i("invalid number")}return isFinite(h.toNumber())||i("NaN and INF not allowed"),h.toString();case"boolean":return a(t),c(t.textContent),Atomic["boolean"].fromString(t.textContent).toString();case"array":u(t);var d="[",v="";return m.getChildElements(t).forEach(function(t){d+=v+f(t),v=","}),d+"]";case"map":u(t);var x="{",E="",S={};return m.getChildElements(t).forEach(function(t){t.hasAttribute("key")||i("child element of map must have a key");var e=m.getAttribute(t,"key"),n=e,o=m.getAttribute(t,"escaped-key"),a=!1;o&&c(o)&&(a=!0,n=r(e)),S[n]&&i("duplicate key '"+e+"'"),S[n]=!0,x+=E+(a?'"'+e+'"':JSON.stringify(e).replace(/\//g,"\\/"))+":"+f(t),E=","}),x+"}";default:i("unknown local name "+t.localName)}else i("wrong namespace "+t.namespaceURI)}else m.isNode(t)||(print("Not a node "+showValue(t)),i("not a node")),Error.dumpStack(),i("wrong node kind "+t.nodeType)}var m=DomUtils;return t(n,"indent","boolean",!1),f(e)}var s="http://www.w3.org/2005/xpath-functions",c=/[\x00-\x08\x0B\x0C\x0E-\x0F\x80-\x9F]/;return i.prototype={_valStack:[],_keyStack:[],_optionsMap:{},_escape:!1,_duplicates:"use-first",reEscape:function(t){return this._escape?JSON.stringify(t).replace(/^"|"$/g,"").replace(/\\"/g,'"').replace(/[\uD800-\uDFFF]/g,o):n(t)},peek:function(){return this._valStack[this._valStack.length-1]},writeItem:function(t){if(0===this._valStack.length)this._valStack.push(t);else if(this.peek()instanceof Expr.XdmArray)this.peek().value.push(t);else{var e=this.peek(),r=Atomic.string.fromString(this._keyStack.pop());if(e.containsKey(r))switch(this._duplicates){case"reject":throw XError("json-to-xml: duplicate key '"+r.toString()+"'","FOJS0003");case"use-first":return}e.inSituPut(r,t)}},emitNull:function(){this.writeItem([])},emitBoolean:function(t){this.writeItem([Atomic["boolean"].fromString(t)])},emitNumber:function(t){this.writeItem([Atomic["double"].fromNumber(parseFloat(t))])},emitString:function(t){this.writeItem([Atomic.string.fromString(this.reEscape(r(t)))])},emitKey:function(t){this._keyStack.push(this.reEscape(r(t)))},startArray:function(){this._valStack.push(new Expr.XdmArray([]))},endArray:function(){this.writeItem([this._valStack.pop()])},startMap:function(){this._valStack.push(new HashTrie)},endMap:function(){this.writeItem([this._valStack.pop()])},result:function(){return void 0!==this.peek()[0]?this.peek()[0]:null}},a.prototype={_valStack:[],_keyStack:[{}],_mapStack:[],_context:null,_optionsMap:{},_escape:!1,_duplicates:"use-first",reEscape:function(t){return this._escape?JSON.stringify(t).replace(/^"|"$/g,"").replace(/\\"/g,'"').replace(/[\uD800-\uDFFF]/g,o):n(t)},peek:function(){return this._valStack[this._valStack.length-1]},writeItem:function(t){if(0===this._valStack.length)t.setAttributeNS("","xmlns",s),this._valStack.push(t);else{var e=this.peek();if("map"==e.tagName){var r=this._keyStack.pop(),n=this._mapStack[this._mapStack.length-1];if(r in n)switch(this._duplicates){case"reject":throw XError("parse-json: duplicate key '"+r.toString()+"'","FOJS0003");case"use-first":return}n[r]=t,t.setAttribute("key",r),this._escape&&/\\/.test(r.toString())&&t.setAttribute("escaped-key","true")}e.appendChild(t)}},emitNull:function(){var t=this._context.resultDocument.createElementNS(s,"null");this.writeItem(t)},emitBoolean:function(t){var e=this._context.resultDocument.createElementNS(s,"boolean"),r=this._context.resultDocument.createTextNode(t.toString());e.appendChild(r),this.writeItem(e)},emitNumber:function(t){var e=this._context.resultDocument.createElementNS(s,"number"),r=this._context.resultDocument.createTextNode(t.toString());e.appendChild(r),this.writeItem(e)},emitString:function(t){var e=this._context.resultDocument.createElementNS(s,"string");if(""!==t){var n=this.reEscape(r(t)),o=this._context.resultDocument.createTextNode(n);this._escape&&/\\/.test(n)&&e.setAttribute("escaped","true"),e.appendChild(o)}this.writeItem(e)},emitKey:function(t){this._keyStack.push(this.reEscape(r(t)))},startArray:function(){var t=this._context.resultDocument.createElementNS(s,"array");this._valStack.push(t)},endArray:function(){this.writeItem(this._valStack.pop())},startMap:function(){var t=this._context.resultDocument.createElementNS(s,"map");this._valStack.push(t),this._mapStack.push({})},endMap:function(){this._mapStack.pop(),this.writeItem(this._valStack.pop())},result:function(){return this.peek()}},{parseToMap:function(t,r){return e(t,r,new i(r))},parseToXml:function(t,r,n){return e(t,r,new a(r,n))},xmlToJson:u}}(),platform={},inBrowser="undefined"!=typeof window,saxonVersion=null,spaceStripper=null,relocatable,timeStamp=inBrowser&&window.performance&&window.performance.now?window.performance.now:function(){return Date.now().valueOf()};Context.prototype={depth:0,focus:null,resultDocument:null,tempOutputState:!1,fixed:{},localParams:{},tunnelParams:{},currentTemplate:null,currentMode:null,currentError:null,currentEvent:null,currentGroup:null,currentGroupingKey:null,localVars:[],toString:function(){var t="{";for(var e in this.localParams)this.localParams.hasOwnProperty(e)&&(t+=e+":("+this.localParams[e]+"),");return t+="}","context: "+this.focus.current+" localParams: "+t},newContext:function(t){var e=this,r=new Context;return r.depth=e.depth+1,r.focus=e.focus,r.resultDocument=e.resultDocument,r.currentMode=e.currentMode,r.currentTemplate=e.currentTemplate,r.currentError=e.currentError,r.currentGroup=e.currentGroup,r.currentGroupingKey=e.currentGroupingKey,r.fixed=e.fixed,r.tempOutputState=e.tempOutputState,r.currentEvent=e.currentEvent,t?(r.localParams={},r.tunnelParams={},r.localVars=[]):(r.localParams=e.localParams,r.tunnelParams=e.tunnelParams,r.localVars=e.localVars),r},clearGrouping:function(){this.currentGroup=null,this.currentGroupingKey=null},createElement:function(t,e){var r;return r=""!==t&&"http://www.w3.org/1999/xhtml"!=t||!inBrowser||this.resultDocument!=window.document?this.resultDocument.createElementNS(t,e):this.resultDocument.createElement(e)},createAttribute:function(t,e){return new AttributeNode(new Atomic.QName.fromEQName("Q{"+t+"}"+e),null,null)},createAttributeFromQName:function(t){return new AttributeNode(t,null,null)}};var XPath=function(){function load(){var content=SaxonJS.getPlatform().readResource("lib/xpath/XPathJS.min.js");content+="XPath;",SaxonJS.XPath=eval(content)}return{parse:function(){return load(),SaxonJS.XPath.parse.apply(null,arguments)},compile:function(){return load(),SaxonJS.XPath.compile.apply(null,arguments)},evaluate:function(){return load(),SaxonJS.XPath.evaluate.apply(null,arguments)},evaluateXDM:function(){return load(),SaxonJS.XPath.evaluateXDM.apply(null,arguments)},setStaticContext:function(){return load(),SaxonJS.XPath.setStaticContext.apply(null,arguments)}}}();return initialize(),{transform:transform,getProcessorInfo:getProcessorInfo,setPlatform:setPlatform,getPlatform:function(){return platform},getNavigator:function(){return window.navigator.userAgent},timeStamp:timeStamp,getSpaceStripper:function(){return spaceStripper},internalTransform:applyStylesheet,U:{Atomic:Atomic,Axis:Axis,Context:Context,nameOfNode:DomUtils.nameOfNode,isNode:DomUtils.isNode,isAttr:DomUtils.isAttr,isNamespaceNode:DomUtils.isNSNode,declareNS:DomUtils.declareNS,isMap:Expr.isMap,isArray:Expr.isArray,ForArray:Iter.ForArray,AnyIterator:Iter.AnyIterator,obtainDocumentNumber:DomUtils.obtainDocumentNumber,evaluate:Expr.evaluate,Iter:Iter,convertFromJS:Expr.convertFromJS,convertToJS:Expr.convertToJS,stringToCodepoints:Expr.stringToCodepoints},XError:XError,XPath:XPath}}();if("function"==typeof require){var DOMImplementation=require("xmldom").DOMImplementation,Node=require("xmldom").Node,Document=require("xmldom").Document,DocumentFragment=require("xmldom").DocumentFragment;module.exports=SaxonJS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment