@beltype/cli 0.1.7 → 0.1.9
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/README.md +13 -6
- package/assets/merge/NOTICE +7 -0
- package/assets/merge/merge.js +106 -0
- package/dist/src/check.js +127 -13
- package/dist/src/compare.js +47 -8
- package/dist/src/flags.js +2 -2
- package/dist/src/in-page.js +33 -6
- package/dist/src/main.js +24 -13
- package/dist/src/merge-tab.js +139 -0
- package/dist/src/print.js +12 -6
- package/dist/src/run.js +24 -5
- package/dist/src/serve.js +252 -57
- package/package.json +19 -7
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var ax=Object.defineProperty;var zs=(m,h)=>{for(var d in h)ax(m,d,{get:h[d],enumerable:!0})};var Bi={};zs(Bi,{Language:()=>hB,ReturnType:()=>wB,compareSpecificity:()=>Qx,compileXPathToJavaScript:()=>Jx,createTypedValueFactory:()=>Kx,default:()=>xi,domFacade:()=>bx,evaluateUpdatingExpression:()=>Vx,evaluateUpdatingExpressionSync:()=>Zx,evaluateXPath:()=>_x,evaluateXPathToArray:()=>Wx,evaluateXPathToAsyncIterator:()=>zx,evaluateXPathToBoolean:()=>eB,evaluateXPathToFirstNode:()=>tB,evaluateXPathToMap:()=>nB,evaluateXPathToNodes:()=>rB,evaluateXPathToNumber:()=>oB,evaluateXPathToNumbers:()=>aB,evaluateXPathToString:()=>vi,evaluateXPathToStrings:()=>sB,executeJavaScriptCompiledXPath:()=>iB,executePendingUpdateList:()=>uB,finalizeModuleRegistration:()=>lB,getBucketForSelector:()=>cB,getBucketsForNode:()=>pB,parseScript:()=>fB,precompileXPath:()=>mB,profiler:()=>dB,registerCustomXPathFunction:()=>gB,registerXQueryModule:()=>yB});var pi={};zs(pi,{compile:()=>wx});function Er(m,h,d,y){let E={op:h,func:d,data:y};return m.push(E),E}function sx(m,h){return m}var ei=class{constructor(){this.program=[]}test(h,d){return Er(this.program,5,h,d===void 0?null:d)}jump(h){return Er(this.program,3,null,h)}record(h,d){return Er(this.program,4,d===void 0?sx:d,h)}bad(h=1){return Er(this.program,1,null,h)}accept(){return Er(this.program,0,null,null)}fail(h){return Er(this.program,2,h||null,null)}},ti=class m{constructor(h,d,y){this.programLength=h,this.maxFromByPc=d,this.maxSurvivorFromByPc=y}static fromProgram(h){let d=h.length,y=[],E=[];return h.forEach(I=>{y.push(0),E.push(0)}),h.forEach((I,F)=>{switch(I.op){case 2:if(I.func===null)return;if(F+1>=d)throw new Error("Invalid program: program could run past end");y[F+1]+=1;break;case 1:case 4:if(F+1>=d)throw new Error("Invalid program: program could run past end");y[F+1]+=1;break;case 3:I.data.forEach(j=>{if(j<0||j>=d)throw new Error("Invalid program: program could run past end");y[j]+=1});break;case 5:if(F+1>=d)throw new Error("Invalid program: program could run past end");E[F+1]+=1;break;case 0:E[F]+=1}}),new m(d,y,E)}static createStub(h){let d=[],y=[];for(let E=0;E<h;++E)d.push(h),y.push(h);return new m(h,d,y)}},ni=class{constructor(h){this.acceptingTraces=h,this.success=h.length>0}},ra=class{constructor(h){this.t=0,this.i=0,this.h=new Uint16Array(h),this.l=new Uint8Array(h)}getBadness(h){return this.l[h]}add(h,d){this.l[h]=d>255?255:d;let y=(function(E,I,F,j,Y){let L=j,ce=Y;for(;L<ce;){let fe=L+ce>>>1;F<I[E[fe]]?ce=fe:L=fe+1}return L})(this.h,this.l,d,this.i,this.t);this.h.copyWithin(y+1,y,this.t),this.h[y]=h,this.t+=1}reschedule(h,d){let y=Math.max(this.l[h],d>255?255:d);if(this.l[h]!==y){let E=this.h.indexOf(h,this.i);if(E<0||E>=this.t)return void(this.l[h]=y);this.h.copyWithin(E,E+1,this.t),this.t-=1,this.add(h,y)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}},oa=class{constructor(h){this.o=[];let d=h.length;h.forEach(y=>{this.o.push(y>0?d:-1),d+=y}),this.u=new Uint16Array(d)}clear(){this.u.fill(0,0,this.o.length)}add(h,d){let y=this.u[d],E=this.o[d];this.u[d]+=1,this.u[E+y]=h}has(h){return this.u[h]>0}forEach(h,d){let y=this.u[h],E=this.o[h];for(let I=E;I<E+y;++I)d(this.u[I])}};function ri(m,h,d=!1){return m===null?h:Array.isArray(m)?(m.indexOf(h)===-1&&(d&&(m=m.slice()),m.push(h)),m):m===h?m:[m,h]}var hn=class{constructor(h,d){this.prefixes=h,this.record=d}};function qp(m,h){let d;if(h===null){if(!Array.isArray(m))return m;d=m}else d=m===hn.EMPTY?[]:Array.isArray(m)?m:[m];return new hn(d,h)}hn.EMPTY=new hn([],null);var oi=class{constructor(h){this.p=[],this.v=[];for(let d=0;d<h;++d)this.p.push(0),this.v.push(null)}mergeTraces(h,d,y,E,I,F){let j=!1;return y.forEach(d,Y=>{let L=this.trace(Y,E,I,F);var ce,fe,Je;fe=L,Je=j,h=(ce=h)===null?fe:fe===null?ce:Array.isArray(fe)?fe.reduce((yt,ae)=>ri(yt,ae,yt===fe),ce):ri(ce,fe,Je),j=h===L}),h}trace(h,d,y,E){switch(this.p[h]){case 2:return this.v[h];case 1:return null}this.p[h]=1;let I=null,F=d[h];if(F!==null)I=F;else if(!y.has(h))throw new Error("Trace without source at pc "+h);if(I=this.mergeTraces(I,h,y,d,y,E),I!==null){let j=E[h];j!==null&&(I=qp(I,j))}return this.v[h]=I,this.p[h]=2,I}buildSurvivorTraces(h,d,y,E,I){for(let F=0,j=h.length;F<j;++F){if(!y.has(F)){d[F]=null;continue}this.v.fill(null),this.p.fill(0);let Y=this.mergeTraces(null,F,y,h,E,I);if(Y===null)throw new Error("No non-cyclic paths found to survivor "+F);d[F]=qp(Y,null)}this.v.fill(null)}},ai=class{constructor(h){this.g=[],this.k=[],this.m=[],this.A=new oa(h.maxFromByPc),this.T=new oa(h.maxSurvivorFromByPc),this.S=new oi(h.programLength);for(let d=0;d<h.programLength;++d)this.g.push(null),this.k.push(null),this.m.push(null);this.k[0]=hn.EMPTY}reset(h){this.A.clear(),this.T.clear(),this.g.fill(null),h&&(this.k.fill(null),this.m.fill(null),this.k[0]=hn.EMPTY)}record(h,d){this.g[h]=d}has(h){return this.A.has(h)||this.k[h]!==null}add(h,d){this.A.add(h,d)}hasSurvivor(h){return this.T.has(h)}addSurvivor(h,d){this.T.add(h,d)}buildSurvivorTraces(){let h=this.k;this.S.buildSurvivorTraces(h,this.m,this.T,this.A,this.g),this.k=this.m,this.m=h}getTraces(h){let d=h.reduce((y,E)=>ri(y,this.k[E]),null);return d===null?[]:Array.isArray(d)?d:[d]}},aa=class{constructor(h){this.I=[],this.N=new ra(h.programLength),this.M=new ra(h.programLength),this.P=new ai(h)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(h,d,y){let E=this.P.has(d);this.P.add(h,d);let I=this.N.getBadness(h)+y;E?this.N.reschedule(d,I):this.N.add(d,I)}stepToNextGeneration(h,d){let y=this.P.hasSurvivor(d);this.P.addSurvivor(h,d);let E=this.N.getBadness(h);y?this.M.reschedule(d,E):this.M.add(d,E)}accept(h){this.I.push(h),this.P.addSurvivor(h,h)}fail(h){}record(h,d){this.P.record(h,d)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);let h=this.N;h.reset(),this.N=this.M,this.M=h}getAcceptingTraces(){return this.P.getTraces(this.I)}},si=class{constructor(h){this.U=[],this.G=h,this.V=ti.fromProgram(h),this.U.push(new aa(this.V))}execute(h,d){let y=this.U.pop()||new aa(this.V);y.reset();let E=h.length,I,F=-1;do{let Y=y.getNextThreadPc();if(Y===null)break;for(++F,I=F>=E?null:h[F];Y!==null;){let L=this.G[Y];switch(L.op){case 0:I===null?y.accept(Y):y.fail(Y);break;case 2:{let ce=L.func;if(ce===null||ce(d)){y.fail(Y);break}y.step(Y,Y+1,0);break}case 1:y.step(Y,Y+1,L.data);break;case 5:if(I===null){y.fail(Y);break}if(!(0,L.func)(I,L.data,d)){y.fail(Y);break}y.stepToNextGeneration(Y,Y+1);break;case 3:{let ce=L.data,fe=ce.length;if(fe===0){y.fail(Y);break}for(let Je=0;Je<fe;++Je)y.step(Y,ce[Je],0);break}case 4:{let ce=(0,L.func)(L.data,F,d);ce!=null&&y.record(Y,ce),y.step(Y,Y+1,0);break}}Y=y.getNextThreadPc()}y.nextGeneration()}while(I!==null);let j=new ni(y.getAcceptingTraces());return y.reset(),this.U.push(y),j}};function Qp(m){let h=new ei;return m(h),new si(h.program)}function it(m){return h=>h===m}function Ce(m,h){if(m===null||h===null)throw new Error("unescaped hyphen may not be used as a range endpoint");if(h<m)throw new Error("character range is in the wrong order");return d=>m<=d&&d<=h}function ix(m){return!0}function Jp(){return!1}function fn(m,h){return d=>m(d)||h(d)}function no(m,h){switch(h.kind){case"predicate":return void m.test(h.value);case"regexp":return void e0(m,h.value,!1)}}function ux(m,h){h.forEach(d=>{(function(y,E){let[I,{min:F,max:j}]=E;if(j!==null){for(let Y=0;Y<F;++Y)no(y,I);for(let Y=F;Y<j;++Y){let L=y.jump([]);L.data.push(y.program.length),no(y,I),L.data.push(y.program.length)}}else if(F>0){for(let L=0;L<F-1;++L)no(y,I);let Y=y.program.length;no(y,I),y.jump([Y]).data.push(y.program.length)}else{let Y=y.program.length,L=y.jump([]);L.data.push(y.program.length),no(y,I),y.jump([Y]),L.data.push(y.program.length)}})(m,d)})}function e0(m,h,d){let y=m.program.length,E=m.jump([]);d&&(E.data.push(m.program.length),m.test(()=>!0),m.jump([y]));let I=[];if(h.forEach(F=>{E.data.push(m.program.length),ux(m,F),I.push(m.jump([]))}),I.forEach(F=>{F.data.push(m.program.length)}),d){let F=m.program.length,j=m.jump([]);j.data.push(m.program.length),m.test(()=>!0),m.jump([F]),j.data.push(m.program.length)}}function Zt(m,h){return{success:!0,offset:m,value:h}}function t0(m){return Zt(m,void 0)}function jn(m,h,d=!1){return{success:!1,offset:m,expected:h,fatal:d}}function Fe(m){return(h,d)=>{let y=d+m.length;return h.slice(d,y)===m?Zt(y,m):jn(d,[m])}}function le(m,h){return(d,y)=>{let E=m(d,y);return E.success?Zt(E.offset,h(E.value)):E}}function kn(m,h,d,y){return(E,I)=>{let F=m(E,I);return F.success?h(F.value)?F:jn(I,d,y):F}}function Ge(m,h){return(d,y)=>{let E=null;for(let I of m){let F=I(d,y);if(F.success||(E===null||F.offset>E.offset?E=F:F.offset===E.offset&&h===void 0&&(E.expected=E.expected.concat(F.expected)),F.fatal))return F}return h=h||E?.expected||[],E&&(E.expected=h),E||jn(y,h)}}function ro(m){return(h,d)=>{let y=m(h,d);return y.success||y.fatal?y:Zt(d,null)}}function fa(m){return(h,d)=>{let y=[],E=d;for(;;){let I=m(h,E);if(!I.success){if(I.fatal)return I;break}if(y.push(I.value),I.offset===E)break;E=I.offset}return Zt(E,y)}}function Ze(m,h,d){return(y,E)=>{let I=m(y,E);if(!I.success)return I;let F=h(y,I.offset);return F.success?Zt(F.offset,d(I.value,F.value)):F}}function Kp(m){return Ze(m,fa(m),(h,d)=>[h].concat(d))}function n0(m,h){return m}function lx(m,h){return h}function st(m,h){return Ze(m,h,lx)}function ma(m,h){return Ze(m,h,n0)}function Hn(m,h,d,y=!1){return st(m,y?r0(ma(h,d)):ma(h,d))}function ii(m,h){return(d,y)=>m(d,y).success?jn(y,h):t0(y)}function r0(m){return(h,d)=>{let y=m(h,d);return y.success?y:jn(y.offset,y.expected,!0)}}var cx=(m,h)=>m.length===h?t0(h):jn(h,["end of input"]),bp=["Lu","Ll","Lt","Lm","Lo","Mn","Mc","Me","Nd","Nl","No","Pc","Pd","Ps","Pe","Pi","Pf","Po","Zs","Zl","Zp","Sm","Sc","Sk","So","Cc","Cf","Co","Cn"],Ir={};function Pe(m){return m.codePointAt(0)}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach((m,h)=>{Ir[m]=h});var o0=m=>m===-1||m===-2;function $n(m){return h=>!o0(h)&&!m(h)}function a0(m,h){return h===null?m:d=>m(d)&&!h(d)}var px=(function(m,h){let d=new Map,y=0;return m.forEach((E,I)=>{let F=h[I];E!==null&&E.split("|").forEach(j=>{let Y=d.get(j),L=Ce(y,y+F-1);d.set(j,Y?fn(Y,L):L)}),y+=F}),d})(["BasicLatin","Latin-1Supplement","LatinExtended-A","LatinExtended-B","IPAExtensions","SpacingModifierLetters","CombiningDiacriticalMarks","GreekandCoptic|Greek","Cyrillic","CyrillicSupplement","Armenian","Hebrew","Arabic","Syriac","ArabicSupplement","Thaana","NKo","Samaritan","Mandaic","SyriacSupplement","ArabicExtended-B","ArabicExtended-A","Devanagari","Bengali","Gurmukhi","Gujarati","Oriya","Tamil","Telugu","Kannada","Malayalam","Sinhala","Thai","Lao","Tibetan","Myanmar","Georgian","HangulJamo","Ethiopic","EthiopicSupplement","Cherokee","UnifiedCanadianAboriginalSyllabics","Ogham","Runic","Tagalog","Hanunoo","Buhid","Tagbanwa","Khmer","Mongolian","UnifiedCanadianAboriginalSyllabicsExtended","Limbu","TaiLe","NewTaiLue","KhmerSymbols","Buginese","TaiTham","CombiningDiacriticalMarksExtended","Balinese","Sundanese","Batak","Lepcha","OlChiki","CyrillicExtended-C","GeorgianExtended","SundaneseSupplement","VedicExtensions","PhoneticExtensions","PhoneticExtensionsSupplement","CombiningDiacriticalMarksSupplement","LatinExtendedAdditional","GreekExtended","GeneralPunctuation","SuperscriptsandSubscripts","CurrencySymbols","CombiningDiacriticalMarksforSymbols|CombiningMarksforSymbols","LetterlikeSymbols","NumberForms","Arrows","MathematicalOperators","MiscellaneousTechnical","ControlPictures","OpticalCharacterRecognition","EnclosedAlphanumerics","BoxDrawing","BlockElements","GeometricShapes","MiscellaneousSymbols","Dingbats","MiscellaneousMathematicalSymbols-A","SupplementalArrows-A","BraillePatterns","SupplementalArrows-B","MiscellaneousMathematicalSymbols-B","SupplementalMathematicalOperators","MiscellaneousSymbolsandArrows","Glagolitic","LatinExtended-C","Coptic","GeorgianSupplement","Tifinagh","EthiopicExtended","CyrillicExtended-A","SupplementalPunctuation","CJKRadicalsSupplement","KangxiRadicals",null,"IdeographicDescriptionCharacters","CJKSymbolsandPunctuation","Hiragana","Katakana","Bopomofo","HangulCompatibilityJamo","Kanbun","BopomofoExtended","CJKStrokes","KatakanaPhoneticExtensions","EnclosedCJKLettersandMonths","CJKCompatibility","CJKUnifiedIdeographsExtensionA","YijingHexagramSymbols","CJKUnifiedIdeographs","YiSyllables","YiRadicals","Lisu","Vai","CyrillicExtended-B","Bamum","ModifierToneLetters","LatinExtended-D","SylotiNagri","CommonIndicNumberForms","Phags-pa","Saurashtra","DevanagariExtended","KayahLi","Rejang","HangulJamoExtended-A","Javanese","MyanmarExtended-B","Cham","MyanmarExtended-A","TaiViet","MeeteiMayekExtensions","EthiopicExtended-A","LatinExtended-E","CherokeeSupplement","MeeteiMayek","HangulSyllables","HangulJamoExtended-B","HighSurrogates","HighPrivateUseSurrogates","LowSurrogates","PrivateUseArea|PrivateUse","CJKCompatibilityIdeographs","AlphabeticPresentationForms","ArabicPresentationForms-A","VariationSelectors","VerticalForms","CombiningHalfMarks","CJKCompatibilityForms","SmallFormVariants","ArabicPresentationForms-B","HalfwidthandFullwidthForms","Specials","LinearBSyllabary","LinearBIdeograms","AegeanNumbers","AncientGreekNumbers","AncientSymbols","PhaistosDisc",null,"Lycian","Carian","CopticEpactNumbers","OldItalic","Gothic","OldPermic","Ugaritic","OldPersian",null,"Deseret","Shavian","Osmanya","Osage","Elbasan","CaucasianAlbanian","Vithkuqi",null,"LinearA","LatinExtended-F",null,"CypriotSyllabary","ImperialAramaic","Palmyrene","Nabataean",null,"Hatran","Phoenician","Lydian",null,"MeroiticHieroglyphs","MeroiticCursive","Kharoshthi","OldSouthArabian","OldNorthArabian",null,"Manichaean","Avestan","InscriptionalParthian","InscriptionalPahlavi","PsalterPahlavi",null,"OldTurkic",null,"OldHungarian","HanifiRohingya",null,"RumiNumeralSymbols","Yezidi","ArabicExtended-C","OldSogdian","Sogdian","OldUyghur","Chorasmian","Elymaic","Brahmi","Kaithi","SoraSompeng","Chakma","Mahajani","Sharada","SinhalaArchaicNumbers","Khojki",null,"Multani","Khudawadi","Grantha",null,"Newa","Tirhuta",null,"Siddham","Modi","MongolianSupplement","Takri",null,"Ahom",null,"Dogra",null,"WarangCiti","DivesAkuru",null,"Nandinagari","ZanabazarSquare","Soyombo","UnifiedCanadianAboriginalSyllabicsExtended-A","PauCinHau","DevanagariExtended-A",null,"Bhaiksuki","Marchen",null,"MasaramGondi","GunjalaGondi",null,"Makasar","Kawi",null,"LisuSupplement","TamilSupplement","Cuneiform","CuneiformNumbersandPunctuation","EarlyDynasticCuneiform",null,"Cypro-Minoan","EgyptianHieroglyphs","EgyptianHieroglyphFormatControls",null,"AnatolianHieroglyphs",null,"BamumSupplement","Mro","Tangsa","BassaVah","PahawhHmong",null,"Medefaidrin",null,"Miao",null,"IdeographicSymbolsandPunctuation","Tangut","TangutComponents","KhitanSmallScript","TangutSupplement",null,"KanaExtended-B","KanaSupplement","KanaExtended-A","SmallKanaExtension","Nushu",null,"Duployan","ShorthandFormatControls",null,"ZnamennyMusicalNotation",null,"ByzantineMusicalSymbols","MusicalSymbols","AncientGreekMusicalNotation",null,"KaktovikNumerals","MayanNumerals","TaiXuanJingSymbols","CountingRodNumerals",null,"MathematicalAlphanumericSymbols","SuttonSignWriting",null,"LatinExtended-G","GlagoliticSupplement","CyrillicExtended-D",null,"NyiakengPuachueHmong",null,"Toto","Wancho",null,"NagMundari",null,"EthiopicExtended-B","MendeKikakui",null,"Adlam",null,"IndicSiyaqNumbers",null,"OttomanSiyaqNumbers",null,"ArabicMathematicalAlphabeticSymbols",null,"MahjongTiles","DominoTiles","PlayingCards","EnclosedAlphanumericSupplement","EnclosedIdeographicSupplement","MiscellaneousSymbolsandPictographs","Emoticons","OrnamentalDingbats","TransportandMapSymbols","AlchemicalSymbols","GeometricShapesExtended","SupplementalArrows-C","SupplementalSymbolsandPictographs","ChessSymbols","SymbolsandPictographsExtended-A","SymbolsforLegacyComputing",null,"CJKUnifiedIdeographsExtensionB",null,"CJKUnifiedIdeographsExtensionC","CJKUnifiedIdeographsExtensionD","CJKUnifiedIdeographsExtensionE","CJKUnifiedIdeographsExtensionF",null,"CJKCompatibilityIdeographsSupplement",null,"CJKUnifiedIdeographsExtensionG","CJKUnifiedIdeographsExtensionH",null,"Tags",null,"VariationSelectorsSupplement",null,"SupplementaryPrivateUseArea-A|PrivateUse","SupplementaryPrivateUseArea-B|PrivateUse"],[128,128,128,208,96,80,112,144,256,48,96,112,256,80,48,64,64,64,32,16,48,96,128,128,128,128,128,128,128,128,128,128,128,128,256,160,96,256,384,32,96,640,32,96,32,32,32,32,128,176,80,80,48,96,32,32,144,80,128,64,64,80,48,16,48,16,48,128,64,64,256,256,112,48,48,48,80,64,112,256,256,64,32,160,128,32,96,256,192,48,16,256,128,128,256,256,96,32,128,48,80,96,32,128,128,224,16,16,64,96,96,48,96,16,32,48,16,256,256,6592,64,20992,1168,64,48,320,96,96,32,224,48,16,64,96,32,48,48,32,96,32,96,32,96,32,48,64,80,64,11184,80,896,128,1024,6400,512,80,688,16,16,16,32,32,144,240,16,128,128,64,80,64,48,128,32,64,32,48,32,48,32,64,32,80,48,48,80,48,64,80,64,384,64,64,64,32,32,48,48,32,32,32,64,32,96,96,32,32,32,64,64,32,32,48,80,80,48,128,64,288,32,64,64,48,64,64,48,32,128,80,48,80,48,96,32,80,48,48,80,128,128,128,96,160,128,96,32,80,48,80,176,80,80,96,96,64,96,80,96,16,64,96,160,112,80,64,96,80,304,32,96,80,16,64,1024,128,208,2624,112,1072,48,4e3,640,8576,576,48,96,48,144,688,96,96,160,64,32,6144,768,512,128,8816,16,256,48,64,400,2304,160,16,4688,208,48,256,256,80,112,32,32,96,32,128,1024,688,1104,256,48,96,112,80,320,48,64,464,48,736,32,224,32,96,784,80,64,80,176,256,256,48,112,96,256,256,768,80,48,128,128,128,256,256,112,144,256,1024,42720,32,4160,224,5776,7488,3088,544,1504,4944,4192,711760,128,128,240,65040,65536,65536]),io=(function(m){let h=new Map,d=m.split(""),y=bp.map(()=>[]),E=0,I=0;for(;I<d.length;){let j=Ir[d[I]],Y=(31&j)-2,L=1+Ir[d[I+1]];switch(32&j?(L+=Ir[d[I+2]]<<6,L+=Ir[d[I+3]]<<12,L+=Ir[d[I+4]]<<18,I+=5):I+=2,Y){case-2:{let ce=0;for(let fe=E;fe<E+L;++fe)y[ce].push(it(fe)),ce=(ce+1)%2;break}case-1:break;default:{let ce=y[Y];L===1?ce.push(it(E)):ce.push(Ce(E,E+L-1));break}}E+=L}let F=new Map;return bp.forEach((j,Y)=>{let L=y[Y].reduce(fn,Jp);h.set(j,L);let ce=j.charAt(0),fe=F.get(ce)||[];F.set(ce,fe),fe.push(L)}),F.forEach((j,Y)=>{h.set(Y,j.reduce(fn,Jp))}),h})("bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcATCGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKBEGXZAGFBAcBBFHHGoFAHXcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABGHBIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBBHAGAHCIDBAHCBAHDBGHBBAGCBBGABBGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBFGBBAGBHBBBKJBAGBIABLHBIBGIBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBAHAIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHGBAKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGRHCIABIGSHBIATBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcAHAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAHPBwHDIAGuHAIAHEIAHAIEHAIBGHBCKJTGaJHIaITBBAHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH/gVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYgBOHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBA6oBAACvDvABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMaBTCPAQAPAQAPAQAPAQAOABhaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGfajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm/mBAa/mUIFAFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDAPCCADBECADABADABADAADBXFCCADAGAFBDAGGHAGCHAGDHAGWIBHBIAaDHABCMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDIFAZBBDjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZQBPmqFAAQAPAaPG/BBG1BGaABfGLYAaCHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaMBCaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTACKBACOBACGBACBBADKBADOBADGBADBhCBAAm2EAABIGVBJGHBXFFBAFpBAFIhEBAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMeBAGpBAHBOABBGBhKBAAHCGcMJGABHGVHKMDTEBVGRHDTDBlGUMGBTGWBIIAHAIAG0HOTGBDMTKJHAGBHBGABIHCIAGsICHDIBHBTBcATDHABJcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBGABHGiHATBGABIHBIAGvICHIIBGDTDHDTAIAHAKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAGBHAB9GGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJTBBATAHAGCBdGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGATABFKJB1GaBBHCIBHDIAHEBDKJMBTCaAGGh4CAAGrICHIIAHBTAhjBAACfDfKJMIBLGHBBGABBGHBAGBBAGXIFBAIBBBHBIAHAGAIAGAIAHATCBIKJhFBAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBMmIBAABGTJh1DAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBBGHBGAIAGMBAGhIBHEBCIBHAIAHATMKJhVBAAGABOMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAhLpAAmgBAATBBMmvQAAcPHAGFHOhp+AAmGJAAh4GCAm4IAABGGeBAKJBDTBmOBAABAKJBFGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFAHABKIBBNm3fBABHmVTAABpGIhmLCAFDBAFGBAFBBAmiEAABOGABcGCBBGABNGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbJBAHtBBHWBI6zBAAB761DAABJamBBa7IBHCaCIFcHHHaBHGadHDa8BU6BBAAHCaAh5BAAMTBLMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPRAADJGADTBFDFhUDAAHGBAHQBBHGBAHBBAHEBEF9BgHAhvBAAGsBCHGFGBBKJBDGAaAh/EAAGdHABQGrHDKJBEYAhPHAAGaFAHDKJhlLAAGGBAGDBAGBBAGOBAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMM6gCAAB3acBMarBDaIBGaBBNaFhZCAA66DAAZE6XLAABDaQBCaMBC62BAABD6eBAABFaLBDaABOaLBDa3BHaJBFanBHadBBaBhNBAA6TFAABLaNBBaMBCaIBGatBAaGBHaNBDaIBGaIBG6SCAABAa2BkKJhFQAAmfbKABfm5ABABFmdDAABBmBaBABNmw0BAhewAAmdIAAhhXAAmKNBABEmfBBAhQxtCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA");function Vp(m){return m===32||m===9||m===10||m===13}var ci=[it(Pe(":")),Ce(Pe("A"),Pe("Z")),it(Pe("_")),Ce(Pe("a"),Pe("z")),Ce(192,214),Ce(216,246),Ce(192,214),Ce(216,246),Ce(248,767),Ce(880,893),Ce(895,8191),Ce(8204,8205),Ce(8304,8591),Ce(11264,12271),Ce(12289,55295),Ce(63744,64975),Ce(65008,65533),Ce(65536,983039)].reduce(fn),Zp=[ci,it(Pe("-")),it(Pe(".")),Ce(Pe("0"),Pe("9")),it(183),Ce(768,879),Ce(8255,8256)].reduce(fn),s0=io.get("Nd"),hx=$n(s0),i0=a0(Ce(0,1114111),[io.get("P"),io.get("Z"),io.get("C")].reduce(fn)),fx=$n(i0);function mx(m){return m!==10&&m!==13&&!o0(m)}var dx={s:Vp,S:$n(Vp),i:ci,I:$n(ci),c:Zp,C:$n(Zp),d:s0,D:hx,w:i0,W:fx},sa=Fe("*"),Nr=Fe("\\"),ia=Fe("{"),Tr=Fe("}"),ua=Fe("["),la=Fe("]"),oo=Fe("^"),_p=Fe("$"),Wp=Fe(","),Pn=Fe("-"),ca=Fe("("),pa=Fe(")"),ui=Fe("."),li=Fe("|"),ha=Fe("+"),ao=Fe("?"),gx=Fe("-["),so=Pe("0");function yx(m){function h(S){return new Set(S.split("").map(V=>Pe(V)))}function d(S,V){let De=S.codePointAt(V);return De===void 0?jn(V,["any character"]):Zt(V+String.fromCodePoint(De).length,De)}let y=m.language==="xpath"?st(Nr,Ge([le(Fe("n"),()=>10),le(Fe("r"),()=>13),le(Fe("t"),()=>9),le(Ge([Nr,li,ui,Pn,oo,ao,sa,ha,ia,Tr,_p,ca,pa,ua,la]),S=>Pe(S))])):st(Nr,Ge([le(Fe("n"),()=>10),le(Fe("r"),()=>13),le(Fe("t"),()=>9),le(Ge([Nr,li,ui,Pn,oo,ao,sa,ha,ia,Tr,ca,pa,ua,la]),S=>Pe(S))]));function E(S,V){let De=h(V);return Ze(Fe(S),ro(kn(d,Ue=>De.has(Ue),V.split(""))),(Ue,gn)=>(function(At){let f=io.get(At);if(f==null)throw new Error(At+" is not a valid unicode category");return f})(gn===null?Ue:Ue+String.fromCodePoint(gn)))}let I=Ge([E("L","ultmo"),E("M","nce"),E("N","dlo"),E("P","cdseifo"),E("Z","slp"),E("S","mcko"),E("C","cfon")]),F=[Ce(Pe("a"),Pe("z")),Ce(Pe("A"),Pe("Z")),Ce(Pe("0"),Pe("9")),it(45)].reduce(fn),j=Ge([I,le(st(Fe("Is"),(function(S){return(V,De)=>{let Ue=S(V,De);return Ue.success?Zt(Ue.offset,V.slice(De,Ue.offset)):Ue}})(Kp(kn(d,F,["block identifier"])))),S=>(function(V,De){let Ue=px.get(V);if(Ue===void 0){if(De)return ix;throw new Error(`The unicode block identifier "${V}" is not known.`)}return Ue})(S,m.language!=="xpath"))]),Y=Hn(Fe("\\p{"),j,Tr,!0),L=le(Hn(Fe("\\P{"),j,Tr,!0),$n),ce=st(Nr,le(Ge("sSiIcCdDwW".split("").map(S=>Fe(S))),S=>dx[S])),fe=le(ui,()=>mx),Je=Ge([ce,Y,L]),yt=h("\\[]"),ae=Ge([y,kn(d,S=>!yt.has(S),["unescaped character"])]),Ee=Ge([le(Pn,()=>null),ae]),je=Ze(Ee,st(Pn,Ee),Ce);function U(S,V){return[S].concat(V||[])}let R=le((function(S){return(V,De)=>{let Ue=S(V,De);return Ue.success?Zt(De,Ue.value):Ue}})(Ge([la,gx])),()=>null),Q=Pe("-"),ne=Ge([le(ma(ma(Pn,ii(ua,["not ["])),R),()=>Q),st(ii(Pn,["not -"]),ae)]),pe=Ge([Ze(le(ne,it),Ge([function(S,V){return pe(S,V)},R]),U),Ze(Ge([je,Je]),Ge([Ke,R]),U)]),v=Ge([Ze(le(ae,it),Ge([pe,R]),U),Ze(Ge([je,Je]),Ge([Ke,R]),U)]);function Ke(S,V){return v(S,V)}let ut=le(v,S=>S.reduce(fn)),Gr=le(st(oo,ut),$n),lo=Ze(Ge([st(ii(oo,["not ^"]),ut),Gr]),ro(st(Pn,(function(S,V){return X(S,V)}))),a0),X=Hn(ua,lo,la,!0),k=m.language==="xpath"?Ge([le(y,it),Je,X,fe,le(oo,()=>S=>S===-1),le(_p,()=>S=>S===-2)]):Ge([le(y,it),Je,X,fe]),co=m.language==="xpath"?h(".\\?*+{}()|^$[]"):h(".\\?*+{}()|[]"),g=kn(d,S=>!co.has(S),["NormalChar"]),da=le(st(Nr,Ze(le(kn(d,Ce(Pe("1"),Pe("9")),["digit"]),S=>S-so),fa(le(kn(d,Ce(so,Pe("9")),["digit"]),S=>S-so)),(S,V)=>{V.reduce((De,Ue)=>10*De+Ue,S)})),S=>{throw new Error("Backreferences in XPath patterns are not yet implemented.")}),Xn=m.language==="xpath"?Ge([le(g,S=>({kind:"predicate",value:it(S)})),le(k,S=>({kind:"predicate",value:S})),le(Hn(ca,st(ro(Fe("?:")),dn),pa,!0),S=>({kind:"regexp",value:S})),da]):Ge([le(g,S=>({kind:"predicate",value:it(S)})),le(k,S=>({kind:"predicate",value:S})),le(Hn(ca,dn,pa,!0),S=>({kind:"regexp",value:S}))]),mn=le(Kp(le(kn(d,Ce(so,Pe("9")),["digit"]),S=>S-so)),S=>S.reduce((V,De)=>10*V+De)),we=Ge([Ze(mn,st(Wp,mn),(S,V)=>{if(V<S)throw new Error("quantifier range is in the wrong order");return{min:S,max:V}}),Ze(mn,Wp,S=>({min:S,max:null})),le(mn,S=>({min:S,max:S}))]),ga=m.language==="xpath"?Ze(Ge([le(ao,()=>({min:0,max:1})),le(sa,()=>({min:0,max:null})),le(ha,()=>({min:1,max:null})),Hn(ia,we,Tr,!0)]),ro(ao),(S,V)=>S):Ge([le(ao,()=>({min:0,max:1})),le(sa,()=>({min:0,max:null})),le(ha,()=>({min:1,max:null})),Hn(ia,we,Tr,!0)]),wt=fa(Ze(Xn,le(ro(ga),S=>S===null?{min:1,max:1}:S),(S,V)=>[S,V])),lt=Ze(wt,fa(st(li,r0(wt))),(S,V)=>[S].concat(V));function dn(S,V){return lt(S,V)}let ya=(function(S){return Ze(S,cx,n0)})(lt);return function(S){let V;try{V=ya(S,0)}catch(De){throw new Error(`Error parsing pattern "${S}": ${De instanceof Error?De.message:De}`)}return V.success?V.value:(function(De,Ue,gn){let At=gn.map(f=>`"${f}"`);throw new Error(`Error parsing pattern "${De}" at offset ${Ue}: expected ${At.length>1?"one of "+At.join(", "):At[0]} but found "${De.slice(Ue,Ue+1)}"`)})(S,V.offset,V.expected)}}function zp(m){return[...m].map(h=>h.codePointAt(0))}function wx(m,h={language:"xsd"}){let d=yx(h)(m),y=Qp(E=>{e0(E,d,h.language==="xpath"),E.accept()});return function(E){let I=h.language==="xpath"?[-1,...zp(E),-2]:zp(E);return y.execute(I).success}}var Ai={};zs(Ai,{codepoint:()=>l0,codepoints:()=>vx,collect:()=>wi,complete:()=>Px,consume:()=>Ex,cut:()=>f0,delimited:()=>Ux,dispatch:()=>kx,end:()=>yi,error:()=>ht,except:()=>Mx,filter:()=>Nx,filterUndefined:()=>Cx,first:()=>mi,followed:()=>hi,map:()=>fi,not:()=>h0,ok:()=>gt,okWithValue:()=>Lt,optional:()=>Ix,or:()=>Tx,peek:()=>Sx,plus:()=>Ox,plusConsumed:()=>Dx,preceded:()=>gi,range:()=>xx,recognize:()=>Rx,second:()=>di,sequence:()=>Fx,sequenceConsumed:()=>Gx,skipChars:()=>Bx,star:()=>c0,starConsumed:()=>p0,start:()=>Hx,streaming:()=>$x,streamingComplete:()=>qx,streamingFilterUndefined:()=>Xx,streamingOptional:()=>Yx,streamingStar:()=>Lx,streamingThen:()=>jx,then:()=>Cr,token:()=>Ax});function Lt(m,h){return{success:!0,offset:m,value:h}}function gt(m){return Lt(m,void 0)}function ht(m,h,d=!1){return{success:!1,offset:m,expected:h,fatal:d}}function Ax(m){return(h,d)=>{let y=d+m.length;return h.slice(d,y)===m?Lt(y,m):ht(d,[m])}}function u0(m){return m>65535?2:1}function l0(m,h){return(d,y)=>{let E=d.codePointAt(y);return E!==void 0&&m(E)?gt(y+u0(E)):ht(y,h)}}function vx(m,h){return(d,y)=>{let E=y;for(;;){let I=d.codePointAt(y);if(I===void 0||!m(I))break;y+=I>65535?2:1}return h!==void 0&&y===E?ht(y,h):gt(y)}}function xx(m,h,d){return l0(y=>m<=y&&y<=h,d||[`${String.fromCodePoint(m)}-${String.fromCodePoint(h)}`])}function Bx(m){return(h,d)=>{let y=m;for(;y>0;){let E=h.codePointAt(d);if(E===void 0)return ht(d,["any character"]);d+=u0(E),y-=1}return gt(d)}}function fi(m,h){return(d,y)=>{let E=m(d,y);return E.success?Lt(E.offset,h(E.value)):E}}function Ex(m){return fi(m,()=>{})}function Nx(m,h,d,y){return(E,I)=>{let F=m(E,I);return F.success?h(F.value)?F:ht(I,d,y):F}}function Tx(m,h){return(d,y)=>{let E=null;for(let I of m){let F=I(d,y);if(F.success||(E===null||F.offset>E.offset?E=F:F.offset===E.offset&&h===void 0&&(E.expected=E.expected.concat(F.expected)),F.fatal))return F}return h=h||E?.expected||[],E&&(E.expected=h),E||ht(y,h)}}function Ix(m){return(h,d)=>{let y=m(h,d);return y.success||y.fatal?y:Lt(d,null)}}function c0(m){return(h,d)=>{let y=[],E=d;for(;;){let I=m(h,E);if(!I.success){if(I.fatal)return I;break}if(y.push(I.value),I.offset===E)break;E=I.offset}return Lt(E,y)}}function p0(m){return(h,d)=>{let y=d;for(;;){let E=m(h,y);if(!E.success){if(E.fatal)return E;break}if(E.offset===y)break;y=E.offset}return gt(y)}}function Cx(m){return fi(m,h=>h.filter(d=>d!==void 0))}function Cr(m,h,d){return(y,E)=>{let I=m(y,E);if(!I.success)return I;let F=h(y,I.offset);return F.success?Lt(F.offset,d(I.value,F.value)):F}}function Fx(...m){return(h,d)=>{let y=[];for(let E of m){let I=E(h,d);if(!I.success)return I;d=I.offset,y.push(I.value)}return Lt(d,y)}}function Gx(...m){return(h,d)=>{for(let y of m){let E=y(h,d);if(!E.success)return E;d=E.offset}return gt(d)}}function Ox(m){return Cr(m,c0(m),(h,d)=>[h].concat(d))}function mi(m,h){return m}function di(m,h){return h}function Dx(m){return Cr(m,p0(m),di)}function gi(m,h){return Cr(m,h,di)}function hi(m,h){return Cr(m,h,mi)}function Ux(m,h,d,y=!1){return gi(m,y?f0(hi(h,d)):hi(h,d))}function Rx(m){return(h,d)=>{let y=m(h,d);return y.success?Lt(y.offset,h.slice(d,y.offset)):y}}function Sx(m){return(h,d)=>{let y=m(h,d);return y.success?Lt(d,y.value):y}}function h0(m,h){return(d,y)=>m(d,y).success?ht(y,h):gt(y)}function Mx(m,h,d){return gi(h0(h,d),m)}function kx(m,h,d=0,y=[]){return(E,I)=>{let F=E.codePointAt(I+d);if(F===void 0)return ht(I,y);let j=m[F];return j===void 0?h===void 0?ht(I,y):h(E,I):j(E,I)}}function f0(m){return(h,d)=>{let y=m(h,d);return y.success?y:ht(y.offset,y.expected,!0)}}var Hx=(m,h)=>h===0?gt(h):ht(h,["start of input"]),yi=(m,h)=>m.length===h?gt(h):ht(h,["end of input"]);function Px(m){return Cr(m,yi,mi)}function wi(m){let h=[],d=m.next();for(;!d.done;)h.push(d.value),d=m.next();return[h,d.value]}function $x(m){return function*(h,d){let y=m(h,d);return y.success&&(yield y.value),y}}function jx(m,h){return function*(d,y){let E=yield*m(d,y);return E.success?yield*h(d,E.offset):E}}function Xx(m){return function*(h,d){let y=m(h,d),E=y.next();for(;!E.done;){let I=E.value;I!==void 0&&(yield I),E=y.next()}return E.value}}function Lx(m){return function*(h,d){for(;;){let[y,E]=wi(m(h,d));if(!E.success)return E.fatal?E:gt(d);if(yield*y,d===E.offset)return gt(d);d=E.offset}}}function Yx(m){return function*(h,d){let[y,E]=wi(m(h,d));return E.success?(yield*y,E):E.fatal?E:gt(d)}}function qx(m){return function*(h,d){let y=yield*m(h,d);return y.success?yi(h,y.offset):y}}var Ie=(function(m,h){let d="3.34.0",y={};function E(e,t){if(!(e!=="0"&&e!=="-0"||t!=="0"&&t!=="-0"))return 0;var n=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;e=n.exec(e+"");var r=n.exec(t+""),o=!e[1];let a=!r[1];return t=(e[2]||"").replace(/^0*/,""),n=(r[2]||"").replace(/^0*/,""),e=e[3]||"",r=r[3]||"",o&&!a?1:!o&&a?-1:(o=o&&a,t.length>n.length?o?1:-1:t.length<n.length?o?-1:1:t>n?o?1:-1:t<n?o?-1:1:(t=Math.max(e.length,r.length),n=e.padEnd(t,"0"),t=r.padEnd(t,"0"),n>t?o?1:-1:n<t?o?-1:1:0))}function I(e,t){return e=e.toString(),-1<e.indexOf(".")&&t===0?!1:(e=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(e),e[2]?e[2].length<=t:!0)}function F(){return function(e,t){return 1>E(e,t)}}function j(){return function(e,t){return 0>E(e,t)}}function Y(){return function(e,t){return-1<E(e,t)}}function L(){return function(e,t){return 0<E(e,t)}}function ce(e,t){switch(t){case"required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"optional":return!0}}function fe(e){switch(e){case 1:case 0:case 6:case 3:return{};case 4:return{ja:I,va:F(),pc:j(),wa:Y(),qc:L()};case 18:return{};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ca:ce};case 22:case 21:case 20:case 23:case 44:return{};default:return null}}var Je={},yt={};function ae(e){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(e)}function Ee(e){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(e)}function je(e){return Ee(e)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(e)}function U(e){return e=e.split(":"),e.length===1?je(e[0]):e.length!==2?!1:je(e[0])&&je(e[1])}function R(e){return!/[\u0009\u000A\u000D]/.test(e)}function Q(e){return je(e)}let ne=new Map([[45,function(){return!0}],[46,function(){return!0}],[1,function(){return!0}],[0,function(e){return/^(0|1|true|false)$/.test(e)}],[6,function(e){return ae(e)}],[3,ae],[4,function(e){return/^[+-]?\d*(\.\d*)?$/.test(e)}],[18,function(e){return/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.test(e)}],[9,function(e){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(e)}],[8,function(e){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(e)}],[7,function(e){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(e)}],[11,function(e){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(e)}],[12,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[13,function(e){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(e)}],[15,function(e){return/^---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[14,function(e){return/^--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[22,function(e){return/^([0-9A-Fa-f]{2})*$/.test(e)}],[21,function(e){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(e)}],[20,function(){return!0}],[44,U],[48,R],[52,function(e){return R(e)&&!/^ | {2,}| $/.test(e)}],[51,function(e){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(e)}],[50,function(e){return/^[-._:A-Za-z0-9]+$/.test(e)}],[25,Ee],[23,U],[24,je],[42,Q],[41,Q],[26,function(e){return je(e)}],[5,function(e){return/^[+-]?\d+$/.test(e)}],[16,function(e){return/^-?P[0-9]+(Y([0-9]+M)?|M)$/.test(e)}],[17,function(e){return/^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?$/.test(e)}]]);var pe=Object.create(null);[{C:0,name:59},{C:0,name:46,parent:59,J:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:23,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,J:{whiteSpace:"collapse"}},{C:1,name:10,R:9,J:{whiteSpace:"collapse",Ca:"required"}},{C:1,name:48,R:1,J:{whiteSpace:"replace"}},{C:1,name:52,R:48,J:{whiteSpace:"collapse"}},{C:1,name:51,R:52,J:{whiteSpace:"collapse"}},{C:1,name:50,R:52,J:{whiteSpace:"collapse"}},{C:2,name:49,type:50,J:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,R:52,J:{whiteSpace:"collapse"}},{C:1,name:24,R:25,J:{whiteSpace:"collapse"}},{C:1,name:42,R:24,J:{whiteSpace:"collapse"}},{C:1,name:41,R:24,J:{whiteSpace:"collapse"}},{C:2,name:43,type:41,J:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,R:24,J:{whiteSpace:"collapse"}},{C:2,name:40,type:26,J:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,J:{ja:0,whiteSpace:"collapse"}},{C:1,name:27,R:5,J:{ja:0,va:"0",whiteSpace:"collapse"}},{C:1,name:28,R:27,J:{ja:0,va:"-1",whiteSpace:"collapse"}},{C:1,name:31,R:5,J:{ja:0,va:"9223372036854775807",wa:"-9223372036854775808",whiteSpace:"collapse"}},{C:1,name:32,R:31,J:{ja:0,va:"2147483647",wa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,R:32,J:{ja:0,va:"32767",wa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,R:33,J:{ja:0,va:"127",wa:"-128",whiteSpace:"collapse"}},{C:1,name:30,R:5,J:{ja:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:36,R:30,J:{ja:0,va:"18446744073709551615",wa:"0",whiteSpace:"collapse"}},{C:1,name:35,R:36,J:{ja:0,va:"4294967295",wa:"0",whiteSpace:"collapse"}},{C:1,name:38,R:35,J:{ja:0,va:"65535",wa:"0",whiteSpace:"collapse"}},{C:1,name:37,R:38,J:{ja:0,va:"255",wa:"0",whiteSpace:"collapse"}},{C:1,name:29,R:30,J:{ja:0,wa:"1",whiteSpace:"collapse"}},{C:1,name:16,R:18,J:{whiteSpace:"collapse"}},{C:1,name:17,R:18,J:{whiteSpace:"collapse"}},{C:1,name:60,R:59},{C:3,name:39,Da:[]},{C:1,name:61,R:60},{C:1,name:62,R:60},{C:0,name:53,parent:59},{C:1,name:54,R:53},{C:1,name:58,R:53},{C:1,name:47,R:53},{C:1,name:56,R:53},{C:1,name:57,R:53},{C:1,name:55,R:53},{C:3,name:2,Da:[4,5,6,3]},{C:3,name:63,Da:[]}].forEach(e=>{let t=e.name,n=e.J||{};switch(e.C){case 0:e=e.parent?pe[e.parent]:null;var r=ne.get(t)||null;pe[t]={C:0,type:t,La:n,parent:e,gb:r,Qa:fe(t),Da:[]};break;case 1:e=pe[e.R],r=ne.get(t)||null,pe[t]={C:1,type:t,La:n,parent:e,gb:r,Qa:e.Qa,Da:[]};break;case 2:pe[t]={C:2,type:t,La:n,parent:pe[e.type],gb:null,Qa:Je,Da:[]};break;case 3:e=e.Da.map(o=>pe[o]),pe[t]={C:3,type:t,La:n,parent:null,gb:null,Qa:yt,Da:e}}});function v(e,t){if(!pe[t])throw Error("Unknown type");return{type:t,value:e}}var Ke=v(!0,0),ut=v(!1,0),Gr=(e="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${e}`),lo=class{constructor(e,t){this.done=e,this.value=t}},X=new lo(!0);function k(e){return new lo(!1,e)}function co(e,t){if(t.C===3)return!!t.Da.find(n=>co(e,n));for(;e;){if(e.type===t.type)return!0;if(e.C===3)return!!e.Da.find(n=>g(n.type,t.type));e=e.parent}return!1}function g(e,t){return e===t?!0:co(pe[e],pe[t])}var da=class{constructor(e){this.o=f,this.h=e;let t=-1;this.value={next:()=>(t++,t>=e.length?X:k(e[t]))}}hb(){return this}filter(e){let t=-1;return this.o.create({next:()=>{for(t++;t<this.h.length&&!e(this.h[t],t,this);)t++;return t>=this.h.length?X:k(this.h[t])}})}first(){return this.h[0]}N(){return this.h}ea(){if(g(this.h[0].type,53))return!0;throw Gr("Cannot determine the effective boolean value of a sequence with a length higher than one.")}Ra(){return this.h.length}isEmpty(){return!1}oa(){return!1}map(e){let t=-1;return this.o.create({next:()=>++t>=this.h.length?X:k(e(this.h[t],t,this))},this.h.length)}M(e){return e(this.h)}X(e){return e.multiple?e.multiple(this):e.default(this)}},Xn=class{constructor(){this.value={next:()=>X}}hb(){return this}filter(){return this}first(){return null}N(){return[]}ea(){return!1}Ra(){return 0}isEmpty(){return!0}oa(){return!1}map(){return this}M(e){return e([])}X(e){return e.empty?e.empty(this):e.default(this)}},mn=class{constructor(e,t){this.type=e,this.value=t}};let we={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",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",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"},ga={"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,"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,"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 wt(e){return e.g===2?we[e.type]+"*":e.g===1?we[e.type]+"+":e.g===0?we[e.type]+"?":we[e.type]}function lt(e){if(e==="none")throw Error('XPST0051: The type "none" could not be found');if(!e.startsWith("xs:")&&0<=e.indexOf(":"))throw Error(`XPST0081: Invalid prefix for input ${e}`);let t=ga[e];if(t===void 0)throw Error(`XPST0051: The type "${e}" could not be found`);return t}function dn(e){switch(e[e.length-1]){case"*":return{type:lt(e.substr(0,e.length-1)),g:2};case"?":return{type:lt(e.substr(0,e.length-1)),g:0};case"+":return{type:lt(e.substr(0,e.length-1)),g:1};default:return{type:lt(e),g:3}}}function ya(e){switch(e){case"*":return 2;case"?":return 0;case"+":return 1;default:return 3}}function S(e){let t=e.value;if(g(e.type,53))return!0;if(g(e.type,0))return t;if(g(e.type,1)||g(e.type,20)||g(e.type,19))return t.length!==0;if(g(e.type,2))return!isNaN(t)&&t!==0;throw Gr(`Cannot determine the effective boolean value of a value with the type ${we[e.type]}`)}function V(e,t=0){e.h=t}var De=class{constructor(e,t=null){this.D=f,this.value={next:n=>this.o!==null&&this.h>=this.o?X:this.v[this.h]!==void 0?k(this.v[this.h++]):(n=e.next(n),n.done?(this.o=this.h,n):((this.l||2>this.h)&&(this.v[this.h]=n.value),this.h++,n))},this.l=!1,this.v=[],this.h=0,this.o=t}hb(){return this.D.create(this.N())}filter(e){let t=-1,n=this.value;return this.D.create({next:r=>{for(t++,r=n.next(r);!r.done&&!e(r.value,t,this);)t++,r=n.next(0);return r}})}first(){if(this.v[0]!==void 0)return this.v[0];let e=this.value.next(0);return V(this),e.done?null:e.value}N(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");let e=this.value;this.l=!0;let t=e.next(0);for(;!t.done;)t=e.next(0);return this.v}ea(){let e=this.value,t=this.h;V(this);var n=e.next(0);if(n.done)return V(this,t),!1;if(n=n.value,g(n.type,53))return V(this,t),!0;if(!e.next(0).done)throw Gr("Cannot determine the effective boolean value of a sequence with a length higher than one.");return V(this,t),S(n)}Ra(e=!1){if(this.o!==null)return this.o;if(e)return-1;e=this.h;let t=this.N().length;return V(this,e),t}isEmpty(){return this.o===0?!0:this.first()===null}oa(){if(this.o!==null)return this.o===1;var e=this.value;let t=this.h;return V(this),e.next(0).done?(V(this,t),!1):(e=e.next(0),V(this,t),e.done)}map(e){let t=0,n=this.value;return this.D.create({next:r=>(r=n.next(r),r.done?X:k(e(r.value,t++,this)))},this.o)}M(e,t){let n=this.value,r,o=[],a=!0;return(function(){for(let i=n.next(a?0:t);!i.done;i=n.next(t))a=!1,o.push(i.value);r=e(o).value})(),this.D.create({next:()=>r.next(0)})}X(e){let t=null,n=r=>{t=r.value,r=r.Ra(!0),r!==-1&&(this.o=r)};return this.D.create({next:r=>t?t.next(r):this.isEmpty()?(n(e.empty?e.empty(this):e.default(this)),t.next(r)):this.oa()?(n(e.m?e.m(this):e.default(this)),t.next(r)):(n(e.multiple?e.multiple(this):e.default(this)),t.next(r))})}},Ue=class{constructor(e){this.v=f,this.h=e;let t=!1;this.value={next:()=>t?X:(t=!0,k(e))},this.o=null}hb(){return this}filter(e){return e(this.h,0,this)?this:this.v.create()}first(){return this.h}N(){return[this.h]}ea(){return this.o===null&&(this.o=S(this.h)),this.o}Ra(){return 1}isEmpty(){return!1}oa(){return!0}map(e){return this.v.create(e(this.h,0,this))}M(e){return e([this.h])}X(e){return e.m?e.m(this):e.default(this)}};let gn=new Xn;function At(e=null,t=null){if(e===null)return gn;if(Array.isArray(e))switch(e.length){case 0:return gn;case 1:return new Ue(e[0]);default:return new da(e)}return e.next?new De(e,t):new Ue(e)}var f={create:At,m:e=>new Ue(e),empty:()=>At(),$:()=>At(Ke),S:()=>At(ut)};function Se(e){let t=[],n=e.value;return()=>{let r=0;return f.create({next:()=>{if(t[r]!==void 0)return t[r++];let o=n.next(0);return o.done?o:t[r++]=o}})}}var _e=class{constructor(e,t,n){this.namespaceURI=t||null,this.prefix=e||"",this.localName=n}Aa(){return this.prefix?this.prefix+":"+this.localName:this.localName}};function I0(e,t){let n=e.value,r=t.map(o=>o===null?null:Se(o));return t=t.reduce((o,a,i)=>(a===null&&o.push(e.o[i]),o),[]),t=new _t({j:t,arity:t.length,bb:!0,H:e.H,localName:"boundFunction",namespaceURI:e.l,i:e.s,value:function(o,a,i){let u=Array.from(arguments).slice(3),l=r.map(p=>p===null?u.shift():p());return n.apply(void 0,[o,a,i].concat(l))}}),f.m(t)}var _t=class extends mn{constructor({j:e,arity:t,bb:n=!1,H:r=!1,localName:o,namespaceURI:a,i,value:u}){for(super(60,null),this.value=u,this.H=r,r=-1,u=0;u<e.length;u++)e[u]===4&&(r=u);-1<r&&(u=Array(t-(e.length-1)).fill(e[r-1]),e=e.slice(0,r).concat(u)),this.o=e,this.v=t,this.ha=n,this.D=o,this.l=a,this.s=i}bb(){return this.ha}};function Ii(e,t){let n=[];return e!==2&&e!==1||n.push("type-1-or-type-2"),n.push(`type-${e}`),t&&n.push(`name-${t}`),n}function Ci(e){let t=e.node.nodeType,n;return(t===2||t===1)&&(n=e.node.localName),Ii(t,n)}function Yt(e){let t=e.nodeType;t===4&&(t=3);let n;return(t===2||t===1)&&(n=e.localName),Ii(t,n)}var Wt=class{getAllAttributes(e,t=null){return e.nodeType!==1?[]:(e=Array.from(e.attributes),t===null?e:e.filter(n=>Yt(n).includes(t)))}getAttribute(e,t){return e.nodeType!==1?null:e.getAttribute(t)}getChildNodes(e,t=null){return e=Array.from(e.childNodes),t===null?e:e.filter(n=>Yt(n).includes(t))}getData(e){return e.nodeType===2?e.value:e.data}getFirstChild(e,t=null){for(e=e.firstChild;e;e=e.nextSibling)if(t===null||Yt(e).includes(t))return e;return null}getLastChild(e,t=null){for(e=e.lastChild;e;e=e.previousSibling)if(t===null||Yt(e).includes(t))return e;return null}getNextSibling(e,t=null){for(e=e.nextSibling;e;e=e.nextSibling)if(t===null||Yt(e).includes(t))return e;return null}getParentNode(e,t=null){return(e=e.nodeType===2?e.ownerElement:e.parentNode)&&(t===null||Yt(e).includes(t))?e:null}getPreviousSibling(e,t=null){for(e=e.previousSibling;e;e=e.previousSibling)if(t===null||Yt(e).includes(t))return e;return null}};class C0{insertBefore(t,n,r){return t.insertBefore(n,r)}removeAttributeNS(t,n,r){return t.removeAttributeNS(n,r)}removeChild(t,n){return t.removeChild(n)}setAttributeNS(t,n,r,o){t.setAttributeNS(n,r,o)}setData(t,n){t.data=n}}var wa=new C0;class Fi{constructor(t){this.h=t}insertBefore(t,n,r){return this.h.insertBefore(t,n,r)}removeAttributeNS(t,n,r){return this.h.removeAttributeNS(t,n,r)}removeChild(t,n){return this.h.removeChild(t,n)}setAttributeNS(t,n,r,o){this.h.setAttributeNS(t,n,r,o)}setData(t,n){this.h.setData(t,n)}}function We(e){return e.Ta!==void 0}function Ln(e,t,n){let r=null;return t&&(We(t.node)?r={F:t.F,offset:n,parent:t.node}:t.F&&(r=t.F)),{node:e,F:r}}function Yn(e,t,n=null){return e.getAllAttributes(t.node,n).map(r=>Ln(r,t,r.nodeName))}function Aa(e,t,n){return t=t.node,We(t)?(e=t.attributes.find(r=>n===r.name))?e.value:null:(e=e.h.getAttribute(t,n))?e:null}function Ct(e,t,n=null){return e.getChildNodes(t.node,n).map((r,o)=>Ln(r,t,o))}function Ye(e,t){return e.getData(t.node)}function po(e,t,n=null){let r=t.node;return We(r)?e=r.childNodes[0]:((n=e.h.getFirstChild(r,n))&&n.nodeType===10&&(n=e.h.getNextSibling(n)),e=n),e?Ln(e,t,0):null}function Gi(e,t,n=null){var r=t.node;return We(r)?(e=r.childNodes.length-1,r=r.childNodes[e]):((r=e.h.getLastChild(r,n))&&r.nodeType===10&&(r=e.h.getPreviousSibling(r)),e=e.getChildNodes(t.node,n).length-1),r?Ln(r,t,e):null}function he(e,t,n=null){let r=t.node,o=t.F;if(o)typeof o.offset=="number"&&r===o.parent.childNodes[o.offset]||typeof o.offset=="string"&&r===o.parent.attributes.find(a=>o.offset===a.nodeName)?(e=o.parent,t=o.F):(e=e.getParentNode(r,n),t=o);else{if(We(r))return null;e=e.getParentNode(r,n),t=null}return e?{node:e,F:t}:null}function zt(e,t,n=null){let r=t.node,o,a,i,u=t.F;if(We(r))u&&(i=u.offset+1,o=u.parent.childNodes[i]);else if(u)i=u.offset+1,a=he(e,t,null),o=e.getChildNodes(a.node,n)[i];else{for(o=r;o&&(!(o=e.h.getNextSibling(o,n))||o.nodeType===10););return o?{node:o,F:null}:null}return o?Ln(o,a||he(e,t,n),i):null}function Or(e,t,n=null){let r=t.node,o,a,i=t.F,u;if(We(r))i&&(u=i.offset-1,o=i.parent.childNodes[u]);else if(i)u=i.offset-1,a=he(e,t,null),o=e.getChildNodes(a.node,n)[u];else{for(o=r;o&&(!(o=e.h.getPreviousSibling(o,n))||o.nodeType===10););return o?{node:o,F:null}:null}return o?Ln(o,a||he(e,t,n),u):null}var ho=class{constructor(e){this.h=e,this.o=[]}getAllAttributes(e,t=null){return We(e)?e.attributes:this.h.getAllAttributes(e,t)}getChildNodes(e,t=null){return t=We(e)?e.childNodes:this.h.getChildNodes(e,t),e.nodeType===9?t.filter(n=>n.nodeType!==10):t}getData(e){return We(e)?e.nodeType===2?e.value:e.data:this.h.getData(e)||""}getParentNode(e,t=null){return this.h.getParentNode(e,t)}},va=(e,t,n,r,o)=>o.M(([a])=>r.M(([i])=>{let u=a.value;if(0>=u||u>i.members.length)throw Error("FOAY0001: array position out of bounds.");return i.members[u-1]()})),ze=class extends _t{constructor(e){super({value:(t,n,r,o)=>va(t,n,r,f.m(this),o),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.members=e}};function F0(e){switch(e.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 Be(e){return{type:F0(e),value:e}}function de(e,t){return e=e.map(n=>n.first()),t(e)}function qn(e,t){var n=g(e.type,1)||g(e.type,20)||g(e.type,19),r=g(t.type,1)||g(t.type,20)||g(t.type,19);return n&&r?e.value===t.value:(n=g(e.type,4)||g(e.type,3)||g(e.type,6),r=g(t.type,4)||g(t.type,3)||g(t.type,6),n&&r?isNaN(e.value)&&isNaN(t.value)?!0:e.value===t.value:(n=g(e.type,0)||g(e.type,22)||g(e.type,18)||g(e.type,23)||g(e.type,44),r=g(t.type,0)||g(t.type,22)||g(t.type,18)||g(t.type,23)||g(t.type,44),n&&r?e.value===t.value:!1))}var xa=(e,t,n,r,o)=>de([r,o],([a,i])=>(a=a.h.find(u=>qn(u.key,i)))?a.value():f.empty()),qt=class extends _t{constructor(e){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(t,n,r,o)=>xa(t,n,r,f.m(this),o),i:{type:59,g:2}}),this.type=61,this.h=e}},Ba=class{equals(e){return this.o()===e.o()&&this.v()===e.v()}Za(){return 0}getHours(){return 0}getMinutes(){return 0}$a(){return 0}o(){return 0}v(){return 0}getSeconds(){return 0}ab(){return 0}na(){return!0}h(){return this}};function Oi(e){var t=Math.abs(e.Za()),n=Math.abs(e.getHours());let r=Math.abs(e.getMinutes());return e=Math.abs(e.getSeconds()),t=`${t?`${t}D`:""}`,n=(n?`${n}H`:"")+(r?`${r}M`:"")+(e?`${e}S`:""),t&&n?`${t}T${n}`:t||(n?`T${n}`:"T0S")}var yn=class extends Ba{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ba=e}Za(){return Math.trunc(this.ba/86400)}getHours(){return Math.trunc(this.ba%86400/3600)}getMinutes(){return Math.trunc(this.ba%3600/60)}v(){return this.ba}getSeconds(){let e=this.ba%60;return Object.is(-0,e)?0:e}na(){return Object.is(-0,this.ba)?!1:0<=this.ba}h(){return new this.constructor(-this.ba)}toString(){return(this.na()?"P":"-P")+Oi(this)}},Ea=(e,t,n,r,o,a)=>(e=86400*e+3600*t+60*n+r+o,new yn(a||e===0?e:-e)),Dr=e=>(e=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e))?Ea(e[4]?parseInt(e[4],10):0,e[5]?parseInt(e[5],10):0,e[6]?parseInt(e[6],10):0,e[7]?parseInt(e[7],10):0,e[8]?parseFloat(e[8]):0,!e[1]):null,Di=e=>(e=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(e),e[1]==="Z"?Ea(0,0,0,0,0,!0):Ea(0,e[3]?parseInt(e[3],10):0,e[4]?parseInt(e[4],10):0,0,0,e[2]==="+"));function Ui(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");if(e=e.ba*t,e>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new yn(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)}function Ur(e){return e?parseInt(e,10):null}function fo(e){e+="";let t=e.startsWith("-");return t&&(e=e.substring(1)),(t?"-":"")+e.padStart(4,"0")}function et(e){return(e+"").padStart(2,"0")}function Ri(e){return e+="",e.split(".")[0].length===1&&(e=e.padStart(e.length+1,"0")),e}function en(e){return e.getHours()===0&&e.getMinutes()===0?"Z":(e.na()?"+":"-")+et(Math.abs(e.getHours()))+":"+et(Math.abs(e.getMinutes()))}function ft(e){var t=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(e);e=t[1]?parseInt(t[1],10):null;let n=Ur(t[2]),r=Ur(t[3]),o=t[4],a=Ur(t[5]),i=Ur(t[6]),u=Ur(t[7]),l=t[8]?parseFloat(t[8]):0;if(t=t[9]?Di(t[9]):null,e&&(-271821>e||273860<e))throw Error("FODT0001: Datetime year is out of bounds");return o?new be(e,n,r,a,i,u,l,t,9):a!==null&&i!==null&&u!==null?new be(1972,12,31,a,i,u,l,t,8):e!==null&&n!==null&&r!==null?new be(e,n,r,0,0,0,0,t,7):e!==null&&n!==null?new be(e,n,1,0,0,0,0,t,11):n!==null&&r!==null?new be(1972,n,r,0,0,0,0,t,13):e!==null?new be(e,1,1,0,0,0,0,t,12):n!==null?new be(1972,n,1,0,0,0,0,t,14):new be(1972,12,r,0,0,0,0,t,15)}function vt(e,t){switch(t){case 15:return new be(1972,12,e.o,0,0,0,0,e.W,15);case 14:return new be(1972,e.h,1,0,0,0,0,e.W,14);case 12:return new be(e.v,1,1,0,0,0,0,e.W,12);case 13:return new be(1972,e.h,e.o,0,0,0,0,e.W,13);case 11:return new be(e.v,e.h,1,0,0,0,0,e.W,11);case 8:return new be(1972,12,31,e.l,e.s,e.D,e.ma,e.W,8);case 7:return new be(e.v,e.h,e.o,0,0,0,0,e.W,7);default:return new be(e.v,e.h,e.o,e.l,e.s,e.D,e.ma,e.W,9)}}function Rr(e,t){return t=e.W||t||Di("Z"),new Date(Date.UTC(e.v,e.h-1,e.o,e.l-t.getHours(),e.s-t.getMinutes(),e.D,1e3*e.ma))}var be=class{constructor(e,t,n,r,o,a,i,u,l=9){this.v=e,this.h=t,this.o=n+(r===24?1:0),this.l=r===24?0:r,this.s=o,this.D=a,this.ma=i,this.W=u,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 fo(this.v)+"-"+et(this.h)+"-"+et(this.o)+"T"+et(this.l)+":"+et(this.s)+":"+Ri(this.D+this.ma)+(this.W?en(this.W):"");case 7:return fo(this.v)+"-"+et(this.h)+"-"+et(this.o)+(this.W?en(this.W):"");case 8:return et(this.l)+":"+et(this.s)+":"+Ri(this.D+this.ma)+(this.W?en(this.W):"");case 15:return"---"+et(this.o)+(this.W?en(this.W):"");case 14:return"--"+et(this.h)+(this.W?en(this.W):"");case 13:return"--"+et(this.h)+"-"+et(this.o)+(this.W?en(this.W):"");case 12:return fo(this.v)+(this.W?en(this.W):"");case 11:return fo(this.v)+"-"+et(this.h)+(this.W?en(this.W):"")}throw Error("Unexpected subType")}};function Sr(e,t,n){let r=Rr(e,n).getTime();return n=Rr(t,n).getTime(),r===n?e.ma===t.ma?0:e.ma>t.ma?1:-1:r>n?1:-1}function wn(e,t,n){return Sr(e,t,n)===0}function Na(e,t,n){return e=(Rr(e,n).getTime()-Rr(t,n).getTime())/1e3,new yn(e)}function Si(e,t){function n(T,P){return P===2?T%4===0&&T%100!==0||T%400===0?29:28:[4,6,9,11].includes(P)?30:31}let r=e.W,o=e.getYear(),a=e.getMonth(),i=e.getDay(),u=e.getHours(),l=e.getMinutes(),p=e.getSeconds(),A=e.ma;for(o+=t.ab(),a+=t.$a();12<a;)a-=12,o+=1;for(;1>a;)a+=12,--o;var x=n(e.getYear(),e.getMonth());x=e.getDay()===x;let C=n(o,a);for(x&&(i=C),i+=t.Za(),u+=t.getHours(),l+=t.getMinutes(),p+=t.getSeconds(),60<=p?(l+=Math.floor(p/60),p%=60):0>p&&(l-=Math.ceil(Math.abs(p)/60),p=(p%60+60)%60),60<=l?(u+=Math.floor(l/60),l%=60):0>l&&(u-=Math.ceil(Math.abs(l)/60),l=(l%60+60)%60),24<=u?(i+=Math.floor(u/24),u%=24):0>u&&(i-=Math.ceil(Math.abs(u)/24),u=(u%24+24)%24);i>n(o,a);)i-=n(o,a),a+=1;for(;1>i;)--a,i+=n(o,a);for(;12<a;)a-=12,o+=1;for(;1>a;)a+=12,--o;return new be(o,a,i,u,l,p,A,r,e.type)}function Ft(e,t){return Si(e,t)}function Gt(e,t){return Si(e,t.h())}function mo(e,t){if(e===null)return null;switch(typeof e){case"boolean":return e?Ke:ut;case"number":return v(e,3);case"string":return v(e,1);case"object":if("nodeType"in e)return Be({node:e,F:null});if(Array.isArray(e))return new ze(e.map(n=>n===void 0?()=>f.empty():(n=mo(n,t),n=n===null?f.empty():f.m(n),Se(n))));if(e instanceof Date){let n=ft(e.toISOString());return v(n,n.type)}return new qt(Object.keys(e).filter(n=>e[n]!==void 0).map(n=>{var r=mo(e[n],t);return r=r===null?f.empty():f.m(r),{key:v(n,1),value:Se(r)}}))}throw Error(`Value ${String(e)} of type "${typeof e}" is not adaptable to an XPath value.`)}function go(e,t){if(typeof e!="number"&&(typeof e!="string"||!ne.get(t)(e)))throw Error(`Cannot convert JavaScript value '${e}' to the XPath type ${we[t]} since it is not valid.`)}function Ta(e,t,n){if(t===null)return null;switch(e){case 0:return t?Ke:ut;case 1:return v(t+"",1);case 3:case 2:return go(t,3),v(+t,3);case 4:return go(t,e),v(+t,4);case 5:return go(t,e),v(t|0,5);case 6:return go(t,e),v(+t,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(t instanceof Date))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${we[e]}.`);return v(vt(ft(t.toISOString()),e),e);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if(typeof t!="object"||!("nodeType"in t))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${we[e]}.`);return Be({node:t,F:null});case 59:return mo(t,n);case 61:return mo(t,n);default:throw Error(`Values of the type "${we[e]}" can not be adapted from JavaScript to equivalent XPath values.`)}}function Mi(e,t,n){if(n.g===0)return t=Ta(n.type,t,e),t===null?[]:[t];if(n.g===2||n.g===1){if(!Array.isArray(t))throw Error(`The JavaScript value ${t} should be an array if it is to be converted to ${wt(n)}.`);return t.map(o=>Ta(n.type,o,e)).filter(o=>o!==null)}let r=Ta(n.type,t,e);if(r===null)throw Error(`The JavaScript value ${t} should be a single entry if it is to be converted to ${wt(n)}.`);return[r]}function yo(e,t,n={type:59,g:0}){return f.create(Mi(e,t,n))}var G0=class{constructor(){this.h=Math.abs(Math.floor(Math.random()*wo)%wo)}},wo=2**32;function Qt(e,t,n,r){return new Qn({L:n,Ba:t,sa:r||e.sa,qa:e.qa},e.h,e.o)}function ki(e,t){let n=0,r=t.value;return{next:o=>(o=r.next(o),o.done?X:k(Qt(e,n++,o.value,t)))}}function Ia(e){return e.h.ib||(e.h.ib=!0,e.h.qb=ft(new Date().toISOString()),e.h.vb=Dr("PT0S")),e.h.qb}function xt(e){return e.h.ib||(e.h.ib=!0,e.h.qb=ft(new Date().toISOString()),e.h.vb=Dr("PT0S")),e.h.vb}function Mr(e,t=null){return e=29421*(t??e.o.h)%wo,{rb:Math.floor(e),bc:e/wo}}function tn(e,t){return new Qn({L:e.L,Ba:e.Ba,sa:e.sa,qa:Object.assign(Object.create(null),e.qa,t)},e.h,e.o)}var Qn=class{constructor(e,t={qb:null,vb:null,ib:!1},n=new G0){this.h=t,this.Ba=e.Ba,this.sa=e.sa,this.L=e.L,this.qa=e.qa||Object.create(null),this.o=n}},Hi=class{constructor(e,t,n,r,o,a,i,u,l){this.debug=e,this.Ha=t,this.h=n,this.Ja=r,this.Oa=o,this.o=a,this.v=i,this.jb=u,this.Wa=l}};function Bt(e){let t=0,n=null,r=!0;return f.create({next:o=>{for(;t<e.length;){n||(n=e[t].value,r=!0);let a=n.next(r?0:o);if(r=!1,a.done)t++,n=null;else return a}return X}})}var Jn=(e,t,n)=>Error(`FORG0001: Cannot cast ${e} to ${we[t]}${n?`, ${n}`:""}`),Et=e=>Error(`XPDY0002: ${e}`),mt=e=>Error(`XPTY0004: ${e}`),Pi=e=>Error(`FOTY0013: Atomization is not supported for ${we[e]}.`),$i=e=>Error(`XPST0081: The prefix ${e} could not be resolved.`);function Jt(e,t){if(g(e.type,46)||g(e.type,19)||g(e.type,0)||g(e.type,4)||g(e.type,3)||g(e.type,6)||g(e.type,5)||g(e.type,2)||g(e.type,23)||g(e.type,1))return f.create(e);let n=t.h;if(g(e.type,53)){let r=e.value;if(r.node.nodeType===2||r.node.nodeType===3)return f.create(v(Ye(n,r),19));if(r.node.nodeType===8||r.node.nodeType===7)return f.create(v(Ye(n,r),1));let o=[];return(function a(i){if(r.node.nodeType!==8&&r.node.nodeType!==7){var u=i.nodeType;u===3||u===4?o.push(n.getData(i)):u!==1&&u!==9&&u!==11||n.getChildNodes(i).forEach(l=>{a(l)})}})(r.node),f.create(v(o.join(""),19))}if(g(e.type,60)&&!g(e.type,62))throw Pi(e.type);if(g(e.type,62))return Bt(e.members.map(r=>Me(r(),t)));throw Error(`Atomizing ${e.type} is not implemented.`)}function Me(e,t){let n=!1,r=e.value,o=null;return f.create({next:()=>{for(;!n;){if(!o){var a=r.next(0);if(a.done){n=!0;break}o=Jt(a.value,t).value}if(a=o.next(0),a.done)o=null;else return a}return X}})}function Ao(e){for(e=pe[e];e&&e.C!==0;)e=e.parent;return e?e.type:null}function Ca(e,t){t=pe[t];let n=t.La;if(!n||!n.whiteSpace)return t.parent?Ca(e,t.parent.type):e;switch(t.La.whiteSpace){case"replace":return e.replace(/[\u0009\u000A\u000D]/g," ");case"collapse":return e.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return e}function vo(e,t){for(t=pe[t];t&&t.gb===null;){if(t.C===2||t.C===3)return!0;t=t.parent}return t?t.gb(e):!0}function O0(e,t){for(;e;){if(e.Qa&&e.Qa[t])return e.Qa[t];e=e.parent}return()=>!0}function D0(e,t){let n=pe[t];for(;n;){if(n.La&&!Object.keys(n.La).every(r=>{if(r==="whiteSpace")return!0;let o=O0(n,r);return o?o(e,n.La[r]):!0}))return!1;n=n.parent}return!0}function An(e){return e?e.g===2||e.g===0:!0}function U0(e){return e(1)||e(19)?t=>({u:!0,value:v(t,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})}function R0(e){return e(22)?t=>{let n="";for(let r=0;r<t.length;r+=2)n+=String.fromCharCode(parseInt(t.substr(r,2),16));return{u:!0,value:v(btoa(n),21)}}:e(1)||e(19)?t=>({u:!0,value:v(t,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})}function S0(e){return e(2)?t=>({u:!0,value:t===0||isNaN(t)?ut:Ke}):e(1)||e(19)?t=>{switch(t){case"true":case"1":return{u:!0,value:Ke};case"false":case"0":return{u:!0,value:ut};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 M0(e){return e(9)?t=>({u:!0,value:v(vt(t,7),7)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})}function k0(e){return e(7)?t=>({u:!0,value:v(vt(t,9),9)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})}function H0(e){return e(18)&&!e(16)?t=>({u:!0,value:v(t.za,17)}):e(16)?()=>({u:!0,value:v(Dr("PT0.0S"),17)}):e(19)||e(1)?t=>{let n=Dr(t);return n?{u:!0,value:v(n,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${t} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})}function P0(e){return e(5)?t=>({u:!0,value:v(t,4)}):e(6)||e(3)?t=>isNaN(t)||!isFinite(t)?{u:!1,error:Error(`FOCA0002: Can not cast ${t} to xs:decimal`)}:Math.abs(t)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${t} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:v(t,4)}:e(0)?t=>({u:!0,value:v(t?1:0,4)}):e(1)||e(19)?t=>{let n=parseFloat(t);return!isNaN(n)||isFinite(n)?{u:!0,value:v(n,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${t} to xs:decimal`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})}function ji(e,t){return e(2)?n=>({u:!0,value:n}):e(0)?n=>({u:!0,value:n?1:0}):e(1)||e(19)?n=>{switch(n){case"NaN":return{u:!0,value:NaN};case"INF":case"+INF":return{u:!0,value:1/0};case"-INF":return{u:!0,value:-1/0};case"0":case"+0":return{u:!0,value:0};case"-0":return{u:!0,value:-0}}let r=parseFloat(n);return isNaN(r)?{u:!1,error:Jn(n,t)}:{u:!0,value:r}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${t} or any of its derived types.`)})}function $0(e){let t=ji(e,3);return n=>(n=t(n),n.u?{u:!0,value:v(n.value,3)}:n)}function Xi(e){let t=Math.abs(e.ab());return e=Math.abs(e.$a()),`${t?`${t}Y`:""}${e?`${e}M`:""}`||"0M"}var Kn=class extends Ba{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.da=e}$a(){let e=this.da%12;return e===0?0:e}o(){return this.da}ab(){return Math.trunc(this.da/12)}na(){return Object.is(-0,this.da)?!1:0<=this.da}h(){return new this.constructor(-this.da)}toString(){return(this.na()?"P":"-P")+Xi(this)}},Fa=e=>{var t=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e);if(t){if(e=!t[1],t=12*(t[2]?parseInt(t[2],10):0)+(t[3]?parseInt(t[3],10):0),t>Number.MAX_SAFE_INTEGER||!Number.isFinite(t))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");e=new Kn(e||t===0?t:-t)}else e=null;return e};function Li(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");if(e=Math.round(e.da*t),e>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new Kn(e<Number.MIN_SAFE_INTEGER||e===0?0:e)}var Ga=class extends Ba{constructor(e,t){super(),this.Na=e,this.za=t}Za(){return this.za.Za()}getHours(){return this.za.getHours()}getMinutes(){return this.za.getMinutes()}$a(){return this.Na.$a()}o(){return this.Na.o()}v(){return this.za.v()}getSeconds(){return this.za.getSeconds()}ab(){return this.Na.ab()}na(){return this.Na.na()&&this.za.na()}h(){return new this.constructor(this.Na.h(),this.za.h())}toString(){let e=this.na()?"P":"-P",t=Xi(this.Na),n=Oi(this.za);return t==="0M"?e+n:n==="T0S"?e+t:e+t+n}};function j0(e){return e(16)?t=>({u:!0,value:v(new Ga(t,new yn(t.na()?0:-0)),18)}):e(17)?t=>(t=new Ga(new Kn(t.na()?0:-0),t),{u:!0,value:v(t,18)}):e(18)?t=>({u:!0,value:v(t,18)}):e(19)||e(1)?t=>{var n;return n=new Ga(Fa(t),Dr(t)),{u:!0,value:v(n,18)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})}function X0(e){let t=ji(e,6);return n=>(n=t(n),n.u?{u:!0,value:v(n.value,6)}:n)}function L0(e){return e(7)||e(9)?t=>({u:!0,value:v(vt(t,15),15)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})}function Y0(e){return e(7)||e(9)?t=>({u:!0,value:v(vt(t,14),14)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})}function q0(e){return e(7)||e(9)?t=>({u:!0,value:v(vt(t,13),13)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})}function Q0(e){return e(7)||e(9)?t=>({u:!0,value:v(vt(t,12),12)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})}function J0(e){return e(7)||e(9)?t=>({u:!0,value:v(vt(t,11),11)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})}function K0(e){return e(21)?t=>{t=atob(t);let n="";for(let r=0,o=t.length;r<o;r++)n+=Number(t.charCodeAt(r)).toString(16);return{u:!0,value:v(n.toUpperCase(),22)}}:e(1)||e(19)?t=>({u:!0,value:v(t,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})}function b0(e){return e(0)?t=>({u:!0,value:v(t?1:0,5)}):e(2)?t=>{let n=Math.trunc(t);return!isFinite(n)||isNaN(n)?{u:!1,error:Error(`FOCA0002: can not cast ${t} to xs:integer`)}:Number.isSafeInteger(n)?{u:!0,value:v(n,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${t} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:e(1)||e(19)?t=>{let n=parseInt(t,10);return isNaN(n)?{u:!1,error:Jn(t,5)}:Number.isSafeInteger(n)?{u:!0,value:v(n,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${t} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})}let V0=[3,6,4,5];function Z0(e){var t=Qi;return n=>{for(let r of V0){let o=t(e,r)(n);if(o.u)return o}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${n}" given type to xs:numeric or any of its derived types.`)}}}function Yi(e){if(e(1)||e(19))return t=>({u:!0,value:t+""});if(e(20))return t=>({u:!0,value:t});if(e(23))return t=>({u:!0,value:t.prefix?`${t.prefix}:${t.localName}`:t.localName});if(e(44))return t=>({u:!0,value:t.toString()});if(e(2)){if(e(5)||e(4))return t=>({u:!0,value:(t+"").replace("e","E")});if(e(6)||e(3))return t=>isNaN(t)?{u:!0,value:"NaN"}:isFinite(t)?Object.is(t,-0)?{u:!0,value:"-0"}:{u:!0,value:(t+"").replace("e","E").replace("E+","E")}:{u:!0,value:`${0>t?"-":""}INF`}}return e(9)||e(7)||e(8)||e(15)||e(14)||e(13)||e(12)||e(11)?t=>({u:!0,value:t.toString()}):e(16)?t=>({u:!0,value:t.toString()}):e(17)?t=>({u:!0,value:t.toString()}):e(18)?t=>({u:!0,value:t.toString()}):e(22)?t=>({u:!0,value:t.toUpperCase()}):t=>({u:!0,value:t+""})}function _0(e){let t=Yi(e);return n=>(n=t(n),n.u?{u:!0,value:v(n.value,1)}:n)}function W0(e){return e(9)?t=>({u:!0,value:v(vt(t,8),8)}):e(19)||e(1)?t=>({u:!0,value:v(ft(t),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})}function z0(e){let t=Yi(e);return n=>(n=t(n),n.u?{u:!0,value:v(n.value,19)}:n)}function eh(e){return e(18)&&!e(17)?t=>({u:!0,value:v(t.Na,16)}):e(17)?()=>({u:!0,value:v(Fa("P0M"),16)}):e(19)||e(1)?t=>{let n=Fa(t);return n?{u:!0,value:v(n,16)}:{u:!1,error:Jn(t,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})}let qi=[2,5,17,16];function Qi(e,t){let n=r=>g(e,r);if(t===39)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(t){case 19:return z0(n);case 1:return _0(n);case 6:return X0(n);case 3:return $0(n);case 4:return P0(n);case 5:return b0(n);case 2:return Z0(e);case 18:return j0(n);case 16:return eh(n);case 17:return H0(n);case 9:return k0(n);case 8:return W0(n);case 7:return M0(n);case 11:return J0(n);case 12:return Q0(n);case 13:return q0(n);case 15:return L0(n);case 14:return Y0(n);case 0:return S0(n);case 21:return R0(n);case 22:return K0(n);case 20:return U0(n);case 23:throw Error("Casting to xs:QName is not implemented.")}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${e} to ${t}.`)})}let Ji=Object.create(null);function th(e,t){if(e===19&&t===1)return a=>({u:!0,value:v(a,1)});if(t===44)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(t===39)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(e===45||t===45)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(e===46||t===46)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(g(e,60)&&t===1)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(e===t)return a=>({u:!0,value:{type:t,value:a}});let n=qi.includes(e)?e:Ao(e),r=qi.includes(t)?t:Ao(t);if(r===null||n===null)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${r?we[e]:we[t]} is unknown.`)});let o=[];return n!==1&&n!==19||o.push(a=>{let i=Ca(a,t);return vo(i,t)?{u:!0,value:i}:{u:!1,error:Jn(a,t,"pattern validation failed.")}}),n!==r&&(o.push(Qi(n,r)),o.push(a=>({u:!0,value:a.value}))),r!==19&&r!==1||o.push(a=>vo(a,t)?{u:!0,value:a}:{u:!1,error:Jn(a,t,"pattern validation failed.")}),o.push(a=>D0(a,t)?{u:!0,value:a}:{u:!1,error:Jn(a,t,"pattern validation failed.")}),o.push(a=>({u:!0,value:{type:t,value:a}})),a=>{a={u:!0,value:a};for(let i=0,u=o.length;i<u&&(a=o[i](a.value),a.u!==!1);++i);return a}}function Oa(e,t){let n=e.type+1e4*t,r=Ji[n];return r||=Ji[n]=th(e.type,t),r.call(void 0,e.value,t)}function xe(e,t){if(e=Oa(e,t),e.u===!0)return e.value;throw e.error}function Kt(e){let t=!1;return{next:()=>t?X:(t=!0,k(e))}}function Ki(e,t){return e===t?!0:e&&t&&e.offset===t.offset&&e.parent===t.parent?Ki(e.F,t.F):!1}function $e(e,t){return!!(e===t||e.node===t.node&&Ki(e.F,t.F))}function nh(e,t,n){var r=he(e,t,null);e=Ct(e,r,null);for(let o=0,a=e.length;o<a;++o){if(r=e[o],$e(r,t))return-1;if($e(r,n))return 1}}function bi(e,t){let n=[];for(;t;t=he(e,t,null))n.unshift(t);return n}function Vi(e,t){let n=[];for(;t;t=e.getParentNode(t,null))n.unshift(t);return n}function rh(e,t,n,r){if(n.F||r.F||We(n.node)||We(r.node)){if($e(n,r))return 0;n=bi(t,n),r=bi(t,r);let a=n[0],i=r[0];if(!$e(a,i))return t=e.findIndex(u=>$e(u,a)),n=e.findIndex(u=>$e(u,i)),t===-1&&(t=e.push(a)),n===-1&&(n=e.push(i)),t-n;e=1;for(var o=Math.min(n.length,r.length);e<o&&$e(n[e],r[e]);++e);return n[e]?r[e]?nh(t,n[e],r[e]):1:-1}if(n=n.node,o=r.node,n===o)return 0;if(r=Vi(t,n),n=Vi(t,o),r[0]!==n[0]){let a={node:r[0],F:null},i={node:n[0],F:null};return t=e.findIndex(u=>$e(u,a)),n=e.findIndex(u=>$e(u,i)),t===-1&&(t=e.push(a)),n===-1&&(n=e.push(i)),t-n}for(e=1,o=Math.min(r.length,n.length);e<o&&r[e]===n[e];++e);if(r=r[e],o=n[e],!r)return-1;if(!o)return 1;t=t.getChildNodes(n[e-1],null);for(let a=0,i=t.length;a<i;++a){if(e=t[a],e===r)return-1;if(e===o)return 1}}function Zi(e,t,n,r){let o=g(n.type,47),a=g(r.type,47);if(o&&!a){if(n=he(t,n.value),r=r.value,$e(n,r))return 1}else if(a&&!o){if(n=n.value,r=he(t,r.value),$e(n,r))return-1}else if(o&&a){if($e(he(t,r.value),he(t,n.value)))return n.value.node.localName>r.value.node.localName?1:-1;n=he(t,n.value),r=he(t,r.value)}else n=n.value,r=r.value;return rh(e,t,n,r)}function kr(e,t,n){return Zi(e.o,e,t,n)}function Hr(e,t){return Da(t,(n,r)=>Zi(e.o,e,n,r)).filter((n,r,o)=>r===0?!0:!$e(n.value,o[r-1].value))}let oh=(e,t)=>e<t?-1:0;function Da(e,t=oh){if(1>=e.length)return e;var n=Math.floor(e.length/2);let r=Da(e.slice(0,n),t);for(e=Da(e.slice(n),t),n=[];r.length&&e.length;)0>t(r[0],e[0])?n.push(r.shift()):n.push(e.shift());return n.concat(r.concat(e))}function ah(e,t){if(g(e.type,2)){if(g(e.type,6))return t===3?v(e.value,3):null;if(g(e.type,4)){if(t===6)return v(e.value,6);if(t===3)return v(e.value,3)}return null}return g(e.type,20)&&t===1?v(e.value,1):null}function xo(e,t,n,r,o){if(g(e.type,t.type)||(g(t.type,46)&&g(e.type,53)&&(e=Jt(e,n).first()),g(e.type,t.type)||t.type===46))return e;if(g(e.type,19)){if(n=xe(e,t.type),!n)throw Error(`XPTY0004 Unable to convert ${o?"return":"argument"} of type ${we[e.type]} to type ${wt(t)} while calling ${r}`);return n}if(n=ah(e,t.type),!n)throw Error(`XPTY0004 Unable to cast ${o?"return":"argument"} of type ${we[e.type]} to type ${wt(t)} while calling ${r}`);return n}function Ua(e){switch(e){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}var Ot=(e,t,n,r,o)=>e.g===0?t.X({default:()=>t.map(a=>xo(a,e,n,r,o)),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${o?"function return value":"function argument"} of type ${we[e.type]}${Ua(e.g)} for ${r} is incorrect. Expected "?", but got "+".`)}}):e.g===1?t.X({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${o?"function return value":"function argument"} of type ${we[e.type]}${Ua(e.g)} for ${r} is incorrect. Expected "+", but got "empty-sequence()"`)},default:()=>t.map(a=>xo(a,e,n,r,o))}):e.g===2?t.map(a=>xo(a,e,n,r,o)):t.X({m:()=>t.map(a=>xo(a,e,n,r,o)),default:()=>{throw Error(`XPTY0004: Multiplicity of ${o?"function return value":"function argument"} of type ${we[e.type]}${Ua(e.g)} for ${r} is incorrect. Expected exactly one`)}});function dt(e,t,n){return(r,o,a)=>{if(r.L===null)throw Et(`The function ${e} depends on dynamic context, which is absent.`);let i=Ot({type:t,g:3},f.m(r.L),o,e,!1);return n(r,o,a,i)}}var sh=m;function Ra(e,t){return g(e,5)?v(t,5):g(e,6)?v(t,6):g(e,3)?v(t,3):v(t,4)}let ih=[{ka:"M",ia:1e3},{ka:"CM",ia:900},{ka:"D",ia:500},{ka:"CD",ia:400},{ka:"C",ia:100},{ka:"XC",ia:90},{ka:"L",ia:50},{ka:"XL",ia:40},{ka:"X",ia:10},{ka:"IX",ia:9},{ka:"V",ia:5},{ka:"IV",ia:4},{ka:"I",ia:1}];function _i(e,t){let n=0>e;if(e=Math.abs(e),!e)return"-";let r=ih.reduce((o,a)=>{let i=Math.floor(e/a.ia);return e-=i*a.ia,o+a.ka.repeat(i)},"");return t&&(r=r.toLowerCase()),n&&(r=`-${r}`),r}let Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");function Wi(e,t){let n=0>e;if(e=Math.abs(e),!e)return"-";let r="",o;for(;0<e;)o=(e-1)%Sa.length,r=Sa[o]+r,e=(e-o)/Sa.length|0;return t&&(r=r.toLowerCase()),n&&(r=`-${r}`),r}function zi(e,t,n=[]){return Array.from({length:t},(r,o)=>o+e).filter(r=>!n.includes(r))}let Ma=zi(1488,27,[1498,1501,1503,1507,1509]),ka=zi(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Ha="\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(""),Bo=[[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,"\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"]],uh=[[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"]];function eu(e,t=[]){var n=25;return t.sort((r,o)=>r-o),n-=t.length,function(r){let o=0>r;if(r=Math.abs(r),!r)return"-";let a=[];for(;0<r;){let i=e+(r-1)%n;t.forEach(u=>{i>=u&&i++}),a.unshift(String.fromCodePoint(i)),r=Math.floor((r-1)/n)}return r=a.join(""),o&&(r=`-${r}`),r}}let tu=eu(945,[962]),nu=eu(913,[930]);function Dt(e){return new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1}).format(e)}function Ut(e){return new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1}).format(e)}let lh=new Map([["A",function(e){return Wi(e,!1)}],["a",function(e){return Wi(e,!0)}],["I",function(e){return _i(e,!1)}],["i",function(e){return _i(e,!0)}],["lowerGreek",tu],["\u03B1",tu],["upperGreek",nu],["\u0391",nu],["arabicAbjadi",function(e){let t=0>e;return e=Math.abs(e),e?(e=Array(Math.floor((e-1)/Ha.length)+1).fill(Ha[(e-1)%Ha.length]).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["arabicAbjadNumeral",function(e){let t=0>e;if(e=Math.abs(e),!e)return"-";var n=[],r=Math.floor(e/1e3);if(e-=1e3*r,r===1)n.push(Bo[0][1]);else if(1<r){for(let[a,i]of Bo){var o=a;let u=i;for(;r>=o;)n.push(u),r-=o}n.push(Bo[0][1])}for(let[a,i]of Bo)for(r=a,o=i;e>=r;)e-=r,n.push(o);return n=n.join(""),t&&(n=`-${n}`),n}],["arabicAlifBaTa",function(e){let t=0>e;return e=Math.abs(e),e?(e=Array(Math.floor((e-1)/ka.length)+1).fill(String.fromCodePoint(ka[(e-1)%ka.length])).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["hebrewAlefBet",function(e){let t=0>e;if(e=Math.abs(e),!e)return"-";var n=Math.floor((e-1)/Ma.length);let r=String.fromCodePoint(1514);return n=Array(n).fill(r),n.push(String.fromCodePoint(Ma[(e-1)%Ma.length])),e=n.join(""),t&&(e=`-${e}`),e}],["hebrewNumeral",function(e){let t=0>e;if(e=Math.abs(e),!e)return"-";var n=[],r=Math.floor(e/400);e-=400*r;for(var o=0;o<r;o++)n.push("\u05EA");for(let[a,i]of uh)for(r=a,o=i;e>=r;)e-=r,n.push(o);return e=n.slice(-2).join(""),e==="\u05D9\u05D4"&&n.splice(-2,2,"\u05D8","\u05D5"),e==="\u05D9\u05D5"&&n.splice(-2,2,"\u05D8","\u05D6"),n=n.join(""),t&&(n=`-${n}`),n}],["arabicIndicNumeral",Dt],["\u0661",Dt],["\u0662",Dt],["\u0663",Dt],["\u0664",Dt],["\u0665",Dt],["\u0666",Dt],["\u0667",Dt],["\u0668",Dt],["\u0669",Dt],["persianNumeral",Ut],["\u06F1",Ut],["\u06F2",Ut],["\u06F3",Ut],["\u06F4",Ut],["\u06F5",Ut],["\u06F6",Ut],["\u06F7",Ut],["\u06F8",Ut],["\u06F9",Ut]]);function ch(e){if(Math.floor(e)===e||isNaN(e))return 0;e=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${e}`);let t=e[1]?e[1].length:0;return e[3]?e[2]?t+parseInt(e[3],10):(e=t-parseInt(e[3],10),0>e?0:e):t}function ph(e,t,n){return t&&e*n%1%.5===0?Math.floor(e*n)%2===0?Math.floor(e*n)/n:Math.ceil(e*n)/n:Math.round(e*n)/n}function bn(e,t,n,r,o,a){let i=!1;return f.create({next:()=>{if(i)return X;let u=o.first();if(!u)return i=!0,X;if((g(u.type,6)||g(u.type,3))&&(u.value===0||isNaN(u.value)||u.value===1/0||u.value===-1/0))return i=!0,k(u);var l;if(a?l=a.first().value:l=0,i=!0,ch(u.value)<l)return k(u);let p=[5,4,3,6].find(x=>g(u.type,x)),A=xe(u,4);switch(l=ph(A.value,e,Math.pow(10,l)),p){case 4:return k(v(l,4));case 3:return k(v(l,3));case 6:return k(v(l,6));case 5:return k(v(l,5))}}})}let ru=(e,t,n,r)=>Me(r,t).X({empty:()=>f.m(v(NaN,3)),m:()=>{let o=Oa(r.first(),3);return o.u?f.m(o.value):f.m(v(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values")}});function hh(e){let t=5381;for(let n=0;n<e.length;++n)t=33*t+e.charCodeAt(n),t%=Number.MAX_SAFE_INTEGER;return t}let ou=(e,t,n,r=f.empty())=>{function o(a){let i=(u,l,p,A)=>{if(A.isEmpty()||A.oa())return A;for(u=A.N(),l=a,p=u.length-1;1<p;p--){l=Mr(e,l).rb,A=l%p;let x=u[A];u[A]=u[p],u[p]=x}return f.create(u)};return f.m(new qt([{key:v("number",1),value:()=>f.m(v(Mr(e,a).bc,3))},{key:v("next",1),value:()=>f.m(new _t({value:()=>o(Mr(e,a).rb),bb:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:v("permute",1),value:()=>f.m(new _t({value:i,bb:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],arity:1,i:{type:59,g:2}}))}]))}return t=r.isEmpty()?Mr(e):Mr(e,hh(xe(r.first(),1).value)),o(t.rb)};var fh=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map(o=>Ra(o.type,Math.abs(o.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:(e,t,n,r,o)=>(e=r.first(),o=o.first(),r.isEmpty()?f.m(v("",1)):(r=lh.get(o.value),o=e.value,r?(r=r(o),f.m(v(r,1))):f.m(v(o.toString(),1))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map(o=>Ra(o.type,Math.ceil(o.value)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map(o=>Ra(o.type,Math.floor(o.value)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:bn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:bn.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:bn.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:bn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:ru},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[],i:{type:3,g:3},callFunction:(e,t,n)=>{let r=e.L&&Ot({type:46,g:0},f.m(e.L),t,"fn:number",!1);if(!r)throw Et("fn:number needs an atomizable context item.");return ru(e,t,n,r)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:ou},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:ou}];function Eo(){throw Error("FOCH0002: No collations are supported")}let Pr=(e,t,n,r)=>r.X({empty:()=>f.m(v("",1)),default:()=>r.map(o=>{if(g(o.type,53)){let a=Jt(o,t).first();return g(o.type,47)?xe(a,1):a}return xe(o,1)})}),au=(e,t,n,r,o)=>de([o],([a])=>Me(r,t).M(i=>(i=i.map(u=>xe(u,1).value).join(a.value),f.m(v(i,1))))),su=(e,t,n,r)=>r.isEmpty()?f.m(v(0,5)):(e=r.first().value,f.m(v(Array.from(e).length,5))),iu=(e,t,n,r,o,a)=>{let i=bn(!1,e,t,n,o,null),u=a!==null?bn(!1,e,t,n,a,null):null,l=!1,p=null,A=null,x=null;return f.create({next:()=>l?X:!p&&(p=r.first(),p===null)?(l=!0,k(v("",1))):(A||=i.first(),!x&&a&&(x=null,x=u.first()),l=!0,k(v(Array.from(p.value).slice(Math.max(A.value-1,0),a?A.value+x.value-1:void 0).join(""),1)))})},uu=(e,t,n,r,o)=>{if(r.isEmpty()||r.first().value.length===0)return f.empty();for(e=r.first().value,o=o.first().value,o=cu(o),o.lastIndex=0,t=[],n=o.exec(e),r=0;n;)t.push(e.slice(r,n.index)),r=o.lastIndex,n=o.exec(e);return t.push(e.slice(r)),f.create(t.map(a=>v(a,1)))},Pa=(e,t,n,r)=>r.isEmpty()?f.m(v("",1)):(e=r.first().value.trim(),f.m(v(e.replace(/\s+/g," "),1))),lu=new Map,$a=new Map;function cu(e){if($a.has(e))return $a.get(e);let t;try{t=new RegExp(e,"g")}catch(n){throw Error(`FORX0002: ${n}`)}if(t.test(""))throw Error(`FORX0003: the pattern ${e} matches the zero length string`);return $a.set(e,t),t}var mh=[{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:(e,t,n,r,o)=>r.isEmpty()||o.isEmpty()?f.empty():(e=r.first().value,o=o.first().value,e>o?f.m(v(1,5)):e<o?f.m(v(-1,5)):f.m(v(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:Eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(e,t,n,...r)=>(r=r.map(o=>Me(o,t).M(a=>f.m(v(a.map(i=>i===null?"":xe(i,1).value).join(""),1)))),de(r,o=>f.m(v(o.map(a=>a.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:Eo},{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:(e,t,n,r,o)=>(e=r.isEmpty()?"":r.first().value,o=o.isEmpty()?"":o.first().value,o.length===0?f.$():e.length===0?f.S():e.includes(o)?f.$():f.S())},{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:(e,t,n,r,o)=>(e=o.isEmpty()?"":o.first().value,e.length===0?f.$():(r=r.isEmpty()?"":r.first().value,r.length===0?f.S():r.endsWith(e)?f.$():f.S()))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:Eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:Pa},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:dt("normalize-space",1,(e,t,n,r)=>Pa(e,t,n,Pr(e,t,n,r)))},{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},callFunction:(e,t,n,r,o)=>(e=o.isEmpty()?"":o.first().value,e.length===0?f.$():(r=r.isEmpty()?"":r.first().value,r.length===0?f.S():r.startsWith(e)?f.$():f.S()))},{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:Eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:Pr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[],i:{type:1,g:3},callFunction:dt("string",59,Pr)},{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:(e,t,n,r,o)=>(e=r.isEmpty()?"":r.first().value,o=o.isEmpty()?"":o.first().value,o===""?f.m(v("",1)):(o=e.indexOf(o),o===-1?f.m(v("",1)):f.m(v(e.substring(0,o),1))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r,o)=>(e=r.isEmpty()?"":r.first().value,o=o.isEmpty()?"":o.first().value,o===""?f.m(v(e,1)):(t=e.indexOf(o),t===-1?f.m(v("",1)):f.m(v(e.substring(t+o.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:iu},{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:iu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.isEmpty()?f.m(v("",1)):r.map(o=>v(o.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:(e,t,n,r)=>r.isEmpty()?f.m(v("",1)):r.map(o=>v(o.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:au},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction(e,t,n,r){return au(e,t,n,r,f.m(v("",1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:su},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:dt("string-length",46,(e,t,n,r)=>su(e,t,n,Pr(e,t,n,r)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,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:uu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction(e,t,n,r){return uu(e,t,n,Pa(e,t,n,r),f.m(v(" ",1)))}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,o,a)=>de([r,o,a],([i,u,l])=>{i=Array.from(i?i.value:"");let p=Array.from(u.value),A=Array.from(l.value);return u=i.map(x=>{if(p.includes(x)){if(x=p.indexOf(x),x<=A.length)return A[x]}else return x}),f.m(v(u.join(""),1))}),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(e,t,n,r)=>r.M(o=>(o=o.map(a=>{if(a=a.value,a===9||a===10||a===13||32<=a&&55295>=a||57344<=a&&65533>=a||65536<=a&&1114111>=a)return String.fromCodePoint(a);throw Error("FOCH0001")}).join(""),f.m(v(o,1)))),localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>de([r],([o])=>(o=o?o.value.split(""):[],o.length===0?f.empty():f.create(o.map(a=>v(a.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:(e,t,n,r)=>de([r],([o])=>o===null||o.value.length===0?f.create(v("",1)):f.create(v(encodeURIComponent(o.value).replace(/[!'()*]/g,a=>"%"+a.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:(e,t,n,r)=>de([r],([o])=>o===null||o.value.length===0?f.create(v("",1)):f.create(v(o.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,a=>encodeURI(a)),1))),localName:"iri-to-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:0}],callFunction:(e,t,n,r,o)=>de([r,o],([a,i])=>{if(a===null||i===null)return f.empty();a=a.value;var u=i.value;if(a.length!==u.length)return f.S();for(i=a.split(""),a=u.split(""),u=0;u<i.length;u++)if(i[u].codePointAt(0)!==a[u].codePointAt(0))return f.S();return f.$()}),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:(e,t,n,r,o)=>de([r,o],([a,i])=>{a=a?a.value:"",i=i.value;let u=lu.get(i);if(!u){try{u=(0,sh.compile)(i,{language:"xpath"})}catch(l){throw Error(`FORX0002: ${l}`)}lu.set(i,u)}return u(a)?f.$():f.S()}),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:(e,t,n,r,o,a)=>de([r,o,a],([i,u,l])=>{if(i=i?i.value:"",u=u.value,l=l.value,l.includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");return l=l.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map(p=>{switch(p){case"\\$":return"$$";case"\\\\":return"\\";case"$$":throw Error('FORX0004: invalid replacement: "$$"');default:return p}}).join(""),u=cu(u),i=i.replace(u,l),f.m(v(i,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")}}];let ja=new WeakMap,dh=0,vn=(e,t,n,r)=>de([r],([o])=>{if(o===null)return f.empty();switch(o=o.value,o.node.nodeType){case 1:case 2:return f.m(v(new _e(o.node.prefix,o.node.namespaceURI,o.node.localName),23));case 7:return f.m(v(new _e("","",o.node.target),23));default:return f.empty()}}),pu=(e,t,n,r)=>r.X({default:()=>Pr(e,t,n,vn(e,t,n,r)),empty:()=>f.m(v("",1))}),hu=(e,t,n,r)=>Me(r,t),fu=(e,t,n,r)=>{if(r.isEmpty())return f.m(v("",1));if(!g(r.first().type,53))throw Error("XPTY0004: The context item must be a node.");return n=r.first().value,e=f,t=e.m,n=n.node,ja.has(n)||ja.set(n,`id${++dh}`),n=ja.get(n),t.call(e,v(n,1))},mu=(e,t,n,r)=>de([r],([o])=>(o=o?o.value:null,o!==null&&po(t.h,o,null)?f.$():f.S()));function du(e,t){return e=e.toLowerCase(),t=t.toLowerCase(),e===t?!0:5>e.length||!e.startsWith(t)?!1:du(e.replace(/-[a-z0-9]+$/,""),t)}let gu=(e,t,n,r,o)=>{if(t=t.h,r.isEmpty())r="";else if(g(r.first().type,1))r=r.first().value;else throw Error("XPTY0004: The first argument of lang must be a string.");if(o)o=o.first().value;else{if(!e||!e.L)throw Et("The function lang depends on dynamic context if a node is not passed as the second argument.");if(!g(e.L.type,53))throw Error("XPTY0004: The context item must be a node.");o=e.L.value}e:{for(e=r;o;)if(o.node.nodeType!==1)o=he(t,o);else if(o.node.nodeType===1){if(r=Aa(t,o,"xml:lang")){t=du(r,e)?f.$():f.S();break e}o=he(t,o)}t=f.S()}return t},yu=(e,t,n,r)=>de([r],([o])=>{function a(p){let A=0,x=p;for(;x!==null;)p.node.nodeType===x.node.nodeType&&(x.node.nodeType===1?x.node.localName===p.node.localName&&x.node.namespaceURI===p.node.namespaceURI:x.node.nodeType!==7||x.node.target===p.node.target)&&A++,x=Or(i,x,null);return A}if(o===null)return f.empty();let i=t.h,u="";for(o=o.value;he(t.h,o,null)!==null;o=he(t.h,o,null))switch(o.node.nodeType){case 1:var l=o;u=`/Q{${l.node.namespaceURI||""}}${l.node.localName}[${a(l)}]${u}`;break;case 2:l=o,u=`/@${l.node.namespaceURI?`Q{${l.node.namespaceURI}}`:""}${l.node.localName}${u}`;break;case 3:u=`/text()[${a(o)}]${u}`;break;case 7:l=o,u=`/processing-instruction(${l.node.target})[${a(l)}]${u}`;break;case 8:u=`/comment()[${a(o)}]${u}`}return o.node.nodeType===9?f.create(v(u||"/",1)):f.create(v("Q{http://www.w3.org/2005/xpath-functions}root()"+u,1))}),wu=(e,t,n,r)=>r.map(o=>v(o.value.node.namespaceURI||"",20)),Au=(e,t,n,r)=>r.X({default:()=>r.map(o=>o.value.node.nodeType===7?v(o.value.node.target,1):v(o.value.node.localName||"",1)),empty:()=>f.m(v("",1))});function vu(e,t,n){if(t.node.nodeType===2)return $e(t,n);for(;n;){if($e(t,n))return!0;if(n.node.nodeType===9)break;n=he(e,n,null)}return!1}let xu=(e,t,n,r)=>r.map(o=>{if(!g(o.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let a;for(o=o.value;o;)a=o,o=he(t.h,a,null);return Be(a)});var gh=[{j:[{type:53,g:0}],callFunction:pu,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:dt("name",53,pu),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:wu,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:dt("namespace-uri",53,wu),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.M(o=>o.length?(o=Hr(t.h,o).reduceRight((a,i,u,l)=>u===l.length-1?(a.push(i),a):(vu(t.h,i.value,a[0].value)||a.unshift(i),a),[]),f.create(o)):f.empty()),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.M(o=>o.length?(o=Hr(t.h,o).reduce((a,i,u)=>u===0?(a.push(i),a):(vu(t.h,a[a.length-1].value,i.value)||a.push(i),a),[]),f.create(o)):f.empty(),1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:mu,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:dt("has-children",53,mu),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:yu,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[],callFunction:dt("path",53,yu),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:vn,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:dt("node-name",53,vn),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:Au,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:dt("local-name",53,Au),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:xu,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:dt("root",53,xu),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:dt("data",59,hu),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:hu,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:1,g:0}],callFunction:gu,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:gu,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:dt("generate-id",53,fu),localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:fu,localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}];function Bu(e,t){let n=0,r=e.length,o=!1,a=null;return{next:()=>{if(!o){for(;n<r;){a||=t(e[n],n,e);let i=a.next(0);if(a=null,i.value)n++;else return k(!1)}return o=!0,k(!0)}return X}}}function Eu(e){return e=e.node.nodeType,e===1||e===3}function $r(e,t){if((g(e.type,4)||g(e.type,6))&&(g(t.type,4)||g(t.type,6))){var n=xe(e,6),r=xe(t,6);return n.value===r.value||isNaN(e.value)&&isNaN(t.value)}return(g(e.type,4)||g(e.type,6)||g(e.type,3))&&(g(t.type,4)||g(t.type,6)||g(t.type,3))?(n=xe(e,3),r=xe(t,3),n.value===r.value||isNaN(e.value)&&isNaN(t.value)):g(e.type,23)&&g(t.type,23)?e.value.namespaceURI===t.value.namespaceURI&&e.value.localName===t.value.localName:(g(e.type,9)||g(e.type,7)||g(e.type,8)||g(e.type,11)||g(e.type,12)||g(e.type,13)||g(e.type,14)||g(e.type,15))&&(g(t.type,9)||g(t.type,7)||g(t.type,8)||g(t.type,11)||g(t.type,12)||g(t.type,13)||g(t.type,14)||g(t.type,15))?wn(e.value,t.value):(g(e.type,16)||g(e.type,17)||g(e.type,18))&&(g(t.type,16)||g(t.type,17)||g(t.type,17))?e.value.equals(t.value):e.value===t.value}function yh(e,t,n){let[r,o]=[t,n].map(a=>({type:1,value:a.reduce((i,u)=>i+=Jt(u,e).first().value,"")}));return k($r(r,o))}function Nu(e,t,n,r){for(;e.value&&g(e.value.type,56);){t.push(e.value);let o=zt(r,e.value.value);if(e=n.next(0),o&&o.node.nodeType!==3)break}return e}function nn(e,t,n,r,o){let a=t.h,i=r.value,u=o.value,l=null,p=null,A=null,x,C=[],T=[];return{next:()=>{for(;!x;)if(l||=i.next(0),l=Nu(l,C,i,a),p||=u.next(0),p=Nu(p,T,u,a),C.length||T.length){var P=yh(t,C,T);if(C.length=0,T.length=0,P.value===!1)return x=!0,P}else{if(l.done||p.done)return x=!0,k(l.done===p.done);if(A||=Xa(e,t,n,l.value,p.value),P=A.next(0),A=null,P.value===!1)return x=!0,P;p=l=null}return X}}}function wh(e,t,n,r,o){return r.h.length!==o.h.length?Kt(!1):Bu(r.h,a=>{let i=o.h.find(u=>$r(u.key,a.key));return i?nn(e,t,n,a.value(),i.value()):Kt(!1)})}function Ah(e,t,n,r,o){return r.members.length!==o.members.length?Kt(!1):Bu(r.members,(a,i)=>(i=o.members[i],nn(e,t,n,a(),i())))}function Tu(e,t,n,r,o){return r=Ct(t.h,r.value),o=Ct(t.h,o.value),r=r.filter(a=>Eu(a)),o=o.filter(a=>Eu(a)),r=f.create(r.map(a=>Be(a))),o=f.create(o.map(a=>Be(a))),nn(e,t,n,r,o)}function vh(e,t,n,r,o){let a=nn(e,t,n,vn(e,t,n,f.m(r)),vn(e,t,n,f.m(o))),i=Tu(e,t,n,r,o);r=Yn(t.h,r.value).filter(p=>p.node.namespaceURI!=="http://www.w3.org/2000/xmlns/").sort((p,A)=>p.node.nodeName>A.node.nodeName?1:-1).map(p=>Be(p)),o=Yn(t.h,o.value).filter(p=>p.node.namespaceURI!=="http://www.w3.org/2000/xmlns/").sort((p,A)=>p.node.nodeName>A.node.nodeName?1:-1).map(p=>Be(p));let u=nn(e,t,n,f.create(r),f.create(o)),l=!1;return{next:()=>{if(l)return X;var p=a.next(0);return!p.done&&p.value===!1||(p=u.next(0),!p.done&&p.value===!1)?(l=!0,p):(p=i.next(0),l=!0,p)}}}function xh(e,t,n,r,o){let a=nn(e,t,n,vn(e,t,n,f.m(r)),vn(e,t,n,f.m(o))),i=!1;return{next:()=>{if(i)return X;let u=a.next(0);return u.done||u.value!==!1?k($r(Jt(r,t).first(),Jt(o,t).first())):(i=!0,u)}}}function Xa(e,t,n,r,o){if(g(r.type,46)&&g(o.type,46))return Kt($r(r,o));if(g(r.type,61)&&g(o.type,61))return wh(e,t,n,r,o);if(g(r.type,62)&&g(o.type,62))return Ah(e,t,n,r,o);if(g(r.type,53)&&g(o.type,53)){if(g(r.type,55)&&g(o.type,55))return Tu(e,t,n,r,o);if(g(r.type,54)&&g(o.type,54))return vh(e,t,n,r,o);if(g(r.type,47)&&g(o.type,47)||g(r.type,57)&&g(o.type,57)||g(r.type,58)&&g(o.type,58))return xh(e,t,n,r,o)}return Kt(!1)}var Bh=class extends Qn{constructor(){super({L:null,Ba:-1,sa:f.empty(),qa:{}})}},bt=(e="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${e}`),Eh=e=>Error(`XUTY0004: The attribute ${e.name}="${e.value}" follows a node that is not an attribute node.`),Iu=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Cu=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),No=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),Fu=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Gu=e=>Error(`XUDY0017: The target ${e.outerHTML} is used in more than one replace value of expression.`),Ou=e=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${e}'`),To=e=>Error(`XUDY0023: The namespace binding ${e} is conflicting.`),Io=e=>Error(`XUDY0024: The namespace binding ${e} is conflicting.`),Co=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function b(e,t,n){return t&&t.L!==null&&e.B?(e.ob===null&&(e.ob=Se(e.h(new Bh,n).hb())),e=e.ob()):e=e.h(t,n),e}var re=class{constructor(e,t,n={B:!1,V:!1,P:"unsorted",subtree:!1},r=!1,o){this.o=e,this.ha=n.P||"unsorted",this.subtree=!!n.subtree,this.V=!!n.V,this.B=!!n.B,this.Ga=t,this.H=!1,this.ob=null,this.Sb=r,this.type=o}D(){return null}v(e){if(this.Ga.forEach(t=>t.v(e)),!this.Sb&&this.Ga.some(t=>t.H))throw bt()}},Du=class{constructor(e,t){this.I=e,this.ca=t}},Uu=class{constructor(e){e&&typeof e=="object"&&"nodeType"in e&&(e=e.ownerDocument||e,typeof e.createElementNS=="function"&&typeof e.createProcessingInstruction=="function"&&typeof e.createTextNode=="function"&&typeof e.createComment=="function"&&(this.h=e)),this.h||(this.h=null)}createAttributeNS(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(e,t)}createCDATASection(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createCDATASection(e)}createComment(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(e)}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(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(e,t)}createTextNode(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(e)}};function Ru(e,t,n,r){return Yn(r,e,`name-${t}`).some(o=>o.node.localName===t&&o.node.namespaceURI===n)}var Nh=(e,t,n,r)=>{let o=he(n,e).node,a=(e=zt(n,e))?e.node:null;t.forEach(i=>{r.insertBefore(o,i.node,a)})},Th=(e,t,n,r)=>{let o=he(n,e).node;t.forEach(a=>{r.insertBefore(o,a.node,e.node)})},Ih=(e,t,n,r)=>{let o=(n=po(n,e))?n.node:null;t.forEach(a=>{r.insertBefore(e.node,a.node,o)})},Su=(e,t,n)=>{t.forEach(r=>{n.insertBefore(e.node,r.node,null)})},Ch=(e,t,n,r)=>{t.forEach(o=>{let a=o.node.localName,i=o.node.namespaceURI;if(Ru(e,a,i,n))throw Ou(`An attribute ${i?`Q{${i}}${a}`:a} already exists.`);r.setAttributeNS(e.node,i,a,Ye(n,o))})},Fh=(e,t,n,r,o)=>{r||=new Uu(e?e.node:null);let a;switch(e.node.nodeType){case 1:let i=n.getAllAttributes(e.node),u=n.getChildNodes(e.node),l=r.createElementNS(t.namespaceURI,t.Aa());a={node:l,F:null},i.forEach(p=>{o.setAttributeNS(l,p.namespaceURI,p.nodeName,p.value)}),u.forEach(p=>{o.insertBefore(l,p,null)});break;case 2:t=r.createAttributeNS(t.namespaceURI,t.Aa()),t.value=Ye(n,e),a={node:t,F:null};break;case 7:a={node:r.createProcessingInstruction(t.Aa(),Ye(n,e)),F:null}}if(!he(n,e))throw Error("Not supported: renaming detached nodes.");Mu(e,[a],n,o)},Gh=(e,t,n,r)=>{n.getChildNodes(e.node).forEach(o=>r.removeChild(e.node,o)),t&&r.insertBefore(e.node,t.node,null)},Mu=(e,t,n,r)=>{let o=he(n,e);var a=e.node.nodeType;if(a===2){if(t.some(u=>u.node.nodeType!==2))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');let i=o?o.node:null;r.removeAttributeNS(i,e.node.namespaceURI,e.node.localName),t.forEach(u=>{let l=u.node.localName,p=u.node.namespaceURI;if(Ru(o,l,p,n))throw Ou(`An attribute ${p?`Q{${p}}${l}`:l} already exists.`);r.setAttributeNS(i,p,l,Ye(n,u))})}if(a===1||a===3||a===8||a===7){let i=(a=zt(n,e))?a.node:null;r.removeChild(o.node,e.node),t.forEach(u=>{r.insertBefore(o.node,u.node,i)})}},ku=(e,t,n,r)=>{if(Oh(e,t),e.filter(o=>["insertInto","insertAttributes","replaceValue","rename"].indexOf(o.type)!==-1).forEach(o=>{switch(o.type){case"insertInto":Su(o.target,o.content,r);break;case"insertAttributes":Ch(o.target,o.content,t,r);break;case"rename":Fh(o.target,o.o,t,n,r);break;case"replaceValue":var a=o.target;if(o=o.o,a.node.nodeType===2){let i=he(t,a);i?r.setAttributeNS(i.node,a.node.namespaceURI,a.node.localName,o):a.node.value=o}else r.setData(a.node,o)}}),e.filter(o=>["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(o.type)!==-1).forEach(o=>{switch(o.type){case"insertAfter":Nh(o.target,o.content,t,r);break;case"insertBefore":Th(o.target,o.content,t,r);break;case"insertIntoAsFirst":Ih(o.target,o.content,t,r);break;case"insertIntoAsLast":Su(o.target,o.content,r)}}),e.filter(o=>o.type==="replaceNode").forEach(o=>{Mu(o.target,o.o,t,r)}),e.filter(o=>o.type==="replaceElementContent").forEach(o=>{Gh(o.target,o.text,t,r)}),e.filter(o=>o.type==="delete").forEach(o=>{o=o.target;var a=he(t,o);(a=a?a.node:null)&&(o.node.nodeType===2?r.removeAttributeNS(a,o.node.namespaceURI,o.node.localName):r.removeChild(a,o.node))}),e.some(o=>o.type==="put"))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.')};let Oh=(e,t)=>{function n(a,i){let u=new Set;e.filter(l=>l.type===a).map(l=>l.target).forEach(l=>{l=l?l.node:null,u.has(l)&&i(l),u.add(l)})}n("rename",a=>{throw Error(`XUDY0015: The target ${a.outerHTML} is used in more than one rename expression.`)}),n("replaceNode",a=>{throw Error(`XUDY0016: The target ${a.outerHTML} is used in more than one replace expression.`)}),n("replaceValue",a=>{throw Gu(a)}),n("replaceElementContent",a=>{throw Gu(a)});let r=new Map,o=a=>new _e(a.node.prefix,a.node.namespaceURI,a.node.localName);e.filter(a=>a.type==="replaceNode"&&a.target.node.nodeType===2).forEach(a=>{var i=he(t,a.target);i=i?i.node:null;let u=r.get(i);u?u.push(...a.o.map(o)):r.set(i,a.o.map(o))}),e.filter(a=>a.type==="rename"&&a.target.node.nodeType===2).forEach(a=>{var i=he(t,a.target);if(i){i=i.node;var u=r.get(i);u?u.push(a.o):r.set(i,[a.o])}}),r.forEach(a=>{let i={};a.forEach(u=>{if(i[u.prefix]||(i[u.prefix]=u.namespaceURI),i[u.prefix]!==u.namespaceURI)throw Io(u.namespaceURI)})})};var Nt=(e,...t)=>e.concat(...t.filter(Boolean));function Rt(e){return e.H?(t,n)=>e.s(t,n):(t,n)=>{let r=e.h(t,n);return{next:()=>{let o=r.N();return k({ca:[],I:o})}}}}var Vn=class extends re{constructor(e,t,n,r){super(e,t,n,!0,r),this.H=!0}h(){throw bt()}};function Zn(e,t){return e=e.next(0),t(e.value.ca),f.create(e.value.I)}function Dh(e){e.Ga.some(t=>t.H)&&(e.H=!0)}var xn=class extends Vn{constructor(e,t,n,r){super(e,t,n,r),this.H=this.Ga.some(o=>o.H)}h(e,t){return this.A(e,t,this.Ga.map(n=>r=>n.h(r,t)))}s(e,t){let n=[],r=this.A(e,t,this.Ga.map(a=>a.H?i=>(i=a.s(i,t),Zn(i,u=>n=Nt(n,u))):i=>a.h(i,t))),o=!1;return{next:()=>{if(o)return X;let a=r.N();return o=!0,k(new Du(a,n))}}}v(e){super.v(e),Dh(this)}};let Fo=["external","attribute","nodeName","nodeType","universal"],Uh=Fo.length;function _n(e,t){for(let n=0;n<Uh;++n){if(t.h[n]<e.h[n])return 1;if(t.h[n]>e.h[n])return-1}return 0}var me=class{constructor(e){if(this.h=Fo.map(t=>e[t]||0),Object.keys(e).some(t=>!Fo.includes(t)))throw Error("Invalid specificity kind passed")}add(e){let t=Fo.reduce((n,r,o)=>(n[r]=this.h[o]+e.h[o],n),Object.create(null));return new me(t)}};let La=()=>mt("Expected base expression of a function call to evaluate to a sequence of single function item");function Wn(e,t,n,r){let o=[];for(let a=0;a<t.length;++a){if(t[a]===null){o.push(null);continue}let i=Ot(e[a],t[a],n,r,!1);o.push(i)}return o}function Hu(e,t){if(!g(e.type,60))throw mt("Expected base expression to evaluate to a function item");if(e.v!==t)throw La();return e}function Ya(e,t,n,r,o,a,i){let u=0;return o=o.map(l=>l?null:a[u++](n)),o=Wn(e.o,o,r,e.D),0<=o.indexOf(null)?I0(e,o):(t=t.apply(void 0,[n,r,i,...o]),Ot(e.s,t,r,e.D,!0))}var jr=class extends xn{constructor(e,t,n){super(new me({external:1}),[e].concat(t.filter(r=>!!r)),{P:"unsorted",V:!1,subtree:!1,B:!1},n),this.la=t.length,this.O=t.map(r=>r===null),this.K=null,this.ya=e,this.Ma=t}s(e,t){if(!this.l||!this.l.H)return super.s(e,t);let n=[],r=Ya(this.l,(a,i,u,...l)=>Zn(this.l.value(a,i,u,...l),p=>{n=Nt(n,p)}),e,t,this.O,this.Ma.map(a=>()=>a.H?Zn(a.s(e,t),i=>{n=Nt(n,i)}):b(a,e,t)),this.K),o=!1;return{next:()=>{if(o)return X;let a=r.N();return o=!0,k({ca:n,I:a})}}}A(e,t,[n,...r]){if(this.l)return Ya(this.l,(a,i,u,...l)=>this.l.value(a,i,u,...l),e,t,this.O,r,this.K);let o=n(e);return o.X({default:()=>{throw La()},m:()=>o.M(([a])=>{if(a=Hu(a,this.la),a.H)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return Ya(a,a.value,e,t,this.O,r,this.K)})})}v(e){if(this.K=Do(e),super.v(e),this.ya.B){if(e=b(this.ya,null,null),!e.oa())throw La();this.l=Hu(e.first(),this.la),this.l.H&&(this.H=!0)}}};let Pu=(e,t,n,r,o,a)=>de([r,o,a],([i,u,l])=>{if(u=u.value,l=l.value,u>i.members.length||0>=u)throw Error("FOAY0001: subarray start out of bounds.");if(0>l)throw Error("FOAY0002: subarray length out of bounds.");if(u+l>i.members.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return f.m(new ze(i.members.slice(u-1,l+u-1)))}),$u=(e,t,n,r,o)=>de([r],([a])=>o.M(i=>{i=i.map(l=>l.value).sort((l,p)=>p-l).filter((l,p,A)=>A[p-1]!==l);let u=a.members.concat();for(let l=0,p=i.length;l<p;++l){let A=i[l];if(A>a.members.length||0>=A)throw Error("FOAY0001: subarray position out of bounds.");u.splice(A-1,1)}return f.m(new ze(u))})),ju=e=>g(e,1)||g(e,20)||g(e,19),Xu=(e,t,n,r,o)=>r.length===0?o.length!==0:o.length!==0&&Xa(e,t,n,r[0],o[0]).next(0).value?Xu(e,t,n,r.slice(1),o.slice(1)):r[0].value!==r[0].value?!0:ju(r[0].type)&&o.length!==0&&ju(o[0].type)?r[0].value<o[0].value:o.length===0?!1:r[0].value<o[0].value,Rh=(e,t,n,r)=>(r.sort((o,a)=>nn(e,t,n,f.create(o),f.create(a)).next(0).value?0:Xu(e,t,n,o,a)?-1:1),f.m(new ze(r.map(o=>()=>f.create(o)))));function Lu(e){return g(e.type,62)?Bt(e.members.map(t=>t().M(n=>Bt(n.map(Lu))))):f.m(e)}var Sh=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>de([r],([o])=>f.m(v(o.members.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:va},{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:(e,t,n,r,o,a)=>de([o,r],([i,u])=>{if(i=i.value,0>=i||i>u.members.length)throw Error("FOAY0001: array position out of bounds.");return u=u.members.concat(),u.splice(i-1,1,Se(a)),f.m(new ze(u))})},{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:(e,t,n,r,o)=>de([r],([a])=>f.m(new ze(a.members.concat([Se(o)]))))},{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:Pu},{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(e,t,n,r,o){let a=f.m(v(r.first().value.length-o.first().value+1,5));return Pu(e,t,n,r,o,a)}},{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:$u},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,o,a)=>de([r,o],([i,u])=>{if(u=u.value,u>i.members.length+1||0>=u)throw Error("FOAY0001: subarray position out of bounds.");return i=i.members.concat(),i.splice(u-1,0,Se(a)),f.m(new ze(i))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(e,t,n,r){return va(e,t,n,r,f.m(v(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(e,t,n,r){return $u(e,t,n,r,f.m(v(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>de([r],([o])=>f.m(new ze(o.members.concat().reverse())))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r)=>r.M(o=>(o=o.reduce((a,i)=>a.concat(i.members),[]),f.m(new ze(o))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,o)=>de([r,o],([a,i])=>{if(i.v!==1)throw mt("The callback passed into array:for-each has a wrong arity.");return a=a.members.map(u=>Se(i.value.call(void 0,e,t,n,Wn(i.o,[u()],t,"array:for-each")[0]))),f.m(new ze(a))})},{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:(e,t,n,r,o)=>de([r,o],([a,i])=>{if(i.v!==1)throw mt("The callback passed into array:filter has a wrong arity.");let u=a.members.map(A=>{A=Wn(i.o,[A()],t,"array:filter")[0];let x=i.value;return x(e,t,n,A)}),l=[],p=!1;return f.create({next:()=>{if(p)return X;for(let x=0,C=a.members.length;x<C;++x){var A=u[x].ea();l[x]=A}return A=a.members.filter((x,C)=>l[C]),p=!0,k(new ze(A))}})})},{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:(e,t,n,r,o,a)=>de([r,a],([i,u])=>{if(u.v!==2)throw mt("The callback passed into array:fold-left has a wrong arity.");return i.members.reduce((l,p)=>(p=Wn(u.o,[p()],t,"array:fold-left")[0],u.value.call(void 0,e,t,n,l,p)),o)})},{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:(e,t,n,r,o,a)=>de([r,a],([i,u])=>{if(u.v!==2)throw mt("The callback passed into array:fold-right has a wrong arity.");return i.members.reduceRight((l,p)=>(p=Wn(u.o,[p()],t,"array:fold-right")[0],u.value.call(void 0,e,t,n,l,p)),o)})},{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:(e,t,n,r,o,a)=>de([r,o,a],([i,u,l])=>{if(l.v!==2)throw mt("The callback passed into array:for-each-pair has a wrong arity.");let p=[];for(let A=0,x=Math.min(i.members.length,u.members.length);A<x;++A){let[C,T]=Wn(l.o,[i.members[A](),u.members[A]()],t,"array:for-each-pair");p[A]=Se(l.value.call(void 0,e,t,n,C,T))}return f.m(new ze(p))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>de([r],([o])=>(o=o.members.map(a=>a().N()),Rh(e,t,n,o)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(e,t,n,r)=>r.M(o=>Bt(o.map(Lu)))}];function ee(e,t,n,r,o){return o.isEmpty()?o:f.m(xe(o.first(),e))}var Mh=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:ee.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:ee.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:ee.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,g:0},callFunction:ee.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:ee.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:ee.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:ee.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,g:0}],i:{type:18,g:0},callFunction:ee.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:ee.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:ee.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:ee.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",j:[{type:46,g:0}],i:{type:7,g:0},callFunction:ee.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:ee.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:ee.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:ee.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:ee.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:ee.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:ee.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:ee.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(e,t,n,r)=>{if(r.isEmpty())return r;if(e=r.first(),g(e.type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");if(e=xe(e,1).value,e=Ca(e,23),!vo(e,23))throw Error("FORG0001: The provided QName is invalid.");if(!e.includes(":"))return n=n.Z(""),f.m(v(new _e("",n,e),23));let[o,a]=e.split(":");if(n=n.Z(o),!n)throw Error(`FONS0004: The value ${e} can not be cast to a QName. Did you mean to use fn:QName?`);return f.m(v(new _e(o,n,a),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:ee.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:ee.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:ee.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],i:{type:51,g:0},callFunction:ee.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:ee.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:ee.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:ee.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",j:[{type:46,g:0}],i:{type:24,g:0},callFunction:ee.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:ee.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:ee.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:ee.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:ee.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",j:[{type:46,g:0}],i:{type:40,g:2},callFunction:ee.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",j:[{type:46,g:0}],i:{type:5,g:0},callFunction:ee.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",j:[{type:46,g:0}],i:{type:27,g:0},callFunction:ee.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:ee.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:ee.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:ee.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:ee.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:ee.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:ee.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:ee.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:ee.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:ee.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:ee.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:ee.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:ee.bind(null,16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:ee.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:ee.bind(null,10)}];let Yu=(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getYear(),5)),qu=(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getMonth(),5)),Qu=(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getDay(),5)),Ju=(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getHours(),5)),Ku=(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getMinutes(),5)),bu=(e,t,n,r)=>(r.isEmpty()||(e=f,t=e.m,r=r.first().value,r=t.call(e,v(r.D+r.ma,4))),r),qa=(e,t,n,r)=>r.isEmpty()?r:(e=r.first().value.W)?f.m(v(e,17)):f.empty();var kh=[{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:(e,t,n,r,o)=>{if(r.isEmpty())return r;if(o.isEmpty())return o;if(e=r.first().value,o=o.first().value,t=e.W,n=o.W,t||n){if(!t||n){if(!t&&n)t=n;else if(!t.equals(n))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.")}}else t=null;return o=new be(e.getYear(),e.getMonth(),e.getDay(),o.getHours(),o.getMinutes(),o.getSeconds(),o.ma,t),f.m(v(o,9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Yu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:qu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Qu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Ju},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Ku},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:bu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:qa},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Yu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:qu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Qu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:qa},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Ju},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Ku},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:bu},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:qa}];function Go(e,t){let n=t.h,r=t.Ja,o=t.Oa;switch(e.node.nodeType){case 1:let i=r.createElementNS(e.node.namespaceURI,e.node.nodeName);n.getAllAttributes(e.node).forEach(u=>o.setAttributeNS(i,u.namespaceURI,u.nodeName,u.value));for(var a of Ct(n,e))e=Go(a,t),o.insertBefore(i,e.node,null);return{node:i,F:null};case 2:return t=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName),t.value=Ye(n,e),{node:t,F:null};case 4:return{node:r.createCDATASection(Ye(n,e)),F:null};case 8:return{node:r.createComment(Ye(n,e)),F:null};case 9:a=r.createDocument();for(let u of Ct(n,e))e=Go(u,t),o.insertBefore(a,e.node,null);return{node:a,F:null};case 7:return{node:r.createProcessingInstruction(e.node.target,Ye(n,e)),F:null};case 3:return{node:r.createTextNode(Ye(n,e)),F:null}}}function Qa(e,t){let n=t.Oa;var r=t.Ja;let o=t.h;if(We(e.node))switch(e.node.nodeType){case 2:return r=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName),r.value=Ye(o,e),r;case 8:return r.createComment(Ye(o,e));case 1:let a=e.node.prefix,i=e.node.localName,u=r.createElementNS(e.node.namespaceURI,a?a+":"+i:i);return Ct(o,e).forEach(l=>{l=Qa(l,t),n.insertBefore(u,l,null)}),Yn(o,e).forEach(l=>{n.setAttributeNS(u,l.node.namespaceURI,l.node.nodeName,Ye(o,l))}),u.normalize(),u;case 7:return r.createProcessingInstruction(e.node.target,Ye(o,e));case 3:return r.createTextNode(Ye(o,e))}else return Go(e,t).node}function Hh(e,t,n){let r=e;for(e=he(n,r);e!==null;){if(r.node.nodeType===2)t.push(r.node.nodeName);else{let o=Ct(n,e);t.push(o.findIndex(a=>$e(a,r)))}r=e,e=he(n,r)}return r}function Ph(e,t,n){for(;0<t.length;){let r=t.pop();typeof r=="string"?e=Yn(n,e).find(o=>o.node.nodeName===r):e=Ct(n,e)[r]}return e.node}function Ve(e,t,n){var r=e.node;if(!(We(r)||n||e.F))return r;r=t.v;let o=[];return n?Qa(e,t):(e=Hh(e,o,t.h),n=r.get(e.node),n||(n={node:Qa(e,t),F:null},r.set(e.node,n)),Ph(n,o,t.h))}let Vu=(e,t,n,r,o)=>r.M(a=>{var i;let u="";for(let l=0;l<a.length;l++){let p=a[l],A=t.Wa&&g(p.type,53)?t.Wa.serializeToString(Ve(p.value,t,!1)):(i=Me(f.m(p),t).map(x=>xe(x,1)).first())===null||i===void 0?void 0:i.value;A&&(u+=`{type: ${we[p.type]}, value: ${A}}
|
|
2
|
+
`)}return o!==void 0&&(u+=o.first().value),t.jb.trace(u),f.create(a)});var $h=[{j:[{type:59,g:2}],callFunction:Vu,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:Vu,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];let Ja=(e,t,n,r,o)=>{throw e=r===void 0||r.isEmpty()?new _e("err","http://www.w3.org/2005/xqt-errors","FOER0000"):r.first().value,t="",o===void 0||o.isEmpty()||(t=`: ${o.first().value}`),Error(`${e.localName}${t}`)};var jh=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:Ja},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:Ja},{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:Ja},{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,g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported")}}];function St(e){return typeof e=="string"?e:(e=new Wt().getChildNodes(e).find(t=>t.nodeType===8))?e.data:"some expression"}var Zu=class extends Error{constructor(e,t){super(e),this.position={end:{ga:t.end.ga,line:t.end.line,offset:t.end.offset},start:{ga:t.start.ga,line:t.start.line,offset:t.start.offset}}}};function at(e,t){if(t instanceof Error)throw t;typeof e!="string"&&(e=St(e));let n=Bl(t);e=e.replace(/\r/g,"").split(`
|
|
3
|
+
`);let r=Math.floor(Math.log10(Math.min(n.end.line+2,e.length)))+1;throw e=e.reduce((o,a,i)=>{var u=i+1;if(2<n.start.line-u||2<u-n.end.line)return o;if(i=`${Array(r).fill(" ",0,Math.floor(Math.log10(u))+1-r).join("")}${u}: `,o.push(`${i}${a}`),u>=n.start.line&&u<=n.end.line){let l=u<n.end.line?a.length+i.length:n.end.ga-1+i.length;u=u>n.start.line?i.length:n.start.ga-1+i.length,a=" ".repeat(i.length)+Array.from(a.substring(0,u-i.length),p=>p===" "?" ":" ").join("")+"^".repeat(l-u),o.push(a)}return o},[]),t=El(t).join(`
|
|
4
|
+
`),new Zu(e.join(`
|
|
5
|
+
`)+`
|
|
6
|
+
|
|
7
|
+
`+t,n)}let rn=Object.create(null);function Xh(e,t){let n=new Map;for(let r=0;r<e.length+1;++r)n.set(r,new Map);return(function r(o,a){if(o===0)return a;if(a===0)return o;if(n.get(o).has(a))return n.get(o).get(a);var i=0;return e[o-1]!==t[a-1]&&(i=1),i=Math.min(r(o-1,a)+1,r(o,a-1)+1,r(o-1,a-1)+i),n.get(o).set(a,i),i})(e.length,t.length)}function Ka(e){let t=rn[e]?rn[e]:Object.keys(rn).map(n=>({name:n,sb:Xh(e,n.slice(n.lastIndexOf(":")+1))})).sort((n,r)=>n.sb-r.sb).slice(0,5).filter(n=>n.sb<e.length/2).reduce((n,r)=>n.concat(rn[r.name]),[]).slice(0,5);return t.length?t.map(n=>`"Q{${n.namespaceURI}}${n.localName} (${n.j.map(r=>r===4?"...":wt(r)).join(", ")})"`).reduce((n,r,o,a)=>o===0?n+r:n+((o!==a.length-1?", ":" or ")+r),"Did you mean ")+"?":"No similar functions found."}function ba(e,t,n){var r=rn[e+":"+t];return r&&(r=r.find(o=>o.j.some(a=>a===4)?o.j.length-1<=n:o.j.length===n))?{j:r.j,arity:n,callFunction:r.callFunction,H:r.H,localName:t,namespaceURI:e,i:r.i}:null}function _u(e,t,n,r,o){rn[e+":"+t]||(rn[e+":"+t]=[]),rn[e+":"+t].push({j:n,arity:n.length,callFunction:o,H:!1,localName:t,namespaceURI:e,i:r})}var Xr={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"},Oo=class{constructor(e,t,n,r){this.Ea=[Object.create(null)],this.Fa=Object.create(null),this.s=e,this.ha=Object.keys(t).reduce((o,a)=>(t[a]===void 0||(o[a]=`Q{}${a}[0]`),o),Object.create(null)),this.o=Object.create(null),this.h=Object.create(null),this.v=n,this.l=r,this.D=[]}ua(e,t,n){return ba(e,t,n)}eb(e,t){return e?null:(e=this.ha[t],this.o[t]||(this.o[t]={name:t}),e)}Ua(e,t){let n=this.l(e,t);if(n)this.D.push({fc:e,arity:t,Eb:n});else if(e.prefix===""){if(this.v)return{namespaceURI:this.v,localName:e.localName}}else if(t=this.Z(e.prefix,!0))return{namespaceURI:t,localName:e.localName};return n}Z(e,t=!0){return t?Xr[e]?Xr[e]:(t=this.s(e),this.h[e]||(this.h[e]={namespaceURI:t,prefix:e}),t!==void 0||e?t:null):null}},Lh=(e,t)=>(e=e.node.nodeType===2?`${e.node.nodeName}="${Ye(t,e)}"`:e.node.outerHTML,Error(`XQTY0024: The node ${e} follows a node that is not an attribute node or a namespace node.`)),Lr=e=>Error(`XQDY0044: The node name "${e.Aa()}" is invalid for a computed attribute constructor.`),Wu=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),zu=(e,t)=>Error(`XQST0049: The function or variable "Q{${e}}${t}" is declared more than once.`),Va=()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),el=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),Za=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),tl=e=>Error(`XQDY0074: The value "${e}" of a name expressions cannot be converted to an expanded QName.`),nl=e=>Error(`XPST0081: The prefix "${e}" could not be resolved`);function zn(e,t){return`Q{${e||""}}${t}`}function rl(e,t){for(let n=e.length-1;0<=n;--n)if(t in e[n])return e[n][t]}function Do(e){let t=new En(e.o);for(let n=0;n<e.h+1;++n)t.D=[Object.assign(Object.create(null),t.D[0],e.D[n])],t.Ea=[Object.assign(Object.create(null),t.Ea[0],e.Ea[n])],t.l=Object.assign(Object.create(null),e.l),t.Fa=e.Fa,t.v=e.v;return t}function er(e){e.s++,e.h++,e.D[e.h]=Object.create(null),e.Ea[e.h]=Object.create(null)}function Yh(e,t,n){return(e=e.Fa[zn(t,n)])?e:null}function _a(e,t,n,r,o){if(r=zn(t,n)+"~"+r,e.l[r])throw zu(t,n);e.l[r]=o}function Bn(e,t,n){e.D[e.h][t]=n}function Mt(e,t,n){return t=zn(t||"",n),e.Ea[e.h][t]=`${t}[${e.s}]`}function ol(e,t,n,r){e.Fa[`${zn(t||"",n)}[${e.s}]`]=r}function tr(e){e.D.length=e.h,e.Ea.length=e.h,e.h--}var En=class{constructor(e){this.o=e,this.s=this.h=0,this.D=[Object.create(null)],this.l=Object.create(null),this.v=null,this.Fa=e&&e.Fa,this.Ea=e&&e.Ea}ua(e,t,n,r=!1){let o=this.l[zn(e,t)+"~"+n];return!o||r&&o.wb?this.o===null?null:this.o.ua(e,t,n,r):o}eb(e,t){let n=rl(this.Ea,zn(e,t));return n||(this.o===null?null:this.o.eb(e,t))}Ua(e,t){var n=e.prefix;let r=e.localName;return n===""&&this.v?{localName:r,namespaceURI:this.v}:n&&(n=this.Z(n,!1))?{localName:r,namespaceURI:n}:this.o===null?null:this.o.Ua(e,t)}Z(e,t=!0){let n=rl(this.D,e||"");return n===void 0?this.o===null?void 0:this.o.Z(e||"",t):n}};function B(e,t){t==="*"||Array.isArray(t)||(t=[t]);for(let n=1;n<e.length;++n){if(!Array.isArray(e[n]))continue;let r=e[n];if(t==="*"||t.includes(r[0]))return r}return null}function se(e){return 2>e.length?"":typeof e[1]=="object"?e[2]||"":e[1]||""}function J(e,t){return Array.isArray(e)?(e=e[1],typeof e!="object"||Array.isArray(e)?null:t in e?e[t]:null):null}function $(e,t){return t.reduce(B,e)}function q(e,t){let n=[];for(let r=1;r<e.length;++r){if(!Array.isArray(e[r]))continue;let o=e[r];t!=="*"&&o[0]!==t||n.push(o)}return n}function Ne(e){return{localName:se(e),namespaceURI:J(e,"URI"),prefix:J(e,"prefix")}}function Uo(e){let t=B(e,"typeDeclaration");if(!t||B(t,"voidSequenceType"))return{type:59,g:2};let n=a=>{switch(a[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;case"atomicType":return lt([J(a,"prefix"),se(a)].join(":"));case"parenthesizedItemType":return n(B(a,"*"));default:throw Error(`Type declaration "${B(t,"*")[0]}" is not supported.`)}};e={type:n(B(t,"*")),g:3};let r=null,o=B(t,"occurrenceIndicator");switch(o&&(r=se(o)),r){case"*":return e.g=2,e;case"?":return e.g=0,e;case"+":return e.g=1,e;case"":case null:return e}}function W(e,t,n){if(typeof e[1]!="object"||Array.isArray(e[1])){let r={};r[t]=n,e.splice(1,0,r)}else e[1][t]=n}function qh(e){let t={type:62,g:3};return W(e,"type",t),t}function Qh(e,t){if(!t||!t.fa)return{type:59,g:2};var n=B(e,"EQName");if(!n)return{type:59,g:2};var r=Ne(n);n=r.localName;let o=r.prefix;return r=q(B(e,"arguments"),"*"),n=t.fa.Ua({localName:n,prefix:o},r.length),n?(t=t.fa.ua(n.namespaceURI,n.localName,r.length+1),t?(t.i.type!==59&&W(e,"type",t.i),t.i):{type:59,g:2}):{type:59,g:2}}function M(e,t,n){return(e<<20)+(t<<12)+(n.charCodeAt(0)<<8)+n.charCodeAt(1)}var Ro={[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,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},al={[M(2,2,"addOp")]:(e,t)=>e+t,[M(2,2,"subtractOp")]:(e,t)=>e-t,[M(2,2,"multiplyOp")]:(e,t)=>e*t,[M(2,2,"divOp")]:(e,t)=>e/t,[M(2,2,"modOp")]:(e,t)=>e%t,[M(2,2,"idivOp")]:(e,t)=>Math.trunc(e/t),[M(16,16,"addOp")]:function(e,t){return new Kn(e.da+t.da)},[M(16,16,"subtractOp")]:function(e,t){return new Kn(e.da-t.da)},[M(16,16,"divOp")]:function(e,t){return e.da/t.da},[M(16,2,"multiplyOp")]:Li,[M(16,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");if(e=Math.round(e.da/t),e>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new Kn(e<Number.MIN_SAFE_INTEGER||e===0?0:e)},[M(2,16,"multiplyOp")]:(e,t)=>Li(t,e),[M(17,17,"addOp")]:function(e,t){return new yn(e.ba+t.ba)},[M(17,17,"subtractOp")]:function(e,t){return new yn(e.ba-t.ba)},[M(17,17,"divOp")]:function(e,t){if(t.ba===0)throw Error("FOAR0001: Division by 0");return e.ba/t.ba},[M(17,2,"multiplyOp")]:Ui,[M(17,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");if(e=e.ba/t,e>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");return new yn(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)},[M(2,17,"multiplyOp")]:(e,t)=>Ui(t,e),[M(9,9,"subtractOp")]:Na,[M(7,7,"subtractOp")]:Na,[M(8,8,"subtractOp")]:Na,[M(9,16,"addOp")]:Ft,[M(9,16,"subtractOp")]:Gt,[M(9,17,"addOp")]:Ft,[M(9,17,"subtractOp")]:Gt,[M(7,16,"addOp")]:Ft,[M(7,16,"subtractOp")]:Gt,[M(7,17,"addOp")]:Ft,[M(7,17,"subtractOp")]:Gt,[M(8,17,"addOp")]:Ft,[M(8,17,"subtractOp")]:Gt,[M(9,16,"addOp")]:Ft,[M(9,16,"subtractOp")]:Gt,[M(9,17,"addOp")]:Ft,[M(9,17,"subtractOp")]:Gt,[M(7,17,"addOp")]:Ft,[M(7,17,"subtractOp")]:Gt,[M(7,16,"addOp")]:Ft,[M(7,16,"subtractOp")]:Gt,[M(8,17,"addOp")]:Ft,[M(8,17,"subtractOp")]:Gt};function sl(e,t){return g(e,5)&&g(t,5)?5:g(e,4)&&g(t,4)?4:g(e,6)&&g(t,6)?6:3}let So=[2,16,17,9,7,8];function il(e,t,n){function r(l,p){return{T:o?o(l):l,U:a?a(p):p}}let o=null,a=null;g(t,19)&&(o=l=>xe(l,3),t=3),g(n,19)&&(a=l=>xe(l,3),n=3);let i=So.filter(l=>g(t,l)),u=So.filter(l=>g(n,l));if(i.includes(2)&&u.includes(2)){let l=al[M(2,2,e)],p=Ro[M(2,2,e)];return p||=sl(t,n),e==="divOp"&&p===5&&(p=4),e==="idivOp"?ul(r,l)[0]:(A,x)=>{let{T:C,U:T}=r(A,x);return v(l(C.value,T.value),p)}}for(let l of i)for(let p of u){let A=al[M(l,p,e)],x=Ro[M(l,p,e)];if(A&&x!==void 0)return(C,T)=>{let{T:P,U:_}=r(C,T);return v(A(P.value,_.value),x)}}}function Jh(e,t,n){function r(p,A){return{T:a?a(p):p,U:i?i(A):A}}var o=[2,53,59,46,47];if(o.includes(t)||o.includes(n))return 2;let a=null,i=null;g(t,19)&&(a=p=>xe(p,3),t=3),g(n,19)&&(i=p=>xe(p,3),n=3);var u=So.filter(p=>g(t,p));if(o=So.filter(p=>g(n,p)),u.includes(2)&&o.includes(2)){var l=Ro[M(2,2,e)];return l===void 0&&(l=sl(t,n)),e==="divOp"&&l===5&&(l=4),e==="idivOp"?ul(r,(p,A)=>Math.trunc(p/A))[1]:l}for(l of u)for(let p of o)if(u=Ro[M(l,p,e)],u!==void 0)return u}function ul(e,t){return[(n,r)=>{let{T:o,U:a}=e(n,r);if(a.value===0)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(o.value)||Number.isNaN(a.value)||!Number.isFinite(o.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(o.value)&&!Number.isFinite(a.value)?v(0,5):v(t(o.value,a.value),5)},5]}let ll=Object.create(null);var Kh=class extends re{constructor(e,t,n,r,o){super(t.o.add(n.o),[t,n],{B:!1},!1,r),this.A=t,this.K=n,this.l=e,this.s=o}h(e,t){return Me(b(this.A,e,t),t).M(n=>n.length===0?f.empty():Me(b(this.K,e,t),t).M(r=>{if(r.length===0)return f.empty();if(1<n.length||1<r.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');let o=n[0];if(r=r[0],this.s&&this.type)return f.m(this.s(o,r));var a=o.type,i=r.type,u=this.l;let l=`${a}~${i}~${u}`,p=ll[l];if(p||=ll[l]=il(u,a,i),a=p,!a)throw Error(`XPTY0004: ${this.l} not available for types ${we[o.type]} and ${we[r.type]}`);return f.m(a(o,r))}))}};function bh(e,t){var n=te;let r=!1;for(var o=1;o<e.length;o++)switch(e[o][0]){case"letClause":Mo(t);var a=e[o],i=t,u=n,l=$(a,["letClauseItem","typedVariableBinding","varName"]);l=Ne(l),a=$(a,["letClauseItem","letExpr"]),u=u(a[1],i),ml(i,l.localName,u);break;case"forClause":r=!0,Mo(t),Vh(e[o],t,n);break;case"whereClause":Mo(t),i=e[o],n(i,t),W(i,"type",{type:0,g:3});break;case"orderByClause":Mo(t);break;case"returnClause":return o=e[o],i=n,n=$(o,["*"]),t=i(n,t),W(n,"type",t),W(o,"type",t),n=t,n?(r&&(n={type:n.type,g:2}),n.type!==59&&W(e,"type",n),n):{type:59,g:2};default:return n=n(e[o],t),n?(r&&(n={type:n.type,g:2}),n.type!==59&&W(e,"type",n),n):{type:59,g:2}}if(0<t.h)t.h--,t.o.pop(),t.v.pop();else throw Error("Variable scope out of bound")}function Vh(e,t,n){let r=Ne($(e,["forClauseItem","typedVariableBinding","varName"]));(e=$(e,["forClauseItem","forExpr","sequenceExpr"]))&&(e=q(e,"*").map(o=>n(o,t)),e.includes(void 0)||e.includes(null)||(e=cl(e),e.length===1&&ml(t,r.localName,e[0])))}function cl(e){return e.filter((t,n,r)=>r.findIndex(o=>o.type===t.type&&o.g===t.g)===n)}function Zh(e,t){if(!t||!t.fa)return{type:59,g:2};let n=B(e,"functionName");var r=Ne(n);let o=r.localName;var a=r.prefix;let i=r.namespaceURI;if(r=q(B(e,"arguments"),"*"),i===null){if(a=t.fa.Ua({localName:o,prefix:a},r.length),!a)return{type:59,g:2};o=a.localName,i=a.namespaceURI,W(n,"URI",i),n[2]=o}return t=t.fa.ua(i,o,r.length),!t||t.i.type===63?{type:59,g:2}:(t.i.type!==59&&W(e,"type",t.i),t.i)}function _h(e){let t={type:61,g:3};return W(e,"type",t),t}function Wh(e,t){if(!t||!t.fa)return{type:59,g:2};let n=B(e,"functionName");var r=Ne(n);let o=r.localName;var a=r.namespaceURI;let i=r.prefix;if(r=Number($(e,["integerConstantExpr","value"])[1]),!a){if(a=t.fa.Ua({localName:o,prefix:i},r),!a)return{type:59,g:2};o=a.localName,a=a.namespaceURI,W(n,"URI",a)}return t=t.fa.ua(a,o,r)||null,t?(t.i.type!==59&&t.i.type!==63&&W(e,"type",t.i),t.i):{type:59,g:2}}function zh(e,t){var n=q(e,"stepExpr");if(!n)return{type:59,g:2};for(let a of n){e:{n=a;var r=t;let i=null;if(!n)break e;var o=q(n,"*");let u="";for(let l of o)switch(l[0]){case"filterExpr":i=J($(l,["*"]),"type");break;case"xpathAxis":u=l[1];t:{switch(u){case"attribute":i={type:47,g:2};break t;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":i={type:53,g:2};break t}i=void 0}break;case"nameTest":if(o=Ne(l),o.namespaceURI!==null||u==="attribute"&&!o.prefix)break;o=r.Z(o.prefix||""),o!==void 0&&W(l,"URI",o);break;case"lookup":i={type:59,g:2}}i&&i.type!==59&&W(n,"type",i)}r=J(a,"type")}return r&&r.type!==59&&W(e,"type",r),r}function ef(e){let t={type:0,g:3};return W(e,"type",t),t}function tf(e,t,n){return t===0?t={type:53,g:2}:t===1?t=n[0]:n.includes(void 0)||n.includes(null)?t={type:59,g:2}:(t=cl(n),t=1<t.length?{type:59,g:2}:{type:t[0].type,g:2}),t&&t.type!==59&&W(e,"type",t),t}function nf(e,t,n,r){if(!t||n.includes(void 0))return{type:59,g:2};var o=q(e,"typeswitchExprCaseClause");for(let i=0;i<n.length;i++){var a=B(o[i],"*");switch(a[0]){case"sequenceType":if(a=pl(a,t,n[i]))return a.type!==59&&W(e,"type",a),a;continue;case"sequenceTypeUnion":for(r=q(a,"*"),o=0;2>o;o++)if(a=pl(r[o],t,n[i]))return a.type!==59&&W(e,"type",a),a;default:return{type:59,g:2}}}return r.type!==59&&W(e,"type",r),r}function pl(e,t,n){let r=q(e,"*"),o=B(e,"atomicType");if(!o)return{type:59,g:2};if(lt(J(o,"prefix")+":"+o[2])===t.type){if(r.length===1){if(t.g===3)return n}else if(e=B(e,"occurrenceIndicator")[1],t.g===ya(e))return n}}function hl(e,t){te(e,t)}function te(e,t){var n=rf.get(e[0]);if(n)return n(e,t);for(n=1;n<e.length;n++)e[n]&&te(e[n],t)}let nr=(e,t)=>{var n=te(B(e,"firstOperand")[1],t);let r=te(B(e,"secondOperand")[1],t);var o=e[0];if(n&&r)if(t=Jh(o,n.type,r.type))n={type:t,g:n.g},t!==2&&t!==59&&W(e,"type",n),e=n;else throw Error(`XPTY0004: ${o} not available for types ${wt(n)} and ${wt(r)}`);else e={type:2,g:3};return e},fl=(e,t)=>{te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t);e:{switch(e[0]){case"orOp":t={type:0,g:3},W(e,"type",t),e=t;break e;case"andOp":t={type:0,g:3},W(e,"type",t),e=t;break e}e=void 0}return e},Wa=(e,t)=>{te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t);e:{switch(e[0]){case"unionOp":t={type:53,g:2},W(e,"type",t),e=t;break e;case"intersectOp":t={type:53,g:2},W(e,"type",t),e=t;break e;case"exceptOp":t={type:53,g:2},W(e,"type",t),e=t;break e}e=void 0}return e},rr=(e,t)=>(te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t),t={type:0,g:3},W(e,"type",t),t),or=(e,t)=>{te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t),t=J($(e,["firstOperand","*"]),"type");let n=J($(e,["secondOperand","*"]),"type");return t={type:0,g:An(t)||An(n)?0:3},W(e,"type",t),t},za=(e,t)=>{te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t),t=J($(e,["firstOperand","*"]),"type");let n=J($(e,["secondOperand","*"]),"type");return t={type:0,g:An(t)||An(n)?0:3},W(e,"type",t),t},rf=new Map([["unaryMinusOp",(e,t)=>(t=te(B(e,"operand")[1],t),t?g(t.type,2)?(t={type:t.type,g:t.g},W(e,"type",t),e=t):(t={type:3,g:3},W(e,"type",t),e=t):(t={type:2,g:2},W(e,"type",t),e=t),e)],["unaryPlusOp",(e,t)=>(t=te(B(e,"operand")[1],t),t?g(t.type,2)?(t={type:t.type,g:t.g},W(e,"type",t),e=t):(t={type:3,g:3},W(e,"type",t),e=t):(t={type:2,g:2},W(e,"type",t),e=t),e)],["addOp",nr],["subtractOp",nr],["divOp",nr],["idivOp",nr],["modOp",nr],["multiplyOp",nr],["andOp",fl],["orOp",fl],["sequenceExpr",(e,t)=>{let n=q(e,"*"),r=n.map(o=>te(o,t));return tf(e,n.length,r)}],["unionOp",Wa],["intersectOp",Wa],["exceptOp",Wa],["stringConcatenateOp",(e,t)=>(te(B(e,"firstOperand")[1],t),te(B(e,"secondOperand")[1],t),t={type:1,g:3},W(e,"type",t),t)],["rangeSequenceExpr",(e,t)=>(te(B(e,"startExpr")[1],t),te(B(e,"endExpr")[1],t),t={type:5,g:1},W(e,"type",t),t)],["equalOp",rr],["notEqualOp",rr],["lessThanOrEqualOp",rr],["lessThanOp",rr],["greaterThanOrEqualOp",rr],["greaterThanOp",rr],["eqOp",or],["neOp",or],["ltOp",or],["leOp",or],["gtOp",or],["geOp",or],["isOp",za],["nodeBeforeOp",za],["nodeAfterOp",za],["pathExpr",(e,t)=>{let n=B(e,"rootExpr");return n&&n[1]&&te(n[1],t),q(e,"stepExpr").map(r=>te(r,t)),zh(e,t)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(e,t)=>{var n=B(e,"ifClause")||B(q(e,"x:stackTrace")[0],"ifClause");let r=B(e,"thenClause")||B(q(e,"x:stackTrace")[1],"thenClause"),o=B(e,"elseClause")||B(q(e,"x:stackTrace")[2],"elseClause");return te(B(n,"*"),t),n=te(B(r,"*"),t),t=te(B(o,"*"),t),n&&t?n.type===t.type&&n.g===t.g?(n.type!==59&&W(e,"type",n),e=n):e={type:59,g:2}:e={type:59,g:2},e}],["instanceOfExpr",(e,t)=>(te(B(e,"argExpr"),t),te(B(e,"sequenceType"),t),t={type:0,g:3},W(e,"type",t),t)],["integerConstantExpr",e=>{let t={type:5,g:3};return W(e,"type",t),t}],["doubleConstantExpr",e=>{let t={type:3,g:3};return W(e,"type",t),t}],["decimalConstantExpr",e=>{let t={type:4,g:3};return W(e,"type",t),t}],["stringConstantExpr",e=>{let t={type:1,g:3};return W(e,"type",t),t}],["functionCallExpr",(e,t)=>{let n=B(e,"arguments");return q(n,"*").map(r=>te(r,t)),Zh(e,t)}],["arrowExpr",(e,t)=>(te(B(e,"argExpr")[1],t),Qh(e,t))],["dynamicFunctionInvocationExpr",(e,t)=>(te($(e,["functionItem","*"]),t),(e=B(e,"arguments"))&&te(e,t),{type:59,g:2})],["namedFunctionRef",(e,t)=>Wh(e,t)],["inlineFunctionExpr",(e,t)=>(te(B(e,"functionBody")[1],t),t={type:60,g:3},W(e,"type",t),t)],["castExpr",e=>{var t=$(e,["singleType","atomicType"]);return t=J(t,"prefix")+":"+t[2],t={type:lt(t),g:3},t.type!==59&&W(e,"type",t),t}],["castableExpr",e=>{let t={type:0,g:3};return W(e,"type",t),t}],["simpleMapExpr",(e,t)=>{let n=q(e,"pathExpr"),r;for(let o=0;o<n.length;o++)r=te(n[o],t);return r!=null?(t={type:r.type,g:2},t.type!==59&&W(e,"type",t),e=t):e={type:59,g:2},e}],["mapConstructor",(e,t)=>(q(e,"mapConstructorEntry").map(n=>({key:te($(n,["mapKeyExpr","*"]),t),value:te($(n,["mapValueExpr","*"]),t)})),_h(e))],["arrayConstructor",(e,t)=>(q(B(e,"*"),"arrayElem").map(n=>te(n,t)),qh(e))],["unaryLookup",e=>(B(e,"NCName"),{type:59,g:2})],["typeswitchExpr",(e,t)=>{let n=te(B(e,"argExpr")[1],t),r=q(e,"typeswitchExprCaseClause").map(a=>te($(a,["resultExpr"])[1],t)),o=te($(e,["typeswitchExprDefaultClause","resultExpr"])[1],t);return nf(e,n,r,o)}],["quantifiedExpr",(e,t)=>(q(e,"*").map(n=>te(n,t)),ef(e))],["x:stackTrace",(e,t)=>(e=q(e,"*"),te(e[0],t))],["queryBody",(e,t)=>te(e[1],t)],["flworExpr",(e,t)=>bh(e,t)],["varRef",(e,t)=>{let n=Ne(B(e,"name"));var r;e:{for(r=t.h;0<=r;r--){let o=t.o[r][n.localName];if(o){r=o;break e}}r=void 0}return r&&r.type!==59&&W(e,"type",r),n.namespaceURI===null&&(t=t.Z(n.prefix),t!==void 0&&W(e,"URI",t)),r}]]);function Mo(e){e.h++,e.o.push({}),e.v.push({})}function ml(e,t,n){if(e.o[e.h][t])throw Error(`Another variable of in the scope ${e.h} with the same name ${t} already exists`);e.o[e.h][t]=n}var ko=class{constructor(e){this.h=0,this.fa=e,this.o=[{}],this.v=[{}]}Z(e){for(let t=this.h;0<=t;t--){let n=this.v[t][e];if(n!==void 0)return n}return this.fa?this.fa.Z(e):void 0}},of=class extends xn{constructor(e,t){super(e.reduce((n,r)=>0<_n(n,r.o)?n:r.o,new me({})),e,{B:e.every(n=>n.B)},t)}A(e,t,n){for(let r of n)if(t=r(e),!t.isEmpty())return t;return f.empty()}};let dl=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]),gl=new Map([["name","type-1-or-type-2"],["type-1","type-1-or-type-2"],["type-2","type-1-or-type-2"]]);function ct(e,t){if(e===null)return t;if(t===null||e===t)return e;let n=e.startsWith("name-")?"name":e,r=t.startsWith("name-")?"name":t,o=dl.get(n);return o!==void 0&&o.includes(r)?t:(t=dl.get(r),t!==void 0&&t.includes(n)?e:"empty")}function yl(e,t){if(e===null||t===null)return null;if(e==="empty")return t;if(t==="empty"||e===t)return e;e=e.startsWith("name-")?"name":e;var n=t.startsWith("name-")?"name":t;return t=gl.get(e),t!==void 0&&t===n?t:(n=gl.get(n),n!==void 0&&n===e?n:t===n?t:null)}var Yr=class extends re{constructor(e){super(e,[],{B:!1})}h(e,t){return this.l(e,e.L,t)?f.$():f.S()}},af=class extends Yr{constructor(e){super(e.reduce((n,r)=>0<_n(n,r.o)?n:r.o,new me({})));let t;for(let n=0;n<e.length;++n){let r=e[n].D();if(t===void 0&&(t=r),t===null)break;t=yl(t,r)}this.A=t,this.s=e}l(e,t,n){return this.s.some(r=>r.l(e,t,n))}D(){return this.A}v(e){this.s.forEach(t=>t.v(e))}},sf=class extends re{constructor(e,t){super(new me({external:1}),e,{B:e.every(n=>n.B)},!1,t),this.l=e}h(e,t){return this.l.length===0?f.m(new ze([])):b(this.l[0],e,t).M(n=>f.m(new ze(n.map(r=>Se(f.m(r))))))}},uf=class extends re{constructor(e,t){super(new me({external:1}),e,{B:e.every(n=>n.B)},!1,t),this.l=e}h(e,t){return f.m(new ze(this.l.map(n=>Se(b(n,e,t)))))}};function kt(e){if(e===null)throw Et("context is absent, it needs to be present to use axes.");if(!g(e.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return e.value}function lf(e,t,n){let r=t;return{next:()=>{if(!r)return X;let o=r;return r=he(e,o,n),k(Be(o))}}}var wl=class extends re{constructor(e,t){t=t||{Sa:!1},super(e.o,[e],{P:"reverse-sorted",V:!1,subtree:!1,B:!1}),this.l=e,this.s=!!t.Sa}h(e,t){let n=t.h,r=kt(e.L);var o=this.l.D();return o=o&&(o.startsWith("name-")||o==="type-1")?"type-1":null,f.create(lf(n,this.s?r:he(n,r,o),o)).filter(a=>this.l.l(e,a,t))}},cf=class extends re{constructor(e,t){super(new me({attribute:1}),[e],{P:"unsorted",subtree:!0,V:!0,B:!1}),this.l=e,this.s=ct(this.l.D(),t)}h(e,t){var n=t.h;let r=kt(e.L);return r.node.nodeType!==1?f.empty():(n=Yn(n,r,this.s).filter(o=>o.node.namespaceURI!=="http://www.w3.org/2000/xmlns/").map(o=>Be(o)).filter(o=>this.l.l(e,o,t)),f.create(n))}D(){return"type-1"}},pf=class extends re{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,V:!0,B:!1}),this.s=e,this.l=ct(t,e.D())}h(e,t){let n=t.h,r=kt(e.L),o=r.node.nodeType;if(o!==1&&o!==9)return f.empty();let a=null,i=!1;return f.create({next:()=>{for(;!i;){if(!a){if(a=po(n,r,this.l),!a){i=!0;continue}return k(Be(a))}if(a=zt(n,a,this.l))return k(Be(a));i=!0}return X}}).filter(u=>this.s.l(e,u,t))}};function es(e,t,n){let r=t.node.nodeType;if(r!==1&&r!==9)return{next:()=>X};let o=po(e,t,n);return{next(){if(!o)return X;let a=o;return o=zt(e,o,n),k(a)}}}function hf(e,t,n){let r=[Kt(t)];return{next:o=>{if(0<r.length&&(o&1)!==0&&r.shift(),!r.length)return X;for(o=r[0].next(0);o.done;){if(r.shift(),!r.length)return X;o=r[0].next(0)}return r.unshift(es(e,o.value,n)),k(Be(o.value))}}}var Al=class extends re{constructor(e,t){t=t||{Sa:!1},super(e.o,[e],{B:!1,V:!1,P:"sorted",subtree:!0}),this.l=e,this.s=!!t.Sa,this.A=(e=this.l.D())&&(e.startsWith("name-")||e==="type-1")||e==="type-1-or-type-2"?"type-1":null}h(e,t){var n=t.h;let r=kt(e.L);return n=hf(n,r,this.A),this.s||n.next(0),f.create(n).filter(o=>this.l.l(e,o,t))}};function vl(e,t,n){var r=e.node.nodeType;if(r!==1&&r!==9)return e;for(r=Gi(t,e,n);r!==null;){if(r.node.nodeType!==1)return r;e=r,r=Gi(t,e,n)}return e}function xl(e,t,n=!1,r){if(n){let a=t,i=!1;return{next:()=>{if(i)return X;if($e(a,t))return a=vl(t,e,r),$e(a,t)?(i=!0,X):k(Be(a));let u=a.node.nodeType,l=u===9||u===2?null:Or(e,a,r);return l!==null?(a=vl(l,e,r),k(Be(a))):(a=u===9?null:he(e,a,r),$e(a,t)?(i=!0,X):k(Be(a)))}}}let o=[es(e,t,r)];return{next:()=>{if(!o.length)return X;let a=o[0].next(0);for(;a.done;){if(o.shift(),!o.length)return X;a=o[0].next(0)}return o.unshift(es(e,a.value,r)),k(Be(a.value))}}}function ff(e,t,n){let r=[];for(;t&&t.node.nodeType!==9;t=he(e,t,null)){let a=zt(e,t,n);a&&r.push(a)}let o=null;return{next:()=>{for(;o||r.length;){if(!o){o=xl(e,r[0],!1,n);var a=k(Be(r[0]));let i=zt(e,r[0],n);return i?r[0]=i:r.shift(),a}if(a=o.next(0),a.done)o=null;else return a}return X}}}var mf=class extends re{constructor(e){super(e.o,[e],{P:"sorted",V:!0,subtree:!1,B:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||e==="type-1")?"type-1":null}h(e,t){let n=t.h,r=kt(e.L);return f.create(ff(n,r,this.s)).filter(o=>this.l.l(e,o,t))}};function df(e,t,n){return{next:()=>(t=t&&zt(e,t,n))?k(Be(t)):X}}var gf=class extends re{constructor(e,t){super(e.o,[e],{P:"sorted",V:!0,subtree:!1,B:!1}),this.l=e,this.s=ct(this.l.D(),t)}h(e,t){let n=t.h,r=kt(e.L);return f.create(df(n,r,this.s)).filter(o=>this.l.l(e,o,t))}},yf=class extends re{constructor(e,t){super(e.o,[e],{P:"reverse-sorted",V:!0,subtree:!0,B:!1}),this.l=e,this.s=ct(t,this.l.D())}h(e,t){var n=t.h;let r=kt(e.L);return n=he(n,r,this.s),n?(n=Be(n),this.l.l(e,n,t)?f.m(n):f.empty()):f.empty()}};function wf(e,t,n){let r=[];for(;t&&t.node.nodeType!==9;t=he(e,t,null)){let a=Or(e,t,n);a!==null&&r.push(a)}let o=null;return{next:()=>{for(;o||r.length;){o||=xl(e,r[0],!0,n);var a=o.next(0);if(a.done){o=null,a=Or(e,r[0],n);let i=k(Be(r[0]));return a===null?r.shift():r[0]=a,i}return a}return X}}}var Af=class extends re{constructor(e){super(e.o,[e],{B:!1,V:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||e==="type-1")?"type-1":null}h(e,t){let n=t.h,r=kt(e.L);return f.create(wf(n,r,this.s)).filter(o=>this.l.l(e,o,t))}};function vf(e,t,n){return{next:()=>(t=t&&Or(e,t,n))?k(Be(t)):X}}var xf=class extends re{constructor(e,t){super(e.o,[e],{B:!1,V:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=ct(this.l.D(),t)}h(e,t){let n=t.h,r=kt(e.L);return f.create(vf(n,r,this.s)).filter(o=>this.l.l(e,o,t))}},Bf=class extends re{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,V:!0,B:!1}),this.l=e,this.s=ct(this.l.D(),t)}h(e,t){return kt(e.L),this.l.l(e,e.L,t)?f.m(e.L):f.empty()}D(){return this.s}},Ef=class extends xn{constructor(e,t,n,r){super(e.o.add(t.o).add(n.o),[e,t,n],{B:e.B&&t.B&&n.B,V:t.V===n.V&&t.V,P:t.ha===n.ha?t.ha:"unsorted",subtree:t.subtree===n.subtree&&t.subtree},r),this.l=e}A(e,t,n){let r=null,o=n[0](e);return f.create({next:a=>(r||(r=(o.ea()?n[1](e):n[2](e)).value),r.next(a))})}v(e){if(super.v(e),this.l.H)throw bt()}};function Bl(e){return e.h instanceof Error?e.location:Bl(e.h)}function El(e){let t;return t=e.h instanceof Zu?["Inner error:",e.h.message]:e.h instanceof Error?[e.h.toString()]:El(e.h),t.push(` at <${e.o}${e.Xa?` (${e.Xa})`:""}>:${e.location.start.line}:${e.location.start.ga} - ${e.location.end.line}:${e.location.end.ga}`),t}var Ho=class{constructor(e,t,n,r){this.location=e,this.o=t,this.Xa=n,this.h=r}},Nf=class extends xn{constructor(e,t,n,r){super(n.o,[n],{B:n.B,V:n.V,P:n.ha,subtree:n.subtree}),this.K=t,this.O={end:{ga:e.end.ga,line:e.end.line,offset:e.end.offset},start:{ga:e.start.ga,line:e.start.line,offset:e.start.offset}},this.l=r}A(e,t,[n]){let r;try{r=n(e)}catch(o){throw new Ho(this.O,this.K,this.l,o)}return f.create({next:o=>{try{return r.value.next(o)}catch(a){throw new Ho(this.O,this.K,this.l,a)}}})}v(e){try{super.v(e)}catch(t){throw new Ho(this.O,this.K,this.l,t)}}D(){return this.Ga[0].D()}};function Nl(e,t,n,r){let o=[],a=e.K(t,n,r,u=>{if(e.l instanceof Nn){let p=Nl(e.l,t,u,r);return Zn(p,A=>o=A)}let l=null;return f.create({next:()=>{for(;;){if(!l){var p=u.next(0);if(p.done)return X;p=e.l.s(p.value,r),l=Zn(p,A=>o=Nt(o,A)).value}if(p=l.next(0),p.done)l=null;else return p}}})}),i=!1;return{next:()=>{if(i)return X;let u=a.N();return i=!0,k(new Du(u,o))}}}function Tl(e,t,n,r){return e.K(t,n,r,o=>{if(e.l instanceof Nn)return Tl(e.l,t,o,r);let a=null;return f.create({next:()=>{for(;;){if(!a){var i=o.next(0);if(i.done)return X;a=b(e.l,i.value,r).value}if(i=a.next(0),i.done)a=null;else return i}}})})}var Nn=class extends re{constructor(e,t,n,r){super(e,t,n,!0),this.l=r,this.H=this.l.H}h(e,t){return this.K(e,Kt(e),t,n=>{if(this.l instanceof Nn)return Tl(this.l,e,n,t);let r=null;return f.create({next:o=>{for(;;){if(!r){var a=n.next(0);if(a.done)return X;r=b(this.l,a.value,t).value}if(a=r.next(o),a.done)r=null;else return a}}})})}s(e,t){return Nl(this,e,Kt(e),t)}v(e){super.v(e),this.H=this.l.H;for(let t of this.Ga)if(t!==this.l&&t.H)throw bt()}},Tf=class extends Nn{constructor(e,t,n,r){super(t.o.add(r.o),[t,r],{B:!1},r),this.O=e.prefix,this.la=e.namespaceURI,this.Rb=e.localName,this.yb=null,this.A=n,this.Ma=null,this.ya=t}K(e,t,n,r){let o=null,a=null,i=0;return r({next:()=>{for(;;){if(!o){var u=t.next(0);if(u.done)return X;a=u.value,i=0,o=b(this.ya,a,n).value}let l=o.next(0);if(l.done)o=null;else return i++,u={[this.yb]:()=>f.m(l.value)},this.Ma&&(u[this.Ma]=()=>f.m(new mn(5,i))),k(tn(a,u))}}})}v(e){if(this.O&&(this.la=e.Z(this.O),!this.la&&this.O))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.O} in a for expression`);if(this.ya.v(e),er(e),this.yb=Mt(e,this.la,this.Rb),this.A){if(this.A.prefix&&(this.A.namespaceURI=e.Z(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.O} in the positionalVariableBinding in a for expression`);this.Ma=Mt(e,this.A.namespaceURI,this.A.localName)}if(this.l.v(e),tr(e),this.ya.H)throw bt();this.l.H&&(this.H=!0)}},If=class extends re{constructor(e,t,n){super(new me({external:1}),[n],{B:!1,P:"unsorted"}),this.O=e.map(({name:r})=>r),this.A=e.map(({type:r})=>r),this.s=null,this.K=t,this.l=n}h(e,t){let n=new _t({j:this.A,arity:this.A.length,bb:!0,H:this.l.H,localName:"dynamic-function",namespaceURI:"",i:this.K,value:(r,o,a,...i)=>(r=tn(Qt(e,-1,null,f.empty()),this.s.reduce((u,l,p)=>(u[l]=Se(i[p]),u),Object.create(null))),b(this.l,r,t))});return f.m(n)}v(e){if(er(e),this.s=this.O.map(t=>Mt(e,t.namespaceURI,t.localName)),this.l.v(e),tr(e),this.l.H)throw Error("Not implemented: inline functions can not yet be updating.")}},Cf=class extends Nn{constructor(e,t,n){if(super(t.o.add(n.o),[t,n],{B:!1,V:n.V,P:n.ha,subtree:n.subtree},n),e.prefix||e.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=e.prefix,this.O=e.namespaceURI,this.Ma=e.localName,this.la=t,this.ya=null}K(e,t,n,r){return r({next:()=>{var o=t.next(0);return o.done?X:(o=o.value,o=tn(o,{[this.ya]:Se(b(this.la,o,n))}),k(o))}})}v(e){if(this.A&&(this.O=e.Z(this.A),!this.O&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);if(this.la.v(e),er(e),this.ya=Mt(e,this.O,this.Ma),this.l.v(e),tr(e),this.H=this.l.H,this.la.H)throw bt()}},ar=class extends re{constructor(e,t){super(new me({}),[],{B:!0,P:"sorted"},!1,t);let n;switch(t.type){case 5:n=v(parseInt(e,10),t.type);break;case 1:n=v(e,t.type);break;case 4:case 3:n=v(parseFloat(e),t.type);break;default:throw new TypeError("Type "+t+" not expected in a literal")}this.l=()=>f.m(n)}h(){return this.l()}},Ff=class extends re{constructor(e,t){super(new me({external:1}),e.reduce((n,{key:r,value:o})=>n.concat(r,o),[]),{B:!1},!1,t),this.l=e}h(e,t){let n=this.l.map(r=>Me(b(r.key,e,t),t).X({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.")},m:o=>o}));return de(n,r=>f.m(new qt(r.map((o,a)=>({key:o,value:Se(b(this.l[a].value,e,t))})))))}},qr=class extends re{constructor(e,t,n){super(new me({external:1}),[],{B:!0},!1,n),this.s=t,this.A=e,this.l=null}h(){let e=new _t({j:this.l.j,H:this.l.H,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return f.m(e)}v(e){let t=this.A.namespaceURI,n=this.A.localName,r=this.A.prefix;if(t===null){let o=e.Ua({localName:n,prefix:r},this.s);if(!o)throw Error(`XPST0017: The function ${r?r+":":""}${n} with arity ${this.s} could not be resolved. ${Ka(n)}`);t=o.namespaceURI,n=o.localName}if(this.l=e.ua(t,n,this.s)||null,!this.l)throw e=this.A,Error(`XPST0017: Function ${`${e.namespaceURI?`Q{${e.namespaceURI}}`:e.prefix?`${e.prefix}:`:""}${e.localName}`} with arity of ${this.s} not registered. ${Ka(n)}`);super.v(e)}};let Gf={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};var Il=class extends re{constructor(e,t,n){super(t.o,[t],{B:!1},!1,n),this.s=t,this.l=e}h(e,t){return Me(b(this.s,e,t),t).M(n=>{if(n.length===0)return f.empty();var r=n[0];if(this.type)return n=this.l==="+"?+r.value:-r.value,r.type===0&&(n=Number.NaN),f.m(v(n,this.type.type));if(1<n.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return g(r.type,19)?(r=xe(r,3).value,f.m(v(this.l==="+"?r:-r,3))):g(r.type,2)?this.l==="+"?f.m(r):f.m(v(-1*r.value,Gf[r.type])):f.m(v(Number.NaN,3))})}},Of=class extends re{constructor(e,t){super(e.reduce((n,r)=>n.add(r.o),new me({})),e,{B:e.every(n=>n.B)},!1,t),this.l=e,this.s=e.reduce((n,r)=>ct(n,r.D()),null)}h(e,t){let n=0,r=null,o=!1,a=null;if(e!==null){let i=e.L;i!==null&&g(i.type,53)&&(a=Ci(i.value))}return f.create({next:()=>{if(!o){for(;n<this.l.length;){if(!r){let i=this.l[n];if(a!==null&&i.D()!==null&&!a.includes(i.D()))return n++,o=!0,k(ut);r=b(i,e,t)}if(r.ea()===!1)return o=!0,k(ut);r=null,n++}return o=!0,k(Ke)}return X}})}D(){return this.s}},Df=class extends re{constructor(e,t){super(e.reduce((r,o)=>0<_n(r,o.o)?r:o.o,new me({})),e,{B:e.every(r=>r.B)},!1,t);let n;for(t=0;t<e.length;++t){let r=e[t].D();if(n===void 0&&(n=r),n===null)break;n=yl(n,r)}this.s=n,this.l=e}h(e,t){let n=0,r=null,o=!1,a=null;if(e!==null){let i=e.L;i!==null&&g(i.type,53)&&(a=Ci(i.value))}return f.create({next:()=>{if(!o){for(;n<this.l.length;){if(!r){let i=this.l[n];if(a!==null&&i.D()!==null&&!a.includes(i.D())){n++;continue}r=b(i,e,t)}if(r.ea()===!0)return o=!0,k(Ke);r=null,n++}return o=!0,k(ut)}return X}})}D(){return this.s}};function sr(e,t){let n;return f.create({next:r=>{for(;;){if(!n){var o=e.value.next(r);if(o.done)return X;n=Jt(o.value,t)}if(o=n.value.next(r),o.done)n=null;else return o}}})}function Uf(e,t){if(e==="eqOp")return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.namespaceURI===a.value.namespaceURI&&o.value.localName===a.value.localName};if(e==="neOp")return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.namespaceURI!==a.value.namespaceURI||o.value.localName!==a.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName')}function Rf(e,t){switch(e){case"eqOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value===a.value};case"neOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value!==a.value};case"ltOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value<a.value};case"leOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value<=a.value};case"gtOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value>a.value};case"geOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value>=a.value}}}function Sf(e,t){switch(e){case"ltOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.da<a.value.da};case"leOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)||o.value.da<a.value.da};case"gtOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.da>a.value.da};case"geOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)||o.value.da>a.value.da}}}function Mf(e,t){switch(e){case"eqOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)};case"ltOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.ba<a.value.ba};case"leOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)||o.value.ba<a.value.ba};case"gtOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.ba>a.value.ba};case"geOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)||o.value.ba>a.value.ba}}}function kf(e,t){switch(e){case"eqOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return o.value.equals(a.value)};case"neOp":return(n,r)=>{let{T:o,U:a}=t(n,r);return!o.value.equals(a.value)}}}function Hf(e,t){switch(e){case"eqOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return wn(a.value,i.value,xt(o))};case"neOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return!wn(a.value,i.value,xt(o))};case"ltOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return n=xt(o),0>Sr(a.value,i.value,n)};case"leOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return(n=wn(a.value,i.value,xt(o)))||(o=xt(o),n=0>Sr(a.value,i.value,o)),n};case"gtOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return n=xt(o),0<Sr(a.value,i.value,n)};case"geOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return(n=wn(a.value,i.value,xt(o)))||(o=xt(o),n=0<Sr(a.value,i.value,o)),n}}}function Pf(e,t){switch(e){case"eqOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return wn(a.value,i.value,xt(o))};case"neOp":return(n,r,o)=>{let{T:a,U:i}=t(n,r);return!wn(a.value,i.value,xt(o))}}}function $f(e,t,n){function r(p,A){return{T:i?i(p):p,U:u?u(A):A}}function o(p){return g(t,p)&&g(n,p)}function a(p){return 0<p.filter(A=>g(t,A)).length&&0<p.filter(A=>g(n,A)).length}let i=null,u=null;if(g(t,19)&&g(n,19)?t=n=1:g(t,19)?(i=p=>xe(p,n),t=n):g(n,19)&&(u=p=>xe(p,t),n=t),g(t,23)&&g(n,23))return Uf(e,r);if(o(0)||a([1,47,61])||a([2,47,61])||o(20)||o(22)||o(21)||a([1,20])){var l=Rf(e,r);if(l!==void 0)return l}if(o(16)&&(l=Sf(e,r),l!==void 0)||o(17)&&(l=Mf(e,r),l!==void 0)||o(18)&&(l=kf(e,r),l!==void 0)||(o(9)||o(7)||o(8))&&(l=Hf(e,r),l!==void 0)||(o(11)||o(12)||o(13)||o(14)||o(15))&&(l=Pf(e,r),l!==void 0))return l;throw Error(`XPTY0004: ${e} not available for ${we[t]} and ${we[n]}`)}let Cl=Object.create(null);function Po(e,t,n){let r=`${t}~${n}~${e}`,o=Cl[r];return o||=Cl[r]=$f(e,t,n),o}var jf=class extends re{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){let n=b(this.l,e,t),r=b(this.A,e,t),o=sr(n,t),a=sr(r,t);return o.X({empty:()=>f.empty(),m:()=>a.X({empty:()=>f.empty(),m:()=>{let i=o.first(),u=a.first();return Po(this.s,i.type,u.type)(i,u,e)?f.$():f.S()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}})}};let Xf={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};function Lf(e,t,n,r){return e=Xf[e],n.M(o=>t.filter(a=>{for(let l=0,p=o.length;l<p;++l){let A=o[l],x,C;var i=a.type,u=A.type;(g(i,19)||g(u,19))&&(g(i,2)?x=3:g(u,2)?C=3:g(i,17)?x=17:g(u,17)?C=17:g(i,16)?x=16:g(u,16)?C=16:g(i,19)?C=u:g(u,19)&&(x=i));let[T,P]=[C,x];if(i=T,u=P,i?a=xe(a,i):u&&(A=xe(A,u)),Po(e,a.type,A.type)(a,A,r))return!0}return!1}).X({default:()=>f.$(),empty:()=>f.S()}))}var Yf=class extends re{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){let n=b(this.l,e,t),r=b(this.A,e,t);return n.X({empty:()=>f.S(),default:()=>r.X({empty:()=>f.S(),default:()=>{let o=sr(n,t),a=sr(r,t);return Lf(this.s,o,a,e)}})})}};function qf(e,t,n,r){if(!g(n,53)||!g(r,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(e){case"isOp":return Qf(n,r);case"nodeBeforeOp":return t?(o,a)=>0>kr(t,o.first(),a.first()):void 0;case"nodeAfterOp":return t?(o,a)=>0<kr(t,o.first(),a.first()):void 0;default:throw Error("Unexpected operator")}}function Qf(e,t){return e!==t||e!==47&&e!==53&&e!==54&&e!==55&&e!==56&&e!==57&&e!==58?()=>!1:(n,r)=>$e(n.first().value,r.first().value)}var Jf=class extends re{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){let n=b(this.l,e,t),r=b(this.A,e,t);return n.X({empty:()=>f.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>r.X({empty:()=>f.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>{let o=n.first(),a=r.first();return qf(this.s,t.h,o.type,a.type)(n,r,e)?f.$():f.S()}})})}};function Fl(e,t,n,r){return n.M(o=>{if(o.some(a=>!g(a.type,53)))throw Error(`XPTY0004: Sequences given to ${e} should only contain nodes.`);return r==="sorted"?f.create(o):r==="reverse-sorted"?f.create(o.reverse()):f.create(Hr(t,o))})}var Kf=class extends re{constructor(e,t,n,r){super(0<_n(t.o,n.o)?t.o:n.o,[t,n],{B:t.B&&n.B},!1,r),this.l=e,this.s=t,this.A=n}h(e,t){let n=Fl(this.l,t.h,b(this.s,e,t),this.s.ha);e=Fl(this.l,t.h,b(this.A,e,t),this.A.ha);let r=n.value,o=e.value,a=null,i=null,u=!1,l=!1;return f.create({next:()=>{if(u)return X;for(;!l;){if(!a){var p=r.next(0);if(p.done)return u=!0,X;a=p.value}if(!i){if(p=o.next(0),p.done){l=!0;break}i=p.value}if($e(a.value,i.value)){if(p=k(a),i=a=null,this.l==="intersectOp")return p}else if(0>kr(t.h,a,i)){if(p=k(a),a=null,this.l==="exceptOp")return p}else i=null}return this.l==="exceptOp"?a!==null?(p=k(a),a=null,p):r.next(0):(u=!0,X)}})}},ts=class extends xn{constructor(e,t){super(e.reduce((n,r)=>n.add(r.o),new me({})),e,{P:"unsorted",B:e.every(n=>n.B)},t)}A(e,t,n){return n.length?Bt(n.map(r=>r(e))):f.empty()}},bf=class extends re{constructor(e,t,n){super(new me({}).add(e.o),[e,t],{B:e.B&&t.B},!1,n),this.l=e,this.s=t}h(e,t){let n=b(this.l,e,t),r=ki(e,n),o=null,a=null,i=!1;return f.create({next:u=>{for(;!i;){if(!o&&(o=r.next(u),o.done))return i=!0,X;a||=b(this.s,o.value,t);let l=a.value.next(u);if(l.done)o=a=null;else return l}}})}},Vf=class extends re{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=lt(t.prefix?`${t.prefix}:${t.localName}`:t.localName),this.l===46||this.l===45||this.l===44)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){let n=Me(b(this.A,e,t),t);return n.X({empty:()=>this.s?f.$():f.S(),m:()=>n.map(r=>Oa(r,this.l).u?Ke:ut),multiple:()=>f.S()})}},Zf=class extends re{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=lt(t.prefix?`${t.prefix}:${t.localName}`:t.localName),this.l===46||this.l===45||this.l===44)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){let n=Me(b(this.A,e,t),t);return n.X({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");return f.empty()},m:()=>n.map(r=>xe(r,this.l)),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.")}})}};function Gl(e,t){let n=e.value,r=null,o=!1;return f.create({next:()=>{for(;!o;){if(!r){var a=n.next(0);if(a.done)return o=!0,k(Ke);r=t(a.value)}if(a=r.ea(),r=null,a===!1)return o=!0,k(ut)}return X}})}var _f=class extends re{constructor(e,t,n,r){super(e.o,[e,t],{B:!1},!1,r),this.A=e,this.s=t,this.l=n}h(e,t){let n=b(this.A,e,t);return n.X({empty:()=>this.l==="?"||this.l==="*"?f.$():f.S(),multiple:()=>this.l==="+"||this.l==="*"?Gl(n,r=>{let o=f.m(r);return r=Qt(e,0,r,o),b(this.s,r,t)}):f.S(),m:()=>Gl(n,r=>{let o=f.m(r);return r=Qt(e,0,r,o),b(this.s,r,t)})})}};function Ol(e,t){return e!==null&&t!==null&&g(e.type,53)&&g(t.type,53)?$e(e.value,t.value):!1}function ns(e){let t=e.next(0);if(t.done)return f.empty();let n=null,r=null;return f.create({next(o){if(t.done)return X;n||(n=t.value.value);let a;do if(a=n.next(o),a.done){if(t=e.next(0),t.done)return a;n=t.value.value}while(a.done||Ol(a.value,r));return r=a.value,a}})}function Dl(e,t){let n=[];(function(){for(var a=t.next(0);!a.done;){let i=a.value.value;a={current:i.next(0),next:u=>i.next(u)},a.current.done||n.push(a),a=t.next(0)}})();let r=null,o=!1;return f.create({[Symbol.iterator](){return this},next:()=>{o||(o=!0,n.every(i=>g(i.current.value.type,53))&&n.sort((i,u)=>kr(e,i.current.value,u.current.value)));let a;do{if(!n.length)return X;let i=n.shift();if(a=i.current,i.current=i.next(0),!g(a.value.type,53))return a;if(!i.current.done){let u=0,l=n.length-1,p=0;for(;u<=l;){p=Math.floor((u+l)/2);let A=kr(e,i.current.value,n[p].current.value);if(A===0){u=p;break}0<A?u=p+1:l=p-1}n.splice(u,0,i)}}while(Ol(a.value,r));return r=a.value,a}})}var Wf=class extends re{constructor(e,t){super(e.reduce((n,r)=>0<_n(n,r.o)?n:r.o,new me({})),e,{B:e.every(n=>n.B)},!1,t),this.l=e}h(e,t){if(this.l.every(n=>n.ha==="sorted")){let n=0;return Dl(t.h,{next:()=>n>=this.l.length?X:k(b(this.l[n++],e,t))}).map(r=>{if(!g(r.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return r})}return Bt(this.l.map(n=>b(n,e,t))).M(n=>{if(n.some(r=>!g(r.type,53)))throw Error("XPTY0004: The sequences to union are not of type node()*");return n=Hr(t.h,n),f.create(n)})}};function $o(e){return e.every(t=>t===null||g(t.type,5)||g(t.type,4))||e.map(t=>t?Ao(t.type):null).reduce((t,n)=>n===null||n===t?t:null)!==null?e:e.every(t=>t===null||g(t.type,1)||g(t.type,20))?e.map(t=>t?xe(t,1):null):e.every(t=>t===null||g(t.type,4)||g(t.type,6))?e.map(t=>t&&xe(t,6)):e.every(t=>t===null||g(t.type,4)||g(t.type,6)||g(t.type,3))?e.map(t=>t&&xe(t,3)):null}function zf(e){return(e=e.find(t=>!!t))?Ao(e.type):null}var em=class extends Nn{constructor(e,t){super(new me({}),[t,...e.map(n=>n.aa)],{B:!1,V:!1,P:"unsorted",subtree:!1},t),this.A=e}K(e,t,n,r){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");let o=[],a=!1,i,u,l=null,p=this.A[0];return f.create({next:()=>{if(!a){for(var A=t.next(0);!A.done;)o.push(A.value),A=t.next(0);if(A=o.map(C=>p.aa.h(C,n)).map(C=>Me(C,n)),A.find(C=>!C.isEmpty()&&!C.oa()))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");if(i=A.map(C=>C.first()),i=i.map(C=>C===null?C:g(19,C.type)?xe(C,1):C),zf(i)&&(i=$o(i),!i))throw Error("XPTY0004: Could not cast values");A=i.length,u=i.map((C,T)=>T);for(let C=0;C<A;C++)if(C+1!==A)for(let T=C;0<=T;T--){let P=T,_=T+1;if(_===A)continue;let oe=i[u[P]],Ae=i[u[_]];if(Ae!==null||oe!==null){if(p.ec){if(oe===null)continue;if(Ae===null&&oe!==null){[u[P],u[_]]=[u[_],u[P]];continue}if(isNaN(Ae.value)&&oe!==null&&!isNaN(oe.value)){[u[P],u[_]]=[u[_],u[P]];continue}}else{if(Ae===null)continue;if(oe===null&&Ae!==null){[u[P],u[_]]=[u[_],u[P]];continue}if(isNaN(oe.value)&&Ae!==null&&!isNaN(Ae.value)){[u[P],u[_]]=[u[_],u[P]];continue}}Po("gtOp",oe.type,Ae.type)(oe,Ae,e)&&([u[P],u[_]]=[u[_],u[P]])}}let x=p.Cb?0:i.length-1;l=r({next:()=>p.Cb?x>=i.length?X:k(o[u[x++]]):0>x?X:k(o[u[x--]])}).value,a=!0}return l.next(0)}})}},Ul=class extends re{constructor(e){super(e?e.o:new me({}),e?[e]:[],{P:"sorted",subtree:!1,V:!1,B:!1}),this.l=e}h(e,t){if(e.L===null)throw Et("context is absent, it needs to be present to use paths.");var n=t.h;let r=e.L.value;for(;r.node.nodeType!==9;)if(r=he(n,r),r===null)throw Error("XPDY0050: the root node of the context node is not a document node.");return n=f.m(Be(r)),this.l?b(this.l,Qt(e,0,n.first(),n),t):n}},tm=class extends re{constructor(e){super(new me({}),[],{P:"sorted"},!1,e)}h(e){if(e.L===null)throw Et('context is absent, it needs to be present to use the "." operator');return f.m(e.L)}};function nm(e,t){let n=!1,r=!1;if(t.forEach(o=>{g(o.type,53)?n=!0:r=!0}),r&&n)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return n?Hr(e,t):t}var rm=class extends re{constructor(e,t){let n=e.every(o=>o.V),r=e.every(o=>o.subtree);super(e.reduce((o,a)=>o.add(a.o),new me({})),e,{B:!1,V:n,P:t?"sorted":"unsorted",subtree:r}),this.l=e,this.s=t}h(e,t){let n=!0;return this.l.reduce((r,o,a)=>{let i=r===null?Kt(e):ki(e,r);r={next:l=>{if(l=i.next(l),l.done)return X;if(l.value.L!==null&&!g(l.value.L.type,53)&&0<a)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return k(b(o,l.value,t))}};let u;if(this.s)switch(o.ha){case"reverse-sorted":let l=r;r={next:p=>(p=l.next(p),p.done?p:k(p.value.M(A=>f.create(A.reverse()))))};case"sorted":if(o.subtree&&n){u=ns(r);break}u=Dl(t.h,r);break;case"unsorted":return ns(r).M(p=>f.create(nm(t.h,p)))}else u=ns(r);return n=n&&o.V,u},null)}D(){return this.l[0].D()}},om=class extends re{constructor(e,t){super(e.o.add(t.o),[e,t],{B:e.B&&t.B,V:e.V,P:e.ha,subtree:e.subtree}),this.s=e,this.l=t}h(e,t){let n=b(this.s,e,t);if(this.l.B){let u=b(this.l,e,t);if(u.isEmpty())return u;let l=u.first();if(g(l.type,2)){let p=l.value;if(!Number.isInteger(p))return f.empty();let A=n.value,x=!1;return f.create({next:()=>{if(!x){for(let C=A.next(0);!C.done;C=A.next(0))if(p--===1)return x=!0,C;x=!0}return X}})}return u.ea()?n:f.empty()}let r=n.value,o=null,a=0,i=null;return f.create({next:u=>{let l=!1;for(;(!o||!o.done)&&(o||(o=r.next(l?0:u),l=!0),!o.done);){i||=b(this.l,Qt(e,a,o.value,n),t);var p=i.first();p=p===null?!1:g(p.type,2)?p.value===a+1:i.ea(),i=null;let A=o.value;if(o=null,a++,p)return k(A)}return o}})}D(){return this.s.D()}};function Rl(e,t,n){if(n=[n],g(e.type,62))if(t==="*")n.push(...e.members.map(r=>r()));else if(g(t.type,5)){let r=t.value;if(e.members.length<r||0>=r)throw Error("FOAY0001: Array index out of bounds");n.push(e.members[r-1]())}else throw Error("XPTY0004: The key specifier is not an integer.");else if(g(e.type,61))t==="*"?n.push(...e.h.map(r=>r.value())):(e=e.h.find(r=>qn(r.key,t)))&&n.push(e.value());else throw Error("XPTY0004: The provided context item is not a map or an array.");return Bt(n)}function Sl(e,t,n,r,o){return t==="*"?Rl(e,t,n):(t=b(t,r,o),t=Se(t)().M(a=>a.reduce((i,u)=>Rl(e,u,i),new Xn)),Bt([n,t]))}var am=class extends re{constructor(e,t){super(e.o,[e].concat(t==="*"?[]:[t]),{B:e.B,P:e.ha,subtree:e.subtree}),this.l=e,this.s=t}h(e,t){return b(this.l,e,t).M(n=>n.reduce((r,o)=>Sl(o,this.s,r,e,t),new Xn))}D(){return this.l.D()}},sm=class extends re{constructor(e,t){super(new me({external:1}),e==="*"?[]:[e],{B:!1},!1,t),this.l=e}h(e,t){return Sl(e.L,this.l,new Xn,e,t)}},im=class extends re{constructor(e,t,n,r){let o=t.map(a=>a.fb);t=t.map(a=>a.name),super(o.reduce((a,i)=>a.add(i.o),n.o),o.concat(n),{B:!1},!1,r),this.s=e,this.A=t,this.K=o,this.O=n,this.l=null}h(e,t){let n=e,r=this.l.map((u,l)=>{let p=b(this.K[l],n,t).N();return n=tn(e,{[u]:()=>f.create(p)}),p});if(r.some(u=>u.length===0))return this.s==="every"?f.$():f.S();let o=Array(r.length).fill(0);o[0]=-1;for(var a=!0;a;){a=!1;for(let u=0,l=o.length;u<l;++u){var i=r[u];if(++o[u]>i.length-1)o[u]=0;else{for(a=Object.create(null),i=0;i<o.length;i++){let p=r[i][o[i]];a[this.l[i]]=()=>f.m(p)}if(a=tn(e,a),a=b(this.O,a,t),a.ea()&&this.s==="some")return f.$();if(!a.ea()&&this.s==="every")return f.S();a=!0;break}}}return this.s==="every"?f.$():f.S()}v(e){this.l=[];for(let n=0,r=this.A.length;n<r;++n){this.K[n].v(e),er(e);var t=this.A[n];let o=t.prefix?e.Z(t.prefix):null;t=Mt(e,o,t.localName),this.l[n]=t}this.O.v(e);for(let n=0,r=this.A.length;n<r;++n)tr(e)}},ir=class extends Yr{constructor(e){super(new me({nodeType:1})),this.s=e}l(e,t){return g(t.type,53)?(e=t.value.node.nodeType,this.s===3&&e===4?!0:this.s===e):!1}D(){return`type-${this.s}`}},Tn=class extends Yr{constructor(e,t={kind:null}){let n=e.prefix,r=e.namespaceURI;e=e.localName;let o={};e!=="*"&&(o.nodeName=1),o.nodeType=1,super(new me(o)),this.s=e,this.K=r,this.A=n,this.O=t.kind}l(e,t){e=g(t.type,54);let n=g(t.type,47);return!e&&!n?!1:(t=t.value,this.O!==null&&(this.O===1&&!e||this.O===2&&!n)?!1:this.A===null&&this.K!==""&&this.s==="*"?!0:this.A==="*"?this.s==="*"?!0:this.s===t.node.localName:this.s!=="*"&&this.s!==t.node.localName?!1:(t.node.namespaceURI||null)===((this.A===""?e?this.K:null:this.K)||null))}D(){return this.s==="*"?this.O===null?"type-1-or-type-2":`type-${this.O}`:`name-${this.s}`}v(e){if(this.K===null&&this.A!=="*"&&(this.K=e.Z(this.A||"")||null,!this.K&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`)}},um=class extends Yr{constructor(e){super(new me({nodeName:1})),this.s=e}l(e,t){return g(t.type,57)&&t.value.node.target===this.s}D(){return"type-7"}},Qr=class extends Yr{constructor(e){super(new me({})),this.s=e}l(e,t){return g(t.type,lt(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}},lm=class extends re{constructor(e,t,n){super(new me({}),[],{B:!1,P:"unsorted"}),this.A=n,this.s=t,this.K=e,this.l=null}h(e,t){if(!e.qa[this.l]){if(this.O)return this.O(e,t);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.")}return e.qa[this.l]()}v(e){if(this.s===null&&this.K&&(this.s=e.Z(this.K)),this.l=e.eb(this.s||"",this.A),!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");(e=e.Fa[this.l])&&(this.O=e)}},cm=class extends Nn{constructor(e,t){super(new me({}),[e,t],{B:!1,V:!1,P:"unsorted",subtree:!1},t),this.A=e}K(e,t,n,r){let o=null,a=null;return r({next:()=>{for(;;){if(!a){var i=t.next(0);if(i.done)return X;o=i.value,a=b(this.A,o,n)}i=a.ea();let u=o;if(a=o=null,i)return k(u)}}})}},In=class{constructor(e){this.type=e}},Ml=class extends In{constructor(e){super("delete"),this.target=e}h(e){return{type:this.type,target:Ve(this.target,e,!1)}}},Jr=class extends In{constructor(e,t,n){super(n),this.target=e,this.content=t}h(e){return{type:this.type,target:Ve(this.target,e,!1),content:this.content.map(t=>Ve(t,e,!0))}}},kl=class extends Jr{constructor(e,t){super(e,t,"insertAfter")}},ur=class extends In{constructor(e,t){super("insertAttributes"),this.target=e,this.content=t}h(e){return{type:this.type,target:Ve(this.target,e,!1),content:this.content.map(t=>Ve(t,e,!0))}}},Hl=class extends Jr{constructor(e,t){super(e,t,"insertBefore")}},Pl=class extends Jr{constructor(e,t){super(e,t,"insertIntoAsFirst")}},$l=class extends Jr{constructor(e,t){super(e,t,"insertIntoAsLast")}},jl=class extends Jr{constructor(e,t){super(e,t,"insertInto")}},Xl=class extends In{constructor(e,t){super("rename"),this.target=e,this.o=t.Aa?t:new _e(t.prefix,t.namespaceURI,t.localName)}h(e){return{type:this.type,target:Ve(this.target,e,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}},Ll=class extends In{constructor(e,t){super("replaceElementContent"),this.target=e,this.text=t}h(e){return{type:this.type,target:Ve(this.target,e,!1),text:this.text?Ve(this.text,e,!0):null}}},Yl=class extends In{constructor(e,t){super("replaceNode"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ve(this.target,e,!1),replacement:this.o.map(t=>Ve(t,e,!0))}}},ql=class extends In{constructor(e,t){super("replaceValue"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ve(this.target,e,!1),"string-value":this.o}}},pm=(e,t)=>new Yl(e,t),hm=class extends Vn{constructor(e){super(new me({}),[e],{B:!1,P:"unsorted"}),this.l=e}s(e,t){let n=Rt(this.l)(e,t),r=t.h,o,a;return{next:()=>{if(!o){let i=n.next(0);if(i.value.I.some(u=>!g(u.type,53)))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");o=i.value.I,a=i.value.ca}return o=o.filter(i=>he(r,i.value)),k({ca:Nt(o.map(i=>new Ml(i.value)),a),I:[]})}}}};function Ql(e,t,n,r,o,a){let i=t.h;return e.reduce(function u(l,p){return g(p.type,62)?(p.members.forEach(A=>A().N().forEach(x=>u(l,x))),l):(l.push(p),l)},[]).forEach((u,l,p)=>{if(g(u.type,47)){if(o)throw a(u.value,i);n.push(u.value.node)}else if(g(u.type,46)||g(u.type,53)&&u.value.node.nodeType===3){let A=g(u.type,46)?xe(Jt(u,t).first(),1).value:Ye(i,u.value);l!==0&&g(p[l-1].type,46)&&g(u.type,46)?(r.push({data:" "+A,Ta:!0,nodeType:3}),o=!0):A&&(r.push({data:""+A,Ta:!0,nodeType:3}),o=!0)}else if(g(u.type,55)){let A=[];Ct(i,u.value).forEach(x=>A.push(Be(x))),o=Ql(A,t,n,r,o,a)}else if(g(u.type,53))r.push(u.value.node),o=!0;else throw g(u.type,60)?Pi(u.type):Error(`Atomizing ${u.type} is not implemented.`)}),o}function rs(e,t,n){let r=[],o=[],a=!1;return e.forEach(i=>{a=Ql(i,t,r,o,a,n)}),{attributes:r,Ya:o}}function fm(e,t,n,r,o){let a=[];switch(e){case 4:r.length&&a.push(new ur(t,r)),o.length&&a.push(new Pl(t,o));break;case 5:r.length&&a.push(new ur(t,r)),o.length&&a.push(new $l(t,o));break;case 3:r.length&&a.push(new ur(t,r)),o.length&&a.push(new jl(t,o));break;case 2:r.length&&a.push(new ur(n,r)),o.length&&a.push(new Hl(t,o));break;case 1:r.length&&a.push(new ur(n,r)),o.length&&a.push(new kl(t,o))}return a}var mm=class extends Vn{constructor(e,t,n){super(new me({}),[e,n],{B:!1,P:"unsorted"}),this.K=e,this.l=t,this.A=n}s(e,t){let n=Rt(this.K)(e,t),r=Rt(this.A)(e,t),o=t.h,a,i,u,l,p,A;return{next:()=>{if(!a){var x=n.next(0);let C=rs([x.value.I],t,Eh);a=C.attributes.map(T=>({node:T,F:null})),i=C.Ya.map(T=>({node:T,F:null})),u=x.value.ca}if(!l){if(x=r.next(0),x.value.I.length===0)throw Co();if(3<=this.l){if(x.value.I.length!==1||!g(x.value.I[0].type,54)&&!g(x.value.I[0].type,55))throw Iu()}else{if(x.value.I.length!==1||!(g(x.value.I[0].type,54)||g(x.value.I[0].type,56)||g(x.value.I[0].type,58)||g(x.value.I[0].type,57)))throw Cu();if(A=he(o,x.value.I[0].value,null),A===null)throw Error(`XUDY0029: The target ${x.value.I[0].value.outerHTML} for inserting a node before or after must have a parent.`)}l=x.value.I[0],p=x.value.ca}if(a.length){if(3<=this.l){if(!g(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.")}else if(A.node.nodeType!==1)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");a.reduce((C,T)=>{let P=T.node.prefix||"";var _=T.node.prefix||"";let oe=T.node.namespaceURI,Ae=_?l.value.node.lookupNamespaceURI(_):null;if(Ae&&Ae!==oe)throw To(oe);if((_=C[_])&&oe!==_)throw Io(oe);return C[P]=T.node.namespaceURI,C},{})}return k({I:[],ca:Nt(fm(this.l,l.value,A||null,a,i),u,p)})}}}};let jo=()=>mt("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),Jl=/([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])/,dm=new RegExp(`${Jl.source}${new RegExp(`(${Jl.source}|[-.0-9\xB7\u0300-\u036F\u203F\u2040])`).source}*`,"g"),os=e=>(e=e.match(dm))?e.length===1:!1;function Kl(e,t){return Me(t,e).X({m:n=>{if(n=n.first(),g(n.type,1)||g(n.type,19)){if(!os(n.value))throw Error(`XQDY0041: The value "${n.value}" of a name expressions cannot be converted to a NCName.`);return f.m(n)}throw jo()},default:()=>{throw jo()}}).value}function Xo(e,t,n){return Me(n,t).X({m:r=>{if(r=r.first(),g(r.type,23))return f.m(r);if(g(r.type,1)||g(r.type,19)){let o,a;if(r=r.value.split(":"),r.length===1?r=r[0]:(o=r[0],a=e.Z(o),r=r[1]),!os(r)||o&&!os(o))throw tl(o?`${o}:${r}`:r);if(o&&!a)throw tl(`${o}:${r}`);return f.m({type:23,value:new _e(o,a,r)})}throw jo()},default:()=>{throw jo()}}).value}var gm=class extends Vn{constructor(e,t){super(new me({}),[e,t],{B:!1,P:"unsorted"}),this.A=e,this.K=t,this.l=void 0}s(e,t){let n=Rt(this.A)(e,t),r=Rt(this.K)(e,t);return{next:()=>{let o=n.next(0);var a=o.value.I;if(a.length===0)throw Co();if(a.length!==1||!g(a[0].type,54)&&!g(a[0].type,47)&&!g(a[0].type,57))throw Fu();a=a[0];let i=r.next(0);e:{var u=this.l,l=f.create(i.value.I);switch(a.type){case 54:if(u=Xo(u,t,l).next(0).value.value,(l=a.value.node.lookupNamespaceURI(u.prefix))&&l!==u.namespaceURI)throw To(u.namespaceURI);break e;case 47:if(u=Xo(u,t,l).next(0).value.value,u.namespaceURI&&(l=a.value.node.lookupNamespaceURI(u.prefix))&&l!==u.namespaceURI)throw To(u.namespaceURI);break e;case 57:u=Kl(t,l).next(0).value.value,u=new _e("",null,u);break e}u=void 0}return k({I:[],ca:Nt([new Xl(a.value,u)],o.value.ca,i.value.ca)})}}}v(e){this.l=Do(e),super.v(e)}};function ym(e,t,n){let r,o,a;return{next:()=>{if(!r){var i=n.next(0),u=rs([i.value.I],e,Io);r={attributes:u.attributes.map(l=>({node:l,F:null})),Ya:u.Ya.map(l=>({node:l,F:null}))},o=i.value.ca}if(u=t.next(0),u.value.I.length===0)throw Co();if(u.value.I.length!==1||!(g(u.value.I[0].type,54)||g(u.value.I[0].type,47)||g(u.value.I[0].type,56)||g(u.value.I[0].type,58)||g(u.value.I[0].type,57)))throw No();if(a=he(e.h,u.value.I[0].value,null),a===null)throw Error(`XUDY0009: The target ${u.value.I[0].value.outerHTML} for replacing a node must have a parent.`);if(i=u.value.I[0],u=u.value.ca,g(i.type,47)){if(r.Ya.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");r.attributes.reduce((l,p)=>{let A=p.node.prefix||"";p=p.node.namespaceURI;var x=a.node.lookupNamespaceURI(A);if(x&&x!==p)throw To(p);if((x=l[A])&&p!==x)throw Io(p);return l[A]=p,l},{})}else if(r.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");return k({I:[],ca:Nt([pm(i.value,[].concat(r.attributes,r.Ya))],o,u)})}}}function wm(e,t,n){let r,o,a,i,u=!1;return{next:()=>{if(u)return X;if(!a){var l=n.next(0);let p=Me(f.create(l.value.I),e).map(A=>xe(A,1)).N().map(A=>A.value).join(" ");a=p.length===0?null:{node:e.Ja.createTextNode(p),F:null},i=l.value.ca}if(!r){if(l=t.next(0),l.value.I.length===0)throw Co();if(l.value.I.length!==1||!(g(l.value.I[0].type,54)||g(l.value.I[0].type,47)||g(l.value.I[0].type,56)||g(l.value.I[0].type,58)||g(l.value.I[0].type,57)))throw No();r=l.value.I[0],o=l.value.ca}if(g(r.type,54))return u=!0,k({I:[],ca:Nt([new Ll(r.value,a)],i,o)});if(g(r.type,47)||g(r.type,56)||g(r.type,58)||g(r.type,57)){if(l=a?Ye(e.h,a):"",g(r.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(g(r.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);return u=!0,k({I:[],ca:Nt([new ql(r.value,l)],i,o)})}}}}var Am=class extends Vn{constructor(e,t,n){super(new me({}),[t,n],{B:!1,P:"unsorted"}),this.K=e,this.l=t,this.A=n}s(e,t){let n=Rt(this.l)(e,t);return e=Rt(this.A)(e,t),this.K?wm(t,n,e):ym(t,n,e)}};function bl(e){switch(e.type){case"delete":return new Ml({node:e.target,F:null});case"insertAfter":return new kl({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"insertBefore":return new Hl({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"insertInto":return new jl({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"insertIntoAsFirst":return new Pl({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"insertIntoAsLast":return new $l({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"insertAttributes":return new ur({node:e.target,F:null},e.content.map(t=>({node:t,F:null})));case"rename":return new Xl({node:e.target,F:null},e.newName);case"replaceNode":return new Yl({node:e.target,F:null},e.replacement.map(t=>({node:t,F:null})));case"replaceValue":return new ql({node:e.target,F:null},e["string-value"]);case"replaceElementContent":return new Ll({node:e.target,F:null},e.text?{node:e.text,F:null}:null);default:throw Error(`Unexpected type "${e.type}" when parsing a transferable pending update.`)}}function Vl(e,t,n){if(t.find(o=>$e(o,e)))return!0;let r=he(n,e);return r?Vl(r,t,n):!1}var vm=class extends Vn{constructor(e,t,n){super(new me({}),e.reduce((r,o)=>(r.push(o.fb),r),[t,n]),{B:!1,P:"unsorted"}),this.l=e,this.K=t,this.A=n,this.H=null}h(e,t){return e=this.s(e,t),Zn(e,()=>{})}s(e,t){let n=t.h,r=t.Ja,o=t.Oa,a=[],i,u,l,p=[],A=[];return{next:()=>{if(p.length!==this.l.length)for(var x=p.length;x<this.l.length;x++){let T=this.l[x];var C=a[x];if(C||(a[x]=C=Rt(T.fb)(e,t)),C=C.next(0),C.value.I.length!==1||!g(C.value.I[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");let P=Be(Go(C.value.I[0].value,t));p.push(P.value),A.push(C.value.ca),e=tn(e,{[T.ic]:()=>f.m(P)})}return l||(i||=Rt(this.K)(e,t),l=i.next(0).value.ca),l.forEach(T=>{if(T.target&&!Vl(T.target,p,n))throw Error(`XUDY0014: The target ${T.target.node.outerHTML} must be a node created by the copy clause.`);if(T.type==="put")throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.")}),x=l.map(T=>(T=T.h(t),bl(T))),ku(x,n,r,o),u||=Rt(this.A)(e,t),x=u.next(0),k({I:x.value.I,ca:Nt(x.value.ca,...A)})}}}v(e){er(e),this.l.forEach(t=>t.ic=Mt(e,t.Lb.namespaceURI,t.Lb.localName)),super.v(e),tr(e),this.H=this.l.some(t=>t.fb.H)||this.A.H}};function Zl(e,t){return{node:{nodeType:2,Ta:!0,nodeName:e.Aa(),namespaceURI:e.namespaceURI,prefix:e.prefix,localName:e.localName,name:e.Aa(),value:t},F:null}}var _l=class extends re{constructor(e,t){let n=t.nb||[];n=n.concat(e.Pa||[]),super(new me({}),n,{B:!1,P:"unsorted"}),e.Pa?this.s=e.Pa:this.name=new _e(e.prefix,e.namespaceURI,e.localName),this.l=t,this.A=void 0}h(e,t){let n,r,o,a=!1;return f.create({next:()=>{if(a)return X;if(!r){if(this.s){if(!n){var i=this.s.h(e,t);n=Xo(this.A,t,i)}r=n.next(0).value.value}else r=this.name;if(r&&(r.prefix==="xmlns"||r.prefix===""&&r.localName==="xmlns"||r.namespaceURI==="http://www.w3.org/2000/xmlns/"||r.prefix==="xml"&&r.namespaceURI!=="http://www.w3.org/XML/1998/namespace"||r.prefix!==""&&r.prefix!=="xml"&&r.namespaceURI==="http://www.w3.org/XML/1998/namespace"))throw Lr(r)}return this.l.nb?(i=this.l.nb,o||(o=Bt(i.map(u=>Me(u.h(e,t),t).M(l=>f.m(v(l.map(p=>p.value).join(" "),1))))).M(u=>f.m(Be(Zl(r,u.map(l=>l.value).join(""))))).value),o.next(0)):(a=!0,k(Be(Zl(r,this.l.value))))}})}v(e){if(this.A=Do(e),this.name&&this.name.prefix&&!this.name.namespaceURI){let t=e.Z(this.name.prefix);if(t===void 0&&this.name.prefix)throw $i(this.name.prefix);this.name.namespaceURI=t||null}super.v(e)}},xm=class extends re{constructor(e){super(e?e.o:new me({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){let n={data:"",Ta:!0,nodeType:8},r={node:n,F:null};return this.l?(e=b(this.l,e,t),Me(e,t).M(o=>{if(o=o.map(a=>xe(a,1).value).join(" "),o.indexOf("-->")!==-1)throw Error('XQDY0072: The contents of the data of a comment may not include "-->"');return n.data=o,f.m(Be(r))})):f.m(Be(r))}},Wl=class extends re{constructor(e,t,n,r){super(new me({}),r.concat(t).concat(e.Pa||[]),{B:!1,P:"unsorted"}),e.Pa?this.s=e.Pa:this.l=new _e(e.prefix,e.namespaceURI,e.localName),this.O=n.reduce((o,a)=>{if(a.prefix in o)throw Error(`XQST0071: The namespace declaration with the prefix ${a.prefix} has already been declared on the constructed element.`);return o[a.prefix||""]=a.uri,o},{}),this.K=t,this.la=r,this.A=void 0}h(e,t){let n=!1,r,o,a=!1,i,u,l,p=!1;return f.create({next:()=>{if(p)return X;if(n||(r||=Bt(this.K.map(P=>b(P,e,t))),o=r.N(),n=!0),!a){i||=this.la.map(P=>b(P,e,t));for(var A=[],x=0;x<i.length;x++){var C=i[x].N();A.push(C)}u=A,a=!0}if(this.s&&(l||(A=this.s.h(e,t),l=Xo(this.A,t,A)),this.l=l.next(0).value.value),this.l.prefix==="xmlns"||this.l.namespaceURI==="http://www.w3.org/2000/xmlns/"||this.l.prefix==="xml"&&this.l.namespaceURI!=="http://www.w3.org/XML/1998/namespace"||this.l.prefix&&this.l.prefix!=="xml"&&this.l.namespaceURI==="http://www.w3.org/XML/1998/namespace")throw Error(`XQDY0096: The node name "${this.l.Aa()}" is invalid for a computed element constructor.`);let T={nodeType:1,Ta:!0,attributes:[],childNodes:[],nodeName:this.l.Aa(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};for(A={node:T,F:null},o.forEach(P=>{T.attributes.push(P.value.node)}),x=rs(u,t,Lh),x.attributes.forEach(P=>{if(T.attributes.find(_=>_.namespaceURI===P.namespaceURI&&_.localName===P.localName))throw Error(`XQDY0025: The attribute ${P.name} does not have an unique name in the constructed element.`);T.attributes.push(P)}),x.Ya.forEach(P=>{T.childNodes.push(P)}),x=0;x<T.childNodes.length;x++){if(C=T.childNodes[x],!We(C)||C.nodeType!==3)continue;let P=T.childNodes[x-1];P&&We(P)&&P.nodeType===3&&(P.data+=C.data,T.childNodes.splice(x,1),x--)}return p=!0,k(Be(A))}})}v(e){if(er(e),Object.keys(this.O).forEach(t=>Bn(e,t,this.O[t])),this.Ga.forEach(t=>t.v(e)),this.K.reduce((t,n)=>{if(n.name){if(n=`Q{${n.name.namespaceURI===null?e.Z(n.name.prefix):n.name.namespaceURI}}${n.name.localName}`,t.includes(n))throw Error(`XQST0040: The attribute ${n} does not have an unique name in the constructed element.`);t.push(n)}return t},[]),this.l&&this.l.namespaceURI===null){let t=e.Z(this.l.prefix);if(t===void 0&&this.l.prefix)throw $i(this.l.prefix);this.l.namespaceURI=t}this.A=Do(e),tr(e)}};function zl(e){if(/^xml$/i.test(e))throw Error(`XQDY0064: The target of a created PI may not be "${e}"`)}function ec(e,t){return{node:{data:t,Ta:!0,nodeName:e,nodeType:7,target:e},F:null}}var Bm=class extends re{constructor(e,t){let n=e.xb?[e.xb].concat(t):[t];super(n.reduce((r,o)=>r.add(o.o),new me({})),n,{B:!1,P:"unsorted"}),this.l=e,this.s=t}h(e,t){let n=b(this.s,e,t);return Me(n,t).M(r=>{let o=r.map(i=>xe(i,1).value).join(" ");if(o.indexOf("?>")!==-1)throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(this.l.Gb!==null)return r=this.l.Gb,zl(r),f.m(Be(ec(r,o)));r=b(this.l.xb,e,t);let a=Kl(t,r);return f.create({next:()=>{var i=a.next(0);return i.done?i:(i=i.value.value,zl(i),k(Be(ec(i,o))))}})})}},Em=class extends re{constructor(e){super(e?e.o:new me({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){return this.l?(e=b(this.l,e,t),Me(e,t).M(n=>n.length===0?f.empty():(n={node:{data:n.map(r=>xe(r,1).value).join(" "),Ta:!0,nodeType:3},F:null},f.m(Be(n))))):f.empty()}},Nm=class extends xn{constructor(e,t,n,r){super(new me({}),[e,...t.map(o=>o.pb),n].concat(...t.map(o=>o.Kb.map(a=>a.Jb))),{B:!1,V:!1,P:"unsorted",subtree:!1},r),this.K=e,this.l=t.length,this.O=t.map(o=>o.Kb)}A(e,t,n){return n[0](e).M(r=>{for(let o=0;o<this.l;o++)if(this.O[o].some(a=>{switch(a.hc){case"?":if(1<r.length)return!1;break;case"*":break;case"+":if(1>r.length)return!1;break;default:if(r.length!==1)return!1}let i=f.create(r);return r.every((u,l)=>(u=Qt(e,l,u,i),b(a.Jb,u,t).ea()))}))return n[o+1](e);return n[this.l+1](e)})}v(e){if(super.v(e),this.K.H)throw bt()}},Tm=class extends xn{constructor(e,t,n,r){super(new me({}),[e,n,...t.map(o=>o.pb)].concat(...t.map(o=>o.Hb.map(a=>a))),{B:!1,V:!1,P:"unsorted",subtree:!1},r),this.K=e,this.l=t.length,this.O=t.map(o=>o.Hb)}A(e,t,n){let r=sr(n[0](e),t),[,o,...a]=n;return r.X({multiple:()=>{throw Error("XPTY0004: The operand for a switch expression should result in zero or one item")},default:()=>{let i=r.first(),u=!i;for(let p=0;p<this.l;p++){var l=this.O[p].map(A=>b(A,e,t));for(let A of l)if(l=sr(A,t),l.isEmpty()){if(u)return a[p](e)}else{if(!l.oa())throw Error("XPTY0004: The operand for a switch case should result in zero or one item");if(!u&&(l=l.first(),Xa(e,t,null,i,l).next(0).value))return a[p](e)}}return o(e)}})}v(e){if(super.v(e),this.K.H)throw bt()}},Im={Y:!1,ra:!1},Cm={Y:!0,ra:!1},Fm={Y:!0,ra:!0};function ie(e){return e.Y?e.ra?Fm:Cm:Im}function H(e,t){switch(e[0]){case"andOp":var n=J(e,"type");return new Of(tc("andOp",e,ie(t)),n);case"orOp":return n=J(e,"type"),new Df(tc("orOp",e,ie(t)),n);case"unaryPlusOp":return n=B(B(e,"operand"),"*"),e=J(e,"type"),new Il("+",H(n,t),e);case"unaryMinusOp":return n=B(B(e,"operand"),"*"),e=J(e,"type"),new Il("-",H(n,t),e);case"addOp":case"subtractOp":case"multiplyOp":case"divOp":case"idivOp":case"modOp":var r=e[0],o=H($(e,["firstOperand","*"]),ie(t));t=H($(e,["secondOperand","*"]),ie(t));let a=J(e,"type"),i=J($(e,["firstOperand","*"]),"type"),u=J($(e,["secondOperand","*"]),"type");return i&&u&&J(e,"type")&&(n=il(r,i.type,u.type)),new Kh(r,o,t,a,n);case"sequenceExpr":return jm(e,t);case"unionOp":return n=J(e,"type"),new Wf([H($(e,["firstOperand","*"]),ie(t)),H($(e,["secondOperand","*"]),ie(t))],n);case"otherwiseOp":return n=J(e,"type"),new of([H($(e,["firstOperand","*"]),ie(t)),H($(e,["secondOperand","*"]),ie(t))],n);case"exceptOp":case"intersectOp":return n=J(e,"type"),new Kf(e[0],H($(e,["firstOperand","*"]),ie(t)),H($(e,["secondOperand","*"]),ie(t)),n);case"stringConcatenateOp":return Lm(e,t);case"rangeSequenceExpr":return Ym(e,t);case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":return ss("generalCompare",e,t);case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":return ss("valueCompare",e,t);case"isOp":case"nodeBeforeOp":case"nodeAfterOp":return ss("nodeCompare",e,t);case"pathExpr":return Pm(e,t);case"contextItemExpr":return t=J(e,"type"),new tm(t);case"functionCallExpr":return Rm(e,t);case"inlineFunctionExpr":return km(e,t);case"arrowExpr":return Sm(e,t);case"dynamicFunctionInvocationExpr":return Mm(e,t);case"namedFunctionRef":return t=B(e,"functionName"),n=J(e,"type"),e=se($(e,["integerConstantExpr","value"])),new qr(Ne(t),parseInt(e,10),n);case"integerConstantExpr":return new ar(se(B(e,"value")),{type:5,g:3});case"stringConstantExpr":return new ar(se(B(e,"value")),{type:1,g:3});case"decimalConstantExpr":return new ar(se(B(e,"value")),{type:4,g:3});case"doubleConstantExpr":return new ar(se(B(e,"value")),{type:3,g:3});case"varRef":let{prefix:l,namespaceURI:p,localName:A}=Ne(B(e,"name"));return new lm(l,p,A);case"flworExpr":return Um(e,t);case"quantifiedExpr":return $m(e,t);case"ifThenElseExpr":return n=J(e,"type"),r=B(e,"ifClause")||q(e,"x:stackTrace")[0],o=B(e,"thenClause")||q(e,"x:stackTrace")[1],e=B(e,"elseClause")||q(e,"x:stackTrace")[2],new Ef(H(r,ie(t)),H(o,t),H(e,t),n);case"instanceOfExpr":return n=H($(e,["argExpr","*"]),t),r=$(e,["sequenceType","*"]),o=$(e,["sequenceType","occurrenceIndicator"]),e=J(e,"type"),new _f(n,H(r,ie(t)),o?se(o):"",e);case"castExpr":return t=H(B(B(e,"argExpr"),"*"),ie(t)),n=B(e,"singleType"),e=Ne(B(n,"atomicType")),n=B(n,"optional")!==null,new Zf(t,e,n);case"castableExpr":return t=H(B(B(e,"argExpr"),"*"),ie(t)),n=B(e,"singleType"),e=Ne(B(n,"atomicType")),n=B(n,"optional")!==null,new Vf(t,e,n);case"simpleMapExpr":return Xm(e,t);case"mapConstructor":return Om(e,t);case"arrayConstructor":return Gm(e,t);case"unaryLookup":return n=J(e,"type"),new sm(nc(e,t),n);case"typeswitchExpr":return bm(e,t);case"switchExpr":return Vm(e,t);case"elementConstructor":return qm(e,t);case"attributeConstructor":return Qm(e,t);case"computedAttributeConstructor":return(n=B(e,"tagName"))?n=Ne(n):(n=B(e,"tagNameExpr"),n={Pa:H(B(n,"*"),ie(t))}),t=H(B(B(e,"valueExpr"),"*"),ie(t)),new _l(n,{nb:[t]});case"computedCommentConstructor":if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return t=(e=B(e,"argExpr"))?H(B(e,"*"),ie(t)):null,new xm(t);case"computedTextConstructor":if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return t=(e=B(e,"argExpr"))?H(B(e,"*"),ie(t)):null,new Em(t);case"computedElementConstructor":return Jm(e,t);case"computedPIConstructor":if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return n=B(e,"piTargetExpr"),r=B(e,"piTarget"),o=B(e,"piValueExpr"),e=J(e,"type"),new Bm({xb:n?H(B(n,"*"),ie(t)):null,Gb:r?se(r):null},o?H(B(o,"*"),ie(t)):new ts([],e));case"CDataSection":return new ar(se(e),{type:1,g:3});case"deleteExpr":return t=H($(e,["targetExpr","*"]),t),new hm(t);case"insertExpr":switch(n=H($(e,["sourceExpr","*"]),t),o=q(e,"*")[1],o[0]){case"insertAfter":r=1;break;case"insertBefore":r=2;break;case"insertInto":r=(r=B(o,"*"))?r[0]==="insertAsFirst"?4:5:3}return t=H($(e,["targetExpr","*"]),t),new mm(n,r,t);case"renameExpr":return n=H($(e,["targetExpr","*"]),t),t=H($(e,["newNameExpr","*"]),t),new gm(n,t);case"replaceExpr":return n=!!B(e,"replaceValue"),r=H($(e,["targetExpr","*"]),t),t=H($(e,["replacementExpr","*"]),t),new Am(n,r,t);case"transformExpr":return Km(e,t);case"x:stackTrace":for(n=e,e=n[2];e[0]==="x:stackTrace";)n=e,e=e[2];return n=n[1],new Nf(n,e[0],H(e,t),n.Xa);case"ifClause":case"thenClause":case"elseClause":return H(B(e,"*"),t);default:return as(e,t)}}function as(e,t){switch(e[0]){case"nameTest":return new Tn(Ne(e));case"piTest":return(e=B(e,"piTarget"))?new um(se(e)):new ir(7);case"commentTest":return new ir(8);case"textTest":return new ir(3);case"documentTest":return new ir(9);case"attributeTest":return t=(e=B(e,"attributeName"))&&B(e,"star"),!e||t?new ir(2):new Tn(Ne(B(e,"QName")),{kind:2});case"elementTest":return t=(e=B(e,"elementName"))&&B(e,"star"),!e||t?new ir(1):new Tn(Ne(B(e,"QName")),{kind:1});case"anyKindTest":return new Qr({prefix:"",namespaceURI:null,localName:"node()"});case"anyMapTest":return new Qr({prefix:"",namespaceURI:null,localName:"map(*)"});case"anyArrayTest":return new Qr({prefix:"",namespaceURI:null,localName:"array(*)"});case"Wildcard":return B(e,"star")?(t=B(e,"uri"))?e=new Tn({localName:"*",namespaceURI:se(t),prefix:""}):(t=B(e,"NCName"),e=B(e,"*")[0]==="star"?new Tn({localName:se(t),namespaceURI:null,prefix:"*"}):new Tn({localName:"*",namespaceURI:null,prefix:se(t)})):e=new Tn({localName:"*",namespaceURI:null,prefix:"*"}),e;case"atomicType":return e=Ne(e),new Qr(e);case"anyItemType":return new Qr({prefix:"",namespaceURI:null,localName:"item()"});case"unionNodeTest":return Hm(e,t);default:throw Error("No selector counterpart for: "+e[0]+".")}}function Gm(e,t){let n=J(e,"type");e=B(e,"*");let r=q(e,"arrayElem").map(o=>H(B(o,"*"),ie(t)));switch(e[0]){case"curlyArray":return new sf(r,n);case"squareArray":return new uf(r,n);default:throw Error("Unrecognized arrayType: "+e[0])}}function Om(e,t){let n=J(e,"type");return new Ff(q(e,"mapConstructorEntry").map(r=>({key:H($(r,["mapKeyExpr","*"]),ie(t)),value:H($(r,["mapValueExpr","*"]),ie(t))})),n)}function tc(e,t,n){function r(a){let i=B(B(a,"firstOperand"),"*");a=B(B(a,"secondOperand"),"*"),i[0]===e?r(i):o.push(H(i,n)),a[0]===e?r(a):o.push(H(a,n))}let o=[];return r(t),o}function nc(e,t){switch(e=B(e,"*"),e[0]){case"NCName":return new ar(se(e),{type:1,g:3});case"star":return"*";default:return H(e,ie(t))}}function ss(e,t,n){var r=$(t,["firstOperand","*"]);let o=$(t,["secondOperand","*"]);switch(r=H(r,ie(n)),n=H(o,ie(n)),e){case"valueCompare":return new jf(t[0],r,n);case"nodeCompare":return new Jf(t[0],r,n);case"generalCompare":return new Yf(t[0],r,n)}}function Dm(e,t,n){return e=q(e,"*"),new em(e.filter(r=>r[0]!=="stable").map(r=>{var o=B(r,"orderModifier"),a=o?B(o,"orderingKind"):null;return o=o?B(o,"emptyOrderingMode"):null,a=a?se(a)==="ascending":!0,o=o?se(o)==="empty least":!0,{aa:H($(r,["orderByExpr","*"]),t),Cb:a,ec:o}}),n)}function Um(e,t){var n=q(e,"*");if(e=B(n[n.length-1],"*"),n=n.slice(0,-1),1<n.length&&!t.Y)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return n.reduceRight((r,o)=>{switch(o[0]){case"forClause":o=q(o,"*");for(var a=o.length-1;0<=a;--a){var i=o[a],u=$(i,["forExpr","*"]);let l=B(i,"positionalVariableBinding");r=new Tf(Ne($(i,["typedVariableBinding","varName"])),H(u,ie(t)),l?Ne(l):null,r)}return r;case"letClause":for(o=q(o,"*"),a=o.length-1;0<=a;--a)i=o[a],u=$(i,["letExpr","*"]),r=new Cf(Ne($(i,["typedVariableBinding","varName"])),H(u,ie(t)),r);return r;case"whereClause":for(o=q(o,"*"),a=o.length-1;0<=a;--a)r=new cm(H(o[a],t),r);return r;case"windowClause":throw Error(`Not implemented: ${o[0]} is not implemented yet.`);case"groupByClause":throw Error(`Not implemented: ${o[0]} is not implemented yet.`);case"orderByClause":return Dm(o,t,r);case"countClause":throw Error(`Not implemented: ${o[0]} is not implemented yet.`);default:throw Error(`Not implemented: ${o[0]} is not supported in a flwor expression`)}},H(e,t))}function Rm(e,t){let n=B(e,"functionName"),r=q(B(e,"arguments"),"*");return e=J(e,"type"),new jr(new qr(Ne(n),r.length,e),r.map(o=>o[0]==="argumentPlaceholder"?null:H(o,t)),e)}function Sm(e,t){let n=J(e,"type");var r=$(e,["argExpr","*"]);e=q(e,"*").slice(1),r=[H(r,t)];for(let a=0;a<e.length;a++)if(e[a][0]!=="arguments"){if(e[a+1][0]==="arguments"){var o=q(e[a+1],"*");r=r.concat(o.map(i=>i[0]==="argumentPlaceholder"?null:H(i,t)))}o=e[a][0]==="EQName"?new qr(Ne(e[a]),r.length,n):H(e[a],ie(t)),r=[new jr(o,r,n)]}return r[0]}function Mm(e,t){let n=$(e,["functionItem","*"]),r=J(e,"type");e=B(e,"arguments");let o=[];return e&&(o=q(e,"*").map(a=>a[0]==="argumentPlaceholder"?null:H(a,t))),new jr(H(n,t),o,r)}function km(e,t){let n=q(B(e,"paramList"),"*"),r=$(e,["functionBody","*"]),o=J(e,"type");return new If(n.map(a=>({name:Ne(B(a,"varName")),type:Uo(a)})),Uo(e),r?H(r,t):new ts([],o))}function Hm(e,t){return e=q(e,"*").map(n=>as(n,t)),e.length===1?e[1]:new af(e)}function Pm(e,t){let n=J(e,"type");var r=q(e,"stepExpr");let o=!1;var a=r.map(i=>{var u=B(i,"xpathAxis");let l;var p=q(i,"*");let A=[],x=null,C=!1;for(let T of p)switch(T[0]){case"lookup":A.push(["lookup",nc(T,t)]);break;case"predicate":case"predicates":for(let P of q(T,"*")){if(p=H(P,ie(t)),!C){let _=p.D();_===null?C=!0:x=ct(x,_)}A.push(["predicate",p])}}if(u)switch(o=!0,i=B(i,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard unionNodeTest".split(" ")),i=as(i,ie(t)),se(u)){case"ancestor":l=new wl(i,{Sa:!1});break;case"ancestor-or-self":l=new wl(i,{Sa:!0});break;case"attribute":l=new cf(i,x);break;case"child":l=new pf(i,x);break;case"descendant":l=new Al(i,{Sa:!1});break;case"descendant-or-self":l=new Al(i,{Sa:!0});break;case"parent":l=new yf(i,x);break;case"following-sibling":l=new gf(i,x);break;case"preceding-sibling":l=new xf(i,x);break;case"following":l=new mf(i);break;case"preceding":l=new Af(i);break;case"self":l=new Bf(i,x)}else u=$(i,["filterExpr","*"]),l=H(u,ie(t));for(let T of A)switch(T[0]){case"lookup":l=new am(l,T[1]);break;case"predicate":l=new om(l,T[1])}return l.type=n,l});return e=B(e,"rootExpr"),r=o||e!==null||1<r.length,!r&&a.length===1||!e&&a.length===1&&a[0].ha==="sorted"?a[0]:e&&a.length===0?new Ul(null):(a=new rm(a,r),e?new Ul(a):a)}function $m(e,t){let n=J(e,"type"),r=se(B(e,"quantifier")),o=$(e,["predicateExpr","*"]);return e=q(e,"quantifiedExprInClause").map(a=>{let i=Ne($(a,["typedVariableBinding","varName"]));return a=$(a,["sourceExpr","*"]),{name:i,fb:H(a,ie(t))}}),new im(r,e,H(o,ie(t)),n)}function jm(e,t){var n=q(e,"*").map(r=>H(r,t));return n.length===1?n[0]:(n=J(e,"type"),new ts(q(e,"*").map(r=>H(r,t)),n))}function Xm(e,t){let n=J(e,"type");return q(e,"*").reduce((r,o)=>r===null?H(o,ie(t)):new bf(r,H(o,ie(t)),n),null)}function Lm(e,t){let n=J(e,"type");return e=[$(e,["firstOperand","*"]),$(e,["secondOperand","*"])],new jr(new qr({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},e.length,n),e.map(r=>H(r,ie(t))),n)}function Ym(e,t){let n=J(e,"type");e=[B(B(e,"startExpr"),"*"),B(B(e,"endExpr"),"*")];let r=new qr({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},e.length,n);return new jr(r,e.map(o=>H(o,ie(t))),n)}function qm(e,t){if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");let n=Ne(B(e,"tagName"));var r=B(e,"attributeList");let o=r?q(r,"attributeConstructor").map(a=>H(a,ie(t))):[];return r=r?q(r,"namespaceDeclaration").map(a=>{let i=B(a,"prefix");return{prefix:i?se(i):"",uri:se(B(a,"uri"))}}):[],e=(e=B(e,"elementContent"))?q(e,"*").map(a=>H(a,ie(t))):[],new Wl(n,o,r,e)}function Qm(e,t){if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");let n=Ne(B(e,"attributeName"));var r=B(e,"attributeValue");return r=r?se(r):null,e=(e=B(e,"attributeValueExpr"))?q(e,"*").map(o=>H(o,ie(t))):null,new _l(n,{value:r,nb:e})}function Jm(e,t){var n=B(e,"tagName");return n?n=Ne(n):(n=B(e,"tagNameExpr"),n={Pa:H(B(n,"*"),ie(t))}),e=(e=B(e,"contentExpr"))?q(e,"*").map(r=>H(r,ie(t))):[],new Wl(n,[],[],e)}function Km(e,t){let n=q(B(e,"transformCopies"),"transformCopy").map(o=>{let a=Ne(B(B(o,"varRef"),"name"));return{fb:H(B(B(o,"copySource"),"*"),t),Lb:new _e(a.prefix,a.namespaceURI,a.localName)}}),r=H(B(B(e,"modifyExpr"),"*"),t);return e=H(B(B(e,"returnExpr"),"*"),t),new vm(n,r,e)}function bm(e,t){if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");let n=J(e,"type"),r=H(B(B(e,"argExpr"),"*"),t),o=q(e,"typeswitchExprCaseClause").map(a=>{let i=q(a,"sequenceTypeUnion").length===0?[B(a,"sequenceType")]:q(B(a,"sequenceTypeUnion"),"sequenceType");return{pb:H($(a,["resultExpr","*"]),t),Kb:i.map(u=>{let l=B(u,"occurrenceIndicator");return{hc:l?se(l):"",Jb:H(B(u,"*"),t)}})}});return e=H($(e,["typeswitchExprDefaultClause","resultExpr","*"]),t),new Nm(r,o,e,n)}function Vm(e,t){if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");let n=J(e,"type"),r=H(B(B(e,"argExpr"),"*"),t),o=q(e,"switchExprCaseClause").map(a=>{let i=q(a,"switchCaseExpr");return{pb:H($(a,["resultExpr","*"]),t),Hb:i.map(u=>H(B(u,"*"),t))}});return e=H($(e,["switchExprDefaultClause","resultExpr","*"]),t),new Tm(r,o,e,n)}function is(e,t){return H(e,t)}let Lo=new Map;class Zm{constructor(t,n,r,o,a,i){this.v=t,this.D=n,this.h=r,this.kb=o,this.o=a,this.l=i}}function _m(e,t,n,r,o,a,i,u){return e=Lo.get(e),e?(t=e[t+(a?"_DEBUG":"")],t&&(t=t.find(l=>l.o===i&&l.v.every(p=>n(p.prefix)===p.namespaceURI)&&l.D.every(p=>r[p.name]!==void 0)&&l.kb.every(p=>o[p.prefix]===p.namespaceURI)&&l.l.every(p=>{let A=u(p.fc,p.arity);return A&&A.namespaceURI===p.Eb.namespaceURI&&A.localName===p.Eb.localName})))?{aa:t.h,jc:!1}:null):null}function rc(e,t,n,r,o,a,i){let u=Lo.get(e);u||(u=Object.create(null),Lo.set(e,u)),e=t+(a?"_DEBUG":""),(t=u[e])||(t=u[e]=[]),t.push(new Zm(Object.values(n.h),Object.values(n.o),o,Object.keys(r).map(l=>({namespaceURI:r[l],prefix:l})),i,n.D))}function Yo(e){var t=new Wt;if(e.namespaceURI!=="http://www.w3.org/2005/XQueryX"&&e.namespaceURI!=="http://www.w3.org/2005/XQueryX"&&e.namespaceURI!=="http://fontoxml.com/fontoxpath"&&e.namespaceURI!=="http://www.w3.org/2007/xquery-update-10")throw mt("The XML structure passed as an XQueryX program was not valid XQueryX");let n=[e.localName==="stackTrace"?"x:stackTrace":e.localName],r=t.getAllAttributes(e);r&&0<r.length&&n.push(Array.from(r).reduce((o,a)=>(a.localName!=="comment"&&a.localName!=="start"&&a.localName!=="end"||e.localName!=="stackTrace"?a.localName==="type"?o[a.localName]=dn(a.value):o[a.localName]=a.value:o[a.localName]=JSON.parse(a.value),o),{})),t=t.getChildNodes(e);for(let o of t)switch(o.nodeType){case 1:n.push(Yo(o));break;case 3:n.push(o.data)}return n}let Kr=Object.create(null);var oc=(e,t)=>{let n=Kr[e];n||=Kr[e]={Ia:[],Va:[],pa:null,source:t.source};let r=n.pa||(()=>{});n.Ia=n.Ia.concat(t.Ia),n.Va=n.Va.concat(t.Va),n.pa=o=>{r(o),t.pa&&t.pa(o)}},us=(e,t)=>{let n=Kr[t];if(!n)throw Error(`XQST0051: No modules found with the namespace uri ${t}`);n.Ia.forEach(r=>{r.cb&&_a(e,t,r.localName,r.arity,r)}),n.Va.forEach(r=>{Mt(e,t,r.localName),ol(e,t,r.localName,(o,a)=>b(r.aa,o,a))})},br=()=>{Object.keys(Kr).forEach(e=>{if(e=Kr[e],e.pa)try{e.pa(e)}catch(t){e.pa=null,at(e.source,t)}e.pa=null})};function ls(e){return e.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,`
|
|
8
|
+
`)}var s=h;function cs(e,t){return(n,r)=>t.has(r)?t.get(r):(n=e(n,r),t.set(r,n),n)}function Z(e,t){return(0,s.delimited)(t,e,t)}function G(e,t){return e.reverse().reduce((n,r)=>(0,s.preceded)(r,n),t)}function Xe(e,t,n,r){return(0,s.then)((0,s.then)(e,t,(o,a)=>[o,a]),n,([o,a],i)=>r(o,a,i))}function ps(e,t,n,r,o){return(0,s.then)((0,s.then)((0,s.then)(e,t,(a,i)=>[a,i]),n,([a,i],u)=>[a,i,u]),r,([a,i,u],l)=>o(a,i,u,l))}function Wm(e,t,n,r,o,a){return(0,s.then)((0,s.then)((0,s.then)((0,s.then)(e,t,(i,u)=>[i,u]),n,([i,u],l)=>[i,u,l]),r,([i,u,l],p)=>[i,u,l,p]),o,([i,u,l,p],A)=>a(i,u,l,p,A))}function on(e){return(0,s.map)(e,t=>[t])}function ge(e,t){return(0,s.map)((0,s.or)(e),()=>t)}function Le(e){return(t,n)=>(t=e.exec(t.substring(n)))&&t.index===0?(0,s.okWithValue)(n+t[0].length,t[0]):(0,s.error)(n,[e.source],!1)}var ac=(0,s.or)([(0,s.token)(" "),(0,s.token)(" "),(0,s.token)("\r"),(0,s.token)(`
|
|
9
|
+
`)]),sc=(0,s.token)("(:"),ic=(0,s.token)(":)"),zm=(0,s.token)("(#"),uc=(0,s.token)("#)"),Re=(0,s.token)("("),Oe=(0,s.token)(")"),lc=(0,s.token)("["),cc=(0,s.token)("]"),an=(0,s.token)("{"),sn=(0,s.token)("}"),ed=(0,s.token)("{{"),td=(0,s.token)("}}"),qo=(0,s.token)("'"),nd=(0,s.token)("''"),Qo=(0,s.token)('"'),rd=(0,s.token)('""'),od=(0,s.token)("<![CDATA["),pc=(0,s.token)("]]>"),ad=(0,s.token)("/>"),sd=(0,s.token)("</"),id=(0,s.token)("<!--"),ud=(0,s.token)("-->"),ld=(0,s.token)("<?"),hc=(0,s.token)("?>"),cd=(0,s.token)("&#x"),pd=(0,s.token)("&#"),hd=(0,s.token)(":*"),fd=(0,s.token)("*:"),Cn=(0,s.token)(":="),md=(0,s.token)("&"),Vr=(0,s.token)(":"),Fn=(0,s.token)(";"),Ht=(0,s.token)("*"),fc=(0,s.token)("@"),Pt=(0,s.token)("$"),dd=(0,s.token)("#"),mc=(0,s.token)("%"),Zr=(0,s.token)("?"),un=(0,s.token)("="),gd=(0,s.followed)((0,s.token)("!"),(0,s.not)((0,s.peek)(un),[])),hs=(0,s.followed)((0,s.token)("|"),(0,s.not)((0,s.peek)((0,s.token)("|")),[])),yd=(0,s.token)("||"),wd=(0,s.token)("!="),dc=(0,s.token)("<"),Ad=(0,s.token)("<<"),vd=(0,s.token)("<="),fs=(0,s.token)(">"),xd=(0,s.token)(">>"),Bd=(0,s.token)(">="),qe=(0,s.token)(","),lr=(0,s.token)("."),Ed=(0,s.token)(".."),Jo=(0,s.token)("+"),cr=(0,s.token)("-"),Ko=(0,s.token)("/"),Nd=(0,s.token)("//"),Td=(0,s.token)("=>"),Id=(0,s.token)("e"),Cd=(0,s.token)("E");(0,s.token)("l"),(0,s.token)("L"),(0,s.token)("m"),(0,s.token)("M");var Fd=(0,s.token)("Q");(0,s.token)("x"),(0,s.token)("X");var Tt=(0,s.token)("as"),Gd=(0,s.token)("cast"),Od=(0,s.token)("castable"),Dd=(0,s.token)("treat"),Ud=(0,s.token)("instance"),gc=(0,s.token)("of"),_r=(0,s.token)("node"),yc=(0,s.token)("nodes"),Rd=(0,s.token)("delete"),Sd=(0,s.token)("value"),pr=(0,s.token)("function"),bo=(0,s.token)("map"),Gn=(0,s.token)("element"),Wr=(0,s.token)("attribute"),wc=(0,s.token)("schema-element"),Md=(0,s.token)("intersect"),kd=(0,s.token)("except"),Hd=(0,s.token)("union"),Pd=(0,s.token)("otherwise"),$d=(0,s.token)("to"),jd=(0,s.token)("is"),Xd=(0,s.token)("or"),Ld=(0,s.token)("and"),Yd=(0,s.token)("div"),qd=(0,s.token)("idiv"),Qd=(0,s.token)("mod"),Jd=(0,s.token)("eq"),Kd=(0,s.token)("ne"),Ac=(0,s.token)("lt"),bd=(0,s.token)("le"),vc=(0,s.token)("gt"),Vd=(0,s.token)("ge"),Zd=(0,s.token)("amp"),_d=(0,s.token)("quot"),Wd=(0,s.token)("apos"),xc=(0,s.token)("if"),zd=(0,s.token)("then"),eg=(0,s.token)("else"),tg=(0,s.token)("allowing"),ms=(0,s.token)("empty"),ds=(0,s.token)("at"),Bc=(0,s.token)("in"),ng=(0,s.token)("for"),rg=(0,s.token)("let"),og=(0,s.token)("where"),gs=(0,s.token)("collation"),ag=(0,s.token)("group"),ys=(0,s.token)("by"),ws=(0,s.token)("order"),sg=(0,s.token)("stable"),hr=(0,s.token)("return"),Vo=(0,s.token)("array"),ig=(0,s.token)("document"),On=(0,s.token)("namespace"),Ec=(0,s.token)("text"),Nc=(0,s.token)("comment"),Tc=(0,s.token)("processing-instruction"),ug=(0,s.token)("lax"),lg=(0,s.token)("strict"),cg=(0,s.token)("validate"),pg=(0,s.token)("type"),pt=(0,s.token)("declare"),Dn=(0,s.token)("default"),hg=(0,s.token)("boundary-space"),Ic=(0,s.token)("strip"),As=(0,s.token)("preserve"),fg=(0,s.token)("no-preserve"),mg=(0,s.token)("inherit"),dg=(0,s.token)("no-inherit"),Cc=(0,s.token)("greatest"),Fc=(0,s.token)("least"),gg=(0,s.token)("copy-namespaces"),Gc=(0,s.token)("decimal-format"),Oc=(0,s.token)("case"),Dc=(0,s.token)("typeswitch"),yg=(0,s.token)("some"),wg=(0,s.token)("every"),Ag=(0,s.token)("satisfies"),vg=(0,s.token)("replace"),xg=(0,s.token)("with"),Bg=(0,s.token)("copy"),Eg=(0,s.token)("modify"),Ng=(0,s.token)("first"),Tg=(0,s.token)("last"),Ig=(0,s.token)("before"),Cg=(0,s.token)("after"),Fg=(0,s.token)("into"),Gg=(0,s.token)("insert"),Og=(0,s.token)("rename"),Uc=(0,s.token)("switch"),Dg=(0,s.token)("variable"),vs=(0,s.token)("external"),Ug=(0,s.token)("updating"),Rc=(0,s.token)("import"),Rg=(0,s.token)("schema"),Sc=(0,s.token)("module"),Sg=(0,s.token)("base-uri"),Mg=(0,s.token)("construction"),kg=(0,s.token)("ordering"),Hg=(0,s.token)("ordered"),Pg=(0,s.token)("unordered"),$g=(0,s.token)("option"),jg=(0,s.token)("context"),Mc=(0,s.token)("item"),Xg=(0,s.token)("xquery"),Lg=(0,s.token)("version"),kc=(0,s.token)("encoding"),Yg=(0,s.token)("document-node"),qg=(0,s.token)("namespace-node"),Qg=(0,s.token)("schema-attribute"),Jg=(0,s.token)("ascending"),Kg=(0,s.token)("descending"),bg=(0,s.token)("empty-sequence"),Vg=(0,s.token)("child::"),Zg=(0,s.token)("descendant::"),_g=(0,s.token)("attribute::"),Wg=(0,s.token)("self::"),zg=(0,s.token)("descendant-or-self::"),ey=(0,s.token)("following-sibling::"),ty=(0,s.token)("following::"),ny=(0,s.token)("parent::"),ry=(0,s.token)("ancestor::"),oy=(0,s.token)("preceding-sibling::"),ay=(0,s.token)("preceding::"),sy=(0,s.token)("ancestor-or-self::"),iy=(0,s.token)("decimal-separator"),uy=(0,s.token)("grouping-separator"),ly=(0,s.token)("infinity"),cy=(0,s.token)("minus-sign"),py=(0,s.token)("NaN"),hy=(0,s.token)("per-mille"),fy=(0,s.token)("zero-digit"),my=(0,s.token)("digit"),dy=(0,s.token)("pattern-separator"),gy=(0,s.token)("exponent-separator"),yy=(0,s.token)("schema-attribute("),wy=(0,s.token)("document-node("),Ay=(0,s.token)("processing-instruction("),vy=(0,s.token)("processing-instruction()"),xy=(0,s.token)("comment()"),By=(0,s.token)("text()"),Ey=(0,s.token)("namespace-node()"),Ny=(0,s.token)("node()"),Ty=(0,s.token)("item()"),Iy=(0,s.token)("empty-sequence()");(0,s.token)("`");var Cy=(0,s.token)("``["),Hc=(0,s.token)("]``"),Pc=(0,s.token)("`{"),$c=(0,s.token)("}`"),jc=new Map,Xc=new Map,$t=(0,s.or)([Le(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Le(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),Fy=(0,s.preceded)((0,s.peek)((0,s.not)((0,s.or)([sc,ic]),['comment contents cannot contain "(:" or ":)"'])),$t),Lc=(0,s.map)((0,s.delimited)(sc,(0,s.star)((0,s.or)([Fy,function(e,t){return Lc(e,t)}])),ic,!0),e=>e.join("")),xs=(0,s.or)([ac,Lc]),Zo=(0,s.map)((0,s.plus)(ac),e=>e.join("")),N=cs((0,s.map)((0,s.star)(xs),e=>e.join("")),jc),D=cs((0,s.map)((0,s.plus)(xs),e=>e.join("")),Xc);let Bs=(0,s.or)([Le(/[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,s.then)(Le(/[\uD800-\uDB7F]/),Le(/[\uDC00-\uDFFF]/),(e,t)=>e+t)]),Yc=(0,s.or)([Bs,Le(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var tt=(0,s.then)(Bs,(0,s.star)(Yc),(e,t)=>e+t.join("")),Gy=(0,s.map)(tt,e=>["prefix",e]);let Oy=(0,s.or)([Bs,Vr]),Dy=(0,s.or)([Yc,Vr]);(0,s.then)(Oy,(0,s.star)(Dy),(e,t)=>e+t.join(""));let Uy=(0,s.map)(tt,e=>[{prefix:"",URI:null},e]),Ry=(0,s.then)(tt,(0,s.preceded)(Vr,tt),(e,t)=>[{prefix:e,URI:null},t]);var _o=(0,s.or)([Ry,Uy]),qc=(0,s.followed)(G([Fd,N,an],(0,s.map)((0,s.star)(Le(/[^{}]/)),e=>e.join("").replace(/\s+/g," ").trim())),sn);let Sy=(0,s.then)(qc,tt,(e,t)=>[e,t]);var Te=(0,s.or)([(0,s.map)(Sy,e=>[{prefix:null,URI:e[0]},e[1]]),_o]),Qc=(0,s.or)([(0,s.map)(Te,e=>["QName",...e]),(0,s.map)(Ht,()=>["star"])]),Es=(0,s.map)((0,s.preceded)(Pt,Te),e=>["varRef",["name",...e]]),Qe=(0,s.peek)((0,s.or)([Re,Qo,qo,xs])),My=(0,s.map)((0,s.or)([Vg,Zg,_g,Wg,zg,ey,ty]),e=>e.substring(0,e.length-2)),ky=(0,s.map)((0,s.or)([ny,ry,oy,ay,sy]),e=>e.substring(0,e.length-2)),Ns=Xe(md,(0,s.or)([Ac,vc,Zd,_d,Wd]),Fn,(e,t,n)=>e+t+n),Ts=(0,s.or)([Xe(cd,Le(/[0-9a-fA-F]+/),Fn,(e,t,n)=>e+t+n),Xe(pd,Le(/[0-9]+/),Fn,(e,t,n)=>e+t+n)]),Is=ge([rd],'"'),Cs=ge([nd],"'"),Hy=on(ge([xy],"commentTest")),Py=on(ge([By],"textTest")),$y=on(ge([Ey],"namespaceTest")),jy=on(ge([Ny],"anyKindTest"));let Un=Le(/[0-9]+/),Xy=(0,s.then)((0,s.or)([(0,s.then)(lr,Un,(e,t)=>e+t),(0,s.then)(Un,(0,s.optional)((0,s.preceded)(lr,Le(/[0-9]*/))),(e,t)=>e+(t!==null?"."+t:""))]),Xe((0,s.or)([Id,Cd]),(0,s.optional)((0,s.or)([Jo,cr])),Un,(e,t,n)=>e+(t||"")+n),(e,t)=>["doubleConstantExpr",["value",e+t]]),Ly=(0,s.or)([(0,s.map)((0,s.preceded)(lr,Un),e=>["decimalConstantExpr",["value","."+e]]),(0,s.then)((0,s.followed)(Un,lr),(0,s.optional)(Un),(e,t)=>["decimalConstantExpr",["value",e+"."+(t!==null?t:"")]])]);var Fs=(0,s.map)(Un,e=>["integerConstantExpr",["value",e]]),Yy=(0,s.followed)((0,s.or)([Xy,Ly,Fs]),(0,s.peek)((0,s.not)(Le(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),qy=(0,s.map)((0,s.followed)(lr,(0,s.peek)((0,s.not)(lr,["context item should not be followed by another ."]))),()=>["contextItemExpr"]),Jc=(0,s.or)([Vo,Wr,Nc,Yg,Gn,bg,pr,xc,Mc,bo,qg,_r,Tc,Qg,wc,Uc,Ec,Dc]),Qy=on(ge([Zr],"argumentPlaceholder")),Jy=(0,s.or)([Zr,Ht,Jo]),Ky=(0,s.preceded)((0,s.peek)((0,s.not)(Le(/[{}<&]/),["elementContentChar cannot be {, }, <, or &"])),$t),by=(0,s.map)((0,s.delimited)(od,(0,s.star)((0,s.preceded)((0,s.peek)((0,s.not)(pc,['CDataSection content may not contain "]]>"'])),$t)),pc,!0),e=>["CDataSection",e.join("")]),Vy=(0,s.preceded)((0,s.peek)((0,s.not)(Le(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),$t),Zy=(0,s.preceded)((0,s.peek)((0,s.not)(Le(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),$t),_y=(0,s.map)((0,s.star)((0,s.or)([(0,s.preceded)((0,s.peek)((0,s.not)(cr,[])),$t),(0,s.map)(G([cr,(0,s.peek)((0,s.not)(cr,[]))],$t),e=>"-"+e)])),e=>e.join("")),Wy=(0,s.map)((0,s.delimited)(id,_y,ud,!0),e=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",e]]]]);let zy=(0,s.filter)(tt,e=>e.toLowerCase()!=="xml",['A processing instruction target cannot be "xml"']),ew=(0,s.map)((0,s.star)((0,s.preceded)((0,s.peek)((0,s.not)(hc,[])),$t)),e=>e.join(""));var tw=(0,s.then)((0,s.preceded)(ld,(0,s.cut)(zy)),(0,s.cut)((0,s.followed)((0,s.optional)((0,s.preceded)(Zo,ew)),hc)),(e,t)=>["computedPIConstructor",["piTarget",e],["piValueExpr",["stringConstantExpr",["value",t]]]]),Gs=(0,s.map)(Nd,()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]]),nw=(0,s.or)([ug,lg]),rw=(0,s.map)((0,s.star)((0,s.followed)($t,(0,s.peek)((0,s.not)(uc,["Pragma contents should not contain '#)'"])))),e=>e.join("")),ow=(0,s.map)((0,s.followed)((0,s.or)([Jd,Kd,Ac,bd,vc,Vd]),Qe),e=>e+"Op"),aw=(0,s.or)([(0,s.followed)(ge([jd],"isOp"),Qe),ge([Ad],"nodeBeforeOp"),ge([xd],"nodeAfterOp")]),sw=(0,s.or)([ge([un],"equalOp"),ge([wd],"notEqualOp"),ge([vd],"lessThanOrEqualOp"),ge([dc],"lessThanOp"),ge([Bd],"greaterThanOrEqualOp"),ge([fs],"greaterThanOp")]),iw=(0,s.map)(Ug,()=>["annotation",["annotationName","updating"]]);let uw=(0,s.or)([As,fg]),lw=(0,s.or)([mg,dg]);var cw=(0,s.or)([iy,uy,ly,cy,py,mc,hy,fy,my,dy,gy]),pw=(0,s.map)(G([pt,D,hg,D],(0,s.or)([As,Ic])),e=>["boundarySpaceDecl",e]),hw=(0,s.map)(G([pt,D,Mg,D],(0,s.or)([As,Ic])),e=>["constructionDecl",e]),fw=(0,s.map)(G([pt,D,kg,D],(0,s.or)([Hg,Pg])),e=>["orderingModeDecl",e]),mw=(0,s.map)(G([pt,D,Dn,D,ws,D,ms,D],(0,s.or)([Cc,Fc])),e=>["emptyOrderDecl",e]),dw=(0,s.then)(G([pt,D,gg,D],uw),G([N,qe,N],lw),(e,t)=>["copyNamespacesDecl",["preserveMode",e],["inheritMode",t]]);function Os(e){switch(e[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 e}return["sequenceExpr",e]}function Kc(e){if(!(1<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e))throw Error("XQST0090: The character reference "+e+" ("+e.toString(16)+") does not reference a valid codePoint.")}function Wo(e){return e.replace(/(&[^;]+);/g,t=>{if(/^&#x/.test(t))return t=parseInt(t.slice(3,-1),16),Kc(t),String.fromCodePoint(t);if(/^&#/.test(t))return t=parseInt(t.slice(2,-1),10),Kc(t),String.fromCodePoint(t);switch(t){case"<":return"<";case">":return">";case"&":return"&";case""":return'"';case"'":return"'"}throw Error('XPST0003: Unknown character reference: "'+t+'"')})}function bc(e,t,n){if(!e.length)return[];let r=[e[0]];for(let o=1;o<e.length;++o){let a=r[r.length-1];typeof a=="string"&&typeof e[o]=="string"?r[r.length-1]=a+e[o]:r.push(e[o])}if(typeof r[0]=="string"&&r.length===0)return[];if(r=r.reduce((o,a,i)=>{if(typeof a!="string")o.push(a);else if(n&&/^\s*$/.test(a)){let u=r[i+1];(u&&u[0]==="CDataSection"||(i=r[i-1])&&i[0]==="CDataSection")&&o.push(Wo(a))}else o.push(Wo(a));return o},[]),!r.length)return r;if(1<r.length||t)for(e=0;e<r.length;e++)typeof r[e]=="string"&&(r[e]=["stringConstantExpr",["value",r[e]]]);return r}function Vc(e){return e[0].prefix?e[0].prefix+":"+e[1]:e[1]}var Zc=(0,s.then)(Te,(0,s.optional)(Zr),(e,t)=>t!==null?["singleType",["atomicType",...e],["optional"]]:["singleType",["atomicType",...e]]),_c=(0,s.map)(Te,e=>["atomicType",...e]);let Wc=new Map;function ln(e){function t(c,w){return w.reduce((O,ue)=>[ue[0],["firstOperand",O],["secondOperand",ue[1]]],c)}function n(c,w,O){return(0,s.then)(c,(0,s.star)((0,s.then)(Z(w,N),(0,s.cut)(c),(ue,ve)=>[ue,ve])),O)}function r(c,w,O="firstOperand",ue="secondOperand"){return(0,s.then)(c,(0,s.optional)((0,s.then)(Z(w,N),(0,s.cut)(c),(ve,ot)=>[ve,ot])),(ve,ot)=>ot===null?ve:[ot[0],[O,ve],[ue,ot[1]]])}function o(c){return e.Ka?(w,O)=>{if(w=c(w,O),!w.success)return w;let ue=p.has(O)?p.get(O):{offset:O,line:-1,ga:-1},ve=p.has(w.offset)?p.get(w.offset):{offset:w.offset,line:-1,ga:-1};return p.set(O,ue),p.set(w.offset,ve),O=w.value.Xa,(0,s.okWithValue)(w.offset,["x:stackTrace",Object.assign({start:ue,end:ve},O?{Xa:O}:{}),w.value])}:c}function a(c,w){return Up(c,w)}function i(c,w){return Ws(c,w)}function u(c,w){return o((0,s.or)([xv,Cv,kv,Nv,nv,Rv,Fv,Sv,Gv,Dv,WA]))(c,w)}function l(c,w){return n(u,qe,(O,ue)=>ue.length===0?O:["sequenceExpr",O,...ue.map(ve=>ve[1])])(c,w)}let p=new Map,A=(0,s.preceded)(lc,(0,s.followed)(Z(l,N),cc)),x=(0,s.map)(e.xa?(0,s.or)([Z((0,s.star)((0,s.or)([Ns,Ts,Is,Le(/[^"&]/)])),Qo),Z((0,s.star)((0,s.or)([Ns,Ts,Cs,Le(/[^'&]/)])),qo)]):(0,s.or)([Z((0,s.star)((0,s.or)([Is,Le(/[^"]/)])),Qo),Z((0,s.star)((0,s.or)([Cs,Le(/[^']/)])),qo)]),c=>c.join("")),C=(0,s.or)([(0,s.map)(G([Gn,N],(0,s.delimited)((0,s.followed)(Re,N),(0,s.then)(Qc,G([N,qe,N],Te),(c,w)=>[["elementName",c],["typeName",...w]]),(0,s.preceded)(N,Oe))),([c,w])=>["elementTest",c,w]),(0,s.map)(G([Gn,N],(0,s.delimited)(Re,Qc,Oe)),c=>["elementTest",["elementName",c]]),(0,s.map)(G([Gn,N],(0,s.delimited)(Re,N,Oe)),()=>["elementTest"])]),T=(0,s.or)([(0,s.map)(Te,c=>["QName",...c]),(0,s.map)(Ht,()=>["star"])]),P=(0,s.or)([(0,s.map)(G([Wr,N],(0,s.delimited)((0,s.followed)(Re,N),(0,s.then)(T,G([N,qe,N],Te),(c,w)=>[["attributeName",c],["typeName",...w]]),(0,s.preceded)(N,Oe))),([c,w])=>["attributeTest",c,w]),(0,s.map)(G([Wr,N],(0,s.delimited)(Re,T,Oe)),c=>["attributeTest",["attributeName",c]]),(0,s.map)(G([Wr,N],(0,s.delimited)(Re,N,Oe)),()=>["attributeTest"])]),_=(0,s.map)(G([wc,N,Re],(0,s.followed)(Te,Oe)),c=>["schemaElementTest",...c]),oe=(0,s.map)((0,s.delimited)(yy,Z(Te,N),Oe),c=>["schemaAttributeTest",...c]),Ae=(0,s.map)((0,s.preceded)(wy,(0,s.followed)(Z((0,s.optional)((0,s.or)([C,_])),N),Oe)),c=>["documentTest",...c?[c]:[]]),rt=(0,s.or)([(0,s.map)((0,s.preceded)(Ay,(0,s.followed)(Z((0,s.or)([tt,x]),N),Oe)),c=>["piTest",["piTarget",c]]),on(ge([vy],"piTest"))]),pn=(0,s.or)([Ae,C,P,_,oe,rt,Hy,Py,$y,jy]),Sn=(0,s.or)([(0,s.map)((0,s.preceded)(fd,tt),c=>["Wildcard",["star"],["NCName",c]]),on(ge([Ht],"Wildcard")),(0,s.map)((0,s.followed)(qc,Ht),c=>["Wildcard",["uri",c],["star"]]),(0,s.map)((0,s.followed)(tt,hd),c=>["Wildcard",["NCName",c],["star"]])]),to=(0,s.or)([Sn,(0,s.map)(Te,c=>["nameTest",...c])]),jt=(0,s.or)([pn,to]),O1=(0,s.map)((0,s.delimited)((0,s.followed)(Re,N),(0,s.then)(jt,(0,s.star)((0,s.preceded)(Z(hs,N),jt)),(c,w)=>[c].concat(w)),(0,s.followed)(N,Oe),!0),c=>["unionNodeTest",...c]),Ks=e.version===4?(0,s.or)([O1,jt]):jt,D1=e.version===4?(0,s.or)([(0,s.map)((0,s.preceded)(fc,Ks),c=>["stepExpr",["xpathAxis","attribute"],c]),(0,s.map)(jt,c=>["stepExpr",["xpathAxis","child"],c])]):(0,s.then)((0,s.optional)(fc),jt,(c,w)=>c!==null||w[0]==="attributeTest"||w[0]==="schemaAttributeTest"?["stepExpr",["xpathAxis","attribute"],w]:["stepExpr",["xpathAxis","child"],w]),U1=(0,s.or)([(0,s.then)(My,Ks,(c,w)=>["stepExpr",["xpathAxis",c],w]),D1]),R1=(0,s.map)(Ed,()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]]),S1=(0,s.or)([(0,s.then)(ky,Ks,(c,w)=>["stepExpr",["xpathAxis",c],w]),R1]),M1=(0,s.map)((0,s.star)((0,s.preceded)(N,A)),c=>0<c.length?["predicates",...c]:void 0),k1=(0,s.then)((0,s.or)([S1,U1]),M1,(c,w)=>w===void 0?c:c.concat([w])),bs=(0,s.or)([Yy,(0,s.map)(x,c=>["stringConstantExpr",["value",e.xa?Wo(c):c]])]),Vs=(0,s.or)([(0,s.delimited)(Re,Z(l,N),Oe),(0,s.map)((0,s.delimited)(Re,N,Oe),()=>["sequenceExpr"])]),Op=(0,s.or)([u,Qy]),na=(0,s.map)((0,s.delimited)(Re,Z((0,s.optional)((0,s.then)(Op,(0,s.star)((0,s.preceded)(Z(qe,N),Op)),(c,w)=>[c,...w])),N),Oe),c=>c!==null?c:[]),H1=(0,s.preceded)((0,s.not)(Xe(Jc,N,Re,()=>{}),["cannot use reserved keyword for function names"]),o((0,s.then)(Te,(0,s.preceded)(N,na),(c,w)=>{w=["functionCallExpr",["functionName",...c],w!==null?["arguments",...w]:["arguments"]];let O=c[0].prefix,ue=c[0].URI;return c=c[1],w.Xa=O?`${O}:${c}`:ue?`Q{${ue}}${c}`:c,w}))),P1=(0,s.then)(Te,(0,s.preceded)(dd,Fs),(c,w)=>["namedFunctionRef",["functionName",...c],w]),It=(0,s.delimited)(an,Z((0,s.optional)(l),N),sn),Dp=(0,s.map)(It,c=>c||["sequenceExpr"]),Xt=(0,s.or)([(0,s.map)(Iy,()=>[["voidSequenceType"]]),(0,s.then)(a,(0,s.optional)((0,s.preceded)(N,Jy)),(c,w)=>[c,...w!==null?[["occurrenceIndicator",w]]:[]])]),Zs=(0,s.then)(G([mc,N],Te),(0,s.optional)((0,s.followed)((0,s.then)(G([Re,N],bs),(0,s.star)(G([qe,N],bs)),(c,w)=>c.concat(w)),Oe)),(c,w)=>["annotation",["annotationName",...c],...w?["arguments",w]:[]]),$1=(0,s.map)(G([pr,N,Re,N,Ht,N],Oe),()=>["anyFunctionTest"]),j1=(0,s.then)(G([pr,N,Re,N],(0,s.optional)(n(Xt,qe,(c,w)=>c.concat.apply(c,w.map(O=>O[1]))))),G([N,Oe,D,Tt,D],Xt),(c,w)=>["typedFunctionTest",["paramTypeList",["sequenceType",...c||[]]],["sequenceType",...w]]),X1=(0,s.then)((0,s.star)(Zs),(0,s.or)([$1,j1]),(c,w)=>[w[0],...c,...w.slice(1)]),L1=(0,s.map)(G([bo,N,Re,N,Ht,N],Oe),()=>["anyMapTest"]),Y1=(0,s.then)(G([bo,N,Re,N],_c),G([N,qe],(0,s.followed)(Z(Xt,N),Oe)),(c,w)=>["typedMapTest",c,["sequenceType",...w]]),q1=(0,s.or)([L1,Y1]),Q1=(0,s.map)(G([Vo,N,Re,N,Ht,N],Oe),()=>["anyArrayTest"]),J1=(0,s.map)(G([Vo,N,Re],(0,s.followed)(Z(Xt,N),Oe)),c=>["typedArrayTest",["sequenceType",...c]]),K1=(0,s.or)([Q1,J1]),b1=(0,s.map)((0,s.delimited)(Re,Z(a,N),Oe),c=>["parenthesizedItemType",c]),Up=(0,s.or)([pn,on(ge([Ty],"anyItemType")),X1,q1,K1,_c,b1]),vr=(0,s.map)(G([Tt,D],Xt),c=>["typeDeclaration",...c]),V1=(0,s.then)((0,s.preceded)(Pt,Te),(0,s.optional)((0,s.preceded)(D,vr)),(c,w)=>["param",["varName",...c],...w?[w]:[]]),Rp=n(V1,qe,(c,w)=>[c,...w.map(O=>O[1])]),Z1=ps((0,s.star)(Zs),G([N,pr,N,Re,N],(0,s.optional)(Rp)),G([N,Oe,N],(0,s.optional)((0,s.map)(G([Tt,N],(0,s.followed)(Xt,N)),c=>["typeDeclaration",...c]))),Dp,(c,w,O,ue)=>["inlineFunctionExpr",...c,["paramList",...w||[]],...O?[O]:[],["functionBody",ue]]),_1=(0,s.or)([P1,Z1]),W1=(0,s.map)(u,c=>["mapKeyExpr",c]),z1=(0,s.map)(u,c=>["mapValueExpr",c]),eA=(0,s.then)(W1,(0,s.preceded)(Z(Vr,N),z1),(c,w)=>["mapConstructorEntry",c,w]),tA=(0,s.preceded)(bo,(0,s.delimited)(Z(an,N),(0,s.map)((0,s.optional)(n(eA,Z(qe,N),(c,w)=>[c,...w.map(O=>O[1])])),c=>c?["mapConstructor",...c]:["mapConstructor"]),(0,s.preceded)(N,sn))),nA=(0,s.map)((0,s.delimited)(lc,Z((0,s.optional)(n(u,qe,(c,w)=>[c,...w.map(O=>O[1])].map(O=>["arrayElem",O]))),N),cc),c=>["squareArray",...c!==null?c:[]]),rA=(0,s.map)((0,s.preceded)(Vo,(0,s.preceded)(N,It)),c=>["curlyArray",...c!==null?[["arrayElem",c]]:[]]),oA=(0,s.map)((0,s.or)([nA,rA]),c=>["arrayConstructor",c]),Sp=(0,s.map)((0,s.star)((0,s.preceded)((0,s.peek)((0,s.not)((0,s.or)([Pc,$c,Hc]),["String constructors can not contain interpolation characters"])),$t)),c=>["stringConstructorChars",c.join("")]),aA=(0,s.map)((0,s.delimited)(Pc,l,$c,!0),c=>["stringConstructorInterpolation",c]),sA=(0,s.then)(Sp,(0,s.star)((0,s.then)(aA,Sp,(c,w)=>[c,w])),(c,w)=>{c=[c];for(let[O,ue]of w)c.push(O,ue);return c}),iA=(0,s.map)((0,s.delimited)(Cy,sA,Hc,!0),c=>["stringConstructor",...c]),Mp=(0,s.or)([tt,Fs,Vs,Ht]),uA=(0,s.map)((0,s.preceded)(Zr,(0,s.preceded)(N,Mp)),c=>c==="*"?["unaryLookup",["star"]]:typeof c=="string"?["unaryLookup",["NCName",c]]:["unaryLookup",c]),_s=(0,s.or)([Ns,Ts,ge([ed],"{"),ge([td],"}"),(0,s.map)(It,c=>c||["sequenceExpr"])]),lA=(0,s.or)([by,function(c,w){return kp(c,w)},_s,Ky]),cA=(0,s.or)([(0,s.map)(Vy,c=>c.replace(/[\x20\x0D\x0A\x09]/g," ")),_s]),pA=(0,s.or)([(0,s.map)(Zy,c=>c.replace(/[\x20\x0D\x0A\x09]/g," ")),_s]),hA=(0,s.map)((0,s.or)([Z((0,s.star)((0,s.or)([Is,cA])),Qo),Z((0,s.star)((0,s.or)([Cs,pA])),qo)]),c=>bc(c,!1,!1)),fA=(0,s.then)(_o,(0,s.preceded)(Z(un,(0,s.optional)(Zo)),hA),(c,w)=>{if(c[0].prefix===""&&c[1]==="xmlns"){if(w.length&&typeof w[0]!="string")throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",w.length?["uri",w[0]]:["uri"]]}if(c[0].prefix==="xmlns"){if(w.length&&typeof w[0]!="string")throw Error("XQST0022: The namespace declaration for 'xmlns:"+c[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",c[1]],w.length?["uri",w[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(c),w.length===0?["attributeValue"]:w.length===1&&typeof w[0]=="string"?["attributeValue",w[0]]:["attributeValueExpr"].concat(w)]}),mA=(0,s.map)((0,s.star)((0,s.preceded)(Zo,(0,s.optional)(fA))),c=>c.filter(Boolean)),dA=Xe((0,s.preceded)(dc,_o),mA,(0,s.or)([(0,s.map)(ad,()=>null),(0,s.then)((0,s.preceded)(fs,(0,s.star)(lA)),G([N,sd],(0,s.followed)(_o,(0,s.then)((0,s.optional)(Zo),fs,()=>null))),(c,w)=>[bc(c,!0,!0),w])]),(c,w,O)=>{var ue=O;if(O&&O.length){ue=Vc(c);let ve=Vc(O[1]);if(ue!==ve)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+ue+'" does not match "'+ve+'"');ue=O[0]}return["elementConstructor",["tagName",...c],...w.length?[["attributeList",...w]]:[],...ue&&ue.length?[["elementContent",...ue]]:[]]}),kp=(0,s.or)([dA,Wy,tw]),gA=(0,s.map)(G([ig,N],It),c=>["computedDocumentConstructor",...c?[["argExpr",c]]:[]]),yA=(0,s.map)(It,c=>c?[["contentExpr",c]]:[]),wA=(0,s.then)(G([Gn,N],(0,s.or)([(0,s.map)(Te,c=>["tagName",...c]),(0,s.map)((0,s.delimited)(an,Z(l,N),sn),c=>["tagNameExpr",c])])),(0,s.preceded)(N,yA),(c,w)=>["computedElementConstructor",c,...w]),AA=(0,s.then)((0,s.preceded)(Wr,(0,s.or)([(0,s.map)(G([Qe,N],Te),c=>["tagName",...c]),(0,s.map)((0,s.preceded)(N,(0,s.delimited)(an,Z(l,N),sn)),c=>["tagNameExpr",c])])),(0,s.preceded)(N,It),(c,w)=>["computedAttributeConstructor",c,["valueExpr",w||["sequenceExpr"]]]),vA=(0,s.map)(It,c=>c?[["prefixExpr",c]]:[]),xA=(0,s.map)(It,c=>c?[["URIExpr",c]]:[]),BA=(0,s.then)(G([On,N],(0,s.or)([Gy,vA])),(0,s.preceded)(N,xA),(c,w)=>["computedNamespaceConstructor",...c,...w]),EA=(0,s.map)(G([Ec,N],It),c=>["computedTextConstructor",...c?[["argExpr",c]]:[]]),NA=(0,s.map)(G([Nc,N],It),c=>["computedCommentConstructor",...c?[["argExpr",c]]:[]]),TA=G([Tc,N],(0,s.then)((0,s.or)([(0,s.map)(tt,c=>["piTarget",c]),(0,s.map)((0,s.delimited)(an,Z(l,N),sn),c=>["piTargetExpr",c])]),(0,s.preceded)(N,It),(c,w)=>["computedPIConstructor",c,...w?[["piValueExpr",w]]:[]])),IA=(0,s.or)([gA,wA,AA,BA,EA,NA,TA]),CA=(0,s.or)([kp,IA]),Hp=(0,s.or)([bs,Es,Vs,qy,H1,CA,_1,tA,oA,iA,uA]),Pp=(0,s.map)(G([Zr,N],Mp),c=>c==="*"?["lookup",["star"]]:typeof c=="string"?["lookup",["NCName",c]]:["lookup",c]),FA=(0,s.then)((0,s.map)(Hp,c=>Os(c)),(0,s.star)((0,s.or)([(0,s.map)((0,s.preceded)(N,A),c=>["predicate",c]),(0,s.map)((0,s.preceded)(N,na),c=>["argumentList",c]),(0,s.preceded)(N,Pp)])),(c,w)=>{function O(){Yp&&ot.length===1?Br.push(["predicate",ot[0]]):ot.length!==0&&Br.push(["predicates",...ot]),ot.length=0}function ue(Mn){O(),Br.length!==0?(ve[0][0]==="sequenceExpr"&&2<ve[0].length&&(ve=[["sequenceExpr",...ve]]),ve=[["filterExpr",...ve],...Br],Br.length=0):Mn&&(ve=[["filterExpr",...ve]])}let ve=[c],ot=[],Br=[],Yp=!1;for(let Mn of w)switch(Mn[0]){case"predicate":ot.push(Mn[1]);break;case"lookup":Yp=!0,O(),Br.push(Mn);break;case"argumentList":ue(!1),1<ve.length&&(ve=[["sequenceExpr",["pathExpr",["stepExpr",...ve]]]]),ve=[["dynamicFunctionInvocationExpr",["functionItem",...ve],...Mn[1].length?[["arguments",...Mn[1]]]:[]]];break;default:throw Error("unreachable")}return ue(!0),ve}),xr=(0,s.or)([(0,s.map)(FA,c=>["stepExpr",...c]),k1]),GA=(0,s.followed)(Hp,(0,s.peek)((0,s.not)((0,s.preceded)(N,(0,s.or)([A,na,Pp])),["primary expression not followed by predicate, argumentList, or lookup"]))),OA=(0,s.or)([Xe(xr,(0,s.preceded)(N,Gs),(0,s.preceded)(N,i),(c,w,O)=>["pathExpr",c,w,...O]),(0,s.then)(xr,(0,s.preceded)(Z(Ko,N),i),(c,w)=>["pathExpr",c,...w]),GA,(0,s.map)(xr,c=>["pathExpr",c])]),Ws=(0,s.or)([Xe(xr,(0,s.preceded)(N,Gs),(0,s.preceded)(N,i),(c,w,O)=>[c,w,...O]),(0,s.then)(xr,(0,s.preceded)(Z(Ko,N),i),(c,w)=>[c,...w]),(0,s.map)(xr,c=>[c])]),DA=(0,s.or)([(0,s.map)(G([Ko,N],Ws),c=>["pathExpr",["rootExpr"],...c]),(0,s.then)(Gs,(0,s.preceded)(N,Ws),(c,w)=>["pathExpr",["rootExpr"],c,...w]),(0,s.map)((0,s.followed)(Ko,(0,s.not)((0,s.preceded)(N,e.xa?Le(/[*<a-zA-Z]/):Le(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),()=>["pathExpr",["rootExpr"]])]),UA=cs((0,s.or)([OA,DA]),Wc),RA=(0,s.preceded)(cg,(0,s.then)((0,s.optional)((0,s.or)([(0,s.map)((0,s.preceded)(N,nw),c=>["validationMode",c]),(0,s.map)(G([N,pg,N],Te),c=>["type",...c])])),(0,s.delimited)((0,s.preceded)(N,an),Z(l,N),sn),(c,w)=>["validateExpr",...c?[c]:[],["argExpr",w]])),SA=(0,s.delimited)(zm,(0,s.then)((0,s.preceded)(N,Te),(0,s.optional)((0,s.preceded)(D,rw)),(c,w)=>w?["pragma",["pragmaName",c],["pragmaContents",w]]:["pragma",["pragmaName",c]]),(0,s.preceded)(N,uc)),MA=(0,s.map)((0,s.followed)((0,s.plus)(SA),(0,s.preceded)(N,(0,s.delimited)(an,Z((0,s.optional)(l),N),sn))),c=>["extensionExpr",...c]),kA=o(n(UA,gd,(c,w)=>w.length===0?c:["simpleMapExpr",c[0]==="pathExpr"?c:["pathExpr",["stepExpr",["filterExpr",Os(c)]]]].concat(w.map(O=>(O=O[1],O[0]==="pathExpr"?O:["pathExpr",["stepExpr",["filterExpr",Os(O)]]]))))),HA=(0,s.or)([RA,MA,kA]),$p=(0,s.or)([(0,s.then)((0,s.or)([ge([cr],"unaryMinusOp"),ge([Jo],"unaryPlusOp")]),(0,s.preceded)(N,function(c,w){return $p(c,w)}),(c,w)=>[c,["operand",w]]),HA]),PA=(0,s.or)([(0,s.map)(Te,c=>["EQName",...c]),Es,Vs]),$A=(0,s.then)($p,(0,s.star)(G([N,Td,N],(0,s.then)(PA,(0,s.preceded)(N,na),(c,w)=>[c,w]))),(c,w)=>w.reduce((O,ue)=>["arrowExpr",["argExpr",O],ue[0],["arguments",...ue[1]]],c)),jA=(0,s.then)($A,(0,s.optional)(G([N,Gd,D,Tt,Qe,N],Zc)),(c,w)=>w!==null?["castExpr",["argExpr",c],w]:c),XA=(0,s.then)(jA,(0,s.optional)(G([N,Od,D,Tt,Qe,N],Zc)),(c,w)=>w!==null?["castableExpr",["argExpr",c],w]:c),LA=(0,s.then)(XA,(0,s.optional)(G([N,Dd,D,Tt,Qe,N],Xt)),(c,w)=>w!==null?["treatExpr",["argExpr",c],["sequenceType",...w]]:c),YA=(0,s.then)(LA,(0,s.optional)(G([N,Ud,D,gc,Qe,N],Xt)),(c,w)=>w!==null?["instanceOfExpr",["argExpr",c],["sequenceType",...w]]:c),qA=n(YA,(0,s.followed)((0,s.or)([ge([Md],"intersectOp"),ge([kd],"exceptOp")]),Qe),t),jp=n(qA,(0,s.or)([ge([hs],"unionOp"),(0,s.followed)(ge([Hd],"unionOp"),Qe)]),t),QA=n(jp,(0,s.followed)(ge([Pd],"otherwiseOp"),(0,s.cut)(Qe)),t),JA=n(4<=e.version?QA:jp,(0,s.or)([ge([Ht],"multiplyOp"),(0,s.followed)(ge([Yd],"divOp"),Qe),(0,s.followed)(ge([qd],"idivOp"),Qe),(0,s.followed)(ge([Qd],"modOp"),Qe)]),t),KA=n(JA,(0,s.or)([ge([cr],"subtractOp"),ge([Jo],"addOp")]),t),bA=r(KA,(0,s.followed)(ge([$d],"rangeSequenceExpr"),Qe),"startExpr","endExpr"),VA=n(bA,ge([yd],"stringConcatenateOp"),t),ZA=r(VA,(0,s.or)([ow,aw,sw])),_A=n(ZA,(0,s.followed)(ge([Ld],"andOp"),Qe),t),WA=n(_A,(0,s.followed)(ge([Xd],"orOp"),Qe),t),zA=o((0,s.map)(l,c=>["ifClause",c])),ev=o((0,s.map)(u,c=>["thenClause",c])),tv=o((0,s.map)(u,c=>["elseClause",c])),nv=(0,s.then)((0,s.then)(G([xc,N,Re,N],zA),G([N,Oe,N,zd,Qe,N],ev),(c,w)=>[c,w]),G([N,eg,Qe,N],tv),(c,w)=>["ifThenElseExpr",c[0],c[1],w]),rv=(0,s.delimited)(tg,D,ms),ov=(0,s.map)(G([ds,D,Pt],Te),c=>["positionalVariableBinding",...c]),av=Wm((0,s.preceded)(Pt,(0,s.cut)(Te)),(0,s.cut)((0,s.preceded)(N,(0,s.optional)(vr))),(0,s.cut)((0,s.preceded)(N,(0,s.optional)(rv))),(0,s.cut)((0,s.preceded)(N,(0,s.optional)(ov))),(0,s.cut)((0,s.preceded)(Z(Bc,N),u)),(c,w,O,ue,ve)=>["forClauseItem",["typedVariableBinding",["varName",...c,...w?[w]:[]]],...O?[["allowingEmpty"]]:[],...ue?[ue]:[],["forExpr",ve]]),sv=G([ng,D],n(av,qe,(c,w)=>["forClause",c,...w.map(O=>O[1])])),iv=Xe((0,s.preceded)(Pt,Te),(0,s.preceded)(N,(0,s.optional)(vr)),(0,s.preceded)(Z(Cn,N),u),(c,w,O)=>["letClauseItem",["typedVariableBinding",["varName",...c],...w?[w]:[]],["letExpr",O]]),uv=(0,s.map)(G([rg,N],n(iv,qe,(c,w)=>[c,...w.map(O=>O[1])])),c=>["letClause",...c]),Xp=(0,s.or)([sv,uv]),lv=(0,s.map)(G([og,Qe,N],u),c=>["whereClause",c]),cv=(0,s.map)((0,s.preceded)(Pt,Te),c=>["varName",...c]),pv=(0,s.then)((0,s.preceded)(N,(0,s.optional)(vr)),(0,s.preceded)(Z(Cn,N),u),(c,w)=>["groupVarInitialize",...c?[["typeDeclaration",...c]]:[],["varValue",w]]),hv=Xe(cv,(0,s.optional)(pv),(0,s.optional)((0,s.map)((0,s.preceded)(Z(gs,N),x),c=>["collation",c])),(c,w,O)=>["groupingSpec",c,...w?[w]:[],...O?[O]:[]]),fv=n(hv,qe,(c,w)=>[c,...w.map(O=>O[1])]),mv=(0,s.map)(G([ag,D,ys,N],fv),c=>["groupByClause",...c]),dv=Xe((0,s.optional)((0,s.or)([Jg,Kg])),(0,s.optional)(G([N,ms,N],(0,s.or)([Cc,Fc].map(c=>(0,s.map)(c,w=>"empty "+w))))),(0,s.preceded)(N,(0,s.optional)(G([gs,N],x))),(c,w,O)=>c||w||O?["orderModifier",...c?[["orderingKind",c]]:[],...w?[["emptyOrderingMode",w]]:[],...O?[["collation",O]]:[]]:null),gv=(0,s.then)(u,(0,s.preceded)(N,dv),(c,w)=>["orderBySpec",["orderByExpr",c],...w?[w]:[]]),yv=n(gv,qe,(c,w)=>[c,...w.map(O=>O[1])]),wv=(0,s.then)((0,s.or)([(0,s.map)(G([ws,D],ys),()=>!1),(0,s.map)(G([sg,D,ws,D],ys),()=>!0)]),(0,s.preceded)(N,yv),(c,w)=>["orderByClause",...c?[["stable"]]:[],...w]),Av=(0,s.or)([Xp,lv,mv,wv]),vv=(0,s.map)(G([hr,N],u),c=>["returnClause",c]),xv=Xe(Xp,(0,s.cut)((0,s.star)((0,s.preceded)(N,Av))),(0,s.cut)((0,s.preceded)(N,vv)),(c,w,O)=>["flworExpr",c,...w,O]),Bv=n(Xt,hs,(c,w)=>w.length===0?["sequenceType",...c]:["sequenceTypeUnion",["sequenceType",...c],...w.map(O=>["sequenceType",...O[1]])]),Ev=Xe(G([Oc,N],(0,s.optional)((0,s.preceded)(Pt,(0,s.followed)((0,s.followed)(Te,D),Tt)))),(0,s.preceded)(N,Bv),G([D,hr,D],u),(c,w,O)=>["typeswitchExprCaseClause"].concat(c?[["variableBinding",...c]]:[],[w],[["resultExpr",O]])),Nv=ps((0,s.preceded)(Dc,Z((0,s.delimited)(Re,Z(l,N),Oe),N)),(0,s.plus)((0,s.followed)(Ev,N)),G([Dn,D],(0,s.optional)((0,s.preceded)(Pt,(0,s.followed)(Te,D)))),G([hr,D],u),(c,w,O,ue)=>["typeswitchExpr",["argExpr",c],...w,["typeswitchExprDefaultClause",...O||[],["resultExpr",ue]]]),Tv=Xe((0,s.preceded)(Pt,Te),(0,s.optional)((0,s.preceded)(D,vr)),(0,s.preceded)(Z(Bc,D),u),(c,w,O)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...c],...w?[w]:[]],["sourceExpr",O]]),Iv=n(Tv,qe,(c,w)=>[c,...w.map(O=>O[1])]),Cv=Xe((0,s.or)([yg,wg]),(0,s.preceded)(D,Iv),(0,s.preceded)(Z(Ag,N),u),(c,w,O)=>["quantifiedExpr",["quantifier",c],...w,["predicateExpr",O]]),Fv=(0,s.map)(G([Rd,D,(0,s.or)([yc,_r]),D],u),c=>["deleteExpr",["targetExpr",c]]),Gv=Xe(G([vg,D],(0,s.optional)(G([Sd,D,gc],D))),G([_r,D],u),(0,s.preceded)(Z(xg,D),u),(c,w,O)=>c?["replaceExpr",["replaceValue"],["targetExpr",w],["replacementExpr",O]]:["replaceExpr",["targetExpr",w],["replacementExpr",O]]),Ov=(0,s.then)(Es,(0,s.preceded)(Z(Cn,N),u),(c,w)=>["transformCopy",c,["copySource",w]]),Dv=Xe(G([Bg,D],n(Ov,qe,(c,w)=>[c,...w.map(O=>O[1])])),G([N,Eg,D],u),(0,s.preceded)(Z(hr,D),u),(c,w,O)=>["transformExpr",["transformCopies",...c],["modifyExpr",w],["returnExpr",O]]),Uv=(0,s.or)([(0,s.followed)((0,s.map)((0,s.optional)((0,s.followed)(G([Tt,D],(0,s.or)([(0,s.map)(Ng,()=>["insertAsFirst"]),(0,s.map)(Tg,()=>["insertAsLast"])])),D)),c=>c?["insertInto",c]:["insertInto"]),Fg),(0,s.map)(Cg,()=>["insertAfter"]),(0,s.map)(Ig,()=>["insertBefore"])]),Rv=Xe(G([Gg,D,(0,s.or)([yc,_r]),D],u),(0,s.preceded)(D,Uv),(0,s.preceded)(D,u),(c,w,O)=>["insertExpr",["sourceExpr",c],w,["targetExpr",O]]),Sv=(0,s.then)(G([Og,D,_r,N],u),G([D,Tt,D],u),(c,w)=>["renameExpr",["targetExpr",c],["newNameExpr",w]]),Mv=(0,s.then)((0,s.plus)((0,s.then)((0,s.map)(G([Oc,D],(0,s.cut)(u)),c=>["switchCaseExpr",c]),(0,s.cut)(D),c=>c)),(0,s.cut)(G([hr,D],(0,s.cut)(u))),(c,w)=>["switchExprCaseClause",...c,["resultExpr",w]]),kv=Xe(G([Uc,N,Re],(0,s.cut)(l)),(0,s.cut)(G([N,Oe,(0,s.cut)(N)],(0,s.plus)((0,s.followed)(Mv,N)))),(0,s.cut)(G([Dn,D,hr,D],u)),(c,w,O)=>["switchExpr",["argExpr",c],...w,["switchExprDefaultClause",["resultExpr",O]]]),Hv=(0,s.map)(l,c=>["queryBody",c]),Pv=G([pt,D,On,D],(0,s.cut)((0,s.then)(tt,(0,s.preceded)(Z(un,N),x),(c,w)=>["namespaceDecl",["prefix",c],["uri",w]]))),$v=(0,s.then)(G([Dg,D,Pt,N],(0,s.then)(Te,(0,s.optional)((0,s.preceded)(N,vr)),(c,w)=>[c,w])),(0,s.cut)((0,s.or)([(0,s.map)(G([N,Cn,N],u),c=>["varValue",c]),(0,s.map)(G([D,vs],(0,s.optional)(G([N,Cn,N],u))),c=>["external",...c?[["varValue",c]]:[]])])),([c,w],O)=>["varDecl",["varName",...c],...w!==null?[w]:[],O]),jv=ps(G([pr,D,(0,s.cut)((0,s.peek)((0,s.not)((0,s.followed)(Jc,(0,s.not)(Vr,[""])),["Cannot use reserved function name"])))],Te),(0,s.cut)(G([N,Re,N],(0,s.optional)(Rp))),(0,s.cut)(G([N,Oe],(0,s.optional)(G([D,Tt,D],Xt)))),(0,s.cut)((0,s.preceded)(N,(0,s.or)([(0,s.map)(Dp,c=>["functionBody",c]),(0,s.map)(vs,()=>["externalDefinition"])]))),(c,w,O,ue)=>["functionDecl",["functionName",...c],["paramList",...w||[]],...O?[["typeDeclaration",...O]]:[],ue]),Xv=G([pt,D],(0,s.then)((0,s.star)((0,s.followed)((0,s.or)([Zs,iw]),D)),(0,s.or)([$v,jv]),(c,w)=>[w[0],...c,...w.slice(1)])),Lv=(0,s.then)(G([pt,D,Dn,D],(0,s.or)([Gn,pr])),G([D,On,D],x),(c,w)=>["defaultNamespaceDecl",["defaultNamespaceCategory",c],["uri",w]]),Yv=(0,s.or)([(0,s.map)((0,s.followed)(G([On,D],tt),(0,s.preceded)(N,un)),c=>["namespacePrefix",c]),(0,s.map)(G([Dn,D,Gn,D],On),()=>["defaultElementNamespace"])]),qv=G([Rc,D,Rg],Xe((0,s.optional)((0,s.preceded)(D,Yv)),(0,s.preceded)(N,x),(0,s.optional)((0,s.then)(G([D,ds,D],x),(0,s.star)(G([N,qe,N],x)),(c,w)=>[c,...w])),(c,w,O)=>["schemaImport",...c?[c]:[],["targetNamespace",w],...O?[O]:[]])),Qv=G([Rc,D,Sc],Xe((0,s.optional)((0,s.followed)(G([D,On,D],tt),(0,s.preceded)(N,un))),(0,s.preceded)(N,x),(0,s.optional)((0,s.then)(G([D,ds,D],x),(0,s.star)(G([N,qe,N],x)),(c,w)=>[c,...w])),(c,w)=>["moduleImport",["namespacePrefix",c],["targetNamespace",w]])),Jv=(0,s.or)([qv,Qv]),Kv=(0,s.map)(G([pt,D,Dn,D,gs,D],x),c=>["defaultCollationDecl",c]),bv=(0,s.map)(G([pt,D,Sg,D],x),c=>["baseUriDecl",c]),Vv=(0,s.then)(G([pt,D],(0,s.or)([(0,s.map)(G([Gc,D],Te),c=>["decimalFormatName",...c]),(0,s.map)(G([Dn,D],Gc),()=>null)])),(0,s.star)((0,s.then)((0,s.preceded)(D,cw),(0,s.preceded)(Z(un,D),x),(c,w)=>["decimalFormatParam",["decimalFormatParamName",c],["decimalFormatParamValue",w]])),(c,w)=>["decimalFormatDecl",...c?[c]:[],...w]),Zv=(0,s.or)([pw,Kv,bv,hw,fw,mw,dw,Vv]),_v=(0,s.then)(G([pt,D,$g,D],Te),(0,s.preceded)(D,x),(c,w)=>["optionDecl",["optionName",c],["optionContents",w]]),Wv=(0,s.then)(G([pt,D,jg,D,Mc],(0,s.optional)(G([D,Tt],Up))),(0,s.or)([(0,s.map)((0,s.preceded)(Z(Cn,N),u),c=>["varValue",c]),(0,s.map)(G([D,vs],(0,s.optional)((0,s.preceded)(Z(Cn,N),u))),()=>["external"])]),(c,w)=>["contextItemDecl",...c?[["contextItemType",c]]:[],w]),Lp=(0,s.then)((0,s.star)((0,s.followed)((0,s.or)([Lv,Zv,Pv,Jv]),(0,s.cut)(Z(Fn,N)))),(0,s.star)((0,s.followed)((0,s.or)([Wv,Xv,_v]),(0,s.cut)(Z(Fn,N)))),(c,w)=>c.length===0&&w.length===0?null:["prolog",...c,...w]),zv=G([Sc,D,On,D],(0,s.then)((0,s.followed)(tt,Z(un,N)),(0,s.followed)(x,Z(Fn,N)),(c,w)=>["moduleDecl",["prefix",c],["uri",w]])),ex=(0,s.then)(zv,(0,s.preceded)(N,Lp),(c,w)=>["libraryModule",c,...w?[w]:[]]),tx=(0,s.then)(Lp,(0,s.preceded)(N,Hv),(c,w)=>["mainModule",...c?[c]:[],w]),nx=(0,s.map)(G([Xg,N],(0,s.followed)((0,s.or)([(0,s.then)((0,s.preceded)(kc,D),x,c=>["encoding",c]),(0,s.then)(G([Lg,D],x),(0,s.optional)(G([D,kc,D],x)),(c,w)=>[["version",c],...w?[["encoding",w]]:[]])]),(0,s.preceded)(N,Fn))),c=>["versionDecl",...c]),rx=(0,s.then)((0,s.optional)(Z(nx,N)),(0,s.or)([ex,tx]),(c,w)=>["module",...c?[c]:[],w]),ox=(0,s.complete)(Z(rx,N));return(c,w)=>{p.clear(),w=ox(c,w);let O=1,ue=1;for(let ve=0;ve<c.length+1;ve++){if(p.has(ve)){let ot=p.get(ve);ot.line=ue,ot.ga=O}c[ve]===`
|
|
10
|
+
`?(ue++,O=1):O++}return w}}let gw=ln({Ka:!1,xa:!1,version:3.1}),yw=ln({Ka:!0,xa:!1,version:3.1}),ww=ln({Ka:!1,xa:!0,version:3.1}),Aw=ln({Ka:!0,xa:!0,version:3.1}),vw=ln({Ka:!1,xa:!1,version:4}),xw=ln({Ka:!0,xa:!1,version:4}),Bw=ln({Ka:!1,xa:!0,version:4}),Ew=ln({Ka:!0,xa:!0,version:4});var Nw={Ab:{debug:xw,mb:vw},Ib:{debug:yw,mb:gw}},Tw={Ab:{debug:Ew,mb:Bw},Ib:{debug:Aw,mb:ww}};function zr(e,t){var n=!!t.Y,r=!!t.debug;if(t=t.version,jc.clear(),Xc.clear(),Wc.clear(),n=n?Tw:Nw,n=t===4?n.Ab:n.Ib,r=(r?n.debug:n.mb)(e,0),r.success===!0)return r.value;throw e=e.substring(0,r.offset).split(`
|
|
11
|
+
`),n=e[e.length-1].length+1,new Ho({start:{offset:r.offset,line:e.length,ga:n},end:{offset:r.offset+1,line:e.length,ga:n+1}},"","",Error(`XPST0003: Failed to parse script. Expected ${[...new Set(r.expected)]}`))}let zc="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(" ");function Iw(e,t,n,r,o){var a=B(e,"functionName"),i=J(a,"prefix")||"";let u=J(a,"URI"),l=se(a);if(u===null&&(u=i===""?t.v===null?"http://www.w3.org/2005/xpath-functions":t.v:t.Z(i),!u&&i))throw nl(i);if(zc.includes(u))throw Wu();if(i=q(e,"annotation").map(T=>B(T,"annotationName")),a=i.every(T=>!J(T,"URI")&&se(T)!=="private"),i=i.some(T=>!J(T,"URI")&&se(T)==="updating"),!u)throw Va();let p=Uo(e),A=q(B(e,"paramList"),"param"),x=A.map(T=>B(T,"varName")),C=A.map(T=>Uo(T));if(e=B(e,"functionBody")){if(t.ua(u,l,C.length))throw zu(u,l);if(!o)return;let T=is(e[1],{ra:!1,Y:!0}),P=new En(t),_=x.map(oe=>{let Ae=J(oe,"URI"),rt=J(oe,"prefix");return oe=se(oe),rt&&Ae===null&&(Ae=t.Z(rt||"")),Mt(P,Ae,oe)});o=i?{j:C,arity:x.length,callFunction:(oe,Ae,rt,...pn)=>(oe=tn(Qt(oe,-1,null,f.empty()),_.reduce((Sn,to,jt)=>(Sn[to]=Se(pn[jt]),Sn),Object.create(null))),T.s(oe,Ae)),wb:!1,H:!0,cb:a,localName:l,namespaceURI:u,i:p}:{j:C,arity:x.length,callFunction:(oe,Ae,rt,...pn)=>(oe=tn(Qt(oe,-1,null,f.empty()),_.reduce((Sn,to,jt)=>(Sn[to]=Se(pn[jt]),Sn),Object.create(null))),b(T,oe,Ae)),wb:!1,H:!1,cb:a,localName:l,namespaceURI:u,i:p},n.push({aa:T,Fb:P}),r.push({arity:x.length,aa:T,Bb:o,localName:l,namespaceURI:u,cb:a})}else{if(i)throw Error("Updating external function declarations are not supported");o={j:C,arity:x.length,callFunction:(T,P,_,...oe)=>{let Ae=_.ua(u,l,x.length,!0);if(!Ae)throw Error(`XPST0017: Function Q{${u}}${l} with arity of ${x.length} not registered. ${Ka(l)}`);if(Ae.i.type!==p.type||Ae.j.some((rt,pn)=>rt.type!==C[pn].type))throw Error("External function declaration types do not match actual function");return Ae.callFunction(T,P,_,...oe)},wb:!0,H:!1,localName:l,namespaceURI:u,cb:a,i:p}}_a(t,u,l,x.length,o)}function Ds(e,t,n,r){let o=[],a=[];q(e,"*").forEach(A=>{switch(A[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")}});let i=new Set;q(e,"moduleImport").forEach(A=>{let x=se(B(A,"namespacePrefix"));if(A=se(B(A,"targetNamespace")),i.has(A))throw Error(`XQST0047: The namespace "${A}" is imported more than once.`);i.add(A),Bn(t,x,A)}),q(e,"namespaceDecl").forEach(A=>{let x=se(B(A,"prefix"));if(A=se(B(A,"uri")),x==="xml"||x==="xmlns"||A==="http://www.w3.org/XML/1998/namespace"||A==="http://www.w3.org/2000/xmlns/")throw Za();Bn(t,x,A)});let u=null,l=null;for(let A of q(e,"defaultNamespaceDecl")){let x=se(B(A,"defaultNamespaceCategory")),C=se(B(A,"uri"));if(!C)throw Va();if(C==="http://www.w3.org/XML/1998/namespace"||C==="http://www.w3.org/2000/xmlns/")throw Za();if(x==="function"){if(u)throw el();u=C}else if(x==="element"){if(l)throw el();l=C}}u&&(t.v=u),l&&Bn(t,"",l),q(e,"functionDecl").forEach(A=>{Iw(A,t,o,a,n)});let p=[];return q(e,"varDecl").forEach(A=>{let x=Ne(B(A,"varName")),C=x.namespaceURI;if(C===null&&(C=t.Z(x.prefix),!C&&x.prefix))throw nl(x.prefix);if(zc.includes(C))throw Wu();var T=B(A,"external");A=B(A,"varValue");let P,_;if(T!==null?(T=B(T,"varValue"),T!==null&&(P=B(T,"*"))):A!==null&&(P=B(A,"*")),p.some(oe=>oe.namespaceURI===C&&oe.localName===x.localName))throw Error(`XQST0049: The variable ${C?`Q{${C}}`:""}${x.localName} has already been declared.`);if(Mt(t,C||"",x.localName),n&&(P&&(_=is(P,{ra:!1,Y:!0})),P&&!Yh(t,C||"",x.localName))){let oe=null;ol(t,C,x.localName,(Ae,rt)=>(oe||(oe=Se(b(_,Ae,rt))),oe())),o.push({aa:_,Fb:new En(t)}),p.push({aa:_,localName:x.localName,namespaceURI:C})}}),a.forEach(A=>{if(!A.Bb.H&&A.aa.H)throw bt(`The function Q{${A.namespaceURI}}${A.localName} is updating but the %updating annotation is missing.`)}),{Ia:a.map(A=>A.Bb),Va:p,source:r,pa:A=>{i.forEach(x=>{us(t,x)}),o.forEach(({aa:x,Fb:C})=>{i.forEach(T=>{us(C,T)}),A.Ia.forEach(T=>{C.ua(T.namespaceURI,T.localName,T.arity,!0)||T.cb&&_a(C,T.namespaceURI,T.localName,T.arity,T)}),A.Va.forEach(T=>{C.eb(T.namespaceURI,T.localName)||Mt(C,T.namespaceURI,T.localName)}),x.v(C)})}}}function Cw(e,t,n,r,o,a,i){let u=t.Y?"XQuery":"XPath";return n=t.Ha?null:_m(e,u,n,r,o,t.debug,a,i),n!==null?{state:n.jc?1:2,aa:n.aa}:{state:0,ac:typeof e=="string"?zr(e,t):Yo(e)}}function Fw(e,t,n,r){let o=B(e,"mainModule");if(!o)throw Error("Can not execute a library module.");let a=B(o,"prolog");if(a){if(!t.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");br(),r=Ds(a,n,!0,r),r.pa(r)}return te(e,new ko(n)),e=$(o,["queryBody","*"]),H(e,t)}function ep(e,t,n,r,o,a,i){let u=new Oo(n,r,a,i),l=new En(u);switch(0<Object.keys(o).length&&br(),Object.keys(o).forEach(p=>{let A=o[p];us(l,A),Bn(l,p,A)}),typeof e=="string"&&(e=ls(e)),n=Cw(e,t,n,r,o,a,i),n.state){case 2:return{fa:l,aa:n.aa};case 1:return n.aa.v(l),rc(e,t.Y?"XQuery":"XPath",u,o,n.aa,t.debug,a),{fa:l,aa:n.aa};case 0:return n=Fw(n.ac,t,l,e),n.v(l),t.Ha||rc(e,t.Y?"XQuery":"XPath",u,o,n,t.debug,a),{fa:l,aa:n}}}function Gw(e){if(g(e.type,1))return e.value;if(g(e.type,54))return e.value.node;throw mt(`Unable to convert selector argument of type ${we[e.type]} to either an ${we[1]} or an ${we[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`)}function Ow(e,t,n,r){e=e.first();let o=t.first().h.reduce((a,i)=>(a[i.key.value]=Se(i.value()),a),Object.create(null));t=o["."]?o["."]():f.empty(),delete o["."],e=Gw(e);try{let{aa:a,fa:i}=ep(e,{ra:!1,Y:!0,debug:r.debug,Ha:r.Ha,version:3.1},p=>n.Z(p),Object.keys(o).reduce((p,A)=>(p[A]=A,p),{}),{},"http://www.w3.org/2005/xpath-functions",(p,A)=>n.Ua(p,A)),u=!t.isEmpty(),l=new Qn({L:u?t.first():null,Ba:u?0:-1,sa:t,qa:Object.keys(o).reduce((p,A)=>(p[i.eb(null,A)]=o[A],p),Object.create(null))});return{kc:a.h(l,r).value,cc:e}}catch(a){at(e,a)}}function Us(e,t,n){if(t.node.nodeType!==1&&t.node.nodeType!==9)return[];let r=Ct(e,t).reduce((o,a)=>{for(let i of Us(e,a,n))o.push(i);return o},[]);return n(t)&&r.unshift(t),r}let tp=(e,t,n,r,o)=>{if(e=o.first(),!e)throw Et("The context is absent, it needs to be present to use id function.");if(!g(e.type,53))throw mt("The context item is not a node, it needs to be node to use id function.");let a=t.h,i=r.N().reduce((u,l)=>(l.value.split(/\s+/).forEach(p=>{u[p]=!0}),u),Object.create(null));for(t=e.value;t.node.nodeType!==9;)if(t=he(a,t),t===null)throw Error("FODC0001: the root node of the target node is not a document node.");return t=Us(a,t,u=>u.node.nodeType!==1||(u=Aa(a,u,"id"),!u||!i[u])?!1:(i[u]=!1,!0)),f.create(t.map(u=>Be(u)))},np=(e,t,n,r,o)=>{if(e=o.first(),!e)throw Et("The context is absent, it needs to be present to use idref function.");if(!g(e.type,53))throw mt("The context item is not a node, it needs to be node to use idref function.");let a=t.h,i=r.N().reduce((u,l)=>(u[l.value]=!0,u),Object.create(null));for(t=e.value;t.node.nodeType!==9;)if(t=he(a,t),t===null)throw Error("FODC0001: the root node of the context node is not a document node.");return t=Us(a,t,u=>u.node.nodeType!==1?!1:(u=Aa(a,u,"idref"))?u.split(/\s+/).some(l=>i[l]):!1),f.create(t.map(u=>Be(u)))};function Rs(e){switch(typeof e){case"object":return Array.isArray(e)?f.m(new ze(e.map(t=>Se(Rs(t))))):e===null?f.empty():f.m(new qt(Object.keys(e).map(t=>({key:v(t,1),value:Se(Rs(e[t]))}))));case"number":return f.m(v(e,3));case"string":return f.m(v(e,1));case"boolean":return e?f.$():f.S();default:throw Error("Unexpected type in JSON parse")}}let rp=(e,t,n,r,o)=>{let a=f.m(v("duplicates",1));e=xa(e,t,n,o,a);let i=e.isEmpty()?"use-first":e.first().value;return r.M(u=>f.m(new qt(u.reduce((l,p)=>(p.h.forEach(A=>{let x=l.findIndex(C=>qn(C.key,A.key));if(0<=x)switch(i){case"reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case"use-last":l.splice(x,1,A);return;case"combine":l.splice(x,1,{key:A.key,value:Se(f.create(l[x].value().N().concat(A.value().N())))});return;default:return}l.push(A)}),l),[]))))};function Ss(e,t,n){let r=1,o=e.value;e=e.Ra(!0);let a=null,i=Math.max(t-1,0);return e!==-1&&(a=Math.max(0,(n===null?e:Math.max(0,Math.min(e,n+(t-1))))-i)),f.create({next:u=>{for(;r<t;)o.next(u),r++;return n!==null&&r>=t+n?X:(u=o.next(u),r++,u)}},a)}function Ms(e){return e.map(t=>g(t.type,19)?xe(t,3):t)}function op(e){if(e=Ms(e),e.some(t=>Number.isNaN(t.value)))return[v(NaN,3)];if(e=$o(e),!e)throw Error("FORG0006: Incompatible types to be converted to a common type");return e}let ap=(e,t,n,r,o,a)=>de([o,a],([i,u])=>{if(i.value===1/0)return f.empty();if(i.value===-1/0)return u&&u.value===1/0?f.empty():r;if(u){if(isNaN(u.value))return f.empty();u.value===1/0&&(u=null)}return isNaN(i.value)?f.empty():Ss(r,Math.round(i.value),u?Math.round(u.value):null)}),sp=(e,t,n,r,o)=>{if(r.isEmpty())return o;if(e=Ms(r.N()),e=$o(e),!e)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every(a=>g(a.type,2)))throw Error("FORG0006: items passed to fn:sum are not all numeric.");return t=e.reduce((a,i)=>a+i.value,0),e.every(a=>g(a.type,5))?f.m(v(t,5)):e.every(a=>g(a.type,3))?f.m(v(t,3)):e.every(a=>g(a.type,4))?f.m(v(t,4)):f.m(v(t,6))};var Dw=[].concat(Sh,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>r.ea()?f.$():f.S()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>f.$()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>r.ea()===!1?f.$():f.S()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",j:[],i:{type:0,g:3},callFunction:()=>f.S()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:e=>{if(e.L===null)throw Et("The fn:last() function depends on dynamic context, which is absent.");let t=!1;return f.create({next:()=>{if(t)return X;let n=e.sa.Ra();return t=!0,k(v(n,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:e=>{if(e.L===null)throw Et("The fn:position() function depends on dynamic context, which is absent.");return f.m(v(e.Ba+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:e=>f.m(v(Ia(e),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:e=>f.m(v(vt(Ia(e),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:e=>f.m(v(vt(Ia(e),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",j:[],i:{type:17,g:3},callFunction:e=>f.m(v(xt(e),17))}],Mh,kh,$h,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.ab(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.Za(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.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:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getMinutes(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(e,t,n,r)=>r.isEmpty()?r:f.m(v(r.first().value.getSeconds(),4))}],jh,[{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:tp},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction(e,t,n,r){return tp(e,t,n,r,f.m(e.L))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:np},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction(e,t,n,r){return np(e,t,n,r,f.m(e.L))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(e,t,n,r)=>{let o;try{o=JSON.parse(r.first().value)}catch{throw Error("FOJS0001: parsed JSON string contains illegal JSON.")}return Rs(o)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"contains",j:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},callFunction:(e,t,n,r,o)=>de([r,o],([a,i])=>a.h.some(u=>qn(u.key,i))?f.$():f.S())},{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:(e,t,n,r,o)=>r.map(a=>new qt([{key:a,value:Se(o)}]))},{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:(e,t,n,r,o)=>de([r,o],([a,i])=>Bt(a.h.map(u=>i.value.call(void 0,e,t,n,f.m(u.key),u.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:xa},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(e,t,n,r)=>de([r],([o])=>f.create(o.h.map(a=>a.key)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2},{type:61,g:3}],i:{type:61,g:3},callFunction:rp},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction(e,t,n,r){return rp(e,t,n,r,f.m(new qt([{key:v("duplicates",1),value:()=>f.m(v("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:(e,t,n,r,o,a)=>de([r,o],([i,u])=>{i=i.h.concat();let l=i.findIndex(p=>qn(p.key,u));return 0<=l?i.splice(l,1,{key:u,value:Se(a)}):i.push({key:u,value:Se(a)}),f.m(new qt(i))})},{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:(e,t,n,r,o)=>de([r],([a])=>{let i=a.h.concat();return o.M(u=>(u.forEach(l=>{let p=i.findIndex(A=>qn(A.key,l));0<=p&&i.splice(p,1)}),f.m(new qt(i))))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>r.map(o=>v(o.h.length,5))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>f.m(v(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:(e,t,n,r)=>r.map(o=>v(Math.pow(Math.E,o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.pow(10,o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.log(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.log10(o.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:(e,t,n,r,o)=>o.M(([a])=>r.map(i=>Math.abs(i.value)!==1||Number.isFinite(a.value)?v(Math.pow(i.value,a.value),3):v(1,3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.sqrt(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.sin(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.cos(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.tan(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.asin(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.acos(o.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map(o=>v(Math.atan(o.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:(e,t,n,r,o)=>o.M(([a])=>r.map(i=>v(Math.atan2(i.value,a.value),3)))}],gh,fh,[{namespaceURI:"http://fontoxpath/operators",localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(e,t,n,r,o)=>{if(e=r.first(),o=o.first(),e===null||o===null)return f.empty();let a=e.value;return o=o.value,a>o?f.empty():f.create({next:()=>k(v(a++,5))},o-a+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:(e,t,n,r,o)=>de([r,o],([a,i])=>{if(i=i.value,!vo(i,23))throw Error("FOCA0002: The provided QName is invalid.");if(a=a&&a.value||null,a===null&&i.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(r.isEmpty())return f.m(v(new _e("",null,i),23));if(!i.includes(":"))return f.m(v(new _e("",a,i),23));let[u,l]=i.split(":");return f.m(v(new _e(u,a,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:(e,t,n,r)=>de([r],([o])=>o===null?f.empty():(o=o.value,o.prefix?f.m(v(o.prefix,24)):f.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:(e,t,n,r)=>r.map(o=>v(o.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:(e,t,n,r)=>r.map(o=>v(o.value.namespaceURI||"",20))}],[{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.X({empty:()=>f.$(),multiple:()=>f.S(),m:()=>f.S()}),localName:"empty",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.X({empty:()=>f.S(),multiple:()=>f.$(),m:()=>f.$()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>Ss(r,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>Ss(r,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(e,t,n,r,o,a)=>r.isEmpty()?a:a.isEmpty()?r:(e=r.N(),o=o.first().value-1,0>o?o=0:o>e.length&&(o=e.length),t=e.slice(o),f.create(e.slice(0,o).concat(a.N(),t))),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:(e,t,n,r,o)=>(e=o.first().value,r=r.N(),!r.length||1>e||e>r.length||r.splice(e-1,1),f.create(r)),localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.M(o=>f.create(o.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:(e,t,n,r,o)=>ap(e,t,n,r,o,f.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:ap,localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{let o=Me(r,t).N();return f.create(o).filter((a,i)=>o.slice(0,i).every(u=>!$r(a,u)))},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")},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:(e,t,n,r,o)=>o.M(([a])=>Me(r,t).map((i,u)=>Po("eqOp",i.type,a.type)(i,a,e)?v(u+1,5):v(-1,5)).filter(i=>i.value!==-1)),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",i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(e,t,n,r,o)=>{let a=!1,i=nn(e,t,n,r,o);return f.create({next:()=>{if(a)return X;let u=i.next(0);return u.done?u:(a=!0,k(v(u.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",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{let o=!1;return f.create({next:()=>{if(o)return X;let a=r.Ra();return o=!0,k(v(a,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{if(r.isEmpty())return r;if(e=Ms(r.N()),e=$o(e),!e)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every(o=>g(o.type,2)))throw Error("FORG0006: items passed to fn:avg are not all numeric.");return t=e.reduce((o,a)=>o+a.value,0)/e.length,e.every(o=>g(o.type,5)||g(o.type,3))?f.m(v(t,3)):e.every(o=>g(o.type,4))?f.m(v(t,4)):f.m(v(t,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.isEmpty()?r:(e=op(r.N()),f.m(e.reduce((o,a)=>o.value<a.value?a:o))),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")},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.isEmpty()?r:(e=op(r.N()),f.m(e.reduce((o,a)=>o.value>a.value?a:o))),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,g:2}],callFunction:(e,t,n,r)=>sp(e,t,n,r,f.m(v(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:sp,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.isEmpty()&&!r.oa())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");return r},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(r.isEmpty())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return r},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.oa())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");return r},localName:"exactly-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:3}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,o)=>{if(r.isEmpty())return r;let a=o.first(),i=a.o;if(i.length!==1)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.filter(u=>{if(u=Ot(i[0],f.m(u),t,"fn:filter",!1),u=a.value.call(void 0,e,t,n,u),!u.oa()||!g(u.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return u.first().value})},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,o)=>{if(r.isEmpty())return r;let a=o.first(),i=a.o;if(i.length!==1)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");let u=r.value,l;return f.create({next:p=>{for(;;){if(!l){var A=u.next(0);if(A.done)return A;A=Ot(i[0],f.m(A.value),t,"fn:for-each",!1),l=a.value.call(void 0,e,t,n,A).value}if(A=l.next(p),!A.done)return A;l=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,o,a)=>{if(r.isEmpty())return r;let i=a.first(),u=i.o;if(u.length!==2)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return r.M(l=>l.reduce((p,A)=>(p=Ot(u[0],p,t,"fn:fold-left",!1),A=Ot(u[1],f.m(A),t,"fn:fold-left",!1),i.value.call(void 0,e,t,n,p,A)),o))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,o,a)=>{if(r.isEmpty())return r;let i=a.first(),u=i.o;if(u.length!==2)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return r.M(l=>l.reduceRight((p,A)=>(p=Ot(u[0],p,t,"fn:fold-right",!1),A=Ot(u[1],f.m(A),t,"fn:fold-right",!1),i.value.call(void 0,e,t,n,A,p)),o))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!t.Wa)throw Error("serialize() called but no xmlSerializer set in execution parameters.");if(e=r.N(),!e.every(o=>g(o.type,53)))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return f.m(v(e.map(o=>t.Wa.serializeToString(Ve(o.value,t,!1))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],mh,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(e,t,n,r,o)=>{let a,i;return f.create({next:()=>{a||({kc:a,cc:i}=Ow(r,o,n,t));try{return a.next(0)}catch(u){at(i,u)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{j:[],callFunction:()=>f.m(v(typeof d>"u"?"devbuild":d,1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(e,t,n,r,o)=>de([r,o],([a,i])=>{let u=n.ua(a.value.namespaceURI,a.value.localName,i.value);return u===null?f.empty():(a=new _t({j:u.j,arity:i.value,localName:a.value.localName,namespaceURI:a.value.namespaceURI,i:u.i,value:u.callFunction}),f.m(a))}),localName:"function-lookup",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>de([r],([o])=>o.bb()?f.empty():f.m(v(new _e("",o.l,o.D),23))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>de([r],([o])=>f.m(v(o.v,5))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class ip{constructor(t){this.h=t}createAttributeNS(t,n){return this.h.createAttributeNS(t,n)}createCDATASection(t){return this.h.createCDATASection(t)}createComment(t){return this.h.createComment(t)}createDocument(){return this.h.createDocument()}createElementNS(t,n){return this.h.createElementNS(t,n)}createProcessingInstruction(t,n){return this.h.createProcessingInstruction(t,n)}createTextNode(t){return this.h.createTextNode(t)}}var ks=Symbol("IS_XPATH_VALUE_SYMBOL");function Uw(e){return(t,n)=>(t=Mi(new ho(n===null?new Wt:n),t,dn(e)),{[ks]:!0,zb:t})}Dw.forEach(e=>{_u(e.namespaceURI,e.localName,e.j,e.i,e.callFunction)});function up(e){return e&&typeof e=="object"&&"lookupNamespaceURI"in e?t=>e.lookupNamespaceURI(t||null):()=>null}function Hs(e){return({prefix:t,localName:n})=>t?null:{namespaceURI:e,localName:n}}function Ps(e,t,n,r,o,a){r==null&&(r=r||{});let i=o?{jb:o.logger||{trace:console.log.bind(console)},Oa:o.documentWriter,kb:o.moduleImports,Db:o.namespaceResolver,dc:o.functionNameResolver,Ja:o.nodesFactory,Wa:o.xmlSerializer}:{jb:{trace:console.log.bind(console)},kb:{},Db:null,Ja:null,Oa:null,Wa:null},u=new ho(n===null?new Wt:n);n=i.kb||Object.create(null);var l=o.defaultFunctionNamespaceURI===void 0?"http://www.w3.org/2005/xpath-functions":o.defaultFunctionNamespaceURI;let p=ep(e,a,i.Db||up(t),r,n,l,i.dc||Hs(l));e=t?yo(u,t):f.empty(),t=!i.Ja&&a.Y?new Uu(t):new ip(i.Ja),n=i.Oa?new Fi(i.Oa):wa,l=i.Wa;let A=Object.keys(r).reduce((T,P)=>{let _=r[P];return T[`Q{}${P}[0]`]=_&&typeof _=="object"&&ks in _?()=>f.create(_.zb):()=>yo(u,r[P]),T},Object.create(null)),x;for(let T of Object.keys(p.fa.Fa))A[T]||(A[T]=()=>(0,p.fa.Fa[T])(x,C));x=new Qn({L:e.first(),Ba:0,sa:e,qa:A});let C=new Hi(a.debug,a.Ha,u,t,n,o.currentContext,new Map,i.jb,l);return{tb:x,ub:C,aa:p.aa}}function $s(e,t){let n={},r=0,o=!1,a=null;return{next:()=>{if(o)return X;for(;r<e.h.length;){let u=e.h[r].key.value;if(!a){let l=e.h[r];var i=l.value().X({default:p=>p,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(i===null){n[u]=null,r++;continue}a=Rn(i,t)}i=a.next(0),a=null,n[u]=i.value,r++}return o=!0,k(n)}}}function js(e,t){let n=[],r=0,o=!1,a=null;return{next:()=>{if(o)return X;for(;r<e.members.length;){if(!a){var i=e.members[r]().X({default:u=>u,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(i===null){n[r++]=null;continue}a=Rn(i,t)}i=a.next(0),a=null,n[r++]=i.value}return o=!0,k(n)}}}function Rn(e,t){if(g(e.type,61))return $s(e,t);if(g(e.type,62))return js(e,t);if(g(e.type,23)){let n=e.value;return{next:()=>k(`Q{${n.namespaceURI||""}}${n.localName}`)}}switch(e.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:let n=e.value;return{next:()=>k(Rr(n))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:let r=e.value;return{next:()=>k(Ve(r,t,!1))};default:return{next:()=>k(e.value)}}}var ke={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};ke[ke.ANY]="ANY",ke[ke.NUMBER]="NUMBER",ke[ke.STRING]="STRING",ke[ke.BOOLEAN]="BOOLEAN",ke[ke.NODES]="NODES",ke[ke.FIRST_NODE]="FIRST_NODE",ke[ke.STRINGS]="STRINGS",ke[ke.MAP]="MAP",ke[ke.ARRAY]="ARRAY",ke[ke.NUMBERS]="NUMBERS",ke[ke.ALL_RESULTS]="ALL_RESULTS",ke[ke.ASYNC_ITERATOR]="ASYNC_ITERATOR";function lp(e,t,n,r){switch(n){case 3:return t.ea();case 2:return t=Me(t,r).N(),t.length?t.map(l=>xe(l,1).value).join(" "):"";case 10:return t=Me(t,r).N(),t.length?t.map(l=>l.value+""):[];case 1:return t=t.first(),t!==null&&g(t.type,2)?t.value:NaN;case 9:if(t=t.first(),t===null)return null;if(!g(t.type,53))throw Error("Expected XPath "+St(e)+" to resolve to Node. Got "+we[t.type]);return Ve(t.value,r,!1);case 7:if(t=t.N(),!t.every(l=>g(l.type,53)))throw Error("Expected XPath "+St(e)+" to resolve to a sequence of Nodes.");return t.map(l=>Ve(l.value,r,!1));case 11:if(t=t.N(),t.length!==1)throw Error("Expected XPath "+St(e)+" to resolve to a single map.");if(t=t[0],!g(t.type,61))throw Error("Expected XPath "+St(e)+" to resolve to a map");return $s(t,r).next(0).value;case 12:if(t=t.N(),t.length!==1)throw Error("Expected XPath "+St(e)+" to resolve to a single array.");if(t=t[0],!g(t.type,62))throw Error("Expected XPath "+St(e)+" to resolve to an array");return js(t,r).next(0).value;case 13:return t.N().map(l=>{if(!g(l.type,2))throw Error("Expected XPath "+St(e)+" to resolve to numbers");return l.value});case 99:let o=t.value,a=null,i=!1,u=()=>{for(;!i;){if(!a){var l=o.next(0);if(l.done){i=!0;break}a=Rn(l.value,r)}return l=a.next(0),a=null,l}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>new Promise(l=>l(u())).catch(l=>{at(e,l)})}:{next:()=>new Promise(l=>l(u()))};case 14:return t.N().map(l=>Rn(l,r).next(0).value);default:return t=t.N(),t.every(l=>g(l.type,53)&&!g(l.type,47))?(t=t.map(l=>Ve(l.value,r,!1)),t.length===1?t[0]:t):t.length===1?(t=t[0],g(t.type,62)?js(t,r).next(0).value:g(t.type,61)?$s(t,r).next(0).value:Jt(t,r).first().value):Me(f.create(t),r).N().map(l=>l.value)}}let zo=!1,cn=null;var Rw={getPerformanceSummary(){let e=cn.getEntriesByType("measure").filter(t=>t.name.startsWith("XPath: "));return Array.from(e.reduce((t,n)=>{var r=n.name.substring(7);return t.has(r)?(r=t.get(r),r.times+=1,r.totalDuration+=n.duration):t.set(r,{xpath:r,times:1,totalDuration:n.duration,average:0}),t},new Map).values()).map(t=>(t.average=t.totalDuration/t.times,t)).sort((t,n)=>n.totalDuration-t.totalDuration)},setPerformanceImplementation(e){cn=e},startProfiling(){if(cn===null)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");cn.clearMarks(),cn.clearMeasures(),zo=!0},stopProfiling(){zo=!1}};let fr=0;var Sw={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1",XPATH_4_0_LANGUAGE:"XPath4.0",XQUERY_4_0_LANGUAGE:"XQuery4.0",XQUERY_UPDATE_4_0_LANGUAGE:"XQueryUpdate4.0"};let He=(e,t,n,r,o,a)=>{if(o=o||0,!e||typeof e!="string"&&!("nodeType"in e))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");a=a||{};let i,u;try{let p=Ps(e,t,n||null,r||{},a,{ra:a.language==="XQueryUpdate3.1",Y:a.language==="XQuery3.1"||a.language==="XQueryUpdate3.1",debug:!!a.debug,Ha:!!a.disableCache,version:a.language==="XPath4.0"||a.language==="XQuery4.0"||a.language==="XQueryUpdate4.0"?4:3.1});var l=p.tb;i=p.ub,u=p.aa}catch(p){at(e,p)}if(u.H)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(o===3&&t&&typeof t=="object"&&"nodeType"in t&&(n=u.D(),t=Yt(t),n!==null&&!t.includes(n)))return!1;try{t=e,zo&&(typeof t!="string"&&(t=St(t)),cn.mark(`${t}${fr===0?"":"@"+fr}`),fr++);let p=b(u,l,i),A=lp(e,p,o,i);return o=e,zo&&(typeof o!="string"&&(o=St(o)),fr--,l=`${o}${fr===0?"":"@"+fr}`,cn.measure(`XPath: ${o}`,l),cn.clearMarks(l)),A}catch(p){at(e,p)}};Object.assign(He,{lc:14,ANY_TYPE:0,Nb:12,Ob:99,BOOLEAN_TYPE:3,Qb:9,Tb:11,Vb:7,Wb:13,NUMBER_TYPE:1,Xb:10,STRING_TYPE:2,mc:"XPath3.1",nc:"XQuery3.1",$b:"XQueryUpdate3.1"}),Object.assign(He,{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",XPATH_4_0_LANGUAGE:"XPath4.0",XQUERY_4_0_LANGUAGE:"XQuery4.0"});function cp(e,t,n,r,o){return He(e,t,n,r,He.Ob,o)}function pp(e,t,n,r){return{pendingUpdateList:e.ca.map(o=>o.h(r)),xdmValue:lp(t,f.create(e.I),n,r)}}async function Mw(e,t,n,r,o){o=o||{},br();let a,i;try{let p=Ps(e,t,n||null,r||{},o||{},{ra:!0,Y:!0,debug:!!o.debug,Ha:!!o.disableCache,version:o.language==="XQueryUpdate4.0"?4:3.1});var u=p.tb;a=p.ub,i=p.aa}catch(p){at(e,p)}if(!i.H){for(u=[],e=cp(e,t,n,r,Object.assign(Object.assign({},o),{language:"XQueryUpdate3.1"})),t=await e.next();!t.done;t=await e.next())u.push(t.value);return Promise.resolve({pendingUpdateList:[],xdmValue:u})}let l;try{l=i.s(u,a).next(0)}catch(p){at(e,p)}return pp(l.value,e,o.returnType,a)}function kw(e,t,n,r,o){o=o||{},br();let a,i,u;try{let p=Ps(e,t,n||null,r||{},o||{},{ra:!0,Y:!0,debug:!!o.debug,Ha:!!o.disableCache,version:o.language==="XQueryUpdate4.0"?4:3.1});a=p.tb,i=p.ub,u=p.aa}catch(p){at(e,p)}if(!u.H)return{pendingUpdateList:[],xdmValue:He(e,t,n,r,o.i,Object.assign(Object.assign({},o),{language:He.$b}))};let l;try{l=u.s(a,i).next(0)}catch(p){at(e,p)}return pp(l.value,e,o.returnType,i)}function Hw(e,t,n,r,o){return He(e,t,n,r,He.Nb,o)}function Pw(e,t,n,r,o){return He(e,t,n,r,He.BOOLEAN_TYPE,o)}function $w(e,t,n,r,o){return He(e,t,n,r,He.Qb,o)}function jw(e,t,n,r,o){return He(e,t,n,r,He.Tb,o)}function Xw(e,t,n,r,o){return He(e,t,n,r,He.Vb,o)}function Lw(e,t,n,r,o){return He(e,t,n,r,He.NUMBER_TYPE,o)}function Yw(e,t,n,r,o){return He(e,t,n,r,He.Wb,o)}function qw(e,t,n,r,o){return He(e,t,n,r,He.STRING_TYPE,o)}function Qw(e,t,n,r,o){return He(e,t,n,r,He.Xb,o)}function Jw(e,t,n,r){t=new ho(t||new Wt),r=r?new Fi(r):wa,n=n?n=new ip(n):null,e=e.map(bl),ku(e,t,n,r)}function z(e,t,n){return{code:e,ta:t,G:n,isAstAccepted:!0}}function ye(e){return{isAstAccepted:!1,reason:e}}function K(e,t){return e.isAstAccepted?t(e):e}function Xs(e,t){return e.isAstAccepted?t(e):[e,null]}function Vt(e,t,n){return K(e,r=>{switch(r.ta.type){case 0:return r;case 1:return K(nt(n,r,"nodes"),o=>K(nt(n,t,"contextItem"),a=>z(`(function () {
|
|
12
|
+
const { done, value } = ${o.code}(${a.code}).next();
|
|
13
|
+
return done ? null : value;
|
|
14
|
+
})()`,{type:0},[...o.G,...a.G])));default:throw Error(`invalid generated code type to convert to value: ${r.ta.type}`)}})}function mr(e,t,n,r){return e=Vt(e,n,r),t&&t.type===0&&t.g===3?e:K(e,o=>z(`!!${o.code}`,{type:0},o.G))}function eo(e,t,n){return t?e.isAstAccepted&&e.ta.type!==0?ye("Atomization only implemented for single value"):g(t.type,1)?e:g(t.type,47)?K(nt(n,e,"attr"),r=>z(`(${r.code} ? domFacade.getData(${r.code}) : null)`,{type:0},r.G)):ye("Atomization only implemented for string and attribute"):ye("Can not atomize value if type was not annotated")}function hp(e,t,n,r){return e=Vt(e,n,r),r=eo(e,t,r),An(t)?K(r,o=>z(`${o.code} ?? ''`,{type:0},o.G)):r}function Ls(e,t,n){return K(nt(n,e,"node"),r=>r.ta.type===1?r:t&&!g(t.type,53)?ye("Can not evaluate to node if expression does not result in nodes"):z(`(function () {
|
|
15
|
+
if (${r.code} !== null && !${r.code}.nodeType) {
|
|
16
|
+
throw new Error('XPDY0050: The result of the expression was not a node');
|
|
17
|
+
}
|
|
18
|
+
return ${r.code};
|
|
19
|
+
})()`,{type:0},r.G))}function Kw(e,t,n,r){return K(e,o=>{switch(o.ta.type){case 1:return K(nt(r,o,"nodes"),a=>K(nt(r,n,"contextItem"),i=>z(`Array.from(${a.code}(${i.code}))`,{type:0},[...a.G,...i.G])));case 0:return K(nt(r,Ls(o,t,r),"node"),a=>z(`(${a.code} === null ? [] : [${a.code}])`,{type:0},a.G));default:return ye("Unsupported code type to evaluate to nodes")}})}function dr(e,t){return K(e,n=>K(t,r=>{if(n.ta.type!==0||r.ta.type!==0)throw Error("can only use emitAnd with value expressions");return z(`${n.code} && ${r.code}`,{type:0},[...n.G,...r.G])}))}function gr(e,t,n,r){return(e=$(e,[t,"*"]))?r.h(e,n,r):[ye(`${t} expression not found`),null]}let Ys={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},bw={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};function fp(e,t,n,r){let o=J($(e,["firstOperand","*"]),"type"),a=J($(e,["secondOperand","*"]),"type");if(!o||!a)return ye("Can not generate code for value compare without both types");var i=[47,1];if(!i.includes(o.type)||!i.includes(a.type))return ye(`Unsupported types in compare: [${we[o.type]}, ${we[a.type]}]`);if(i=new Map([["eqOp","==="],["neOp","!=="]]),!i.has(t))return ye(t+" not yet implemented");let u=i.get(t);return[t]=gr(e,"firstOperand",n,r),t=Vt(t,n,r),t=eo(t,o,r),K(nt(r,t,"first"),l=>{var[p]=gr(e,"secondOperand",n,r);return p=Vt(p,n,r),p=eo(p,a,r),K(nt(r,p,"second"),A=>{let x=[];return An(o)&&x.push(`${l.code} === null`),An(a)&&x.push(`${A.code} === null`),z(`(${x.length?`${x.join(" || ")} ? null : `:""}${l.code} ${u} ${A.code})`,{type:0},[...l.G,...A.G])})})}function mp(e,t,n,r,o,a){var i=J($(e,[t,"*"]),"type");let u=J($(e,[n,"*"]),"type");if(!i||!u)return ye("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(i.type)||!l.includes(u.type))return ye(`Unsupported types in compare: [${we[i.type]}, ${we[u.type]}]`);if(l=new Map([["eqOp","==="],["neOp","!=="]]),!l.has(r))return ye(r+" not yet implemented");let p=l.get(r);return[t]=gr(e,t,o,a),t=Vt(t,o,a),i=eo(t,i,a),K(nt(a,i,"single"),A=>{let[x]=gr(e,n,o,a);return K(nt(a,x,"multiple"),C=>{if(C.ta.type!==1)return ye("can only generate general compare for a single value and a generator");let T=ta(a,ea(a,"n")),P=eo(T,u,a);return K(o,_=>K(P,oe=>z(`(function () {
|
|
20
|
+
for (const ${T.code} of ${C.code}(${_.code})) {
|
|
21
|
+
${oe.G.join(`
|
|
22
|
+
`)}
|
|
23
|
+
if (${oe.code} ${p} ${A.code}) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
})()`,{type:0},[...A.G,...T.G,..._.G,...C.G])))})})}function yr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}let Vw={"false#0":n1,"local-name#0":wp,"local-name#1":wp,"name#0":yp,"name#1":yp,"not#1":t1,"true#0":r1},Zw={"http://fontoxml.com/fontoxpath":["version#0"],"":["root#1","path#1"]};function _w(e,t,n,r){let[o]=r.h(e,n,r);if(e=J(e,"type"),!t||t.g===2||t.g===1)return ye("Not supported: sequence arguments with multiple items");if(g(t.type,53))return t=Vt(o,n,r),Ls(t,e,r);switch(t.type){case 59:return Vt(o,n,r);case 0:return mr(o,e,n,r);case 1:return hp(o,e,n,r)}return ye(`Argument types not supported: ${e?we[e.type]:"unknown"} -> ${we[t.type]}`)}function dp(e,t,n,r){if(e.length!==t.length||t.some(l=>l===4))return ye("Not supported: variadic function or mismatch in argument count");if(e.length===0)return z("",{type:0},[]);let[o,...a]=e,[i,...u]=t;return e=nt(r,_w(o,i,n,r),"arg"),a.length===0?e:K(e,l=>{let p=dp(a,u,n,r);return K(p,A=>z(`${l.code}, ${A.code}`,{type:0},[...l.G,...A.G]))})}function Ww(e,t){return K(e,n=>!t||t.g===2||t.g===1||![0,1].includes(t.type)&&!g(t.type,53)?ye(`Function return type ${we[t.type]} not supported`):n)}function zw(e,t,n){let{localName:r,namespaceURI:o}=Ne(B(e,"functionName")),a=q(B(e,"arguments"),"*");var i=a.length;let u=`${r}#${i}`,l=o===n.D;if(l){let p=Vw[u];if(p!==void 0)return p(e,t,n)}return(e=Zw[l?"":o])&&!e.includes(u)?ye(`Not supported: built-in function not on allow list: ${u}`):(i=ba(o,r,i),i?i.H?ye("Not supported: updating functions"):(t=dp(a,i.j,t,n),t=K(t,p=>z(`runtimeLib.callFunction(domFacade, ${yr(o)}, ${yr(r)}, [${p.code}], options)`,{type:0},p.G)),Ww(t,i.i)):ye(`Unknown function / arity: ${u}`))}function e1(e,t){return K(nt(t,e,"contextItem"),n=>z(n.code,{type:0},[...n.G,`if (${n.code} === undefined || ${n.code} === null) {
|
|
29
|
+
throw errXPDY0002('The function which was called depends on dynamic context, which is absent.');
|
|
30
|
+
}`]))}function gp(e,t,n,r){if((e=$(e,["arguments","*"]))&&e[0]!=="contextItemExpr"){let o=J(e,"type");if(!o||!g(o.type,53))return ye("name function only implemented if arg is a node");[e]=n.h(e,t,n)}else e=e1(t,n);return t=Vt(e,t,n),K(nt(n,t,"arg"),o=>z(`(${o.code} ? ${r(o.code)} : '')`,{type:0},o.G))}function yp(e,t,n){return gp(e,t,n,r=>`(((${r}.prefix || '').length !== 0 ? ${r}.prefix + ':' : '')
|
|
31
|
+
+ (${r}.localName || ${r}.target || ''))`)}function wp(e,t,n){return gp(e,t,n,r=>`(${r}.localName || ${r}.target || '')`)}function t1(e,t,n){var r=$(e,["arguments","*"]);return e=J(r,"type"),[r]=n.h(r,t,n),t=mr(r,e,t,n),K(t,o=>z(`!${o.code}`,{type:0},o.G))}function n1(){return z("false",{type:0},[])}function r1(){return z("true",{type:0},[])}function Ap(e,t,n,r){let[o,a]=gr(e,"firstOperand",n,r);var i=J($(e,["firstOperand","*"]),"type");i=mr(o,i,n,r);let[u,l]=gr(e,"secondOperand",n,r);i=K(i,A=>{var x=J($(e,["secondOperand","*"]),"type");return x=mr(u,x,n,r),K(x,C=>z(`(${A.code} ${t} ${C.code})`,{type:0},[...A.G,...C.G]))});let p=t==="&&"?ct(a,l):a===l?a:null;return[i,p]}function vp(e,t,n){return K(e,r=>K(t,o=>K(n,a=>z(`for (${r.code}) {
|
|
32
|
+
${o.G.join(`
|
|
33
|
+
`)}
|
|
34
|
+
if (!(${o.code})) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
${a.G.join(`
|
|
38
|
+
`)}
|
|
39
|
+
${a.code}
|
|
40
|
+
}`,{type:2},r.G))))}function o1(e,t,n,r,o){let a=t?`, "${t}"`:"";return t=K(r,i=>K(o,u=>z(`let ${i.code} = domFacade.getFirstChild(${u.code}${a});
|
|
41
|
+
${i.code};
|
|
42
|
+
${i.code} = domFacade.getNextSibling(${i.code}${a})`,{type:2},[...i.G,...u.G]))),vp(t,e,n)}function a1(e,t,n,r,o){let a=ct(t,"type-2"),i=K(o,u=>z(`(${u.code} && ${u.code}.nodeType === /*ELEMENT_NODE*/ 1 ? domFacade.getAllAttributes(${u.code}${a?`, "${a}"`:""}) : [])`,{type:0},u.G));return t=K(r,u=>K(i,l=>z(`const ${u.code} of ${l.code}`,{type:2},[...u.G,...l.G]))),vp(t,e,n)}function s1(e,t,n,r,o){let a=t?`, "${t}"`:"";return t=K(o,i=>z(`domFacade.getParentNode(${i.code}${a})`,{type:0},i.G)),xp(r,t,e,n)}function xp(e,t,n,r){let o=dr(e,n);return K(e,a=>K(t,i=>K(o,u=>K(r,l=>z(`const ${a.code} = ${i.code};
|
|
43
|
+
${u.G.join(`
|
|
44
|
+
`)}
|
|
45
|
+
if (${u.code}) {
|
|
46
|
+
${l.G.join(`
|
|
47
|
+
`)}
|
|
48
|
+
${l.code}
|
|
49
|
+
}`,{type:2},[...a.G,...i.G])))))}function i1(e,t,n,r,o,a){switch(e=se(e),e){case"attribute":return[a1(t,n,r,o,a),"type-1"];case"child":return[o1(t,n,r,o,a),null];case"parent":return[s1(t,n,r,o,a),null];case"self":return[xp(o,a,t,r),n];default:return[ye(`Unsupported: the ${e} axis`),null]}}let wr={Yb:"textTest",Pb:"elementTest",Ub:"nameTest",Zb:"Wildcard",Mb:"anyKindTest"};var Bp=Object.values(wr);function u1(e){return[K(e,t=>z(`(${t.code}.nodeType === /*TEXT_NODE*/ 3 ||
|
|
50
|
+
${t.code}.nodeType === /* CDATA_SECTION_NODE */ 4)`,{type:0},[])),"type-3"]}function l1(e,t){if(e.namespaceURI===null&&e.prefix!=="*"){if(t=t.Z(e.prefix||"")||null,!t&&e.prefix)throw Error(`XPST0081: The prefix ${e.prefix} could not be resolved.`);e.namespaceURI=t}}function Ar(e,t,n,r){l1(e,r);let o=e.prefix,a=e.namespaceURI,i=e.localName;return Xs(n,u=>{var l=t?z(`${u.code}.nodeType
|
|
51
|
+
&& (${u.code}.nodeType === /*ELEMENT_NODE*/ 1
|
|
52
|
+
|| ${u.code}.nodeType === /*ATTRIBUTE_NODE*/ 2)`,{type:0},[]):z(`${u.code}.nodeType
|
|
53
|
+
&& ${u.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]);if(o==="*")return i==="*"?[l,t?"type-1-or-type-2":"type-1"]:[dr(l,z(`${u.code}.localName === ${yr(i)}`,{type:0},[])),`name-${i}`];l=i==="*"?l:dr(l,z(`${u.code}.localName === ${yr(i)}`,{type:0},[]));var p=z(yr(a),{type:0},[]);return p=o===""&&t?K(p,A=>z(`${u.code}.nodeType === /*ELEMENT_NODE*/ 1 ? ${A.code} : null`,{type:0},A.G)):p,p=K(p,A=>z(`(${u.code}.namespaceURI || null) === ((${A.code}) || null)`,{type:0},A.G)),[dr(l,p),`name-${i}`]})}function c1(e,t,n){let r=(e=B(e,"elementName"))&&B(e,"star");return e===null||r?[K(t,o=>z(`${o.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[])),"type-1"]:(e=Ne(B(e,"QName")),Ar(e,!1,t,n))}function p1(e){return[K(e,t=>z(`!!${t.code}.nodeType`,{type:0},[])),null]}function Ep(e,t,n,r){var o=e[0];switch(o){case wr.Pb:return c1(e,n,r);case wr.Yb:return u1(n);case wr.Ub:return Ar(Ne(e),t,n,r);case wr.Zb:return B(e,"star")?(o=B(e,"uri"),o!==null?e=Ar({localName:"*",namespaceURI:se(o),prefix:""},t,n,r):(o=B(e,"NCName"),e=B(e,"*")[0]==="star"?Ar({localName:se(o),namespaceURI:null,prefix:"*"},t,n,r):Ar({localName:"*",namespaceURI:null,prefix:se(o)},t,n,r))):e=Ar({localName:"*",namespaceURI:null,prefix:"*"},t,n,r),e;case wr.Mb:return p1(n);default:return[ye(`Test not implemented: '${o}`),null]}}function Np(e,t,n){let[r,o]=n.h(e,t,n);return e=J(e,"type"),[mr(r,e,t,n),o]}function Tp(e,t,n){e=e?q(e,"*"):[];let[r,o]=e.reduce(([a,i],u)=>{if(!a)return Np(u,t,n);let l=i;return Xs(a,p=>{let[A,x]=Np(u,t,n);return l=ct(i,x),[K(A,C=>z(`${p.code} && ${C.code}`,{type:0},[...p.G,...C.G])),l]})},[null,null]);return[r?K(r,a=>z(`(function () {
|
|
54
|
+
${a.G.join(`
|
|
55
|
+
`)}
|
|
56
|
+
return ${a.code};
|
|
57
|
+
})()`,{type:0},[])):null,o]}function qs(e,t,n,r){if(e.length===0)return[K(n,T=>z(`yield ${T.code};`,{type:2},T.G)),null];let[o,...a]=e;if(0<q(o,"lookup").length)return[ye("Unsupported: lookups"),null];let i=ta(r,ea(r,"contextItem"));e=B(o,"predicates");let[u,l]=Tp(e,i,r);if(e=B(o,"xpathAxis")){var p=B(o,Bp);if(!p)return[ye("Unsupported test in step"),null];var A=se(e);t=A==="attribute"||A==="self"&&t;let[T,P]=Ep(p,t,i,r);return p=u===null?T:dr(T,u),A=ct(P,l),[t]=qs(a,t,i,r),i1(e,p,A,t,i,n)}if(e=$(o,["filterExpr","*"]),!e)return[ye("Unsupported: unknown step type"),null];let[x,C]=r.h(e,n,r);return[K(x,T=>{let P=a.length===0?z("",{type:2},[]):z(`if (${i.code} !== null && !${i.code}.nodeType) {
|
|
58
|
+
throw new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');
|
|
59
|
+
}`,{type:2},[]),[_]=qs(a,!0,i,r),oe=u===null?_:K(u,Ae=>K(_,rt=>z(`if (${Ae.code}) {
|
|
60
|
+
${rt.G.join(`
|
|
61
|
+
`)}
|
|
62
|
+
${rt.code}
|
|
63
|
+
}`,{type:2},Ae.G)));return K(oe,Ae=>{switch(T.ta.type){case 1:return K(n,rt=>z(`for (const ${i.code} of ${T.code}(${rt.code})) {
|
|
64
|
+
${Ae.G.join(`
|
|
65
|
+
`)}
|
|
66
|
+
${Ae.code}
|
|
67
|
+
}`,{type:2},[...i.G,...T.G,...P.G]));case 0:return z(`const ${i.code} = ${T.code};
|
|
68
|
+
${P.code}
|
|
69
|
+
if (${i.code} !== null) {
|
|
70
|
+
${Ae.G.join(`
|
|
71
|
+
`)}
|
|
72
|
+
${Ae.code}
|
|
73
|
+
}`,{type:2},[...i.G,...T.G,...P.G]);default:return ye("Unsupported generated code type for filterExpr")}})}),C]}function h1(e){return K(e,t=>z(`(function () {
|
|
74
|
+
let n = ${t.code};
|
|
75
|
+
while (n.nodeType !== /*DOCUMENT_NODE*/9) {
|
|
76
|
+
n = domFacade.getParentNode(n);
|
|
77
|
+
if (n === null) {
|
|
78
|
+
throw new Error('XPDY0050: the root node of the context node is not a document node.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return n;
|
|
82
|
+
})()`,{type:0},t.G))}function f1(e,t,n){return Xs(t,r=>{if(0<q(e,"lookup").length)return[ye("Unsupported: lookups"),null];var o=B(e,"predicates");let[a,i]=Tp(o,r,n);if(o=B(e,Bp),!o)return[ye("Unsupported test in step"),null];let[u,l]=Ep(o,!0,r,n);o=a===null?u:dr(u,a);let p=ct(l,i);return[K(o,A=>z(`((${A.code}) ? ${r.code} : null)`,{type:0},[...r.G,...A.G])),p]})}function m1(e,t,n){let r=q(e,"stepExpr");if(r.length===1){let u=B(r[0],"xpathAxis");if(u&&se(u)==="self")return f1(r[0],t,n)}let o=ta(n,ea(n,"contextItem"));t=(e=B(e,"rootExpr"))?nt(n,h1(o),"root"):o;let[a,i]=qs(r,!e,t,n);return[K(a,u=>z(`(function* (${o.code}) {
|
|
83
|
+
${u.G.join(`
|
|
84
|
+
`)}
|
|
85
|
+
${u.code}
|
|
86
|
+
})`,{type:1},[])),i]}function d1(e,t,n){let r=e[0];switch(r){case"contextItemExpr":return[t,null];case"pathExpr":return m1(e,t,n);case"andOp":return Ap(e,"&&",t,n);case"orOp":return Ap(e,"||",t,n);case"stringConstantExpr":return e=B(e,"value")[1]||"",e=yr(e),[z(e,{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":e:switch(r){case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":e=fp(e,r,t,n);break e;case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":let o=J($(e,["firstOperand","*"]),"type"),a=J($(e,["secondOperand","*"]),"type");e=o&&a?o.g===3&&a.g===3?fp(e,Ys[r],t,n):o.g===3?mp(e,"firstOperand","secondOperand",Ys[r],t,n):a.g===3?mp(e,"secondOperand","firstOperand",bw[Ys[r]],t,n):ye("General comparison for sequences is not implemented"):ye("types of compare are not known");break e;default:e=ye(`Unsupported compare type: ${r}`)}return[e,null];case"functionCallExpr":return[zw(e,t,n),null];default:return[ye(`Unsupported: the base expression '${r}'.`),null]}}function nt(e,t,n){return K(t,r=>{var o=e.o.get(r);return o||(o=ea(e,n),o=z(o,r.ta,[...r.G,`const ${o} = ${r.code};`]),e.o.set(r,o),e.o.set(o,o)),o})}function ea(e,t="v"){let n=e.v.get(t)||0;return e.v.set(t,n+1),`${t}${n}`}function ta(e,t){return t=z(t,{type:0},[]),e.o.set(t,t),t}var g1=class{constructor(e,t){this.o=new Map,this.v=new Map,this.Z=e,this.D=t,this.h=d1}};function Ip(e){let t=q(e,"*");if(e[0]==="pathExpr")return!0;for(let n of t)if(Ip(n))return!0;return!1}function y1(e,t,n){if(n=n||{},t=t||0,typeof e=="string"){e=ls(e);var r={Y:n.language==="XQuery3.1"||n.language==="XQueryUpdate3.1",debug:!1,version:n.language==="XPath4.0"||n.language==="XQuery4.0"||n.language==="XQueryUpdate4.0"?4:3.1};try{var o=zr(e,r)}catch(i){at(e,i)}}else o=Yo(e);if(e=B(o,"mainModule"),!e)return ye("Unsupported: XQuery Library modules are not supported.");if(B(e,"prolog"))return ye("Unsupported: XQuery Prologs are not supported.");if(r=n.defaultFunctionNamespaceURI===void 0?"http://www.w3.org/2005/xpath-functions":n.defaultFunctionNamespaceURI,e=new g1(n.namespaceResolver||up(null),r),n=new ko(new En(new Oo(e.Z,{},r,n.functionNameResolver||Hs("http://www.w3.org/2005/xpath-functions")))),te(o,n),n=B(o,"mainModule"))if(B(n,"prolog"))e=ye("Unsupported: XQuery.");else{var a=$(n,["queryBody","*"]);n=ta(e,"contextItem"),[r]=e.h(a,n,e),a=J(a,"type");e:switch(t){case 9:t=Vt(r,n,e),e=Ls(t,a,e);break e;case 7:e=Kw(r,a,n,e);break e;case 3:e=mr(r,a,n,e);break e;case 2:e=hp(r,a,n,e);break e;default:e=ye(`Unsupported: the return type '${t}'.`)}e.isAstAccepted&&(e=`
|
|
87
|
+
${e.G.join(`
|
|
88
|
+
`)}
|
|
89
|
+
return ${e.code};`,t=`
|
|
90
|
+
return (contextItem, domFacade, runtimeLib, options) => {
|
|
91
|
+
const {
|
|
92
|
+
errXPDY0002,
|
|
93
|
+
} = runtimeLib;`,Ip(o)&&(t+=`
|
|
94
|
+
if (!contextItem) {
|
|
95
|
+
throw errXPDY0002("Context is needed to evaluate the given path expression.");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!contextItem.nodeType) {
|
|
99
|
+
throw new Error("Context item must be subtype of node().");
|
|
100
|
+
}
|
|
101
|
+
`),e={code:t+(e+`}
|
|
102
|
+
//# sourceURL=generated.js`),isAstAccepted:!0})}else e=ye("Unsupported: Can not execute a library module.");return e}class w1 extends Error{constructor(t,n,r){var o=t.stack;o&&(o.includes(t.message)&&(o=o.substr(o.indexOf(t.message)+t.message.length).trim()),o=o.split(`
|
|
103
|
+
`),o.splice(10),o=o.map(a=>a.startsWith(" ")||a.startsWith(" ")?a:` ${a}`),o=o.join(`
|
|
104
|
+
`)),super(`Custom XPath function Q{${r}}${n} raised:
|
|
105
|
+
${t.message}
|
|
106
|
+
${o}`)}}function Cp(e,t,n){return t.g===0?e.isEmpty()?null:Rn(e.first(),n).next(0).value:t.g===2||t.g===1?e.N().map(r=>{if(g(r.type,47))throw Error("Cannot pass attribute nodes to custom functions");return Rn(r,n).next(0).value}):Rn(e.first(),n).next(0).value}function A1(e){if(typeof e=="object")return e;if(e=e.split(":"),e.length!==2)throw Error("Do not register custom functions in the default function namespace");let[t,n]=e;if(e=Xr[t],!e){if(e=`generated_namespace_uri_${t}`,Xr[t])throw Error("Prefix already registered: Do not register the same prefix twice.");Xr[t]=e}return{localName:n,namespaceURI:e}}function v1(e,t,n,r){let{namespaceURI:o,localName:a}=A1(e);if(!o)throw Va();let i=t.map(l=>dn(l)),u=dn(n);_u(o,a,i,u,function(l,p,A){var x=Array.from(arguments);x.splice(0,3),x=x.map((P,_)=>Cp(P,i[_],p));let C={currentContext:p.o,domFacade:p.h.h},T;try{T=r.apply(void 0,[C,...x])}catch(P){throw new w1(P,a,o)}return T&&typeof T=="object"&&Object.getOwnPropertySymbols(T).includes(ks)?f.create(T.zb):yo(p.h,T,u)})}var x1={callFunction(e,t,n,r,o){let a=ba(t,n,r.length);if(!a)throw Error("function not found for codegen function call");t=new Qn({L:null,Ba:0,sa:f.empty(),qa:{}});let i=new ho(e);return e=new Hi(!1,!1,i,null,null,o?o.currentContext:null,null),r=a.callFunction(t,e,null,...r.map((u,l)=>yo(i,u,a.j[l]))),Cp(r,{type:59,g:0},e)},errXPDY0002:Et},B1=(e,t,n,r)=>(n=n||new Wt,e()(t??null,n,x1,r));let Fp={"http://www.w3.org/2005/XQueryX":"xqx","http://www.w3.org/2007/xquery-update-10":"xquf","http://fontoxml.com/fontoxpath":"x"};function E1(e,t){switch(e){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:e,lb:t||"http://www.w3.org/2005/XQueryX"};case"deleteExpr":case"insertExpr":case"renameExpr":case"replaceExpr":case"transformExpr":return{localName:e,lb:"http://www.w3.org/2007/xquery-update-10"};case"x:stackTrace":return{localName:"stackTrace",lb:"http://fontoxml.com/fontoxpath"};default:return{localName:e,lb:"http://www.w3.org/2005/XQueryX"}}}function Gp(e,t,n,r,o){if(typeof n=="string")return n.length===0?null:t.createTextNode(n);if(!Array.isArray(n))throw new TypeError("JsonML element should be an array or string");var a=E1(n[0],r);r=a.localName,a=a.lb;let i=t.createElementNS(a,Fp[a]+":"+r),u=n[1];var l=1;if(typeof u=="object"&&!Array.isArray(u)){if(u!==null)for(var p of Object.keys(u))l=u[p],l!==null&&(p==="type"?l!==void 0&&e.setAttributeNS(i,a,"fontoxpath:"+p,wt(l)):(p!=="start"&&p!=="end"&&p!=="comment"||r!=="stackTrace"||(l=JSON.stringify(l)),o&&p==="prefix"&&l===""||e.setAttributeNS(i,a,Fp[a]+":"+p,l)));l=2}for(let A=l,x=n.length;A<x;++A)p=Gp(e,t,n[A],a,o),p!==null&&e.insertBefore(i,p,null);return i}function N1(e,t,n,r=wa){e=ls(e);let o;try{o=zr(e,{Y:t.language==="XQuery3.1"||t.language==="XQueryUpdate3.1"||t.language==="XQuery4.0"||t.language==="XQueryUpdate4.0",version:t.language==="XPath4.0"||t.language==="XQuery4.0"||t.language==="XQueryUpdate4.0"?4:3.1,debug:t.debug})}catch(l){at(e,l)}var a=new Oo(t.namespaceResolver||(()=>null),{},t.defaultFunctionNamespaceURI===void 0?"http://www.w3.org/2005/xpath-functions":t.defaultFunctionNamespaceURI,t.functionNameResolver||(()=>null));a=new En(a);var i=B(o,["mainModule","libraryModule"]),u=B(i,"moduleDecl");if(u){let l=se(B(u,"prefix"));u=se(B(u,"uri")),Bn(a,l,u)}return(i=B(i,"prolog"))&&Ds(i,a,!1,e),t.annotateAst!==!1&&hl(o,new ko(a)),a=new Wt,t=Gp(r,n,o,null,t.oc===!1),r.insertBefore(t,n.createComment(e),a.getFirstChild(t)),t}function T1(e){return Promise.resolve(e)}function I1(e,t={debug:!1,language:"XQuery3.1"}){try{var n=zr(e,{Y:!0,debug:t.debug,version:t.language==="XQuery4.0"||t.language==="XQueryUpdate4.0"?4:3.1})}catch(a){at(e,a)}if(hl(n,new ko),t=B(n,"libraryModule"),!t)throw Error("XQuery module must be declared in a library module.");n=B(t,"moduleDecl");var r=B(n,"uri");let o=se(r);if(n=B(n,"prefix"),r=se(n),n=new En(new Oo(()=>null,Object.create(null),"http://www.w3.org/2005/xpath-functions",Hs("http://www.w3.org/2005/xpath-functions"))),Bn(n,r,o),t=B(t,"prolog"),t!==null){let a;try{a=Ds(t,n,!0,e)}catch(i){at(e,i)}a.Ia.forEach(({namespaceURI:i})=>{if(o!==i)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.")}),oc(o,a)}else oc(o,{Ia:[],Va:[],pa:null,source:e});return o}let Qs=new Map;function Js(e){var t;e:{if(t=Lo.get(e)){for(let n of Object.keys(t))if(t[n]&&t[n].length){t=t[n][0].h;break e}}t=null}if(t)return t;if(Qs.has(e))return Qs.get(e);if(t=typeof e=="string"?zr(e,{Y:!1,version:4}):Yo(e),t=$(t,["mainModule","queryBody","*"]),t===null)throw Error("Library modules do not have a specificity");return t=is(t,{ra:!1,Y:!1}),Qs.set(e,t),t}function C1(e){return Js(e).D()}function F1(e,t){return _n(Js(e).o,Js(t).o)}var G1=new Wt;return typeof y<"u"&&(y.compareSpecificity=F1,y.compileXPathToJavaScript=y1,y.domFacade=G1,y.evaluateXPath=He,y.evaluateXPathToArray=Hw,y.evaluateXPathToAsyncIterator=cp,y.evaluateXPathToBoolean=Pw,y.evaluateXPathToFirstNode=$w,y.evaluateXPathToMap=jw,y.evaluateXPathToNodes=Xw,y.evaluateXPathToNumber=Lw,y.evaluateXPathToNumbers=Yw,y.evaluateXPathToString=qw,y.evaluateXPathToStrings=Qw,y.evaluateUpdatingExpression=Mw,y.evaluateUpdatingExpressionSync=kw,y.executeJavaScriptCompiledXPath=B1,y.executePendingUpdateList=Jw,y.getBucketForSelector=C1,y.getBucketsForNode=Yt,y.precompileXPath=T1,y.registerXQueryModule=I1,y.registerCustomXPathFunction=v1,y.parseScript=N1,y.profiler=Rw,y.createTypedValueFactory=Uw,y.finalizeModuleRegistration=br,y.Language=Sw,y.ReturnType=ke),y}).call(typeof window>"u"?void 0:window,pi,Ai),Qx=Ie.compareSpecificity,Jx=Ie.compileXPathToJavaScript,Kx=Ie.createTypedValueFactory,bx=Ie.domFacade,Vx=Ie.evaluateUpdatingExpression,Zx=Ie.evaluateUpdatingExpressionSync,_x=Ie.evaluateXPath,Wx=Ie.evaluateXPathToArray,zx=Ie.evaluateXPathToAsyncIterator,eB=Ie.evaluateXPathToBoolean,tB=Ie.evaluateXPathToFirstNode,nB=Ie.evaluateXPathToMap,rB=Ie.evaluateXPathToNodes,oB=Ie.evaluateXPathToNumber,aB=Ie.evaluateXPathToNumbers,vi=Ie.evaluateXPathToString,sB=Ie.evaluateXPathToStrings,iB=Ie.executeJavaScriptCompiledXPath,uB=Ie.executePendingUpdateList,lB=Ie.finalizeModuleRegistration,cB=Ie.getBucketForSelector,pB=Ie.getBucketsForNode,hB=Ie.Language,fB=Ie.parseScript,mB=Ie.precompileXPath,dB=Ie.profiler,gB=Ie.registerCustomXPathFunction,yB=Ie.registerXQueryModule,wB=Ie.ReturnType,xi=Ie;var{evaluateXPathToBoolean:AB,evaluateXPathToString:vB}=vi?Bi:xi,m0=(m,h,d,y)=>{try{return m(h[d],y)}catch(E){throw new Error(`binds: the ${d} of "${h.ref}" "${h.property}" failed: ${E.message}`)}};function d0(m,h){return m0(vB,m,"calculate",h)}function g0(m,h){return m.readonly!==void 0&&m0(AB,m,"readonly",h)}var xB=["https://schema.org/",{beltype:"urn:beltype:",csvw:"http://www.w3.org/ns/csvw#",Bind:"beltype:Bind",ref:{"@id":"beltype:ref","@type":"@id"},property:"beltype:property",calculate:"beltype:calculate",readonly:"beltype:readonly"}],y0=/^[A-Za-z][A-Za-z0-9_-]*$/,Ei=m=>m===null||typeof m=="string"||typeof m=="number"||typeof m=="boolean",A0=m=>m===null?"null":typeof m,BB=m=>m!==null&&typeof m=="object"&&m["@type"]==="csvw:Table";function v0(m,h={}){let d;try{d=JSON.parse(m)}catch(y){throw new Error(`graph: the data block is not JSON: ${y.message}`)}if(d===null||!Array.isArray(d["@graph"]))throw new Error("graph: the data block is not a JSON-LD document with an @graph");return EB(d["@graph"],{...h,context:d["@context"]})}function EB(m,h={}){let d=Object.hasOwn(h,"context")?h.context:xB,y=h.rows??new Map,E=structuredClone(m),I=[],F=new Map,j=[];for(let U of E){if(U["@type"]==="Bind"){j.push(U);continue}let R=U["@id"];if(typeof R!="string"||R==="")throw new Error(`graph: an item has no @id: ${JSON.stringify(U).slice(0,80)}`);if(F.has(R))throw new Error(`graph: two items are "${R}"`);for(let ne of Object.keys(U))if(!ne.startsWith("@")&&!y0.test(ne))throw new Error(`graph: "${R}" has the key ${JSON.stringify(ne)}, which does not match ${y0}`);let Q={id:R,node:U,parent:null,depth:0};I.push(Q),F.set(R,Q)}for(let U of I)for(let R of[U.node.hasPart??[]].flat()){let Q=F.get(R?.["@id"]);if(Q===void 0)throw new Error(`graph: "${U.id}" has a part that is no item: ${JSON.stringify(R)}`);if(Q.parent!==null)throw new Error(`graph: "${Q.id}" is a part of "${Q.parent.id}" and of "${U.id}"`);Q.parent=U}for(let U of I)for(let R=U.parent;R!==null;R=R.parent)if(++U.depth>I.length)throw new Error(`graph: "${U.id}" is in a cycle of parts`);for(let U of j){let R=F.get(U.ref);if(R===void 0||!Object.hasOwn(R.node,U.property)||!Ei(R.node[U.property]))throw new Error(`graph: a bind names "${U.ref}" "${U.property}", which is not a value an item holds`);if(U.calculate!==void 0&&j.some(Q=>Q!==U&&Q.calculate!==void 0&&Q.ref===U.ref&&Q.property===U.property))throw new Error(`graph: two binds calculate "${U.ref}" "${U.property}"`)}let Y=new Map(Array.from(y,([U,R])=>[U,R.map(Q=>Object.fromEntries(Object.entries(Q).map(([ne,pe])=>[ne,typeof pe=="object"&&pe!==null?pe.value:pe])))])),L=U=>{let R=U.parent===null?{}:L(U.parent);for(let[Q,ne]of Object.entries(U.node))Q.startsWith("@")||(Ei(ne)?R[Q]=ne:delete R[Q]);return R},ce=(U,R)=>{for(let Q=U;Q!==null;Q=Q.parent)if(Object.hasOwn(Q.node,R))return Ei(Q.node[R])?Q:null;return null},fe=(U,R,Q)=>j.find(ne=>ne.ref===U.id&&ne.property===R&&ne[Q]!==void 0),Je=U=>{let R=L(U);for(let[Q,ne]of Object.entries(U.node))BB(ne)&&(R[Q]=Y.get(ne["csvw:url"])??[]);return R},yt=(U,R)=>{for(let Q=U;Q!==null;Q=Q.parent)if(Q===R)return!0;return!1},ae=(U,R,Q)=>{let ne=I.filter(v=>yt(v,U)),pe=ne.map(v=>L(v)[R]);return U.node[R]=Q,ne.filter((v,Ke)=>L(v)[R]!==pe[Ke]).map(v=>v.id)},Ee=()=>{let U=[];for(let R of j){if(R.calculate===void 0)continue;let Q=F.get(R.ref),ne=R.property,pe=w0(Q.node[ne],d0(R,Je(Q)),Q.id,ne);pe!==Q.node[ne]&&U.push({item:Q.id,key:ne,value:pe,items:ae(Q,ne,pe)})}return U};return{stale:Ee(),items(){return I.map(U=>({id:U.id,type:U.node["@type"]??null,parent:U.parent===null?null:U.parent.id,depth:U.depth}))},properties(U){let R=F.get(U);if(R===void 0)return[];let Q=L(R);return Object.keys(Q).sort().map(ne=>{let pe=ce(R,ne);return{key:ne,type:A0(Q[ne]),value:Q[ne],own:pe===R,computed:fe(pe,ne,"calculate")!==void 0}})},get(U,R){let Q=F.get(U);return Q===void 0?void 0:L(Q)[R]},sheetText(){let U=F.get("#doc")??I.find(R=>R.parent===null);return NB(U===void 0?{}:L(U))},serialize(){return JSON.stringify({"@context":d,"@graph":E},null,2)},set(U,R,Q){let ne=F.get(U);if(ne===void 0)throw new RangeError(`graph: no item "${U}"`);let pe=ce(ne,R);if(pe===null)throw new RangeError(`graph: no key "${R}" on "${U}"`);if(fe(pe,R,"calculate")!==void 0)throw new RangeError(`graph: "${U}" "${R}" is computed (calculate) and cannot be set`);let v=fe(pe,R,"readonly");if(v!==void 0&&g0(v,Je(ne)))throw new RangeError(`graph: "${U}" "${R}" is read-only`);let Ke=w0(pe.node[R],Q,U,R);return Ke===L(ne)[R]?null:[{item:U,key:R,value:Ke,items:ae(ne,R,Ke)},...Ee()]}}}function w0(m,h,d,y){let E=String(h);switch(A0(m)){case"null":throw new RangeError(`graph: "${d}" "${y}" is null, and a null value cannot be set`);case"number":if(E.trim()===""||!Number.isFinite(Number(E)))throw new RangeError(`graph: ${JSON.stringify(E)} is not a finite number for "${d}" "${y}"`);return Number(E);case"boolean":if(E!=="true"&&E!=="false")throw new RangeError(`graph: ${JSON.stringify(E)} is not a boolean for "${d}" "${y}"`);return E==="true";default:return E}}function NB(m){return`:root{${Object.keys(m).sort().filter(d=>m[d]!==null).map(d=>`--beltype-val-${d}:${typeof m[d]=="string"?TB(m[d]):String(m[d])}`).join(";")}}`}function TB(m){return`"${m.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r\n|\r|\n/g,"\\a ")}"`}var IB=new Map([["meta","content"],["audio","src"],["embed","src"],["iframe","src"],["img","src"],["source","src"],["track","src"],["video","src"],["a","href"],["area","href"],["link","href"],["object","data"],["data","value"],["meter","value"],["time","datetime"]]);function Ni(m,h){let d=IB.get(m)??null;return d==="datetime"&&!h(d)?null:d}var CB=/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][-+]?\d+)?$/,FB=/^https?:\/\/schema\.org\//,uo=m=>(m??"").split(/\s+/).filter(Boolean),GB=(m,h)=>m==="value"&&CB.test(h)&&Number.isFinite(Number(h))?Number(h):h,OB={tag:m=>m.localName,attribute:(m,h)=>m.getAttribute(h),children:m=>Array.from(m.children),text:m=>m.textContent};var DB={...OB,setAttribute:(m,h,d)=>m.setAttribute(h,d),setText:(m,h)=>{m.textContent=h}};function x0(m,h,d=DB){let y=0;for(let{element:E,item:I,keys:F}of UB(m,d).fields){let j=F.map(L=>h.get(I,L)).find(L=>typeof L=="string"||typeof L=="number"||typeof L=="boolean");if(j===void 0)continue;let Y=Ni(d.tag(E),L=>d.attribute(E,L)!==null);Y===null?d.setText(E,String(j)):d.setAttribute(E,Y,String(j)),y++}return y}function UB(m,h){let d=(ae,Ee)=>h.attribute(ae,Ee)!==null,y=new Map,E=new Map,I=[],F=ae=>{y.set(ae,y.size);let Ee=h.attribute(ae,"id");Ee!==null&&!E.has(Ee)&&E.set(Ee,ae),d(ae,"itemscope")&&!d(ae,"itemprop")&&I.push(ae);for(let je of h.children(ae))F(je)};F(m);let j=new Map,Y=[],L=new Map,ce=0,fe=ae=>{let Ee=[],je=new Set([ae]),U=[...h.children(ae),...uo(h.attribute(ae,"itemref")).map(R=>E.get(R)).filter(Boolean)];for(;U.length>0;){let R=U.shift();je.has(R)||(je.add(R),d(R,"itemscope")||U.push(...h.children(R)),uo(h.attribute(R,"itemprop")).length>0&&Ee.push(R))}return Ee.sort((R,Q)=>y.get(R)-y.get(Q))},Je=ae=>{if(d(ae,"itemscope"))return{"@id":yt(ae)};let Ee=Ni(h.tag(ae),je=>d(ae,je));return Ee===null?h.text(ae):GB(Ee,h.attribute(ae,Ee)??"")},yt=ae=>{if(L.has(ae))return L.get(ae);let Ee=h.attribute(ae,"itemid")??`_:b${ce++}`;if(L.set(ae,Ee),!j.has(Ee)){let U={"@id":Ee},R=uo(h.attribute(ae,"itemtype")).map(Q=>Q.replace(FB,""));R.length>0&&(U["@type"]=R.length===1?R[0]:R),j.set(Ee,{node:U,values:new Map})}let{values:je}=j.get(Ee);for(let U of fe(ae)){let R=Je(U);d(U,"itemscope")||Y.push({element:U,item:Ee,keys:uo(h.attribute(U,"itemprop"))});let Q=JSON.stringify(R);for(let ne of uo(h.attribute(U,"itemprop"))){let pe=je.get(ne)??[];pe.some(v=>JSON.stringify(v)===Q)||pe.push(R),je.set(ne,pe)}}return Ee};for(let ae of I)yt(ae);return{nodes:Array.from(j.values(),({node:ae,values:Ee})=>{for(let[je,U]of Ee)ae[je]=U.length===1?U[0]:U;return ae}),fields:Y}}var RB='script[type="application/ld+json"]',B0="data-pdf-source",E0="",Fr={boxes:[],text:""},Ti=null;function SB(m){let h=new Map,d=JSON.parse(m)["@graph"]??[];for(let y of d)for(let[E,I]of Object.entries(y)){let F=I;F?.["@type"]==="csvw:Table"&&typeof F["csvw:url"]=="string"&&h.set(E,F["csvw:url"])}return h}function MB(m,h){for(let d of m.querySelectorAll("[itemprop]")){let y=h[d.getAttribute("itemprop")];if(y===void 0)continue;let E=typeof y=="string"?y:y.text;d.localName==="data"&&d.setAttribute("value",typeof y=="string"?y:String(y.value)),(d.localName!=="data"||typeof y!="string")&&(d.textContent=E)}}function N0(m,h){let d=m.querySelector(RB);if(!d)throw new Error('the template has no data block (<script type="application/ld+json">)');let y=m.querySelector("[itemscope][itemid]:not([itemprop])")?.getAttribute("itemid");if(!y)throw new Error("the template has no top-level item (an element with itemscope and itemid, and no itemprop)");let E=d.textContent,I=SB(E);for(let j of Object.keys(h.rows))if(!I.has(j))throw new Error(`the data names a table "${j}", and the block has ${[...I.keys()].join(", ")||"none"}`);let F=v0(E,{rows:new Map([...I].map(([j,Y])=>[Y,h.rows[j]??[]]))});for(let[j,Y]of Object.entries(h.values))F.set(y,j,Y);x0(m.documentElement,F);for(let j of[...m.querySelectorAll("template[data-repeat]")]){let Y=j.getAttribute("data-repeat"),L=j.content.firstElementChild;if(L)for(let ce of h.rows[Y]??[]){let fe=L.cloneNode(!0);fe.setAttribute("itemscope",""),fe.setAttribute("itemprop",Y),MB(fe,ce),j.before(fe)}j.remove()}d.remove()}var T0=m=>({boxes:[...m.body.children].map(h=>h.outerHTML),text:[...m.body.childNodes].filter(h=>h.nodeType===3).map(h=>h.data.trim()).join("")});function ZE(m,h){E0=m,N0(document,h),Fr=T0(document),Ti=document.head.querySelector("[itemprop]")?"a field stands in the head":document.body.querySelector(":scope > :is(script, style, template, link, meta)")?"the body holds a child that is no box":null}function _E(m){if(Ti)return{again:Ti};let h=window.__beltypeCicero;if(!h?.box||!h.patch)return{again:"the page shows no presented run"};let d=new DOMParser().parseFromString(E0,"text/html");N0(d,m);let y=T0(d);if(y.boxes.length!==Fr.boxes.length)return{again:`the top-level boxes went from ${Fr.boxes.length} to ${y.boxes.length}`};if(y.text!==Fr.text)return{again:"text directly in the body changed"};let E=[...d.body.children],I=null,F=0;for(let[j,Y]of E.entries()){if(y.boxes[j]===Fr.boxes[j])continue;let L=h.box(j);if(!L)return{again:`box ${j} is no flow block`};let ce=L.getAttribute(B0);ce!==null&&Y.setAttribute(B0,ce);let fe=h.patch(j,[],document.adoptNode(Y));if(fe===null)return{again:`Cicero's patch door refused box ${j}`};I??=fe,F++}return Fr=y,{resumeAt:I,changed:F}}export{_E as keep,ZE as seat};
|