jtlt 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +16 -0
- package/demo/index.css +4 -0
- package/demo/index.html +4 -4
- package/demo/index.js +6 -2
- package/demo/vendor/fontoxpath/dist/fontoxpath.esm.js +600 -0
- package/demo/vendor/prsc/dist/prsc.esm.js +2 -0
- package/demo/vendor/whynot/dist/whynot.esm.js +2 -0
- package/demo/vendor/xspattern/dist/xspattern.esm.js +2 -0
- package/dist/AbstractJoiningTransformer.d.ts +35 -0
- package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
- package/dist/DOMJoiningTransformer.d.ts +85 -8
- package/dist/DOMJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONJoiningTransformer.d.ts +28 -10
- package/dist/JSONJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformerContext.d.ts +168 -3
- package/dist/JSONPathTransformerContext.d.ts.map +1 -1
- package/dist/StringJoiningTransformer.d.ts +25 -8
- package/dist/StringJoiningTransformer.d.ts.map +1 -1
- package/dist/XPathTransformer.d.ts.map +1 -1
- package/dist/XPathTransformerContext.d.ts +107 -1
- package/dist/XPathTransformerContext.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/docs/TO-DO.md +38 -36
- package/package.json +6 -2
- package/src/AbstractJoiningTransformer.js +53 -0
- package/src/DOMJoiningTransformer.js +199 -24
- package/src/JSONJoiningTransformer.js +89 -27
- package/src/JSONPathTransformer.js +2 -0
- package/src/JSONPathTransformerContext.js +572 -9
- package/src/StringJoiningTransformer.js +60 -22
- package/src/XPathTransformer.js +2 -0
- package/src/XPathTransformerContext.js +487 -11
- package/src/index.js +7 -1
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import * as xspattern from 'xspattern';
|
|
2
|
+
import * as prsc from 'prsc';
|
|
3
|
+
const fontoxpath = (function (xspattern, prsc) {
|
|
4
|
+
const VERSION='3.33.2';
|
|
5
|
+
const fontoxpathGlobal = {};
|
|
6
|
+
function aa(a,b){if(!("0"!==a&&"-0"!==a||"0"!==b&&"-0"!==b))return 0;var c=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;a=c.exec(a+"");var d=c.exec(b+""),e=!a[1];const f=!d[1];b=(a[2]||"").replace(/^0*/,"");c=(d[2]||"").replace(/^0*/,"");a=a[3]||"";d=d[3]||"";if(e&&!f)return 1;if(!e&&f)return-1;e=e&&f;if(b.length>c.length)return e?1:-1;if(b.length<c.length)return e?-1:1;if(b>c)return e?1:-1;if(b<c)return e?-1:1;b=Math.max(a.length,d.length);c=a.padEnd(b,"0");b=d.padEnd(b,"0");return c>b?e?1:-1:c<b?e?-1:1:0};function ba(a,b){a=a.toString();if(-1<a.indexOf(".")&&0===b)return!1;a=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(a);return a[2]?a[2].length<=b:!0}function da(){return function(a,b){return 1>aa(a,b)}}function fa(){return function(a,b){return 0>aa(a,b)}}function ha(){return function(a,b){return-1<aa(a,b)}}function ia(){return function(a,b){return 0<aa(a,b)}}
|
|
7
|
+
function ja(a,b){switch(b){case "required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "optional":return!0}}function ka(a){switch(a){case 1:case 0:case 6:case 3:return{};case 4:return{ka:ba,wa:da(),nc:fa(),xa:ha(),oc:ia()};case 18:return{};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ba:ja};case 22:case 21:case 20:case 23:case 44:return{};default:return null}}var la={},ma={};function na(a){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(a)}function oa(a){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(a)}function pa(a){return oa(a)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(a)}function qa(a){a=a.split(":");return 1===a.length?pa(a[0]):2!==a.length?!1:pa(a[0])&&pa(a[1])}function ra(a){return!/[\u0009\u000A\u000D]/.test(a)}function sa(a){return pa(a)}
|
|
8
|
+
const ta=new Map([[45,function(){return!0}],[46,function(){return!0}],[1,function(){return!0}],[0,function(a){return/^(0|1|true|false)$/.test(a)}],[6,function(a){return na(a)}],[3,na],[4,function(a){return/^[+-]?\d*(\.\d*)?$/.test(a)}],[18,function(a){return/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.test(a)}],[9,function(a){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],
|
|
9
|
+
[8,function(a){return/^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[7,function(a){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[11,function(a){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[12,function(a){return/^-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],
|
|
10
|
+
[13,function(a){return/^--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[15,function(a){return/^---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[14,function(a){return/^--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[22,function(a){return/^([0-9A-Fa-f]{2})*$/.test(a)}],[21,function(a){return(new RegExp(/^((([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(a)}],
|
|
11
|
+
[20,function(){return!0}],[44,qa],[48,ra],[52,function(a){return ra(a)&&!/^ | {2,}| $/.test(a)}],[51,function(a){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(a)}],[50,function(a){return/^[-._:A-Za-z0-9]+$/.test(a)}],[25,oa],[23,qa],[24,pa],[42,sa],[41,sa],[26,function(a){return pa(a)}],[5,function(a){return/^[+-]?\d+$/.test(a)}],[16,function(a){return/^-?P[0-9]+(Y([0-9]+M)?|M)$/.test(a)}],[17,function(a){return/^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?$/.test(a)}]]);var ua=Object.create(null);
|
|
12
|
+
[{C:0,name:59},{C:0,name:46,parent:59,K:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,
|
|
13
|
+
K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,K:{whiteSpace:"collapse"}},
|
|
14
|
+
{C:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{C:1,name:10,S:9,K:{whiteSpace:"collapse",Ba:"required"}},{C:1,name:48,S:1,K:{whiteSpace:"replace"}},{C:1,name:52,S:48,K:{whiteSpace:"collapse"}},{C:1,name:51,S:52,K:{whiteSpace:"collapse"}},{C:1,name:50,S:52,K:{whiteSpace:"collapse"}},{C:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,S:52,K:{whiteSpace:"collapse"}},{C:1,name:24,S:25,K:{whiteSpace:"collapse"}},{C:1,name:42,S:24,
|
|
15
|
+
K:{whiteSpace:"collapse"}},{C:1,name:41,S:24,K:{whiteSpace:"collapse"}},{C:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,S:24,K:{whiteSpace:"collapse"}},{C:2,name:40,type:26,K:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,K:{ka:0,whiteSpace:"collapse"}},{C:1,name:27,S:5,K:{ka:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:28,S:27,K:{ka:0,wa:"-1",whiteSpace:"collapse"}},{C:1,name:31,S:5,K:{ka:0,wa:"9223372036854775807",xa:"-9223372036854775808",whiteSpace:"collapse"}},
|
|
16
|
+
{C:1,name:32,S:31,K:{ka:0,wa:"2147483647",xa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,S:32,K:{ka:0,wa:"32767",xa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,S:33,K:{ka:0,wa:"127",xa:"-128",whiteSpace:"collapse"}},{C:1,name:30,S:5,K:{ka:0,xa:"0",whiteSpace:"collapse"}},{C:1,name:36,S:30,K:{ka:0,wa:"18446744073709551615",xa:"0",whiteSpace:"collapse"}},{C:1,name:35,S:36,K:{ka:0,wa:"4294967295",xa:"0",whiteSpace:"collapse"}},{C:1,name:38,S:35,K:{ka:0,wa:"65535",xa:"0",whiteSpace:"collapse"}},
|
|
17
|
+
{C:1,name:37,S:38,K:{ka:0,wa:"255",xa:"0",whiteSpace:"collapse"}},{C:1,name:29,S:30,K:{ka:0,xa:"1",whiteSpace:"collapse"}},{C:1,name:16,S:18,K:{whiteSpace:"collapse"}},{C:1,name:17,S:18,K:{whiteSpace:"collapse"}},{C:1,name:60,S:59},{C:3,name:39,Ca:[]},{C:1,name:61,S:60},{C:1,name:62,S:60},{C:0,name:53,parent:59},{C:1,name:54,S:53},{C:1,name:58,S:53},{C:1,name:47,S:53},{C:1,name:56,S:53},{C:1,name:57,S:53},{C:1,name:55,S:53},{C:3,name:2,Ca:[4,5,6,3]},{C:3,name:63,Ca:[]}].forEach(a=>{const b=a.name,
|
|
18
|
+
c=a.K||{};switch(a.C){case 0:a=a.parent?ua[a.parent]:null;var d=ta.get(b)||null;ua[b]={C:0,type:b,Ka:c,parent:a,gb:d,Oa:ka(b),Ca:[]};break;case 1:a=ua[a.S];d=ta.get(b)||null;ua[b]={C:1,type:b,Ka:c,parent:a,gb:d,Oa:a.Oa,Ca:[]};break;case 2:ua[b]={C:2,type:b,Ka:c,parent:ua[a.type],gb:null,Oa:la,Ca:[]};break;case 3:a=a.Ca.map(e=>ua[e]),ua[b]={C:3,type:b,Ka:c,parent:null,gb:null,Oa:ma,Ca:a}}});function g(a,b){if(!ua[b])throw Error("Unknown type");return{type:b,value:a}}var va=g(!0,0),wa=g(!1,0);var xa=(a="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${a}`);var ya=class{constructor(a,b){this.done=a;this.value=b}},p=new ya(!0);function q(a){return new ya(!1,a)};function za(a,b){if(3===b.C)return!!b.Ca.find(c=>za(a,c));for(;a;){if(a.type===b.type)return!0;if(3===a.C)return!!a.Ca.find(c=>v(c.type,b.type));a=a.parent}return!1}function v(a,b){return a===b?!0:za(ua[a],ua[b])};var Aa=class{constructor(a){this.o=w;this.h=a;let b=-1;this.value={next:()=>{b++;return b>=a.length?p:q(a[b])}}}hb(){return this}filter(a){let b=-1;return this.o.create({next:()=>{for(b++;b<this.h.length&&!a(this.h[b],b,this);)b++;return b>=this.h.length?p:q(this.h[b])}})}first(){return this.h[0]}O(){return this.h}fa(){if(v(this.h[0].type,53))return!0;throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");}Pa(){return this.h.length}F(){return!1}oa(){return!1}map(a){let b=
|
|
19
|
+
-1;return this.o.create({next:()=>++b>=this.h.length?p:q(a(this.h[b],b,this))},this.h.length)}N(a){return a(this.h)}X(a){return a.multiple?a.multiple(this):a.default(this)}};var Ba=class{constructor(){this.value={next:()=>p}}hb(){return this}filter(){return this}first(){return null}O(){return[]}fa(){return!1}Pa(){return 0}F(){return!0}oa(){return!1}map(){return this}N(a){return a([])}X(a){return a.empty?a.empty(this):a.default(this)}};var Ca=class{constructor(a,b){this.type=a;this.value=b}};
|
|
20
|
+
const Da={[0]:"xs:boolean",[1]:"xs:string",[2]:"xs:numeric",[3]:"xs:double",[4]:"xs:decimal",[5]:"xs:integer",[6]:"xs:float",[7]:"xs:date",[8]:"xs:time",[9]:"xs:dateTime",[10]:"xs:dateTimeStamp",[11]:"xs:gYearMonth",[12]:"xs:gYear",[13]:"xs:gMonthDay",[14]:"xs:gMonth",[15]:"xs:gDay",[16]:"xs:yearMonthDuration",[17]:"xs:dayTimeDuration",[18]:"xs:duration",[19]:"xs:untypedAtomic",[20]:"xs:anyURI",[21]:"xs:base64Binary",[22]:"xs:hexBinary",[23]:"xs:QName",[24]:"xs:NCName",[25]:"xs:Name",[26]:"xs:ENTITY",
|
|
21
|
+
[27]:"xs:nonPositiveInteger",[28]:"xs:negativeInteger",[29]:"xs:positiveInteger",[30]:"xs:nonNegativeInteger",[31]:"xs:long",[32]:"xs:int",[33]:"xs:short",[34]:"xs:byte",[35]:"xs:unsignedInt",[36]:"xs:unsignedLong",[37]:"xs:unsignedByte",[38]:"xs:unsignedShort",[39]:"xs:error",[40]:"xs:ENTITIES",[41]:"xs:IDREF",[42]:"xs:ID",[43]:"xs:IDREFS",[44]:"xs:NOTATION",[45]:"xs:anySimpleType",[46]:"xs:anyAtomicType",[47]:"attribute()",[48]:"xs:normalizedString",[49]:"xs:NMTOKENS",[50]:"xs:NMTOKEN",[51]:"xs:language",
|
|
22
|
+
[52]:"xs:token",[53]:"node()",[54]:"element()",[55]:"document-node()",[56]:"text()",[57]:"processing-instruction()",[58]:"comment()",[59]:"item()",[60]:"function(*)",[61]:"map(*)",[62]:"array(*)",[63]:"none"},Ea={"xs:boolean":0,"xs:string":1,"xs:numeric":2,"xs:double":3,"xs:decimal":4,"xs:integer":5,"xs:float":6,"xs:date":7,"xs:time":8,"xs:dateTime":9,"xs:dateTimeStamp":10,"xs:gYearMonth":11,"xs:gYear":12,"xs:gMonthDay":13,"xs:gMonth":14,"xs:gDay":15,"xs:yearMonthDuration":16,"xs:dayTimeDuration":17,
|
|
23
|
+
"xs:duration":18,"xs:untypedAtomic":19,"xs:anyURI":20,"xs:base64Binary":21,"xs:hexBinary":22,"xs:QName":23,"xs:NCName":24,"xs:Name":25,"xs:ENTITY":26,"xs:nonPositiveInteger":27,"xs:negativeInteger":28,"xs:positiveInteger":29,"xs:nonNegativeInteger":30,"xs:long":31,"xs:int":32,"xs:short":33,"xs:byte":34,"xs:unsignedInt":35,"xs:unsignedLong":36,"xs:unsignedByte":37,"xs:unsignedShort":38,"xs:error":39,"xs:ENTITIES":40,"xs:IDREF":41,"xs:ID":42,"xs:IDREFS":43,"xs:NOTATION":44,"xs:anySimpleType":45,"xs:anyAtomicType":46,
|
|
24
|
+
"attribute()":47,"xs:normalizedString":48,"xs:NMTOKENS":49,"xs:NMTOKEN":50,"xs:language":51,"xs:token":52,"node()":53,"element()":54,"document-node()":55,"text()":56,"processing-instruction()":57,"comment()":58,"item()":59,"function(*)":60,"map(*)":61,"array(*)":62};function Ha(a){return 2===a.g?Da[a.type]+"*":1===a.g?Da[a.type]+"+":0===a.g?Da[a.type]+"?":Da[a.type]}
|
|
25
|
+
function Ia(a){if("none"===a)throw Error('XPST0051: The type "none" could not be found');if(!a.startsWith("xs:")&&0<=a.indexOf(":"))throw Error(`XPST0081: Invalid prefix for input ${a}`);const b=Ea[a];if(void 0===b)throw Error(`XPST0051: The type "${a}" could not be found`);return b}
|
|
26
|
+
function Ja(a){switch(a[a.length-1]){case "*":return{type:Ia(a.substr(0,a.length-1)),g:2};case "?":return{type:Ia(a.substr(0,a.length-1)),g:0};case "+":return{type:Ia(a.substr(0,a.length-1)),g:1};default:return{type:Ia(a),g:3}}}function Ka(a){switch(a){case "*":return 2;case "?":return 0;case "+":return 1;default:return 3}};function La(a){const b=a.value;if(v(a.type,53))return!0;if(v(a.type,0))return b;if(v(a.type,1)||v(a.type,20)||v(a.type,19))return 0!==b.length;if(v(a.type,2))return!isNaN(b)&&0!==b;throw xa(`Cannot determine the effective boolean value of a value with the type ${Da[a.type]}`);};function Ma(a,b=0){a.h=b}
|
|
27
|
+
var Na=class{constructor(a,b=null){this.D=w;this.value={next:c=>{if(null!==this.o&&this.h>=this.o)return p;if(void 0!==this.v[this.h])return q(this.v[this.h++]);c=a.next(c);if(c.done)return this.o=this.h,c;if(this.l||2>this.h)this.v[this.h]=c.value;this.h++;return c}};this.l=!1;this.v=[];this.h=0;this.o=b}hb(){return this.D.create(this.O())}filter(a){let b=-1;const c=this.value;return this.D.create({next:d=>{b++;for(d=c.next(d);!d.done&&!a(d.value,b,this);)b++,d=c.next(0);return d}})}first(){if(void 0!==
|
|
28
|
+
this.v[0])return this.v[0];const a=this.value.next(0);Ma(this);return a.done?null:a.value}O(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const a=this.value;this.l=!0;let b=a.next(0);for(;!b.done;)b=a.next(0);return this.v}fa(){const a=this.value,b=this.h;Ma(this);var c=a.next(0);if(c.done)return Ma(this,b),!1;c=c.value;if(v(c.type,53))return Ma(this,b),!0;if(!a.next(0).done)throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");
|
|
29
|
+
Ma(this,b);return La(c)}Pa(a=!1){if(null!==this.o)return this.o;if(a)return-1;a=this.h;const b=this.O().length;Ma(this,a);return b}F(){return 0===this.o?!0:null===this.first()}oa(){if(null!==this.o)return 1===this.o;var a=this.value;const b=this.h;Ma(this);if(a.next(0).done)return Ma(this,b),!1;a=a.next(0);Ma(this,b);return a.done}map(a){let b=0;const c=this.value;return this.D.create({next:d=>{d=c.next(d);return d.done?p:q(a(d.value,b++,this))}},this.o)}N(a,b){const c=this.value;let d;const e=[];
|
|
30
|
+
let f=!0;(function(){for(let h=c.next(f?0:b);!h.done;h=c.next(b))f=!1,e.push(h.value);d=a(e).value})();return this.D.create({next:()=>d.next(0)})}X(a){let b=null;const c=d=>{b=d.value;d=d.Pa(!0);-1!==d&&(this.o=d)};return this.D.create({next:d=>{if(b)return b.next(d);if(this.F())return c(a.empty?a.empty(this):a.default(this)),b.next(d);if(this.oa())return c(a.m?a.m(this):a.default(this)),b.next(d);c(a.multiple?a.multiple(this):a.default(this));return b.next(d)}})}};var Oa=class{constructor(a){this.v=w;this.h=a;let b=!1;this.value={next:()=>{if(b)return p;b=!0;return q(a)}};this.o=null}hb(){return this}filter(a){return a(this.h,0,this)?this:this.v.create()}first(){return this.h}O(){return[this.h]}fa(){null===this.o&&(this.o=La(this.h));return this.o}Pa(){return 1}F(){return!1}oa(){return!0}map(a){return this.v.create(a(this.h,0,this))}N(a){return a([this.h])}X(a){return a.m?a.m(this):a.default(this)}};const Pa=new Ba;function Qa(a=null,b=null){if(null===a)return Pa;if(Array.isArray(a))switch(a.length){case 0:return Pa;case 1:return new Oa(a[0]);default:return new Aa(a)}return a.next?new Na(a,b):new Oa(a)}var w={create:Qa,m:a=>new Oa(a),empty:()=>Qa(),aa:()=>Qa(va),T:()=>Qa(wa)};function Ra(a){const b=[],c=a.value;return()=>{let d=0;return w.create({next:()=>{if(void 0!==b[d])return b[d++];const e=c.next(0);return e.done?e:b[d++]=e}})}};var Sa=class{constructor(a,b,c){this.namespaceURI=b||null;this.prefix=a||"";this.localName=c}za(){return this.prefix?this.prefix+":"+this.localName:this.localName}};function Ta(a,b){const c=a.value,d=b.map(e=>null===e?null:Ra(e));b=b.reduce((e,f,h)=>{null===f&&e.push(a.o[h]);return e},[]);b=new Va({j:b,arity:b.length,Ya:!0,I:a.I,localName:"boundFunction",namespaceURI:a.l,i:a.s,value:function(e,f,h){const k=Array.from(arguments).slice(3),l=d.map(n=>null===n?k.shift():n());return c.apply(void 0,[e,f,h].concat(l))}});return w.m(b)}
|
|
31
|
+
var Va=class extends Ca{constructor({j:a,arity:b,Ya:c=!1,I:d=!1,localName:e,namespaceURI:f,i:h,value:k}){super(60,null);this.value=k;this.I=d;d=-1;for(k=0;k<a.length;k++)4===a[k]&&(d=k);-1<d&&(k=Array(b-(a.length-1)).fill(a[d-1]),a=a.slice(0,d).concat(k));this.o=a;this.v=b;this.ia=c;this.D=e;this.l=f;this.s=h}Ya(){return this.ia}};function Wa(a,b){const c=[];2!==a&&1!==a||c.push("type-1-or-type-2");c.push(`type-${a}`);b&&c.push(`name-${b}`);return c}function Xa(a){const b=a.node.nodeType;let c;if(2===b||1===b)c=a.node.localName;return Wa(b,c)}function Ya(a){let b=a.nodeType;4===b&&(b=3);let c;if(2===b||1===b)c=a.localName;return Wa(b,c)};var Za=class{getAllAttributes(a,b=null){if(1!==a.nodeType)return[];a=Array.from(a.attributes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getAttribute(a,b){return 1!==a.nodeType?null:a.getAttribute(b)}getChildNodes(a,b=null){a=Array.from(a.childNodes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getData(a){return 2===a.nodeType?a.value:a.data}getFirstChild(a,b=null){for(a=a.firstChild;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getLastChild(a,b=null){for(a=a.lastChild;a;a=
|
|
32
|
+
a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}getNextSibling(a,b=null){for(a=a.nextSibling;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getParentNode(a,b=null){return(a=2===a.nodeType?a.ownerElement:a.parentNode)?null===b||Ya(a).includes(b)?a:null:null}getPreviousSibling(a,b=null){for(a=a.previousSibling;a;a=a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}};class $a{insertBefore(a,b,c){return a.insertBefore(b,c)}removeAttributeNS(a,b,c){return a.removeAttributeNS(b,c)}removeChild(a,b){return a.removeChild(b)}setAttributeNS(a,b,c,d){a.setAttributeNS(b,c,d)}setData(a,b){a.data=b}}var ab=new $a;class bb{constructor(a){this.h=a}insertBefore(a,b,c){return this.h.insertBefore(a,b,c)}removeAttributeNS(a,b,c){return this.h.removeAttributeNS(a,b,c)}removeChild(a,b){return this.h.removeChild(a,b)}setAttributeNS(a,b,c,d){this.h.setAttributeNS(a,b,c,d)}setData(a,b){this.h.setData(a,b)}};function cb(a){return void 0!==a.Ra};function db(a,b,c){let d=null;b&&(cb(b.node)?d={G:b.G,offset:c,parent:b.node}:b.G&&(d=b.G));return{node:a,G:d}}function eb(a,b,c=null){return a.getAllAttributes(b.node,c).map(d=>db(d,b,d.nodeName))}function fb(a,b,c){b=b.node;return cb(b)?(a=b.attributes.find(d=>c===d.name))?a.value:null:(a=a.h.getAttribute(b,c))?a:null}function gb(a,b,c=null){return a.getChildNodes(b.node,c).map((d,e)=>db(d,b,e))}function hb(a,b){return a.getData(b.node)}
|
|
33
|
+
function ib(a,b,c=null){const d=b.node;cb(d)?a=d.childNodes[0]:((c=a.h.getFirstChild(d,c))&&10===c.nodeType&&(c=a.h.getNextSibling(c)),a=c);return a?db(a,b,0):null}function kb(a,b,c=null){var d=b.node;cb(d)?(a=d.childNodes.length-1,d=d.childNodes[a]):((d=a.h.getLastChild(d,c))&&10===d.nodeType&&(d=a.h.getPreviousSibling(d)),a=a.getChildNodes(b.node,c).length-1);return d?db(d,b,a):null}
|
|
34
|
+
function x(a,b,c=null){const d=b.node,e=b.G;if(e)"number"===typeof e.offset&&d===e.parent.childNodes[e.offset]||"string"===typeof e.offset&&d===e.parent.attributes.find(f=>e.offset===f.nodeName)?(a=e.parent,b=e.G):(a=a.getParentNode(d,c),b=e);else{if(cb(d))return null;a=a.getParentNode(d,c);b=null}return a?{node:a,G:b}:null}
|
|
35
|
+
function lb(a,b,c=null){const d=b.node;let e,f,h;const k=b.G;if(cb(d))k&&(h=k.offset+1,e=k.parent.childNodes[h]);else if(k)h=k.offset+1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[h];else{for(e=d;e&&(!(e=a.h.getNextSibling(e,c))||10===e.nodeType););return e?{node:e,G:null}:null}return e?db(e,f||x(a,b,c),h):null}
|
|
36
|
+
function mb(a,b,c=null){const d=b.node;let e,f;const h=b.G;let k;if(cb(d))h&&(k=h.offset-1,e=h.parent.childNodes[k]);else if(h)k=h.offset-1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[k];else{for(e=d;e&&(!(e=a.h.getPreviousSibling(e,c))||10===e.nodeType););return e?{node:e,G:null}:null}return e?db(e,f||x(a,b,c),k):null}
|
|
37
|
+
var nb=class{constructor(a){this.h=a;this.o=[]}getAllAttributes(a,b=null){return cb(a)?a.attributes:this.h.getAllAttributes(a,b)}getChildNodes(a,b=null){b=cb(a)?a.childNodes:this.h.getChildNodes(a,b);return 9===a.nodeType?b.filter(c=>10!==c.nodeType):b}getData(a){return cb(a)?2===a.nodeType?a.value:a.data:this.h.getData(a)||""}getParentNode(a,b=null){return this.h.getParentNode(a,b)}};var ob=(a,b,c,d,e)=>e.N(([f])=>d.N(([h])=>{const k=f.value;if(0>=k||k>h.h.length)throw Error("FOAY0001: array position out of bounds.");return h.h[k-1]()}));var pb=class extends Va{constructor(a){super({value:(b,c,d,e)=>ob(b,c,d,w.m(this),e),localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/array",j:[{type:5,g:3}],arity:1,i:{type:59,g:2}});this.type=62;this.h=a}};function qb(a){switch(a.node.nodeType){case 2:return 47;case 1:return 54;case 3:case 4:return 56;case 7:return 57;case 8:return 58;case 9:return 55;default:return 53}}function rb(a){return{type:qb(a),value:a}};function A(a,b){a=a.map(c=>c.first());return b(a)};function sb(a,b){var c=v(a.type,1)||v(a.type,20)||v(a.type,19),d=v(b.type,1)||v(b.type,20)||v(b.type,19);if(c&&d)return a.value===b.value;c=v(a.type,4)||v(a.type,3)||v(a.type,6);d=v(b.type,4)||v(b.type,3)||v(b.type,6);if(c&&d)return isNaN(a.value)&&isNaN(b.value)?!0:a.value===b.value;c=v(a.type,0)||v(a.type,22)||v(a.type,18)||v(a.type,23)||v(a.type,44);d=v(b.type,0)||v(b.type,22)||v(b.type,18)||v(b.type,23)||v(b.type,44);return c&&d?a.value===b.value:!1};var tb=(a,b,c,d,e)=>A([d,e],([f,h])=>(f=f.h.find(k=>sb(k.key,h)))?f.value():w.empty());var ub=class extends Va{constructor(a){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(b,c,d,e)=>tb(b,c,d,w.m(this),e),i:{type:59,g:2}});this.type=61;this.h=a}};function vb(a,b){return a.h()===b.h()&&a.o()===b.o()}var wb=class{$a(){return 0}getHours(){return 0}getMinutes(){return 0}ab(){return 0}h(){return 0}o(){return 0}getSeconds(){return 0}bb(){return 0}na(){return!0}};function xb(a){var b=Math.abs(a.$a()),c=Math.abs(a.getHours());const d=Math.abs(a.getMinutes());a=Math.abs(a.getSeconds());b=`${b?`${b}D`:""}`;c=(c?`${c}H`:"")+(d?`${d}M`:"")+(a?`${a}S`:"");return b&&c?`${b}T${c}`:b?b:c?`T${c}`:"T0S"}
|
|
38
|
+
var yb=class extends wb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ca=a}$a(){return Math.trunc(this.ca/86400)}getHours(){return Math.trunc(this.ca%86400/3600)}getMinutes(){return Math.trunc(this.ca%3600/60)}o(){return this.ca}getSeconds(){const a=this.ca%60;return Object.is(-0,a)?0:a}na(){return Object.is(-0,this.ca)?!1:0<=this.ca}toString(){return(this.na()?
|
|
39
|
+
"P":"-P")+xb(this)}},zb=(a,b,c,d,e,f)=>{a=86400*a+3600*b+60*c+d+e;return new yb(f||0===a?a:-a)},Ab=a=>(a=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a))?zb(a[4]?parseInt(a[4],10):0,a[5]?parseInt(a[5],10):0,a[6]?parseInt(a[6],10):0,a[7]?parseInt(a[7],10):0,a[8]?parseFloat(a[8]):0,!a[1]):null,Bb=a=>{a=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(a);return"Z"===a[1]?zb(0,0,0,0,0,!0):zb(0,a[3]?parseInt(a[3],10):0,a[4]?parseInt(a[4],10):0,0,0,"+"===a[2])};
|
|
40
|
+
function Cb(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");a=a.ca*b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new yb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)};function Db(a){return a?parseInt(a,10):null}function Eb(a){a+="";const b=a.startsWith("-");b&&(a=a.substring(1));return(b?"-":"")+a.padStart(4,"0")}function Fb(a){return(a+"").padStart(2,"0")}function Hb(a){a+="";1===a.split(".")[0].length&&(a=a.padStart(a.length+1,"0"));return a}function Ib(a){return 0===a.getHours()&&0===a.getMinutes()?"Z":(a.na()?"+":"-")+Fb(Math.abs(a.getHours()))+":"+Fb(Math.abs(a.getMinutes()))}
|
|
41
|
+
function Jb(a){var b=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(a);a=b[1]?parseInt(b[1],10):null;const c=Db(b[2]),d=Db(b[3]),e=b[4],f=Db(b[5]),h=Db(b[6]),k=Db(b[7]),l=b[8]?parseFloat(b[8]):0;b=b[9]?Bb(b[9]):null;if(a&&(-271821>a||273860<a))throw Error("FODT0001: Datetime year is out of bounds");return e?new Kb(a,c,d,f,h,k,l,b,9):null!==f&&null!==h&&null!==k?new Kb(1972,12,31,f,h,k,l,b,8):null!==a&&null!==c&&null!==d?new Kb(a,
|
|
42
|
+
c,d,0,0,0,0,b,7):null!==a&&null!==c?new Kb(a,c,1,0,0,0,0,b,11):null!==c&&null!==d?new Kb(1972,c,d,0,0,0,0,b,13):null!==a?new Kb(a,1,1,0,0,0,0,b,12):null!==c?new Kb(1972,c,1,0,0,0,0,b,14):new Kb(1972,12,d,0,0,0,0,b,15)}
|
|
43
|
+
function Lb(a,b){switch(b){case 15:return new Kb(1972,12,a.o,0,0,0,0,a.Y,15);case 14:return new Kb(1972,a.h,1,0,0,0,0,a.Y,14);case 12:return new Kb(a.v,1,1,0,0,0,0,a.Y,12);case 13:return new Kb(1972,a.h,a.o,0,0,0,0,a.Y,13);case 11:return new Kb(a.v,a.h,1,0,0,0,0,a.Y,11);case 8:return new Kb(1972,12,31,a.l,a.s,a.D,a.qa,a.Y,8);case 7:return new Kb(a.v,a.h,a.o,0,0,0,0,a.Y,7);default:return new Kb(a.v,a.h,a.o,a.l,a.s,a.D,a.qa,a.Y,9)}}
|
|
44
|
+
function Mb(a,b){b=a.Y||b||Bb("Z");return new Date(Date.UTC(a.v,a.h-1,a.o,a.l-b.getHours(),a.s-b.getMinutes(),a.D,1E3*a.qa))}
|
|
45
|
+
var Kb=class{constructor(a,b,c,d,e,f,h,k,l=9){this.v=a;this.h=b;this.o=c+(24===d?1:0);this.l=24===d?0:d;this.s=e;this.D=f;this.qa=h;this.Y=k;this.type=l}getDay(){return this.o}getHours(){return this.l}getMinutes(){return this.s}getMonth(){return this.h}getSeconds(){return this.D}getYear(){return this.v}toString(){switch(this.type){case 9:return Eb(this.v)+"-"+Fb(this.h)+"-"+Fb(this.o)+"T"+Fb(this.l)+":"+Fb(this.s)+":"+Hb(this.D+this.qa)+(this.Y?Ib(this.Y):"");case 7:return Eb(this.v)+"-"+Fb(this.h)+
|
|
46
|
+
"-"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 8:return Fb(this.l)+":"+Fb(this.s)+":"+Hb(this.D+this.qa)+(this.Y?Ib(this.Y):"");case 15:return"---"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 14:return"--"+Fb(this.h)+(this.Y?Ib(this.Y):"");case 13:return"--"+Fb(this.h)+"-"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 12:return Eb(this.v)+(this.Y?Ib(this.Y):"");case 11:return Eb(this.v)+"-"+Fb(this.h)+(this.Y?Ib(this.Y):"")}throw Error("Unexpected subType");}};
|
|
47
|
+
function Nb(a,b,c){const d=Mb(a,c).getTime();c=Mb(b,c).getTime();return d===c?a.qa===b.qa?0:a.qa>b.qa?1:-1:d>c?1:-1}function Ob(a,b,c){return 0===Nb(a,b,c)}function Pb(a,b,c){a=(Mb(a,c).getTime()-Mb(b,c).getTime())/1E3;return new yb(a)}function Qb(a){throw Error(`Not implemented: adding durations to ${Da[a.type]}`);}function Rb(a){throw Error(`Not implemented: subtracting durations from ${Da[a.type]}`);};function Sb(a,b){if(null===a)return null;switch(typeof a){case "boolean":return a?va:wa;case "number":return g(a,3);case "string":return g(a,1);case "object":if("nodeType"in a)return rb({node:a,G:null});if(Array.isArray(a))return new pb(a.map(c=>{if(void 0===c)return()=>w.empty();c=Sb(c,b);c=null===c?w.empty():w.m(c);return Ra(c)}));if(a instanceof Date){const c=Jb(a.toISOString());return g(c,c.type)}return new ub(Object.keys(a).filter(c=>void 0!==a[c]).map(c=>{var d=Sb(a[c],b);d=null===d?w.empty():
|
|
48
|
+
w.m(d);return{key:g(c,1),value:Ra(d)}}))}throw Error(`Value ${String(a)} of type "${typeof a}" is not adaptable to an XPath value.`);}function Tb(a,b){if("number"!==typeof a&&("string"!==typeof a||!ta.get(b)(a)))throw Error(`Cannot convert JavaScript value '${a}' to the XPath type ${Da[b]} since it is not valid.`);}
|
|
49
|
+
function Ub(a,b,c){if(null===b)return null;switch(a){case 0:return b?va:wa;case 1:return g(b+"",1);case 3:case 2:return Tb(b,3),g(+b,3);case 4:return Tb(b,a),g(+b,4);case 5:return Tb(b,a),g(b|0,5);case 6:return Tb(b,a),g(+b,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(b instanceof Date))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return g(Lb(Jb(b.toISOString()),a),a);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!==
|
|
50
|
+
typeof b||!("nodeType"in b))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return rb({node:b,G:null});case 59:return Sb(b,c);case 61:return Sb(b,c);default:throw Error(`Values of the type "${Da[a]}" can not be adapted from JavaScript to equivalent XPath values.`);}}
|
|
51
|
+
function Vb(a,b,c){if(0===c.g)return b=Ub(c.type,b,a),null===b?[]:[b];if(2===c.g||1===c.g){if(!Array.isArray(b))throw Error(`The JavaScript value ${b} should be an array if it is to be converted to ${Ha(c)}.`);return b.map(e=>Ub(c.type,e,a)).filter(e=>null!==e)}const d=Ub(c.type,b,a);if(null===d)throw Error(`The JavaScript value ${b} should be a single entry if it is to be converted to ${Ha(c)}.`);return[d]}function Wb(a,b,c={type:59,g:0}){return w.create(Vb(a,b,c))};var ac=class{constructor(){this.h=Math.abs(Math.floor(Math.random()*$b)%$b)}},$b=2**32;function bc(a,b,c,d){return new cc({M:c,Aa:b,ta:d||a.ta,ra:a.ra},a.h,a.o)}function dc(a,b){let c=0;const d=b.value;return{next:e=>{e=d.next(e);return e.done?p:q(bc(a,c++,e.value,b))}}}function ec(a){a.h.ib||(a.h.ib=!0,a.h.qb=Jb((new Date).toISOString()),a.h.vb=Ab("PT0S"));return a.h.qb}function fc(a){a.h.ib||(a.h.ib=!0,a.h.qb=Jb((new Date).toISOString()),a.h.vb=Ab("PT0S"));return a.h.vb}function gc(a,b=null){a=29421*(null!==b&&void 0!==b?b:a.o.h)%$b;return{rb:Math.floor(a),$b:a/$b}}
|
|
52
|
+
function hc(a,b){return new cc({M:a.M,Aa:a.Aa,ta:a.ta,ra:Object.assign(Object.create(null),a.ra,b)},a.h,a.o)}var cc=class{constructor(a,b={qb:null,vb:null,ib:!1},c=new ac){this.h=b;this.Aa=a.Aa;this.ta=a.ta;this.M=a.M;this.ra=a.ra||Object.create(null);this.o=c}};var ic=class{constructor(a,b,c,d,e,f,h,k,l){this.debug=a;this.Ha=b;this.h=c;this.Ja=d;this.Ma=e;this.o=f;this.v=h;this.jb=k;this.Ua=l}};function jc(a){let b=0,c=null,d=!0;return w.create({next:e=>{for(;b<a.length;){c||(c=a[b].value,d=!0);const f=c.next(d?0:e);d=!1;if(f.done)b++,c=null;else return f}return p}})};var kc=(a,b,c)=>Error(`FORG0001: Cannot cast ${a} to ${Da[b]}${c?`, ${c}`:""}`),lc=a=>Error(`XPDY0002: ${a}`),mc=a=>Error(`XPTY0004: ${a}`),nc=a=>Error(`FOTY0013: Atomization is not supported for ${Da[a]}.`),oc=a=>Error(`XPST0081: The prefix ${a} could not be resolved.`);function pc(a,b){if(v(a.type,46)||v(a.type,19)||v(a.type,0)||v(a.type,4)||v(a.type,3)||v(a.type,6)||v(a.type,5)||v(a.type,2)||v(a.type,23)||v(a.type,1))return w.create(a);const c=b.h;if(v(a.type,53)){const d=a.value;if(2===d.node.nodeType||3===d.node.nodeType)return w.create(g(hb(c,d),19));if(8===d.node.nodeType||7===d.node.nodeType)return w.create(g(hb(c,d),1));const e=[];(function k(h){if(8!==d.node.nodeType&&7!==d.node.nodeType){var l=h.nodeType;3===l||4===l?e.push(c.getData(h)):1!==l&&9!==l&&
|
|
53
|
+
11!==l||c.getChildNodes(h).forEach(n=>{k(n)})}})(d.node);return w.create(g(e.join(""),19))}if(v(a.type,60)&&!v(a.type,62))throw nc(a.type);if(v(a.type,62))return jc(a.h.map(d=>qc(d(),b)));throw Error(`Atomizing ${a.type} is not implemented.`);}function qc(a,b){let c=!1;const d=a.value;let e=null;return w.create({next:()=>{for(;!c;){if(!e){var f=d.next(0);if(f.done){c=!0;break}e=pc(f.value,b).value}f=e.next(0);if(f.done)e=null;else return f}return p}})};function rc(a){for(a=ua[a];a&&0!==a.C;)a=a.parent;return a?a.type:null}function sc(a,b){b=ua[b];const c=b.Ka;if(!c||!c.whiteSpace)return b.parent?sc(a,b.parent.type):a;switch(b.Ka.whiteSpace){case "replace":return a.replace(/[\u0009\u000A\u000D]/g," ");case "collapse":return a.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return a}function tc(a,b){for(b=ua[b];b&&null===b.gb;){if(2===b.C||3===b.C)return!0;b=b.parent}return b?b.gb(a):!0}
|
|
54
|
+
function uc(a,b){for(;a;){if(a.Oa&&a.Oa[b])return a.Oa[b];a=a.parent}return()=>!0}function vc(a,b){let c=ua[b];for(;c;){if(c.Ka&&!Object.keys(c.Ka).every(d=>{if("whiteSpace"===d)return!0;const e=uc(c,d);return e?e(a,c.Ka[d]):!0}))return!1;c=c.parent}return!0}function wc(a){return a?2===a.g||0===a.g:!0};function xc(a){return a(1)||a(19)?b=>({u:!0,value:g(b,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})};function yc(a){return a(22)?b=>{let c="";for(let d=0;d<b.length;d+=2)c+=String.fromCharCode(parseInt(b.substr(d,2),16));return{u:!0,value:g(btoa(c),21)}}:a(1)||a(19)?b=>({u:!0,value:g(b,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})};function zc(a){return a(2)?b=>({u:!0,value:0===b||isNaN(b)?wa:va}):a(1)||a(19)?b=>{switch(b){case "true":case "1":return{u:!0,value:va};case "false":case "0":return{u:!0,value:wa};default:return{u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")}}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")})};function Dc(a){return a(9)?b=>({u:!0,value:g(Lb(b,7),7)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})};function Ec(a){return a(7)?b=>({u:!0,value:g(Lb(b,9),9)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})};function Fc(a){return a(18)&&!a(16)?b=>({u:!0,value:g(b.Ga,17)}):a(16)?()=>({u:!0,value:g(Ab("PT0.0S"),17)}):a(19)||a(1)?b=>{const c=Ab(b);return c?{u:!0,value:g(c,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})};function Gc(a){return a(5)?b=>({u:!0,value:g(b,4)}):a(6)||a(3)?b=>isNaN(b)||!isFinite(b)?{u:!1,error:Error(`FOCA0002: Can not cast ${b} to xs:decimal`)}:Math.abs(b)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${b} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:g(b,4)}:a(0)?b=>({u:!0,value:g(b?1:0,4)}):a(1)||a(19)?b=>{const c=parseFloat(b);return!isNaN(c)||isFinite(c)?{u:!0,value:g(c,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:decimal`)}}:()=>({u:!1,
|
|
55
|
+
error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})};function Hc(a,b){return a(2)?c=>({u:!0,value:c}):a(0)?c=>({u:!0,value:c?1:0}):a(1)||a(19)?c=>{switch(c){case "NaN":return{u:!0,value:NaN};case "INF":case "+INF":return{u:!0,value:Infinity};case "-INF":return{u:!0,value:-Infinity};case "0":case "+0":return{u:!0,value:0};case "-0":return{u:!0,value:-0}}const d=parseFloat(c);return isNaN(d)?{u:!1,error:kc(c,b)}:{u:!0,value:d}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${b} or any of its derived types.`)})};function Ic(a){const b=Hc(a,3);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,3)}:c}};function Jc(a){const b=Math.abs(a.bb());a=Math.abs(a.ab());return`${b?`${b}Y`:""}`+`${a?`${a}M`:""}`||"0M"}
|
|
56
|
+
var Kc=class extends wb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ea=a}ab(){const a=this.ea%12;return 0===a?0:a}h(){return this.ea}bb(){return Math.trunc(this.ea/12)}na(){return Object.is(-0,this.ea)?!1:0<=this.ea}toString(){return(this.na()?"P":"-P")+Jc(this)}},Lc=a=>{var b=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a);
|
|
57
|
+
if(b){a=!b[1];b=12*(b[2]?parseInt(b[2],10):0)+(b[3]?parseInt(b[3],10):0);if(b>Number.MAX_SAFE_INTEGER||!Number.isFinite(b))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");a=new Kc(a||0===b?b:-b)}else a=null;return a};
|
|
58
|
+
function Mc(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");a=Math.round(a.ea*b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new Kc(a<Number.MIN_SAFE_INTEGER||0===a?0:a)};var Nc=class extends wb{constructor(a,b){super();this.Va=a;this.Ga=b}$a(){return this.Ga.$a()}getHours(){return this.Ga.getHours()}getMinutes(){return this.Ga.getMinutes()}ab(){return this.Va.ab()}h(){return this.Va.h()}o(){return this.Ga.o()}getSeconds(){return this.Ga.getSeconds()}bb(){return this.Va.bb()}na(){return this.Va.na()&&this.Ga.na()}toString(){const a=this.na()?"P":"-P",b=Jc(this.Va),c=xb(this.Ga);return"0M"===b?a+c:"T0S"===c?a+b:a+b+c}};function Oc(a){return a(16)?b=>({u:!0,value:g(new Nc(b,new yb(b.na()?0:-0)),18)}):a(17)?b=>{b=new Nc(new Kc(b.na()?0:-0),b);return{u:!0,value:g(b,18)}}:a(18)?b=>({u:!0,value:g(b,18)}):a(19)||a(1)?b=>{var c;return c=new Nc(Lc(b),Ab(b)),{u:!0,value:g(c,18)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})};function Pc(a){const b=Hc(a,6);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,6)}:c}};function Qc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,15),15)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})};function Rc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,14),14)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})};function Sc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,13),13)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})};function Tc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,12),12)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})};function Uc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,11),11)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})};function Vc(a){return a(21)?b=>{b=atob(b);let c="";for(let d=0,e=b.length;d<e;d++)c+=Number(b.charCodeAt(d)).toString(16);return{u:!0,value:g(c.toUpperCase(),22)}}:a(1)||a(19)?b=>({u:!0,value:g(b,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})};function Wc(a){return a(0)?b=>({u:!0,value:g(b?1:0,5)}):a(2)?b=>{const c=Math.trunc(b);return!isFinite(c)||isNaN(c)?{u:!1,error:Error(`FOCA0002: can not cast ${b} to xs:integer`)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:a(1)||a(19)?b=>{const c=parseInt(b,10);return isNaN(c)?{u:!1,error:kc(b,5)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:
|
|
59
|
+
()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})};const Xc=[3,6,4,5];function Yc(a){var b=Zc;return c=>{for(const d of Xc){const e=b(a,d)(c);if(e.u)return e}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${c}" given type to xs:numeric or any of its derived types.`)}}};function $c(a){if(a(1)||a(19))return b=>({u:!0,value:b+""});if(a(20))return b=>({u:!0,value:b});if(a(23))return b=>({u:!0,value:b.prefix?`${b.prefix}:${b.localName}`:b.localName});if(a(44))return b=>({u:!0,value:b.toString()});if(a(2)){if(a(5)||a(4))return b=>({u:!0,value:(b+"").replace("e","E")});if(a(6)||a(3))return b=>isNaN(b)?{u:!0,value:"NaN"}:isFinite(b)?Object.is(b,-0)?{u:!0,value:"-0"}:{u:!0,value:(b+"").replace("e","E").replace("E+","E")}:{u:!0,value:`${0>b?"-":""}INF`}}return a(9)||a(7)||
|
|
60
|
+
a(8)||a(15)||a(14)||a(13)||a(12)||a(11)?b=>({u:!0,value:b.toString()}):a(16)?b=>({u:!0,value:b.toString()}):a(17)?b=>({u:!0,value:b.toString()}):a(18)?b=>({u:!0,value:b.toString()}):a(22)?b=>({u:!0,value:b.toUpperCase()}):b=>({u:!0,value:b+""})};function ad(a){const b=$c(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,1)}:c}};function bd(a){return a(9)?b=>({u:!0,value:g(Lb(b,8),8)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})};function cd(a){const b=$c(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,19)}:c}};function dd(a){return a(18)&&!a(17)?b=>({u:!0,value:g(b.Va,16)}):a(17)?()=>({u:!0,value:g(Lc("P0M"),16)}):a(19)||a(1)?b=>{const c=Lc(b);return c?{u:!0,value:g(c,16)}:{u:!1,error:kc(b,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})};const ed=[2,5,17,16];
|
|
61
|
+
function Zc(a,b){const c=d=>v(a,d);if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(b){case 19:return cd(c);case 1:return ad(c);case 6:return Pc(c);case 3:return Ic(c);case 4:return Gc(c);case 5:return Wc(c);case 2:return Yc(a);case 18:return Oc(c);case 16:return dd(c);case 17:return Fc(c);case 9:return Ec(c);case 8:return bd(c);case 7:return Dc(c);case 11:return Uc(c);case 12:return Tc(c);case 13:return Sc(c);case 15:return Qc(c);case 14:return Rc(c);
|
|
62
|
+
case 0:return zc(c);case 21:return yc(c);case 22:return Vc(c);case 20:return xc(c);case 23:throw Error("Casting to xs:QName is not implemented.");}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${a} to ${b}.`)})}const gd=Object.create(null);
|
|
63
|
+
function hd(a,b){if(19===a&&1===b)return f=>({u:!0,value:g(f,1)});if(44===b)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===a||45===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===a||46===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(v(a,60)&&1===
|
|
64
|
+
b)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(a===b)return f=>({u:!0,value:{type:b,value:f}});const c=ed.includes(a)?a:rc(a),d=ed.includes(b)?b:rc(b);if(null===d||null===c)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${d?Da[a]:Da[b]} is unknown.`)});const e=[];1!==c&&19!==c||e.push(f=>{const h=sc(f,b);return tc(h,b)?{u:!0,value:h}:{u:!1,error:kc(f,b,"pattern validation failed.")}});c!==d&&(e.push(Zc(c,d)),e.push(f=>({u:!0,
|
|
65
|
+
value:f.value})));19!==d&&1!==d||e.push(f=>tc(f,b)?{u:!0,value:f}:{u:!1,error:kc(f,b,"pattern validation failed.")});e.push(f=>vc(f,b)?{u:!0,value:f}:{u:!1,error:kc(f,b,"pattern validation failed.")});e.push(f=>({u:!0,value:{type:b,value:f}}));return f=>{f={u:!0,value:f};for(let h=0,k=e.length;h<k&&(f=e[h](f.value),!1!==f.u);++h);return f}}function id(a,b){const c=a.type+1E4*b;let d=gd[c];d||=gd[c]=hd(a.type,b);return d.call(void 0,a.value,b)};function jd(a,b){a=id(a,b);if(!0===a.u)return a.value;throw a.error;};function kd(a){let b=!1;return{next:()=>{if(b)return p;b=!0;return q(a)}}};function ld(a,b){return a===b?!0:a&&b&&a.offset===b.offset&&a.parent===b.parent?ld(a.G,b.G):!1}function md(a,b){return a===b||a.node===b.node&&ld(a.G,b.G)?!0:!1};function nd(a,b,c){var d=x(a,b,null);a=gb(a,d,null);for(let e=0,f=a.length;e<f;++e){d=a[e];if(md(d,b))return-1;if(md(d,c))return 1}}function od(a,b){const c=[];for(;b;b=x(a,b,null))c.unshift(b);return c}function pd(a,b){const c=[];for(;b;b=a.getParentNode(b,null))c.unshift(b);return c}
|
|
66
|
+
function qd(a,b,c,d){if(c.G||d.G||cb(c.node)||cb(d.node)){if(md(c,d))return 0;c=od(b,c);d=od(b,d);const f=c[0],h=d[0];if(!md(f,h))return b=a.findIndex(k=>md(k,f)),c=a.findIndex(k=>md(k,h)),-1===b&&(b=a.push(f)),-1===c&&(c=a.push(h)),b-c;a=1;for(var e=Math.min(c.length,d.length);a<e&&md(c[a],d[a]);++a);return c[a]?d[a]?nd(b,c[a],d[a]):1:-1}c=c.node;e=d.node;if(c===e)return 0;d=pd(b,c);c=pd(b,e);if(d[0]!==c[0]){const f={node:d[0],G:null},h={node:c[0],G:null};b=a.findIndex(k=>md(k,f));c=a.findIndex(k=>
|
|
67
|
+
md(k,h));-1===b&&(b=a.push(f));-1===c&&(c=a.push(h));return b-c}a=1;for(e=Math.min(d.length,c.length);a<e&&d[a]===c[a];++a);d=d[a];e=c[a];if(!d)return-1;if(!e)return 1;b=b.getChildNodes(c[a-1],null);for(let f=0,h=b.length;f<h;++f){a=b[f];if(a===d)return-1;if(a===e)return 1}}
|
|
68
|
+
function rd(a,b,c,d){const e=v(c.type,47),f=v(d.type,47);if(e&&!f){if(c=x(b,c.value),d=d.value,md(c,d))return 1}else if(f&&!e){if(c=c.value,d=x(b,d.value),md(c,d))return-1}else if(e&&f){if(md(x(b,d.value),x(b,c.value)))return c.value.node.localName>d.value.node.localName?1:-1;c=x(b,c.value);d=x(b,d.value)}else c=c.value,d=d.value;return qd(a,b,c,d)}function sd(a,b,c){return rd(a.o,a,b,c)}function td(a,b){return ud(b,(c,d)=>rd(a.o,a,c,d)).filter((c,d,e)=>0===d?!0:!md(c.value,e[d-1].value))}
|
|
69
|
+
const vd=(a,b)=>a<b?-1:0;function ud(a,b=vd){if(1>=a.length)return a;var c=Math.floor(a.length/2);const d=ud(a.slice(0,c),b);a=ud(a.slice(c),b);for(c=[];d.length&&a.length;)0>b(d[0],a[0])?c.push(d.shift()):c.push(a.shift());return c.concat(d.concat(a))};function wd(a,b){if(v(a.type,2)){if(v(a.type,6))return 3===b?g(a.value,3):null;if(v(a.type,4)){if(6===b)return g(a.value,6);if(3===b)return g(a.value,3)}return null}return v(a.type,20)&&1===b?g(a.value,1):null};function xd(a,b,c,d,e){if(v(a.type,b.type))return a;v(b.type,46)&&v(a.type,53)&&(a=pc(a,c).first());if(v(a.type,b.type)||46===b.type)return a;if(v(a.type,19)){c=jd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to convert ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}c=wd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to cast ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}
|
|
70
|
+
function yd(a){switch(a){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}
|
|
71
|
+
var zd=(a,b,c,d,e)=>0===a.g?b.X({default:()=>b.map(f=>xd(f,a,c,d,e)),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected "?", but got "+".`);}}):1===a.g?b.X({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected "+", but got "empty-sequence()"`);},default:()=>b.map(f=>xd(f,a,c,
|
|
72
|
+
d,e))}):2===a.g?b.map(f=>xd(f,a,c,d,e)):b.X({m:()=>b.map(f=>xd(f,a,c,d,e)),default:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected exactly one`);}});function Ad(a,b,c){return(d,e,f)=>{if(null===d.M)throw lc(`The function ${a} depends on dynamic context, which is absent.`);const h=zd({type:b,g:3},w.m(d.M),e,a,!1);return c(d,e,f,h)}};var Bd=xspattern;function Cd(a,b){return v(a,5)?g(b,5):v(a,6)?g(b,6):v(a,3)?g(b,3):g(b,4)}const Dd=[{la:"M",ja:1E3},{la:"CM",ja:900},{la:"D",ja:500},{la:"CD",ja:400},{la:"C",ja:100},{la:"XC",ja:90},{la:"L",ja:50},{la:"XL",ja:40},{la:"X",ja:10},{la:"IX",ja:9},{la:"V",ja:5},{la:"IV",ja:4},{la:"I",ja:1}];function Ed(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d=Dd.reduce((e,f)=>{const h=Math.floor(a/f.ja);a-=h*f.ja;return e+f.la.repeat(h)},"");b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}const Fd="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
73
|
+
function Gd(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d="",e;for(;0<a;)e=(a-1)%Fd.length,d=Fd[e]+d,a=(a-e)/Fd.length|0;b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}function Hd(a,b,c=[]){return Array.from({length:b},(d,e)=>e+a).filter(d=>!c.includes(d))}
|
|
74
|
+
const Id=Hd(1488,27,[1498,1501,1503,1507,1509]),Jd=Hd(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Kd="\u0623\u0628\u062c\u062f\u0647\u0648\u0632\u062d\u0637\u064a\u0643\u0644\u0645\u0646\u0633\u0639\u0641\u0635\u0642\u0631\u0634\u062a\u062b\u062e\u0630\u0636\u0638\u063a".split(""),Ld=[[1E3,"\u063a"],[900,"\u0638"],[800,"\u0636"],[700,"\u0630"],[600,"\u062e"],[500,"\u062b"],[400,"\u062a"],[300,"\u0634"],[200,"\u0631"],[100,"\u0642"],[90,"\u0635"],[80,"\u0641"],[70,"\u0639"],[60,"\u0633"],[50,
|
|
75
|
+
"\u0646"],[40,"\u0645"],[30,"\u0644"],[20,"\u0643"],[10,"\u064a"],[9,"\u0637"],[8,"\u062d"],[7,"\u0632"],[6,"\u0648"],[5,"\u0647"],[4,"\u062f"],[3,"\u062c"],[2,"\u0628"],[1,"\u0623"]],Md=[[400,"\u05ea"],[300,"\u05e9"],[200,"\u05e8"],[100,"\u05e7"],[90,"\u05e6"],[80,"\u05e4"],[70,"\u05e2"],[60,"\u05e1"],[50,"\u05e0"],[40,"\u05de"],[30,"\u05dc"],[20,"\u05db"],[10,"\u05d9"],[9,"\u05d8"],[8,"\u05d7"],[7,"\u05d6"],[6,"\u05d5"],[5,"\u05d4"],[4,"\u05d3"],[3,"\u05d2"],[2,"\u05d1"],[1,"\u05d0"]];
|
|
76
|
+
function Nd(a,b=[]){var c=25;b.sort((d,e)=>d-e);c-=b.length;return function(d){const e=0>d;d=Math.abs(d);if(!d)return"-";const f=[];for(;0<d;){let h=a+(d-1)%c;b.forEach(k=>{h>=k&&h++});f.unshift(String.fromCodePoint(h));d=Math.floor((d-1)/c)}d=f.join("");e&&(d=`-${d}`);return d}}const Od=Nd(945,[962]),Pd=Nd(913,[930]);function Qd(a){return(new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1})).format(a)}
|
|
77
|
+
function Rd(a){return(new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1})).format(a)}
|
|
78
|
+
const Sd=new Map([["A",function(a){return Gd(a,!1)}],["a",function(a){return Gd(a,!0)}],["I",function(a){return Ed(a,!1)}],["i",function(a){return Ed(a,!0)}],["lowerGreek",Od],["\u03b1",Od],["upperGreek",Pd],["\u0391",Pd],["arabicAbjadi",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Kd.length)+1).fill(Kd[(a-1)%Kd.length]).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["arabicAbjadNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],
|
|
79
|
+
d=Math.floor(a/1E3);a-=1E3*d;if(1===d)c.push(Ld[0][1]);else if(1<d){for(const [f,h]of Ld){var e=f;const k=h;for(;d>=e;)c.push(k),d-=e}c.push(Ld[0][1])}for(const [f,h]of Ld)for(d=f,e=h;a>=d;)a-=d,c.push(e);c=c.join("");b&&(c=`-${c}`);return c}],["arabicAlifBaTa",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Jd.length)+1).fill(String.fromCodePoint(Jd[(a-1)%Jd.length])).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["hebrewAlefBet",function(a){const b=0>
|
|
80
|
+
a;a=Math.abs(a);if(!a)return"-";var c=Math.floor((a-1)/Id.length);const d=String.fromCodePoint(1514);c=Array(c).fill(d);c.push(String.fromCodePoint(Id[(a-1)%Id.length]));a=c.join("");b&&(a=`-${a}`);return a}],["hebrewNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],d=Math.floor(a/400);a-=400*d;for(var e=0;e<d;e++)c.push("\u05ea");for(const [f,h]of Md)for(d=f,e=h;a>=d;)a-=d,c.push(e);a=c.slice(-2).join("");"\u05d9\u05d4"===a&&c.splice(-2,2,"\u05d8","\u05d5");"\u05d9\u05d5"===
|
|
81
|
+
a&&c.splice(-2,2,"\u05d8","\u05d6");c=c.join("");b&&(c=`-${c}`);return c}],["arabicIndicNumeral",Qd],["\u0661",Qd],["\u0662",Qd],["\u0663",Qd],["\u0664",Qd],["\u0665",Qd],["\u0666",Qd],["\u0667",Qd],["\u0668",Qd],["\u0669",Qd],["persianNumeral",Rd],["\u06f1",Rd],["\u06f2",Rd],["\u06f3",Rd],["\u06f4",Rd],["\u06f5",Rd],["\u06f6",Rd],["\u06f7",Rd],["\u06f8",Rd],["\u06f9",Rd]]);
|
|
82
|
+
function Td(a){if(Math.floor(a)===a||isNaN(a))return 0;a=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${a}`);const b=a[1]?a[1].length:0;if(a[3]){if(a[2])return b+parseInt(a[3],10);a=b-parseInt(a[3],10);return 0>a?0:a}return b}function Ud(a,b,c){return b&&0===a*c%1%.5?0===Math.floor(a*c)%2?Math.floor(a*c)/c:Math.ceil(a*c)/c:Math.round(a*c)/c}
|
|
83
|
+
function Vd(a,b,c,d,e,f){let h=!1;return w.create({next:()=>{if(h)return p;const k=e.first();if(!k)return h=!0,p;if((v(k.type,6)||v(k.type,3))&&(0===k.value||isNaN(k.value)||Infinity===k.value||-Infinity===k.value))return h=!0,q(k);var l;f?l=f.first().value:l=0;h=!0;if(Td(k.value)<l)return q(k);const n=[5,4,3,6].find(u=>v(k.type,u)),t=jd(k,4);l=Ud(t.value,a,Math.pow(10,l));switch(n){case 4:return q(g(l,4));case 3:return q(g(l,3));case 6:return q(g(l,6));case 5:return q(g(l,5))}}})}
|
|
84
|
+
const Wd=(a,b,c,d)=>qc(d,b).X({empty:()=>w.m(g(NaN,3)),m:()=>{const e=id(d.first(),3);return e.u?w.m(e.value):w.m(g(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values");}});function Xd(a){let b=5381;for(let c=0;c<a.length;++c)b=33*b+a.charCodeAt(c),b%=Number.MAX_SAFE_INTEGER;return b}
|
|
85
|
+
const Yd=(a,b,c,d=w.empty())=>{function e(f){const h=(k,l,n,t)=>{if(t.F()||t.oa())return t;k=t.O();l=f;for(n=k.length-1;1<n;n--){l=gc(a,l).rb;t=l%n;const u=k[t];k[t]=k[n];k[n]=u}return w.create(k)};return w.m(new ub([{key:g("number",1),value:()=>w.m(g(gc(a,f).$b,3))},{key:g("next",1),value:()=>w.m(new Va({value:()=>e(gc(a,f).rb),Ya:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:g("permute",1),value:()=>w.m(new Va({value:h,Ya:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],
|
|
86
|
+
arity:1,i:{type:59,g:2}}))}]))}b=d.F()?gc(a):gc(a,Xd(jd(d.first(),1).value));return e(b.rb)};
|
|
87
|
+
var Zd=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Cd(e.type,Math.abs(e.value)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"format-integer",j:[{type:5,g:0},{type:1,g:3}],i:{type:1,g:3},callFunction:(a,b,c,d,e)=>{a=d.first();e=e.first();if(d.F())return w.m(g("",1));d=Sd.get(e.value);e=a.value;return d?(d=d(e),w.m(g(d,1))):w.m(g(e.toString(),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
88
|
+
localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Cd(e.type,Math.ceil(e.value)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Cd(e.type,Math.floor(e.value)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:Vd.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,
|
|
89
|
+
g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:Vd.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:Vd.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:Vd.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:Wd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
90
|
+
localName:"number",j:[],i:{type:3,g:3},callFunction:(a,b,c)=>{const d=a.M&&zd({type:46,g:0},w.m(a.M),b,"fn:number",!1);if(!d)throw lc("fn:number needs an atomizable context item.");return Wd(a,b,c,d)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:Yd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:Yd}];function $d(){throw Error("FOCH0002: No collations are supported");}
|
|
91
|
+
const ae=(a,b,c,d)=>d.X({empty:()=>w.m(g("",1)),default:()=>d.map(e=>{if(v(e.type,53)){const f=pc(e,b).first();return v(e.type,47)?jd(f,1):f}return jd(e,1)})}),be=(a,b,c,d,e)=>A([e],([f])=>qc(d,b).N(h=>{h=h.map(k=>jd(k,1).value).join(f.value);return w.m(g(h,1))})),ce=(a,b,c,d)=>{if(d.F())return w.m(g(0,5));a=d.first().value;return w.m(g(Array.from(a).length,5))},ee=(a,b,c,d,e,f)=>{const h=Vd(!1,a,b,c,e,null),k=null!==f?Vd(!1,a,b,c,f,null):null;let l=!1,n=null,t=null,u=null;return w.create({next:()=>
|
|
92
|
+
{if(l)return p;if(!n&&(n=d.first(),null===n))return l=!0,q(g("",1));t||=h.first();!u&&f&&(u=null,u=k.first());l=!0;return q(g(Array.from(n.value).slice(Math.max(t.value-1,0),f?t.value+u.value-1:void 0).join(""),1))}})},ge=(a,b,c,d,e)=>{if(d.F()||0===d.first().value.length)return w.empty();a=d.first().value;e=e.first().value;e=fe(e);e.lastIndex=0;b=[];c=e.exec(a);for(d=0;c;)b.push(a.slice(d,c.index)),d=e.lastIndex,c=e.exec(a);b.push(a.slice(d));return w.create(b.map(f=>g(f,1)))},he=(a,b,c,d)=>{if(d.F())return w.m(g("",
|
|
93
|
+
1));a=d.first().value.trim();return w.m(g(a.replace(/\s+/g," "),1))},ie=new Map,je=new Map;function fe(a){if(je.has(a))return je.get(a);let b;try{b=new RegExp(a,"g")}catch(c){throw Error(`FORX0002: ${c}`);}if(b.test(""))throw Error(`FORX0003: the pattern ${a} matches the zero length string`);je.set(a,b);return b}
|
|
94
|
+
var ke=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d,e)=>{if(d.F()||e.F())return w.empty();a=d.first().value;e=e.first().value;return a>e?w.m(g(1,5)):a<e?w.m(g(-1,5)):w.m(g(0,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:5,g:0},callFunction:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",
|
|
95
|
+
j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(a,b,c,...d)=>{d=d.map(e=>qc(e,b).N(f=>w.m(g(f.map(h=>null===h?"":jd(h,1).value).join(""),1))));return A(d,e=>w.m(g(e.map(f=>f.value).join(""),1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(a,b,
|
|
96
|
+
c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;return 0===e.length?w.aa():0===a.length?w.T():a.includes(e)?w.aa():w.T()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(a,b,c,d,e)=>{a=e.F()?"":e.first().value;if(0===a.length)return w.aa();d=d.F()?"":d.first().value;return 0===d.length?w.T():d.endsWith(a)?w.aa():w.T()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",
|
|
97
|
+
j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:he},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:Ad("normalize-space",1,(a,b,c,d)=>he(a,b,c,ae(a,b,c,d)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},
|
|
98
|
+
callFunction:(a,b,c,d,e)=>{a=e.F()?"":e.first().value;if(0===a.length)return w.aa();d=d.F()?"":d.first().value;return 0===d.length?w.T():d.startsWith(a)?w.aa():w.T()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:ae},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
99
|
+
localName:"string",j:[],i:{type:1,g:3},callFunction:Ad("string",59,ae)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-before",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(a,b,c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;if(""===e)return w.m(g("",1));e=a.indexOf(e);return-1===e?w.m(g("",1)):w.m(g(a.substring(0,e),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,
|
|
100
|
+
g:3},callFunction:(a,b,c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;if(""===e)return w.m(g(a,1));b=a.indexOf(e);return-1===b?w.m(g("",1)):w.m(g(a.substring(b+e.length),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3}],i:{type:1,g:3},callFunction:ee},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3},{type:3,g:3}],i:{type:1,g:3},callFunction:ee},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
101
|
+
localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(a,b,c,d)=>d.F()?w.m(g("",1)):d.map(e=>g(e.value.toUpperCase(),1))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"lower-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(a,b,c,d)=>d.F()?w.m(g("",1)):d.map(e=>g(e.value.toLowerCase(),1))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2},{type:1,g:3}],i:{type:1,g:3},callFunction:be},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
102
|
+
localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction(a,b,c,d){return be(a,b,c,d,w.m(g("",1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:ce},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:Ad("string-length",46,(a,b,c,d)=>ce(a,b,c,ae(a,b,c,d)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,
|
|
103
|
+
g:0},{type:1,g:3},{type:1,g:3}],i:{type:1,g:2},callFunction(){throw Error("Not implemented: Using flags in tokenize is not supported");}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0},{type:1,g:3}],i:{type:1,g:2},callFunction:ge},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction(a,b,c,d){return ge(a,b,c,he(a,b,c,d),w.m(g(" ",1)))}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(a,
|
|
104
|
+
b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{h=Array.from(h?h.value:"");const n=Array.from(k.value),t=Array.from(l.value);k=h.map(u=>{if(n.includes(u)){if(u=n.indexOf(u),u<=t.length)return t[u]}else return u});return w.m(g(k.join(""),1))}),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{e=e.map(f=>{f=f.value;if(9===f||10===f||13===f||32<=f&&55295>=f||57344<=f&&65533>=f||65536<=f&&1114111>=f)return String.fromCodePoint(f);
|
|
105
|
+
throw Error("FOCH0001");}).join("");return w.m(g(e,1))}),localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(a,b,c,d)=>A([d],([e])=>{e=e?e.value.split(""):[];return 0===e.length?w.empty():w.create(e.map(f=>g(f.codePointAt(0),5)))}),localName:"string-to-codepoints",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:1,g:0}],callFunction:(a,b,c,d)=>A([d],([e])=>null===e||0===e.value.length?
|
|
106
|
+
w.create(g("",1)):w.create(g(encodeURIComponent(e.value).replace(/[!'()*]/g,f=>"%"+f.charCodeAt(0).toString(16).toUpperCase()),1))),localName:"encode-for-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(a,b,c,d)=>A([d],([e])=>null===e||0===e.value.length?w.create(g("",1)):w.create(g(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,f=>encodeURI(f)),1))),localName:"iri-to-uri",
|
|
107
|
+
namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:0}],callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(null===f||null===h)return w.empty();f=f.value;var k=h.value;if(f.length!==k.length)return w.T();h=f.split("");f=k.split("");for(k=0;k<h.length;k++)if(h[k].codePointAt(0)!==f[k].codePointAt(0))return w.T();return w.aa()}),localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:0}},{j:[{type:1,g:0},{type:1,g:3}],callFunction:(a,
|
|
108
|
+
b,c,d,e)=>A([d,e],([f,h])=>{f=f?f.value:"";h=h.value;let k=ie.get(h);if(!k){try{k=(0,Bd.compile)(h,{language:"xpath"})}catch(l){throw Error(`FORX0002: ${l}`);}ie.set(h,k)}return k(f)?w.aa():w.T()}),localName:"matches",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{h=h?h.value:"";k=k.value;l=l.value;if(l.includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");
|
|
109
|
+
l=l.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map(n=>{switch(n){case "\\$":return"$$";case "\\\\":return"\\";case "$$":throw Error('FORX0004: invalid replacement: "$$"');default:return n}}).join("");k=fe(k);h=h.replace(k,l);return w.m(g(h,1))}),localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3},{type:1,g:3}],localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3},callFunction(){throw Error("Not implemented: Using flags in replace is not supported");
|
|
110
|
+
}}];const le=new WeakMap;let me=0;const ne=(a,b,c,d)=>A([d],([e])=>{if(null===e)return w.empty();e=e.value;switch(e.node.nodeType){case 1:case 2:return w.m(g(new Sa(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return w.m(g(new Sa("","",e.node.target),23));default:return w.empty()}}),oe=(a,b,c,d)=>d.X({default:()=>ae(a,b,c,ne(a,b,c,d)),empty:()=>w.m(g("",1))}),pe=(a,b,c,d)=>qc(d,b),qe=(a,b,c,d)=>{if(d.F())return w.m(g("",1));if(!v(d.first().type,53))throw Error("XPTY0004: The context item must be a node.");c=d.first().value;
|
|
111
|
+
a=w;b=a.m;c=c.node;le.has(c)||le.set(c,`id${++me}`);c=le.get(c);return b.call(a,g(c,1))},re=(a,b,c,d)=>A([d],([e])=>{e=e?e.value:null;return null!==e&&ib(b.h,e,null)?w.aa():w.T()});function se(a,b){a=a.toLowerCase();b=b.toLowerCase();return a===b?!0:5>a.length||!a.startsWith(b)?!1:se(a.replace(/-[a-z0-9]+$/,""),b)}
|
|
112
|
+
const te=(a,b,c,d,e)=>{b=b.h;if(d.F())d="";else if(v(d.first().type,1))d=d.first().value;else throw Error("XPTY0004: The first argument of lang must be a string.");if(e)e=e.first().value;else{if(!a||!a.M)throw lc("The function lang depends on dynamic context if a node is not passed as the second argument.");if(!v(a.M.type,53))throw Error("XPTY0004: The context item must be a node.");e=a.M.value}a:{for(a=d;e;)if(1!==e.node.nodeType)e=x(b,e);else if(1===e.node.nodeType){if(d=fb(b,e,"xml:lang")){b=se(d,
|
|
113
|
+
a)?w.aa():w.T();break a}e=x(b,e)}b=w.T()}return b},ue=(a,b,c,d)=>A([d],([e])=>{function f(n){let t=0,u=n;for(;null!==u;)(n.node.nodeType!==u.node.nodeType?0:1===u.node.nodeType?u.node.localName===n.node.localName&&u.node.namespaceURI===n.node.namespaceURI:7===u.node.nodeType?u.node.target===n.node.target:1)&&t++,u=mb(h,u,null);return t}if(null===e)return w.empty();const h=b.h;let k="";for(e=e.value;null!==x(b.h,e,null);e=x(b.h,e,null))switch(e.node.nodeType){case 1:var l=e;k=`/Q{${l.node.namespaceURI||
|
|
114
|
+
""}}${l.node.localName}[${f(l)}]${k}`;break;case 2:l=e;k=`/@${l.node.namespaceURI?`Q{${l.node.namespaceURI}}`:""}${l.node.localName}${k}`;break;case 3:k=`/text()[${f(e)}]${k}`;break;case 7:l=e;k=`/processing-instruction(${l.node.target})[${f(l)}]${k}`;break;case 8:k=`/comment()[${f(e)}]${k}`}return 9===e.node.nodeType?w.create(g(k||"/",1)):w.create(g("Q{http://www.w3.org/2005/xpath-functions}root()"+k,1))}),ve=(a,b,c,d)=>d.map(e=>g(e.value.node.namespaceURI||"",20)),we=(a,b,c,d)=>d.X({default:()=>
|
|
115
|
+
d.map(e=>7===e.value.node.nodeType?g(e.value.node.target,1):g(e.value.node.localName||"",1)),empty:()=>w.m(g("",1))});function xe(a,b,c){if(2===b.node.nodeType)return md(b,c);for(;c;){if(md(b,c))return!0;if(9===c.node.nodeType)break;c=x(a,c,null)}return!1}const ye=(a,b,c,d)=>d.map(e=>{if(!v(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let f;for(e=e.value;e;)f=e,e=x(b.h,f,null);return rb(f)});
|
|
116
|
+
var ze=[{j:[{type:53,g:0}],callFunction:oe,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:Ad("name",53,oe),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:ve,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:Ad("namespace-uri",53,ve),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
117
|
+
i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{if(!e.length)return w.empty();e=td(b.h,e).reduceRight((f,h,k,l)=>{if(k===l.length-1)return f.push(h),f;if(xe(b.h,h.value,f[0].value))return f;f.unshift(h);return f},[]);return w.create(e)}),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{if(!e.length)return w.empty();e=td(b.h,e).reduce((f,h,k)=>{if(0===k)return f.push(h),f;if(xe(b.h,f[f.length-
|
|
118
|
+
1].value,h.value))return f;f.push(h);return f},[]);return w.create(e)},1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:re,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Ad("has-children",53,re),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:ue,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
119
|
+
i:{type:1,g:0}},{j:[],callFunction:Ad("path",53,ue),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:ne,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:Ad("node-name",53,ne),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:we,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
120
|
+
i:{type:1,g:3}},{j:[],callFunction:Ad("local-name",53,we),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:ye,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Ad("root",53,ye),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Ad("data",59,pe),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
121
|
+
i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:pe,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:1,g:0}],callFunction:te,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:53,g:3}],callFunction:te,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Ad("generate-id",53,qe),localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
122
|
+
i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:qe,localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}];function Ae(a,b){let c=0;const d=a.length;let e=!1,f=null;return{next:()=>{if(!e){for(;c<d;){f||=b(a[c],c,a);const h=f.next(0);f=null;if(h.value)c++;else return q(!1)}e=!0;return q(!0)}return p}}}function Be(a){a=a.node.nodeType;return 1===a||3===a}
|
|
123
|
+
function Ce(a,b){if((v(a.type,4)||v(a.type,6))&&(v(b.type,4)||v(b.type,6))){var c=jd(a,6),d=jd(b,6);return c.value===d.value||isNaN(a.value)&&isNaN(b.value)}return(v(a.type,4)||v(a.type,6)||v(a.type,3))&&(v(b.type,4)||v(b.type,6)||v(b.type,3))?(c=jd(a,3),d=jd(b,3),c.value===d.value||isNaN(a.value)&&isNaN(b.value)):v(a.type,23)&&v(b.type,23)?a.value.namespaceURI===b.value.namespaceURI&&a.value.localName===b.value.localName:(v(a.type,9)||v(a.type,7)||v(a.type,8)||v(a.type,11)||v(a.type,12)||v(a.type,
|
|
124
|
+
13)||v(a.type,14)||v(a.type,15))&&(v(b.type,9)||v(b.type,7)||v(b.type,8)||v(b.type,11)||v(b.type,12)||v(b.type,13)||v(b.type,14)||v(b.type,15))?Ob(a.value,b.value):(v(a.type,16)||v(a.type,17)||v(a.type,18))&&(v(b.type,16)||v(b.type,17)||v(b.type,17))?vb(a.value,b.value):a.value===b.value}function De(a,b,c){const [d,e]=[b,c].map(f=>({type:1,value:f.reduce((h,k)=>h+=pc(k,a).first().value,"")}));return q(Ce(d,e))}
|
|
125
|
+
function Ee(a,b,c,d){for(;a.value&&v(a.value.type,56);){b.push(a.value);const e=lb(d,a.value.value);a=c.next(0);if(e&&3!==e.node.nodeType)break}return a}
|
|
126
|
+
function Fe(a,b,c,d,e){const f=b.h,h=d.value,k=e.value;let l=null,n=null,t=null,u;const z=[],y=[];return{next:()=>{for(;!u;)if(l||=h.next(0),l=Ee(l,z,h,f),n||=k.next(0),n=Ee(n,y,k,f),z.length||y.length){var G=De(b,z,y);z.length=0;y.length=0;if(!1===G.value)return u=!0,G}else{if(l.done||n.done)return u=!0,q(l.done===n.done);t||=Ge(a,b,c,l.value,n.value);G=t.next(0);t=null;if(!1===G.value)return u=!0,G;n=l=null}return p}}}
|
|
127
|
+
function He(a,b,c,d,e){return d.h.length!==e.h.length?kd(!1):Ae(d.h,f=>{const h=e.h.find(k=>Ce(k.key,f.key));return h?Fe(a,b,c,f.value(),h.value()):kd(!1)})}function Ie(a,b,c,d,e){return d.h.length!==e.h.length?kd(!1):Ae(d.h,(f,h)=>{h=e.h[h];return Fe(a,b,c,f(),h())})}function Je(a,b,c,d,e){d=gb(b.h,d.value);e=gb(b.h,e.value);d=d.filter(f=>Be(f));e=e.filter(f=>Be(f));d=w.create(d.map(f=>rb(f)));e=w.create(e.map(f=>rb(f)));return Fe(a,b,c,d,e)}
|
|
128
|
+
function Ke(a,b,c,d,e){const f=Fe(a,b,c,ne(a,b,c,w.m(d)),ne(a,b,c,w.m(e))),h=Je(a,b,c,d,e);d=eb(b.h,d.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>rb(n));e=eb(b.h,e.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>rb(n));const k=Fe(a,b,c,w.create(d),w.create(e));let l=!1;return{next:()=>{if(l)return p;var n=f.next(0);if(!n.done&&!1===n.value)return l=
|
|
129
|
+
!0,n;n=k.next(0);if(!n.done&&!1===n.value)return l=!0,n;n=h.next(0);l=!0;return n}}}function Le(a,b,c,d,e){const f=Fe(a,b,c,ne(a,b,c,w.m(d)),ne(a,b,c,w.m(e)));let h=!1;return{next:()=>{if(h)return p;const k=f.next(0);return k.done||!1!==k.value?q(Ce(pc(d,b).first(),pc(e,b).first())):(h=!0,k)}}}
|
|
130
|
+
function Ge(a,b,c,d,e){if(v(d.type,46)&&v(e.type,46))return kd(Ce(d,e));if(v(d.type,61)&&v(e.type,61))return He(a,b,c,d,e);if(v(d.type,62)&&v(e.type,62))return Ie(a,b,c,d,e);if(v(d.type,53)&&v(e.type,53)){if(v(d.type,55)&&v(e.type,55))return Je(a,b,c,d,e);if(v(d.type,54)&&v(e.type,54))return Ke(a,b,c,d,e);if(v(d.type,47)&&v(e.type,47)||v(d.type,57)&&v(e.type,57)||v(d.type,58)&&v(e.type,58))return Le(a,b,c,d,e)}return kd(!1)};var Me=class extends cc{constructor(){super({M:null,Aa:-1,ta:w.empty(),ra:{}})}};var Ne=(a="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${a}`),Oe=a=>Error(`XUTY0004: The attribute ${a.name}="${a.value}" follows a node that is not an attribute node.`),Pe=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Qe=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),Re=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),
|
|
131
|
+
Se=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Te=a=>Error(`XUDY0017: The target ${a.outerHTML} is used in more than one replace value of expression.`),Ue=a=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${a}'`),Ve=a=>Error(`XUDY0023: The namespace binding ${a} is conflicting.`),We=a=>Error(`XUDY0024: The namespace binding ${a} is conflicting.`),Xe=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function C(a,b,c){b&&null!==b.M?a.B?(null===a.ob&&(a.ob=Ra(a.h(new Me,c).hb())),a=a.ob()):a=a.h(b,c):a=a.h(b,c);return a}var D=class{constructor(a,b,c={B:!1,W:!1,R:"unsorted",subtree:!1},d=!1,e){this.o=a;this.ia=c.R||"unsorted";this.subtree=!!c.subtree;this.W=!!c.W;this.B=!!c.B;this.Fa=b;this.I=!1;this.ob=null;this.Qb=d;this.type=e}D(){return null}v(a){this.Fa.forEach(b=>b.v(a));if(!this.Qb&&this.Fa.some(b=>b.I))throw Ne();}};var Ye=class{constructor(a,b){this.J=a;this.da=b}};var Ze=class{constructor(a){a&&"object"===typeof a&&"nodeType"in a&&(a=a.ownerDocument||a,"function"===typeof a.createElementNS&&"function"===typeof a.createProcessingInstruction&&"function"===typeof a.createTextNode&&"function"===typeof a.createComment&&(this.h=a));this.h||(this.h=null)}createAttributeNS(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(a,b)}createCDATASection(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");
|
|
132
|
+
return this.h.createCDATASection(a)}createComment(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(a)}createDocument(){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.implementation.createDocument(null,null,null)}createElementNS(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createElementNS(a,
|
|
133
|
+
b)}createProcessingInstruction(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(a,b)}createTextNode(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(a)}};function $e(a,b,c,d){return eb(d,a,`name-${b}`).some(e=>e.node.localName===b&&e.node.namespaceURI===c)}
|
|
134
|
+
var af=(a,b,c,d)=>{const e=x(c,a).node,f=(a=lb(c,a))?a.node:null;b.forEach(h=>{d.insertBefore(e,h.node,f)})},bf=(a,b,c,d)=>{const e=x(c,a).node;b.forEach(f=>{d.insertBefore(e,f.node,a.node)})},cf=(a,b,c,d)=>{const e=(c=ib(c,a))?c.node:null;b.forEach(f=>{d.insertBefore(a.node,f.node,e)})},df=(a,b,c)=>{b.forEach(d=>{c.insertBefore(a.node,d.node,null)})},ef=(a,b,c,d)=>{b.forEach(e=>{const f=e.node.localName,h=e.node.namespaceURI;if($e(a,f,h,c))throw Ue(`An attribute ${h?`Q{${h}}${f}`:f} already exists.`);
|
|
135
|
+
d.setAttributeNS(a.node,h,f,hb(c,e))})},gf=(a,b,c,d,e)=>{d||=new Ze(a?a.node:null);let f;switch(a.node.nodeType){case 1:const h=c.getAllAttributes(a.node),k=c.getChildNodes(a.node),l=d.createElementNS(b.namespaceURI,b.za());f={node:l,G:null};h.forEach(n=>{e.setAttributeNS(l,n.namespaceURI,n.nodeName,n.value)});k.forEach(n=>{e.insertBefore(l,n,null)});break;case 2:b=d.createAttributeNS(b.namespaceURI,b.za());b.value=hb(c,a);f={node:b,G:null};break;case 7:f={node:d.createProcessingInstruction(b.za(),
|
|
136
|
+
hb(c,a)),G:null}}if(!x(c,a))throw Error("Not supported: renaming detached nodes.");ff(a,[f],c,e)},hf=(a,b,c,d)=>{c.getChildNodes(a.node).forEach(e=>d.removeChild(a.node,e));b&&d.insertBefore(a.node,b.node,null)},ff=(a,b,c,d)=>{const e=x(c,a);var f=a.node.nodeType;if(2===f){if(b.some(k=>2!==k.node.nodeType))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const h=e?e.node:null;d.removeAttributeNS(h,a.node.namespaceURI,a.node.localName);
|
|
137
|
+
b.forEach(k=>{const l=k.node.localName,n=k.node.namespaceURI;if($e(e,l,n,c))throw Ue(`An attribute ${n?`Q{${n}}${l}`:l} already exists.`);d.setAttributeNS(h,n,l,hb(c,k))})}if(1===f||3===f||8===f||7===f){const h=(f=lb(c,a))?f.node:null;d.removeChild(e.node,a.node);b.forEach(k=>{d.insertBefore(e.node,k.node,h)})}};var kf=(a,b,c,d)=>{jf(a,b);a.filter(e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertInto":df(e.target,e.content,d);break;case "insertAttributes":ef(e.target,e.content,b,d);break;case "rename":gf(e.target,e.o,b,c,d);break;case "replaceValue":var f=e.target;e=e.o;if(2===f.node.nodeType){const h=x(b,f);h?d.setAttributeNS(h.node,f.node.namespaceURI,f.node.localName,e):f.node.value=e}else d.setData(f.node,e)}});a.filter(e=>-1!==
|
|
138
|
+
["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertAfter":af(e.target,e.content,b,d);break;case "insertBefore":bf(e.target,e.content,b,d);break;case "insertIntoAsFirst":cf(e.target,e.content,b,d);break;case "insertIntoAsLast":df(e.target,e.content,d)}});a.filter(e=>"replaceNode"===e.type).forEach(e=>{ff(e.target,e.o,b,d)});a.filter(e=>"replaceElementContent"===e.type).forEach(e=>{hf(e.target,e.text,b,d)});a.filter(e=>"delete"===
|
|
139
|
+
e.type).forEach(e=>{e=e.target;var f=x(b,e);(f=f?f.node:null)&&(2===e.node.nodeType?d.removeAttributeNS(f,e.node.namespaceURI,e.node.localName):d.removeChild(f,e.node))});if(a.some(e=>"put"===e.type))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.');};
|
|
140
|
+
const jf=(a,b)=>{function c(f,h){const k=new Set;a.filter(l=>l.type===f).map(l=>l.target).forEach(l=>{l=l?l.node:null;k.has(l)&&h(l);k.add(l)})}c("rename",f=>{throw Error(`XUDY0015: The target ${f.outerHTML} is used in more than one rename expression.`);});c("replaceNode",f=>{throw Error(`XUDY0016: The target ${f.outerHTML} is used in more than one replace expression.`);});c("replaceValue",f=>{throw Te(f);});c("replaceElementContent",f=>{throw Te(f);});const d=new Map,e=f=>new Sa(f.node.prefix,f.node.namespaceURI,
|
|
141
|
+
f.node.localName);a.filter(f=>"replaceNode"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);h=h?h.node:null;const k=d.get(h);k?k.push(...f.o.map(e)):d.set(h,f.o.map(e))});a.filter(f=>"rename"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);if(h){h=h.node;var k=d.get(h);k?k.push(f.o):d.set(h,[f.o])}});d.forEach(f=>{const h={};f.forEach(k=>{h[k.prefix]||(h[k.prefix]=k.namespaceURI);if(h[k.prefix]!==k.namespaceURI)throw We(k.namespaceURI);})})};
|
|
142
|
+
var lf=(a,...b)=>a.concat(...b.filter(Boolean));function mf(a){return a.I?(b,c)=>a.s(b,c):(b,c)=>{const d=a.h(b,c);return{next:()=>{const e=d.O();return q({da:[],J:e})}}}}var nf=class extends D{constructor(a,b,c,d){super(a,b,c,!0,d);this.I=!0}h(){throw Ne();}};function of(a,b){a=a.next(0);b(a.value.da);return w.create(a.value.J)}function pf(a){a.Fa.some(b=>b.I)&&(a.I=!0)}var qf=class extends nf{constructor(a,b,c,d){super(a,b,c,d);this.I=this.Fa.some(e=>e.I)}h(a,b){return this.A(a,b,this.Fa.map(c=>d=>c.h(d,b)))}s(a,b){let c=[];const d=this.A(a,b,this.Fa.map(f=>f.I?h=>{h=f.s(h,b);return of(h,k=>c=lf(c,k))}:h=>f.h(h,b)));let e=!1;return{next:()=>{if(e)return p;const f=d.O();e=!0;return q(new Ye(f,c))}}}v(a){super.v(a);pf(this)}};const rf=["external","attribute","nodeName","nodeType","universal"],sf=rf.length;function tf(a,b){for(let c=0;c<sf;++c){if(b.h[c]<a.h[c])return 1;if(b.h[c]>a.h[c])return-1}return 0}var uf=class{constructor(a){this.h=rf.map(b=>a[b]||0);if(Object.keys(a).some(b=>!rf.includes(b)))throw Error("Invalid specificity kind passed");}add(a){const b=rf.reduce((c,d,e)=>{c[d]=this.h[e]+a.h[e];return c},Object.create(null));return new uf(b)}};const vf=()=>mc("Expected base expression of a function call to evaluate to a sequence of single function item");function wf(a,b,c,d){const e=[];for(let f=0;f<b.length;++f){if(null===b[f]){e.push(null);continue}const h=zd(a[f],b[f],c,d,!1);e.push(h)}return e}function Cf(a,b){if(!v(a.type,60))throw mc("Expected base expression to evaluate to a function item");if(a.v!==b)throw vf();return a}
|
|
143
|
+
function Df(a,b,c,d,e,f,h){let k=0;e=e.map(l=>l?null:f[k++](c));e=wf(a.o,e,d,a.D);if(0<=e.indexOf(null))return Ta(a,e);b=b.apply(void 0,[c,d,h,...e]);return zd(a.s,b,d,a.D,!0)}
|
|
144
|
+
var Ff=class extends qf{constructor(a,b,c){super(new uf({external:1}),[a].concat(b.filter(d=>!!d)),{R:"unsorted",W:!1,subtree:!1,B:!1},c);this.ma=b.length;this.P=b.map(d=>null===d);this.L=null;this.ya=a;this.La=b}s(a,b){if(!this.l||!this.l.I)return super.s(a,b);let c=[];const d=Df(this.l,(f,h,k,...l)=>of(this.l.value(f,h,k,...l),n=>{c=lf(c,n)}),a,b,this.P,this.La.map(f=>()=>f.I?of(f.s(a,b),h=>{c=lf(c,h)}):C(f,a,b)),this.L);let e=!1;return{next:()=>{if(e)return p;const f=d.O();e=!0;return q({da:c,
|
|
145
|
+
J:f})}}}A(a,b,[c,...d]){if(this.l)return Df(this.l,(f,h,k,...l)=>this.l.value(f,h,k,...l),a,b,this.P,d,this.L);const e=c(a);return e.X({default:()=>{throw vf();},m:()=>e.N(([f])=>{f=Cf(f,this.ma);if(f.I)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return Df(f,f.value,a,b,this.P,d,this.L)})})}v(a){this.L=Ef(a);super.v(a);if(this.ya.B){a=C(this.ya,null,null);if(!a.oa())throw vf();this.l=Cf(a.first(),this.ma);this.l.I&&
|
|
146
|
+
(this.I=!0)}}};const Gf=(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{k=k.value;l=l.value;if(k>h.h.length||0>=k)throw Error("FOAY0001: subarray start out of bounds.");if(0>l)throw Error("FOAY0002: subarray length out of bounds.");if(k+l>h.h.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return w.m(new pb(h.h.slice(k-1,l+k-1)))}),Hf=(a,b,c,d,e)=>A([d],([f])=>e.N(h=>{h=h.map(l=>l.value).sort((l,n)=>n-l).filter((l,n,t)=>t[n-1]!==l);const k=f.h.concat();for(let l=0,n=h.length;l<n;++l){const t=h[l];
|
|
147
|
+
if(t>f.h.length||0>=t)throw Error("FOAY0001: subarray position out of bounds.");k.splice(t-1,1)}return w.m(new pb(k))})),If=a=>v(a,1)||v(a,20)||v(a,19),Jf=(a,b,c,d,e)=>0===d.length?0!==e.length:0!==e.length&&Ge(a,b,c,d[0],e[0]).next(0).value?Jf(a,b,c,d.slice(1),e.slice(1)):d[0].value!==d[0].value?!0:If(d[0].type)&&0!==e.length&&If(e[0].type)?d[0].value<e[0].value:0===e.length?!1:d[0].value<e[0].value,Kf=(a,b,c,d)=>{d.sort((e,f)=>Fe(a,b,c,w.create(e),w.create(f)).next(0).value?0:Jf(a,b,c,e,f)?-1:1);
|
|
148
|
+
return w.m(new pb(d.map(e=>()=>w.create(e))))};function Lf(a){return v(a.type,62)?jc(a.h.map(b=>b().N(c=>jc(c.map(Lf))))):w.m(a)}
|
|
149
|
+
var Mf=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>w.m(g(e.h.length,5)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"get",j:[{type:62,g:3},{type:5,g:3}],i:{type:59,g:2},callFunction:ob},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"put",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(a,b,c,d,e,f)=>A([e,d],([h,k])=>
|
|
150
|
+
{h=h.value;if(0>=h||h>k.h.length)throw Error("FOAY0001: array position out of bounds.");k=k.h.concat();k.splice(h-1,1,Ra(f));return w.m(new pb(k))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"append",j:[{type:62,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(a,b,c,d,e)=>A([d],([f])=>w.m(new pb(f.h.concat([Ra(e)]))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction:Gf},
|
|
151
|
+
{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction(a,b,c,d,e){const f=w.m(g(d.first().value.length-e.first().value+1,5));return Gf(a,b,c,d,e,f)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"remove",j:[{type:62,g:3},{type:5,g:2}],i:{type:62,g:3},callFunction:Hf},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",j:[{type:62,g:3},{type:5,g:3},{type:59,
|
|
152
|
+
g:2}],i:{type:62,g:3},callFunction:(a,b,c,d,e,f)=>A([d,e],([h,k])=>{k=k.value;if(k>h.h.length+1||0>=k)throw Error("FOAY0001: subarray position out of bounds.");h=h.h.concat();h.splice(k-1,0,Ra(f));return w.m(new pb(h))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(a,b,c,d){return ob(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},
|
|
153
|
+
callFunction(a,b,c,d){return Hf(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>w.m(new pb(e.h.concat().reverse())))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(a,b,c,d)=>d.N(e=>{e=e.reduce((f,h)=>f.concat(h.h),[]);return w.m(new pb(e))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",
|
|
154
|
+
localName:"for-each",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(1!==h.v)throw mc("The callback passed into array:for-each has a wrong arity.");f=f.h.map(k=>Ra(h.value.call(void 0,a,b,c,wf(h.o,[k()],b,"array:for-each")[0])));return w.m(new pb(f))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"filter",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(1!==h.v)throw mc("The callback passed into array:filter has a wrong arity.");
|
|
155
|
+
const k=f.h.map(t=>{t=wf(h.o,[t()],b,"array:filter")[0];const u=h.value;return u(a,b,c,t)}),l=[];let n=!1;return w.create({next:()=>{if(n)return p;for(let u=0,z=f.h.length;u<z;++u){var t=k[u].fa();l[u]=t}t=f.h.filter((u,z)=>l[z]);n=!0;return q(new pb(t))}})})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-left",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(a,b,c,d,e,f)=>A([d,f],([h,k])=>{if(2!==k.v)throw mc("The callback passed into array:fold-left has a wrong arity.");
|
|
156
|
+
return h.h.reduce((l,n)=>{n=wf(k.o,[n()],b,"array:fold-left")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-right",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(a,b,c,d,e,f)=>A([d,f],([h,k])=>{if(2!==k.v)throw mc("The callback passed into array:fold-right has a wrong arity.");return h.h.reduceRight((l,n)=>{n=wf(k.o,[n()],b,"array:fold-right")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},
|
|
157
|
+
{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each-pair",j:[{type:62,g:3},{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{if(2!==l.v)throw mc("The callback passed into array:for-each-pair has a wrong arity.");const n=[];for(let t=0,u=Math.min(h.h.length,k.h.length);t<u;++t){const [z,y]=wf(l.o,[h.h[t](),k.h[t]()],b,"array:for-each-pair");n[t]=Ra(l.value.call(void 0,a,b,c,z,y))}return w.m(new pb(n))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",
|
|
158
|
+
localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>{e=e.h.map(f=>f().O());return Kf(a,b,c,e)})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(a,b,c,d)=>d.N(e=>jc(e.map(Lf)))}];function E(a,b,c,d,e){return e.F()?e:w.m(jd(e.first(),a))}
|
|
159
|
+
var Nf=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:E.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:E.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:E.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,
|
|
160
|
+
g:0},callFunction:E.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:E.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:E.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:E.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,
|
|
161
|
+
g:0}],i:{type:18,g:0},callFunction:E.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:E.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:E.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:E.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",
|
|
162
|
+
j:[{type:46,g:0}],i:{type:7,g:0},callFunction:E.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:E.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:E.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:E.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
163
|
+
localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:E.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:E.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:E.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:E.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
164
|
+
localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(a,b,c,d)=>{if(d.F())return d;a=d.first();if(v(a.type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");a=jd(a,1).value;a=sc(a,23);if(!tc(a,23))throw Error("FORG0001: The provided QName is invalid.");if(!a.includes(":"))return c=c.$(""),w.m(g(new Sa("",c,a),23));const [e,f]=a.split(":");c=c.$(e);if(!c)throw Error(`FONS0004: The value ${a} can not be cast to a QName. Did you mean to use fn:QName?`);return w.m(g(new Sa(e,
|
|
165
|
+
c,f),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:E.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:E.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:E.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],
|
|
166
|
+
i:{type:51,g:0},callFunction:E.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:E.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:E.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:E.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",
|
|
167
|
+
j:[{type:46,g:0}],i:{type:24,g:0},callFunction:E.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:E.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:E.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:E.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
168
|
+
localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:E.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",j:[{type:46,g:0}],i:{type:40,g:2},callFunction:E.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",j:[{type:46,g:0}],i:{type:5,g:0},callFunction:E.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",j:[{type:46,g:0}],i:{type:27,g:0},callFunction:E.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
169
|
+
localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:E.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:E.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:E.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:E.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
170
|
+
localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:E.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:E.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:E.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:E.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
|
|
171
|
+
localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:E.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:E.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:E.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:E.bind(null,
|
|
172
|
+
16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:E.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:E.bind(null,10)}];const Of=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getYear(),5)),Pf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMonth(),5)),Qf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getDay(),5)),Rf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getHours(),5)),Sf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMinutes(),5)),Tf=(a,b,c,d)=>{d.F()||(a=w,b=a.m,d=d.first().value,d=b.call(a,g(d.D+d.qa,4)));return d},Uf=(a,b,c,d)=>d.F()?d:(a=d.first().value.Y)?w.m(g(a,17)):w.empty();
|
|
173
|
+
var Vf=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"dateTime",j:[{type:7,g:0},{type:8,g:0}],i:{type:9,g:0},callFunction:(a,b,c,d,e)=>{if(d.F())return d;if(e.F())return e;a=d.first().value;e=e.first().value;b=a.Y;c=e.Y;if(b||c){if(!b||c)if(!b&&c)b=c;else if(!vb(b,c))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.");}else b=null;return w.m(g(new Kb(a.getYear(),a.getMonth(),a.getDay(),e.getHours(),e.getMinutes(),e.getSeconds(),e.qa,b),9))}},
|
|
174
|
+
{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Of},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,
|
|
175
|
+
g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
176
|
+
localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Of},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
177
|
+
localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:Uf}];function Wf(a,b){const c=b.h,d=b.Ja,e=b.Ma;switch(a.node.nodeType){case 1:const h=d.createElementNS(a.node.namespaceURI,a.node.nodeName);c.getAllAttributes(a.node).forEach(k=>e.setAttributeNS(h,k.namespaceURI,k.nodeName,k.value));for(var f of gb(c,a))a=Wf(f,b),e.insertBefore(h,a.node,null);return{node:h,G:null};case 2:return b=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),b.value=hb(c,a),{node:b,G:null};case 4:return{node:d.createCDATASection(hb(c,a)),G:null};case 8:return{node:d.createComment(hb(c,
|
|
178
|
+
a)),G:null};case 9:f=d.createDocument();for(const k of gb(c,a))a=Wf(k,b),e.insertBefore(f,a.node,null);return{node:f,G:null};case 7:return{node:d.createProcessingInstruction(a.node.target,hb(c,a)),G:null};case 3:return{node:d.createTextNode(hb(c,a)),G:null}}};function Xf(a,b){const c=b.Ma;var d=b.Ja;const e=b.h;if(cb(a.node))switch(a.node.nodeType){case 2:return d=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),d.value=hb(e,a),d;case 8:return d.createComment(hb(e,a));case 1:const f=a.node.prefix,h=a.node.localName,k=d.createElementNS(a.node.namespaceURI,f?f+":"+h:h);gb(e,a).forEach(l=>{l=Xf(l,b);c.insertBefore(k,l,null)});eb(e,a).forEach(l=>{c.setAttributeNS(k,l.node.namespaceURI,l.node.nodeName,hb(e,l))});k.normalize();return k;case 7:return d.createProcessingInstruction(a.node.target,
|
|
179
|
+
hb(e,a));case 3:return d.createTextNode(hb(e,a))}else return Wf(a,b).node}function Yf(a,b,c){let d=a;for(a=x(c,d);null!==a;){if(2===d.node.nodeType)b.push(d.node.nodeName);else{const e=gb(c,a);b.push(e.findIndex(f=>md(f,d)))}d=a;a=x(c,d)}return d}function Zf(a,b,c){for(;0<b.length;){const d=b.pop();"string"===typeof d?a=eb(c,a).find(e=>e.node.nodeName===d):a=gb(c,a)[d]}return a.node}
|
|
180
|
+
function $f(a,b,c){var d=a.node;if(!(cb(d)||c||a.G))return d;d=b.v;const e=[];if(c)return Xf(a,b);a=Yf(a,e,b.h);c=d.get(a.node);c||(c={node:Xf(a,b),G:null},d.set(a.node,c));return Zf(c,e,b.h)};const ag=(a,b,c,d,e)=>d.N(f=>{var h;let k="";for(let l=0;l<f.length;l++){const n=f[l],t=b.Ua&&v(n.type,53)?b.Ua.serializeToString($f(n.value,b,!1)):null===(h=qc(w.m(n),b).map(u=>jd(u,1)).first())||void 0===h?void 0:h.value;t&&(k+=`{type: ${Da[n.type]}, value: ${t}}\n`)}void 0!==e&&(k+=e.first().value);b.jb.trace(k);return w.create(f)});
|
|
181
|
+
var bg=[{j:[{type:59,g:2}],callFunction:ag,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:1,g:3}],callFunction:ag,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const cg=(a,b,c,d,e)=>{a=void 0===d||d.F()?new Sa("err","http://www.w3.org/2005/xqt-errors","FOER0000"):d.first().value;b="";void 0===e||e.F()||(b=`: ${e.first().value}`);throw Error(`${a.localName}${b}`);};
|
|
182
|
+
var dg=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:cg},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:cg},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3}],i:{type:63,g:3},callFunction:cg},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3},{type:59,g:2}],i:{type:63,
|
|
183
|
+
g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported");}}];function eg(a){return"string"===typeof a?a:(a=(new Za).getChildNodes(a).find(b=>8===b.nodeType))?a.data:"some expression"};var fg=class extends Error{constructor(a,b){super(a);this.position={end:{ha:b.end.ha,line:b.end.line,offset:b.end.offset},start:{ha:b.start.ha,line:b.start.line,offset:b.start.offset}}}};function gg(a,b){if(b instanceof Error)throw b;"string"!==typeof a&&(a=eg(a));const c=hg(b);a=a.replace(/\r/g,"").split("\n");const d=Math.floor(Math.log10(Math.min(c.end.line+2,a.length)))+1;a=a.reduce((e,f,h)=>{var k=h+1;if(2<c.start.line-k||2<k-c.end.line)return e;h=`${Array(d).fill(" ",0,Math.floor(Math.log10(k))+1-d).join("")}${k}: `;e.push(`${h}${f}`);if(k>=c.start.line&&k<=c.end.line){const l=k<c.end.line?f.length+h.length:c.end.ha-1+h.length;k=k>c.start.line?h.length:c.start.ha-1+h.length;
|
|
184
|
+
f=" ".repeat(h.length)+Array.from(f.substring(0,k-h.length),n=>"\t"===n?"\t":" ").join("")+"^".repeat(l-k);e.push(f)}return e},[]);b=ig(b).join("\n");throw new fg(a.join("\n")+"\n\n"+b,c);};const jg=Object.create(null);function kg(a,b){const c=new Map;for(let d=0;d<a.length+1;++d)c.set(d,new Map);return function h(e,f){if(0===e)return f;if(0===f)return e;if(c.get(e).has(f))return c.get(e).get(f);var k=0;a[e-1]!==b[f-1]&&(k=1);k=Math.min(h(e-1,f)+1,h(e,f-1)+1,h(e-1,f-1)+k);c.get(e).set(f,k);return k}(a.length,b.length)}
|
|
185
|
+
function lg(a){const b=jg[a]?jg[a]:Object.keys(jg).map(c=>({name:c,sb:kg(a,c.slice(c.lastIndexOf(":")+1))})).sort((c,d)=>c.sb-d.sb).slice(0,5).filter(c=>c.sb<a.length/2).reduce((c,d)=>c.concat(jg[d.name]),[]).slice(0,5);return b.length?b.map(c=>`"Q{${c.namespaceURI}}${c.localName} (${c.j.map(d=>4===d?"...":Ha(d)).join(", ")})"`).reduce((c,d,e,f)=>0===e?c+d:c+((e!==f.length-1?", ":" or ")+d),"Did you mean ")+"?":"No similar functions found."}
|
|
186
|
+
function mg(a,b,c){var d=jg[a+":"+b];return d?(d=d.find(e=>e.j.some(f=>4===f)?e.j.length-1<=c:e.j.length===c))?{j:d.j,arity:c,callFunction:d.callFunction,I:d.I,localName:b,namespaceURI:a,i:d.i}:null:null}function ng(a,b,c,d,e){jg[a+":"+b]||(jg[a+":"+b]=[]);jg[a+":"+b].push({j:c,arity:c.length,callFunction:e,I:!1,localName:b,namespaceURI:a,i:d})};var og={xml:"http://www.w3.org/XML/1998/namespace",xs:"http://www.w3.org/2001/XMLSchema",fn:"http://www.w3.org/2005/xpath-functions",map:"http://www.w3.org/2005/xpath-functions/map",array:"http://www.w3.org/2005/xpath-functions/array",math:"http://www.w3.org/2005/xpath-functions/math",fontoxpath:"http://fontoxml.com/fontoxpath",local:"http://www.w3.org/2005/xquery-local-functions"};var pg=class{constructor(a,b,c,d){this.Da=[Object.create(null)];this.Ea=Object.create(null);this.s=a;this.ia=Object.keys(b).reduce((e,f)=>{if(void 0===b[f])return e;e[f]=`Q{}${f}[0]`;return e},Object.create(null));this.o=Object.create(null);this.h=Object.create(null);this.v=c;this.l=d;this.D=[]}va(a,b,c){return mg(a,b,c)}eb(a,b){if(a)return null;a=this.ia[b];this.o[b]||(this.o[b]={name:b});return a}Sa(a,b){const c=this.l(a,b);if(c)this.D.push({dc:a,arity:b,Db:c});else if(""===a.prefix){if(this.v)return{namespaceURI:this.v,
|
|
187
|
+
localName:a.localName}}else if(b=this.$(a.prefix,!0))return{namespaceURI:b,localName:a.localName};return c}$(a,b=!0){if(!b)return null;if(og[a])return og[a];b=this.s(a);this.h[a]||(this.h[a]={namespaceURI:b,prefix:a});return void 0!==b||a?b:null}};var qg=(a,b)=>{a=2===a.node.nodeType?`${a.node.nodeName}="${hb(b,a)}"`:a.node.outerHTML;return Error(`XQTY0024: The node ${a} follows a node that is not an attribute node or a namespace node.`)},rg=a=>Error(`XQDY0044: The node name "${a.za()}" is invalid for a computed attribute constructor.`),sg=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),tg=(a,b)=>Error(`XQST0049: The function or variable "Q{${a}}${b}" is declared more than once.`),ug=
|
|
188
|
+
()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),vg=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),wg=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),xg=a=>Error(`XQDY0074: The value "${a}" of a name expressions cannot be converted to an expanded QName.`),yg=a=>Error(`XPST0081: The prefix "${a}" could not be resolved`);function zg(a,b){return`Q{${a||""}}${b}`}function Ag(a,b){for(let c=a.length-1;0<=c;--c)if(b in a[c])return a[c][b]}function Ef(a){const b=new Bg(a.o);for(let c=0;c<a.h+1;++c)b.D=[Object.assign(Object.create(null),b.D[0],a.D[c])],b.Da=[Object.assign(Object.create(null),b.Da[0],a.Da[c])],b.l=Object.assign(Object.create(null),a.l),b.Ea=a.Ea,b.v=a.v;return b}function Cg(a){a.s++;a.h++;a.D[a.h]=Object.create(null);a.Da[a.h]=Object.create(null)}function Dg(a,b,c){return(a=a.Ea[zg(b,c)])?a:null}
|
|
189
|
+
function Eg(a,b,c,d,e){d=zg(b,c)+"~"+d;if(a.l[d])throw tg(b,c);a.l[d]=e}function Fg(a,b,c){a.D[a.h][b]=c}function Gg(a,b,c){b=zg(b||"",c);return a.Da[a.h][b]=`${b}[${a.s}]`}function Hg(a,b,c,d){a.Ea[`${zg(b||"",c)}[${a.s}]`]=d}function Ig(a){a.D.length=a.h;a.Da.length=a.h;a.h--}
|
|
190
|
+
var Bg=class{constructor(a){this.o=a;this.s=this.h=0;this.D=[Object.create(null)];this.l=Object.create(null);this.v=null;this.Ea=a&&a.Ea;this.Da=a&&a.Da}va(a,b,c,d=!1){const e=this.l[zg(a,b)+"~"+c];return!e||d&&e.wb?null===this.o?null:this.o.va(a,b,c,d):e}eb(a,b){const c=Ag(this.Da,zg(a,b));return c?c:null===this.o?null:this.o.eb(a,b)}Sa(a,b){var c=a.prefix;const d=a.localName;return""===c&&this.v?{localName:d,namespaceURI:this.v}:c&&(c=this.$(c,!1))?{localName:d,namespaceURI:c}:null===this.o?null:
|
|
191
|
+
this.o.Sa(a,b)}$(a,b=!0){const c=Ag(this.D,a||"");return void 0===c?null===this.o?void 0:this.o.$(a||"",b):c}};function F(a,b){"*"===b||Array.isArray(b)||(b=[b]);for(let c=1;c<a.length;++c){if(!Array.isArray(a[c]))continue;const d=a[c];if("*"===b||b.includes(d[0]))return d}return null}function H(a){return 2>a.length?"":"object"===typeof a[1]?a[2]||"":a[1]||""}function I(a,b){if(!Array.isArray(a))return null;a=a[1];return"object"!==typeof a||Array.isArray(a)?null:b in a?a[b]:null}function J(a,b){return b.reduce(F,a)}
|
|
192
|
+
function K(a,b){const c=[];for(let d=1;d<a.length;++d){if(!Array.isArray(a[d]))continue;const e=a[d];"*"!==b&&e[0]!==b||c.push(e)}return c}function Jg(a){return{localName:H(a),namespaceURI:I(a,"URI"),prefix:I(a,"prefix")}}
|
|
193
|
+
function Kg(a){const b=F(a,"typeDeclaration");if(!b||F(b,"voidSequenceType"))return{type:59,g:2};const c=f=>{switch(f[0]){case "documentTest":return 55;case "elementTest":return 54;case "attributeTest":return 47;case "piTest":return 57;case "commentTest":return 58;case "textTest":return 56;case "anyKindTest":return 53;case "anyItemType":return 59;case "anyFunctionTest":case "functionTest":case "typedFunctionTest":return 60;case "anyMapTest":case "typedMapTest":return 61;case "anyArrayTest":case "typedArrayTest":return 62;
|
|
194
|
+
case "atomicType":return Ia([I(f,"prefix"),H(f)].join(":"));case "parenthesizedItemType":return c(F(f,"*"));default:throw Error(`Type declaration "${F(b,"*")[0]}" is not supported.`);}};a={type:c(F(b,"*")),g:3};let d=null;const e=F(b,"occurrenceIndicator");e&&(d=H(e));switch(d){case "*":return a.g=2,a;case "?":return a.g=0,a;case "+":return a.g=1,a;case "":case null:return a}}function L(a,b,c){if("object"!==typeof a[1]||Array.isArray(a[1])){const d={};d[b]=c;a.splice(1,0,d)}else a[1][b]=c};function Lg(a){const b={type:62,g:3};L(a,"type",b);return b};function Mg(a,b){if(!b||!b.ga)return{type:59,g:2};var c=F(a,"EQName");if(!c)return{type:59,g:2};var d=Jg(c);c=d.localName;const e=d.prefix;d=K(F(a,"arguments"),"*");c=b.ga.Sa({localName:c,prefix:e},d.length);if(!c)return{type:59,g:2};b=b.ga.va(c.namespaceURI,c.localName,d.length+1);if(!b)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function M(a,b,c){return(a<<20)+(b<<12)+(c.charCodeAt(0)<<8)+c.charCodeAt(1)}
|
|
195
|
+
var Ng={[M(2,2,"idivOp")]:5,[M(16,16,"addOp")]:16,[M(16,16,"subtractOp")]:16,[M(16,16,"divOp")]:4,[M(16,2,"multiplyOp")]:16,[M(16,2,"divOp")]:16,[M(2,16,"multiplyOp")]:16,[M(17,17,"addOp")]:17,[M(17,17,"subtractOp")]:17,[M(17,17,"divOp")]:4,[M(17,2,"multiplyOp")]:17,[M(17,2,"divOp")]:17,[M(2,17,"multiplyOp")]:17,[M(9,9,"subtractOp")]:17,[M(7,7,"subtractOp")]:17,[M(8,8,"subtractOp")]:17,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,16,"addOp")]:7,[M(7,
|
|
196
|
+
16,"subtractOp")]:7,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(7,16,"addOp")]:7,[M(7,16,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8},Og={[M(2,2,"addOp")]:(a,b)=>a+b,[M(2,2,"subtractOp")]:(a,b)=>a-b,[M(2,2,"multiplyOp")]:(a,b)=>a*b,[M(2,2,"divOp")]:(a,b)=>a/b,[M(2,2,"modOp")]:(a,b)=>a%b,[M(2,2,"idivOp")]:(a,
|
|
197
|
+
b)=>Math.trunc(a/b),[M(16,16,"addOp")]:function(a,b){return new Kc(a.ea+b.ea)},[M(16,16,"subtractOp")]:function(a,b){return new Kc(a.ea-b.ea)},[M(16,16,"divOp")]:function(a,b){return a.ea/b.ea},[M(16,2,"multiplyOp")]:Mc,[M(16,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");a=Math.round(a.ea/b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new Kc(a<Number.MIN_SAFE_INTEGER||
|
|
198
|
+
0===a?0:a)},[M(2,16,"multiplyOp")]:(a,b)=>Mc(b,a),[M(17,17,"addOp")]:function(a,b){return new yb(a.ca+b.ca)},[M(17,17,"subtractOp")]:function(a,b){return new yb(a.ca-b.ca)},[M(17,17,"divOp")]:function(a,b){if(0===b.ca)throw Error("FOAR0001: Division by 0");return a.ca/b.ca},[M(17,2,"multiplyOp")]:Cb,[M(17,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");a=a.ca/b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");
|
|
199
|
+
return new yb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)},[M(2,17,"multiplyOp")]:(a,b)=>Cb(b,a),[M(9,9,"subtractOp")]:Pb,[M(7,7,"subtractOp")]:Pb,[M(8,8,"subtractOp")]:Pb,[M(9,16,"addOp")]:Qb,[M(9,16,"subtractOp")]:Rb,[M(9,17,"addOp")]:Qb,[M(9,17,"subtractOp")]:Rb,[M(7,16,"addOp")]:Qb,[M(7,16,"subtractOp")]:Rb,[M(7,17,"addOp")]:Qb,[M(7,17,"subtractOp")]:Rb,[M(8,17,"addOp")]:Qb,[M(8,17,"subtractOp")]:Rb,[M(9,16,"addOp")]:Qb,[M(9,16,"subtractOp")]:Rb,[M(9,17,"addOp")]:Qb,[M(9,17,"subtractOp")]:Rb,
|
|
200
|
+
[M(7,17,"addOp")]:Qb,[M(7,17,"subtractOp")]:Rb,[M(7,16,"addOp")]:Qb,[M(7,16,"subtractOp")]:Rb,[M(8,17,"addOp")]:Qb,[M(8,17,"subtractOp")]:Rb};function Pg(a,b){return v(a,5)&&v(b,5)?5:v(a,4)&&v(b,4)?4:v(a,6)&&v(b,6)?6:3}const Qg=[2,16,17,9,7,8];
|
|
201
|
+
function Rg(a,b,c){function d(l,n){return{U:e?e(l):l,V:f?f(n):n}}let e=null,f=null;v(b,19)&&(e=l=>jd(l,3),b=3);v(c,19)&&(f=l=>jd(l,3),c=3);const h=Qg.filter(l=>v(b,l)),k=Qg.filter(l=>v(c,l));if(h.includes(2)&&k.includes(2)){const l=Og[M(2,2,a)];let n=Ng[M(2,2,a)];n||=Pg(b,c);"divOp"===a&&5===n&&(n=4);return"idivOp"===a?Sg(d,l)[0]:(t,u)=>{const {U:z,V:y}=d(t,u);return g(l(z.value,y.value),n)}}for(const l of h)for(const n of k){const t=Og[M(l,n,a)],u=Ng[M(l,n,a)];if(t&&void 0!==u)return(z,y)=>{const {U:G,
|
|
202
|
+
V:N}=d(z,y);return g(t(G.value,N.value),u)}}}
|
|
203
|
+
function Tg(a,b,c){function d(n,t){return{U:f?f(n):n,V:h?h(t):t}}var e=[2,53,59,46,47];if(e.includes(b)||e.includes(c))return 2;let f=null,h=null;v(b,19)&&(f=n=>jd(n,3),b=3);v(c,19)&&(h=n=>jd(n,3),c=3);var k=Qg.filter(n=>v(b,n));e=Qg.filter(n=>v(c,n));if(k.includes(2)&&e.includes(2)){var l=Ng[M(2,2,a)];void 0===l&&(l=Pg(b,c));"divOp"===a&&5===l&&(l=4);return"idivOp"===a?Sg(d,(n,t)=>Math.trunc(n/t))[1]:l}for(l of k)for(const n of e)if(k=Ng[M(l,n,a)],void 0!==k)return k}
|
|
204
|
+
function Sg(a,b){return[(c,d)=>{const {U:e,V:f}=a(c,d);if(0===f.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(e.value)||Number.isNaN(f.value)||!Number.isFinite(e.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(e.value)&&!Number.isFinite(f.value)?g(0,5):g(b(e.value,f.value),5)},5]}const Ug=Object.create(null);
|
|
205
|
+
var Vg=class extends D{constructor(a,b,c,d,e){super(b.o.add(c.o),[b,c],{B:!1},!1,d);this.A=b;this.L=c;this.l=a;this.s=e}h(a,b){return qc(C(this.A,a,b),b).N(c=>0===c.length?w.empty():qc(C(this.L,a,b),b).N(d=>{if(0===d.length)return w.empty();if(1<c.length||1<d.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const e=c[0];d=d[0];if(this.s&&this.type)return w.m(this.s(e,d));var f=e.type;var h=d.type,k=this.l;const l=`${f}~${h}~${k}`;let n=Ug[l];
|
|
206
|
+
n||=Ug[l]=Rg(k,f,h);f=n;if(!f)throw Error(`XPTY0004: ${this.l} not available for types ${Da[e.type]} and ${Da[d.type]}`);return w.m(f(e,d))}))}};function Wg(a,b){var c=O;let d=!1;for(var e=1;e<a.length;e++)switch(a[e][0]){case "letClause":Xg(b);var f=a[e],h=b,k=c,l=J(f,["letClauseItem","typedVariableBinding","varName"]);l=Jg(l);f=J(f,["letClauseItem","letExpr"]);k=k(f[1],h);Yg(h,l.localName,k);break;case "forClause":d=!0;Xg(b);Zg(a[e],b,c);break;case "whereClause":Xg(b);h=a[e];c(h,b);L(h,"type",{type:0,g:3});break;case "orderByClause":Xg(b);break;case "returnClause":e=a[e];h=c;c=J(e,["*"]);b=h(c,b);L(c,"type",b);L(e,"type",b);c=b;if(!c)return{type:59,
|
|
207
|
+
g:2};d&&(c={type:c.type,g:2});59!==c.type&&L(a,"type",c);return c;default:c=c(a[e],b);if(!c)return{type:59,g:2};d&&(c={type:c.type,g:2});59!==c.type&&L(a,"type",c);return c}if(0<b.h)b.h--,b.o.pop(),b.v.pop();else throw Error("Variable scope out of bound");}
|
|
208
|
+
function Zg(a,b,c){const d=Jg(J(a,["forClauseItem","typedVariableBinding","varName"]));if(a=J(a,["forClauseItem","forExpr","sequenceExpr"]))a=K(a,"*").map(e=>c(e,b)),a.includes(void 0)||a.includes(null)||(a=$g(a),1===a.length&&Yg(b,d.localName,a[0]))}function $g(a){return a.filter((b,c,d)=>d.findIndex(e=>e.type===b.type&&e.g===b.g)===c)};function ah(a,b){if(!b||!b.ga)return{type:59,g:2};const c=F(a,"functionName");var d=Jg(c);let e=d.localName;var f=d.prefix;let h=d.namespaceURI;d=K(F(a,"arguments"),"*");if(null===h){f=b.ga.Sa({localName:e,prefix:f},d.length);if(!f)return{type:59,g:2};e=f.localName;h=f.namespaceURI;L(c,"URI",h);c[2]=e}b=b.ga.va(h,e,d.length);if(!b||63===b.i.type)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function bh(a){const b={type:61,g:3};L(a,"type",b);return b};function ch(a,b){if(!b||!b.ga)return{type:59,g:2};const c=F(a,"functionName");var d=Jg(c);let e=d.localName;var f=d.namespaceURI;const h=d.prefix;d=Number(J(a,["integerConstantExpr","value"])[1]);if(!f){f=b.ga.Sa({localName:e,prefix:h},d);if(!f)return{type:59,g:2};e=f.localName;f=f.namespaceURI;L(c,"URI",f)}b=b.ga.va(f,e,d)||null;if(!b)return{type:59,g:2};59!==b.i.type&&63!==b.i.type&&L(a,"type",b.i);return b.i};function dh(a,b){var c=K(a,"stepExpr");if(!c)return{type:59,g:2};for(const f of c){a:{c=f;var d=b;let h=null;if(!c)break a;var e=K(c,"*");let k="";for(const l of e)switch(l[0]){case "filterExpr":h=I(J(l,["*"]),"type");break;case "xpathAxis":k=l[1];b:{switch(k){case "attribute":h={type:47,g:2};break b;case "child":case "decendant":case "self":case "descendant-or-self":case "following-sibling":case "following":case "namespace":case "parent":case "ancestor":case "preceding-sibling":case "preceding":case "ancestor-or-self":h=
|
|
209
|
+
{type:53,g:2};break b}h=void 0}break;case "nameTest":e=Jg(l);if(null!==e.namespaceURI)break;if("attribute"===k&&!e.prefix)break;e=d.$(e.prefix||"");void 0!==e&&L(l,"URI",e);break;case "lookup":h={type:59,g:2}}h&&59!==h.type&&L(c,"type",h)}d=I(f,"type")}d&&59!==d.type&&L(a,"type",d);return d};function eh(a){const b={type:0,g:3};L(a,"type",b);return b};function fh(a,b,c){0===b?b={type:53,g:2}:1===b?b=c[0]:c.includes(void 0)||c.includes(null)?b={type:59,g:2}:(b=$g(c),b=1<b.length?{type:59,g:2}:{type:b[0].type,g:2});b&&59!==b.type&&L(a,"type",b);return b};function gh(a,b,c,d){if(!b||c.includes(void 0))return{type:59,g:2};var e=K(a,"typeswitchExprCaseClause");for(let h=0;h<c.length;h++){var f=F(e[h],"*");switch(f[0]){case "sequenceType":if(f=hh(f,b,c[h]))return 59!==f.type&&L(a,"type",f),f;continue;case "sequenceTypeUnion":for(d=K(f,"*"),e=0;2>e;e++)if(f=hh(d[e],b,c[h]))return 59!==f.type&&L(a,"type",f),f;default:return{type:59,g:2}}}59!==d.type&&L(a,"type",d);return d}
|
|
210
|
+
function hh(a,b,c){const d=K(a,"*"),e=F(a,"atomicType");if(!e)return{type:59,g:2};if(Ia(I(e,"prefix")+":"+e[2])===b.type)if(1===d.length){if(3===b.g)return c}else if(a=F(a,"occurrenceIndicator")[1],b.g===Ka(a))return c};function ih(a,b){O(a,b)}function O(a,b){var c=jh.get(a[0]);if(c)return c(a,b);for(c=1;c<a.length;c++)a[c]&&O(a[c],b)}
|
|
211
|
+
const kh=(a,b)=>{var c=O(F(a,"firstOperand")[1],b);const d=O(F(a,"secondOperand")[1],b);var e=a[0];if(c&&d)if(b=Tg(e,c.type,d.type))c={type:b,g:c.g},2!==b&&59!==b&&L(a,"type",c),a=c;else throw Error(`XPTY0004: ${e} not available for types ${Ha(c)} and ${Ha(d)}`);else a={type:2,g:3};return a},lh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);a:{switch(a[0]){case "orOp":b={type:0,g:3};L(a,"type",b);a=b;break a;case "andOp":b={type:0,g:3};L(a,"type",b);a=b;break a}a=void 0}return a},
|
|
212
|
+
mh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);a:{switch(a[0]){case "unionOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "intersectOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "exceptOp":b={type:53,g:2};L(a,"type",b);a=b;break a}a=void 0}return a},nh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b={type:0,g:3};L(a,"type",b);return b},oh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,
|
|
213
|
+
["secondOperand","*"]),"type");b={type:0,g:wc(b)||wc(c)?0:3};L(a,"type",b);return b},ph=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,["secondOperand","*"]),"type");b={type:0,g:wc(b)||wc(c)?0:3};L(a,"type",b);return b},jh=new Map([["unaryMinusOp",(a,b)=>{b=O(F(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["unaryPlusOp",
|
|
214
|
+
(a,b)=>{b=O(F(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["addOp",kh],["subtractOp",kh],["divOp",kh],["idivOp",kh],["modOp",kh],["multiplyOp",kh],["andOp",lh],["orOp",lh],["sequenceExpr",(a,b)=>{const c=K(a,"*"),d=c.map(e=>O(e,b));return fh(a,c.length,d)}],["unionOp",mh],["intersectOp",mh],["exceptOp",mh],["stringConcatenateOp",(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],
|
|
215
|
+
b);b={type:1,g:3};L(a,"type",b);return b}],["rangeSequenceExpr",(a,b)=>{O(F(a,"startExpr")[1],b);O(F(a,"endExpr")[1],b);b={type:5,g:1};L(a,"type",b);return b}],["equalOp",nh],["notEqualOp",nh],["lessThanOrEqualOp",nh],["lessThanOp",nh],["greaterThanOrEqualOp",nh],["greaterThanOp",nh],["eqOp",oh],["neOp",oh],["ltOp",oh],["leOp",oh],["gtOp",oh],["geOp",oh],["isOp",ph],["nodeBeforeOp",ph],["nodeAfterOp",ph],["pathExpr",(a,b)=>{const c=F(a,"rootExpr");c&&c[1]&&O(c[1],b);K(a,"stepExpr").map(d=>O(d,b));
|
|
216
|
+
return dh(a,b)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(a,b)=>{var c=F(a,"ifClause")||F(K(a,"x:stackTrace")[0],"ifClause");const d=F(a,"thenClause")||F(K(a,"x:stackTrace")[1],"thenClause"),e=F(a,"elseClause")||F(K(a,"x:stackTrace")[2],"elseClause");O(F(c,"*"),b);c=O(F(d,"*"),b);b=O(F(e,"*"),b);c&&b?c.type===b.type&&c.g===b.g?(59!==c.type&&L(a,"type",c),a=c):a={type:59,g:2}:a={type:59,g:2};return a}],["instanceOfExpr",(a,b)=>{O(F(a,"argExpr"),b);O(F(a,"sequenceType"),b);b={type:0,
|
|
217
|
+
g:3};L(a,"type",b);return b}],["integerConstantExpr",a=>{const b={type:5,g:3};L(a,"type",b);return b}],["doubleConstantExpr",a=>{const b={type:3,g:3};L(a,"type",b);return b}],["decimalConstantExpr",a=>{const b={type:4,g:3};L(a,"type",b);return b}],["stringConstantExpr",a=>{const b={type:1,g:3};L(a,"type",b);return b}],["functionCallExpr",(a,b)=>{const c=F(a,"arguments");K(c,"*").map(d=>O(d,b));return ah(a,b)}],["arrowExpr",(a,b)=>{O(F(a,"argExpr")[1],b);return Mg(a,b)}],["dynamicFunctionInvocationExpr",
|
|
218
|
+
(a,b)=>{O(J(a,["functionItem","*"]),b);(a=F(a,"arguments"))&&O(a,b);return{type:59,g:2}}],["namedFunctionRef",(a,b)=>ch(a,b)],["inlineFunctionExpr",(a,b)=>{O(F(a,"functionBody")[1],b);b={type:60,g:3};L(a,"type",b);return b}],["castExpr",a=>{var b=J(a,["singleType","atomicType"]);b={type:Ia(I(b,"prefix")+":"+b[2]),g:3};59!==b.type&&L(a,"type",b);return b}],["castableExpr",a=>{const b={type:0,g:3};L(a,"type",b);return b}],["simpleMapExpr",(a,b)=>{const c=K(a,"pathExpr");let d;for(let e=0;e<c.length;e++)d=
|
|
219
|
+
O(c[e],b);void 0!==d&&null!==d?((b={type:d.type,g:2},59!==b.type)&&L(a,"type",b),a=b):a={type:59,g:2};return a}],["mapConstructor",(a,b)=>{K(a,"mapConstructorEntry").map(c=>({key:O(J(c,["mapKeyExpr","*"]),b),value:O(J(c,["mapValueExpr","*"]),b)}));return bh(a)}],["arrayConstructor",(a,b)=>{K(F(a,"*"),"arrayElem").map(c=>O(c,b));return Lg(a)}],["unaryLookup",a=>{F(a,"NCName");return{type:59,g:2}}],["typeswitchExpr",(a,b)=>{const c=O(F(a,"argExpr")[1],b),d=K(a,"typeswitchExprCaseClause").map(f=>O(J(f,
|
|
220
|
+
["resultExpr"])[1],b)),e=O(J(a,["typeswitchExprDefaultClause","resultExpr"])[1],b);return gh(a,c,d,e)}],["quantifiedExpr",(a,b)=>{K(a,"*").map(c=>O(c,b));return eh(a)}],["x:stackTrace",(a,b)=>{a=K(a,"*");return O(a[0],b)}],["queryBody",(a,b)=>O(a[1],b)],["flworExpr",(a,b)=>Wg(a,b)],["varRef",(a,b)=>{const c=Jg(F(a,"name"));var d;a:{for(d=b.h;0<=d;d--){const e=b.o[d][c.localName];if(e){d=e;break a}}d=void 0}d&&59!==d.type&&L(a,"type",d);null===c.namespaceURI&&(b=b.$(c.prefix),void 0!==b&&L(a,"URI",
|
|
221
|
+
b));return d}]]);function Xg(a){a.h++;a.o.push({});a.v.push({})}function Yg(a,b,c){if(a.o[a.h][b])throw Error(`Another variable of in the scope ${a.h} with the same name ${b} already exists`);a.o[a.h][b]=c}var qh=class{constructor(a){this.h=0;this.ga=a;this.o=[{}];this.v=[{}]}$(a){for(let b=this.h;0<=b;b--){const c=this.v[b][a];if(void 0!==c)return c}return this.ga?this.ga.$(a):void 0}};var rh=class extends D{constructor(a,b){super(new uf({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return 0===this.l.length?w.m(new pb([])):C(this.l[0],a,b).N(c=>w.m(new pb(c.map(d=>Ra(w.m(d))))))}};var sh=class extends D{constructor(a,b){super(new uf({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return w.m(new pb(this.l.map(c=>Ra(C(c,a,b)))))}};function th(a){if(null===a)throw lc("context is absent, it needs to be present to use axes.");if(!v(a.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return a.value};function uh(a,b,c){let d=b;return{next:()=>{if(!d)return p;const e=d;d=x(a,e,c);return q(rb(e))}}}var vh=class extends D{constructor(a,b){b=b||{Qa:!1};super(a.o,[a],{R:"reverse-sorted",W:!1,subtree:!1,B:!1});this.l=a;this.s=!!b.Qa}h(a,b){b=b.h;a=th(a.M);var c=this.l.D();c=c&&(c.startsWith("name-")||"type-1"===c)?"type-1":null;return w.create(uh(b,this.s?a:x(b,a,c),c)).filter(d=>this.l.l(d))}};const wh=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function xh(a,b){if(null===a)return b;if(null===b||a===b)return a;const c=a.startsWith("name-")?"name":a,d=b.startsWith("name-")?"name":b,e=wh.get(c);if(void 0!==e&&e.includes(d))return b;b=wh.get(d);return void 0!==b&&b.includes(c)?a:"empty"};var yh=class extends D{constructor(a,b){super(new uf({attribute:1}),[a],{R:"unsorted",subtree:!0,W:!0,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);if(1!==a.node.nodeType)return w.empty();a=eb(b,a,this.s).filter(c=>"http://www.w3.org/2000/xmlns/"!==c.node.namespaceURI).map(c=>rb(c)).filter(c=>this.l.l(c));return w.create(a)}D(){return"type-1"}};var zh=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",subtree:!0,W:!0,B:!1});this.s=a;this.l=xh(b,a.D())}h(a,b){const c=b.h,d=th(a.M);a=d.node.nodeType;if(1!==a&&9!==a)return w.empty();let e=null,f=!1;return w.create({next:()=>{for(;!f;){if(!e){e=ib(c,d,this.l);if(!e){f=!0;continue}return q(rb(e))}if(e=lb(c,e,this.l))return q(rb(e));f=!0}return p}}).filter(h=>this.s.l(h))}};function Ah(a,b,c){const d=b.node.nodeType;if(1!==d&&9!==d)return{next:()=>p};let e=ib(a,b,c);return{next(){if(!e)return p;const f=e;e=lb(a,e,c);return q(f)}}};function Bh(a,b,c){const d=[kd(b)];return{next:e=>{0<d.length&&0!==(e&1)&&d.shift();if(!d.length)return p;for(e=d[0].next(0);e.done;){d.shift();if(!d.length)return p;e=d[0].next(0)}d.unshift(Ah(a,e.value,c));return q(rb(e.value))}}}
|
|
222
|
+
var Ch=class extends D{constructor(a,b){b=b||{Qa:!1};super(a.o,[a],{B:!1,W:!1,R:"sorted",subtree:!0});this.l=a;this.s=!!b.Qa;this.A=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)||"type-1-or-type-2"===a?"type-1":null}h(a,b){b=b.h;a=th(a.M);a=Bh(b,a,this.A);this.s||a.next(0);return w.create(a).filter(c=>this.l.l(c))}};function Dh(a,b,c){var d=a.node.nodeType;if(1!==d&&9!==d)return a;for(d=kb(b,a,c);null!==d;){if(1!==d.node.nodeType)return d;a=d;d=kb(b,a,c)}return a}
|
|
223
|
+
function Eh(a,b,c=!1,d){if(c){let f=b,h=!1;return{next:()=>{if(h)return p;if(md(f,b))return f=Dh(b,a,d),md(f,b)?(h=!0,p):q(rb(f));const k=f.node.nodeType,l=9===k||2===k?null:mb(a,f,d);if(null!==l)return f=Dh(l,a,d),q(rb(f));f=9===k?null:x(a,f,d);return md(f,b)?(h=!0,p):q(rb(f))}}}const e=[Ah(a,b,d)];return{next:()=>{if(!e.length)return p;let f=e[0].next(0);for(;f.done;){e.shift();if(!e.length)return p;f=e[0].next(0)}e.unshift(Ah(a,f.value,d));return q(rb(f.value))}}};function Fh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=lb(a,b,c);f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){if(!e){e=Eh(a,d[0],!1,c);var f=q(rb(d[0]));const h=lb(a,d[0],c);h?d[0]=h:d.shift();return f}f=e.next(0);if(f.done)e=null;else return f}return p}}}
|
|
224
|
+
var Gh=class extends D{constructor(a){super(a.o,[a],{R:"sorted",W:!0,subtree:!1,B:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){b=b.h;a=th(a.M);return w.create(Fh(b,a,this.s)).filter(c=>this.l.l(c))}};function Hh(a,b,c){return{next:()=>(b=b&&lb(a,b,c))?q(rb(b)):p}}var Ih=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",W:!0,subtree:!1,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);return w.create(Hh(b,a,this.s)).filter(c=>this.l.l(c))}};var Jh=class extends D{constructor(a,b){super(a.o,[a],{R:"reverse-sorted",W:!0,subtree:!0,B:!1});this.l=a;this.s=xh(b,this.l.D())}h(a,b){b=b.h;a=th(a.M);a=x(b,a,this.s);if(!a)return w.empty();a=rb(a);return this.l.l(a)?w.m(a):w.empty()}};function Kh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=mb(a,b,c);null!==f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){e||=Eh(a,d[0],!0,c);var f=e.next(0);if(f.done){e=null;f=mb(a,d[0],c);const h=q(rb(d[0]));null===f?d.shift():d[0]=f;return h}return f}return p}}}
|
|
225
|
+
var Lh=class extends D{constructor(a){super(a.o,[a],{B:!1,W:!0,R:"reverse-sorted",subtree:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){b=b.h;a=th(a.M);return w.create(Kh(b,a,this.s)).filter(c=>this.l.l(c))}};function Mh(a,b,c){return{next:()=>(b=b&&mb(a,b,c))?q(rb(b)):p}}var Nh=class extends D{constructor(a,b){super(a.o,[a],{B:!1,W:!0,R:"reverse-sorted",subtree:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);return w.create(Mh(b,a,this.s)).filter(c=>this.l.l(c))}};var Oh=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",subtree:!0,W:!0,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a){th(a.M);return this.l.l(a.M)?w.m(a.M):w.empty()}D(){return this.s}};var Ph=class extends qf{constructor(a,b,c,d){super(a.o.add(b.o).add(c.o),[a,b,c],{B:a.B&&b.B&&c.B,W:b.W===c.W&&b.W,R:b.ia===c.ia?b.ia:"unsorted",subtree:b.subtree===c.subtree&&b.subtree},d);this.l=a}A(a,b,c){let d=null;const e=c[0](a);return w.create({next:f=>{d||(d=(e.fa()?c[1](a):c[2](a)).value);return d.next(f)}})}v(a){super.v(a);if(this.l.I)throw Ne();}};function hg(a){return a.h instanceof Error?a.location:hg(a.h)}function ig(a){let b;b=a.h instanceof fg?["Inner error:",a.h.message]:a.h instanceof Error?[a.h.toString()]:ig(a.h);b.push(` at <${a.o}${a.Wa?` (${a.Wa})`:""}>:${a.location.start.line}:${a.location.start.ha} - ${a.location.end.line}:${a.location.end.ha}`);return b}var Qh=class{constructor(a,b,c,d){this.location=a;this.o=b;this.Wa=c;this.h=d}};var Rh=class extends qf{constructor(a,b,c,d){super(c.o,[c],{B:c.B,W:c.W,R:c.ia,subtree:c.subtree});this.L=b;this.P={end:{ha:a.end.ha,line:a.end.line,offset:a.end.offset},start:{ha:a.start.ha,line:a.start.line,offset:a.start.offset}};this.l=d}A(a,b,[c]){let d;try{d=c(a)}catch(e){throw new Qh(this.P,this.L,this.l,e);}return w.create({next:e=>{try{return d.value.next(e)}catch(f){throw new Qh(this.P,this.L,this.l,f);}}})}v(a){try{super.v(a)}catch(b){throw new Qh(this.P,this.L,this.l,b);}}D(){return this.Fa[0].D()}};function Sh(a,b,c,d){let e=[];const f=a.L(b,c,d,k=>{if(a.l instanceof Th){const n=Sh(a.l,b,k,d);return of(n,t=>e=t)}let l=null;return w.create({next:()=>{for(;;){if(!l){var n=k.next(0);if(n.done)return p;n=a.l.s(n.value,d);l=of(n,t=>e=lf(e,t)).value}n=l.next(0);if(n.done)l=null;else return n}}})});let h=!1;return{next:()=>{if(h)return p;const k=f.O();h=!0;return q(new Ye(k,e))}}}
|
|
226
|
+
function Uh(a,b,c,d){return a.L(b,c,d,e=>{if(a.l instanceof Th)return Uh(a.l,b,e,d);let f=null;return w.create({next:()=>{for(;;){if(!f){var h=e.next(0);if(h.done)return p;f=C(a.l,h.value,d).value}h=f.next(0);if(h.done)f=null;else return h}}})})}
|
|
227
|
+
var Th=class extends D{constructor(a,b,c,d){super(a,b,c,!0);this.l=d;this.I=this.l.I}h(a,b){return this.L(a,kd(a),b,c=>{if(this.l instanceof Th)return Uh(this.l,a,c,b);let d=null;return w.create({next:e=>{for(;;){if(!d){var f=c.next(0);if(f.done)return p;d=C(this.l,f.value,b).value}f=d.next(e);if(f.done)d=null;else return f}}})})}s(a,b){return Sh(this,a,kd(a),b)}v(a){super.v(a);this.I=this.l.I;for(const b of this.Fa)if(b!==this.l&&b.I)throw Ne();}};var Vh=class extends Th{constructor(a,b,c,d){super(b.o.add(d.o),[b,d],{B:!1},d);this.P=a.prefix;this.ma=a.namespaceURI;this.Pb=a.localName;this.yb=null;this.A=c;this.La=null;this.ya=b}L(a,b,c,d){let e=null,f=null,h=0;return d({next:()=>{for(;;){if(!e){var k=b.next(0);if(k.done)return p;f=k.value;h=0;e=C(this.ya,f,c).value}const l=e.next(0);if(l.done)e=null;else return h++,k={[this.yb]:()=>w.m(l.value)},this.La&&(k[this.La]=()=>w.m(new Ca(5,h))),q(hc(f,k))}}})}v(a){if(this.P&&(this.ma=a.$(this.P),
|
|
228
|
+
!this.ma&&this.P))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.P} in a for expression`);this.ya.v(a);Cg(a);this.yb=Gg(a,this.ma,this.Pb);if(this.A){if(this.A.prefix&&(this.A.namespaceURI=a.$(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.P} in the positionalVariableBinding in a for expression`);this.La=Gg(a,this.A.namespaceURI,this.A.localName)}this.l.v(a);Ig(a);if(this.ya.I)throw Ne();this.l.I&&(this.I=
|
|
229
|
+
!0)}};var Wh=class extends D{constructor(a,b,c){super(new uf({external:1}),[c],{B:!1,R:"unsorted"});this.P=a.map(({name:d})=>d);this.A=a.map(({type:d})=>d);this.s=null;this.L=b;this.l=c}h(a,b){const c=new Va({j:this.A,arity:this.A.length,Ya:!0,I:this.l.I,localName:"dynamic-function",namespaceURI:"",i:this.L,value:(d,e,f,...h)=>{d=hc(bc(a,-1,null,w.empty()),this.s.reduce((k,l,n)=>{k[l]=Ra(h[n]);return k},Object.create(null)));return C(this.l,d,b)}});return w.m(c)}v(a){Cg(a);this.s=this.P.map(b=>Gg(a,b.namespaceURI,
|
|
230
|
+
b.localName));this.l.v(a);Ig(a);if(this.l.I)throw Error("Not implemented: inline functions can not yet be updating.");}};var Xh=class extends Th{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1,W:c.W,R:c.ia,subtree:c.subtree},c);if(a.prefix||a.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=a.prefix;this.P=a.namespaceURI;this.La=a.localName;this.ma=b;this.ya=null}L(a,b,c,d){return d({next:()=>{var e=b.next(0);if(e.done)return p;e=e.value;e=hc(e,{[this.ya]:Ra(C(this.ma,e,c))});return q(e)}})}v(a){if(this.A&&(this.P=a.$(this.A),!this.P&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);
|
|
231
|
+
this.ma.v(a);Cg(a);this.ya=Gg(a,this.P,this.La);this.l.v(a);Ig(a);this.I=this.l.I;if(this.ma.I)throw Ne();}};var Yh=class extends D{constructor(a,b){super(new uf({}),[],{B:!0,R:"sorted"},!1,b);let c;switch(b.type){case 5:c=g(parseInt(a,10),b.type);break;case 1:c=g(a,b.type);break;case 4:case 3:c=g(parseFloat(a),b.type);break;default:throw new TypeError("Type "+b+" not expected in a literal");}this.l=()=>w.m(c)}h(){return this.l()}};var Zh=class extends D{constructor(a,b){super(new uf({external:1}),a.reduce((c,{key:d,value:e})=>c.concat(d,e),[]),{B:!1},!1,b);this.l=a}h(a,b){const c=this.l.map(d=>qc(C(d.key,a,b),b).X({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.");},m:e=>e}));return A(c,d=>w.m(new ub(d.map((e,f)=>({key:e,value:Ra(C(this.l[f].value,a,b))})))))}};var $h=class extends D{constructor(a,b,c){super(new uf({external:1}),[],{B:!0},!1,c);this.s=b;this.A=a;this.l=null}h(){const a=new Va({j:this.l.j,I:this.l.I,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return w.m(a)}v(a){let b=this.A.namespaceURI,c=this.A.localName;const d=this.A.prefix;if(null===b){const e=a.Sa({localName:c,prefix:d},this.s);if(!e)throw Error(`XPST0017: The function ${d?d+":":""}${c} with arity ${this.s} could not be resolved. ${lg(c)}`);
|
|
232
|
+
b=e.namespaceURI;c=e.localName}this.l=a.va(b,c,this.s)||null;if(!this.l)throw a=this.A,Error(`XPST0017: Function ${`${a.namespaceURI?`Q{${a.namespaceURI}}`:a.prefix?`${a.prefix}:`:""}${a.localName}`} with arity of ${this.s} not registered. ${lg(c)}`);super.v(a)}};const ai={[5]:5,[27]:5,[28]:5,[31]:5,[32]:5,[33]:5,[34]:5,[30]:5,[36]:5,[35]:5,[38]:5,[37]:5,[29]:5,[4]:4,[6]:6,[3]:3};
|
|
233
|
+
var bi=class extends D{constructor(a,b,c){super(b.o,[b],{B:!1},!1,c);this.s=b;this.l=a}h(a,b){return qc(C(this.s,a,b),b).N(c=>{if(0===c.length)return w.empty();var d=c[0];if(this.type)return c="+"===this.l?+d.value:-d.value,0===d.type&&(c=Number.NaN),w.m(g(c,this.type.type));if(1<c.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return v(d.type,19)?(d=jd(d,3).value,w.m(g("+"===this.l?d:-d,3))):v(d.type,2)?"+"===this.l?w.m(d):w.m(g(-1*
|
|
234
|
+
d.value,ai[d.type])):w.m(g(Number.NaN,3))})}};var ci=class extends D{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new uf({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a;this.s=a.reduce((c,d)=>xh(c,d.D()),null)}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.M;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D()))return c++,e=!0,q(wa);d=C(h,a,b)}if(!1===d.fa())return e=!0,q(wa);d=null;c++}e=!0;return q(va)}return p}})}D(){return this.s}};var di=class extends D{constructor(a,b){super(a.reduce((d,e)=>0<tf(d,e.o)?d:e.o,new uf({})),a,{B:a.every(d=>d.B)},!1,b);let c;for(b=0;b<a.length;++b){void 0===c&&(c=a[b].D());if(null===c)break;if(c!==a[b].D()){c=null;break}}this.s=c;this.l=a}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.M;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D())){c++;continue}d=C(h,a,b)}if(!0===
|
|
235
|
+
d.fa())return e=!0,q(va);d=null;c++}e=!0;return q(wa)}return p}})}D(){return this.s}};function ei(a,b){let c;return w.create({next:d=>{for(;;){if(!c){var e=a.value.next(d);if(e.done)return p;c=pc(e.value,b)}e=c.value.next(d);if(e.done)c=null;else return e}}})};function fi(a,b){if("eqOp"===a)return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.namespaceURI===f.value.namespaceURI&&e.value.localName===f.value.localName};if("neOp"===a)return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.namespaceURI!==f.value.namespaceURI||e.value.localName!==f.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName');}
|
|
236
|
+
function gi(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value===f.value};case "neOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value!==f.value};case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value<f.value};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value<=f.value};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value>f.value};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value>=f.value}}}
|
|
237
|
+
function hi(a,b){switch(a){case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ea<f.value.ea};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ea<f.value.ea};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ea>f.value.ea};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ea>f.value.ea}}}
|
|
238
|
+
function ii(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)};case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ca<f.value.ca};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ca<f.value.ca};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ca>f.value.ca};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ca>f.value.ca}}}
|
|
239
|
+
function ji(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)};case "neOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return!vb(e.value,f.value)}}}
|
|
240
|
+
function ki(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return Ob(f.value,h.value,fc(e))};case "neOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return!Ob(f.value,h.value,fc(e))};case "ltOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);c=fc(e);return 0>Nb(f.value,h.value,c)};case "leOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);(c=Ob(f.value,h.value,fc(e)))||(e=fc(e),c=0>Nb(f.value,h.value,e));return c};case "gtOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);c=fc(e);return 0<Nb(f.value,h.value,
|
|
241
|
+
c)};case "geOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);(c=Ob(f.value,h.value,fc(e)))||(e=fc(e),c=0<Nb(f.value,h.value,e));return c}}}function li(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return Ob(f.value,h.value,fc(e))};case "neOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return!Ob(f.value,h.value,fc(e))}}}
|
|
242
|
+
function mi(a,b,c){function d(n,t){return{U:h?h(n):n,V:k?k(t):t}}function e(n){return v(b,n)&&v(c,n)}function f(n){return 0<n.filter(t=>v(b,t)).length&&0<n.filter(t=>v(c,t)).length}let h=null,k=null;v(b,19)&&v(c,19)?b=c=1:v(b,19)?(h=n=>jd(n,c),b=c):v(c,19)&&(k=n=>jd(n,b),c=b);if(v(b,23)&&v(c,23))return fi(a,d);if(e(0)||f([1,47,61])||f([2,47,61])||e(20)||e(22)||e(21)||f([1,20])){var l=gi(a,d);if(void 0!==l)return l}if(e(16)&&(l=hi(a,d),void 0!==l)||e(17)&&(l=ii(a,d),void 0!==l)||e(18)&&(l=ji(a,d),
|
|
243
|
+
void 0!==l))return l;if(e(9)||e(7)||e(8))if(l=ki(a,d),void 0!==l)return l;if(e(11)||e(12)||e(13)||e(14)||e(15))if(l=li(a,d),void 0!==l)return l;throw Error(`XPTY0004: ${a} not available for ${Da[b]} and ${Da[c]}`);}const ni=Object.create(null);function oi(a,b,c){const d=`${b}~${c}~${a}`;let e=ni[d];e||=ni[d]=mi(a,b,c);return e}
|
|
244
|
+
var pi=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b),e=ei(c,b),f=ei(d,b);return e.X({empty:()=>w.empty(),m:()=>f.X({empty:()=>w.empty(),m:()=>{const h=e.first(),k=f.first();return oi(this.s,h.type,k.type)(h,k,a)?w.aa():w.T()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}})}};const qi={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};
|
|
245
|
+
function ri(a,b,c,d){a=qi[a];return c.N(e=>b.filter(f=>{for(let l=0,n=e.length;l<n;++l){let t=e[l],u=void 0,z=void 0;var h=f.type,k=t.type;if(v(h,19)||v(k,19))v(h,2)?u=3:v(k,2)?z=3:v(h,17)?u=17:v(k,17)?z=17:v(h,16)?u=16:v(k,16)?z=16:v(h,19)?z=k:v(k,19)&&(u=h);const [y,G]=[z,u];h=y;k=G;h?f=jd(f,h):k&&(t=jd(t,k));if(oi(a,f.type,t.type)(f,t,d))return!0}return!1}).X({default:()=>w.aa(),empty:()=>w.T()}))}
|
|
246
|
+
var si=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b);return c.X({empty:()=>w.T(),default:()=>d.X({empty:()=>w.T(),default:()=>{const e=ei(c,b),f=ei(d,b);return ri(this.s,e,f,a)}})})}};function ti(a,b,c,d){if(!v(c,53)||!v(d,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(a){case "isOp":return ui(c,d);case "nodeBeforeOp":return b?(e,f)=>0>sd(b,e.first(),f.first()):void 0;case "nodeAfterOp":return b?(e,f)=>0<sd(b,e.first(),f.first()):void 0;default:throw Error("Unexpected operator");}}function ui(a,b){return a!==b||47!==a&&53!==a&&54!==a&&55!==a&&56!==a&&57!==a&&58!==a?()=>!1:(c,d)=>md(c.first().value,d.first().value)}
|
|
247
|
+
var vi=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b);return c.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>d.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>{const e=c.first(),f=d.first();return ti(this.s,b.h,e.type,f.type)(c,d,a)?w.aa():w.T()}})})}};function wi(a,b,c,d){return c.N(e=>{if(e.some(f=>!v(f.type,53)))throw Error(`XPTY0004: Sequences given to ${a} should only contain nodes.`);return"sorted"===d?w.create(e):"reverse-sorted"===d?w.create(e.reverse()):w.create(td(b,e))})}
|
|
248
|
+
var xi=class extends D{constructor(a,b,c,d){super(0<tf(b.o,c.o)?b.o:c.o,[b,c],{B:b.B&&c.B},!1,d);this.l=a;this.s=b;this.A=c}h(a,b){const c=wi(this.l,b.h,C(this.s,a,b),this.s.ia);a=wi(this.l,b.h,C(this.A,a,b),this.A.ia);const d=c.value,e=a.value;let f=null,h=null,k=!1,l=!1;return w.create({next:()=>{if(k)return p;for(;!l;){if(!f){var n=d.next(0);if(n.done)return k=!0,p;f=n.value}if(!h){n=e.next(0);if(n.done){l=!0;break}h=n.value}if(md(f.value,h.value)){if(n=q(f),h=f=null,"intersectOp"===this.l)return n}else if(0>
|
|
249
|
+
sd(b.h,f,h)){if(n=q(f),f=null,"exceptOp"===this.l)return n}else h=null}if("exceptOp"===this.l)return null!==f?(n=q(f),f=null,n):d.next(0);k=!0;return p}})}};var yi=class extends qf{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new uf({})),a,{R:"unsorted",B:a.every(c=>c.B)},b)}A(a,b,c){return c.length?jc(c.map(d=>d(a))):w.empty()}};var zi=class extends D{constructor(a,b,c){super((new uf({})).add(a.o),[a,b],{B:a.B&&b.B},!1,c);this.l=a;this.s=b}h(a,b){const c=C(this.l,a,b),d=dc(a,c);let e=null,f=null,h=!1;return w.create({next:k=>{for(;!h;){if(!e&&(e=d.next(k),e.done))return h=!0,p;f||=C(this.s,e.value,b);const l=f.value.next(k);if(l.done)e=f=null;else return l}}})}};var Ai=class extends D{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(b.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=qc(C(this.A,a,b),b);return c.X({empty:()=>this.s?w.aa():w.T(),m:()=>c.map(d=>id(d,this.l).u?va:wa),multiple:()=>
|
|
250
|
+
w.T()})}};var Bi=class extends D{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(b.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=qc(C(this.A,a,b),b);return c.X({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");
|
|
251
|
+
return w.empty()},m:()=>c.map(d=>jd(d,this.l)),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.");}})}};function Ci(a,b){const c=a.value;let d=null,e=!1;return w.create({next:()=>{for(;!e;){if(!d){var f=c.next(0);if(f.done)return e=!0,q(va);d=b(f.value)}f=d.fa();d=null;if(!1===f)return e=!0,q(wa)}return p}})};var Di=class extends D{constructor(a,b,c,d){super(a.o,[a],{B:!1},!1,d);this.A=a;this.s=b;this.l=c}h(a,b){const c=C(this.A,a,b);return c.X({empty:()=>"?"===this.l||"*"===this.l?w.aa():w.T(),multiple:()=>"+"===this.l||"*"===this.l?Ci(c,d=>{const e=w.m(d);d=bc(a,0,d,e);return C(this.s,d,b)}):w.T(),m:()=>Ci(c,d=>{const e=w.m(d);d=bc(a,0,d,e);return C(this.s,d,b)})})}};function Ei(a,b){return null!==a&&null!==b&&v(a.type,53)&&v(b.type,53)?md(a.value,b.value):!1}function Fi(a){let b=a.next(0);if(b.done)return w.empty();let c=null,d=null;return w.create({next(e){if(b.done)return p;c||(c=b.value.value);let f;do if(f=c.next(e),f.done){b=a.next(0);if(b.done)return f;c=b.value.value}while(f.done||Ei(f.value,d));d=f.value;return f}})}
|
|
252
|
+
function Gi(a,b){const c=[];(function(){for(var f=b.next(0);!f.done;){const h=f.value.value;f={current:h.next(0),next:k=>h.next(k)};f.current.done||c.push(f);f=b.next(0)}})();let d=null,e=!1;return w.create({[Symbol.iterator](){return this},next:()=>{e||(e=!0,c.every(h=>v(h.current.value.type,53))&&c.sort((h,k)=>sd(a,h.current.value,k.current.value)));let f;do{if(!c.length)return p;const h=c.shift();f=h.current;h.current=h.next(0);if(!v(f.value.type,53))return f;if(!h.current.done){let k=0,l=c.length-
|
|
253
|
+
1,n=0;for(;k<=l;){n=Math.floor((k+l)/2);const t=sd(a,h.current.value,c[n].current.value);if(0===t){k=n;break}0<t?k=n+1:l=n-1}c.splice(k,0,h)}}while(Ei(f.value,d));d=f.value;return f}})};var Hi=class extends D{constructor(a,b){super(a.reduce((c,d)=>0<tf(c,d.o)?c:d.o,new uf({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){if(this.l.every(c=>"sorted"===c.ia)){let c=0;return Gi(b.h,{next:()=>c>=this.l.length?p:q(C(this.l[c++],a,b))}).map(d=>{if(!v(d.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return d})}return jc(this.l.map(c=>C(c,a,b))).N(c=>{if(c.some(d=>!v(d.type,53)))throw Error("XPTY0004: The sequences to union are not of type node()*");c=td(b.h,
|
|
254
|
+
c);return w.create(c)})}};function Ii(a){return a.every(b=>null===b||v(b.type,5)||v(b.type,4))||null!==a.map(b=>b?rc(b.type):null).reduce((b,c)=>null===c?b:c===b?b:null)?a:a.every(b=>null===b||v(b.type,1)||v(b.type,20))?a.map(b=>b?jd(b,1):null):a.every(b=>null===b||v(b.type,4)||v(b.type,6))?a.map(b=>b?jd(b,6):b):a.every(b=>null===b||v(b.type,4)||v(b.type,6)||v(b.type,3))?a.map(b=>b?jd(b,3):b):null};function Ji(a){return(a=a.find(b=>!!b))?rc(a.type):null}
|
|
255
|
+
var Ki=class extends Th{constructor(a,b){super(new uf({}),[b,...a.map(c=>c.ba)],{B:!1,W:!1,R:"unsorted",subtree:!1},b);this.A=a}L(a,b,c,d){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const e=[];let f=!1,h,k,l=null;const n=this.A[0];return w.create({next:()=>{if(!f){for(var t=b.next(0);!t.done;)e.push(t.value),t=b.next(0);t=e.map(z=>n.ba.h(z,c)).map(z=>qc(z,c));if(t.find(z=>!z.F()&&!z.oa()))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");h=
|
|
256
|
+
t.map(z=>z.first());h=h.map(z=>null===z?z:v(19,z.type)?jd(z,1):z);if(Ji(h)&&(h=Ii(h),!h))throw Error("XPTY0004: Could not cast values");t=h.length;k=h.map((z,y)=>y);for(let z=0;z<t;z++)if(z+1!==t)for(let y=z;0<=y;y--){const G=y,N=y+1;if(N===t)continue;const U=h[k[G]],ca=h[k[N]];if(null!==ca||null!==U){if(n.cc){if(null===U)continue;if(null===ca&&null!==U){[k[G],k[N]]=[k[N],k[G]];continue}if(isNaN(ca.value)&&null!==U&&!isNaN(U.value)){[k[G],k[N]]=[k[N],k[G]];continue}}else{if(null===ca)continue;if(null===
|
|
257
|
+
U&&null!==ca){[k[G],k[N]]=[k[N],k[G]];continue}if(isNaN(U.value)&&null!==ca&&!isNaN(ca.value)){[k[G],k[N]]=[k[N],k[G]];continue}}oi("gtOp",U.type,ca.type)(U,ca,a)&&([k[G],k[N]]=[k[N],k[G]])}}let u=n.Bb?0:h.length-1;l=d({next:()=>n.Bb?u>=h.length?p:q(e[k[u++]]):0>u?p:q(e[k[u--]])}).value;f=!0}return l.next(0)}})}};var Li=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{R:"sorted",subtree:!1,W:!1,B:!1});this.l=a}h(a,b){if(null===a.M)throw lc("context is absent, it needs to be present to use paths.");var c=b.h;let d=a.M.value;for(;9!==d.node.nodeType;)if(d=x(c,d),null===d)throw Error("XPDY0050: the root node of the context node is not a document node.");c=w.m(rb(d));return this.l?C(this.l,bc(a,0,c.first(),c),b):c}};var Mi=class extends D{constructor(a){super(new uf({}),[],{R:"sorted"},!1,a)}h(a){if(null===a.M)throw lc('context is absent, it needs to be present to use the "." operator');return w.m(a.M)}};function Ni(a,b){let c=!1,d=!1;b.forEach(e=>{v(e.type,53)?c=!0:d=!0});if(d&&c)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return c?td(a,b):b}
|
|
258
|
+
var Oi=class extends D{constructor(a,b){const c=a.every(e=>e.W),d=a.every(e=>e.subtree);super(a.reduce((e,f)=>e.add(f.o),new uf({})),a,{B:!1,W:c,R:b?"sorted":"unsorted",subtree:d});this.l=a;this.s=b}h(a,b){let c=!0;return this.l.reduce((d,e,f)=>{const h=null===d?kd(a):dc(a,d);d={next:l=>{l=h.next(l);if(l.done)return p;if(null!==l.value.M&&!v(l.value.M.type,53)&&0<f)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return q(C(e,l.value,
|
|
259
|
+
b))}};let k;if(this.s)switch(e.ia){case "reverse-sorted":const l=d;d={next:n=>{n=l.next(n);return n.done?n:q(n.value.N(t=>w.create(t.reverse())))}};case "sorted":if(e.subtree&&c){k=Fi(d);break}k=Gi(b.h,d);break;case "unsorted":return Fi(d).N(n=>w.create(Ni(b.h,n)))}else k=Fi(d);c=c&&e.W;return k},null)}D(){return this.l[0].D()}};var Pi=class extends D{constructor(a,b){super(a.o.add(b.o),[a,b],{B:a.B&&b.B,W:a.W,R:a.ia,subtree:a.subtree});this.s=a;this.l=b}h(a,b){const c=C(this.s,a,b);if(this.l.B){const k=C(this.l,a,b);if(k.F())return k;const l=k.first();if(v(l.type,2)){let n=l.value;if(!Number.isInteger(n))return w.empty();const t=c.value;let u=!1;return w.create({next:()=>{if(!u){for(let z=t.next(0);!z.done;z=t.next(0))if(1===n--)return u=!0,z;u=!0}return p}})}return k.fa()?c:w.empty()}const d=c.value;let e=null,f=0,h=null;
|
|
260
|
+
return w.create({next:k=>{let l=!1;for(;!e||!e.done;){e||(e=d.next(l?0:k),l=!0);if(e.done)break;h||=C(this.l,bc(a,f,e.value,c),b);var n=h.first();n=null===n?!1:v(n.type,2)?n.value===f+1:h.fa();h=null;const t=e.value;e=null;f++;if(n)return q(t)}return e}})}D(){return this.s.D()}};function Qi(a,b,c){c=[c];if(v(a.type,62))if("*"===b)c.push(...a.h.map(d=>d()));else if(v(b.type,5)){const d=b.value;if(a.h.length<d||0>=d)throw Error("FOAY0001: Array index out of bounds");c.push(a.h[d-1]())}else throw Error("XPTY0004: The key specifier is not an integer.");else if(v(a.type,61))"*"===b?c.push(...a.h.map(d=>d.value())):(a=a.h.find(d=>sb(d.key,b)))&&c.push(a.value());else throw Error("XPTY0004: The provided context item is not a map or an array.");return jc(c)}
|
|
261
|
+
function Ri(a,b,c,d,e){if("*"===b)return Qi(a,b,c);b=C(b,d,e);b=Ra(b)().N(f=>f.reduce((h,k)=>Qi(a,k,h),new Ba));return jc([c,b])};var Si=class extends D{constructor(a,b){super(a.o,[a].concat("*"===b?[]:[b]),{B:a.B,R:a.ia,subtree:a.subtree});this.l=a;this.s=b}h(a,b){return C(this.l,a,b).N(c=>c.reduce((d,e)=>Ri(e,this.s,d,a,b),new Ba))}D(){return this.l.D()}};var Ti=class extends D{constructor(a,b){super(new uf({external:1}),"*"===a?[]:[a],{B:!1},!1,b);this.l=a}h(a,b){return Ri(a.M,this.l,new Ba,a,b)}};var Ui=class extends D{constructor(a,b,c,d){const e=b.map(f=>f.fb);b=b.map(f=>f.name);super(e.reduce((f,h)=>f.add(h.o),c.o),e.concat(c),{B:!1},!1,d);this.s=a;this.A=b;this.L=e;this.P=c;this.l=null}h(a,b){let c=a;const d=this.l.map((k,l)=>{const n=C(this.L[l],c,b).O();c=hc(a,{[k]:()=>w.create(n)});return n});if(d.some(k=>0===k.length))return"every"===this.s?w.aa():w.T();const e=Array(d.length).fill(0);e[0]=-1;for(var f=!0;f;){f=!1;for(let k=0,l=e.length;k<l;++k){var h=d[k];if(++e[k]>h.length-1)e[k]=
|
|
262
|
+
0;else{f=Object.create(null);for(h=0;h<e.length;h++){const n=d[h][e[h]];f[this.l[h]]=()=>w.m(n)}f=hc(a,f);f=C(this.P,f,b);if(f.fa()&&"some"===this.s)return w.aa();if(!f.fa()&&"every"===this.s)return w.T();f=!0;break}}}return"every"===this.s?w.aa():w.T()}v(a){this.l=[];for(let c=0,d=this.A.length;c<d;++c){this.L[c].v(a);Cg(a);var b=this.A[c];const e=b.prefix?a.$(b.prefix):null;b=Gg(a,e,b.localName);this.l[c]=b}this.P.v(a);for(let c=0,d=this.A.length;c<d;++c)Ig(a)}};var Vi=class extends D{constructor(a){super(a,[],{B:!1})}h(a){return this.l(a.M)?w.aa():w.T()}};var Wi=class extends Vi{constructor(a){super(new uf({nodeType:1}));this.s=a}l(a){if(!v(a.type,53))return!1;a=a.value.node.nodeType;return 3===this.s&&4===a?!0:this.s===a}D(){return`type-${this.s}`}};var Xi=class extends Vi{constructor(a,b={kind:null}){const c=a.prefix,d=a.namespaceURI;a=a.localName;const e={};"*"!==a&&(e.nodeName=1);e.nodeType=1;super(new uf(e));this.s=a;this.L=d;this.A=c;this.P=b.kind}l(a){const b=v(a.type,54),c=v(a.type,47);if(!b&&!c)return!1;a=a.value;return null!==this.P&&(1===this.P&&!b||2===this.P&&!c)?!1:null===this.A&&""!==this.L&&"*"===this.s?!0:"*"===this.A?"*"===this.s?!0:this.s===a.node.localName:"*"!==this.s&&this.s!==a.node.localName?!1:(a.node.namespaceURI||null)===
|
|
263
|
+
((""===this.A?b?this.L:null:this.L)||null)}D(){return"*"===this.s?null===this.P?"type-1-or-type-2":`type-${this.P}`:`name-${this.s}`}v(a){if(null===this.L&&"*"!==this.A&&(this.L=a.$(this.A||"")||null,!this.L&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`);}};var Yi=class extends Vi{constructor(a){super(new uf({nodeName:1}));this.s=a}l(a){return v(a.type,57)&&a.value.node.target===this.s}D(){return"type-7"}};var Zi=class extends Vi{constructor(a){super(new uf({}));this.s=a}l(a){return v(a.type,Ia(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}};var $i=class extends D{constructor(a,b,c){super(new uf({}),[],{B:!1,R:"unsorted"});this.A=c;this.s=b;this.L=a;this.l=null}h(a,b){if(!a.ra[this.l]){if(this.P)return this.P(a,b);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.");}return a.ra[this.l]()}v(a){null===this.s&&this.L&&(this.s=a.$(this.L));this.l=a.eb(this.s||"",this.A);if(!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");if(a=a.Ea[this.l])this.P=a}};var aj=class extends Th{constructor(a,b){super(new uf({}),[a,b],{B:!1,W:!1,R:"unsorted",subtree:!1},b);this.A=a}L(a,b,c,d){let e=null,f=null;return d({next:()=>{for(;;){if(!f){var h=b.next(0);if(h.done)return p;e=h.value;f=C(this.A,e,c)}h=f.fa();const k=e;f=e=null;if(h)return q(k)}}})}};var bj=class{constructor(a){this.type=a}};var cj=class extends bj{constructor(a){super("delete");this.target=a}h(a){return{type:this.type,target:$f(this.target,a,!1)}}};var dj=class extends bj{constructor(a,b,c){super(c);this.target=a;this.content=b}h(a){return{type:this.type,target:$f(this.target,a,!1),content:this.content.map(b=>$f(b,a,!0))}}};var ej=class extends dj{constructor(a,b){super(a,b,"insertAfter")}};var fj=class extends bj{constructor(a,b){super("insertAttributes");this.target=a;this.content=b}h(a){return{type:this.type,target:$f(this.target,a,!1),content:this.content.map(b=>$f(b,a,!0))}}};var gj=class extends dj{constructor(a,b){super(a,b,"insertBefore")}};var hj=class extends dj{constructor(a,b){super(a,b,"insertIntoAsFirst")}};var ij=class extends dj{constructor(a,b){super(a,b,"insertIntoAsLast")}};var jj=class extends dj{constructor(a,b){super(a,b,"insertInto")}};var kj=class extends bj{constructor(a,b){super("rename");this.target=a;this.o=b.za?b:new Sa(b.prefix,b.namespaceURI,b.localName)}h(a){return{type:this.type,target:$f(this.target,a,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}};var lj=class extends bj{constructor(a,b){super("replaceElementContent");this.target=a;this.text=b}h(a){return{type:this.type,target:$f(this.target,a,!1),text:this.text?$f(this.text,a,!0):null}}};var mj=class extends bj{constructor(a,b){super("replaceNode");this.target=a;this.o=b}h(a){return{type:this.type,target:$f(this.target,a,!1),replacement:this.o.map(b=>$f(b,a,!0))}}};var nj=class extends bj{constructor(a,b){super("replaceValue");this.target=a;this.o=b}h(a){return{type:this.type,target:$f(this.target,a,!1),["string-value"]:this.o}}};var oj=(a,b)=>new mj(a,b);var pj=class extends nf{constructor(a){super(new uf({}),[a],{B:!1,R:"unsorted"});this.l=a}s(a,b){const c=mf(this.l)(a,b),d=b.h;let e,f;return{next:()=>{if(!e){const h=c.next(0);if(h.value.J.some(k=>!v(k.type,53)))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");e=h.value.J;f=h.value.da}e=e.filter(h=>x(d,h.value));return q({da:lf(e.map(h=>new cj(h.value)),f),J:[]})}}}};function qj(a,b,c,d,e,f){const h=b.h;a.reduce(function t(l,n){if(v(n.type,62))return n.h.forEach(u=>u().O().forEach(z=>t(l,z))),l;l.push(n);return l},[]).forEach((l,n,t)=>{if(v(l.type,47)){if(e)throw f(l.value,h);c.push(l.value.node)}else if(v(l.type,46)||v(l.type,53)&&3===l.value.node.nodeType){const u=v(l.type,46)?jd(pc(l,b).first(),1).value:hb(h,l.value);0!==n&&v(t[n-1].type,46)&&v(l.type,46)?(d.push({data:" "+u,Ra:!0,nodeType:3}),e=!0):u&&(d.push({data:""+u,Ra:!0,nodeType:3}),e=!0)}else if(v(l.type,
|
|
264
|
+
55)){const u=[];gb(h,l.value).forEach(z=>u.push(rb(z)));e=qj(u,b,c,d,e,f)}else if(v(l.type,53))d.push(l.value.node),e=!0;else{if(v(l.type,60))throw nc(l.type);throw Error(`Atomizing ${l.type} is not implemented.`);}});return e}function rj(a,b,c){const d=[],e=[];let f=!1;a.forEach(h=>{f=qj(h,b,d,e,f,c)});return{attributes:d,Xa:e}};function sj(a,b,c,d,e){const f=[];switch(a){case 4:d.length&&f.push(new fj(b,d));e.length&&f.push(new hj(b,e));break;case 5:d.length&&f.push(new fj(b,d));e.length&&f.push(new ij(b,e));break;case 3:d.length&&f.push(new fj(b,d));e.length&&f.push(new jj(b,e));break;case 2:d.length&&f.push(new fj(c,d));e.length&&f.push(new gj(b,e));break;case 1:d.length&&f.push(new fj(c,d)),e.length&&f.push(new ej(b,e))}return f}
|
|
265
|
+
var tj=class extends nf{constructor(a,b,c){super(new uf({}),[a,c],{B:!1,R:"unsorted"});this.L=a;this.l=b;this.A=c}s(a,b){const c=mf(this.L)(a,b),d=mf(this.A)(a,b),e=b.h;let f,h,k,l,n,t;return{next:()=>{if(!f){var u=c.next(0);const z=rj([u.value.J],b,Oe);f=z.attributes.map(y=>({node:y,G:null}));h=z.Xa.map(y=>({node:y,G:null}));k=u.value.da}if(!l){u=d.next(0);if(0===u.value.J.length)throw Xe();if(3<=this.l){if(1!==u.value.J.length)throw Pe();if(!v(u.value.J[0].type,54)&&!v(u.value.J[0].type,55))throw Pe();
|
|
266
|
+
}else{if(1!==u.value.J.length)throw Qe();if(!(v(u.value.J[0].type,54)||v(u.value.J[0].type,56)||v(u.value.J[0].type,58)||v(u.value.J[0].type,57)))throw Qe();t=x(e,u.value.J[0].value,null);if(null===t)throw Error(`XUDY0029: The target ${u.value.J[0].value.outerHTML} for inserting a node before or after must have a parent.`);}l=u.value.J[0];n=u.value.da}if(f.length){if(3<=this.l){if(!v(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.");
|
|
267
|
+
}else if(1!==t.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");f.reduce((z,y)=>{const G=y.node.prefix||"";var N=y.node.prefix||"";const U=y.node.namespaceURI,ca=N?l.value.node.lookupNamespaceURI(N):null;if(ca&&ca!==U)throw Ve(U);if((N=z[N])&&U!==N)throw We(U);z[G]=y.node.namespaceURI;return z},{})}return q({J:[],da:lf(sj(this.l,l.value,t?t:null,f,h),k,n)})}}}};const uj=()=>mc("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),vj=/([A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])/,wj=new RegExp(`${vj.source}${(new RegExp(`(${vj.source}|[-.0-9\xB7\u0300-\u036F\u203F\u2040])`)).source}*`,"g"),xj=a=>(a=a.match(wj))?1===a.length:!1;
|
|
268
|
+
function yj(a,b){return qc(b,a).X({m:c=>{c=c.first();if(v(c.type,1)||v(c.type,19)){if(!xj(c.value))throw Error(`XQDY0041: The value "${c.value}" of a name expressions cannot be converted to a NCName.`);return w.m(c)}throw uj();},default:()=>{throw uj();}}).value}
|
|
269
|
+
function zj(a,b,c){return qc(c,b).X({m:d=>{d=d.first();if(v(d.type,23))return w.m(d);if(v(d.type,1)||v(d.type,19)){let e,f;d=d.value.split(":");1===d.length?d=d[0]:(e=d[0],f=a.$(e),d=d[1]);if(!xj(d)||e&&!xj(e))throw xg(e?`${e}:${d}`:d);if(e&&!f)throw xg(`${e}:${d}`);return w.m({type:23,value:new Sa(e,f,d)})}throw uj();},default:()=>{throw uj();}}).value};var Aj=class extends nf{constructor(a,b){super(new uf({}),[a,b],{B:!1,R:"unsorted"});this.A=a;this.L=b;this.l=void 0}s(a,b){const c=mf(this.A)(a,b),d=mf(this.L)(a,b);return{next:()=>{const e=c.next(0);var f=e.value.J;if(0===f.length)throw Xe();if(1!==f.length)throw Se();if(!v(f[0].type,54)&&!v(f[0].type,47)&&!v(f[0].type,57))throw Se();f=f[0];const h=d.next(0);a:{var k=this.l;var l=w.create(h.value.J);switch(f.type){case 54:k=zj(k,b,l).next(0).value.value;if((l=f.value.node.lookupNamespaceURI(k.prefix))&&
|
|
270
|
+
l!==k.namespaceURI)throw Ve(k.namespaceURI);break a;case 47:k=zj(k,b,l).next(0).value.value;if(k.namespaceURI&&(l=f.value.node.lookupNamespaceURI(k.prefix))&&l!==k.namespaceURI)throw Ve(k.namespaceURI);break a;case 57:k=yj(b,l).next(0).value.value;k=new Sa("",null,k);break a}k=void 0}return q({J:[],da:lf([new kj(f.value,k)],e.value.da,h.value.da)})}}}v(a){this.l=Ef(a);super.v(a)}};function Bj(a,b,c){let d,e,f;return{next:()=>{if(!d){var h=c.next(0),k=rj([h.value.J],a,We);d={attributes:k.attributes.map(l=>({node:l,G:null})),Xa:k.Xa.map(l=>({node:l,G:null}))};e=h.value.da}k=b.next(0);if(0===k.value.J.length)throw Xe();if(1!==k.value.J.length)throw Re();if(!(v(k.value.J[0].type,54)||v(k.value.J[0].type,47)||v(k.value.J[0].type,56)||v(k.value.J[0].type,58)||v(k.value.J[0].type,57)))throw Re();f=x(a.h,k.value.J[0].value,null);if(null===f)throw Error(`XUDY0009: The target ${k.value.J[0].value.outerHTML} for replacing a node must have a parent.`);
|
|
271
|
+
h=k.value.J[0];k=k.value.da;if(v(h.type,47)){if(d.Xa.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");d.attributes.reduce((l,n)=>{const t=n.node.prefix||"";n=n.node.namespaceURI;var u=f.node.lookupNamespaceURI(t);if(u&&u!==n)throw Ve(n);if((u=l[t])&&n!==u)throw We(n);l[t]=n;return l},{})}else if(d.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");
|
|
272
|
+
return q({J:[],da:lf([oj(h.value,[].concat(d.attributes,d.Xa))],e,k)})}}}
|
|
273
|
+
function Cj(a,b,c){let d,e,f,h,k=!1;return{next:()=>{if(k)return p;if(!f){var l=c.next(0);const n=qc(w.create(l.value.J),a).map(t=>jd(t,1)).O().map(t=>t.value).join(" ");f=0===n.length?null:{node:a.Ja.createTextNode(n),G:null};h=l.value.da}if(!d){l=b.next(0);if(0===l.value.J.length)throw Xe();if(1!==l.value.J.length)throw Re();if(!(v(l.value.J[0].type,54)||v(l.value.J[0].type,47)||v(l.value.J[0].type,56)||v(l.value.J[0].type,58)||v(l.value.J[0].type,57)))throw Re();d=l.value.J[0];e=l.value.da}if(v(d.type,
|
|
274
|
+
54))return k=!0,q({J:[],da:lf([new lj(d.value,f)],h,e)});if(v(d.type,47)||v(d.type,56)||v(d.type,58)||v(d.type,57)){l=f?hb(a.h,f):"";if(v(d.type,58)&&(l.includes("--")||l.endsWith("-")))throw Error(`XQDY0072: The content "${l}" for a comment node contains two adjacent hyphens or ends with a hyphen.`);if(v(d.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);k=!0;return q({J:[],da:lf([new nj(d.value,l)],h,e)})}}}}
|
|
275
|
+
var Qj=class extends nf{constructor(a,b,c){super(new uf({}),[b,c],{B:!1,R:"unsorted"});this.L=a;this.l=b;this.A=c}s(a,b){const c=mf(this.l)(a,b);a=mf(this.A)(a,b);return this.L?Cj(b,c,a):Bj(b,c,a)}};function Rj(a){switch(a.type){case "delete":return new cj({node:a.target,G:null});case "insertAfter":return new ej({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertBefore":return new gj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertInto":return new jj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertIntoAsFirst":return new hj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertIntoAsLast":return new ij({node:a.target,
|
|
276
|
+
G:null},a.content.map(b=>({node:b,G:null})));case "insertAttributes":return new fj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "rename":return new kj({node:a.target,G:null},a.newName);case "replaceNode":return new mj({node:a.target,G:null},a.replacement.map(b=>({node:b,G:null})));case "replaceValue":return new nj({node:a.target,G:null},a["string-value"]);case "replaceElementContent":return new lj({node:a.target,G:null},a.text?{node:a.text,G:null}:null);default:throw Error(`Unexpected type "${a.type}" when parsing a transferable pending update.`);
|
|
277
|
+
}};function Sj(a,b,c){if(b.find(e=>md(e,a)))return!0;const d=x(c,a);return d?Sj(d,b,c):!1}
|
|
278
|
+
var Tj=class extends nf{constructor(a,b,c){super(new uf({}),a.reduce((d,e)=>{d.push(e.fb);return d},[b,c]),{B:!1,R:"unsorted"});this.l=a;this.L=b;this.A=c;this.I=null}h(a,b){a=this.s(a,b);return of(a,()=>{})}s(a,b){const c=b.h,d=b.Ja,e=b.Ma,f=[];let h,k,l;const n=[],t=[];return{next:()=>{if(n.length!==this.l.length)for(var u=n.length;u<this.l.length;u++){const y=this.l[u];var z=f[u];z||(f[u]=z=mf(y.fb)(a,b));z=z.next(0);if(1!==z.value.J.length||!v(z.value.J[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");
|
|
279
|
+
const G=rb(Wf(z.value.J[0].value,b));n.push(G.value);t.push(z.value.da);a=hc(a,{[y.fc]:()=>w.m(G)})}l||(h||=mf(this.L)(a,b),l=h.next(0).value.da);l.forEach(y=>{if(y.target&&!Sj(y.target,n,c))throw Error(`XUDY0014: The target ${y.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===y.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.");});u=l.map(y=>{y=y.h(b);return Rj(y)});kf(u,c,d,e);k||=mf(this.A)(a,b);u=k.next(0);return q({J:u.value.J,
|
|
280
|
+
da:lf(u.value.da,...t)})}}}v(a){Cg(a);this.l.forEach(b=>b.fc=Gg(a,b.Jb.namespaceURI,b.Jb.localName));super.v(a);Ig(a);this.I=this.l.some(b=>b.fb.I)||this.A.I}};function Uj(a,b){return{node:{nodeType:2,Ra:!0,nodeName:a.za(),namespaceURI:a.namespaceURI,prefix:a.prefix,localName:a.localName,name:a.za(),value:b},G:null}}
|
|
281
|
+
var Vj=class extends D{constructor(a,b){let c=b.nb||[];c=c.concat(a.Na||[]);super(new uf({}),c,{B:!1,R:"unsorted"});a.Na?this.s=a.Na:this.name=new Sa(a.prefix,a.namespaceURI,a.localName);this.l=b;this.A=void 0}h(a,b){let c,d,e,f=!1;return w.create({next:()=>{if(f)return p;if(!d){if(this.s){if(!c){var h=this.s.h(a,b);c=zj(this.A,b,h)}d=c.next(0).value.value}else d=this.name;if(d){if("xmlns"===d.prefix)throw rg(d);if(""===d.prefix&&"xmlns"===d.localName)throw rg(d);if("http://www.w3.org/2000/xmlns/"===
|
|
282
|
+
d.namespaceURI)throw rg(d);if("xml"===d.prefix&&"http://www.w3.org/XML/1998/namespace"!==d.namespaceURI)throw rg(d);if(""!==d.prefix&&"xml"!==d.prefix&&"http://www.w3.org/XML/1998/namespace"===d.namespaceURI)throw rg(d);}}if(this.l.nb)return h=this.l.nb,e||(e=jc(h.map(k=>qc(k.h(a,b),b).N(l=>w.m(g(l.map(n=>n.value).join(" "),1))))).N(k=>w.m(rb(Uj(d,k.map(l=>l.value).join(""))))).value),e.next(0);f=!0;return q(rb(Uj(d,this.l.value)))}})}v(a){this.A=Ef(a);if(this.name&&this.name.prefix&&!this.name.namespaceURI){const b=
|
|
283
|
+
a.$(this.name.prefix);if(void 0===b&&this.name.prefix)throw oc(this.name.prefix);this.name.namespaceURI=b||null}super.v(a)}};var Wj=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{B:!1,R:"unsorted"});this.l=a}h(a,b){const c={data:"",Ra:!0,nodeType:8},d={node:c,G:null};if(!this.l)return w.m(rb(d));a=C(this.l,a,b);return qc(a,b).N(e=>{e=e.map(f=>jd(f,1).value).join(" ");if(-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');c.data=e;return w.m(rb(d))})}};var Xj=class extends D{constructor(a,b,c,d){super(new uf({}),d.concat(b).concat(a.Na||[]),{B:!1,R:"unsorted"});a.Na?this.s=a.Na:this.l=new Sa(a.prefix,a.namespaceURI,a.localName);this.P=c.reduce((e,f)=>{if(f.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${f.prefix} has already been declared on the constructed element.`);e[f.prefix||""]=f.uri;return e},{});this.L=b;this.ma=d;this.A=void 0}h(a,b){let c=!1,d,e,f=!1,h,k,l,n=!1;return w.create({next:()=>{if(n)return p;c||
|
|
284
|
+
(d||=jc(this.L.map(G=>C(G,a,b))),e=d.O(),c=!0);if(!f){h||=this.ma.map(G=>C(G,a,b));var t=[];for(var u=0;u<h.length;u++){var z=h[u].O();t.push(z)}k=t;f=!0}this.s&&(l||(t=this.s.h(a,b),l=zj(this.A,b,t)),this.l=l.next(0).value.value);if("xmlns"===this.l.prefix||"http://www.w3.org/2000/xmlns/"===this.l.namespaceURI||"xml"===this.l.prefix&&"http://www.w3.org/XML/1998/namespace"!==this.l.namespaceURI||this.l.prefix&&"xml"!==this.l.prefix&&"http://www.w3.org/XML/1998/namespace"===this.l.namespaceURI)throw Error(`XQDY0096: The node name "${this.l.za()}" is invalid for a computed element constructor.`);
|
|
285
|
+
const y={nodeType:1,Ra:!0,attributes:[],childNodes:[],nodeName:this.l.za(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};t={node:y,G:null};e.forEach(G=>{y.attributes.push(G.value.node)});u=rj(k,b,qg);u.attributes.forEach(G=>{if(y.attributes.find(N=>N.namespaceURI===G.namespaceURI&&N.localName===G.localName))throw Error(`XQDY0025: The attribute ${G.name} does not have an unique name in the constructed element.`);y.attributes.push(G)});u.Xa.forEach(G=>{y.childNodes.push(G)});
|
|
286
|
+
for(u=0;u<y.childNodes.length;u++){z=y.childNodes[u];if(!cb(z)||3!==z.nodeType)continue;const G=y.childNodes[u-1];G&&cb(G)&&3===G.nodeType&&(G.data+=z.data,y.childNodes.splice(u,1),u--)}n=!0;return q(rb(t))}})}v(a){Cg(a);Object.keys(this.P).forEach(b=>Fg(a,b,this.P[b]));this.Fa.forEach(b=>b.v(a));this.L.reduce((b,c)=>{if(c.name){c=`Q{${null===c.name.namespaceURI?a.$(c.name.prefix):c.name.namespaceURI}}${c.name.localName}`;if(b.includes(c))throw Error(`XQST0040: The attribute ${c} does not have an unique name in the constructed element.`);
|
|
287
|
+
b.push(c)}return b},[]);if(this.l&&null===this.l.namespaceURI){const b=a.$(this.l.prefix);if(void 0===b&&this.l.prefix)throw oc(this.l.prefix);this.l.namespaceURI=b}this.A=Ef(a);Ig(a)}};function Yj(a){if(/^xml$/i.test(a))throw Error(`XQDY0064: The target of a created PI may not be "${a}"`);}function Zj(a,b){return{node:{data:b,Ra:!0,nodeName:a,nodeType:7,target:a},G:null}}
|
|
288
|
+
var ak=class extends D{constructor(a,b){const c=a.xb?[a.xb].concat(b):[b];super(c.reduce((d,e)=>d.add(e.o),new uf({})),c,{B:!1,R:"unsorted"});this.l=a;this.s=b}h(a,b){const c=C(this.s,a,b);return qc(c,b).N(d=>{const e=d.map(h=>jd(h,1).value).join(" ");if(-1!==e.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Fb)return d=this.l.Fb,Yj(d),w.m(rb(Zj(d,e)));d=C(this.l.xb,a,b);const f=yj(b,d);return w.create({next:()=>{var h=
|
|
289
|
+
f.next(0);if(h.done)return h;h=h.value.value;Yj(h);return q(rb(Zj(h,e)))}})})}};var bk=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{B:!1,R:"unsorted"});this.l=a}h(a,b){if(!this.l)return w.empty();a=C(this.l,a,b);return qc(a,b).N(c=>{if(0===c.length)return w.empty();c={node:{data:c.map(d=>jd(d,1).value).join(" "),Ra:!0,nodeType:3},G:null};return w.m(rb(c))})}};var ck=class extends qf{constructor(a,b,c,d){super(new uf({}),[a,...b.map(e=>e.pb),c].concat(...b.map(e=>e.Ib.map(f=>f.Hb))),{B:!1,W:!1,R:"unsorted",subtree:!1},d);this.L=a;this.l=b.length;this.P=b.map(e=>e.Ib)}A(a,b,c){return c[0](a).N(d=>{for(let e=0;e<this.l;e++)if(this.P[e].some(f=>{switch(f.ec){case "?":if(1<d.length)return!1;break;case "*":break;case "+":if(1>d.length)return!1;break;default:if(1!==d.length)return!1}const h=w.create(d);return d.every((k,l)=>{k=bc(a,l,k,h);return C(f.Hb,k,b).fa()})}))return c[e+
|
|
290
|
+
1](a);return c[this.l+1](a)})}v(a){super.v(a);if(this.L.I)throw Ne();}};var dk=class extends qf{constructor(a,b,c,d){super(new uf({}),[a,c,...b.map(e=>e.pb)].concat(...b.map(e=>e.Gb.map(f=>f))),{B:!1,W:!1,R:"unsorted",subtree:!1},d);this.L=a;this.l=b.length;this.P=b.map(e=>e.Gb)}A(a,b,c){const d=ei(c[0](a),b),[,e,...f]=c;return d.X({multiple:()=>{throw Error("XPTY0004: The operand for a switch expression should result in zero or one item");},default:()=>{const h=d.first(),k=!h;for(let n=0;n<this.l;n++){var l=this.P[n].map(t=>C(t,a,b));for(const t of l)if(l=ei(t,b),l.F()){if(k)return f[n](a)}else{if(!l.oa())throw Error("XPTY0004: The operand for a switch case should result in zero or one item");
|
|
291
|
+
if(!k&&(l=l.first(),Ge(a,b,null,h,l).next(0).value))return f[n](a)}}return e(a)}})}v(a){super.v(a);if(this.L.I)throw Ne();}};var ek={Z:!1,sa:!1},fk={Z:!0,sa:!1},gk={Z:!0,sa:!0};function P(a){return a.Z?a.sa?gk:fk:ek}
|
|
292
|
+
function Q(a,b){switch(a[0]){case "andOp":var c=I(a,"type");return new ci(hk("andOp",a,P(b)),c);case "orOp":return c=I(a,"type"),new di(hk("orOp",a,P(b)),c);case "unaryPlusOp":return c=F(F(a,"operand"),"*"),a=I(a,"type"),new bi("+",Q(c,b),a);case "unaryMinusOp":return c=F(F(a,"operand"),"*"),a=I(a,"type"),new bi("-",Q(c,b),a);case "addOp":case "subtractOp":case "multiplyOp":case "divOp":case "idivOp":case "modOp":var d=a[0],e=Q(J(a,["firstOperand","*"]),P(b));b=Q(J(a,["secondOperand","*"]),P(b));
|
|
293
|
+
const f=I(a,"type"),h=I(J(a,["firstOperand","*"]),"type"),k=I(J(a,["secondOperand","*"]),"type");h&&k&&I(a,"type")&&(c=Rg(d,h.type,k.type));return new Vg(d,e,b,f,c);case "sequenceExpr":return ik(a,b);case "unionOp":return c=I(a,"type"),new Hi([Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b))],c);case "exceptOp":case "intersectOp":return c=I(a,"type"),new xi(a[0],Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b)),c);case "stringConcatenateOp":return jk(a,b);case "rangeSequenceExpr":return kk(a,
|
|
294
|
+
b);case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":return lk("generalCompare",a,b);case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":return lk("valueCompare",a,b);case "isOp":case "nodeBeforeOp":case "nodeAfterOp":return lk("nodeCompare",a,b);case "pathExpr":return mk(a,b);case "contextItemExpr":return new Mi(I(a,"type"));case "functionCallExpr":return nk(a,b);case "inlineFunctionExpr":return ok(a,b);
|
|
295
|
+
case "arrowExpr":return pk(a,b);case "dynamicFunctionInvocationExpr":return qk(a,b);case "namedFunctionRef":return b=F(a,"functionName"),c=I(a,"type"),a=H(J(a,["integerConstantExpr","value"])),new $h(Jg(b),parseInt(a,10),c);case "integerConstantExpr":return new Yh(H(F(a,"value")),{type:5,g:3});case "stringConstantExpr":return new Yh(H(F(a,"value")),{type:1,g:3});case "decimalConstantExpr":return new Yh(H(F(a,"value")),{type:4,g:3});case "doubleConstantExpr":return new Yh(H(F(a,"value")),{type:3,g:3});
|
|
296
|
+
case "varRef":const {prefix:l,namespaceURI:n,localName:t}=Jg(F(a,"name"));return new $i(l,n,t);case "flworExpr":return rk(a,b);case "quantifiedExpr":return sk(a,b);case "ifThenElseExpr":return c=I(a,"type"),d=F(a,"ifClause")||K(a,"x:stackTrace")[0],e=F(a,"thenClause")||K(a,"x:stackTrace")[1],a=F(a,"elseClause")||K(a,"x:stackTrace")[2],new Ph(Q(d,P(b)),Q(e,b),Q(a,b),c);case "instanceOfExpr":return c=Q(J(a,["argExpr","*"]),b),d=J(a,["sequenceType","*"]),e=J(a,["sequenceType","occurrenceIndicator"]),
|
|
297
|
+
a=I(a,"type"),new Di(c,Q(d,P(b)),e?H(e):"",a);case "castExpr":return b=Q(F(F(a,"argExpr"),"*"),P(b)),c=F(a,"singleType"),a=Jg(F(c,"atomicType")),c=null!==F(c,"optional"),new Bi(b,a,c);case "castableExpr":return b=Q(F(F(a,"argExpr"),"*"),P(b)),c=F(a,"singleType"),a=Jg(F(c,"atomicType")),c=null!==F(c,"optional"),new Ai(b,a,c);case "simpleMapExpr":return tk(a,b);case "mapConstructor":return uk(a,b);case "arrayConstructor":return vk(a,b);case "unaryLookup":return c=I(a,"type"),new Ti(wk(a,b),c);case "typeswitchExpr":return xk(a,
|
|
298
|
+
b);case "switchExpr":return yk(a,b);case "elementConstructor":return zk(a,b);case "attributeConstructor":return Ak(a,b);case "computedAttributeConstructor":return(c=F(a,"tagName"))?c=Jg(c):(c=F(a,"tagNameExpr"),c={Na:Q(F(c,"*"),P(b))}),b=Q(F(F(a,"valueExpr"),"*"),P(b)),new Vj(c,{nb:[b]});case "computedCommentConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");b=(a=F(a,"argExpr"))?Q(F(a,"*"),P(b)):null;return new Wj(b);case "computedTextConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");
|
|
299
|
+
b=(a=F(a,"argExpr"))?Q(F(a,"*"),P(b)):null;return new bk(b);case "computedElementConstructor":return Bk(a,b);case "computedPIConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");c=F(a,"piTargetExpr");d=F(a,"piTarget");e=F(a,"piValueExpr");a=I(a,"type");return new ak({xb:c?Q(F(c,"*"),P(b)):null,Fb:d?H(d):null},e?Q(F(e,"*"),P(b)):new yi([],a));case "CDataSection":return new Yh(H(a),{type:1,g:3});case "deleteExpr":return b=Q(J(a,["targetExpr","*"]),
|
|
300
|
+
b),new pj(b);case "insertExpr":c=Q(J(a,["sourceExpr","*"]),b);e=K(a,"*")[1];switch(e[0]){case "insertAfter":d=1;break;case "insertBefore":d=2;break;case "insertInto":d=(d=F(e,"*"))?"insertAsFirst"===d[0]?4:5:3}b=Q(J(a,["targetExpr","*"]),b);return new tj(c,d,b);case "renameExpr":return c=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,["newNameExpr","*"]),b),new Aj(c,b);case "replaceExpr":return c=!!F(a,"replaceValue"),d=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,["replacementExpr","*"]),b),new Qj(c,d,b);case "transformExpr":return Ck(a,
|
|
301
|
+
b);case "x:stackTrace":c=a;for(a=c[2];"x:stackTrace"===a[0];)c=a,a=a[2];c=c[1];return new Rh(c,a[0],Q(a,b),c.Wa);case "ifClause":case "thenClause":case "elseClause":return Q(F(a,"*"),b);default:return Dk(a)}}
|
|
302
|
+
function Dk(a){switch(a[0]){case "nameTest":return new Xi(Jg(a));case "piTest":return(a=F(a,"piTarget"))?new Yi(H(a)):new Wi(7);case "commentTest":return new Wi(8);case "textTest":return new Wi(3);case "documentTest":return new Wi(9);case "attributeTest":var b=(a=F(a,"attributeName"))&&F(a,"star");return!a||b?new Wi(2):new Xi(Jg(F(a,"QName")),{kind:2});case "elementTest":return b=(a=F(a,"elementName"))&&F(a,"star"),!a||b?new Wi(1):new Xi(Jg(F(a,"QName")),{kind:1});case "anyKindTest":return new Zi({prefix:"",
|
|
303
|
+
namespaceURI:null,localName:"node()"});case "anyMapTest":return new Zi({prefix:"",namespaceURI:null,localName:"map(*)"});case "anyArrayTest":return new Zi({prefix:"",namespaceURI:null,localName:"array(*)"});case "Wildcard":return F(a,"star")?(b=F(a,"uri"))?a=new Xi({localName:"*",namespaceURI:H(b),prefix:""}):(b=F(a,"NCName"),a="star"===F(a,"*")[0]?new Xi({localName:H(b),namespaceURI:null,prefix:"*"}):new Xi({localName:"*",namespaceURI:null,prefix:H(b)})):a=new Xi({localName:"*",namespaceURI:null,
|
|
304
|
+
prefix:"*"}),a;case "atomicType":return new Zi(Jg(a));case "anyItemType":return new Zi({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+a[0]+".");}}function vk(a,b){const c=I(a,"type");a=F(a,"*");const d=K(a,"arrayElem").map(e=>Q(F(e,"*"),P(b)));switch(a[0]){case "curlyArray":return new rh(d,c);case "squareArray":return new sh(d,c);default:throw Error("Unrecognized arrayType: "+a[0]);}}
|
|
305
|
+
function uk(a,b){const c=I(a,"type");return new Zh(K(a,"mapConstructorEntry").map(d=>({key:Q(J(d,["mapKeyExpr","*"]),P(b)),value:Q(J(d,["mapValueExpr","*"]),P(b))})),c)}function hk(a,b,c){function d(f){const h=F(F(f,"firstOperand"),"*");f=F(F(f,"secondOperand"),"*");h[0]===a?d(h):e.push(Q(h,c));f[0]===a?d(f):e.push(Q(f,c))}const e=[];d(b);return e}function wk(a,b){a=F(a,"*");switch(a[0]){case "NCName":return new Yh(H(a),{type:1,g:3});case "star":return"*";default:return Q(a,P(b))}}
|
|
306
|
+
function lk(a,b,c){var d=J(b,["firstOperand","*"]);const e=J(b,["secondOperand","*"]);d=Q(d,P(c));c=Q(e,P(c));switch(a){case "valueCompare":return new pi(b[0],d,c);case "nodeCompare":return new vi(b[0],d,c);case "generalCompare":return new si(b[0],d,c)}}
|
|
307
|
+
function Ek(a,b,c){a=K(a,"*");return new Ki(a.filter(d=>"stable"!==d[0]).map(d=>{var e=F(d,"orderModifier"),f=e?F(e,"orderingKind"):null;e=e?F(e,"emptyOrderingMode"):null;f=f?"ascending"===H(f):!0;e=e?"empty least"===H(e):!0;return{ba:Q(J(d,["orderByExpr","*"]),b),Bb:f,cc:e}}),c)}
|
|
308
|
+
function rk(a,b){var c=K(a,"*");a=F(c[c.length-1],"*");c=c.slice(0,-1);if(1<c.length&&!b.Z)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return c.reduceRight((d,e)=>{switch(e[0]){case "forClause":e=K(e,"*");for(var f=e.length-1;0<=f;--f){var h=e[f],k=J(h,["forExpr","*"]);const l=F(h,"positionalVariableBinding");d=new Vh(Jg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),l?Jg(l):null,d)}return d;case "letClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)h=e[f],k=J(h,
|
|
309
|
+
["letExpr","*"]),d=new Xh(Jg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),d);return d;case "whereClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)d=new aj(Q(e[f],b),d);return d;case "windowClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "groupByClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "orderByClause":return Ek(e,b,d);case "countClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);default:throw Error(`Not implemented: ${e[0]} is not supported in a flwor expression`);
|
|
310
|
+
}},Q(a,b))}function nk(a,b){const c=F(a,"functionName"),d=K(F(a,"arguments"),"*");a=I(a,"type");return new Ff(new $h(Jg(c),d.length,a),d.map(e=>"argumentPlaceholder"===e[0]?null:Q(e,b)),a)}
|
|
311
|
+
function pk(a,b){const c=I(a,"type");var d=J(a,["argExpr","*"]);a=K(a,"*").slice(1);d=[Q(d,b)];for(let f=0;f<a.length;f++)if("arguments"!==a[f][0]){if("arguments"===a[f+1][0]){var e=K(a[f+1],"*");d=d.concat(e.map(h=>"argumentPlaceholder"===h[0]?null:Q(h,b)))}e="EQName"===a[f][0]?new $h(Jg(a[f]),d.length,c):Q(a[f],P(b));d=[new Ff(e,d,c)]}return d[0]}
|
|
312
|
+
function qk(a,b){const c=J(a,["functionItem","*"]),d=I(a,"type");a=F(a,"arguments");let e=[];a&&(e=K(a,"*").map(f=>"argumentPlaceholder"===f[0]?null:Q(f,b)));return new Ff(Q(c,b),e,d)}function ok(a,b){const c=K(F(a,"paramList"),"*"),d=J(a,["functionBody","*"]),e=I(a,"type");return new Wh(c.map(f=>({name:Jg(F(f,"varName")),type:Kg(f)})),Kg(a),d?Q(d,b):new yi([],e))}
|
|
313
|
+
function mk(a,b){const c=I(a,"type");var d=K(a,"stepExpr");let e=!1;var f=d.map(h=>{var k=F(h,"xpathAxis");let l;var n=K(h,"*");const t=[];let u=null,z=!1;for(const y of n)switch(y[0]){case "lookup":t.push(["lookup",wk(y,b)]);break;case "predicate":case "predicates":for(const G of K(y,"*")){n=Q(G,P(b));if(!z){const N=n.D();null===N?z=!0:u=xh(u,N)}t.push(["predicate",n])}}if(k)switch(e=!0,h=F(h,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),
|
|
314
|
+
h=Dk(h),H(k)){case "ancestor":l=new vh(h,{Qa:!1});break;case "ancestor-or-self":l=new vh(h,{Qa:!0});break;case "attribute":l=new yh(h,u);break;case "child":l=new zh(h,u);break;case "descendant":l=new Ch(h,{Qa:!1});break;case "descendant-or-self":l=new Ch(h,{Qa:!0});break;case "parent":l=new Jh(h,u);break;case "following-sibling":l=new Ih(h,u);break;case "preceding-sibling":l=new Nh(h,u);break;case "following":l=new Gh(h);break;case "preceding":l=new Lh(h);break;case "self":l=new Oh(h,u)}else k=J(h,
|
|
315
|
+
["filterExpr","*"]),l=Q(k,P(b));for(const y of t)switch(y[0]){case "lookup":l=new Si(l,y[1]);break;case "predicate":l=new Pi(l,y[1])}l.type=c;return l});a=F(a,"rootExpr");d=e||null!==a||1<d.length;if(!d&&1===f.length||!a&&1===f.length&&"sorted"===f[0].ia)return f[0];if(a&&0===f.length)return new Li(null);f=new Oi(f,d);return a?new Li(f):f}
|
|
316
|
+
function sk(a,b){const c=I(a,"type"),d=H(F(a,"quantifier")),e=J(a,["predicateExpr","*"]);a=K(a,"quantifiedExprInClause").map(f=>{const h=Jg(J(f,["typedVariableBinding","varName"]));f=J(f,["sourceExpr","*"]);return{name:h,fb:Q(f,P(b))}});return new Ui(d,a,Q(e,P(b)),c)}function ik(a,b){var c=K(a,"*").map(d=>Q(d,b));if(1===c.length)return c[0];c=I(a,"type");return new yi(K(a,"*").map(d=>Q(d,b)),c)}
|
|
317
|
+
function tk(a,b){const c=I(a,"type");return K(a,"*").reduce((d,e)=>null===d?Q(e,P(b)):new zi(d,Q(e,P(b)),c),null)}function jk(a,b){const c=I(a,"type");a=[J(a,["firstOperand","*"]),J(a,["secondOperand","*"])];return new Ff(new $h({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},a.length,c),a.map(d=>Q(d,P(b))),c)}
|
|
318
|
+
function kk(a,b){const c=I(a,"type");a=[F(F(a,"startExpr"),"*"),F(F(a,"endExpr"),"*")];const d=new $h({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},a.length,c);return new Ff(d,a.map(e=>Q(e,P(b))),c)}
|
|
319
|
+
function zk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Jg(F(a,"tagName"));var d=F(a,"attributeList");const e=d?K(d,"attributeConstructor").map(f=>Q(f,P(b))):[];d=d?K(d,"namespaceDeclaration").map(f=>{const h=F(f,"prefix");return{prefix:h?H(h):"",uri:H(F(f,"uri"))}}):[];a=(a=F(a,"elementContent"))?K(a,"*").map(f=>Q(f,P(b))):[];return new Xj(c,e,d,a)}
|
|
320
|
+
function Ak(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Jg(F(a,"attributeName"));var d=F(a,"attributeValue");d=d?H(d):null;a=(a=F(a,"attributeValueExpr"))?K(a,"*").map(e=>Q(e,P(b))):null;return new Vj(c,{value:d,nb:a})}function Bk(a,b){var c=F(a,"tagName");c?c=Jg(c):(c=F(a,"tagNameExpr"),c={Na:Q(F(c,"*"),P(b))});a=(a=F(a,"contentExpr"))?K(a,"*").map(d=>Q(d,P(b))):[];return new Xj(c,[],[],a)}
|
|
321
|
+
function Ck(a,b){const c=K(F(a,"transformCopies"),"transformCopy").map(e=>{const f=Jg(F(F(e,"varRef"),"name"));return{fb:Q(F(F(e,"copySource"),"*"),b),Jb:new Sa(f.prefix,f.namespaceURI,f.localName)}}),d=Q(F(F(a,"modifyExpr"),"*"),b);a=Q(F(F(a,"returnExpr"),"*"),b);return new Tj(c,d,a)}
|
|
322
|
+
function xk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(F(F(a,"argExpr"),"*"),b),e=K(a,"typeswitchExprCaseClause").map(f=>{const h=0===K(f,"sequenceTypeUnion").length?[F(f,"sequenceType")]:K(F(f,"sequenceTypeUnion"),"sequenceType");return{pb:Q(J(f,["resultExpr","*"]),b),Ib:h.map(k=>{const l=F(k,"occurrenceIndicator");return{ec:l?H(l):"",Hb:Q(F(k,"*"),b)}})}});a=Q(J(a,["typeswitchExprDefaultClause","resultExpr","*"]),b);
|
|
323
|
+
return new ck(d,e,a,c)}function yk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(F(F(a,"argExpr"),"*"),b),e=K(a,"switchExprCaseClause").map(f=>{const h=K(f,"switchCaseExpr");return{pb:Q(J(f,["resultExpr","*"]),b),Gb:h.map(k=>Q(F(k,"*"),b))}});a=Q(J(a,["switchExprDefaultClause","resultExpr","*"]),b);return new dk(d,e,a,c)}function Fk(a,b){return Q(a,b)};const Gk=new Map;class Hk{constructor(a,b,c,d,e,f){this.v=a;this.D=b;this.h=c;this.kb=d;this.o=e;this.l=f}}function Ik(a,b,c,d,e,f,h,k){a=Gk.get(a);if(!a)return null;b=a[b+(f?"_DEBUG":"")];return b?(b=b.find(l=>l.o===h&&l.v.every(n=>c(n.prefix)===n.namespaceURI)&&l.D.every(n=>void 0!==d[n.name])&&l.kb.every(n=>e[n.prefix]===n.namespaceURI)&&l.l.every(n=>{const t=k(n.dc,n.arity);return t&&t.namespaceURI===n.Db.namespaceURI&&t.localName===n.Db.localName})))?{ba:b.h,hc:!1}:null:null}
|
|
324
|
+
function Jk(a,b,c,d,e,f,h){let k=Gk.get(a);k||(k=Object.create(null),Gk.set(a,k));a=b+(f?"_DEBUG":"");(b=k[a])||(b=k[a]=[]);b.push(new Hk(Object.values(c.h),Object.values(c.o),e,Object.keys(d).map(l=>({namespaceURI:d[l],prefix:l})),h,c.D))};function Kk(a){var b=new Za;if("http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://fontoxml.com/fontoxpath"!==a.namespaceURI&&"http://www.w3.org/2007/xquery-update-10"!==a.namespaceURI)throw mc("The XML structure passed as an XQueryX program was not valid XQueryX");const c=["stackTrace"===a.localName?"x:stackTrace":a.localName],d=b.getAllAttributes(a);d&&0<d.length&&c.push(Array.from(d).reduce((e,f)=>{"comment"!==f.localName&&"start"!==f.localName&&
|
|
325
|
+
"end"!==f.localName||"stackTrace"!==a.localName?"type"===f.localName?e[f.localName]=Ja(f.value):e[f.localName]=f.value:e[f.localName]=JSON.parse(f.value);return e},{}));b=b.getChildNodes(a);for(const e of b)switch(e.nodeType){case 1:c.push(Kk(e));break;case 3:c.push(e.data)}return c};const Lk=Object.create(null);
|
|
326
|
+
var Mk=(a,b)=>{let c=Lk[a];c||=Lk[a]={Ia:[],Ta:[],pa:null,source:b.source};const d=c.pa||(()=>{});c.Ia=c.Ia.concat(b.Ia);c.Ta=c.Ta.concat(b.Ta);c.pa=e=>{d(e);b.pa&&b.pa(e)}},Nk=(a,b)=>{const c=Lk[b];if(!c)throw Error(`XQST0051: No modules found with the namespace uri ${b}`);c.Ia.forEach(d=>{d.cb&&Eg(a,b,d.localName,d.arity,d)});c.Ta.forEach(d=>{Gg(a,b,d.localName);Hg(a,b,d.localName,(e,f)=>C(d.ba,e,f))})},Ok=()=>{Object.keys(Lk).forEach(a=>{a=Lk[a];if(a.pa)try{a.pa(a)}catch(b){a.pa=null,gg(a.source,
|
|
327
|
+
b)}a.pa=null})};function Pk(a){return a.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))};var R=prsc;function Qk(a,b){return(c,d)=>{if(b.has(d))return b.get(d);c=a(c,d);b.set(d,c);return c}}function S(a,b){return(0,R.delimited)(b,a,b)}function T(a,b){return a.reverse().reduce((c,d)=>(0,R.preceded)(d,c),b)}function Rk(a,b,c,d){return(0,R.then)((0,R.then)(a,b,(e,f)=>[e,f]),c,([e,f],h)=>d(e,f,h))}function Sk(a,b,c,d,e){return(0,R.then)((0,R.then)((0,R.then)(a,b,(f,h)=>[f,h]),c,([f,h],k)=>[f,h,k]),d,([f,h,k],l)=>e(f,h,k,l))}
|
|
328
|
+
function Tk(a,b,c,d,e,f){return(0,R.then)((0,R.then)((0,R.then)((0,R.then)(a,b,(h,k)=>[h,k]),c,([h,k],l)=>[h,k,l]),d,([h,k,l],n)=>[h,k,l,n]),e,([h,k,l,n],t)=>f(h,k,l,n,t))}function Uk(a){return(0,R.map)(a,b=>[b])}function Vk(a,b){return(0,R.map)((0,R.or)(a),()=>b)}function Wk(a){return(b,c)=>(b=a.exec(b.substring(c)))&&0===b.index?(0,R.okWithValue)(c+b[0].length,b[0]):(0,R.error)(c,[a.source],!1)};var Xk=(0,R.or)([(0,R.token)(" "),(0,R.token)("\t"),(0,R.token)("\r"),(0,R.token)("\n")]),Yk=(0,R.token)("(:"),Zk=(0,R.token)(":)"),$k=(0,R.token)("(#"),al=(0,R.token)("#)"),bl=(0,R.token)("("),cl=(0,R.token)(")"),dl=(0,R.token)("["),el=(0,R.token)("]"),fl=(0,R.token)("{"),gl=(0,R.token)("}"),hl=(0,R.token)("{{"),il=(0,R.token)("}}"),jl=(0,R.token)("'"),kl=(0,R.token)("''"),ll=(0,R.token)('"'),ml=(0,R.token)('""'),nl=(0,R.token)("<![CDATA["),ol=(0,R.token)("]]\x3e"),pl=(0,R.token)("/>"),ql=(0,R.token)("</"),
|
|
329
|
+
rl=(0,R.token)("\x3c!--"),sl=(0,R.token)("--\x3e"),tl=(0,R.token)("<?"),ul=(0,R.token)("?>"),vl=(0,R.token)("&#x"),wl=(0,R.token)("&#"),xl=(0,R.token)(":*"),yl=(0,R.token)("*:"),zl=(0,R.token)(":="),Al=(0,R.token)("&"),Bl=(0,R.token)(":"),Cl=(0,R.token)(";"),Dl=(0,R.token)("*"),El=(0,R.token)("@"),Fl=(0,R.token)("$"),Gl=(0,R.token)("#"),Hl=(0,R.token)("%"),Il=(0,R.token)("?"),Jl=(0,R.token)("="),Kl=(0,R.followed)((0,R.token)("!"),(0,R.not)((0,R.peek)(Jl),[])),Ll=(0,R.followed)((0,R.token)("|"),(0,R.not)((0,R.peek)((0,R.token)("|")),
|
|
330
|
+
[])),Ml=(0,R.token)("||"),Nl=(0,R.token)("!="),Ol=(0,R.token)("<"),Pl=(0,R.token)("<<"),Ql=(0,R.token)("<="),Rl=(0,R.token)(">"),Sl=(0,R.token)(">>"),Tl=(0,R.token)(">="),Ul=(0,R.token)(","),Vl=(0,R.token)("."),Wl=(0,R.token)(".."),Xl=(0,R.token)("+"),Yl=(0,R.token)("-"),Zl=(0,R.token)("/"),$l=(0,R.token)("//"),am=(0,R.token)("=>"),bm=(0,R.token)("e"),cm=(0,R.token)("E");(0,R.token)("l");(0,R.token)("L");(0,R.token)("m");(0,R.token)("M");var dm=(0,R.token)("Q");(0,R.token)("x");(0,R.token)("X");
|
|
331
|
+
var em=(0,R.token)("as"),fm=(0,R.token)("cast"),gm=(0,R.token)("castable"),hm=(0,R.token)("treat"),im=(0,R.token)("instance"),jm=(0,R.token)("of"),km=(0,R.token)("node"),lm=(0,R.token)("nodes"),mm=(0,R.token)("delete"),nm=(0,R.token)("value"),om=(0,R.token)("function"),pm=(0,R.token)("map"),qm=(0,R.token)("element"),rm=(0,R.token)("attribute"),sm=(0,R.token)("schema-element"),tm=(0,R.token)("intersect"),um=(0,R.token)("except"),vm=(0,R.token)("union"),wm=(0,R.token)("to"),xm=(0,R.token)("is"),ym=
|
|
332
|
+
(0,R.token)("or"),zm=(0,R.token)("and"),Am=(0,R.token)("div"),Bm=(0,R.token)("idiv"),Cm=(0,R.token)("mod"),Dm=(0,R.token)("eq"),Em=(0,R.token)("ne"),Fm=(0,R.token)("lt"),Gm=(0,R.token)("le"),Hm=(0,R.token)("gt"),Im=(0,R.token)("ge"),Jm=(0,R.token)("amp"),Km=(0,R.token)("quot"),Lm=(0,R.token)("apos"),Mm=(0,R.token)("if"),Nm=(0,R.token)("then"),Om=(0,R.token)("else"),Pm=(0,R.token)("allowing"),Qm=(0,R.token)("empty"),Rm=(0,R.token)("at"),Sm=(0,R.token)("in"),Tm=(0,R.token)("for"),Um=(0,R.token)("let"),
|
|
333
|
+
Vm=(0,R.token)("where"),Wm=(0,R.token)("collation"),Xm=(0,R.token)("group"),Ym=(0,R.token)("by"),Zm=(0,R.token)("order"),$m=(0,R.token)("stable"),an=(0,R.token)("return"),bn=(0,R.token)("array"),cn=(0,R.token)("document"),dn=(0,R.token)("namespace"),en=(0,R.token)("text"),fn=(0,R.token)("comment"),gn=(0,R.token)("processing-instruction"),hn=(0,R.token)("lax"),jn=(0,R.token)("strict"),kn=(0,R.token)("validate"),ln=(0,R.token)("type"),mn=(0,R.token)("declare"),nn=(0,R.token)("default"),on=(0,R.token)("boundary-space"),
|
|
334
|
+
pn=(0,R.token)("strip"),qn=(0,R.token)("preserve"),rn=(0,R.token)("no-preserve"),sn=(0,R.token)("inherit"),tn=(0,R.token)("no-inherit"),un=(0,R.token)("greatest"),vn=(0,R.token)("least"),wn=(0,R.token)("copy-namespaces"),xn=(0,R.token)("decimal-format"),yn=(0,R.token)("case"),zn=(0,R.token)("typeswitch"),An=(0,R.token)("some"),Bn=(0,R.token)("every"),Cn=(0,R.token)("satisfies"),Dn=(0,R.token)("replace"),En=(0,R.token)("with"),Fn=(0,R.token)("copy"),Gn=(0,R.token)("modify"),Hn=(0,R.token)("first"),
|
|
335
|
+
In=(0,R.token)("last"),Jn=(0,R.token)("before"),Kn=(0,R.token)("after"),Ln=(0,R.token)("into"),Mn=(0,R.token)("insert"),Nn=(0,R.token)("rename"),On=(0,R.token)("switch"),Pn=(0,R.token)("variable"),Qn=(0,R.token)("external"),Rn=(0,R.token)("updating"),Sn=(0,R.token)("import"),Tn=(0,R.token)("schema"),Un=(0,R.token)("module"),Vn=(0,R.token)("base-uri"),Wn=(0,R.token)("construction"),Xn=(0,R.token)("ordering"),Yn=(0,R.token)("ordered"),Zn=(0,R.token)("unordered"),$n=(0,R.token)("option"),ao=(0,R.token)("context"),
|
|
336
|
+
bo=(0,R.token)("item"),co=(0,R.token)("xquery"),eo=(0,R.token)("version"),fo=(0,R.token)("encoding"),go=(0,R.token)("document-node"),ho=(0,R.token)("namespace-node"),io=(0,R.token)("schema-attribute"),jo=(0,R.token)("ascending"),ko=(0,R.token)("descending"),lo=(0,R.token)("empty-sequence"),mo=(0,R.token)("child::"),no=(0,R.token)("descendant::"),oo=(0,R.token)("attribute::"),po=(0,R.token)("self::"),qo=(0,R.token)("descendant-or-self::"),ro=(0,R.token)("following-sibling::"),so=(0,R.token)("following::"),
|
|
337
|
+
to=(0,R.token)("parent::"),uo=(0,R.token)("ancestor::"),vo=(0,R.token)("preceding-sibling::"),wo=(0,R.token)("preceding::"),xo=(0,R.token)("ancestor-or-self::"),yo=(0,R.token)("decimal-separator"),zo=(0,R.token)("grouping-separator"),Ao=(0,R.token)("infinity"),Bo=(0,R.token)("minus-sign"),Co=(0,R.token)("NaN"),Do=(0,R.token)("per-mille"),Eo=(0,R.token)("zero-digit"),Fo=(0,R.token)("digit"),Go=(0,R.token)("pattern-separator"),Ho=(0,R.token)("exponent-separator"),Io=(0,R.token)("schema-attribute("),
|
|
338
|
+
Jo=(0,R.token)("document-node("),Ko=(0,R.token)("processing-instruction("),Lo=(0,R.token)("processing-instruction()"),Mo=(0,R.token)("comment()"),No=(0,R.token)("text()"),Oo=(0,R.token)("namespace-node()"),Po=(0,R.token)("node()"),Qo=(0,R.token)("item()"),Ro=(0,R.token)("empty-sequence()");(0,R.token)("`");var So=(0,R.token)("``["),To=(0,R.token)("]``"),Uo=(0,R.token)("`{"),Vo=(0,R.token)("}`");var Wo=new Map,Xo=new Map,Yo=(0,R.or)([Wk(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Wk(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),Zo=(0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([Yk,Zk]),['comment contents cannot contain "(:" or ":)"'])),Yo),$o=(0,R.map)((0,R.delimited)(Yk,(0,R.star)((0,R.or)([Zo,function(a,b){return $o(a,b)}])),Zk,!0),a=>a.join("")),ap=(0,R.or)([Xk,$o]),bp=(0,R.map)((0,R.plus)(Xk),a=>a.join("")),V=Qk((0,R.map)((0,R.star)(ap),a=>a.join("")),Wo),X=Qk((0,R.map)((0,R.plus)(ap),a=>a.join("")),Xo);const cp=(0,R.or)([Wk(/[A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/),(0,R.then)(Wk(/[\uD800-\uDB7F]/),Wk(/[\uDC00-\uDFFF]/),(a,b)=>a+b)]),dp=(0,R.or)([cp,Wk(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var ep=(0,R.then)(cp,(0,R.star)(dp),(a,b)=>a+b.join("")),fp=(0,R.map)(ep,a=>["prefix",a]);const gp=(0,R.or)([cp,Bl]),hp=(0,R.or)([dp,Bl]);(0,R.then)(gp,(0,R.star)(hp),(a,b)=>a+b.join(""));
|
|
339
|
+
const ip=(0,R.map)(ep,a=>[{prefix:"",URI:null},a]),jp=(0,R.then)(ep,(0,R.preceded)(Bl,ep),(a,b)=>[{prefix:a,URI:null},b]);var kp=(0,R.or)([jp,ip]),lp=(0,R.followed)(T([dm,V,fl],(0,R.map)((0,R.star)(Wk(/[^{}]/)),a=>a.join("").replace(/\s+/g," ").trim())),gl);const mp=(0,R.then)(lp,ep,(a,b)=>[a,b]);var np=(0,R.or)([(0,R.map)(mp,a=>[{prefix:null,URI:a[0]},a[1]]),kp]),op=(0,R.or)([(0,R.map)(np,a=>["QName",...a]),(0,R.map)(Dl,()=>["star"])]),pp=(0,R.map)((0,R.preceded)(Fl,np),a=>["varRef",["name",...a]]);var qp=(0,R.peek)((0,R.or)([bl,ll,jl,ap])),rp=(0,R.map)((0,R.or)([mo,no,oo,po,qo,ro,so]),a=>a.substring(0,a.length-2)),sp=(0,R.map)((0,R.or)([to,uo,vo,wo,xo]),a=>a.substring(0,a.length-2)),tp=Rk(Al,(0,R.or)([Fm,Hm,Jm,Km,Lm]),Cl,(a,b,c)=>a+b+c),up=(0,R.or)([Rk(vl,Wk(/[0-9a-fA-F]+/),Cl,(a,b,c)=>a+b+c),Rk(wl,Wk(/[0-9]+/),Cl,(a,b,c)=>a+b+c)]),vp=Vk([ml],'"'),wp=Vk([kl],"'"),xp=Uk(Vk([Mo],"commentTest")),yp=Uk(Vk([No],"textTest")),zp=Uk(Vk([Oo],"namespaceTest")),Ap=Uk(Vk([Po],"anyKindTest"));
|
|
340
|
+
const Bp=Wk(/[0-9]+/),Cp=(0,R.then)((0,R.or)([(0,R.then)(Vl,Bp,(a,b)=>a+b),(0,R.then)(Bp,(0,R.optional)((0,R.preceded)(Vl,Wk(/[0-9]*/))),(a,b)=>a+(null!==b?"."+b:""))]),Rk((0,R.or)([bm,cm]),(0,R.optional)((0,R.or)([Xl,Yl])),Bp,(a,b,c)=>a+(b?b:"")+c),(a,b)=>["doubleConstantExpr",["value",a+b]]),Dp=(0,R.or)([(0,R.map)((0,R.preceded)(Vl,Bp),a=>["decimalConstantExpr",["value","."+a]]),(0,R.then)((0,R.followed)(Bp,Vl),(0,R.optional)(Bp),(a,b)=>["decimalConstantExpr",["value",a+"."+(null!==b?b:"")]])]);
|
|
341
|
+
var Ep=(0,R.map)(Bp,a=>["integerConstantExpr",["value",a]]),Fp=(0,R.followed)((0,R.or)([Cp,Dp,Ep]),(0,R.peek)((0,R.not)(Wk(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),Gp=(0,R.map)((0,R.followed)(Vl,(0,R.peek)((0,R.not)(Vl,["context item should not be followed by another ."]))),()=>["contextItemExpr"]),Hp=(0,R.or)([bn,rm,fn,go,qm,lo,om,Mm,bo,pm,ho,km,gn,io,sm,On,en,zn]),Ip=Uk(Vk([Il],"argumentPlaceholder")),Jp=(0,R.or)([Il,Dl,Xl]),Kp=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/[{}<&]/),
|
|
342
|
+
["elementContentChar cannot be {, }, <, or &"])),Yo),Lp=(0,R.map)((0,R.delimited)(nl,(0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(ol,['CDataSection content may not contain "]]\x3e"'])),Yo)),ol,!0),a=>["CDataSection",a.join("")]),Mp=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),Yo),Np=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),Yo),Op=(0,R.map)((0,R.star)((0,R.or)([(0,R.preceded)((0,R.peek)((0,R.not)(Yl,
|
|
343
|
+
[])),Yo),(0,R.map)(T([Yl,(0,R.peek)((0,R.not)(Yl,[]))],Yo),a=>"-"+a)])),a=>a.join("")),Pp=(0,R.map)((0,R.delimited)(rl,Op,sl,!0),a=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",a]]]]);const Qp=(0,R.filter)(ep,a=>"xml"!==a.toLowerCase(),['A processing instruction target cannot be "xml"']),Rp=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(ul,[])),Yo)),a=>a.join(""));
|
|
344
|
+
var Sp=(0,R.then)((0,R.preceded)(tl,(0,R.cut)(Qp)),(0,R.cut)((0,R.followed)((0,R.optional)((0,R.preceded)(bp,Rp)),ul)),(a,b)=>["computedPIConstructor",["piTarget",a],["piValueExpr",["stringConstantExpr",["value",b]]]]),Tp=(0,R.map)($l,()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]]),Up=(0,R.or)([hn,jn]),Vp=(0,R.map)((0,R.star)((0,R.followed)(Yo,(0,R.peek)((0,R.not)(al,["Pragma contents should not contain '#)'"])))),a=>a.join("")),Wp=(0,R.map)((0,R.followed)((0,R.or)([Dm,Em,Fm,
|
|
345
|
+
Gm,Hm,Im]),qp),a=>a+"Op"),Xp=(0,R.or)([(0,R.followed)(Vk([xm],"isOp"),qp),Vk([Pl],"nodeBeforeOp"),Vk([Sl],"nodeAfterOp")]),Yp=(0,R.or)([Vk([Jl],"equalOp"),Vk([Nl],"notEqualOp"),Vk([Ql],"lessThanOrEqualOp"),Vk([Ol],"lessThanOp"),Vk([Tl],"greaterThanOrEqualOp"),Vk([Rl],"greaterThanOp")]),Zp=(0,R.map)(Rn,()=>["annotation",["annotationName","updating"]]);const $p=(0,R.or)([qn,rn]),aq=(0,R.or)([sn,tn]);
|
|
346
|
+
var bq=(0,R.or)([yo,zo,Ao,Bo,Co,Hl,Do,Eo,Fo,Go,Ho]),cq=(0,R.map)(T([mn,X,on,X],(0,R.or)([qn,pn])),a=>["boundarySpaceDecl",a]),dq=(0,R.map)(T([mn,X,Wn,X],(0,R.or)([qn,pn])),a=>["constructionDecl",a]),eq=(0,R.map)(T([mn,X,Xn,X],(0,R.or)([Yn,Zn])),a=>["orderingModeDecl",a]),fq=(0,R.map)(T([mn,X,nn,X,Zm,X,Qm,X],(0,R.or)([un,vn])),a=>["emptyOrderDecl",a]),gq=(0,R.then)(T([mn,X,wn,X],$p),T([V,Ul,V],aq),(a,b)=>["copyNamespacesDecl",["preserveMode",a],["inheritMode",b]]);function hq(a){switch(a[0]){case "constantExpr":case "varRef":case "contextItemExpr":case "functionCallExpr":case "sequenceExpr":case "elementConstructor":case "computedElementConstructor":case "computedAttributeConstructor":case "computedDocumentConstructor":case "computedTextConstructor":case "computedCommentConstructor":case "computedNamespaceConstructor":case "computedPIConstructor":case "orderedExpr":case "unorderedExpr":case "namedFunctionRef":case "inlineFunctionExpr":case "dynamicFunctionInvocationExpr":case "mapConstructor":case "arrayConstructor":case "stringConstructor":case "unaryLookup":return a}return["sequenceExpr",
|
|
347
|
+
a]}function iq(a){if(!(1<=a&&55295>=a||57344<=a&&65533>=a||65536<=a&&1114111>=a))throw Error("XQST0090: The character reference "+a+" ("+a.toString(16)+") does not reference a valid codePoint.");}
|
|
348
|
+
function jq(a){return a.replace(/(&[^;]+);/g,b=>{if(/^&#x/.test(b))return b=parseInt(b.slice(3,-1),16),iq(b),String.fromCodePoint(b);if(/^&#/.test(b))return b=parseInt(b.slice(2,-1),10),iq(b),String.fromCodePoint(b);switch(b){case "<":return"<";case ">":return">";case "&":return"&";case """:return String.fromCharCode(34);case "'":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: "'+b+'"');})}
|
|
349
|
+
function kq(a,b,c){if(!a.length)return[];let d=[a[0]];for(let e=1;e<a.length;++e){const f=d[d.length-1];"string"===typeof f&&"string"===typeof a[e]?d[d.length-1]=f+a[e]:d.push(a[e])}if("string"===typeof d[0]&&0===d.length)return[];d=d.reduce((e,f,h)=>{if("string"!==typeof f)e.push(f);else if(c&&/^\s*$/.test(f)){const k=d[h+1];k&&"CDataSection"===k[0]?e.push(jq(f)):(h=d[h-1])&&"CDataSection"===h[0]&&e.push(jq(f))}else e.push(jq(f));return e},[]);if(!d.length)return d;if(1<d.length||b)for(a=0;a<d.length;a++)"string"===
|
|
350
|
+
typeof d[a]&&(d[a]=["stringConstantExpr",["value",d[a]]]);return d}function lq(a){return a[0].prefix?a[0].prefix+":"+a[1]:a[1]};var mq=(0,R.then)(np,(0,R.optional)(Il),(a,b)=>null!==b?["singleType",["atomicType",...a],["optional"]]:["singleType",["atomicType",...a]]),nq=(0,R.map)(np,a=>["atomicType",...a]);const oq=new Map;
|
|
351
|
+
function pq(a){function b(m,r){return r.reduce((B,W)=>[W[0],["firstOperand",B],["secondOperand",W[1]]],m)}function c(m,r,B){return(0,R.then)(m,(0,R.star)((0,R.then)(S(r,V),(0,R.cut)(m),(W,ea)=>[W,ea])),B)}function d(m,r,B="firstOperand",W="secondOperand"){return(0,R.then)(m,(0,R.optional)((0,R.then)(S(r,V),(0,R.cut)(m),(ea,Fa)=>[ea,Fa])),(ea,Fa)=>null===Fa?ea:[Fa[0],[B,ea],[W,Fa[1]]])}function e(m){return a.mb?(r,B)=>{r=m(r,B);if(!r.success)return r;const W=n.has(B)?n.get(B):{offset:B,line:-1,ha:-1},
|
|
352
|
+
ea=n.has(r.offset)?n.get(r.offset):{offset:r.offset,line:-1,ha:-1};n.set(B,W);n.set(r.offset,ea);B=r.value.Wa;return(0,R.okWithValue)(r.offset,["x:stackTrace",Object.assign({start:W,end:ea},B?{Wa:B}:{}),r.value])}:m}function f(m,r){return Dj(m,r)}function h(m,r){return xf(m,r)}function k(m,r){return e((0,R.or)([Dr,Er,Fr,Gr,Hr,Ir,Jr,Kr,Lr,Mr,Nr]))(m,r)}function l(m,r){return c(k,Ul,(B,W)=>0===W.length?B:["sequenceExpr",B,...W.map(ea=>ea[1])])(m,r)}const n=new Map,t=(0,R.preceded)(dl,(0,R.followed)(S(l,
|
|
353
|
+
V),el)),u=(0,R.map)(a.Za?(0,R.or)([S((0,R.star)((0,R.or)([tp,up,vp,Wk(/[^"&]/)])),ll),S((0,R.star)((0,R.or)([tp,up,wp,Wk(/[^'&]/)])),jl)]):(0,R.or)([S((0,R.star)((0,R.or)([vp,Wk(/[^"]/)])),ll),S((0,R.star)((0,R.or)([wp,Wk(/[^']/)])),jl)]),m=>m.join("")),z=(0,R.or)([(0,R.map)(T([qm,V],(0,R.delimited)((0,R.followed)(bl,V),(0,R.then)(op,T([V,Ul,V],np),(m,r)=>[["elementName",m],["typeName",...r]]),(0,R.preceded)(V,cl))),([m,r])=>["elementTest",m,r]),(0,R.map)(T([qm,V],(0,R.delimited)(bl,op,cl)),m=>["elementTest",
|
|
354
|
+
["elementName",m]]),(0,R.map)(T([qm,V],(0,R.delimited)(bl,V,cl)),()=>["elementTest"])]),y=(0,R.or)([(0,R.map)(np,m=>["QName",...m]),(0,R.map)(Dl,()=>["star"])]),G=(0,R.or)([(0,R.map)(T([rm,V],(0,R.delimited)((0,R.followed)(bl,V),(0,R.then)(y,T([V,Ul,V],np),(m,r)=>[["attributeName",m],["typeName",...r]]),(0,R.preceded)(V,cl))),([m,r])=>["attributeTest",m,r]),(0,R.map)(T([rm,V],(0,R.delimited)(bl,y,cl)),m=>["attributeTest",["attributeName",m]]),(0,R.map)(T([rm,V],(0,R.delimited)(bl,V,cl)),()=>["attributeTest"])]),
|
|
355
|
+
N=(0,R.map)(T([sm,V,bl],(0,R.followed)(np,cl)),m=>["schemaElementTest",...m]),U=(0,R.map)((0,R.delimited)(Io,S(np,V),cl),m=>["schemaAttributeTest",...m]),ca=(0,R.map)((0,R.preceded)(Jo,(0,R.followed)(S((0,R.optional)((0,R.or)([z,N])),V),cl)),m=>["documentTest",...(m?[m]:[])]),Ga=(0,R.or)([(0,R.map)((0,R.preceded)(Ko,(0,R.followed)(S((0,R.or)([ep,u]),V),cl)),m=>["piTest",["piTarget",m]]),Uk(Vk([Lo],"piTest"))]),Gb=(0,R.or)([ca,z,G,N,U,Ga,xp,yp,zp,Ap]),Xb=(0,R.or)([(0,R.map)((0,R.preceded)(yl,ep),m=>
|
|
356
|
+
["Wildcard",["star"],["NCName",m]]),Uk(Vk([Dl],"Wildcard")),(0,R.map)((0,R.followed)(lp,Dl),m=>["Wildcard",["uri",m],["star"]]),(0,R.map)((0,R.followed)(ep,xl),m=>["Wildcard",["NCName",m],["star"]])]),fd=(0,R.or)([Xb,(0,R.map)(np,m=>["nameTest",...m])]),Yb=(0,R.or)([Gb,fd]),Or=(0,R.then)((0,R.optional)(El),Yb,(m,r)=>null!==m||"attributeTest"===r[0]||"schemaAttributeTest"===r[0]?["stepExpr",["xpathAxis","attribute"],r]:["stepExpr",["xpathAxis","child"],r]),Pr=(0,R.or)([(0,R.then)(rp,Yb,(m,r)=>["stepExpr",
|
|
357
|
+
["xpathAxis",m],r]),Or]),Qr=(0,R.map)(Wl,()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]]),Rr=(0,R.or)([(0,R.then)(sp,Yb,(m,r)=>["stepExpr",["xpathAxis",m],r]),Qr]),Sr=(0,R.map)((0,R.star)((0,R.preceded)(V,t)),m=>0<m.length?["predicates",...m]:void 0),Tr=(0,R.then)((0,R.or)([Rr,Pr]),Sr,(m,r)=>void 0===r?m:m.concat([r])),yf=(0,R.or)([Fp,(0,R.map)(u,m=>["stringConstantExpr",["value",a.Za?jq(m):m]])]),zf=(0,R.or)([(0,R.delimited)(bl,S(l,V),cl),(0,R.map)((0,R.delimited)(bl,V,cl),()=>["sequenceExpr"])]),
|
|
358
|
+
Ej=(0,R.or)([k,Ip]),de=(0,R.map)((0,R.delimited)(bl,S((0,R.optional)((0,R.then)(Ej,(0,R.star)((0,R.preceded)(S(Ul,V),Ej)),(m,r)=>[m,...r])),V),cl),m=>null!==m?m:[]),Ur=(0,R.preceded)((0,R.not)(Rk(Hp,V,bl,()=>{}),["cannot use reserved keyword for function names"]),e((0,R.then)(np,(0,R.preceded)(V,de),(m,r)=>{r=["functionCallExpr",["functionName",...m],null!==r?["arguments",...r]:["arguments"]];const B=m[0].prefix,W=m[0].URI;m=m[1];r.Wa=B?`${B}:${m}`:W?`Q{${W}}${m}`:m;return r}))),Vr=(0,R.then)(np,
|
|
359
|
+
(0,R.preceded)(Gl,Ep),(m,r)=>["namedFunctionRef",["functionName",...m],r]),Ua=(0,R.delimited)(fl,S((0,R.optional)(l),V),gl),Fj=(0,R.map)(Ua,m=>m?m:["sequenceExpr"]),jb=(0,R.or)([(0,R.map)(Ro,()=>[["voidSequenceType"]]),(0,R.then)(f,(0,R.optional)((0,R.preceded)(V,Jp)),(m,r)=>[m,...(null!==r?[["occurrenceIndicator",r]]:[])])]),Af=(0,R.then)(T([Hl,V],np),(0,R.optional)((0,R.followed)((0,R.then)(T([bl,V],yf),(0,R.star)(T([Ul,V],yf)),(m,r)=>m.concat(r)),cl)),(m,r)=>["annotation",["annotationName",...m],
|
|
360
|
+
...(r?["arguments",r]:[])]),Wr=(0,R.map)(T([om,V,bl,V,Dl,V],cl),()=>["anyFunctionTest"]),Xr=(0,R.then)(T([om,V,bl,V],(0,R.optional)(c(jb,Ul,(m,r)=>m.concat.apply(m,r.map(B=>B[1]))))),T([V,cl,X,em,X],jb),(m,r)=>["typedFunctionTest",["paramTypeList",["sequenceType",...(m?m:[])]],["sequenceType",...r]]),Yr=(0,R.then)((0,R.star)(Af),(0,R.or)([Wr,Xr]),(m,r)=>[r[0],...m,...r.slice(1)]),Zr=(0,R.map)(T([pm,V,bl,V,Dl,V],cl),()=>["anyMapTest"]),$r=(0,R.then)(T([pm,V,bl,V],nq),T([V,Ul],(0,R.followed)(S(jb,V),
|
|
361
|
+
cl)),(m,r)=>["typedMapTest",m,["sequenceType",...r]]),as=(0,R.or)([Zr,$r]),bs=(0,R.map)(T([bn,V,bl,V,Dl,V],cl),()=>["anyArrayTest"]),cs=(0,R.map)(T([bn,V,bl],(0,R.followed)(S(jb,V),cl)),m=>["typedArrayTest",["sequenceType",...m]]),ds=(0,R.or)([bs,cs]),es=(0,R.map)((0,R.delimited)(bl,S(f,V),cl),m=>["parenthesizedItemType",m]),Dj=(0,R.or)([Gb,Uk(Vk([Qo],"anyItemType")),Yr,as,ds,nq,es]),Ac=(0,R.map)(T([em,X],jb),m=>["typeDeclaration",...m]),fs=(0,R.then)((0,R.preceded)(Fl,np),(0,R.optional)((0,R.preceded)(X,
|
|
362
|
+
Ac)),(m,r)=>["param",["varName",...m],...(r?[r]:[])]),Gj=c(fs,Ul,(m,r)=>[m,...r.map(B=>B[1])]),gs=Sk((0,R.star)(Af),T([V,om,V,bl,V],(0,R.optional)(Gj)),T([V,cl,V],(0,R.optional)((0,R.map)(T([em,V],(0,R.followed)(jb,V)),m=>["typeDeclaration",...m]))),Fj,(m,r,B,W)=>["inlineFunctionExpr",...m,["paramList",...(r?r:[])],...(B?[B]:[]),["functionBody",W]]),hs=(0,R.or)([Vr,gs]),is=(0,R.map)(k,m=>["mapKeyExpr",m]),js=(0,R.map)(k,m=>["mapValueExpr",m]),ks=(0,R.then)(is,(0,R.preceded)(S(Bl,V),js),(m,r)=>["mapConstructorEntry",
|
|
363
|
+
m,r]),ls=(0,R.preceded)(pm,(0,R.delimited)(S(fl,V),(0,R.map)((0,R.optional)(c(ks,S(Ul,V),(m,r)=>[m,...r.map(B=>B[1])])),m=>m?["mapConstructor",...m]:["mapConstructor"]),(0,R.preceded)(V,gl))),ms=(0,R.map)((0,R.delimited)(dl,S((0,R.optional)(c(k,Ul,(m,r)=>[m,...r.map(B=>B[1])].map(B=>["arrayElem",B]))),V),el),m=>["squareArray",...(null!==m?m:[])]),ns=(0,R.map)((0,R.preceded)(bn,(0,R.preceded)(V,Ua)),m=>["curlyArray",...(null!==m?[["arrayElem",m]]:[])]),os=(0,R.map)((0,R.or)([ms,ns]),m=>["arrayConstructor",
|
|
364
|
+
m]),Hj=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([Uo,Vo,To]),["String constructors can not contain interpolation characters"])),Yo)),m=>["stringConstructorChars",m.join("")]),ps=(0,R.map)((0,R.delimited)(Uo,l,Vo,!0),m=>["stringConstructorInterpolation",m]),qs=(0,R.then)(Hj,(0,R.star)((0,R.then)(ps,Hj,(m,r)=>[m,r])),(m,r)=>{m=[m];for(const [B,W]of r)m.push(B,W);return m}),rs=(0,R.map)((0,R.delimited)(So,qs,To,!0),m=>["stringConstructor",...m]),Ij=(0,R.or)([ep,Ep,zf,Dl]),ss=
|
|
365
|
+
(0,R.map)((0,R.preceded)(Il,(0,R.preceded)(V,Ij)),m=>"*"===m?["unaryLookup",["star"]]:"string"===typeof m?["unaryLookup",["NCName",m]]:["unaryLookup",m]),Bf=(0,R.or)([tp,up,Vk([hl],"{"),Vk([il],"}"),(0,R.map)(Ua,m=>m||["sequenceExpr"])]),ts=(0,R.or)([Lp,function(m,r){return Jj(m,r)},Bf,Kp]),us=(0,R.or)([(0,R.map)(Mp,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Bf]),vs=(0,R.or)([(0,R.map)(Np,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Bf]),ws=(0,R.map)((0,R.or)([S((0,R.star)((0,R.or)([vp,us])),ll),S((0,R.star)((0,R.or)([wp,
|
|
366
|
+
vs])),jl)]),m=>kq(m,!1,!1)),xs=(0,R.then)(kp,(0,R.preceded)(S(Jl,(0,R.optional)(bp)),ws),(m,r)=>{if(""===m[0].prefix&&"xmlns"===m[1]){if(r.length&&"string"!==typeof r[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",r.length?["uri",r[0]]:["uri"]]}if("xmlns"===m[0].prefix){if(r.length&&"string"!==typeof r[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+m[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",
|
|
367
|
+
["prefix",m[1]],r.length?["uri",r[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(m),0===r.length?["attributeValue"]:1===r.length&&"string"===typeof r[0]?["attributeValue",r[0]]:["attributeValueExpr"].concat(r)]}),ys=(0,R.map)((0,R.star)((0,R.preceded)(bp,(0,R.optional)(xs))),m=>m.filter(Boolean)),zs=Rk((0,R.preceded)(Ol,kp),ys,(0,R.or)([(0,R.map)(pl,()=>null),(0,R.then)((0,R.preceded)(Rl,(0,R.star)(ts)),T([V,ql],(0,R.followed)(kp,(0,R.then)((0,R.optional)(bp),Rl,()=>null))),(m,
|
|
368
|
+
r)=>[kq(m,!0,!0),r])]),(m,r,B)=>{var W=B;if(B&&B.length){W=lq(m);const ea=lq(B[1]);if(W!==ea)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+W+'" does not match "'+ea+'"');W=B[0]}return["elementConstructor",["tagName",...m],...(r.length?[["attributeList",...r]]:[]),...(W&&W.length?[["elementContent",...W]]:[])]}),Jj=(0,R.or)([zs,Pp,Sp]),As=(0,R.map)(T([cn,V],Ua),m=>["computedDocumentConstructor",...(m?[["argExpr",m]]:[])]),Bs=(0,R.map)(Ua,m=>m?[["contentExpr",
|
|
369
|
+
m]]:[]),Cs=(0,R.then)(T([qm,V],(0,R.or)([(0,R.map)(np,m=>["tagName",...m]),(0,R.map)((0,R.delimited)(fl,S(l,V),gl),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Bs),(m,r)=>["computedElementConstructor",m,...r]),Ds=(0,R.then)((0,R.preceded)(rm,(0,R.or)([(0,R.map)(T([qp,V],np),m=>["tagName",...m]),(0,R.map)((0,R.preceded)(V,(0,R.delimited)(fl,S(l,V),gl)),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Ua),(m,r)=>["computedAttributeConstructor",m,["valueExpr",r?r:["sequenceExpr"]]]),Es=(0,R.map)(Ua,m=>m?[["prefixExpr",
|
|
370
|
+
m]]:[]),Fs=(0,R.map)(Ua,m=>m?[["URIExpr",m]]:[]),Gs=(0,R.then)(T([dn,V],(0,R.or)([fp,Es])),(0,R.preceded)(V,Fs),(m,r)=>["computedNamespaceConstructor",...m,...r]),Hs=(0,R.map)(T([en,V],Ua),m=>["computedTextConstructor",...(m?[["argExpr",m]]:[])]),Is=(0,R.map)(T([fn,V],Ua),m=>["computedCommentConstructor",...(m?[["argExpr",m]]:[])]),Js=T([gn,V],(0,R.then)((0,R.or)([(0,R.map)(ep,m=>["piTarget",m]),(0,R.map)((0,R.delimited)(fl,S(l,V),gl),m=>["piTargetExpr",m])]),(0,R.preceded)(V,Ua),(m,r)=>["computedPIConstructor",
|
|
371
|
+
m,...(r?[["piValueExpr",r]]:[])])),Ks=(0,R.or)([As,Cs,Ds,Gs,Hs,Is,Js]),Ls=(0,R.or)([Jj,Ks]),Kj=(0,R.or)([yf,pp,zf,Gp,Ur,Ls,hs,ls,os,rs,ss]),Lj=(0,R.map)(T([Il,V],Ij),m=>"*"===m?["lookup",["star"]]:"string"===typeof m?["lookup",["NCName",m]]:["lookup",m]),Ms=(0,R.then)((0,R.map)(Kj,m=>hq(m)),(0,R.star)((0,R.or)([(0,R.map)((0,R.preceded)(V,t),m=>["predicate",m]),(0,R.map)((0,R.preceded)(V,de),m=>["argumentList",m]),(0,R.preceded)(V,Lj)])),(m,r)=>{function B(){Mj&&1===Fa.length?Bc.push(["predicate",
|
|
372
|
+
Fa[0]]):0!==Fa.length&&Bc.push(["predicates",...Fa]);Fa.length=0}function W(Zb){B();0!==Bc.length?("sequenceExpr"===ea[0][0]&&2<ea[0].length&&(ea=[["sequenceExpr",...ea]]),ea=[["filterExpr",...ea],...Bc],Bc.length=0):Zb&&(ea=[["filterExpr",...ea]])}let ea=[m];const Fa=[],Bc=[];let Mj=!1;for(const Zb of r)switch(Zb[0]){case "predicate":Fa.push(Zb[1]);break;case "lookup":Mj=!0;B();Bc.push(Zb);break;case "argumentList":W(!1);1<ea.length&&(ea=[["sequenceExpr",["pathExpr",["stepExpr",...ea]]]]);ea=[["dynamicFunctionInvocationExpr",
|
|
373
|
+
["functionItem",...ea],...(Zb[1].length?[["arguments",...Zb[1]]]:[])]];break;default:throw Error("unreachable");}W(!0);return ea}),Cc=(0,R.or)([(0,R.map)(Ms,m=>["stepExpr",...m]),Tr]),Ns=(0,R.followed)(Kj,(0,R.peek)((0,R.not)((0,R.preceded)(V,(0,R.or)([t,de,Lj])),["primary expression not followed by predicate, argumentList, or lookup"]))),Os=(0,R.or)([Rk(Cc,(0,R.preceded)(V,Tp),(0,R.preceded)(V,h),(m,r,B)=>["pathExpr",m,r,...B]),(0,R.then)(Cc,(0,R.preceded)(S(Zl,V),h),(m,r)=>["pathExpr",m,...r]),
|
|
374
|
+
Ns,(0,R.map)(Cc,m=>["pathExpr",m])]),xf=(0,R.or)([Rk(Cc,(0,R.preceded)(V,Tp),(0,R.preceded)(V,h),(m,r,B)=>[m,r,...B]),(0,R.then)(Cc,(0,R.preceded)(S(Zl,V),h),(m,r)=>[m,...r]),(0,R.map)(Cc,m=>[m])]),Ps=(0,R.or)([(0,R.map)(T([Zl,V],xf),m=>["pathExpr",["rootExpr"],...m]),(0,R.then)(Tp,(0,R.preceded)(V,xf),(m,r)=>["pathExpr",["rootExpr"],m,...r]),(0,R.map)((0,R.followed)(Zl,(0,R.not)((0,R.preceded)(V,a.Za?Wk(/[*<a-zA-Z]/):Wk(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),
|
|
375
|
+
()=>["pathExpr",["rootExpr"]])]),Qs=Qk((0,R.or)([Os,Ps]),oq),Rs=(0,R.preceded)(kn,(0,R.then)((0,R.optional)((0,R.or)([(0,R.map)((0,R.preceded)(V,Up),m=>["validationMode",m]),(0,R.map)(T([V,ln,V],np),m=>["type",...m])])),(0,R.delimited)((0,R.preceded)(V,fl),S(l,V),gl),(m,r)=>["validateExpr",...(m?[m]:[]),["argExpr",r]])),Ss=(0,R.delimited)($k,(0,R.then)((0,R.preceded)(V,np),(0,R.optional)((0,R.preceded)(X,Vp)),(m,r)=>r?["pragma",["pragmaName",m],["pragmaContents",r]]:["pragma",["pragmaName",m]]),(0,R.preceded)(V,
|
|
376
|
+
al)),Ts=(0,R.map)((0,R.followed)((0,R.plus)(Ss),(0,R.preceded)(V,(0,R.delimited)(fl,S((0,R.optional)(l),V),gl))),m=>["extensionExpr",...m]),Us=e(c(Qs,Kl,(m,r)=>0===r.length?m:["simpleMapExpr","pathExpr"===m[0]?m:["pathExpr",["stepExpr",["filterExpr",hq(m)]]]].concat(r.map(B=>{B=B[1];return"pathExpr"===B[0]?B:["pathExpr",["stepExpr",["filterExpr",hq(B)]]]})))),Vs=(0,R.or)([Rs,Ts,Us]),Nj=(0,R.or)([(0,R.then)((0,R.or)([Vk([Yl],"unaryMinusOp"),Vk([Xl],"unaryPlusOp")]),(0,R.preceded)(V,function(m,r){return Nj(m,
|
|
377
|
+
r)}),(m,r)=>[m,["operand",r]]),Vs]),Ws=(0,R.or)([(0,R.map)(np,m=>["EQName",...m]),pp,zf]),Xs=(0,R.then)(Nj,(0,R.star)(T([V,am,V],(0,R.then)(Ws,(0,R.preceded)(V,de),(m,r)=>[m,r]))),(m,r)=>r.reduce((B,W)=>["arrowExpr",["argExpr",B],W[0],["arguments",...W[1]]],m)),Ys=(0,R.then)(Xs,(0,R.optional)(T([V,fm,X,em,qp,V],mq)),(m,r)=>null!==r?["castExpr",["argExpr",m],r]:m),Zs=(0,R.then)(Ys,(0,R.optional)(T([V,gm,X,em,qp,V],mq)),(m,r)=>null!==r?["castableExpr",["argExpr",m],r]:m),$s=(0,R.then)(Zs,(0,R.optional)(T([V,
|
|
378
|
+
hm,X,em,qp,V],jb)),(m,r)=>null!==r?["treatExpr",["argExpr",m],["sequenceType",...r]]:m),at=(0,R.then)($s,(0,R.optional)(T([V,im,X,jm,qp,V],jb)),(m,r)=>null!==r?["instanceOfExpr",["argExpr",m],["sequenceType",...r]]:m),bt=c(at,(0,R.followed)((0,R.or)([Vk([tm],"intersectOp"),Vk([um],"exceptOp")]),qp),b),ct=c(bt,(0,R.or)([Vk([Ll],"unionOp"),(0,R.followed)(Vk([vm],"unionOp"),qp)]),b),dt=c(ct,(0,R.or)([Vk([Dl],"multiplyOp"),(0,R.followed)(Vk([Am],"divOp"),qp),(0,R.followed)(Vk([Bm],"idivOp"),qp),(0,R.followed)(Vk([Cm],
|
|
379
|
+
"modOp"),qp)]),b),et=c(dt,(0,R.or)([Vk([Yl],"subtractOp"),Vk([Xl],"addOp")]),b),ft=d(et,(0,R.followed)(Vk([wm],"rangeSequenceExpr"),qp),"startExpr","endExpr"),gt=c(ft,Vk([Ml],"stringConcatenateOp"),b),ht=d(gt,(0,R.or)([Wp,Xp,Yp])),it=c(ht,(0,R.followed)(Vk([zm],"andOp"),qp),b),Nr=c(it,(0,R.followed)(Vk([ym],"orOp"),qp),b),jt=e((0,R.map)(l,m=>["ifClause",m])),kt=e((0,R.map)(k,m=>["thenClause",m])),lt=e((0,R.map)(k,m=>["elseClause",m])),Hr=(0,R.then)((0,R.then)(T([Mm,V,bl,V],jt),T([V,cl,V,Nm,qp,V],
|
|
380
|
+
kt),(m,r)=>[m,r]),T([V,Om,qp,V],lt),(m,r)=>["ifThenElseExpr",m[0],m[1],r]),mt=(0,R.delimited)(Pm,X,Qm),nt=(0,R.map)(T([Rm,X,Fl],np),m=>["positionalVariableBinding",...m]),ot=Tk((0,R.preceded)(Fl,(0,R.cut)(np)),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(Ac))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(mt))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(nt))),(0,R.cut)((0,R.preceded)(S(Sm,V),k)),(m,r,B,W,ea)=>["forClauseItem",["typedVariableBinding",["varName",...m,...(r?[r]:[])]],...(B?[["allowingEmpty"]]:
|
|
381
|
+
[]),...(W?[W]:[]),["forExpr",ea]]),pt=T([Tm,X],c(ot,Ul,(m,r)=>["forClause",m,...r.map(B=>B[1])])),qt=Rk((0,R.preceded)(Fl,np),(0,R.preceded)(V,(0,R.optional)(Ac)),(0,R.preceded)(S(zl,V),k),(m,r,B)=>["letClauseItem",["typedVariableBinding",["varName",...m],...(r?[r]:[])],["letExpr",B]]),rt=(0,R.map)(T([Um,V],c(qt,Ul,(m,r)=>[m,...r.map(B=>B[1])])),m=>["letClause",...m]),Oj=(0,R.or)([pt,rt]),st=(0,R.map)(T([Vm,qp,V],k),m=>["whereClause",m]),tt=(0,R.map)((0,R.preceded)(Fl,np),m=>["varName",...m]),ut=
|
|
382
|
+
(0,R.then)((0,R.preceded)(V,(0,R.optional)(Ac)),(0,R.preceded)(S(zl,V),k),(m,r)=>["groupVarInitialize",...(m?[["typeDeclaration",...m]]:[]),["varValue",r]]),vt=Rk(tt,(0,R.optional)(ut),(0,R.optional)((0,R.map)((0,R.preceded)(S(Wm,V),u),m=>["collation",m])),(m,r,B)=>["groupingSpec",m,...(r?[r]:[]),...(B?[B]:[])]),wt=c(vt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),xt=(0,R.map)(T([Xm,X,Ym,V],wt),m=>["groupByClause",...m]),yt=Rk((0,R.optional)((0,R.or)([jo,ko])),(0,R.optional)(T([V,Qm,V],(0,R.or)([un,vn].map(m=>
|
|
383
|
+
(0,R.map)(m,r=>"empty "+r))))),(0,R.preceded)(V,(0,R.optional)(T([Wm,V],u))),(m,r,B)=>m||r||B?["orderModifier",...(m?[["orderingKind",m]]:[]),...(r?[["emptyOrderingMode",r]]:[]),...(B?[["collation",B]]:[])]:null),zt=(0,R.then)(k,(0,R.preceded)(V,yt),(m,r)=>["orderBySpec",["orderByExpr",m],...(r?[r]:[])]),At=c(zt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),Bt=(0,R.then)((0,R.or)([(0,R.map)(T([Zm,X],Ym),()=>!1),(0,R.map)(T([$m,X,Zm,X],Ym),()=>!0)]),(0,R.preceded)(V,At),(m,r)=>["orderByClause",...(m?[["stable"]]:
|
|
384
|
+
[]),...r]),Ct=(0,R.or)([Oj,st,xt,Bt]),Dt=(0,R.map)(T([an,V],k),m=>["returnClause",m]),Dr=Rk(Oj,(0,R.cut)((0,R.star)((0,R.preceded)(V,Ct))),(0,R.cut)((0,R.preceded)(V,Dt)),(m,r,B)=>["flworExpr",m,...r,B]),Et=c(jb,Ll,(m,r)=>0===r.length?["sequenceType",...m]:["sequenceTypeUnion",["sequenceType",...m],...r.map(B=>["sequenceType",...B[1]])]),Ft=Rk(T([yn,V],(0,R.optional)((0,R.preceded)(Fl,(0,R.followed)((0,R.followed)(np,X),em)))),(0,R.preceded)(V,Et),T([X,an,X],k),(m,r,B)=>["typeswitchExprCaseClause"].concat(m?
|
|
385
|
+
[["variableBinding",...m]]:[],[r],[["resultExpr",B]])),Gr=Sk((0,R.preceded)(zn,S((0,R.delimited)(bl,S(l,V),cl),V)),(0,R.plus)((0,R.followed)(Ft,V)),T([nn,X],(0,R.optional)((0,R.preceded)(Fl,(0,R.followed)(np,X)))),T([an,X],k),(m,r,B,W)=>["typeswitchExpr",["argExpr",m],...r,["typeswitchExprDefaultClause",...(B||[]),["resultExpr",W]]]),Gt=Rk((0,R.preceded)(Fl,np),(0,R.optional)((0,R.preceded)(X,Ac)),(0,R.preceded)(S(Sm,X),k),(m,r,B)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...m],
|
|
386
|
+
...(r?[r]:[])],["sourceExpr",B]]),Ht=c(Gt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),Er=Rk((0,R.or)([An,Bn]),(0,R.preceded)(X,Ht),(0,R.preceded)(S(Cn,V),k),(m,r,B)=>["quantifiedExpr",["quantifier",m],...r,["predicateExpr",B]]),Jr=(0,R.map)(T([mm,X,(0,R.or)([lm,km]),X],k),m=>["deleteExpr",["targetExpr",m]]),Lr=Rk(T([Dn,X],(0,R.optional)(T([nm,X,jm],X))),T([km,X],k),(0,R.preceded)(S(En,X),k),(m,r,B)=>m?["replaceExpr",["replaceValue"],["targetExpr",r],["replacementExpr",B]]:["replaceExpr",["targetExpr",r],["replacementExpr",
|
|
387
|
+
B]]),It=(0,R.then)(pp,(0,R.preceded)(S(zl,V),k),(m,r)=>["transformCopy",m,["copySource",r]]),Mr=Rk(T([Fn,X],c(It,Ul,(m,r)=>[m,...r.map(B=>B[1])])),T([V,Gn,X],k),(0,R.preceded)(S(an,X),k),(m,r,B)=>["transformExpr",["transformCopies",...m],["modifyExpr",r],["returnExpr",B]]),Jt=(0,R.or)([(0,R.followed)((0,R.map)((0,R.optional)((0,R.followed)(T([em,X],(0,R.or)([(0,R.map)(Hn,()=>["insertAsFirst"]),(0,R.map)(In,()=>["insertAsLast"])])),X)),m=>m?["insertInto",m]:["insertInto"]),Ln),(0,R.map)(Kn,()=>["insertAfter"]),
|
|
388
|
+
(0,R.map)(Jn,()=>["insertBefore"])]),Ir=Rk(T([Mn,X,(0,R.or)([lm,km]),X],k),(0,R.preceded)(X,Jt),(0,R.preceded)(X,k),(m,r,B)=>["insertExpr",["sourceExpr",m],r,["targetExpr",B]]),Kr=(0,R.then)(T([Nn,X,km,V],k),T([X,em,X],k),(m,r)=>["renameExpr",["targetExpr",m],["newNameExpr",r]]),Kt=(0,R.then)((0,R.plus)((0,R.then)((0,R.map)(T([yn,X],(0,R.cut)(k)),m=>["switchCaseExpr",m]),(0,R.cut)(X),m=>m)),(0,R.cut)(T([an,X],(0,R.cut)(k))),(m,r)=>["switchExprCaseClause",...m,["resultExpr",r]]),Fr=Rk(T([On,V,bl],
|
|
389
|
+
(0,R.cut)(l)),(0,R.cut)(T([V,cl,(0,R.cut)(V)],(0,R.plus)((0,R.followed)(Kt,V)))),(0,R.cut)(T([nn,X,an,X],k)),(m,r,B)=>["switchExpr",["argExpr",m],...r,["switchExprDefaultClause",["resultExpr",B]]]),Lt=(0,R.map)(l,m=>["queryBody",m]),Mt=T([mn,X,dn,X],(0,R.cut)((0,R.then)(ep,(0,R.preceded)(S(Jl,V),u),(m,r)=>["namespaceDecl",["prefix",m],["uri",r]]))),Nt=(0,R.then)(T([Pn,X,Fl,V],(0,R.then)(np,(0,R.optional)((0,R.preceded)(V,Ac)),(m,r)=>[m,r])),(0,R.cut)((0,R.or)([(0,R.map)(T([V,zl,V],k),m=>["varValue",
|
|
390
|
+
m]),(0,R.map)(T([X,Qn],(0,R.optional)(T([V,zl,V],k))),m=>["external",...(m?[["varValue",m]]:[])])])),([m,r],B)=>["varDecl",["varName",...m],...(null!==r?[r]:[]),B]),Ot=Sk(T([om,X,(0,R.cut)((0,R.peek)((0,R.not)((0,R.followed)(Hp,(0,R.not)(Bl,[""])),["Cannot use reserved function name"])))],np),(0,R.cut)(T([V,bl,V],(0,R.optional)(Gj))),(0,R.cut)(T([V,cl],(0,R.optional)(T([X,em,X],jb)))),(0,R.cut)((0,R.preceded)(V,(0,R.or)([(0,R.map)(Fj,m=>["functionBody",m]),(0,R.map)(Qn,()=>["externalDefinition"])]))),
|
|
391
|
+
(m,r,B,W)=>["functionDecl",["functionName",...m],["paramList",...(r||[])],...(B?[["typeDeclaration",...B]]:[]),W]),Pt=T([mn,X],(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Af,Zp]),X)),(0,R.or)([Nt,Ot]),(m,r)=>[r[0],...m,...r.slice(1)])),Qt=(0,R.then)(T([mn,X,nn,X],(0,R.or)([qm,om])),T([X,dn,X],u),(m,r)=>["defaultNamespaceDecl",["defaultNamespaceCategory",m],["uri",r]]),Rt=(0,R.or)([(0,R.map)((0,R.followed)(T([dn,X],ep),(0,R.preceded)(V,Jl)),m=>["namespacePrefix",m]),(0,R.map)(T([nn,X,qm,X],dn),
|
|
392
|
+
()=>["defaultElementNamespace"])]),St=T([Sn,X,Tn],Rk((0,R.optional)((0,R.preceded)(X,Rt)),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([X,Rm,X],u),(0,R.star)(T([V,Ul,V],u)),(m,r)=>[m,...r])),(m,r,B)=>["schemaImport",...(m?[m]:[]),["targetNamespace",r],...(B?[B]:[])])),Tt=T([Sn,X,Un],Rk((0,R.optional)((0,R.followed)(T([X,dn,X],ep),(0,R.preceded)(V,Jl))),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([X,Rm,X],u),(0,R.star)(T([V,Ul,V],u)),(m,r)=>[m,...r])),(m,r)=>["moduleImport",["namespacePrefix",
|
|
393
|
+
m],["targetNamespace",r]])),Ut=(0,R.or)([St,Tt]),Vt=(0,R.map)(T([mn,X,nn,X,Wm,X],u),m=>["defaultCollationDecl",m]),Wt=(0,R.map)(T([mn,X,Vn,X],u),m=>["baseUriDecl",m]),Xt=(0,R.then)(T([mn,X],(0,R.or)([(0,R.map)(T([xn,X],np),m=>["decimalFormatName",...m]),(0,R.map)(T([nn,X],xn),()=>null)])),(0,R.star)((0,R.then)((0,R.preceded)(X,bq),(0,R.preceded)(S(Jl,X),u),(m,r)=>["decimalFormatParam",["decimalFormatParamName",m],["decimalFormatParamValue",r]])),(m,r)=>["decimalFormatDecl",...(m?[m]:[]),...r]),Yt=
|
|
394
|
+
(0,R.or)([cq,Vt,Wt,dq,eq,fq,gq,Xt]),Zt=(0,R.then)(T([mn,X,$n,X],np),(0,R.preceded)(X,u),(m,r)=>["optionDecl",["optionName",m],["optionContents",r]]),$t=(0,R.then)(T([mn,X,ao,X,bo],(0,R.optional)(T([X,em],Dj))),(0,R.or)([(0,R.map)((0,R.preceded)(S(zl,V),k),m=>["varValue",m]),(0,R.map)(T([X,Qn],(0,R.optional)((0,R.preceded)(S(zl,V),k))),()=>["external"])]),(m,r)=>["contextItemDecl",...(m?[["contextItemType",m]]:[]),r]),Pj=(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Qt,Yt,Mt,Ut]),(0,R.cut)(S(Cl,V)))),
|
|
395
|
+
(0,R.star)((0,R.followed)((0,R.or)([$t,Pt,Zt]),(0,R.cut)(S(Cl,V)))),(m,r)=>0===m.length&&0===r.length?null:["prolog",...m,...r]),au=T([Un,X,dn,X],(0,R.then)((0,R.followed)(ep,S(Jl,V)),(0,R.followed)(u,S(Cl,V)),(m,r)=>["moduleDecl",["prefix",m],["uri",r]])),bu=(0,R.then)(au,(0,R.preceded)(V,Pj),(m,r)=>["libraryModule",m,...(r?[r]:[])]),cu=(0,R.then)(Pj,(0,R.preceded)(V,Lt),(m,r)=>["mainModule",...(m?[m]:[]),r]),du=(0,R.map)(T([co,V],(0,R.followed)((0,R.or)([(0,R.then)((0,R.preceded)(fo,X),u,m=>["encoding",
|
|
396
|
+
m]),(0,R.then)(T([eo,X],u),(0,R.optional)(T([X,fo,X],u)),(m,r)=>[["version",m],...(r?[["encoding",r]]:[])])]),(0,R.preceded)(V,Cl))),m=>["versionDecl",...m]),eu=(0,R.then)((0,R.optional)(S(du,V)),(0,R.or)([bu,cu]),(m,r)=>["module",...(m?[m]:[]),r]),fu=(0,R.complete)(S(eu,V));return(m,r)=>{n.clear();r=fu(m,r);let B=1,W=1;for(let ea=0;ea<m.length+1;ea++){if(n.has(ea)){const Fa=n.get(ea);Fa.line=W;Fa.ha=B}"\n"===m[ea]?(W++,B=1):B++}return r}}
|
|
397
|
+
const qq=pq({mb:!1,Za:!1}),rq=pq({mb:!0,Za:!1}),sq=pq({mb:!1,Za:!0}),tq=pq({mb:!0,Za:!0});function uq(a,b){var c=!!b.Z;b=!!b.debug;Wo.clear();Xo.clear();oq.clear();c=c?b?tq(a,0):sq(a,0):b?rq(a,0):qq(a,0);if(!0===c.success)return c.value;a=a.substring(0,c.offset).split("\n");b=a[a.length-1].length+1;throw new Qh({start:{offset:c.offset,line:a.length,ha:b},end:{offset:c.offset+1,line:a.length,ha:b+1}},"","",Error(`XPST0003: Failed to parse script. Expected ${[...(new Set(c.expected))]}`));};const vq="http://www.w3.org/XML/1998/namespace http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2005/xpath-functions http://www.w3.org/2005/xpath-functions/math http://www.w3.org/2012/xquery http://www.w3.org/2005/xpath-functions/array http://www.w3.org/2005/xpath-functions/map".split(" ");
|
|
398
|
+
function wq(a,b,c,d,e){var f=F(a,"functionName"),h=I(f,"prefix")||"";let k=I(f,"URI");const l=H(f);if(null===k&&(k=""===h?null===b.v?"http://www.w3.org/2005/xpath-functions":b.v:b.$(h),!k&&h))throw yg(h);if(vq.includes(k))throw sg();h=K(a,"annotation").map(y=>F(y,"annotationName"));f=h.every(y=>!I(y,"URI")&&"private"!==H(y));h=h.some(y=>!I(y,"URI")&&"updating"===H(y));if(!k)throw ug();const n=Kg(a),t=K(F(a,"paramList"),"param"),u=t.map(y=>F(y,"varName")),z=t.map(y=>Kg(y));if(a=F(a,"functionBody")){if(b.va(k,
|
|
399
|
+
l,z.length))throw tg(k,l);if(!e)return;const y=Fk(a[1],{sa:!1,Z:!0}),G=new Bg(b),N=u.map(U=>{let ca=I(U,"URI");const Ga=I(U,"prefix");U=H(U);Ga&&null===ca&&(ca=b.$(Ga||""));return Gg(G,ca,U)});e=h?{j:z,arity:u.length,callFunction:(U,ca,Ga,...Gb)=>{U=hc(bc(U,-1,null,w.empty()),N.reduce((Xb,fd,Yb)=>{Xb[fd]=Ra(Gb[Yb]);return Xb},Object.create(null)));return y.s(U,ca)},wb:!1,I:!0,cb:f,localName:l,namespaceURI:k,i:n}:{j:z,arity:u.length,callFunction:(U,ca,Ga,...Gb)=>{U=hc(bc(U,-1,null,w.empty()),N.reduce((Xb,
|
|
400
|
+
fd,Yb)=>{Xb[fd]=Ra(Gb[Yb]);return Xb},Object.create(null)));return C(y,U,ca)},wb:!1,I:!1,cb:f,localName:l,namespaceURI:k,i:n};c.push({ba:y,Eb:G});d.push({arity:u.length,ba:y,Ab:e,localName:l,namespaceURI:k,cb:f})}else{if(h)throw Error("Updating external function declarations are not supported");e={j:z,arity:u.length,callFunction:(y,G,N,...U)=>{const ca=N.va(k,l,u.length,!0);if(!ca)throw Error(`XPST0017: Function Q{${k}}${l} with arity of ${u.length} not registered. ${lg(l)}`);if(ca.i.type!==n.type||
|
|
401
|
+
ca.j.some((Ga,Gb)=>Ga.type!==z[Gb].type))throw Error("External function declaration types do not match actual function");return ca.callFunction(y,G,N,...U)},wb:!0,I:!1,localName:l,namespaceURI:k,cb:f,i:n}}Eg(b,k,l,u.length,e)}
|
|
402
|
+
function xq(a,b,c,d){const e=[],f=[];K(a,"*").forEach(t=>{switch(t[0]){case "moduleImport":case "namespaceDecl":case "defaultNamespaceDecl":case "functionDecl":case "varDecl":break;default:throw Error("Not implemented: only module imports, namespace declarations, and function declarations are implemented in XQuery modules");}});const h=new Set;K(a,"moduleImport").forEach(t=>{const u=H(F(t,"namespacePrefix"));t=H(F(t,"targetNamespace"));if(h.has(t))throw Error(`XQST0047: The namespace "${t}" is imported more than once.`);
|
|
403
|
+
h.add(t);Fg(b,u,t)});K(a,"namespaceDecl").forEach(t=>{const u=H(F(t,"prefix"));t=H(F(t,"uri"));if("xml"===u||"xmlns"===u)throw wg();if("http://www.w3.org/XML/1998/namespace"===t||"http://www.w3.org/2000/xmlns/"===t)throw wg();Fg(b,u,t)});let k=null,l=null;for(const t of K(a,"defaultNamespaceDecl")){const u=H(F(t,"defaultNamespaceCategory")),z=H(F(t,"uri"));if(!z)throw ug();if("http://www.w3.org/XML/1998/namespace"===z||"http://www.w3.org/2000/xmlns/"===z)throw wg();if("function"===u){if(k)throw vg();
|
|
404
|
+
k=z}else if("element"===u){if(l)throw vg();l=z}}k&&(b.v=k);l&&Fg(b,"",l);K(a,"functionDecl").forEach(t=>{wq(t,b,e,f,c)});const n=[];K(a,"varDecl").forEach(t=>{const u=Jg(F(t,"varName"));let z=u.namespaceURI;if(null===z&&(z=b.$(u.prefix),!z&&u.prefix))throw yg(u.prefix);if(vq.includes(z))throw sg();var y=F(t,"external");t=F(t,"varValue");let G,N;null!==y?(y=F(y,"varValue"),null!==y&&(G=F(y,"*"))):null!==t&&(G=F(t,"*"));if(n.some(U=>U.namespaceURI===z&&U.localName===u.localName))throw Error(`XQST0049: The variable ${z?
|
|
405
|
+
`Q{${z}}`:""}${u.localName} has already been declared.`);Gg(b,z||"",u.localName);if(c&&(G&&(N=Fk(G,{sa:!1,Z:!0})),G&&!Dg(b,z||"",u.localName))){let U=null;Hg(b,z,u.localName,(ca,Ga)=>{if(U)return U();U=Ra(C(N,ca,Ga));return U()});e.push({ba:N,Eb:new Bg(b)});n.push({ba:N,localName:u.localName,namespaceURI:z})}});f.forEach(t=>{if(!t.Ab.I&&t.ba.I)throw Ne(`The function Q{${t.namespaceURI}}${t.localName} is updating but the %updating annotation is missing.`);});return{Ia:f.map(t=>t.Ab),Ta:n,source:d,
|
|
406
|
+
pa:t=>{h.forEach(u=>{Nk(b,u)});e.forEach(({ba:u,Eb:z})=>{h.forEach(y=>{Nk(z,y)});t.Ia.forEach(y=>{z.va(y.namespaceURI,y.localName,y.arity,!0)||y.cb&&Eg(z,y.namespaceURI,y.localName,y.arity,y)});t.Ta.forEach(y=>{z.eb(y.namespaceURI,y.localName)||Gg(z,y.namespaceURI,y.localName)});u.v(z)})}}};function yq(a,b,c,d,e,f,h){const k=b.Z?"XQuery":"XPath";c=b.Ha?null:Ik(a,k,c,d,e,b.debug,f,h);return null!==c?{state:c.hc?1:2,ba:c.ba}:{state:0,Zb:"string"===typeof a?uq(a,b):Kk(a)}}function zq(a,b,c,d){const e=F(a,"mainModule");if(!e)throw Error("Can not execute a library module.");const f=F(e,"prolog");if(f){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");Ok();d=xq(f,c,!0,d);d.pa(d)}O(a,new qh(c));a=J(e,["queryBody","*"]);return Q(a,b)}
|
|
407
|
+
function Aq(a,b,c,d,e,f,h){const k=new pg(c,d,f,h),l=new Bg(k);0<Object.keys(e).length&&Ok();Object.keys(e).forEach(n=>{const t=e[n];Nk(l,t);Fg(l,n,t)});"string"===typeof a&&(a=Pk(a));c=yq(a,b,c,d,e,f,h);switch(c.state){case 2:return{ga:l,ba:c.ba};case 1:return c.ba.v(l),Jk(a,b.Z?"XQuery":"XPath",k,e,c.ba,b.debug,f),{ga:l,ba:c.ba};case 0:return c=zq(c.Zb,b,l,a),c.v(l),b.Ha||Jk(a,b.Z?"XQuery":"XPath",k,e,c,b.debug,f),{ga:l,ba:c}}};function Bq(a){if(v(a.type,1))return a.value;if(v(a.type,54))return a.value.node;throw mc(`Unable to convert selector argument of type ${Da[a.type]} to either an ${Da[1]} or an ${Da[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`);}
|
|
408
|
+
function Cq(a,b,c,d){a=a.first();const e=b.first().h.reduce((f,h)=>{f[h.key.value]=Ra(h.value());return f},Object.create(null));b=e["."]?e["."]():w.empty();delete e["."];a=Bq(a);try{const {ba:f,ga:h}=Aq(a,{sa:!1,Z:!0,debug:d.debug,Ha:d.Ha},n=>c.$(n),Object.keys(e).reduce((n,t)=>{n[t]=t;return n},{}),{},"http://www.w3.org/2005/xpath-functions",(n,t)=>c.Sa(n,t)),k=!b.F(),l=new cc({M:k?b.first():null,Aa:k?0:-1,ta:b,ra:Object.keys(e).reduce((n,t)=>{n[h.eb(null,t)]=e[t];return n},Object.create(null))});
|
|
409
|
+
return{ic:f.h(l,d).value,ac:a}}catch(f){gg(a,f)}};function Dq(a,b,c){if(1!==b.node.nodeType&&9!==b.node.nodeType)return[];const d=gb(a,b).reduce((e,f)=>{for(const h of Dq(a,f,c))e.push(h);return e},[]);c(b)&&d.unshift(b);return d}
|
|
410
|
+
const Eq=(a,b,c,d,e)=>{a=e.first();if(!a)throw lc("The context is absent, it needs to be present to use id function.");if(!v(a.type,53))throw mc("The context item is not a node, it needs to be node to use id function.");const f=b.h,h=d.O().reduce((k,l)=>{l.value.split(/\s+/).forEach(n=>{k[n]=!0});return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the target node is not a document node.");b=Dq(f,b,k=>{if(1!==k.node.nodeType)return!1;
|
|
411
|
+
k=fb(f,k,"id");if(!k||!h[k])return!1;h[k]=!1;return!0});return w.create(b.map(k=>rb(k)))},Fq=(a,b,c,d,e)=>{a=e.first();if(!a)throw lc("The context is absent, it needs to be present to use idref function.");if(!v(a.type,53))throw mc("The context item is not a node, it needs to be node to use idref function.");const f=b.h,h=d.O().reduce((k,l)=>{k[l.value]=!0;return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the context node is not a document node.");
|
|
412
|
+
b=Dq(f,b,k=>1!==k.node.nodeType?!1:(k=fb(f,k,"idref"))?k.split(/\s+/).some(l=>h[l]):!1);return w.create(b.map(k=>rb(k)))};function Gq(a){switch(typeof a){case "object":return Array.isArray(a)?w.m(new pb(a.map(b=>Ra(Gq(b))))):null===a?w.empty():w.m(new ub(Object.keys(a).map(b=>({key:g(b,1),value:Ra(Gq(a[b]))}))));case "number":return w.m(g(a,3));case "string":return w.m(g(a,1));case "boolean":return a?w.aa():w.T();default:throw Error("Unexpected type in JSON parse");}};const Hq=(a,b,c,d,e)=>{const f=w.m(g("duplicates",1));a=tb(a,b,c,e,f);const h=a.F()?"use-first":a.first().value;return d.N(k=>w.m(new ub(k.reduce((l,n)=>{n.h.forEach(t=>{const u=l.findIndex(z=>sb(z.key,t.key));if(0<=u)switch(h){case "reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case "use-last":l.splice(u,1,t);return;case "combine":l.splice(u,1,{key:t.key,value:Ra(w.create(l[u].value().O().concat(t.value().O())))});return;default:return}l.push(t)});return l},[]))))};function Iq(a,b,c){let d=1;const e=a.value;a=a.Pa(!0);let f=null;const h=Math.max(b-1,0);-1!==a&&(f=Math.max(0,(null===c?a:Math.max(0,Math.min(a,c+(b-1))))-h));return w.create({next:k=>{for(;d<b;)e.next(k),d++;if(null!==c&&d>=b+c)return p;k=e.next(k);d++;return k}},f)}function Jq(a){return a.map(b=>v(b.type,19)?jd(b,3):b)}function Kq(a){a=Jq(a);if(a.some(b=>Number.isNaN(b.value)))return[g(NaN,3)];a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");return a}
|
|
413
|
+
const Lq=(a,b,c,d,e,f)=>A([e,f],([h,k])=>{if(Infinity===h.value)return w.empty();if(-Infinity===h.value)return k&&Infinity===k.value?w.empty():d;if(k){if(isNaN(k.value))return w.empty();Infinity===k.value&&(k=null)}return isNaN(h.value)?w.empty():Iq(d,Math.round(h.value),k?Math.round(k.value):null)}),Mq=(a,b,c,d,e)=>{if(d.F())return e;a=Jq(d.O());a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(f=>v(f.type,2)))throw Error("FORG0006: items passed to fn:sum are not all numeric.");
|
|
414
|
+
b=a.reduce((f,h)=>f+h.value,0);return a.every(f=>v(f.type,5))?w.m(g(b,5)):a.every(f=>v(f.type,3))?w.m(g(b,3)):a.every(f=>v(f.type,4))?w.m(g(b,4)):w.m(g(b,6))};var Nq=[].concat(Mf,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>d.fa()?w.aa():w.T()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>w.aa()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>!1===d.fa()?w.aa():w.T()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",
|
|
415
|
+
j:[],i:{type:0,g:3},callFunction:()=>w.T()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.M)throw lc("The fn:last() function depends on dynamic context, which is absent.");let b=!1;return w.create({next:()=>{if(b)return p;const c=a.ta.Pa();b=!0;return q(g(c,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.M)throw lc("The fn:position() function depends on dynamic context, which is absent.");
|
|
416
|
+
return w.m(g(a.Aa+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:a=>w.m(g(ec(a),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:a=>w.m(g(Lb(ec(a),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:a=>w.m(g(Lb(ec(a),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",
|
|
417
|
+
j:[],i:{type:17,g:3},callFunction:a=>w.m(g(fc(a),17))}],Nf,Vf,bg,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.bb(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.ab(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",
|
|
418
|
+
j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getHours(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMinutes(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
419
|
+
localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getSeconds(),4))}],dg,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2},{type:53,g:3}],i:{type:54,g:2},callFunction:Eq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction(a,b,c,d){return Eq(a,b,c,d,w.m(a.M))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",
|
|
420
|
+
j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:Fq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction(a,b,c,d){return Fq(a,b,c,d,w.m(a.M))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(a,b,c,d)=>{let e;try{e=JSON.parse(d.first().value)}catch(f){throw Error("FOJS0001: parsed JSON string contains illegal JSON.");}return Gq(e)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",
|
|
421
|
+
localName:"contains",j:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>f.h.some(k=>sb(k.key,h))?w.aa():w.T())},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"entry",j:[{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(a,b,c,d,e)=>d.map(f=>new ub([{key:f,value:Ra(e)}]))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"for-each",j:[{type:61,g:3},{type:59,g:2}],i:{type:59,g:2},callFunction:(a,b,c,d,e)=>A([d,
|
|
422
|
+
e],([f,h])=>jc(f.h.map(k=>h.value.call(void 0,a,b,c,w.m(k.key),k.value()))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"get",j:[{type:61,g:3},{type:46,g:3}],i:{type:59,g:2},callFunction:tb},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(a,b,c,d)=>A([d],([e])=>w.create(e.h.map(f=>f.key)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2},{type:61,g:3}],
|
|
423
|
+
i:{type:61,g:3},callFunction:Hq},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction(a,b,c,d){return Hq(a,b,c,d,w.m(new ub([{key:g("duplicates",1),value:()=>w.m(g("use-first",1))}])))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"put",j:[{type:61,g:3},{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(a,b,c,d,e,f)=>A([d,e],([h,k])=>{h=h.h.concat();const l=h.findIndex(n=>sb(n.key,k));0<=l?h.splice(l,
|
|
424
|
+
1,{key:k,value:Ra(f)}):h.push({key:k,value:Ra(f)});return w.m(new ub(h))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"remove",j:[{type:61,g:3},{type:46,g:2}],i:{type:61,g:3},callFunction:(a,b,c,d,e)=>A([d],([f])=>{const h=f.h.concat();return e.N(k=>{k.forEach(l=>{const n=h.findIndex(t=>sb(t.key,l));0<=n&&h.splice(n,1)});return w.m(new ub(h))})})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(a,
|
|
425
|
+
b,c,d)=>d.map(e=>g(e.h.length,5))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>w.m(g(Math.PI,3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.pow(Math.E,e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.pow(10,e.value),
|
|
426
|
+
3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.log(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.log10(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pow",j:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},callFunction:(a,b,c,d,e)=>e.N(([f])=>d.map(h=>
|
|
427
|
+
1!==Math.abs(h.value)||Number.isFinite(f.value)?g(Math.pow(h.value,f.value),3):g(1,3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.sqrt(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.sin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",j:[{type:3,
|
|
428
|
+
g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.cos(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.tan(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.asin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",j:[{type:3,
|
|
429
|
+
g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.acos(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(Math.atan(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan2",j:[{type:3,g:0},{type:3,g:3}],i:{type:3,g:0},callFunction:(a,b,c,d,e)=>e.N(([f])=>d.map(h=>g(Math.atan2(h.value,f.value),3)))}],ze,Zd,[{namespaceURI:"http://fontoxpath/operators",
|
|
430
|
+
localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(a,b,c,d,e)=>{a=d.first();e=e.first();if(null===a||null===e)return w.empty();let f=a.value;e=e.value;return f>e?w.empty():w.create({next:()=>q(g(f++,5))},e-f+1)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"QName",j:[{type:1,g:0},{type:1,g:3}],i:{type:23,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{h=h.value;if(!tc(h,23))throw Error("FOCA0002: The provided QName is invalid.");f=f?f.value||null:null;
|
|
431
|
+
if(null===f&&h.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(d.F())return w.m(g(new Sa("",null,h),23));if(!h.includes(":"))return w.m(g(new Sa("",f,h),23));const [k,l]=h.split(":");return w.m(g(new Sa(k,f,l),23))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(a,b,c,d)=>A([d],([e])=>{if(null===e)return w.empty();e=e.value;return e.prefix?w.m(g(e.prefix,24)):
|
|
432
|
+
w.empty()})},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"local-name-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(e.value.localName,24))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"namespace-uri-from-QName",j:[{type:23,g:0}],i:{type:20,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(e.value.namespaceURI||"",20))}],[{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.aa(),multiple:()=>w.T(),m:()=>w.T()}),localName:"empty",
|
|
433
|
+
namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.T(),multiple:()=>w.aa(),m:()=>w.aa()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Iq(d,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Iq(d,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
434
|
+
i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return f;if(f.F())return d;a=d.O();e=e.first().value-1;0>e?e=0:e>a.length&&(e=a.length);b=a.slice(e);return w.create(a.slice(0,e).concat(f.O(),b))},localName:"insert-before",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3}],callFunction:(a,b,c,d,e)=>{a=e.first().value;d=d.O();if(!d.length||1>a||a>d.length)return w.create(d);d.splice(a-1,1);return w.create(d)},
|
|
435
|
+
localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.N(e=>w.create(e.reverse())),localName:"reverse",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3}],callFunction:(a,b,c,d,e)=>Lq(a,b,c,d,e,w.empty()),localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3},{type:3,g:3}],callFunction:Lq,localName:"subsequence",
|
|
436
|
+
namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{const e=qc(d,b).O();return w.create(e).filter((f,h)=>e.slice(0,h).every(k=>!Ce(f,k)))},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported");
|
|
437
|
+
},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:46,g:3}],callFunction:(a,b,c,d,e)=>e.N(([f])=>qc(d,b).map((h,k)=>oi("eqOp",h.type,f.type)(h,f,a)?g(k+1,5):g(-1,5)).filter(h=>-1!==h.value)),localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:46,g:2},{type:46,g:3},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported");},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
438
|
+
i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(a,b,c,d,e)=>{let f=!1;const h=Fe(a,b,c,d,e);return w.create({next:()=>{if(f)return p;const k=h.next(0);if(k.done)return k;f=!0;return q(g(k.value,0))}})},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2},{type:59,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported");},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
439
|
+
i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{let e=!1;return w.create({next:()=>{if(e)return p;const f=d.Pa();e=!0;return q(g(f,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Jq(d.O());a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(e=>v(e.type,2)))throw Error("FORG0006: items passed to fn:avg are not all numeric.");
|
|
440
|
+
b=a.reduce((e,f)=>e+f.value,0)/a.length;return a.every(e=>v(e.type,5)||v(e.type,3))?w.m(g(b,3)):a.every(e=>v(e.type,4))?w.m(g(b,4)):w.m(g(b,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Kq(d.O());return w.m(a.reduce((e,f)=>e.value<f.value?f:e))},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported");
|
|
441
|
+
},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Kq(d.O());return w.m(a.reduce((e,f)=>e.value>f.value?f:e))},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported");},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,
|
|
442
|
+
g:2}],callFunction:(a,b,c,d)=>Mq(a,b,c,d,w.m(g(0,5))),localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:3}},{j:[{type:46,g:2},{type:46,g:0}],callFunction:Mq,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.F()&&!d.oa())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");return d},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
443
|
+
i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(d.F())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return d},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.oa())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");return d},localName:"exactly-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,
|
|
444
|
+
g:3}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e)=>{if(d.F())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return d.filter(k=>{k=zd(h[0],w.m(k),b,"fn:filter",!1);k=f.value.call(void 0,a,b,c,k);if(!k.oa()||!v(k.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return k.first().value})},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
445
|
+
i:{type:59,g:2}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e)=>{if(d.F())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const k=d.value;let l;return w.create({next:n=>{for(;;){if(!l){var t=k.next(0);if(t.done)return t;t=zd(h[0],w.m(t.value),b,"fn:for-each",!1);l=f.value.call(void 0,a,b,c,t).value}t=l.next(n);if(!t.done)return t;l=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",
|
|
446
|
+
i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return d.N(l=>l.reduce((n,t)=>{n=zd(k[0],n,b,"fn:fold-left",!1);t=zd(k[1],w.m(t),b,"fn:fold-left",!1);return h.value.call(void 0,a,b,c,n,t)},e))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,
|
|
447
|
+
g:2},{type:60,g:3}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return d.N(l=>l.reduceRight((n,t)=>{n=zd(k[0],n,b,"fn:fold-right",!1);t=zd(k[1],w.m(t),b,"fn:fold-right",!1);return h.value.call(void 0,a,b,c,t,n)},e))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!b.Ua)throw Error("serialize() called but no xmlSerializer set in execution parameters.");
|
|
448
|
+
a=d.O();if(!a.every(e=>v(e.type,53)))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return w.m(g(a.map(e=>b.Ua.serializeToString($f(e.value,b,!1))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],ke,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(a,b,c,d,e)=>{let f,h;return w.create({next:()=>{f||({ic:f,ac:h}=Cq(d,e,c,b));try{return f.next(0)}catch(k){gg(h,k)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",
|
|
449
|
+
i:{type:59,g:2}},{j:[],callFunction:()=>w.m(g("undefined"===typeof VERSION?"devbuild":VERSION,1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{const k=c.va(f.value.namespaceURI,f.value.localName,h.value);if(null===k)return w.empty();f=new Va({j:k.j,arity:h.value,localName:f.value.localName,namespaceURI:f.value.namespaceURI,i:k.i,value:k.callFunction});return w.m(f)}),localName:"function-lookup",
|
|
450
|
+
namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(a,b,c,d)=>A([d],([e])=>e.Ya()?w.empty():w.m(g(new Sa("",e.l,e.D),23))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(a,b,c,d)=>A([d],([e])=>w.m(g(e.v,5))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class Oq{constructor(a){this.h=a}createAttributeNS(a,b){return this.h.createAttributeNS(a,b)}createCDATASection(a){return this.h.createCDATASection(a)}createComment(a){return this.h.createComment(a)}createDocument(){return this.h.createDocument()}createElementNS(a,b){return this.h.createElementNS(a,b)}createProcessingInstruction(a,b){return this.h.createProcessingInstruction(a,b)}createTextNode(a){return this.h.createTextNode(a)}};var Pq=Symbol("IS_XPATH_VALUE_SYMBOL");function Qq(a){return(b,c)=>{b=Vb(new nb(null===c?new Za:c),b,Ja(a));return{[Pq]:!0,zb:b}}};Nq.forEach(a=>{ng(a.namespaceURI,a.localName,a.j,a.i,a.callFunction)});function Rq(a){return a&&"object"===typeof a&&"lookupNamespaceURI"in a?b=>a.lookupNamespaceURI(b||null):()=>null}function Sq(a){return({prefix:b,localName:c})=>b?null:{namespaceURI:a,localName:c}}
|
|
451
|
+
function Tq(a,b,c,d,e,f){if(null===d||void 0===d)d=d||{};const h=e?{jb:e.logger||{trace:console.log.bind(console)},Ma:e.documentWriter,kb:e.moduleImports,Cb:e.namespaceResolver,bc:e.functionNameResolver,Ja:e.nodesFactory,Ua:e.xmlSerializer}:{jb:{trace:console.log.bind(console)},kb:{},Cb:null,Ja:null,Ma:null,Ua:null},k=new nb(null===c?new Za:c);c=h.kb||Object.create(null);var l=void 0===e.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":e.defaultFunctionNamespaceURI;const n=Aq(a,
|
|
452
|
+
f,h.Cb||Rq(b),d,c,l,h.bc||Sq(l));a=b?Wb(k,b):w.empty();b=!h.Ja&&f.Z?new Ze(b):new Oq(h.Ja);c=h.Ma?new bb(h.Ma):ab;l=h.Ua;const t=Object.keys(d).reduce((y,G)=>{const N=d[G];y[`Q{}${G}[0]`]=N&&"object"===typeof N&&Pq in N?()=>w.create(N.zb):()=>Wb(k,d[G]);return y},Object.create(null));let u;for(const y of Object.keys(n.ga.Ea))t[y]||(t[y]=()=>(0,n.ga.Ea[y])(u,z));u=new cc({M:a.first(),Aa:0,ta:a,ra:t});const z=new ic(f.debug,f.Ha,k,b,c,e.currentContext,new Map,h.jb,l);return{tb:u,ub:z,ba:n.ba}};function Uq(a,b){const c={};let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.h.length;){const k=a.h[d].key.value;if(!f){const l=a.h[d];var h=l.value().X({default:n=>n,multiple:()=>{throw Error(`Serialization error: The value of an entry in a map is expected to be a single item or an empty sequence. Use arrays when putting multiple values in a map. The value of the key ${l.key.value} holds multiple items`);}}).first();if(null===h){c[k]=null;d++;continue}f=Vq(h,b)}h=f.next(0);f=null;c[k]=
|
|
453
|
+
h.value;d++}e=!0;return q(c)}}}function Wq(a,b){const c=[];let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.h.length;){if(!f){var h=a.h[d]().X({default:k=>k,multiple:()=>{throw Error("Serialization error: The value of an entry in an array is expected to be a single item or an empty sequence. Use nested arrays when putting multiple values in an array.");}}).first();if(null===h){c[d++]=null;continue}f=Vq(h,b)}h=f.next(0);f=null;c[d++]=h.value}e=!0;return q(c)}}}
|
|
454
|
+
function Vq(a,b){if(v(a.type,61))return Uq(a,b);if(v(a.type,62))return Wq(a,b);if(v(a.type,23)){const c=a.value;return{next:()=>q(`Q{${c.namespaceURI||""}}${c.localName}`)}}switch(a.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const c=a.value;return{next:()=>q(Mb(c))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const d=a.value;return{next:()=>q($f(d,b,!1))};default:return{next:()=>q(a.value)}}};var Xq={ANY:0,NUMBER:1,STRING:2,BOOLEAN:3,NODES:7,FIRST_NODE:9,STRINGS:10,MAP:11,ARRAY:12,NUMBERS:13,ALL_RESULTS:14,ASYNC_ITERATOR:99};Xq[Xq.ANY]="ANY";Xq[Xq.NUMBER]="NUMBER";Xq[Xq.STRING]="STRING";Xq[Xq.BOOLEAN]="BOOLEAN";Xq[Xq.NODES]="NODES";Xq[Xq.FIRST_NODE]="FIRST_NODE";Xq[Xq.STRINGS]="STRINGS";Xq[Xq.MAP]="MAP";Xq[Xq.ARRAY]="ARRAY";Xq[Xq.NUMBERS]="NUMBERS";Xq[Xq.ALL_RESULTS]="ALL_RESULTS";Xq[Xq.ASYNC_ITERATOR]="ASYNC_ITERATOR";
|
|
455
|
+
function Yq(a,b,c,d){switch(c){case 3:return b.fa();case 2:return b=qc(b,d).O(),b.length?b.map(l=>jd(l,1).value).join(" "):"";case 10:return b=qc(b,d).O(),b.length?b.map(l=>l.value+""):[];case 1:return b=b.first(),null!==b&&v(b.type,2)?b.value:NaN;case 9:b=b.first();if(null===b)return null;if(!v(b.type,53))throw Error("Expected XPath "+eg(a)+" to resolve to Node. Got "+Da[b.type]);return $f(b.value,d,!1);case 7:b=b.O();if(!b.every(l=>v(l.type,53)))throw Error("Expected XPath "+eg(a)+" to resolve to a sequence of Nodes.");
|
|
456
|
+
return b.map(l=>$f(l.value,d,!1));case 11:b=b.O();if(1!==b.length)throw Error("Expected XPath "+eg(a)+" to resolve to a single map.");b=b[0];if(!v(b.type,61))throw Error("Expected XPath "+eg(a)+" to resolve to a map");return Uq(b,d).next(0).value;case 12:b=b.O();if(1!==b.length)throw Error("Expected XPath "+eg(a)+" to resolve to a single array.");b=b[0];if(!v(b.type,62))throw Error("Expected XPath "+eg(a)+" to resolve to an array");return Wq(b,d).next(0).value;case 13:return b.O().map(l=>{if(!v(l.type,
|
|
457
|
+
2))throw Error("Expected XPath "+eg(a)+" to resolve to numbers");return l.value});case 99:const e=b.value;let f=null,h=!1;const k=()=>{for(;!h;){if(!f){var l=e.next(0);if(l.done){h=!0;break}f=Vq(l.value,d)}l=f.next(0);f=null;return l}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>(new Promise(l=>l(k()))).catch(l=>{gg(a,l)})}:{next:()=>new Promise(l=>l(k()))};case 14:return b.O().map(l=>Vq(l,d).next(0).value);default:return b=
|
|
458
|
+
b.O(),b.every(l=>v(l.type,53)&&!v(l.type,47))?(b=b.map(l=>$f(l.value,d,!1)),1===b.length?b[0]:b):1===b.length?(b=b[0],v(b.type,62)?Wq(b,d).next(0).value:v(b.type,61)?Uq(b,d).next(0).value:pc(b,d).first().value):qc(w.create(b),d).O().map(l=>l.value)}};let Zq=!1,$q=null;
|
|
459
|
+
var ar={getPerformanceSummary(){const a=$q.getEntriesByType("measure").filter(b=>b.name.startsWith("XPath: "));return Array.from(a.reduce((b,c)=>{var d=c.name.substring(7);b.has(d)?(d=b.get(d),d.times+=1,d.totalDuration+=c.duration):b.set(d,{xpath:d,times:1,totalDuration:c.duration,average:0});return b},new Map).values()).map(b=>{b.average=b.totalDuration/b.times;return b}).sort((b,c)=>c.totalDuration-b.totalDuration)},setPerformanceImplementation(a){$q=a},startProfiling(){if(null===$q)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");
|
|
460
|
+
$q.clearMarks();$q.clearMeasures();Zq=!0},stopProfiling(){Zq=!1}};let br=0;var cr={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"};const dr=(a,b,c,d,e,f)=>{e=e||0;if(!a||"string"!==typeof a&&!("nodeType"in a))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");f=f||{};let h,k;try{const n=Tq(a,b,c||null,d||{},f,{sa:"XQueryUpdate3.1"===f.language,Z:"XQuery3.1"===f.language||"XQueryUpdate3.1"===f.language,debug:!!f.debug,Ha:!!f.disableCache});var l=n.tb;h=n.ub;k=n.ba}catch(n){gg(a,n)}if(k.I)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");
|
|
461
|
+
if(3===e&&b&&"object"===typeof b&&"nodeType"in b&&(c=k.D(),b=Ya(b),null!==c&&!b.includes(c)))return!1;try{b=a;Zq&&("string"!==typeof b&&(b=eg(b)),$q.mark(`${b}${0===br?"":"@"+br}`),br++);const n=C(k,l,h),t=Yq(a,n,e,h);e=a;Zq&&("string"!==typeof e&&(e=eg(e)),br--,l=`${e}${0===br?"":"@"+br}`,$q.measure(`XPath: ${e}`,l),$q.clearMarks(l));return t}catch(n){gg(a,n)}};
|
|
462
|
+
Object.assign(dr,{jc:14,ANY_TYPE:0,Lb:12,Mb:99,BOOLEAN_TYPE:3,Ob:9,Rb:11,Tb:7,Ub:13,NUMBER_TYPE:1,Vb:10,STRING_TYPE:2,kc:"XPath3.1",lc:"XQuery3.1",Yb:"XQueryUpdate3.1"});Object.assign(dr,{ALL_RESULTS_TYPE:14,ANY_TYPE:0,ARRAY_TYPE:12,ASYNC_ITERATOR_TYPE:99,BOOLEAN_TYPE:3,FIRST_NODE_TYPE:9,MAP_TYPE:11,NODES_TYPE:7,NUMBERS_TYPE:13,NUMBER_TYPE:1,STRINGS_TYPE:10,STRING_TYPE:2,XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"});function er(a,b,c,d,e){return dr(a,b,c,d,dr.Mb,e)};function fr(a,b,c,d){return{pendingUpdateList:a.da.map(e=>e.h(d)),xdmValue:Yq(b,w.create(a.J),c,d)}};async function gr(a,b,c,d,e){e=e||{};Ok();let f,h;try{const n=Tq(a,b,c||null,d||{},e||{},{sa:!0,Z:!0,debug:!!e.debug,Ha:!!e.disableCache});var k=n.tb;f=n.ub;h=n.ba}catch(n){gg(a,n)}if(!h.I){k=[];a=er(a,b,c,d,Object.assign(Object.assign({},e),{language:"XQueryUpdate3.1"}));for(b=await a.next();!b.done;b=await a.next())k.push(b.value);return Promise.resolve({pendingUpdateList:[],xdmValue:k})}let l;try{l=h.s(k,f).next(0)}catch(n){gg(a,n)}return fr(l.value,a,e.returnType,f)};function hr(a,b,c,d,e){e=e||{};Ok();let f,h,k;try{const n=Tq(a,b,c||null,d||{},e||{},{sa:!0,Z:!0,debug:!!e.debug,Ha:!!e.disableCache});f=n.tb;h=n.ub;k=n.ba}catch(n){gg(a,n)}if(!k.I)return{pendingUpdateList:[],xdmValue:dr(a,b,c,d,e.i,Object.assign(Object.assign({},e),{language:dr.Yb}))};let l;try{l=k.s(f,h).next(0)}catch(n){gg(a,n)}return fr(l.value,a,e.returnType,h)};function ir(a,b,c,d,e){return dr(a,b,c,d,dr.Lb,e)};function jr(a,b,c,d,e){return dr(a,b,c,d,dr.BOOLEAN_TYPE,e)};function kr(a,b,c,d,e){return dr(a,b,c,d,dr.Ob,e)};function lr(a,b,c,d,e){return dr(a,b,c,d,dr.Rb,e)};function mr(a,b,c,d,e){return dr(a,b,c,d,dr.Tb,e)};function nr(a,b,c,d,e){return dr(a,b,c,d,dr.NUMBER_TYPE,e)};function or(a,b,c,d,e){return dr(a,b,c,d,dr.Ub,e)};function pr(a,b,c,d,e){return dr(a,b,c,d,dr.STRING_TYPE,e)};function qr(a,b,c,d,e){return dr(a,b,c,d,dr.Vb,e)};function rr(a,b,c,d){b=new nb(b?b:new Za);d=d?new bb(d):ab;c=c?c=new Oq(c):null;a=a.map(Rj);kf(a,b,c,d)};function Y(a,b,c){return{code:a,ua:b,H:c,isAstAccepted:!0}}function sr(a){return{isAstAccepted:!1,reason:a}};function Z(a,b){return a.isAstAccepted?b(a):a}function tr(a,b){return a.isAstAccepted?b(a):[a,null]}function ur(a,b,c){return Z(a,d=>{switch(d.ua.type){case 0:return d;case 1:return Z(vr(c,d,"nodes"),e=>Z(vr(c,b,"contextItem"),f=>Y(`(function () {
|
|
463
|
+
const { done, value } = ${e.code}(${f.code}).next();
|
|
464
|
+
return done ? null : value;
|
|
465
|
+
})()`,{type:0},[...e.H,...f.H])));default:throw Error(`invalid generated code type to convert to value: ${d.ua.type}`);}})}function wr(a,b,c,d){a=ur(a,c,d);return b&&0===b.type&&3===b.g?a:Z(a,e=>Y(`!!${e.code}`,{type:0},e.H))}
|
|
466
|
+
function xr(a,b,c){return b?a.isAstAccepted&&0!==a.ua.type?sr("Atomization only implemented for single value"):v(b.type,1)?a:v(b.type,47)?Z(vr(c,a,"attr"),d=>Y(`(${d.code} ? domFacade.getData(${d.code}) : null)`,{type:0},d.H)):sr("Atomization only implemented for string and attribute"):sr("Can not atomize value if type was not annotated")}function yr(a,b,c,d){a=ur(a,c,d);d=xr(a,b,d);return wc(b)?Z(d,e=>Y(`${e.code} ?? ''`,{type:0},e.H)):d}
|
|
467
|
+
function zr(a,b,c){return Z(vr(c,a,"node"),d=>1===d.ua.type?d:b&&!v(b.type,53)?sr("Can not evaluate to node if expression does not result in nodes"):Y(`(function () {
|
|
468
|
+
if (${d.code} !== null && !${d.code}.nodeType) {
|
|
469
|
+
throw new Error('XPDY0050: The result of the expression was not a node');
|
|
470
|
+
}
|
|
471
|
+
return ${d.code};
|
|
472
|
+
})()`,{type:0},d.H))}function Ar(a,b,c,d){return Z(a,e=>{switch(e.ua.type){case 1:return Z(vr(d,e,"nodes"),f=>Z(vr(d,c,"contextItem"),h=>Y(`Array.from(${f.code}(${h.code}))`,{type:0},[...f.H,...h.H])));case 0:return Z(vr(d,zr(e,b,d),"node"),f=>Y(`(${f.code} === null ? [] : [${f.code}])`,{type:0},f.H));default:return sr("Unsupported code type to evaluate to nodes")}})}
|
|
473
|
+
function Br(a,b){return Z(a,c=>Z(b,d=>{if(0!==c.ua.type||0!==d.ua.type)throw Error("can only use emitAnd with value expressions");return Y(`${c.code} && ${d.code}`,{type:0},[...c.H,...d.H])}))};function Cr(a,b,c,d){return(a=J(a,[b,"*"]))?d.h(a,c,d):[sr(`${b} expression not found`),null]};const gu={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},hu={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};
|
|
474
|
+
function iu(a,b,c,d){const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");if(!e||!f)return sr("Can not generate code for value compare without both types");var h=[47,1];if(!h.includes(e.type)||!h.includes(f.type))return sr(`Unsupported types in compare: [${Da[e.type]}, ${Da[f.type]}]`);h=new Map([["eqOp","==="],["neOp","!=="]]);if(!h.has(b))return sr(b+" not yet implemented");const k=h.get(b);[b]=Cr(a,"firstOperand",c,d);b=ur(b,c,d);b=xr(b,e,d);return Z(vr(d,b,"first"),
|
|
475
|
+
l=>{var [n]=Cr(a,"secondOperand",c,d);n=ur(n,c,d);n=xr(n,f,d);return Z(vr(d,n,"second"),t=>{const u=[];wc(e)&&u.push(`${l.code} === null`);wc(f)&&u.push(`${t.code} === null`);return Y(`(${u.length?`${u.join(" || ")} ? null : `:""}${l.code} ${k} ${t.code})`,{type:0},[...l.H,...t.H])})})}
|
|
476
|
+
function ju(a,b,c,d,e,f){var h=I(J(a,[b,"*"]),"type");const k=I(J(a,[c,"*"]),"type");if(!h||!k)return sr("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(h.type)||!l.includes(k.type))return sr(`Unsupported types in compare: [${Da[h.type]}, ${Da[k.type]}]`);l=new Map([["eqOp","==="],["neOp","!=="]]);if(!l.has(d))return sr(d+" not yet implemented");const n=l.get(d);[b]=Cr(a,b,e,f);b=ur(b,e,f);h=xr(b,h,f);return Z(vr(f,h,"single"),t=>{const [u]=Cr(a,c,e,f);
|
|
477
|
+
return Z(vr(f,u,"multiple"),z=>{if(1!==z.ua.type)return sr("can only generate general compare for a single value and a generator");const y=ku(f,lu(f,"n")),G=xr(y,k,f);return Z(e,N=>Z(G,U=>Y(`(function () {
|
|
478
|
+
for (const ${y.code} of ${z.code}(${N.code})) {
|
|
479
|
+
${U.H.join("\n")}
|
|
480
|
+
if (${U.code} ${n} ${t.code}) {
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
})()`,{type:0},[...t.H,...y.H,...N.H,...z.H])))})})};function mu(a){return JSON.stringify(a).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};const su={"false#0":nu,"local-name#0":ou,"local-name#1":ou,"name#0":pu,"name#1":pu,"not#1":qu,"true#0":ru},tu={["http://fontoxml.com/fontoxpath"]:["version#0"],[""]:["root#1","path#1"]};
|
|
486
|
+
function uu(a,b,c,d){const [e]=d.h(a,c,d);a=I(a,"type");if(b?2===b.g||1===b.g:1)return sr("Not supported: sequence arguments with multiple items");if(v(b.type,53))return b=ur(e,c,d),zr(b,a,d);switch(b.type){case 59:return ur(e,c,d);case 0:return wr(e,a,c,d);case 1:return yr(e,a,c,d)}return sr(`Argument types not supported: ${a?Da[a.type]:"unknown"} -> ${Da[b.type]}`)}
|
|
487
|
+
function vu(a,b,c,d){if(a.length!==b.length||b.some(l=>4===l))return sr("Not supported: variadic function or mismatch in argument count");if(0===a.length)return Y("",{type:0},[]);const [e,...f]=a,[h,...k]=b;a=vr(d,uu(e,h,c,d),"arg");return 0===f.length?a:Z(a,l=>{const n=vu(f,k,c,d);return Z(n,t=>Y(`${l.code}, ${t.code}`,{type:0},[...l.H,...t.H]))})}
|
|
488
|
+
function wu(a,b){return Z(a,c=>(b?2===b.g||1===b.g:1)||![0,1].includes(b.type)&&!v(b.type,53)?sr(`Function return type ${Da[b.type]} not supported`):c)}
|
|
489
|
+
function xu(a,b,c){const {localName:d,namespaceURI:e}=Jg(F(a,"functionName")),f=K(F(a,"arguments"),"*");var h=f.length;const k=`${d}#${h}`,l=e===c.D;if(l){const n=su[k];if(void 0!==n)return n(a,b,c)}if((a=tu[l?"":e])&&!a.includes(k))return sr(`Not supported: built-in function not on allow list: ${k}`);h=mg(e,d,h);if(!h)return sr(`Unknown function / arity: ${k}`);if(h.I)return sr("Not supported: updating functions");b=vu(f,h.j,b,c);b=Z(b,n=>Y(`runtimeLib.callFunction(domFacade, ${mu(e)}, ${mu(d)}, [${n.code}], options)`,
|
|
490
|
+
{type:0},n.H));return wu(b,h.i)}function yu(a,b){return Z(vr(b,a,"contextItem"),c=>Y(c.code,{type:0},[...c.H,`if (${c.code} === undefined || ${c.code} === null) {
|
|
491
|
+
throw errXPDY0002('The function which was called depends on dynamic context, which is absent.');
|
|
492
|
+
}`]))}function zu(a,b,c,d){if((a=J(a,["arguments","*"]))&&"contextItemExpr"!==a[0]){const e=I(a,"type");if(!e||!v(e.type,53))return sr("name function only implemented if arg is a node");[a]=c.h(a,b,c)}else a=yu(b,c);b=ur(a,b,c);return Z(vr(c,b,"arg"),e=>Y(`(${e.code} ? ${d(e.code)} : '')`,{type:0},e.H))}function pu(a,b,c){return zu(a,b,c,d=>`(((${d}.prefix || '').length !== 0 ? ${d}.prefix + ':' : '')
|
|
493
|
+
+ (${d}.localName || ${d}.target || ''))`)}function ou(a,b,c){return zu(a,b,c,d=>`(${d}.localName || ${d}.target || '')`)}function qu(a,b,c){var d=J(a,["arguments","*"]);a=I(d,"type");[d]=c.h(d,b,c);b=wr(d,a,b,c);return Z(b,e=>Y(`!${e.code}`,{type:0},e.H))}function nu(){return Y("false",{type:0},[])}function ru(){return Y("true",{type:0},[])};function Au(a,b,c,d){const [e,f]=Cr(a,"firstOperand",c,d);var h=I(J(a,["firstOperand","*"]),"type");h=wr(e,h,c,d);const [k,l]=Cr(a,"secondOperand",c,d);h=Z(h,t=>{var u=I(J(a,["secondOperand","*"]),"type");u=wr(k,u,c,d);return Z(u,z=>Y(`(${t.code} ${b} ${z.code})`,{type:0},[...t.H,...z.H]))});const n="&&"===b?xh(f,l):f===l?f:null;return[h,n]};function Bu(a,b,c){return Z(a,d=>Z(b,e=>Z(c,f=>Y(`for (${d.code}) {
|
|
494
|
+
${e.H.join("\n")}
|
|
495
|
+
if (!(${e.code})) {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
${f.H.join("\n")}
|
|
499
|
+
${f.code}
|
|
500
|
+
}`,{type:2},d.H))))}function Cu(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(d,h=>Z(e,k=>Y(`let ${h.code} = domFacade.getFirstChild(${k.code}${f});
|
|
501
|
+
${h.code};
|
|
502
|
+
${h.code} = domFacade.getNextSibling(${h.code}${f})`,{type:2},[...h.H,...k.H])));return Bu(b,a,c)}function Du(a,b,c,d,e){const f=xh(b,"type-2"),h=Z(e,k=>Y(`(${k.code} && ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? domFacade.getAllAttributes(${k.code}${f?`, "${f}"`:""}) : [])`,{type:0},k.H));b=Z(d,k=>Z(h,l=>Y(`const ${k.code} of ${l.code}`,{type:2},[...k.H,...l.H])));return Bu(b,a,c)}
|
|
503
|
+
function Eu(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(e,h=>Y(`domFacade.getParentNode(${h.code}${f})`,{type:0},h.H));return Fu(d,b,a,c)}function Fu(a,b,c,d){const e=Br(a,c);return Z(a,f=>Z(b,h=>Z(e,k=>Z(d,l=>Y(`const ${f.code} = ${h.code};
|
|
504
|
+
${k.H.join("\n")}
|
|
505
|
+
if (${k.code}) {
|
|
506
|
+
${l.H.join("\n")}
|
|
507
|
+
${l.code}
|
|
508
|
+
}`,{type:2},[...f.H,...h.H])))))}function Gu(a,b,c,d,e,f){a=H(a);switch(a){case "attribute":return[Du(b,c,d,e,f),"type-1"];case "child":return[Cu(b,c,d,e,f),null];case "parent":return[Eu(b,c,d,e,f),null];case "self":return[Fu(e,f,b,d),c];default:return[sr(`Unsupported: the ${a} axis`),null]}};const Hu={Wb:"textTest",Nb:"elementTest",Sb:"nameTest",Xb:"Wildcard",Kb:"anyKindTest"};var Iu=Object.values(Hu);function Ju(a){return[Z(a,b=>Y(`(${b.code}.nodeType === /*TEXT_NODE*/ ${3} ||
|
|
509
|
+
${b.code}.nodeType === /* CDATA_SECTION_NODE */ ${4})`,{type:0},[])),"type-3"]}function Ku(a,b){if(null===a.namespaceURI&&"*"!==a.prefix){b=b.$(a.prefix||"")||null;if(!b&&a.prefix)throw Error(`XPST0081: The prefix ${a.prefix} could not be resolved.`);a.namespaceURI=b}}function Lu(a,b,c,d){Ku(a,d);const e=a.prefix,f=a.namespaceURI,h=a.localName;return tr(c,k=>{var l=b?Y(`${k.code}.nodeType
|
|
510
|
+
&& (${k.code}.nodeType === /*ELEMENT_NODE*/ ${1}
|
|
511
|
+
|| ${k.code}.nodeType === /*ATTRIBUTE_NODE*/ ${2})`,{type:0},[]):Y(`${k.code}.nodeType
|
|
512
|
+
&& ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[]);if("*"===e)return"*"===h?[l,b?"type-1-or-type-2":"type-1"]:[Br(l,Y(`${k.code}.localName === ${mu(h)}`,{type:0},[])),`name-${h}`];l="*"===h?l:Br(l,Y(`${k.code}.localName === ${mu(h)}`,{type:0},[]));var n=Y(mu(f),{type:0},[]);n=""===e&&b?Z(n,t=>Y(`${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? ${t.code} : null`,{type:0},t.H)):n;n=Z(n,t=>Y(`(${k.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.H));return[Br(l,n),`name-${h}`]})}
|
|
513
|
+
function Mu(a,b,c){const d=(a=F(a,"elementName"))&&F(a,"star");if(null===a||d)return[Z(b,e=>Y(`${e.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[])),"type-1"];a=Jg(F(a,"QName"));return Lu(a,!1,b,c)}function Nu(a){return[Z(a,b=>Y(`!!${b.code}.nodeType`,{type:0},[])),null]}
|
|
514
|
+
function Ou(a,b,c,d){var e=a[0];switch(e){case Hu.Nb:return Mu(a,c,d);case Hu.Wb:return Ju(c);case Hu.Sb:return Lu(Jg(a),b,c,d);case Hu.Xb:return F(a,"star")?(e=F(a,"uri"),null!==e?a=Lu({localName:"*",namespaceURI:H(e),prefix:""},b,c,d):(e=F(a,"NCName"),a="star"===F(a,"*")[0]?Lu({localName:H(e),namespaceURI:null,prefix:"*"},b,c,d):Lu({localName:"*",namespaceURI:null,prefix:H(e)},b,c,d))):a=Lu({localName:"*",namespaceURI:null,prefix:"*"},b,c,d),a;case Hu.Kb:return Nu(c);default:return[sr(`Test not implemented: '${e}`),
|
|
515
|
+
null]}};function Pu(a,b,c){const [d,e]=c.h(a,b,c);return[wr(d,I(a,"type"),b,c),e]}function Qu(a,b,c){a=a?K(a,"*"):[];const [d,e]=a.reduce(([f,h],k)=>{if(!f)return Pu(k,b,c);let l=h;return tr(f,n=>{const [t,u]=Pu(k,b,c);l=xh(h,u);return[Z(t,z=>Y(`${n.code} && ${z.code}`,{type:0},[...n.H,...z.H])),l]})},[null,null]);return[d?Z(d,f=>Y(`(function () {
|
|
516
|
+
${f.H.join("\n")}
|
|
517
|
+
return ${f.code};
|
|
518
|
+
})()`,{type:0},[])):null,e]}
|
|
519
|
+
function Ru(a,b,c,d){if(0===a.length)return[Z(c,y=>Y(`yield ${y.code};`,{type:2},y.H)),null];const [e,...f]=a;if(0<K(e,"lookup").length)return[sr("Unsupported: lookups"),null];const h=ku(d,lu(d,"contextItem"));a=F(e,"predicates");const [k,l]=Qu(a,h,d);if(a=F(e,"xpathAxis")){var n=F(e,Iu);if(!n)return[sr("Unsupported test in step"),null];var t=H(a);b="attribute"===t||"self"===t&&b;const [y,G]=Ou(n,b,h,d);n=null===k?y:Br(y,k);t=xh(G,l);[b]=Ru(f,b,h,d);return Gu(a,n,t,b,h,c)}a=J(e,["filterExpr","*"]);
|
|
520
|
+
if(!a)return[sr("Unsupported: unknown step type"),null];const [u,z]=d.h(a,c,d);return[Z(u,y=>{const G=0===f.length?Y("",{type:2},[]):Y(`if (${h.code} !== null && !${h.code}.nodeType) {
|
|
521
|
+
throw new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');
|
|
522
|
+
}`,{type:2},[]),[N]=Ru(f,!0,h,d),U=null===k?N:Z(k,ca=>Z(N,Ga=>Y(`if (${ca.code}) {
|
|
523
|
+
${Ga.H.join("\n")}
|
|
524
|
+
${Ga.code}
|
|
525
|
+
}`,{type:2},ca.H)));return Z(U,ca=>{switch(y.ua.type){case 1:return Z(c,Ga=>Y(`for (const ${h.code} of ${y.code}(${Ga.code})) {
|
|
526
|
+
${ca.H.join("\n")}
|
|
527
|
+
${ca.code}
|
|
528
|
+
}`,{type:2},[...h.H,...y.H,...G.H]));case 0:return Y(`const ${h.code} = ${y.code};
|
|
529
|
+
${G.code}
|
|
530
|
+
if (${h.code} !== null) {
|
|
531
|
+
${ca.H.join("\n")}
|
|
532
|
+
${ca.code}
|
|
533
|
+
}`,{type:2},[...h.H,...y.H,...G.H]);default:return sr("Unsupported generated code type for filterExpr")}})}),z]}function Su(a){return Z(a,b=>Y(`(function () {
|
|
534
|
+
let n = ${b.code};
|
|
535
|
+
while (n.nodeType !== /*DOCUMENT_NODE*/${9}) {
|
|
536
|
+
n = domFacade.getParentNode(n);
|
|
537
|
+
if (n === null) {
|
|
538
|
+
throw new Error('XPDY0050: the root node of the context node is not a document node.');
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return n;
|
|
542
|
+
})()`,{type:0},b.H))}function Tu(a,b,c){return tr(b,d=>{if(0<K(a,"lookup").length)return[sr("Unsupported: lookups"),null];var e=F(a,"predicates");const [f,h]=Qu(e,d,c);e=F(a,Iu);if(!e)return[sr("Unsupported test in step"),null];const [k,l]=Ou(e,!0,d,c);e=null===f?k:Br(k,f);const n=xh(l,h);return[Z(e,t=>Y(`((${t.code}) ? ${d.code} : null)`,{type:0},[...d.H,...t.H])),n]})}
|
|
543
|
+
function Uu(a,b,c){const d=K(a,"stepExpr");if(1===d.length){const k=F(d[0],"xpathAxis");if(k&&"self"===H(k))return Tu(d[0],b,c)}const e=ku(c,lu(c,"contextItem"));b=(a=F(a,"rootExpr"))?vr(c,Su(e),"root"):e;const [f,h]=Ru(d,!a,b,c);return[Z(f,k=>Y(`(function* (${e.code}) {
|
|
544
|
+
${k.H.join("\n")}
|
|
545
|
+
${k.code}
|
|
546
|
+
})`,{type:1},[])),h]};function Vu(a,b,c){const d=a[0];switch(d){case "contextItemExpr":return[b,null];case "pathExpr":return Uu(a,b,c);case "andOp":return Au(a,"&&",b,c);case "orOp":return Au(a,"||",b,c);case "stringConstantExpr":return a=F(a,"value")[1]||"",a=mu(a),[Y(a,{type:0},[]),null];case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":case "isOp":case "nodeBeforeOp":case "nodeAfterOp":a:switch(d){case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":case "isOp":a=
|
|
547
|
+
iu(a,d,b,c);break a;case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");a=e&&f?3===e.g&&3===f.g?iu(a,gu[d],b,c):3===e.g?ju(a,"firstOperand","secondOperand",gu[d],b,c):3===f.g?ju(a,"secondOperand","firstOperand",hu[gu[d]],b,c):sr("General comparison for sequences is not implemented"):sr("types of compare are not known");break a;default:a=sr(`Unsupported compare type: ${d}`)}return[a,
|
|
548
|
+
null];case "functionCallExpr":return[xu(a,b,c),null];default:return[sr(`Unsupported: the base expression '${d}'.`),null]}};function vr(a,b,c){return Z(b,d=>{var e=a.o.get(d);e||(e=lu(a,c),e=Y(e,d.ua,[...d.H,`const ${e} = ${d.code};`]),a.o.set(d,e),a.o.set(e,e));return e})}function lu(a,b="v"){const c=a.v.get(b)||0;a.v.set(b,c+1);return`${b}${c}`}function ku(a,b){b=Y(b,{type:0},[]);a.o.set(b,b);return b}var Wu=class{constructor(a,b){this.o=new Map;this.v=new Map;this.$=a;this.D=b;this.h=Vu}};function Xu(a){const b=K(a,"*");if("pathExpr"===a[0])return!0;for(const c of b)if(Xu(c))return!0;return!1};function Yu(a,b,c){c=c||{};b=b||0;if("string"===typeof a){a=Pk(a);var d={Z:"XQuery3.1"===c.language||"XQueryUpdate3.1"===c.language,debug:!1};try{var e=uq(a,d)}catch(h){gg(a,h)}}else e=Kk(a);a=F(e,"mainModule");if(!a)return sr("Unsupported: XQuery Library modules are not supported.");if(F(a,"prolog"))return sr("Unsupported: XQuery Prologs are not supported.");d=void 0===c.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":c.defaultFunctionNamespaceURI;a=new Wu(c.namespaceResolver||
|
|
549
|
+
Rq(null),d);c=new qh(new Bg(new pg(a.$,{},d,c.functionNameResolver||Sq("http://www.w3.org/2005/xpath-functions"))));O(e,c);if(c=F(e,"mainModule"))if(F(c,"prolog"))a=sr("Unsupported: XQuery.");else{var f=J(c,["queryBody","*"]);c=ku(a,"contextItem");[d]=a.h(f,c,a);b:switch(f=I(f,"type"),b){case 9:b=ur(d,c,a);a=zr(b,f,a);break b;case 7:a=Ar(d,f,c,a);break b;case 3:a=wr(d,f,c,a);break b;case 2:a=yr(d,f,c,a);break b;default:a=sr(`Unsupported: the return type '${b}'.`)}a.isAstAccepted&&(a=`
|
|
550
|
+
${a.H.join("\n")}
|
|
551
|
+
return ${a.code};`,b="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",Xu(e)&&(b+='\n\t\tif (!contextItem) {\n\t\t\tthrow errXPDY0002("Context is needed to evaluate the given path expression.");\n\t\t}\n\n\t\tif (!contextItem.nodeType) {\n\t\t\tthrow new Error("Context item must be subtype of node().");\n\t\t}\n\t\t'),a={code:b+(a+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else a=sr("Unsupported: Can not execute a library module.");
|
|
552
|
+
return a};class Zu extends Error{constructor(a,b,c){var d=a.stack;d&&(d.includes(a.message)&&(d=d.substr(d.indexOf(a.message)+a.message.length).trim()),d=d.split("\n"),d.splice(10),d=d.map(e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`),d=d.join("\n"));super(`Custom XPath function Q{${c}}${b} raised:\n${a.message}\n${d}`)}}
|
|
553
|
+
function $u(a,b,c){return 0===b.g?a.F()?null:Vq(a.first(),c).next(0).value:2===b.g||1===b.g?a.O().map(d=>{if(v(d.type,47))throw Error("Cannot pass attribute nodes to custom functions");return Vq(d,c).next(0).value}):Vq(a.first(),c).next(0).value}
|
|
554
|
+
function av(a){if("object"===typeof a)return a;a=a.split(":");if(2!==a.length)throw Error("Do not register custom functions in the default function namespace");const [b,c]=a;a=og[b];if(!a){a=`generated_namespace_uri_${b}`;if(og[b])throw Error("Prefix already registered: Do not register the same prefix twice.");og[b]=a}return{localName:c,namespaceURI:a}}
|
|
555
|
+
function bv(a,b,c,d){const {namespaceURI:e,localName:f}=av(a);if(!e)throw ug();const h=b.map(l=>Ja(l)),k=Ja(c);ng(e,f,h,k,function(l,n,t){var u=Array.from(arguments);u.splice(0,3);u=u.map((G,N)=>$u(G,h[N],n));const z={currentContext:n.o,domFacade:n.h.h};let y;try{y=d.apply(void 0,[z,...u])}catch(G){throw new Zu(G,f,e);}return y&&"object"===typeof y&&Object.getOwnPropertySymbols(y).includes(Pq)?w.create(y.zb):Wb(n.h,y,k)})};var cv={callFunction(a,b,c,d,e){const f=mg(b,c,d.length);if(!f)throw Error("function not found for codegen function call");b=new cc({M:null,Aa:0,ta:w.empty(),ra:{}});const h=new nb(a);a=new ic(!1,!1,h,null,null,e?e.currentContext:null,null);d=f.callFunction(b,a,null,...d.map((k,l)=>Wb(h,k,f.j[l])));return $u(d,{type:59,g:0},a)},errXPDY0002:lc};var dv=(a,b,c,d)=>{c=c?c:new Za;return a()(null!==b&&void 0!==b?b:null,c,cv,d)};const ev={["http://www.w3.org/2005/XQueryX"]:"xqx",["http://www.w3.org/2007/xquery-update-10"]:"xquf",["http://fontoxml.com/fontoxpath"]:"x"};
|
|
556
|
+
function fv(a,b){switch(a){case "copySource":case "insertAfter":case "insertAsFirst":case "insertAsLast":case "insertBefore":case "insertInto":case "modifyExpr":case "newNameExpr":case "replacementExpr":case "replaceValue":case "returnExpr":case "sourceExpr":case "targetExpr":case "transformCopies":case "transformCopy":return{localName:a,lb:b||"http://www.w3.org/2005/XQueryX"};case "deleteExpr":case "insertExpr":case "renameExpr":case "replaceExpr":case "transformExpr":return{localName:a,lb:"http://www.w3.org/2007/xquery-update-10"};
|
|
557
|
+
case "x:stackTrace":return{localName:"stackTrace",lb:"http://fontoxml.com/fontoxpath"};default:return{localName:a,lb:"http://www.w3.org/2005/XQueryX"}}}
|
|
558
|
+
function gv(a,b,c,d,e){if("string"===typeof c)return 0===c.length?null:b.createTextNode(c);if(!Array.isArray(c))throw new TypeError("JsonML element should be an array or string");var f=fv(c[0],d);d=f.localName;f=f.lb;const h=b.createElementNS(f,ev[f]+":"+d),k=c[1];var l=1;if("object"===typeof k&&!Array.isArray(k)){if(null!==k)for(var n of Object.keys(k))l=k[n],null!==l&&("type"===n?void 0!==l&&a.setAttributeNS(h,f,"fontoxpath:"+n,Ha(l)):("start"!==n&&"end"!==n&&"comment"!==n||"stackTrace"!==d||(l=
|
|
559
|
+
JSON.stringify(l)),e&&"prefix"===n&&""===l||a.setAttributeNS(h,f,ev[f]+":"+n,l)));l=2}for(let t=l,u=c.length;t<u;++t)n=gv(a,b,c[t],f,e),null!==n&&a.insertBefore(h,n,null);return h}
|
|
560
|
+
function hv(a,b,c,d=ab){a=Pk(a);let e;try{e=uq(a,{Z:"XQuery3.1"===b.language||"XQueryUpdate3.1"===b.language,debug:b.debug})}catch(l){gg(a,l)}var f=new pg(b.namespaceResolver||(()=>null),{},void 0===b.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":b.defaultFunctionNamespaceURI,b.functionNameResolver||(()=>null));f=new Bg(f);var h=F(e,["mainModule","libraryModule"]),k=F(h,"moduleDecl");if(k){const l=H(F(k,"prefix"));k=H(F(k,"uri"));Fg(f,l,k)}(h=F(h,"prolog"))&&xq(h,f,!1,a);!1!==
|
|
561
|
+
b.annotateAst&&ih(e,new qh(f));f=new Za;b=gv(d,c,e,null,!1===b.mc);d.insertBefore(b,c.createComment(a),f.getFirstChild(b));return b};function iv(a){return Promise.resolve(a)};function jv(a,b={debug:!1}){try{var c=uq(a,{Z:!0,debug:b.debug})}catch(f){gg(a,f)}ih(c,new qh);b=F(c,"libraryModule");if(!b)throw Error("XQuery module must be declared in a library module.");c=F(b,"moduleDecl");var d=F(c,"uri");const e=H(d);c=F(c,"prefix");d=H(c);c=new Bg(new pg(()=>null,Object.create(null),"http://www.w3.org/2005/xpath-functions",Sq("http://www.w3.org/2005/xpath-functions")));Fg(c,d,e);b=F(b,"prolog");if(null!==b){let f;try{f=xq(b,c,!0,a)}catch(h){gg(a,h)}f.Ia.forEach(({namespaceURI:h})=>
|
|
562
|
+
{if(e!==h)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.");});Mk(e,f)}else Mk(e,{Ia:[],Ta:[],pa:null,source:a});return e};const kv=new Map;function lv(a){var b;a:{if(b=Gk.get(a))for(const c of Object.keys(b))if(b[c]&&b[c].length){b=b[c][0].h;break a}b=null}if(b)return b;if(kv.has(a))return kv.get(a);b="string"===typeof a?uq(a,{Z:!1}):Kk(a);b=J(b,["mainModule","queryBody","*"]);if(null===b)throw Error("Library modules do not have a specificity");b=Fk(b,{sa:!1,Z:!1});kv.set(a,b);return b}function mv(a){return lv(a).D()}function nv(a,b){return tf(lv(a).o,lv(b).o)}var ov=new Za;
|
|
563
|
+
"undefined"!==typeof fontoxpathGlobal&&(fontoxpathGlobal.compareSpecificity=nv,fontoxpathGlobal.compileXPathToJavaScript=Yu,fontoxpathGlobal.domFacade=ov,fontoxpathGlobal.evaluateXPath=dr,fontoxpathGlobal.evaluateXPathToArray=ir,fontoxpathGlobal.evaluateXPathToAsyncIterator=er,fontoxpathGlobal.evaluateXPathToBoolean=jr,fontoxpathGlobal.evaluateXPathToFirstNode=kr,fontoxpathGlobal.evaluateXPathToMap=lr,fontoxpathGlobal.evaluateXPathToNodes=mr,fontoxpathGlobal.evaluateXPathToNumber=nr,fontoxpathGlobal.evaluateXPathToNumbers=
|
|
564
|
+
or,fontoxpathGlobal.evaluateXPathToString=pr,fontoxpathGlobal.evaluateXPathToStrings=qr,fontoxpathGlobal.evaluateUpdatingExpression=gr,fontoxpathGlobal.evaluateUpdatingExpressionSync=hr,fontoxpathGlobal.executeJavaScriptCompiledXPath=dv,fontoxpathGlobal.executePendingUpdateList=rr,fontoxpathGlobal.getBucketForSelector=mv,fontoxpathGlobal.getBucketsForNode=Ya,fontoxpathGlobal.precompileXPath=iv,fontoxpathGlobal.registerXQueryModule=jv,fontoxpathGlobal.registerCustomXPathFunction=bv,fontoxpathGlobal.parseScript=
|
|
565
|
+
hv,fontoxpathGlobal.profiler=ar,fontoxpathGlobal.createTypedValueFactory=Qq,fontoxpathGlobal.finalizeModuleRegistration=Ok,fontoxpathGlobal.Language=cr,fontoxpathGlobal.ReturnType=Xq);
|
|
566
|
+
return fontoxpathGlobal;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
)
|
|
570
|
+
.call(typeof window === 'undefined' ? undefined : window, xspattern, prsc);
|
|
571
|
+
export const compareSpecificity = fontoxpath.compareSpecificity;
|
|
572
|
+
export const compileXPathToJavaScript = fontoxpath.compileXPathToJavaScript;
|
|
573
|
+
export const createTypedValueFactory = fontoxpath.createTypedValueFactory;
|
|
574
|
+
export const domFacade = fontoxpath.domFacade;
|
|
575
|
+
export const evaluateUpdatingExpression = fontoxpath.evaluateUpdatingExpression;
|
|
576
|
+
export const evaluateUpdatingExpressionSync = fontoxpath.evaluateUpdatingExpressionSync;
|
|
577
|
+
export const evaluateXPath = fontoxpath.evaluateXPath;
|
|
578
|
+
export const evaluateXPathToArray = fontoxpath.evaluateXPathToArray;
|
|
579
|
+
export const evaluateXPathToAsyncIterator = fontoxpath.evaluateXPathToAsyncIterator;
|
|
580
|
+
export const evaluateXPathToBoolean = fontoxpath.evaluateXPathToBoolean;
|
|
581
|
+
export const evaluateXPathToFirstNode = fontoxpath.evaluateXPathToFirstNode;
|
|
582
|
+
export const evaluateXPathToMap = fontoxpath.evaluateXPathToMap;
|
|
583
|
+
export const evaluateXPathToNodes = fontoxpath.evaluateXPathToNodes;
|
|
584
|
+
export const evaluateXPathToNumber = fontoxpath.evaluateXPathToNumber;
|
|
585
|
+
export const evaluateXPathToNumbers = fontoxpath.evaluateXPathToNumbers;
|
|
586
|
+
export const evaluateXPathToString = fontoxpath.evaluateXPathToString;
|
|
587
|
+
export const evaluateXPathToStrings = fontoxpath.evaluateXPathToStrings;
|
|
588
|
+
export const executeJavaScriptCompiledXPath = fontoxpath.executeJavaScriptCompiledXPath;
|
|
589
|
+
export const executePendingUpdateList = fontoxpath.executePendingUpdateList;
|
|
590
|
+
export const finalizeModuleRegistration = fontoxpath.finalizeModuleRegistration;
|
|
591
|
+
export const getBucketForSelector = fontoxpath.getBucketForSelector;
|
|
592
|
+
export const getBucketsForNode = fontoxpath.getBucketsForNode;
|
|
593
|
+
export const Language = fontoxpath.Language;
|
|
594
|
+
export const parseScript = fontoxpath.parseScript;
|
|
595
|
+
export const precompileXPath = fontoxpath.precompileXPath;
|
|
596
|
+
export const profiler = fontoxpath.profiler;
|
|
597
|
+
export const registerCustomXPathFunction = fontoxpath.registerCustomXPathFunction;
|
|
598
|
+
export const registerXQueryModule = fontoxpath.registerXQueryModule;
|
|
599
|
+
export const ReturnType = fontoxpath.ReturnType;
|
|
600
|
+
export default fontoxpath;
|