@jinntec/fore 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fore-dev.js +2 -36
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -30
- package/dist/fore.js.map +1 -1
- package/index.js +12 -0
- package/package.json +9 -5
- package/resources/fore.css +178 -92
- package/src/DependencyNotifyingDomFacade.js +1 -2
- package/src/ForeElementMixin.js +31 -5
- package/src/actions/abstract-action.js +379 -297
- package/src/actions/fx-action.js +0 -1
- package/src/actions/fx-append.js +1 -2
- package/src/actions/fx-confirm.js +12 -0
- package/src/actions/fx-copy.js +0 -1
- package/src/actions/fx-delete.js +31 -9
- package/src/actions/fx-dispatch.js +19 -5
- package/src/actions/fx-hide.js +19 -0
- package/src/actions/fx-insert.js +72 -8
- package/src/actions/fx-load.js +253 -0
- package/src/actions/fx-message.js +22 -7
- package/src/actions/fx-refresh.js +11 -1
- package/src/actions/fx-reload.js +12 -2
- package/src/actions/fx-replace.js +5 -4
- package/src/actions/fx-reset.js +48 -0
- package/src/actions/fx-return.js +0 -1
- package/src/actions/fx-send.js +40 -2
- package/src/actions/fx-setfocus.js +25 -7
- package/src/actions/fx-setvalue.js +32 -4
- package/src/actions/fx-show.js +14 -2
- package/src/actions/fx-toggle.js +0 -1
- package/src/actions/fx-update.js +9 -0
- package/src/events.js +0 -1
- package/src/fore.js +118 -63
- package/src/functions/common-function.js +28 -0
- package/src/fx-bind.js +7 -7
- package/src/fx-fore.js +152 -55
- package/src/fx-instance.js +55 -17
- package/src/fx-model.js +31 -33
- package/src/fx-submission.js +50 -47
- package/src/getInScopeContext.js +8 -10
- package/src/lab/fore-component.js +90 -0
- package/src/lab/instance-inspector.js +56 -0
- package/src/lab/template.html +16 -0
- package/src/relevance.js +27 -1
- package/src/tools/adi.js +1056 -0
- package/src/tools/fx-action-log.js +662 -0
- package/src/tools/fx-devtools.js +444 -0
- package/src/tools/fx-dom-inspector.js +609 -0
- package/src/tools/fx-json-instance.js +435 -0
- package/src/tools/fx-log-item.js +133 -0
- package/src/tools/fx-log-settings.js +474 -0
- package/src/tools/fx-minimap.js +194 -0
- package/src/tools/helpers.js +132 -0
- package/src/ui/abstract-control.js +41 -3
- package/src/ui/fx-action-log.js +358 -0
- package/src/ui/fx-alert.js +0 -1
- package/src/ui/fx-container.js +14 -3
- package/src/ui/fx-control.js +553 -474
- package/src/ui/fx-dialog.js +2 -0
- package/src/ui/fx-dom-inspector.js +1255 -0
- package/src/ui/fx-group.js +3 -4
- package/src/ui/fx-hint.js +2 -4
- package/src/ui/fx-inspector.js +5 -6
- package/src/ui/fx-items.js +55 -14
- package/src/ui/fx-output.js +36 -17
- package/src/ui/fx-repeat-attributes.js +10 -43
- package/src/ui/fx-repeat.js +5 -7
- package/src/ui/fx-switch.js +14 -3
- package/src/ui/fx-trigger.js +13 -1
- package/src/xpath-evaluation.js +109 -26
- package/src/xpath-util.js +55 -1
package/dist/fore-dev.js
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
function e(e,t,n,r){const o={op:t,func:n,data:r};return e.push(o),o}function t(e,t){return e}class n{constructor(){this.program=[]}test(t,n){return e(this.program,5,t,void 0===n?null:n)}jump(t){return e(this.program,3,null,t)}record(n,r){return e(this.program,4,void 0===r?t:r,n)}bad(t=1){return e(this.program,1,null,t)}accept(){return e(this.program,0,null,null)}fail(t){return e(this.program,2,t||null,null)}}class r{constructor(e,t,n){this.programLength=e,this.maxFromByPc=t,this.maxSurvivorFromByPc=n}static fromProgram(e){const t=e.length,n=[],o=[];return e.forEach((e=>{n.push(0),o.push(0)})),e.forEach(((e,r)=>{switch(e.op){case 2:if(null===e.func)return;if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 1:case 4:if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 3:e.data.forEach((e=>{if(e<0||e>=t)throw new Error("Invalid program: program could run past end");n[e]+=1}));break;case 5:if(r+1>=t)throw new Error("Invalid program: program could run past end");o[r+1]+=1;break;case 0:o[r]+=1}})),new r(t,n,o)}static createStub(e){const t=[],n=[];for(let r=0;r<e;++r)t.push(e),n.push(e);return new r(e,t,n)}}class o{constructor(e){this.acceptingTraces=e,this.success=e.length>0}}class i{constructor(e){this.t=0,this.i=0,this.h=new Uint16Array(e),this.l=new Uint8Array(e)}getBadness(e){return this.l[e]}add(e,t){this.l[e]=t>255?255:t;const n=function(e,t,n,r,o){let i=r,a=o;for(;i<a;){const r=i+a>>>1;n<t[e[r]]?a=r:i=r+1}return i}(this.h,this.l,t,this.i,this.t);this.h.copyWithin(n+1,n,this.t),this.h[n]=e,this.t+=1}reschedule(e,t){const n=Math.max(this.l[e],t>255?255:t);if(this.l[e]!==n){const t=this.h.indexOf(e,this.i);if(t<0||t>=this.t)return void(this.l[e]=n);this.h.copyWithin(t,t+1,this.t),this.t-=1,this.add(e,n)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}}class a{constructor(e){this.o=[];let t=e.length;e.forEach((e=>{this.o.push(e>0?t:-1),t+=e})),this.u=new Uint16Array(t)}clear(){this.u.fill(0,0,this.o.length)}add(e,t){const n=this.u[t],r=this.o[t];this.u[t]+=1,this.u[r+n]=e}has(e){return this.u[e]>0}forEach(e,t){const n=this.u[e],r=this.o[e];for(let e=r;e<r+n;++e)t(this.u[e])}}function s(e,t,n=!1){return null===e?t:Array.isArray(e)?(-1===e.indexOf(t)&&(n&&(e=e.slice()),e.push(t)),e):e===t?e:[e,t]}class u{constructor(e,t){this.prefixes=e,this.record=t}}function c(e,t){let n;if(null===t){if(!Array.isArray(e))return e;n=e}else n=e===u.EMPTY?[]:Array.isArray(e)?e:[e];return new u(n,t)}u.EMPTY=new u([],null);class l{constructor(e){this.p=[],this.v=[];for(let t=0;t<e;++t)this.p.push(0),this.v.push(null)}mergeTraces(e,t,n,r,o,i){let a=!1;return n.forEach(t,(t=>{const n=this.trace(t,r,o,i);var u,c,l;c=n,l=a,e=null===(u=e)?c:null===c?u:Array.isArray(c)?c.reduce(((e,t)=>s(e,t,e===c)),u):s(u,c,l),a=e===n})),e}trace(e,t,n,r){switch(this.p[e]){case 2:return this.v[e];case 1:return null}this.p[e]=1;let o=null;const i=t[e];if(null!==i)o=i;else if(!n.has(e))throw new Error("Trace without source at pc "+e);if(o=this.mergeTraces(o,e,n,t,n,r),null!==o){const t=r[e];null!==t&&(o=c(o,t))}return this.v[e]=o,this.p[e]=2,o}buildSurvivorTraces(e,t,n,r,o){for(let i=0,a=e.length;i<a;++i){if(!n.has(i)){t[i]=null;continue}this.v.fill(null),this.p.fill(0);const a=this.mergeTraces(null,i,n,e,r,o);if(null===a)throw new Error("No non-cyclic paths found to survivor "+i);t[i]=c(a,null)}this.v.fill(null)}}class p{constructor(e){this.g=[],this.k=[],this.m=[],this.A=new a(e.maxFromByPc),this.T=new a(e.maxSurvivorFromByPc),this.S=new l(e.programLength);for(let t=0;t<e.programLength;++t)this.g.push(null),this.k.push(null),this.m.push(null);this.k[0]=u.EMPTY}reset(e){this.A.clear(),this.T.clear(),this.g.fill(null),e&&(this.k.fill(null),this.m.fill(null),this.k[0]=u.EMPTY)}record(e,t){this.g[e]=t}has(e){return this.A.has(e)||null!==this.k[e]}add(e,t){this.A.add(e,t)}hasSurvivor(e){return this.T.has(e)}addSurvivor(e,t){this.T.add(e,t)}buildSurvivorTraces(){const e=this.k;this.S.buildSurvivorTraces(e,this.m,this.T,this.A,this.g),this.k=this.m,this.m=e}getTraces(e){const t=e.reduce(((e,t)=>s(e,this.k[t])),null);return null===t?[]:Array.isArray(t)?t:[t]}}class h{constructor(e){this.I=[],this.N=new i(e.programLength),this.M=new i(e.programLength),this.P=new p(e)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(e,t,n){const r=this.P.has(t);this.P.add(e,t);const o=this.N.getBadness(e)+n;r?this.N.reschedule(t,o):this.N.add(t,o)}stepToNextGeneration(e,t){const n=this.P.hasSurvivor(t);this.P.addSurvivor(e,t);const r=this.N.getBadness(e);n?this.M.reschedule(t,r):this.M.add(t,r)}accept(e){this.I.push(e),this.P.addSurvivor(e,e)}fail(e){}record(e,t){this.P.record(e,t)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);const e=this.N;e.reset(),this.N=this.M,this.M=e}getAcceptingTraces(){return this.P.getTraces(this.I)}}class f{constructor(e){this.U=[],this.G=e,this.V=r.fromProgram(e),this.U.push(new h(this.V))}execute(e,t){const n=this.U.pop()||new h(this.V);n.reset();const r=e.length;let i,a=-1;do{let o=n.getNextThreadPc();if(null===o)break;for(++a,i=a>=r?null:e[a];null!==o;){const e=this.G[o];switch(e.op){case 0:null===i?n.accept(o):n.fail(o);break;case 2:{const r=e.func;if(null===r||r(t)){n.fail(o);break}n.step(o,o+1,0);break}case 1:n.step(o,o+1,e.data);break;case 5:if(null===i){n.fail(o);break}if(!(0,e.func)(i,e.data,t)){n.fail(o);break}n.stepToNextGeneration(o,o+1);break;case 3:{const t=e.data,r=t.length;if(0===r){n.fail(o);break}for(let e=0;e<r;++e)n.step(o,t[e],0);break}case 4:{const r=(0,e.func)(e.data,a,t);null!=r&&n.record(o,r),n.step(o,o+1,0);break}}o=n.getNextThreadPc()}n.nextGeneration()}while(null!==i);const s=new o(n.getAcceptingTraces());return n.reset(),this.U.push(n),s}}function d(e){return t=>t===e}function m(e,t){if(null===e||null===t)throw new Error("unescaped hyphen may not be used as a range endpoint");if(t<e)throw new Error("character range is in the wrong order");return n=>e<=n&&n<=t}function g(e){return!0}function y(){return!1}function v(e,t){return n=>e(n)||t(n)}function w(e,t){switch(t.kind){case"predicate":return void e.test(t.value);case"regexp":return void A(e,t.value,!1)}}function A(e,t,n){const r=e.program.length,o=e.jump([]);n&&(o.data.push(e.program.length),e.test((()=>!0)),e.jump([r]));const i=[];if(t.forEach((t=>{o.data.push(e.program.length),function(e,t){t.forEach((t=>{!function(e,t){const[n,{min:r,max:o}]=t;if(null!==o){for(let t=0;t<r;++t)w(e,n);for(let t=r;t<o;++t){const t=e.jump([]);t.data.push(e.program.length),w(e,n),t.data.push(e.program.length)}}else if(r>0){for(let t=0;t<r-1;++t)w(e,n);const t=e.program.length;w(e,n),e.jump([t]).data.push(e.program.length)}else{const t=e.program.length,r=e.jump([]);r.data.push(e.program.length),w(e,n),e.jump([t]),r.data.push(e.program.length)}}(e,t)}))}(e,t),i.push(e.jump([]))})),i.forEach((t=>{t.data.push(e.program.length)})),n){const t=e.program.length,n=e.jump([]);n.data.push(e.program.length),e.test((()=>!0)),e.jump([t]),n.data.push(e.program.length)}}function x(e,t){return{success:!0,offset:e,value:t}}function b(e){return x(e,void 0)}function E(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function N(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?x(r,e):E(n,[e])}}function B(e,t){return(n,r)=>{const o=e(n,r);return o.success?x(o.offset,t(o.value)):o}}function T(e,t,n,r){return(o,i)=>{const a=e(o,i);return a.success?t(a.value)?a:E(i,n,r):a}}function I(e,t){return(n,r)=>{let o=null;for(const i of e){const e=i(n,r);if(e.success)return e;if(null===o||e.offset>o.offset?o=e:e.offset===o.offset&&void 0===t&&(o.expected=o.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==o?void 0:o.expected)||[],o&&(o.expected=t),o||E(r,t)}}function C(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:x(n,null)}}function S(e){return(t,n)=>{let r=[],o=n;for(;;){const n=e(t,o);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===o)break;o=n.offset}return x(o,r)}}function O(e,t,n){return(r,o)=>{const i=e(r,o);if(!i.success)return i;const a=t(r,i.offset);return a.success?x(a.offset,n(i.value,a.value)):a}}function R(e){return O(e,S(e),((e,t)=>[e].concat(t)))}function D(e,t){return e}function U(e,t){return t}function M(e,t){return O(e,t,U)}function k(e,t){return O(e,t,D)}function F(e,t,n,r=!1){return M(e,r?P(k(t,n)):k(t,n))}function G(e,t){return(n,r)=>e(n,r).success?E(r,t):b(r)}function P(e){return(t,n)=>{const r=e(t,n);return r.success?r:E(r.offset,r.expected,!0)}}const H=(e,t)=>e.length===t?b(t):E(t,["end of input"]),_=["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"],j={};function X(e){return e.codePointAt(0)}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(((e,t)=>{j[e]=t}));const L=e=>-1===e||-2===e;function $(e){return t=>!L(t)&&!e(t)}function q(e,t){return null===t?e:n=>e(n)&&!t(n)}const V=function(e,t){const n=new Map;let r=0;return["BasicLatin","Latin-1Supplement","LatinExtended-A","LatinExtended-B","IPAExtensions","SpacingModifierLetters","CombiningDiacriticalMarks","GreekandCoptic|Greek","Cyrillic","CyrillicSupplement","Armenian","Hebrew","Arabic","Syriac","ArabicSupplement","Thaana","NKo","Samaritan","Mandaic","SyriacSupplement",null,"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",null,"LinearA",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",null,"OldSogdian","Sogdian",null,"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",null,"Nandinagari","ZanabazarSquare","Soyombo",null,"PauCinHau",null,"Bhaiksuki","Marchen",null,"MasaramGondi","GunjalaGondi",null,"Makasar",null,"TamilSupplement","Cuneiform","CuneiformNumbersandPunctuation","EarlyDynasticCuneiform",null,"EgyptianHieroglyphs","EgyptianHieroglyphFormatControls",null,"AnatolianHieroglyphs",null,"BamumSupplement","Mro",null,"BassaVah","PahawhHmong",null,"Medefaidrin",null,"Miao",null,"IdeographicSymbolsandPunctuation","Tangut","TangutComponents",null,"KanaSupplement","KanaExtended-A","SmallKanaExtension","Nushu",null,"Duployan","ShorthandFormatControls",null,"ByzantineMusicalSymbols","MusicalSymbols","AncientGreekMusicalNotation",null,"MayanNumerals","TaiXuanJingSymbols","CountingRodNumerals",null,"MathematicalAlphanumericSymbols","SuttonSignWriting",null,"GlagoliticSupplement",null,"NyiakengPuachueHmong",null,"Wancho",null,"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",null,"CJKUnifiedIdeographsExtensionB",null,"CJKUnifiedIdeographsExtensionC","CJKUnifiedIdeographsExtensionD","CJKUnifiedIdeographsExtensionE","CJKUnifiedIdeographsExtensionF",null,"CJKCompatibilityIdeographsSupplement",null,"Tags",null,"VariationSelectorsSupplement",null,"SupplementaryPrivateUseArea-A|PrivateUse","SupplementaryPrivateUseArea-B|PrivateUse"].forEach(((e,o)=>{const i=t[o];null!==e&&e.split("|").forEach((e=>{const t=n.get(e),o=m(r,r+i-1);n.set(e,t?v(t,o):o)})),r+=i})),n}(0,[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,144,384,128,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,128,48,64,112,32,128,80,48,80,48,96,32,80,48,48,80,128,128,128,96,160,128,96,32,80,48,64,192,80,80,96,160,96,80,96,16,64,256,112,80,64,96,80,304,32,192,64,1024,128,208,2736,1072,16,4032,640,8576,576,48,96,48,144,688,96,96,160,64,32,6144,768,9472,256,48,64,400,2304,160,16,4944,256,256,80,144,32,96,32,128,1024,688,1360,48,208,80,368,64,1280,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,1280,42720,32,4160,224,5776,7488,3088,544,722400,128,128,240,65040,65536,65536]),Y=function(e){const t=new Map,n="bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcABATBGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKB0GUBAGHBUHOcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABHHAIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBCGAHCIDBAHCBAHDBGHBBAGCBEGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBGGABAGBHBBBKJBAGBBMHBIBBAGHBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBBIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHFBBKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGMBAGDHCBKGRHCTBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcABAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAhABAAHDIAGuHAIAHEIAHAIEHAIBGGBDKJTGaJHIaIBCHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH5BAHEgVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYfBPHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBB6nBAACuBADuBAABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMBvaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGaBEajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm1mBABJa/mvHFABPGUFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDALBBABCCBvGAFBDAGGHAGCHAGDHAGWIBHBIAaDBDMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDHBHjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZPBQmqFAAQAPABPG/BBG1BnGLYAaABBHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaLBDaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTAhPCAAm2EAABIGVBJGHhXCAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMehACAAGcMJGABHGVHKMDTEhFCAAGWBIIAHAIAG0HOTGBDMTKJBOHCIAGsICHDIBHBTBcATDBKcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBBIGiHATBGABIHBIAGvICHIIBGDTDHDTABBKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAhABAAGGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJBATABATAHAGABfGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGABGKJB1GaBBHCIBHDIAHEBDKJMBTCaAh/CAAGrICHIIAHBTAhjBAACfDfKJMIBLGAhfCAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBcG4hGEAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBhGDAAMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAh7qAAmuQAABAcIhG/AAmGJAAh4GCAm4IAABGGeBAKJBDTBhfBAAGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFABbm3fBABHmyLAAhMUCAmeEAABwGCBQGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbNBA61DAABJamBBa7IBHCaCIFcHHHaBHGadHDa6BW6BBAAHCaAhZCAAMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPVAAHGBAHQBBHGBAHBBAHEhUDAAGsBCHGFGBBKJBDGAaAhvFAAGrHDKJBEYAh/TAAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMMBC6cBAABCa8B4acBMarBDaIBGaBBNaFhZCAA66DAAZE6VLAABJaMBCaKBE6zBAABL6YBAABGaLBTaLBDa3BHaJBFanBHadhRBAAaLBA6kBAABAaDBCaoBBaFBCacBB6GCAABLaNBBaDBDaCBEaCBMaFhpVAAmWbKABom0ABABKmdDAABBmBaBABNmw0BAhewAAmdIAAhiXwCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA".split(""),r=_.map((()=>[]));let o=0,i=0;for(;i<n.length;){const e=j[n[i]],t=(31&e)-2;let a=1+j[n[i+1]];switch(32&e?(a+=j[n[i+2]]<<6,a+=j[n[i+3]]<<12,a+=j[n[i+4]]<<18,i+=5):i+=2,t){case-2:{let e=0;for(let t=o;t<o+a;++t)r[e].push(d(t)),e=(e+1)%2;break}case-1:break;default:{const e=r[t];1===a?e.push(d(o)):e.push(m(o,o+a-1));break}}o+=a}const a=new Map;return _.forEach(((e,n)=>{const o=r[n].reduce(v,y);t.set(e,o);const i=e.charAt(0),s=a.get(i)||[];a.set(i,s),s.push(o)})),a.forEach(((e,n)=>{t.set(n,e.reduce(v,y))})),t}();function Q(e){return 32===e||9===e||10===e||13===e}const J=[d(X(":")),m(X("A"),X("Z")),d(X("_")),m(X("a"),X("z")),m(192,214),m(216,246),m(192,214),m(216,246),m(248,767),m(880,893),m(895,8191),m(8204,8205),m(8304,8591),m(11264,12271),m(12289,55295),m(63744,64975),m(65008,65533),m(65536,983039)].reduce(v),z=[J,d(X("-")),d(X(".")),m(X("0"),X("9")),d(183),m(768,879),m(8255,8256)].reduce(v),K=Y.get("Nd"),W=$(K),Z=q(m(0,1114111),[Y.get("P"),Y.get("Z"),Y.get("C")].reduce(v)),ee=$(Z);function te(e){return 10!==e&&13!==e&&!L(e)}const ne={s:Q,S:$(Q),i:J,I:$(J),c:z,C:$(z),d:K,D:W,w:Z,W:ee},re=N("*"),oe=N("\\"),ie=N("{"),ae=N("}"),se=N("["),ue=N("]"),ce=N("^"),le=N("$"),pe=N(","),he=N("-"),fe=N("("),de=N(")"),me=N("."),ge=N("|"),ye=N("+"),ve=N("?"),we=N("-["),Ae=X("0");function xe(e){return[...e].map((e=>e.codePointAt(0)))}var be=Object.freeze({__proto__:null,compile:function(e,t={language:"xsd"}){const r=function(e){function t(e){return new Set(e.split("").map((e=>X(e))))}function n(e,t){const n=e.codePointAt(t);return void 0===n?E(t,["any character"]):x(t+String.fromCodePoint(n).length,n)}const r="xpath"===e.language?M(oe,I([B(N("n"),(()=>10)),B(N("r"),(()=>13)),B(N("t"),(()=>9)),B(I([oe,ge,me,he,ce,ve,re,ye,ie,ae,le,fe,de,se,ue]),(e=>X(e)))])):M(oe,I([B(N("n"),(()=>10)),B(N("r"),(()=>13)),B(N("t"),(()=>9)),B(I([oe,ge,me,he,ce,ve,re,ye,ie,ae,fe,de,se,ue]),(e=>X(e)))]));function o(e,r){const o=t(r);return O(N(e),C(T(n,(e=>o.has(e)),r.split(""))),((e,t)=>function(e){const t=Y.get(e);if(null==t)throw new Error(e+" is not a valid unicode category");return t}(null===t?e:e+String.fromCodePoint(t))))}const i=I([o("L","ultmo"),o("M","nce"),o("N","dlo"),o("P","cdseifo"),o("Z","slp"),o("S","mcko"),o("C","cfon")]),a=[m(X("a"),X("z")),m(X("A"),X("Z")),m(X("0"),X("9")),d(45)].reduce(v),s=I([i,B(M(N("Is"),function(e){return(t,n)=>{const r=e(t,n);return r.success?x(r.offset,t.slice(n,r.offset)):r}}(R(T(n,a,["block identifier"])))),(t=>function(e,t){const n=V.get(e);if(void 0===n){if(t)return g;throw new Error(`The unicode block identifier "${e}" is not known.`)}return n}(t,"xpath"!==e.language)))]),u=F(N("\\p{"),s,ae,!0),c=B(F(N("\\P{"),s,ae,!0),$),l=M(oe,B(I("sSiIcCdDwW".split("").map((e=>N(e)))),(e=>ne[e]))),p=B(me,(()=>te)),h=I([l,u,c]),f=t("\\[]"),y=I([r,T(n,(e=>!f.has(e)),["unescaped character"])]),w=I([B(he,(()=>null)),y]),A=O(w,M(he,w),m);function b(e,t){return[e].concat(t||[])}const U=B(function(e){return(t,n)=>{const r=e(t,n);return r.success?x(n,r.value):r}}(I([ue,we])),(()=>null)),_=X("-"),j=I([B(k(k(he,G(se,["not ["])),U),(()=>_)),M(G(he,["not -"]),y)]),L=I([O(B(j,d),I([function(e,t){return L(e,t)},U]),b),O(I([A,h]),I([J,U]),b)]),Q=I([O(B(y,d),I([L,U]),b),O(I([A,h]),I([J,U]),b)]);function J(e,t){return Q(e,t)}const z=B(Q,(e=>e.reduce(v))),K=B(M(ce,z),$),W=O(I([M(G(ce,["not ^"]),z),K]),C(M(he,(function(e,t){return Z(e,t)}))),q),Z=F(se,W,ue,!0),ee="xpath"===e.language?I([B(r,d),h,Z,p,B(ce,(()=>e=>-1===e)),B(le,(()=>e=>-2===e))]):I([B(r,d),h,Z,p]),xe="xpath"===e.language?t(".\\?*+{}()|^$[]"):t(".\\?*+{}()|[]"),be=T(n,(e=>!xe.has(e)),["NormalChar"]),Ee=B(M(oe,O(B(T(n,m(X("1"),X("9")),["digit"]),(e=>e-Ae)),S(B(T(n,m(Ae,X("9")),["digit"]),(e=>e-Ae))),((e,t)=>{t.reduce(((e,t)=>10*e+t),e)}))),(e=>{throw new Error("Backreferences in XPath patterns are not yet implemented.")})),Ne="xpath"===e.language?I([B(be,(e=>({kind:"predicate",value:d(e)}))),B(ee,(e=>({kind:"predicate",value:e}))),B(F(fe,M(C(N("?:")),Oe),de,!0),(e=>({kind:"regexp",value:e}))),Ee]):I([B(be,(e=>({kind:"predicate",value:d(e)}))),B(ee,(e=>({kind:"predicate",value:e}))),B(F(fe,Oe,de,!0),(e=>({kind:"regexp",value:e})))]),Be=B(R(B(T(n,m(Ae,X("9")),["digit"]),(e=>e-Ae))),(e=>e.reduce(((e,t)=>10*e+t)))),Te=I([O(Be,M(pe,Be),((e,t)=>{if(t<e)throw new Error("quantifier range is in the wrong order");return{min:e,max:t}})),O(Be,pe,(e=>({min:e,max:null}))),B(Be,(e=>({min:e,max:e})))]),Ie="xpath"===e.language?O(I([B(ve,(()=>({min:0,max:1}))),B(re,(()=>({min:0,max:null}))),B(ye,(()=>({min:1,max:null}))),F(ie,Te,ae,!0)]),C(ve),((e,t)=>e)):I([B(ve,(()=>({min:0,max:1}))),B(re,(()=>({min:0,max:null}))),B(ye,(()=>({min:1,max:null}))),F(ie,Te,ae,!0)]),Ce=S(O(Ne,B(C(Ie),(e=>null===e?{min:1,max:1}:e)),((e,t)=>[e,t]))),Se=O(Ce,S(M(ge,P(Ce))),((e,t)=>[e].concat(t)));function Oe(e,t){return Se(e,t)}const Re=function(e){return O(e,H,D)}(Se);return function(e){let t;try{t=Re(e,0)}catch(t){throw new Error(`Error parsing pattern "${e}": ${t instanceof Error?t.message:t}`)}return t.success?t.value:function(e,t,n){const r=n.map((e=>`"${e}"`));throw new Error(`Error parsing pattern "${e}" at offset ${t}: expected ${r.length>1?"one of "+r.join(", "):r[0]} but found "${e.slice(t,t+1)}"`)}(e,t.offset,t.expected)}}(t)(e),o=function(e){const t=new n;return e(t),new f(t.program)}((e=>{A(e,r,"xpath"===t.language),e.accept()}));return function(e){const n="xpath"===t.language?[-1,...xe(e),-2]:xe(e);return o.execute(n).success}}});function Ee(e,t){return{success:!0,offset:e,value:t}}function Ne(e){return Ee(e,void 0)}function Be(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function Te(e){return e>65535?2:1}function Ie(e,t){return(n,r)=>{const o=n.codePointAt(r);return void 0!==o&&e(o)?Ne(r+Te(o)):Be(r,t)}}function Ce(e,t){return(n,r)=>{const o=e(n,r);return o.success?Ee(o.offset,t(o.value)):o}}function Se(e){return(t,n)=>{let r=[],o=n;for(;;){const n=e(t,o);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===o)break;o=n.offset}return Ee(o,r)}}function Oe(e){return(t,n)=>{let r=n;for(;;){const n=e(t,r);if(!n.success){if(n.fatal)return n;break}if(n.offset===r)break;r=n.offset}return Ne(r)}}function Re(e,t,n){return(r,o)=>{const i=e(r,o);if(!i.success)return i;const a=t(r,i.offset);return a.success?Ee(a.offset,n(i.value,a.value)):a}}function De(e,t){return e}function Ue(e,t){return t}function Me(e,t){return Re(e,t,Ue)}function ke(e,t){return Re(e,t,De)}function Fe(e,t){return(n,r)=>e(n,r).success?Be(r,t):Ne(r)}function Ge(e){return(t,n)=>{const r=e(t,n);return r.success?r:Be(r.offset,r.expected,!0)}}const Pe=(e,t)=>e.length===t?Ne(t):Be(t,["end of input"]);function He(e){const t=[];let n=e.next();for(;!n.done;)t.push(n.value),n=e.next();return[t,n.value]}var _e=Object.freeze({__proto__:null,codepoint:Ie,codepoints:function(e,t){return(n,r)=>{const o=r;for(;;){const t=n.codePointAt(r);if(void 0===t)break;if(!e(t))break;r+=t>65535?2:1}return void 0!==t&&r===o?Be(r,t):Ne(r)}},collect:He,complete:function(e){return Re(e,Pe,De)},consume:function(e){return Ce(e,(()=>{}))},cut:Ge,delimited:function(e,t,n,r=!1){return Me(e,r?Ge(ke(t,n)):ke(t,n))},dispatch:function(e,t,n=0,r=[]){return(o,i)=>{const a=o.codePointAt(i+n);if(void 0===a)return Be(i,r);const s=e[a];return void 0===s?void 0===t?Be(i,r):t(o,i):s(o,i)}},end:Pe,error:Be,except:function(e,t,n){return Me(Fe(t,n),e)},filter:function(e,t,n,r){return(o,i)=>{const a=e(o,i);return a.success?t(a.value)?a:Be(i,n,r):a}},filterUndefined:function(e){return Ce(e,(e=>e.filter((e=>void 0!==e))))},first:De,followed:ke,map:Ce,not:Fe,ok:Ne,okWithValue:Ee,optional:function(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:Ee(n,null)}},or:function(e,t){return(n,r)=>{let o=null;for(const i of e){const e=i(n,r);if(e.success)return e;if(null===o||e.offset>o.offset?o=e:e.offset===o.offset&&void 0===t&&(o.expected=o.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==o?void 0:o.expected)||[],o&&(o.expected=t),o||Be(r,t)}},peek:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(n,r.value):r}},plus:function(e){return Re(e,Se(e),((e,t)=>[e].concat(t)))},plusConsumed:function(e){return Re(e,Oe(e),Ue)},preceded:Me,range:function(e,t,n){return Ie((n=>e<=n&&n<=t),n||[`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`])},recognize:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(r.offset,t.slice(n,r.offset)):r}},second:Ue,sequence:function(...e){return(t,n)=>{const r=[];for(const o of e){const e=o(t,n);if(!e.success)return e;n=e.offset,r.push(e.value)}return Ee(n,r)}},sequenceConsumed:function(...e){return(t,n)=>{for(const r of e){const e=r(t,n);if(!e.success)return e;n=e.offset}return Ne(n)}},skipChars:function(e){return(t,n)=>{let r=e;for(;r>0;){const e=t.codePointAt(n);if(void 0===e)return Be(n,["any character"]);n+=Te(e),r-=1}return Ne(n)}},star:Se,starConsumed:Oe,start:(e,t)=>0===t?Ne(t):Be(t,["start of input"]),streaming:function(e){return function*(t,n){const r=e(t,n);return r.success&&(yield r.value),r}},streamingComplete:function(e){return function*(t,n){const r=yield*e(t,n);return r.success?Pe(t,r.offset):r}},streamingFilterUndefined:function(e){return function*(t,n){const r=e(t,n);let o=r.next();for(;!o.done;){const e=o.value;void 0!==e&&(yield e),o=r.next()}return o.value}},streamingOptional:function(e){return function*(t,n){const[r,o]=He(e(t,n));return o.success?(yield*r,o):o.fatal?o:Ne(n)}},streamingStar:function(e){return function*(t,n){for(;;){const[r,o]=He(e(t,n));if(!o.success)return o.fatal?o:Ne(n);if(yield*r,n===o.offset)return Ne(n);n=o.offset}}},streamingThen:function(e,t){return function*(n,r){const o=yield*e(n,r);return o.success?yield*t(n,o.offset):o}},then:Re,token:function(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?Ee(r,e):Be(n,[e])}}});const je=function(e,t){const n={};var r;function o(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}var i="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e};var a=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);function s(e,t){if(t)e:{var n=a;e=e.split(".");for(var r=0;r<e.length-1;r++){var o=e[r];if(!(o in n))break e;n=n[o]}(t=t(r=n[e=e[e.length-1]]))!=r&&null!=t&&i(n,e,{configurable:!0,writable:!0,value:t})}}function u(e){return(e={next:e})[Symbol.iterator]=function(){return this},e}function c(e){var t="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];return t?t.call(e):{next:o(e)}}function l(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function p(e){return e instanceof Array?e:l(c(e))}s("Symbol",(function(e){function t(e,t){this.h=e,i(this,"description",{configurable:!0,writable:!0,value:t})}if(e)return e;t.prototype.toString=function(){return this.h};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",r=0;return function e(o){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new t(n+(o||"")+"_"+r++,o)}})),s("Symbol.iterator",(function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var t="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),n=0;n<t.length;n++){var r=a[t[n]];"function"==typeof r&&"function"!=typeof r.prototype[e]&&i(r.prototype,e,{configurable:!0,writable:!0,value:function(){return u(o(this))}})}return e})),s("Symbol.asyncIterator",(function(e){return e||Symbol("Symbol.asyncIterator")}));var h,f="function"==typeof Object.create?Object.create:function(e){function t(){}return t.prototype=e,new t};if("function"==typeof Object.setPrototypeOf)h=Object.setPrototypeOf;else{var d;e:{var m={};try{m.__proto__={a:!0},d=m.a;break e}catch(e){}d=!1}h=d?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null}var g=h;function y(e,t){if(e.prototype=f(t.prototype),e.prototype.constructor=e,g)g(e,t);else for(var n in t)if("prototype"!=n)if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(t,n);r&&Object.defineProperty(e,n,r)}else e[n]=t[n];e.Pc=t.prototype}function v(){this.j=!1,this.s=null,this.u=void 0,this.h=1,this.ha=0,this.A=null}function w(e){if(e.j)throw new TypeError("Generator is already running");e.j=!0}function A(e,t){e.A={Ac:t,Cc:!0},e.h=e.ha}function x(e){this.h=new v,this.s=e}function b(e,t,n,r){try{var o=t.call(e.h.s,n);if(!(o instanceof Object))throw new TypeError("Iterator result "+o+" is not an object");if(!o.done)return e.h.j=!1,o;var i=o.value}catch(t){return e.h.s=null,A(e.h,t),E(e)}return e.h.s=null,r.call(e.h,i),E(e)}function E(e){for(;e.h.h;)try{var t=e.s(e.h);if(t)return e.h.j=!1,{value:t.value,done:!1}}catch(t){e.h.u=void 0,A(e.h,t)}if(e.h.j=!1,e.h.A){if(t=e.h.A,e.h.A=null,t.Cc)throw t.Ac;return{value:t.return,done:!0}}return{value:void 0,done:!0}}function N(e){this.next=function(t){return w(e.h),e.h.s?t=b(e,e.h.s.next,t,e.h.O):(e.h.O(t),t=E(e)),t},this.throw=function(t){return w(e.h),e.h.s?t=b(e,e.h.s.throw,t,e.h.O):(A(e.h,t),t=E(e)),t},this.return=function(t){return function(e,t){w(e.h);var n=e.h.s;return n?b(e,"return"in n?n.return:function(e){return{value:e,done:!0}},t,e.h.return):(e.h.return(t),E(e))}(e,t)},this[Symbol.iterator]=function(){return this}}function B(e,t){return Object.prototype.hasOwnProperty.call(e,t)}v.prototype.O=function(e){this.u=e},v.prototype.return=function(e){this.A={return:e},this.h=this.ha},s("Promise",(function(e){function t(e){this.s=0,this.A=void 0,this.h=[],this.ha=!1;var t=this.j();try{e(t.resolve,t.reject)}catch(e){t.reject(e)}}function n(){this.h=null}function r(e){return e instanceof t?e:new t((function(t){t(e)}))}if(e)return e;n.prototype.s=function(e){if(null==this.h){this.h=[];var t=this;this.A((function(){t.u()}))}this.h.push(e)};var o=a.setTimeout;n.prototype.A=function(e){o(e,0)},n.prototype.u=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var t=0;t<e.length;++t){var n=e[t];e[t]=null;try{n()}catch(e){this.j(e)}}}this.h=null},n.prototype.j=function(e){this.A((function(){throw e}))},t.prototype.j=function(){function e(e){return function(r){n||(n=!0,e.call(t,r))}}var t=this,n=!1;return{resolve:e(this.pa),reject:e(this.u)}},t.prototype.pa=function(e){if(e===this)this.u(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof t)this.xa(e);else{e:switch(typeof e){case"object":var n=null!=e;break e;case"function":n=!0;break e;default:n=!1}n?this.ka(e):this.O(e)}},t.prototype.ka=function(e){var t=void 0;try{t=e.then}catch(e){return void this.u(e)}"function"==typeof t?this.ob(t,e):this.O(e)},t.prototype.u=function(e){this.B(2,e)},t.prototype.O=function(e){this.B(1,e)},t.prototype.B=function(e,t){if(0!=this.s)throw Error("Cannot settle("+e+", "+t+"): Promise already settled in state"+this.s);this.s=e,this.A=t,2===this.s&&this.$a(),this.J()},t.prototype.$a=function(){var e=this;o((function(){if(e.T()){var t=a.console;void 0!==t&&t.error(e.A)}}),1)},t.prototype.T=function(){if(this.ha)return!1;var e=a.CustomEvent,t=a.Event,n=a.dispatchEvent;return void 0===n||("function"==typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"==typeof t?e=new t("unhandledrejection",{cancelable:!0}):(e=a.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,e),e.promise=this,e.reason=this.A,n(e))},t.prototype.J=function(){if(null!=this.h){for(var e=0;e<this.h.length;++e)i.s(this.h[e]);this.h=null}};var i=new n;return t.prototype.xa=function(e){var t=this.j();e.pb(t.resolve,t.reject)},t.prototype.ob=function(e,t){var n=this.j();try{e.call(t,n.resolve,n.reject)}catch(e){n.reject(e)}},t.prototype.then=function(e,n){function r(e,t){return"function"==typeof e?function(t){try{o(e(t))}catch(e){i(e)}}:t}var o,i,a=new t((function(e,t){o=e,i=t}));return this.pb(r(e,o),r(n,i)),a},t.prototype.catch=function(e){return this.then(void 0,e)},t.prototype.pb=function(e,t){function n(){switch(r.s){case 1:e(r.A);break;case 2:t(r.A);break;default:throw Error("Unexpected state: "+r.s)}}var r=this;null==this.h?i.s(n):this.h.push(n),this.ha=!0},t.resolve=r,t.reject=function(e){return new t((function(t,n){n(e)}))},t.race=function(e){return new t((function(t,n){for(var o=c(e),i=o.next();!i.done;i=o.next())r(i.value).pb(t,n)}))},t.all=function(e){var n=c(e),o=n.next();return o.done?r([]):new t((function(e,t){function i(t){return function(n){a[t]=n,0==--s&&e(a)}}var a=[],s=0;do{a.push(void 0),s++,r(o.value).pb(i(a.length-1),t),o=n.next()}while(!o.done)}))},t}));var T="function"==typeof Object.assign?Object.assign:function(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var o in r)B(r,o)&&(e[o]=r[o])}return e};function I(e,t,n){if(null==e)throw new TypeError("The 'this' value for String.prototype."+n+" must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype."+n+" must not be a regular expression");return e+""}function C(e,t){return e=void 0!==e?String(e):" ",0<t&&e?e.repeat(Math.ceil(t/e.length)).substring(0,t):""}function S(e,t,n){e instanceof String&&(e=String(e));for(var r=e.length,o=0;o<r;o++){var i=e[o];if(t.call(n,i,o,e))return{Hb:o,Ob:i}}return{Hb:-1,Ob:void 0}}function O(e){return e||Array.prototype.fill}function R(e,t){e instanceof String&&(e+="");var n=0,r=!1,o={next:function(){if(!r&&n<e.length){var o=n++;return{value:t(o,e[o]),done:!1}}return r=!0,{done:!0,value:void 0}}};return o[Symbol.iterator]=function(){return o},o}function D(e,t){if(!("0"!==e&&"-0"!==e||"0"!==t&&"-0"!==t))return 0;var n=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;e=n.exec(e+"");var r=n.exec(t+""),o=!e[1],i=!r[1];return t=(e[2]||"").replace(/^0*/,""),n=(r[2]||"").replace(/^0*/,""),e=e[3]||"",r=r[3]||"",o&&!i?1:!o&&i?-1:(o=o&&i,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"))?o?1:-1:n<t?o?-1:1:0))}function U(e,t){return!(-1<(e=e.toString()).indexOf(".")&&0===t)&&(!(e=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(e))[2]||e[2].length<=t)}function M(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 k(e){switch(e){case 1:case 0:case 6:case 3:case 18:case 22:case 21:case 20:case 23:case 44:return{};case 4:return{na:U,ua:function(e,t){return 1>D(e,t)},Nc:function(e,t){return 0>D(e,t)},va:function(e,t){return-1<D(e,t)},Oc:function(e,t){return 0<D(e,t)}};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{za:M};default:return null}}s("Object.assign",(function(e){return e||T})),s("String.prototype.repeat",(function(e){return e||function(e){var t=I(this,null,"repeat");if(0>e||1342177279<e)throw new RangeError("Invalid count value");e|=0;for(var n="";e;)1&e&&(n+=t),(e>>>=1)&&(t+=t);return n}})),s("String.prototype.padEnd",(function(e){return e||function(e,t){var n=I(this,null,"padStart");return n+C(t,e-n.length)}})),s("WeakMap",(function(e){function t(e){if(this.h=(u+=Math.random()+1).toString(),e){e=c(e);for(var t;!(t=e.next()).done;)t=t.value,this.set(t[0],t[1])}}function n(){}function r(e){var t=typeof e;return"object"===t&&null!==e||"function"===t}function o(e){if(!B(e,s)){var t=new n;i(e,s,{value:t})}}function a(e){var t=Object[e];t&&(Object[e]=function(e){return e instanceof n?e:(Object.isExtensible(e)&&o(e),t(e))})}if(function(){if(!e||!Object.seal)return!1;try{var t=Object.seal({}),n=Object.seal({}),r=new e([[t,2],[n,3]]);return 2==r.get(t)&&3==r.get(n)&&(r.delete(t),r.set(n,4),!r.has(t)&&4==r.get(n))}catch(e){return!1}}())return e;var s="$jscomp_hidden_"+Math.random();a("freeze"),a("preventExtensions"),a("seal");var u=0;return t.prototype.set=function(e,t){if(!r(e))throw Error("Invalid WeakMap key");if(o(e),!B(e,s))throw Error("WeakMap key fail: "+e);return e[s][this.h]=t,this},t.prototype.get=function(e){return r(e)&&B(e,s)?e[s][this.h]:void 0},t.prototype.has=function(e){return r(e)&&B(e,s)&&B(e[s],this.h)},t.prototype.delete=function(e){return!!(r(e)&&B(e,s)&&B(e[s],this.h))&&delete e[s][this.h]},t})),s("Map",(function(e){function t(){var e={};return e.Da=e.next=e.head=e}function n(e,t){var n=e.h;return u((function(){if(n){for(;n.head!=e.h;)n=n.Da;for(;n.next!=n.head;)return n=n.next,{done:!1,value:t(n)};n=null}return{done:!0,value:void 0}}))}function r(e,t){var n=t&&typeof t;"object"==n||"function"==n?i.has(t)?n=i.get(t):(n=""+ ++a,i.set(t,n)):n="p_"+t;var r=e.s[n];if(r&&B(e.s,n))for(e=0;e<r.length;e++){var o=r[e];if(t!=t&&o.key!=o.key||t===o.key)return{id:n,list:r,index:e,ja:o}}return{id:n,list:r,index:-1,ja:void 0}}function o(e){if(this.s={},this.h=t(),this.size=0,e){e=c(e);for(var n;!(n=e.next()).done;)n=n.value,this.set(n[0],n[1])}}if(function(){if(!e||"function"!=typeof e||!e.prototype.entries||"function"!=typeof Object.seal)return!1;try{var t=Object.seal({x:4}),n=new e(c([[t,"s"]]));if("s"!=n.get(t)||1!=n.size||n.get({x:4})||n.set({x:4},"t")!=n||2!=n.size)return!1;var r=n.entries(),o=r.next();return!o.done&&o.value[0]==t&&"s"==o.value[1]&&!((o=r.next()).done||4!=o.value[0].x||"t"!=o.value[1]||!r.next().done)}catch(e){return!1}}())return e;var i=new WeakMap;o.prototype.set=function(e,t){var n=r(this,e=0===e?0:e);return n.list||(n.list=this.s[n.id]=[]),n.ja?n.ja.value=t:(n.ja={next:this.h,Da:this.h.Da,head:this.h,key:e,value:t},n.list.push(n.ja),this.h.Da.next=n.ja,this.h.Da=n.ja,this.size++),this},o.prototype.delete=function(e){return!(!(e=r(this,e)).ja||!e.list)&&(e.list.splice(e.index,1),e.list.length||delete this.s[e.id],e.ja.Da.next=e.ja.next,e.ja.next.Da=e.ja.Da,e.ja.head=null,this.size--,!0)},o.prototype.clear=function(){this.s={},this.h=this.h.Da=t(),this.size=0},o.prototype.has=function(e){return!!r(this,e).ja},o.prototype.get=function(e){return(e=r(this,e).ja)&&e.value},o.prototype.entries=function(){return n(this,(function(e){return[e.key,e.value]}))},o.prototype.keys=function(){return n(this,(function(e){return e.key}))},o.prototype.values=function(){return n(this,(function(e){return e.value}))},o.prototype.forEach=function(e,t){for(var n,r=this.entries();!(n=r.next()).done;)n=n.value,e.call(t,n[1],n[0],this)},o.prototype[Symbol.iterator]=o.prototype.entries;var a=0;return o})),s("Array.prototype.find",(function(e){return e||function(e,t){return S(this,e,t).Ob}})),s("String.prototype.startsWith",(function(e){return e||function(e,t){var n=I(this,e,"startsWith"),r=n.length,o=e.length;t=Math.max(0,Math.min(0|t,n.length));for(var i=0;i<o&&t<r;)if(n[t++]!=e[i++])return!1;return i>=o}})),s("Array.prototype.fill",(function(e){return e||function(e,t,n){var r=this.length||0;for(0>t&&(t=Math.max(0,r+t)),(null==n||n>r)&&(n=r),0>(n=Number(n))&&(n=Math.max(0,r+n)),t=Number(t||0);t<n;t++)this[t]=e;return this}})),s("Int8Array.prototype.fill",O),s("Uint8Array.prototype.fill",O),s("Uint8ClampedArray.prototype.fill",O),s("Int16Array.prototype.fill",O),s("Uint16Array.prototype.fill",O),s("Int32Array.prototype.fill",O),s("Uint32Array.prototype.fill",O),s("Float32Array.prototype.fill",O),s("Float64Array.prototype.fill",O),s("Array.from",(function(e){return e||function(e,t,n){t=null!=t?t:function(e){return e};var r=[],o="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];if("function"==typeof o){e=o.call(e);for(var i=0;!(o=e.next()).done;)r.push(t.call(n,o.value,i++))}else for(o=e.length,i=0;i<o;i++)r.push(t.call(n,e[i],i));return r}})),s("Object.is",(function(e){return e||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),s("Array.prototype.includes",(function(e){return e||function(e,t){var n=this;n instanceof String&&(n=String(n));var r=n.length;for(0>(t=t||0)&&(t=Math.max(t+r,0));t<r;t++){var o=n[t];if(o===e||Object.is(o,e))return!0}return!1}})),s("String.prototype.includes",(function(e){return e||function(e,t){return-1!==I(this,e,"includes").indexOf(e,t||0)}})),s("Number.MAX_SAFE_INTEGER",(function(){return 9007199254740991})),s("Number.MIN_SAFE_INTEGER",(function(){return-9007199254740991})),s("Math.trunc",(function(e){return e||function(e){if(e=Number(e),isNaN(e)||1/0===e||-1/0===e||0===e)return e;var t=Math.floor(Math.abs(e));return 0>e?-t:t}})),s("Number.isFinite",(function(e){return e||function(e){return"number"==typeof e&&(!isNaN(e)&&1/0!==e&&-1/0!==e)}})),s("String.prototype.padStart",(function(e){return e||function(e,t){var n=I(this,null,"padStart");return C(t,e-n.length)+n}})),s("Array.prototype.keys",(function(e){return e||function(){return R(this,(function(e){return e}))}})),s("Number.isInteger",(function(e){return e||function(e){return!!Number.isFinite(e)&&e===Math.floor(e)}})),s("Number.isSafeInteger",(function(e){return e||function(e){return Number.isInteger(e)&&Math.abs(e)<=Number.MAX_SAFE_INTEGER}})),s("Array.prototype.findIndex",(function(e){return e||function(e,t){return S(this,e,t).Hb}})),s("String.prototype.endsWith",(function(e){return e||function(e,t){var n=I(this,e,"endsWith");void 0===t&&(t=n.length),t=Math.max(0,Math.min(0|t,n.length));for(var r=e.length;0<r&&0<t;)if(n[--t]!=e[--r])return!1;return 0>=r}})),s("String.fromCodePoint",(function(e){return e||function(e){for(var t="",n=0;n<arguments.length;n++){var r=Number(arguments[n]);if(0>r||1114111<r||r!==Math.floor(r))throw new RangeError("invalid_code_point "+r);65535>=r?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode(r>>>10&1023|55296),t+=String.fromCharCode(1023&r|56320))}return t}})),s("String.prototype.codePointAt",(function(e){return e||function(e){var t=I(this,null,"codePointAt"),n=t.length;if(0<=(e=Number(e)||0)&&e<n){e|=0;var r=t.charCodeAt(e);return 55296>r||56319<r||e+1===n||(56320>(e=t.charCodeAt(e+1))||57343<e)?r:1024*(r-55296)+e+9216}}})),s("Set",(function(e){function t(e){if(this.h=new Map,e){e=c(e);for(var t;!(t=e.next()).done;)this.add(t.value)}this.size=this.h.size}return function(){if(!e||"function"!=typeof e||!e.prototype.entries||"function"!=typeof Object.seal)return!1;try{var t=Object.seal({x:4}),n=new e(c([t]));if(!n.has(t)||1!=n.size||n.add(t)!=n||1!=n.size||n.add({x:4})!=n||2!=n.size)return!1;var r=n.entries(),o=r.next();return!o.done&&o.value[0]==t&&o.value[1]==t&&(!(o=r.next()).done&&o.value[0]!=t&&4==o.value[0].x&&o.value[1]==o.value[0]&&r.next().done)}catch(e){return!1}}()?e:(t.prototype.add=function(e){return e=0===e?0:e,this.h.set(e,e),this.size=this.h.size,this},t.prototype.delete=function(e){return e=this.h.delete(e),this.size=this.h.size,e},t.prototype.clear=function(){this.h.clear(),this.size=0},t.prototype.has=function(e){return this.h.has(e)},t.prototype.entries=function(){return this.h.entries()},t.prototype.values=function(){return this.h.values()},t.prototype.keys=t.prototype.values,t.prototype[Symbol.iterator]=t.prototype.values,t.prototype.forEach=function(e,t){var n=this;this.h.forEach((function(r){return e.call(t,r,r,n)}))},t)})),s("Math.log10",(function(e){return e||function(e){return Math.log(e)/Math.LN10}})),s("Object.values",(function(e){return e||function(e){var t,n=[];for(t in e)B(e,t)&&n.push(e[t]);return n}})),s("Number.isNaN",(function(e){return e||function(e){return"number"==typeof e&&isNaN(e)}})),s("Array.prototype.values",(function(e){return e||function(){return R(this,(function(e,t){return t}))}})),s("Object.getOwnPropertySymbols",(function(e){return e||function(){return[]}}));var F={},G={};function P(e){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(e)}function H(e){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(e)}function _(e){return H(e)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(e)}function j(e){return 1===(e=e.split(":")).length?_(e[0]):2===e.length&&(_(e[0])&&_(e[1]))}function X(e){return!/[\u0009\u000A\u000D]/.test(e)}function L(e){return _(e)}var $=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 P(e)}],[3,P],[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,j],[48,X],[52,function(e){return X(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,H],[23,j],[24,_],[42,L],[41,L],[26,function(e){return _(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)}]]),q=Object.create(null);function V(e,t){if(!q[t])throw Error("Unknown type");return{type:t,value:e}}[{D:0,name:59},{D:0,name:46,parent:59,K:{whiteSpace:"preserve"}},{D:0,name:19,parent:46},{D:0,name:1,parent:46},{D:0,name:0,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:4,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:6,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:3,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:18,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:9,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:8,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:7,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:11,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:12,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:13,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:15,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:14,parent:46,K:{za:"optional",whiteSpace:"collapse"}},{D:0,name:22,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:21,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:20,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{D:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{D:1,name:10,U:9,K:{whiteSpace:"collapse",za:"required"}},{D:1,name:48,U:1,K:{whiteSpace:"replace"}},{D:1,name:52,U:48,K:{whiteSpace:"collapse"}},{D:1,name:51,U:52,K:{whiteSpace:"collapse"}},{D:1,name:50,U:52,K:{whiteSpace:"collapse"}},{D:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{D:1,name:25,U:52,K:{whiteSpace:"collapse"}},{D:1,name:24,U:25,K:{whiteSpace:"collapse"}},{D:1,name:42,U:24,K:{whiteSpace:"collapse"}},{D:1,name:41,U:24,K:{whiteSpace:"collapse"}},{D:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{D:1,name:26,U:24,K:{whiteSpace:"collapse"}},{D:2,name:40,type:26,K:{minLength:1,whiteSpace:"collapse"}},{D:0,name:5,parent:4,K:{na:0,whiteSpace:"collapse"}},{D:1,name:27,U:5,K:{na:0,ua:"0",whiteSpace:"collapse"}},{D:1,name:28,U:27,K:{na:0,ua:"-1",whiteSpace:"collapse"}},{D:1,name:31,U:5,K:{na:0,ua:"9223372036854775807",va:"-9223372036854775808",whiteSpace:"collapse"}},{D:1,name:32,U:31,K:{na:0,ua:"2147483647",va:"-2147483648",whiteSpace:"collapse"}},{D:1,name:33,U:32,K:{na:0,ua:"32767",va:"-32768",whiteSpace:"collapse"}},{D:1,name:34,U:33,K:{na:0,ua:"127",va:"-128",whiteSpace:"collapse"}},{D:1,name:30,U:5,K:{na:0,va:"0",whiteSpace:"collapse"}},{D:1,name:36,U:30,K:{na:0,ua:"18446744073709551615",va:"0",whiteSpace:"collapse"}},{D:1,name:35,U:36,K:{na:0,ua:"4294967295",va:"0",whiteSpace:"collapse"}},{D:1,name:38,U:35,K:{na:0,ua:"65535",va:"0",whiteSpace:"collapse"}},{D:1,name:37,U:38,K:{na:0,ua:"255",va:"0",whiteSpace:"collapse"}},{D:1,name:29,U:30,K:{na:0,va:"1",whiteSpace:"collapse"}},{D:1,name:16,U:18,K:{whiteSpace:"collapse"}},{D:1,name:17,U:18,K:{whiteSpace:"collapse"}},{D:1,name:60,U:59},{D:3,name:39,Ca:[]},{D:1,name:61,U:60},{D:1,name:62,U:60},{D:0,name:53,parent:59},{D:1,name:54,U:53},{D:1,name:58,U:53},{D:1,name:47,U:53},{D:1,name:56,U:53},{D:1,name:57,U:53},{D:1,name:55,U:53},{D:3,name:2,Ca:[4,5,6,3]},{D:3,name:63,Ca:[]}].forEach((function(e){var t=e.name,n=e.K||{};switch(e.D){case 0:e=e.parent?q[e.parent]:null;var r=$.get(t)||null;q[t]={D:0,type:t,Ka:n,parent:e,hb:r,Na:k(t),Ca:[]};break;case 1:e=q[e.U],r=$.get(t)||null,q[t]={D:1,type:t,Ka:n,parent:e,hb:r,Na:e.Na,Ca:[]};break;case 2:q[t]={D:2,type:t,Ka:n,parent:q[e.type],hb:null,Na:F,Ca:[]};break;case 3:e=e.Ca.map((function(e){return q[e]})),q[t]={D:3,type:t,Ka:n,parent:null,hb:null,Na:G,Ca:e}}}));var Y=V(!0,0),Q=V(!1,0);function J(e){return Error("FORG0006: "+(void 0===e?"A wrong argument type was specified in a function call.":e))}function z(e,t){this.done=e,this.value=t}var K=new z(!0,void 0);function W(e){return new z(!1,e)}function Z(e,t){if(3===t.D)return!!t.Ca.find((function(t){return Z(e,t)}));for(;e;){if(e.type===t.type)return!0;if(3===e.D)return!!e.Ca.find((function(e){return ee(e.type,t.type)}));e=e.parent}return!1}function ee(e,t){return e===t||Z(q[e],q[t])}function te(e){this.s=ge,this.h=e;var t=-1;this.value={next:function(){return++t>=e.length?K:W(e[t])}}}function ne(){this.value={next:function(){return K}}}function re(e,t){this.type=e,this.value=t}(r=te.prototype).qb=function(){return this},r.filter=function(e){var t=this,n=-1;return this.s.create({next:function(){for(n++;n<t.h.length&&!e(t.h[n],n,t);)n++;return n>=t.h.length?K:W(t.h[n])}})},r.first=function(){return this.h[0]},r.N=function(){return this.h},r.getEffectiveBooleanValue=function(){if(ee(this.h[0].type,53))return!0;throw J("Cannot determine the effective boolean value of a sequence with a length higher than one.")},r.Pa=function(){return this.h.length},r.G=function(){return!1},r.ta=function(){return!1},r.map=function(e){var t=this,n=-1;return this.s.create({next:function(){return++n>=t.h.length?K:W(e(t.h[n],n,t))}},this.h.length)},r.L=function(e){return e(this.h)},r.$=function(e){return e.multiple?e.multiple(this):e.default(this)},(r=ne.prototype).qb=function(){return this},r.filter=function(){return this},r.first=function(){return null},r.N=function(){return[]},r.getEffectiveBooleanValue=function(){return!1},r.Pa=function(){return 0},r.G=function(){return!0},r.ta=function(){return!1},r.map=function(){return this},r.L=function(e){return e([])},r.$=function(e){return e.empty?e.empty(this):e.default(this)};var oe={},ie=(oe[0]="xs:boolean",oe[1]="xs:string",oe[2]="xs:numeric",oe[3]="xs:double",oe[4]="xs:decimal",oe[5]="xs:integer",oe[6]="xs:float",oe[7]="xs:date",oe[8]="xs:time",oe[9]="xs:dateTime",oe[10]="xs:dateTimeStamp",oe[11]="xs:gYearMonth",oe[12]="xs:gYear",oe[13]="xs:gMonthDay",oe[14]="xs:gMonth",oe[15]="xs:gDay",oe[16]="xs:yearMonthDuration",oe[17]="xs:dayTimeDuration",oe[18]="xs:duration",oe[19]="xs:untypedAtomic",oe[20]="xs:anyURI",oe[21]="xs:base64Binary",oe[22]="xs:hexBinary",oe[23]="xs:QName",oe[24]="xs:NCName",oe[25]="xs:Name",oe[26]="xs:ENTITY",oe[27]="xs:nonPositiveInteger",oe[28]="xs:negativeInteger",oe[29]="xs:positiveInteger",oe[30]="xs:nonNegativeInteger",oe[31]="xs:long",oe[32]="xs:int",oe[33]="xs:short",oe[34]="xs:byte",oe[35]="xs:unsignedInt",oe[36]="xs:unsignedLong",oe[37]="xs:unsignedByte",oe[38]="xs:unsignedShort",oe[39]="xs:error",oe[40]="xs:ENTITIES",oe[41]="xs:IDREF",oe[42]="xs:ID",oe[43]="xs:IDREFS",oe[44]="xs:NOTATION",oe[45]="xs:anySimpleType",oe[46]="xs:anyAtomicType",oe[47]="attribute()",oe[48]="xs:normalizedString",oe[49]="xs:NMTOKENS",oe[50]="xs:NMTOKEN",oe[51]="xs:language",oe[52]="xs:token",oe[53]="node()",oe[54]="element()",oe[55]="document-node()",oe[56]="text()",oe[57]="processing-instruction()",oe[58]="comment()",oe[59]="item()",oe[60]="function(*)",oe[61]="map(*)",oe[62]="array(*)",oe[63]="none",oe),ae={"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 se(e){return 2===e.g?ie[e.type]+"*":1===e.g?ie[e.type]+"+":0===e.g?ie[e.type]+"?":ie[e.type]}function ue(e){if("none"===e)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);var t=ae[e];if(void 0===t)throw Error('XPST0051: The type "'+e+'" could not be found');return t}function ce(e){switch(e[e.length-1]){case"*":return{type:ue(e.substr(0,e.length-1)),g:2};case"?":return{type:ue(e.substr(0,e.length-1)),g:0};case"+":return{type:ue(e.substr(0,e.length-1)),g:1};default:return{type:ue(e),g:3}}}function le(e){var t=e.value;if(ee(e.type,53))return!0;if(ee(e.type,0))return t;if(ee(e.type,1)||ee(e.type,20)||ee(e.type,19))return 0!==t.length;if(ee(e.type,2))return!isNaN(t)&&0!==t;throw J("Cannot determine the effective boolean value of a value with the type "+ie[e.type])}function pe(e,t){var n=this;this.j=ge,this.value={next:function(t){return null!==n.s&&n.h>=n.s?K:void 0!==n.A[n.h]?W(n.A[n.h++]):(t=e.next(t)).done?(n.s=n.h,t):((n.u||2>n.h)&&(n.A[n.h]=t.value),n.h++,t)}},this.u=!1,this.A=[],this.h=0,this.s=void 0===t?null:t}function he(e,t){e.h=void 0===t?0:t}function fe(e){this.A=ge,this.h=e;var t=!1;this.value={next:function(){return t?K:(t=!0,W(e))}},this.s=null}(r=pe.prototype).qb=function(){return this.j.create(this.N())},r.filter=function(e){var t=this,n=-1,r=this.value;return this.j.create({next:function(o){for(n++,o=r.next(o);!o.done&&!e(o.value,n,t);)n++,o=r.next(0);return o}})},r.first=function(){if(void 0!==this.A[0])return this.A[0];var e=this.value.next(0);return he(this),e.done?null:e.value},r.N=function(){if(this.h>this.A.length&&this.s!==this.A.length)throw Error("Implementation error: Sequence Iterator has progressed.");var e=this.value;this.u=!0;for(var t=e.next(0);!t.done;)t=e.next(0);return this.A},r.getEffectiveBooleanValue=function(){var e=this.value,t=this.h;he(this);var n=e.next(0);if(n.done)return he(this,t),!1;if(ee((n=n.value).type,53))return he(this,t),!0;if(!e.next(0).done)throw J("Cannot determine the effective boolean value of a sequence with a length higher than one.");return he(this,t),le(n)},r.Pa=function(e){if(null!==this.s)return this.s;if(void 0!==e&&e)return-1;e=this.h;var t=this.N().length;return he(this,e),t},r.G=function(){return 0===this.s||null===this.first()},r.ta=function(){if(null!==this.s)return 1===this.s;var e=this.value,t=this.h;return he(this),e.next(0).done?(he(this,t),!1):(e=e.next(0),he(this,t),e.done)},r.map=function(e){var t=this,n=0,r=this.value;return this.j.create({next:function(o){return(o=r.next(o)).done?K:W(e(o.value,n++,t))}},this.s)},r.L=function(e,t){var n,r=this.value,o=[],i=!0;return function(){for(var a=r.next(i?0:t);!a.done;a=r.next(t))i=!1,o.push(a.value);n=e(o).value}(),this.j.create({next:function(){return n.next(0)}})},r.$=function(e){function t(e){r=e.value,-1!==(e=e.Pa(!0))&&(n.s=e)}var n=this,r=null;return this.j.create({next:function(o){return r?r.next(o):n.G()?(t(e.empty?e.empty(n):e.default(n)),r.next(o)):n.ta()?(t(e.o?e.o(n):e.default(n)),r.next(o)):(t(e.multiple?e.multiple(n):e.default(n)),r.next(o))}})},(r=fe.prototype).qb=function(){return this},r.filter=function(e){return e(this.h,0,this)?this:this.A.create()},r.first=function(){return this.h},r.N=function(){return[this.h]},r.getEffectiveBooleanValue=function(){return null===this.s&&(this.s=le(this.h)),this.s},r.Pa=function(){return 1},r.G=function(){return!1},r.ta=function(){return!0},r.map=function(e){return this.A.create(e(this.h,0,this))},r.L=function(e){return e([this.h])},r.$=function(e){return e.o?e.o(this):e.default(this)};var de=new ne;function me(e,t){if(null===(e=void 0===e?null:e))return de;if(Array.isArray(e))switch(e.length){case 0:return de;case 1:return new fe(e[0]);default:return new te(e)}return e.next?new pe(e,void 0===t?null:t):new fe(e)}var ge={create:me,o:function(e){return new fe(e)},empty:function(){return me()},ca:function(){return me(Y)},X:function(){return me(Q)}};function ye(e){var t=[],n=e.value;return function(){var e=0;return ge.create({next:function(){if(void 0!==t[e])return t[e++];var r=n.next(0);return r.done?r:t[e++]=r}})}}function ve(e,t,n){this.namespaceURI=t||null,this.prefix=e||"",this.localName=n}function we(e){var t=e.l,n=e.arity,r=void 0!==e.Ra&&e.Ra,o=void 0!==e.I&&e.I,i=e.localName,a=e.namespaceURI,s=e.i;for(e=e.value,re.call(this,60,null),this.value=e,this.I=o,o=-1,e=0;e<t.length;e++)4===t[e]&&(o=e);-1<o&&(e=Array(n-(t.length-1)).fill(t[o-1]),t=t.slice(0,o).concat(e)),this.s=t,this.A=n,this.ha=r,this.j=i,this.u=a,this.O=s}function Ae(e,t){var n=[];return 2!==e&&1!==e||n.push("type-1-or-type-2"),n.push("type-"+e),t&&n.push("name-"+t),n}function xe(e){var t=e.node.nodeType;if(2===t||1===t)var n=e.node.localName;return Ae(t,n)}function be(e){var t=e.nodeType;if(2===t||1===t)var n=e.localName;return Ae(t,n)}function Ee(){}function Ne(){}ve.prototype.ya=function(){return this.prefix?this.prefix+":"+this.localName:this.localName},y(we,re),we.prototype.Ra=function(){return this.ha},Ee.prototype.getAllAttributes=function(e,t){return t=void 0===t?null:t,1!==e.nodeType?[]:(e=Array.from(e.attributes),null===t?e:e.filter((function(e){return be(e).includes(t)})))},Ee.prototype.getAttribute=function(e,t){return 1!==e.nodeType?null:e.getAttribute(t)},Ee.prototype.getChildNodes=function(e,t){return t=void 0===t?null:t,e=Array.from(e.childNodes),null===t?e:e.filter((function(e){return be(e).includes(t)}))},Ee.prototype.getData=function(e){return 2===e.nodeType?e.value:e.data},Ee.prototype.getFirstChild=function(e,t){for(t=void 0===t?null:t,e=e.firstChild;e;e=e.nextSibling)if(null===t||be(e).includes(t))return e;return null},Ee.prototype.getLastChild=function(e,t){for(t=void 0===t?null:t,e=e.lastChild;e;e=e.previousSibling)if(null===t||be(e).includes(t))return e;return null},Ee.prototype.getNextSibling=function(e,t){for(t=void 0===t?null:t,e=e.nextSibling;e;e=e.nextSibling)if(null===t||be(e).includes(t))return e;return null},Ee.prototype.getParentNode=function(e,t){return t=void 0===t?null:t,(e=2===e.nodeType?e.ownerElement:e.parentNode)&&(null===t||be(e).includes(t))?e:null},Ee.prototype.getPreviousSibling=function(e,t){for(t=void 0===t?null:t,e=e.previousSibling;e;e=e.previousSibling)if(null===t||be(e).includes(t))return e;return null},(r=Ne.prototype).insertBefore=function(e,t,n){return e.insertBefore(t,n)},r.removeAttributeNS=function(e,t,n){return e.removeAttributeNS(t,n)},r.removeChild=function(e,t){return e.removeChild(t)},r.setAttributeNS=function(e,t,n,r){e.setAttributeNS(t,n,r)},r.setData=function(e,t){e.data=t};var Be=new Ne;function Te(e){this.h=e}function Ie(e){return void 0!==e.Sa}function Ce(e,t,n){var r=null;return t&&(Ie(t.node)?r={F:t.F,offset:n,parent:t.node}:t.F&&(r=t.F)),{node:e,F:r}}function Se(e){this.h=e,this.s=[]}function Oe(e,t,n){return e.getAllAttributes(t.node,void 0===n?null:n).map((function(e){return Ce(e,t,e.nodeName)}))}function Re(e,t,n){return Ie(t=t.node)?(e=t.attributes.find((function(e){return n===e.name})))?e.value:null:(e=e.h.getAttribute(t,n))?e:null}function De(e,t,n){return e.getChildNodes(t.node,void 0===n?null:n).map((function(e,n){return Ce(e,t,n)}))}function Ue(e,t){return e.getData(t.node)}function Me(e,t,n){var r=t.node;return Ie(r)?e=r.childNodes[0]:((n=e.h.getFirstChild(r,void 0===n?null:n))&&10===n.nodeType&&(n=e.h.getNextSibling(n)),e=n),e?Ce(e,t,0):null}function ke(e,t,n){n=void 0===n?null:n;var r=t.node;return Ie(r)?(e=r.childNodes.length-1,r=r.childNodes[e]):((r=e.h.getLastChild(r,n))&&10===r.nodeType&&(r=e.h.getPreviousSibling(r)),e=e.getChildNodes(t.node,n).length-1),r?Ce(r,t,e):null}function Fe(e,t,n){n=void 0===n?null:n;var r=t.node,o=t.F;if(Ie(r)){if(o)var i=o.offset+1,a=o.parent.childNodes[i]}else{if(!o){for(a=r;a&&(!(a=e.h.getNextSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}i=o.offset+1;var s=Ge(e,t,null);a=e.getChildNodes(s.node,n)[i]}return a?Ce(a,s||Ge(e,t,n),i):null}function Ge(e,t,n){n=void 0===n?null:n;var r=t.node,o=t.F;if(o)"number"==typeof o.offset&&r===o.parent.childNodes[o.offset]||"string"==typeof o.offset&&r===o.parent.attributes.find((function(e){return o.offset===e.nodeName}))?(e=o.parent,t=o.F):(e=e.getParentNode(r,n),t=o);else{if(Ie(r))return null;e=e.getParentNode(r,n),t=null}return e?{node:e,F:t}:null}function Pe(e,t,n){n=void 0===n?null:n;var r=t.node,o=t.F;if(Ie(r)){if(o)var i=o.offset-1,a=o.parent.childNodes[i]}else{if(!o){for(a=r;a&&(!(a=e.h.getPreviousSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}i=o.offset-1;var s=Ge(e,t,null);a=e.getChildNodes(s.node,n)[i]}return a?Ce(a,s||Ge(e,t,n),i):null}function He(e,t,n,r,o){return o.L((function(e){var t=c(e).next().value;return r.L((function(e){e=c(e).next().value;var n=t.value;if(0>=n||n>e.R.length)throw Error("FOAY0001: array position out of bounds.");return e.R[n-1]()}))}))}function _e(e){we.call(this,{value:function(e,n,r,o){return He(0,0,0,ge.o(t),o)},localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/array",l:[{type:5,g:3}],arity:1,i:{type:59,g:2}});var t=this;this.type=62,this.R=e}function je(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 Xe(e){return{type:je(e),value:e}}function Le(e,t){return e=e.map((function(e){return e.first()})),t(e)}function $e(e,t){var n=ee(e.type,1)||ee(e.type,20)||ee(e.type,19),r=ee(t.type,1)||ee(t.type,20)||ee(t.type,19);return n&&r?e.value===t.value:(n=ee(e.type,4)||ee(e.type,3)||ee(e.type,6),r=ee(t.type,4)||ee(t.type,3)||ee(t.type,6),n&&r?!(!isNaN(e.value)||!isNaN(t.value))||e.value===t.value:(n=ee(e.type,0)||ee(e.type,22)||ee(e.type,18)||ee(e.type,23)||ee(e.type,44),r=ee(t.type,0)||ee(t.type,22)||ee(t.type,18)||ee(t.type,23)||ee(t.type,44),!(!n||!r)&&e.value===t.value))}function qe(e,t,n,r,o){return Le([r,o],(function(e){var t=(e=c(e)).next().value,n=e.next().value;return(e=t.h.find((function(e){return $e(e.key,n)})))?e.value():ge.empty()}))}function Ve(e){we.call(this,{l:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:function(e,n,r,o){return qe(0,0,0,ge.o(t),o)},i:{type:59,g:2}});var t=this;this.type=61,this.h=e}function Ye(){}function Qe(e,t){return e.cb()===t.cb()&&e.eb()===t.eb()}function Je(e){if(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.ea=e}function ze(e){var t=Math.abs(e.ab()),n=Math.abs(e.getHours()),r=Math.abs(e.getMinutes());return n=(n?n+"H":"")+(r?r+"M":"")+((e=Math.abs(e.getSeconds()))?e+"S":""),(t=t?t+"D":"")&&n?t+"T"+n:t||(n?"T"+n:"T0S")}function Ke(e,t,n,r,o,i){return e=86400*e+3600*t+60*n+r+o,new Je(i||0===e?e:-e)}function We(e){return(e=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e))?Ke(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}function Ze(e){return"Z"===(e=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(e))[1]?Ke(0,0,0,0,0,!0):Ke(0,e[3]?parseInt(e[3],10):0,e[4]?parseInt(e[4],10):0,0,0,"+"===e[2])}function et(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");if((e=e.ea*t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new Je(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)}function tt(e){return e?parseInt(e,10):null}function nt(e){var t=(e+="").startsWith("-");return t&&(e=e.substring(1)),(t?"-":"")+e.padStart(4,"0")}function rt(e){return(e+"").padStart(2,"0")}function ot(e){return 1===(e+="").split(".")[0].length&&(e=e.padStart(e.length+1,"0")),e}function it(e){return 0===e.getHours()&&0===e.getMinutes()?"Z":(e.qa()?"+":"-")+rt(Math.abs(e.getHours()))+":"+rt(Math.abs(e.getMinutes()))}function at(e,t,n,r,o,i,a,s,u){this.A=e,this.h=t,this.s=n+(24===r?1:0),this.u=24===r?0:r,this.O=o,this.j=i,this.ra=a,this.Z=s,this.type=void 0===u?9:u}function st(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;var n=tt(t[2]),r=tt(t[3]),o=t[4],i=tt(t[5]),a=tt(t[6]),s=tt(t[7]),u=t[8]?parseFloat(t[8]):0;if(t=t[9]?Ze(t[9]):null,e&&(-271821>e||273860<e))throw Error("FODT0001: Datetime year is out of bounds");return o?new at(e,n,r,i,a,s,u,t,9):null!==i&&null!==a&&null!==s?new at(1972,12,31,i,a,s,u,t,8):null!==e&&null!==n&&null!==r?new at(e,n,r,0,0,0,0,t,7):null!==e&&null!==n?new at(e,n,1,0,0,0,0,t,11):null!==n&&null!==r?new at(1972,n,r,0,0,0,0,t,13):null!==e?new at(e,1,1,0,0,0,0,t,12):null!==n?new at(1972,n,1,0,0,0,0,t,14):new at(1972,12,r,0,0,0,0,t,15)}function ut(e,t){switch(t){case 15:return new at(1972,12,e.s,0,0,0,0,e.Z,15);case 14:return new at(1972,e.h,1,0,0,0,0,e.Z,14);case 12:return new at(e.A,1,1,0,0,0,0,e.Z,12);case 13:return new at(1972,e.h,e.s,0,0,0,0,e.Z,13);case 11:return new at(e.A,e.h,1,0,0,0,0,e.Z,11);case 8:return new at(1972,12,31,e.u,e.O,e.j,e.ra,e.Z,8);case 7:return new at(e.A,e.h,e.s,0,0,0,0,e.Z,7);default:return new at(e.A,e.h,e.s,e.u,e.O,e.j,e.ra,e.Z,9)}}function ct(e,t){return t=e.Z||t||Ze("Z"),new Date(Date.UTC(e.A,e.h-1,e.s,e.u-t.getHours(),e.O-t.getMinutes(),e.j,1e3*e.ra))}function lt(e,t,n){var r=ct(e,n).getTime();return r===(n=ct(t,n).getTime())?e.ra===t.ra?0:e.ra>t.ra?1:-1:r>n?1:-1}function pt(e,t,n){return 0===lt(e,t,n)}function ht(e,t,n){return new Je(e=(ct(e,n).getTime()-ct(t,n).getTime())/1e3)}function ft(e){throw Error("Not implemented: adding durations to "+ie[e.type])}function dt(e){throw Error("Not implemented: subtracting durations from "+ie[e.type])}function mt(e,t){if(null===e)return null;switch(typeof e){case"boolean":return e?Y:Q;case"number":return V(e,3);case"string":return V(e,1);case"object":if("nodeType"in e)return Xe({node:e,F:null});if(Array.isArray(e))return new _e(e.map((function(e){return void 0===e?function(){return ge.empty()}:ye(e=null===(e=mt(e))?ge.empty():ge.o(e))})));if(e instanceof Date){var n=st(e.toISOString());return V(n,n.type)}return new Ve(Object.keys(e).filter((function(t){return void 0!==e[t]})).map((function(t){var n=mt(e[t]);return n=null===n?ge.empty():ge.o(n),{key:V(t,1),value:ye(n)}})))}throw Error("Value "+String(e)+' of type "'+typeof e+'" is not adaptable to an XPath value.')}function gt(e,t){if("number"!=typeof e&&("string"!=typeof e||!$.get(t)(e)))throw Error("Cannot convert JavaScript value '"+e+"' to the XPath type "+ie[t]+" since it is not valid.")}function yt(e,t,n){if(null===t)return null;switch(e){case 0:return t?Y:Q;case 1:return V(t+"",1);case 3:case 2:return gt(t,3),V(+t,3);case 4:return gt(t,e),V(+t,4);case 5:return gt(t,e),V(0|t,5);case 6:return gt(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 "+ie[e]+".");return V(ut(st(t.toISOString()),e),e);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!=typeof t||!("nodeType"in t))throw Error("The JavaScript value "+t+" with type "+typeof t+" is not a valid type to be converted to an XPath "+ie[e]+".");return Xe({node:t,F:null});case 59:case 61:return mt(t);default:throw Error('Values of the type "'+ie[e]+'" can not be adapted from JavaScript to equivalent XPath values.')}}function vt(e,t,n){if(0===n.g)return null===(t=yt(n.type,t))?[]:[t];if(2===n.g||1===n.g){if(!Array.isArray(t))throw Error("The JavaScript value "+t+" should be an array if it is to be converted to "+se(n)+".");return t.map((function(e){return yt(n.type,e)})).filter((function(e){return null!==e}))}var r=yt(n.type,t);if(null===r)throw Error("The JavaScript value "+t+" should be a single entry if it is to be converted to "+se(n)+".");return[r]}function wt(e,t,n){return n=void 0===n?{type:59,g:0}:n,ge.create(vt(0,t,n))}function At(e,t){this.h=t=void 0===t?{xb:null,Cb:null,rb:!1}:t,this.La=e.La,this.Ia=e.Ia,this.M=e.M,this.Ga=e.Ga||Object.create(null)}function xt(e,t){var n=0,r=t.value;return{next:function(o){return(o=r.next(o)).done?K:W(Nt(e,n++,o.value,t))}}}function bt(e){return e.h.rb||(e.h.rb=!0,e.h.xb=st((new Date).toISOString()),e.h.Cb=We("PT0S")),e.h.xb}function Et(e){return e.h.rb||(e.h.rb=!0,e.h.xb=st((new Date).toISOString()),e.h.Cb=We("PT0S")),e.h.Cb}function Nt(e,t,n,r){return new At({M:n,La:t,Ia:r||e.Ia,Ga:e.Ga},e.h)}function Bt(e,t){return new At({M:e.M,La:e.La,Ia:e.Ia,Ga:Object.assign(Object.create(null),e.Ga,t)},e.h)}function Tt(e,t,n,r,o,i,a,s){var u=new Map;this.debug=e,this.Ja=t,this.h=n,this.s=r,this.j=o,this.u=i,this.ha=u,this.O=a,this.A=s}function It(e){var t=0,n=null,r=!0;return ge.create({next:function(o){for(;t<e.length;){n||(n=e[t].value,r=!0);var i=n.next(r?0:o);if(r=!1,!i.done)return i;t++,n=null}return K}})}function Ct(e,t,n){return Error("FORG0001: Cannot cast "+e+" to "+ie[t]+(n?", "+n:""))}function St(e){return Error("XPTY0004: "+e)}function Ot(e){return Error("FOTY0013: Atomization is not supported for "+ie[e]+".")}function Rt(e){return Error("XPST0081: The prefix "+e+" could not be resolved.")}function Dt(e,t){if(ee(e.type,46)||ee(e.type,19)||ee(e.type,0)||ee(e.type,4)||ee(e.type,3)||ee(e.type,6)||ee(e.type,5)||ee(e.type,2)||ee(e.type,23)||ee(e.type,1))return ge.create(e);var n=t.h;if(ee(e.type,53)){var r=e.value;if(2===r.node.nodeType||3===r.node.nodeType)return ge.create(V(Ue(n,r),19));if(8===r.node.nodeType||7===r.node.nodeType)return ge.create(V(Ue(n,r),1));var o=[];return function e(t){if(8!==r.node.nodeType&&7!==r.node.nodeType){var i=t.nodeType;3===i||4===i?o.push(n.getData(t)):1!==i&&9!==i||n.getChildNodes(t).forEach((function(t){e(t)}))}}(r.node),ge.create(V(o.join(""),19))}if(ee(e.type,60)&&!ee(e.type,62))throw Ot(e.type);if(ee(e.type,62))return It(e.R.map((function(e){return Ut(e(),t)})));throw Error("Atomizing "+e.type+" is not implemented.")}function Ut(e,t){var n=!1,r=e.value,o=null;return ge.create({next:function(){for(;!n;){if(!o){var e=r.next(0);if(e.done){n=!0;break}o=Dt(e.value,t).value}if(!(e=o.next(0)).done)return e;o=null}return K}})}function Mt(e){for(e=q[e];e&&0!==e.D;)e=e.parent;return e?e.type:null}function kt(e,t){var n=(t=q[t]).Ka;if(!n||!n.whiteSpace)return t.parent?kt(e,t.parent.type):e;switch(t.Ka.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 Ft(e,t){for(t=q[t];t&&null===t.hb;){if(2===t.D||3===t.D)return!0;t=t.parent}return!t||t.hb(e)}function Gt(e,t){for(;e;){if(e.Na&&e.Na[t])return e.Na[t];e=e.parent}return function(){return!0}}function Pt(e,t){return e(2)?function(e){return{v:!0,value:e}}:e(0)?function(e){return{v:!0,value:e?1:0}}:e(1)||e(19)?function(e){switch(e){case"NaN":return{v:!0,value:NaN};case"INF":case"+INF":return{v:!0,value:1/0};case"-INF":return{v:!0,value:-1/0};case"0":case"+0":return{v:!0,value:0};case"-0":return{v:!0,value:-0}}var n=parseFloat(e);return isNaN(n)?{v:!1,error:Ct(e,t)}:{v:!0,value:n}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to "+t+" or any of its derived types.")}}}function Ht(e){if(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.ga=e}function _t(e){var t=Math.abs(e.fb());return(t?t+"Y":"")+((e=Math.abs(e.bb()))?e+"M":"")||"0M"}function jt(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))>Number.MAX_SAFE_INTEGER||!Number.isFinite(t))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");e=new Ht(e||0===t?t:-t)}else e=null;return e}function Xt(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");if((e=Math.round(e.ga*t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new Ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)}function Lt(e,t){this.Ua=e,this.Ha=t}(r=Te.prototype).insertBefore=function(e,t,n){return this.h.insertBefore(e,t,n)},r.removeAttributeNS=function(e,t,n){return this.h.removeAttributeNS(e,t,n)},r.removeChild=function(e,t){return this.h.removeChild(e,t)},r.setAttributeNS=function(e,t,n,r){this.h.setAttributeNS(e,t,n,r)},r.setData=function(e,t){this.h.setData(e,t)},Se.prototype.getAllAttributes=function(e,t){return Ie(e)?e.attributes:this.h.getAllAttributes(e,void 0===t?null:t)},Se.prototype.getChildNodes=function(e,t){return t=Ie(e)?e.childNodes:this.h.getChildNodes(e,void 0===t?null:t),9===e.nodeType?t.filter((function(e){return 10!==e.nodeType})):t},Se.prototype.getData=function(e){return Ie(e)?2===e.nodeType?e.value:e.data:this.h.getData(e)||""},Se.prototype.getParentNode=function(e,t){return this.h.getParentNode(e,void 0===t?null:t)},y(_e,we),y(Ve,we),(r=Ye.prototype).ab=function(){return 0},r.getHours=function(){return 0},r.getMinutes=function(){return 0},r.bb=function(){return 0},r.cb=function(){return 0},r.eb=function(){return 0},r.getSeconds=function(){return 0},r.fb=function(){return 0},r.qa=function(){return!0},y(Je,Ye),(r=Je.prototype).ab=function(){return Math.trunc(this.ea/86400)},r.getHours=function(){return Math.trunc(this.ea%86400/3600)},r.getMinutes=function(){return Math.trunc(this.ea%3600/60)},r.eb=function(){return this.ea},r.getSeconds=function(){var e=this.ea%60;return Object.is(-0,e)?0:e},r.qa=function(){return!Object.is(-0,this.ea)&&0<=this.ea},r.toString=function(){return(this.qa()?"P":"-P")+ze(this)},(r=at.prototype).getDay=function(){return this.s},r.getHours=function(){return this.u},r.getMinutes=function(){return this.O},r.getMonth=function(){return this.h},r.getSeconds=function(){return this.j},r.getYear=function(){return this.A},r.toString=function(){switch(this.type){case 9:return nt(this.A)+"-"+rt(this.h)+"-"+rt(this.s)+"T"+rt(this.u)+":"+rt(this.O)+":"+ot(this.j+this.ra)+(this.Z?it(this.Z):"");case 7:return nt(this.A)+"-"+rt(this.h)+"-"+rt(this.s)+(this.Z?it(this.Z):"");case 8:return rt(this.u)+":"+rt(this.O)+":"+ot(this.j+this.ra)+(this.Z?it(this.Z):"");case 15:return"---"+rt(this.s)+(this.Z?it(this.Z):"");case 14:return"--"+rt(this.h)+(this.Z?it(this.Z):"");case 13:return"--"+rt(this.h)+"-"+rt(this.s)+(this.Z?it(this.Z):"");case 12:return nt(this.A)+(this.Z?it(this.Z):"");case 11:return nt(this.A)+"-"+rt(this.h)+(this.Z?it(this.Z):"")}throw Error("Unexpected subType")},y(Ht,Ye),(r=Ht.prototype).bb=function(){var e=this.ga%12;return 0===e?0:e},r.cb=function(){return this.ga},r.fb=function(){return Math.trunc(this.ga/12)},r.qa=function(){return!Object.is(-0,this.ga)&&0<=this.ga},r.toString=function(){return(this.qa()?"P":"-P")+_t(this)},y(Lt,Ye),(r=Lt.prototype).ab=function(){return this.Ha.ab()},r.getHours=function(){return this.Ha.getHours()},r.getMinutes=function(){return this.Ha.getMinutes()},r.bb=function(){return this.Ua.bb()},r.cb=function(){return this.Ua.cb()},r.eb=function(){return this.Ha.eb()},r.getSeconds=function(){return this.Ha.getSeconds()},r.fb=function(){return this.Ua.fb()},r.qa=function(){return this.Ua.qa()&&this.Ha.qa()},r.toString=function(){var e=this.qa()?"P":"-P",t=_t(this.Ua),n=ze(this.Ha);return"0M"===t?e+n:"T0S"===n?e+t:e+t+n};var $t=[3,6,4,5];function qt(e){if(e(1)||e(19))return function(e){return{v:!0,value:e+""}};if(e(20))return function(e){return{v:!0,value:e}};if(e(23))return function(e){return{v:!0,value:e.prefix?e.prefix+":"+e.localName:e.localName}};if(e(44))return function(e){return{v:!0,value:e.toString()}};if(e(2)){if(e(5)||e(4))return function(e){return{v:!0,value:(e+"").replace("e","E")}};if(e(6)||e(3))return function(e){return isNaN(e)?{v:!0,value:"NaN"}:isFinite(e)?Object.is(e,-0)?{v:!0,value:"-0"}:{v:!0,value:(e+"").replace("e","E").replace("E+","E")}:{v:!0,value:(0>e?"-":"")+"INF"}}}return e(9)||e(7)||e(8)||e(15)||e(14)||e(13)||e(12)||e(11)||e(16)||e(17)||e(18)?function(e){return{v:!0,value:e.toString()}}:e(22)?function(e){return{v:!0,value:e.toUpperCase()}}:function(e){return{v:!0,value:e+""}}}var Vt=[2,5,17,16];function Yt(e,t){function n(t){return ee(e,t)}if(39===t)return function(){return{v:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")}};switch(t){case 19:return function(e){var t=qt(e);return function(e){return(e=t(e)).v?{v:!0,value:V(e.value,19)}:e}}(n);case 1:return function(e){var t=qt(e);return function(e){return(e=t(e)).v?{v:!0,value:V(e.value,1)}:e}}(n);case 6:return function(e){var t=Pt(e,6);return function(e){return(e=t(e)).v?{v:!0,value:V(e.value,6)}:e}}(n);case 3:return function(e){var t=Pt(e,3);return function(e){return(e=t(e)).v?{v:!0,value:V(e.value,3)}:e}}(n);case 4:return function(e){return e(5)?function(e){return{v:!0,value:V(e,4)}}:e(6)||e(3)?function(e){return isNaN(e)||!isFinite(e)?{v:!1,error:Error("FOCA0002: Can not cast "+e+" to xs:decimal")}:Math.abs(e)>Number.MAX_VALUE?{v:!1,error:Error("FOAR0002: Can not cast "+e+" to xs:decimal, it is out of bounds for JavaScript numbers")}:{v:!0,value:V(e,4)}}:e(0)?function(e){return{v:!0,value:V(e?1:0,4)}}:e(1)||e(19)?function(e){var t=parseFloat(e);return!isNaN(t)||isFinite(t)?{v:!0,value:V(t,4)}:{v:!1,error:Error("FORG0001: Can not cast "+e+" to xs:decimal")}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")}}}(n);case 5:return function(e){return e(0)?function(e){return{v:!0,value:V(e?1:0,5)}}:e(2)?function(e){var t=Math.trunc(e);return!isFinite(t)||isNaN(t)?{v:!1,error:Error("FOCA0002: can not cast "+e+" to xs:integer")}:Number.isSafeInteger(t)?{v:!0,value:V(t,5)}:{v:!1,error:Error("FOAR0002: can not cast "+e+" to xs:integer, it is out of bounds for JavaScript numbers.")}}:e(1)||e(19)?function(e){var t=parseInt(e,10);return isNaN(t)?{v:!1,error:Ct(e,5)}:Number.isSafeInteger(t)?{v:!0,value:V(t,5)}:{v:!1,error:Error("FOCA0003: can not cast "+e+" to xs:integer, it is out of bounds for JavaScript numbers.")}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")}}}(n);case 2:return function(e){var t=Yt;return function(n){for(var r=c($t),o=r.next();!o.done;o=r.next())if((o=t(e,o.value)(n)).v)return o;return{v:!1,error:Error('XPTY0004: Casting not supported from "'+n+'" given type to xs:numeric or any of its derived types.')}}}(e);case 18:return function(e){return e(16)?function(e){return{v:!0,value:V(new Lt(e,new Je(e.qa()?0:-0)),18)}}:e(17)?function(e){return{v:!0,value:V(e=new Lt(new Ht(e.qa()?0:-0),e),18)}}:e(18)?function(e){return{v:!0,value:V(e,18)}}:e(19)||e(1)?function(e){return{v:!0,value:V(new Lt(jt(e),We(e)),18)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")}}}(n);case 16:return function(e){return e(18)&&!e(17)?function(e){return{v:!0,value:V(e.Ua,16)}}:e(17)?function(){return{v:!0,value:V(jt("P0M"),16)}}:e(19)||e(1)?function(e){var t=jt(e);return t?{v:!0,value:V(t,16)}:{v:!1,error:Ct(e,16)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")}}}(n);case 17:return function(e){return e(18)&&!e(16)?function(e){return{v:!0,value:V(e.Ha,17)}}:e(16)?function(){return{v:!0,value:V(We("PT0.0S"),17)}}:e(19)||e(1)?function(e){var t=We(e);return t?{v:!0,value:V(t,17)}:{v:!1,error:Error("FORG0001: Can not cast "+e+" to xs:dayTimeDuration")}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")}}}(n);case 9:return function(e){return e(7)?function(e){return{v:!0,value:V(ut(e,9),9)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),9)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")}}}(n);case 8:return function(e){return e(9)?function(e){return{v:!0,value:V(ut(e,8),8)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),8)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")}}}(n);case 7:return function(e){return e(9)?function(e){return{v:!0,value:V(ut(e,7),7)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),7)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")}}}(n);case 11:return function(e){return e(7)||e(9)?function(e){return{v:!0,value:V(ut(e,11),11)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),11)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")}}}(n);case 12:return function(e){return e(7)||e(9)?function(e){return{v:!0,value:V(ut(e,12),12)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),12)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")}}}(n);case 13:return function(e){return e(7)||e(9)?function(e){return{v:!0,value:V(ut(e,13),13)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),13)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")}}}(n);case 15:return function(e){return e(7)||e(9)?function(e){return{v:!0,value:V(ut(e,15),15)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),15)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")}}}(n);case 14:return function(e){return e(7)||e(9)?function(e){return{v:!0,value:V(ut(e,14),14)}}:e(19)||e(1)?function(e){return{v:!0,value:V(st(e),14)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")}}}(n);case 0:return function(e){return e(2)?function(e){return{v:!0,value:0===e||isNaN(e)?Q:Y}}:e(1)||e(19)?function(e){switch(e){case"true":case"1":return{v:!0,value:Y};case"false":case"0":return{v:!0,value:Q};default:return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")}}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")}}}(n);case 21:return function(e){return e(22)?function(e){for(var t="",n=0;n<e.length;n+=2)t+=String.fromCharCode(parseInt(e.substr(n,2),16));return{v:!0,value:V(btoa(t),21)}}:e(1)||e(19)?function(e){return{v:!0,value:V(e,21)}}:function(){return{error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),v:!1}}}(n);case 22:return function(e){return e(21)?function(e){for(var t="",n=0,r=(e=atob(e)).length;n<r;n++)t+=Number(e.charCodeAt(n)).toString(16);return{v:!0,value:V(t.toUpperCase(),22)}}:e(1)||e(19)?function(e){return{v:!0,value:V(e,22)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")}}}(n);case 20:return function(e){return e(1)||e(19)?function(e){return{v:!0,value:V(e,20)}}:function(){return{v:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")}}}(n);case 23:throw Error("Casting to xs:QName is not implemented.")}return function(){return{v:!1,error:Error("XPTY0004: Casting not supported from "+e+" to "+t+".")}}}var Qt=Object.create(null);function Jt(e,t){if(19===e&&1===t)return function(e){return{v:!0,value:V(e,1)}};if(44===t)return function(){return{v:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")}};if(39===t)return function(){return{v:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")}};if(45===e||45===t)return function(){return{v:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")}};if(46===e||46===t)return function(){return{v:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")}};if(ee(e,60)&&1===t)return function(){return{v:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")}};if(e===t)return function(e){return{v:!0,value:{type:t,value:e}}};var n=Vt.includes(e)?e:Mt(e),r=Vt.includes(t)?t:Mt(t);if(null===r||null===n)return function(){return{v:!1,error:Error("XPST0081: Can not cast: type "+(r?ie[e]:ie[t])+" is unknown.")}};var o=[];return 1!==n&&19!==n||o.push((function(e){var n=kt(e,t);return Ft(n,t)?{v:!0,value:n}:{v:!1,error:Ct(e,t,"pattern validation failed.")}})),n!==r&&(o.push(Yt(n,r)),o.push((function(e){return{v:!0,value:e.value}}))),19!==r&&1!==r||o.push((function(e){return Ft(e,t)?{v:!0,value:e}:{v:!1,error:Ct(e,t,"pattern validation failed.")}})),o.push((function(e){return function(e,t){for(var n=q[t];n;){if(n.Ka&&!Object.keys(n.Ka).every((function(t){if("whiteSpace"===t)return!0;var r=Gt(n,t);return!r||r(e,n.Ka[t])})))return!1;n=n.parent}return!0}(e,t)?{v:!0,value:e}:{v:!1,error:Ct(e,t,"pattern validation failed.")}})),o.push((function(e){return{v:!0,value:{type:t,value:e}}})),function(e){e={v:!0,value:e};for(var t=0,n=o.length;t<n&&!1!==(e=o[t](e.value)).v;++t);return e}}function zt(e,t){var n=e.type+1e4*t,r=Qt[n];return r||(r=Qt[n]=Jt(e.type,t)),r.call(void 0,e.value,t)}function Kt(e,t){if(!0===(e=zt(e,t)).v)return e.value;throw e.error}function Wt(e){var t=!1;return{next:function(){return t?K:(t=!0,W(e))}}}function Zt(e,t){return e===t||!(!e||!t||e.offset!==t.offset||e.parent!==t.parent)&&Zt(e.F,t.F)}function en(e,t){return!!(e===t||e.node===t.node&&Zt(e.F,t.F))}function tn(e,t){for(var n=[];t;t=Ge(e,t,null))n.unshift(t);return n}function nn(e,t){for(var n=[];t;t=e.getParentNode(t,null))n.unshift(t);return n}function rn(e,t,n,r){if(n.F||r.F||Ie(n.node)||Ie(r.node)){if(en(n,r))return 0;n=tn(t,n),r=tn(t,r);var o=n[0],i=r[0];if(!en(o,i))return t=e.findIndex((function(e){return en(e,o)})),n=e.findIndex((function(e){return en(e,i)})),-1===t&&(t=e.push(o)),-1===n&&(n=e.push(i)),t-n;e=1;for(var a=Math.min(n.length,r.length);e<a&&en(n[e],r[e]);++e);return n[e]?r[e]?function(e,t,n){var r=Ge(e,t,null);e=De(e,r,null),r=0;for(var o=e.length;r<o;++r){var i=e[r];if(en(i,t))return-1;if(en(i,n))return 1}}(t,n[e],r[e]):1:-1}if((n=n.node)===(r=r.node))return 0;if(n=nn(t,n),r=nn(t,r),n[0]!==r[0]){var s={node:n[0],F:null},u={node:r[0],F:null};return t=e.findIndex((function(e){return en(e,s)})),n=e.findIndex((function(e){return en(e,u)})),-1===t&&(t=e.push(s)),-1===n&&(n=e.push(u)),t-n}for(a=1,e=Math.min(n.length,r.length);a<e&&n[a]===r[a];++a);if(e=n[a],n=r[a],!e)return-1;if(!n)return 1;for(t=t.getChildNodes(r[a-1],null),r=0,a=t.length;r<a;++r){var c=t[r];if(c===e)return-1;if(c===n)return 1}}function on(e,t,n,r){var o=ee(n.type,47),i=ee(r.type,47);if(o&&!i){if(en(n=Ge(t,n.value),r=r.value))return 1}else if(i&&!o){if(en(n=n.value,r=Ge(t,r.value)))return-1}else if(o&&i){if(en(Ge(t,r.value),Ge(t,n.value)))return n.value.node.localName>r.value.node.localName?1:-1;n=Ge(t,n.value),r=Ge(t,r.value)}else n=n.value,r=r.value;return rn(e,t,n,r)}function an(e,t,n){return on(e.s,e,t,n)}function sn(e,t){return cn(t,(function(t,n){return on(e.s,e,t,n)})).filter((function(e,t,n){return 0===t||!en(e.value,n[t-1].value)}))}function un(e,t){return e<t?-1:0}function cn(e,t){if(t=void 0===t?un:t,1>=e.length)return e;var n=Math.floor(e.length/2),r=cn(e.slice(0,n),t);for(e=cn(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))}var ln=e;function pn(e,t,n,r,o){if(ee(e.type,t.type))return e;if(ee(t.type,46)&&ee(e.type,53)&&(e=Dt(e,n).first()),ee(e.type,t.type)||46===t.type)return e;if(ee(e.type,19)){if(!(n=Kt(e,t.type)))throw Error("XPTY0004 Unable to convert "+(o?"return":"argument")+" of type "+ie[e.type]+" to type "+se(t)+" while calling "+r);return n}if(n=function(e,t){if(ee(e.type,2)){if(ee(e.type,6))return 3===t?V(e.value,3):null;if(ee(e.type,4)){if(6===t)return V(e.value,6);if(3===t)return V(e.value,3)}return null}return ee(e.type,20)&&1===t?V(e.value,1):null}(e,t.type),!n)throw Error("XPTY0004 Unable to cast "+(o?"return":"argument")+" of type "+ie[e.type]+" to type "+se(t)+" while calling "+r);return n}function hn(e){switch(e){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}function fn(e,t,n,r,o){return 0===e.g?t.$({default:function(){return t.map((function(t){return pn(t,e,n,r,o)}))},multiple:function(){throw Error("XPTY0004: Multiplicity of "+(o?"function return value":"function argument")+" of type "+ie[e.type]+hn(e.g)+" for "+r+' is incorrect. Expected "?", but got "+".')}}):1===e.g?t.$({empty:function(){throw Error("XPTY0004: Multiplicity of "+(o?"function return value":"function argument")+" of type "+ie[e.type]+hn(e.g)+" for "+r+' is incorrect. Expected "+", but got "empty-sequence()"')},default:function(){return t.map((function(t){return pn(t,e,n,r,o)}))}}):2===e.g?t.map((function(t){return pn(t,e,n,r,o)})):t.$({o:function(){return t.map((function(t){return pn(t,e,n,r,o)}))},default:function(){throw Error("XPTY0004: Multiplicity of "+(o?"function return value":"function argument")+" of type "+ie[e.type]+hn(e.g)+" for "+r+" is incorrect. Expected exactly one")}})}function dn(e,t){return ee(e,5)?V(t,5):ee(e,6)?V(t,6):ee(e,3)?V(t,3):V(t,4)}var mn=[{oa:"M",ma:1e3},{oa:"CM",ma:900},{oa:"D",ma:500},{oa:"CD",ma:400},{oa:"C",ma:100},{oa:"XC",ma:90},{oa:"L",ma:50},{oa:"XL",ma:40},{oa:"X",ma:10},{oa:"IX",ma:9},{oa:"V",ma:5},{oa:"IV",ma:4},{oa:"I",ma:1}];function gn(e,t){var n=parseInt(e,10);if(e=0>n,!(n=Math.abs(n)))return"-";var r=mn.reduce((function(e,t){var r=Math.floor(n/t.ma);return n-=r*t.ma,e+t.oa.repeat(r)}),"");return t&&(r=r.toLowerCase()),e&&(r="-"+r),r}var yn="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");function vn(e,t){var n=0>(e=parseInt(e,10));if(!(e=Math.abs(e)))return"-";for(var r,o="";0<e;)r=(e-1)%yn.length,o=yn[r]+o,e=(e-r)/yn.length|0;return t&&(o=o.toLowerCase()),n&&(o="-"+o),o}function wn(e,t,n,r,o,i){var a=!1;return ge.create({next:function(){if(a)return K;var t,n=o.first();if(!n)return a=!0,K;if((ee(n.type,6)||ee(n.type,3))&&(0===n.value||isNaN(n.value)||1/0===n.value||-1/0===n.value))return a=!0,W(n);if(t=i?i.first().value:0,a=!0,function(e){if(Math.floor(e)===e||isNaN(e))return 0;var t=(e=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(""+e))[1]?e[1].length:0;return e[3]?e[2]?t+parseInt(e[3],10):0>(e=t-parseInt(e[3],10))?0:e:t}(n.value)<t)return W(n);var r=[5,4,3,6].find((function(e){return ee(n.type,e)}));switch(t=function(e,t,n){return t&&0==e*n%1%.5?0==Math.floor(e*n)%2?Math.floor(e*n)/n:Math.ceil(e*n)/n:Math.round(e*n)/n}(Kt(n,4).value,e,Math.pow(10,t)),r){case 4:return W(V(t,4));case 3:return W(V(t,3));case 6:return W(V(t,6));case 5:return W(V(t,5))}}})}function An(e,t,n,r){return Ut(r,t).$({empty:function(){return ge.o(V(NaN,3))},o:function(){var e=zt(r.first(),3);return e.v?ge.o(e.value):ge.o(V(NaN,3))},multiple:function(){throw Error("fn:number may only be called with zero or one values")}})}function xn(e,t,n,r){if(r.G()||r.ta())return r;for(t=(e=r.N()).length-1;1<t;t--)r=e[n=Math.floor(Math.random()*(t+1))],e[n]=e[t],e[t]=r;return ge.create(e)}var bn=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",l:[{type:2,g:0}],i:{type:2,g:0},m:function(e,t,n,r){return r.map((function(e){return dn(e.type,Math.abs(e.value))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"format-integer",l:[{type:5,g:0},{type:1,g:3}],i:{type:1,g:3},m:function(e,t,n,r,o){if(e=r.first(),o=o.first(),r.G())return ge.o(V("",1));switch(o.value){case"I":return r=gn(e.value),ge.o(V(r,1));case"i":return r=gn(e.value,!0),ge.o(V(r,1));case"A":return ge.o(V(vn(e.value),1));case"a":return ge.o(V(vn(e.value,!0),1));default:throw Error("Picture: "+o.value+' is not implemented yet. The supported picture strings are "A", "a", "I", and "i"')}}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ceiling",l:[{type:2,g:0}],i:{type:2,g:0},m:function(e,t,n,r){return r.map((function(e){return dn(e.type,Math.ceil(e.value))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",l:[{type:2,g:0}],i:{type:2,g:0},m:function(e,t,n,r){return r.map((function(e){return dn(e.type,Math.floor(e.value))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",l:[{type:2,g:0}],i:{type:2,g:0},m:wn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",l:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},m:wn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",l:[{type:2,g:0}],i:{type:2,g:0},m:wn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",l:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},m:wn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",l:[{type:46,g:0}],i:{type:3,g:3},m:An},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",l:[],i:{type:3,g:3},m:function(e,t,n){var r=e.M&&fn({type:46,g:0},ge.o(e.M),t,"fn:number",!1);if(!r)throw Error("XPDY0002: fn:number needs an atomizable context item.");return An(0,t,0,r)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",l:[],i:{type:61,g:3},m:function e(){return ge.o(new Ve([{key:V("number",1),value:function(){return ge.o(V(Math.random(),3))}},{key:V("next",1),value:function(){return ge.o(new we({value:e,Ra:!0,localName:"",namespaceURI:"",l:[],arity:0,i:{type:61,g:3}}))}},{key:V("permute",1),value:function(){return ge.o(new we({value:xn,Ra:!0,localName:"",namespaceURI:"",l:[{type:59,g:2}],arity:1,i:{type:59,g:2}}))}}]))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",l:[{type:46,g:0}],i:{type:61,g:3},m:function(){throw Error("Not implemented: Specifying a seed is not supported")}}];function En(){throw Error("FOCH0002: No collations are supported")}function Nn(e,t,n,r){if(null===t.M)throw Error("XPDY0002: The function which was called depends on dynamic context, which is absent.");return e(t,n,r,ge.o(t.M))}function Bn(e,t,n,r){return r.$({empty:function(){return ge.o(V("",1))},default:function(){return r.map((function(e){if(ee(e.type,53)){var n=Dt(e,t).first();return ee(e.type,47)?Kt(n,1):n}return Kt(e,1)}))}})}function Tn(e,t,n,r,o){return Le([o],(function(e){var n=c(e).next().value;return Ut(r,t).L((function(e){return e=e.map((function(e){return Kt(e,1).value})).join(n.value),ge.o(V(e,1))}))}))}function In(e,t,n,r){return r.G()?ge.o(V(0,5)):(e=r.first().value,ge.o(V(Array.from(e).length,5)))}function Cn(e,t,n,r,o,i){var a=wn(!1,0,0,0,o,null),s=null!==i?wn(!1,0,0,0,i,null):null,u=!1,c=null,l=null,p=null;return ge.create({next:function(){return u?K:c||null!==(c=r.first())?(l||(l=a.first()),!p&&i&&(p=null,p=s.first()),u=!0,W(V(Array.from(c.value).slice(Math.max(l.value-1,0),i?l.value+p.value-1:void 0).join(""),1))):(u=!0,W(V("",1)))}})}function Sn(e,t,n,r,o){return r.G()||0===r.first().value.length?ge.empty():(e=r.first().value,o=Un(o=o.first().value),ge.create(e.split(o).map((function(e){return V(e,1)}))))}function On(e,t,n,r){return r.G()?ge.o(V("",1)):(e=r.first().value.trim(),ge.o(V(e.replace(/\s+/g," "),1)))}var Rn=new Map,Dn=new Map;function Un(e){if(Dn.has(e))return Dn.get(e);try{var t=new RegExp(e,"g")}catch(e){throw Error("FORX0002: "+e)}if(t.test(""))throw Error("FORX0003: the pattern "+e+" matches the zero length string");return Dn.set(e,t),t}var Mn=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",l:[{type:1,g:0},{type:1,g:0}],i:{type:5,g:0},m:function(e,t,n,r,o){return r.G()||o.G()?ge.empty():(e=r.first().value)>(o=o.first().value)?ge.o(V(1,5)):e<o?ge.o(V(-1,5)):ge.o(V(0,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",l:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:5,g:0},m:En},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",l:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},m:function(e,t,n,r){for(var o=[],i=3;i<arguments.length;++i)o[i-3]=arguments[i];return o=o.map((function(e){return Ut(e,t).L((function(e){return ge.o(V(e.map((function(e){return null===e?"":Kt(e,1).value})).join(""),1))}))})),Le(o,(function(e){return ge.o(V(e.map((function(e){return e.value})).join(""),1))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",l:[{type:1,g:0},{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},m:En},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",l:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},m:function(e,t,n,r,o){return e=r.G()?"":r.first().value,0===(o=o.G()?"":o.first().value).length?ge.ca():0===e.length?ge.X():e.includes(o)?ge.ca():ge.X()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",l:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},m:function(e,t,n,r,o){return 0===(e=o.G()?"":o.first().value).length?ge.ca():0===(r=r.G()?"":r.first().value).length?ge.X():r.endsWith(e)?ge.ca():ge.X()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",l:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},m:En},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",l:[{type:1,g:0}],i:{type:1,g:3},m:On},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",l:[],i:{type:1,g:3},m:Nn.bind(null,(function(e,t,n,r){return On(e,0,0,Bn(0,t,0,r))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",l:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},m:function(e,t,n,r,o){return 0===(e=o.G()?"":o.first().value).length?ge.ca():0===(r=r.G()?"":r.first().value).length?ge.X():r.startsWith(e)?ge.ca():ge.X()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",l:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},m:En},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",l:[{type:59,g:0}],i:{type:1,g:3},m:Bn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",l:[],i:{type:1,g:3},m:Nn.bind(null,Bn)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-before",l:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},m:function(e,t,n,r,o){return e=r.G()?"":r.first().value,""===(o=o.G()?"":o.first().value)||-1===(o=e.indexOf(o))?ge.o(V("",1)):ge.o(V(e.substring(0,o),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",l:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},m:function(e,t,n,r,o){return e=r.G()?"":r.first().value,""===(o=o.G()?"":o.first().value)?ge.o(V(e,1)):-1===(t=e.indexOf(o))?ge.o(V("",1)):ge.o(V(e.substring(t+o.length),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",l:[{type:1,g:0},{type:3,g:3}],i:{type:1,g:3},m:Cn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",l:[{type:1,g:0},{type:3,g:3},{type:3,g:3}],i:{type:1,g:3},m:Cn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"upper-case",l:[{type:1,g:0}],i:{type:1,g:3},m:function(e,t,n,r){return r.G()?ge.o(V("",1)):r.map((function(e){return V(e.value.toUpperCase(),1)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"lower-case",l:[{type:1,g:0}],i:{type:1,g:3},m:function(e,t,n,r){return r.G()?ge.o(V("",1)):r.map((function(e){return V(e.value.toLowerCase(),1)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",l:[{type:46,g:2},{type:1,g:3}],i:{type:1,g:3},m:Tn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",l:[{type:46,g:2}],i:{type:1,g:3},m:function(e,t,n,r){return Tn(0,t,0,r,ge.o(V("",1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",l:[{type:1,g:0}],i:{type:5,g:3},m:In},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",l:[],i:{type:5,g:3},m:Nn.bind(null,(function(e,t,n,r){return In(e,0,0,Bn(0,t,0,r))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",l:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],i:{type:1,g:2},m:function(){throw Error("Not implemented: Using flags in tokenize is not supported")}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",l:[{type:1,g:0},{type:1,g:3}],i:{type:1,g:2},m:Sn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",l:[{type:1,g:0}],i:{type:1,g:2},m:function(e,t,n,r){return Sn(e,0,0,On(e,0,0,r),ge.o(V(" ",1)))}},{l:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],m:function(e,t,n,r,o,i){return Le([r,o,i],(function(e){var t=c(e),n=t.next().value;e=t.next().value,t=t.next().value,n=Array.from(n?n.value:"");var r=Array.from(e.value),o=Array.from(t.value);return e=n.map((function(e){return r.includes(e)?(e=r.indexOf(e))<=o.length?o[e]:void 0:e})),ge.o(V(e.join(""),1))}))},localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:5,g:2}],m:function(e,t,n,r){return r.L((function(e){return e=e.map((function(e){if(9===(e=e.value)||10===e||13===e||32<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e)return String.fromCodePoint(e);throw Error("FOCH0001")})).join(""),ge.o(V(e,1))}))},localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:1,g:0}],m:function(e,t,n,r){return Le([r],(function(e){return 0===(e=(e=c(e).next().value)?e.value.split(""):[]).length?ge.empty():ge.create(e.map((function(e){return V(e.codePointAt(0),5)})))}))},localName:"string-to-codepoints",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{l:[{type:1,g:0}],m:function(e,t,n,r){return Le([r],(function(e){return null===(e=c(e).next().value)||0===e.value.length?ge.create(V("",1)):ge.create(V(encodeURIComponent(e.value).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})),1))}))},localName:"encode-for-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:1,g:0}],m:function(e,t,n,r){return Le([r],(function(e){return null===(e=c(e).next().value)||0===e.value.length?ge.create(V("",1)):ge.create(V(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,(function(e){return encodeURI(e)})),1))}))},localName:"iri-to-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:1,g:0},{type:1,g:0}],m:function(e,t,n,r,o){return Le([r,o],(function(e){var t=c(e);if(e=t.next().value,t=t.next().value,null===e||null===t)return ge.empty();if(e=e.value,t=t.value,e.length!==t.length)return ge.X();e=e.split(""),t=t.split("");for(var n=0;n<e.length;n++)if(e[n].codePointAt(0)!==t[n].codePointAt(0))return ge.X();return ge.ca()}))},localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:0}},{l:[{type:1,g:0},{type:1,g:3}],m:function(e,t,n,r,o){return Le([r,o],(function(e){var t=c(e);e=t.next().value,t=t.next().value,e=e?e.value:"",t=t.value;var n=Rn.get(t);if(!n){try{n=ln.compile(t,{language:"xpath"})}catch(e){throw Error("FORX0002: "+e)}Rn.set(t,n)}return n(e)?ge.ca():ge.X()}))},localName:"matches",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],m:function(e,t,n,r,o,i){return Le([r,o,i],(function(e){var t=c(e);e=t.next().value;var n=t.next().value;if(t=t.next().value,e=e?e.value:"",n=n.value,(t=t.value).includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");return t=t.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map((function(e){switch(e){case"\\$":return"$$";case"\\\\":return"\\";case"$$":throw Error('FORX0004: invalid replacement: "$$"');default:return e}})).join(""),n=Un(n),e=e.replace(n,t),ge.o(V(e,1))}))},localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{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},m:function(){throw Error("Not implemented: Using flags in replace is not supported")}}];function kn(e,t,n,r){if(null===t.M)throw Error("XPDY0002: The function which was called depends on dynamic context, which is absent.");return e(t,n,r,ge.o(t.M))}function Fn(e,t,n,r){return Le([r],(function(e){if(null===(e=c(e).next().value))return ge.empty();switch((e=e.value).node.nodeType){case 1:case 2:return ge.o(V(new ve(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return ge.o(V(new ve("","",e.node.target),23));default:return ge.empty()}}))}function Gn(e,t,n,r){return r.$({default:function(){return Bn(0,t,0,Fn(0,0,0,r))},empty:function(){return ge.empty()}})}function Pn(e,t,n,r){return Ut(r,t)}function Hn(e,t,n,r){return Le([r],(function(e){return null!==(e=(e=c(e).next().value)?e.value:null)&&Me(t.h,e,null)?ge.ca():ge.X()}))}function _n(e,t,n,r){return Le([r],(function(e){function n(e){for(var t=0,n=e;null!==n;)(e.node.nodeType!==n.node.nodeType?0:1===n.node.nodeType?n.node.localName===e.node.localName&&n.node.namespaceURI===e.node.namespaceURI:7===n.node.nodeType?n.node.target===e.node.target:1)&&t++,n=Pe(o,n,null);return t}var r=c(e).next().value;if(null===r)return ge.empty();var o=t.h;for(e="",r=r.value;null!==Ge(t.h,r,null);r=Ge(t.h,r,null))switch(r.node.nodeType){case 1:var i=r;e="/Q{"+(i.node.namespaceURI||"")+"}"+i.node.localName+"["+n(i)+"]"+e;break;case 2:e="/@"+((i=r).node.namespaceURI?"Q{"+i.node.namespaceURI+"}":"")+i.node.localName+e;break;case 3:e="/text()["+n(r)+"]"+e;break;case 7:e="/processing-instruction("+(i=r).node.target+")["+n(i)+"]"+e;break;case 8:e="/comment()["+n(r)+"]"+e}return 9===r.node.nodeType?ge.create(V(e||"/",1)):ge.create(V("Q{http://www.w3.org/2005/xpath-functions}root()"+e,1))}))}function jn(e,t,n,r){return r.map((function(e){return V(e.value.node.namespaceURI||"",20)}))}function Xn(e,t,n,r){return r.$({default:function(){return r.map((function(e){return 7===e.value.node.nodeType?V(e.value.node.target,1):V(e.value.node.localName||"",1)}))},empty:function(){return ge.o(V("",1))}})}function Ln(e,t,n){if(2===t.node.nodeType)return en(t,n);for(;n;){if(en(t,n))return!0;if(9===n.node.nodeType)break;n=Ge(e,n,null)}return!1}function $n(e,t,n,r){return r.map((function(e){if(!ee(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");for(e=e.value;e;){var n=e;e=Ge(t.h,n,null)}return Xe(n)}))}var qn=[{l:[{type:53,g:0}],m:Gn,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{l:[],m:kn.bind(null,Gn),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:53,g:3}],m:jn,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{l:[],m:kn.bind(null,jn),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{l:[{type:53,g:2}],m:function(e,t,n,r){return r.L((function(e){return e.length?(e=sn(t.h,e).reduceRight((function(e,n,r,o){return r===o.length-1?(e.push(n),e):(Ln(t.h,n.value,e[0].value)||e.unshift(n),e)}),[]),ge.create(e)):ge.empty()}))},localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{l:[{type:53,g:2}],m:function(e,t,n,r){return r.L((function(e){return e.length?(e=sn(t.h,e).reduce((function(e,n,r){return 0===r?(e.push(n),e):(Ln(t.h,e[e.length-1].value,n.value)||e.push(n),e)}),[]),ge.create(e)):ge.empty()}),1)},localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{l:[{type:53,g:0}],m:Hn,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[],m:kn.bind(null,Hn),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:53,g:0}],m:_n,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{l:[],m:kn.bind(null,_n),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{l:[{type:53,g:0}],m:Fn,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{l:[],m:kn.bind(null,Fn),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{l:[{type:53,g:0}],m:Xn,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[],m:kn.bind(null,Xn),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{l:[{type:53,g:0}],m:$n,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{l:[],m:kn.bind(null,$n),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{l:[],m:kn.bind(null,Pn),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{l:[{type:59,g:2}],m:Pn,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}}];function Vn(e,t){var n=0,r=e.length,o=!1,i=null;return{next:function(){if(!o){for(;n<r;){i||(i=t(e[n],n,e));var a=i.next(0);if(i=null,!a.value)return W(!1);n++}return o=!0,W(!0)}return K}}}function Yn(e){return 1===(e=e.node.nodeType)||3===e}function Qn(e,t){if((ee(e.type,4)||ee(e.type,6))&&(ee(t.type,4)||ee(t.type,6))){var n=Kt(e,6),r=Kt(t,6);return n.value===r.value||isNaN(e.value)&&isNaN(t.value)}return(ee(e.type,4)||ee(e.type,6)||ee(e.type,3))&&(ee(t.type,4)||ee(t.type,6)||ee(t.type,3))?(n=Kt(e,3),r=Kt(t,3),n.value===r.value||isNaN(e.value)&&isNaN(t.value)):ee(e.type,23)&&ee(t.type,23)?e.value.namespaceURI===t.value.namespaceURI&&e.value.localName===t.value.localName:(ee(e.type,9)||ee(e.type,7)||ee(e.type,8)||ee(e.type,11)||ee(e.type,12)||ee(e.type,13)||ee(e.type,14)||ee(e.type,15))&&(ee(t.type,9)||ee(t.type,7)||ee(t.type,8)||ee(t.type,11)||ee(t.type,12)||ee(t.type,13)||ee(t.type,14)||ee(t.type,15))?pt(e.value,t.value):(ee(e.type,16)||ee(e.type,17)||ee(e.type,18))&&(ee(t.type,16)||ee(t.type,17)||ee(t.type,17))?Qe(e.value,t.value):e.value===t.value}function Jn(e,t,n){return n=c([t,n].map((function(t){return{type:1,value:t.reduce((function(t,n){return t+Dt(n,e).first().value}),"")}}))),W(Qn(t=n.next().value,n=n.next().value))}function zn(e,t,n,r){for(;e.value&&ee(e.value.type,56);){t.push(e.value);var o=Fe(r,e.value.value);if(e=n.next(0),o&&3!==o.node.nodeType)break}return e}function Kn(e,t,n,r,o){var i,a=t.h,s=r.value,u=o.value,c=null,l=null,p=null,h=[],f=[];return{next:function(){for(;!i;)if(c||(c=s.next(0)),c=zn(c,h,s,a),l||(l=u.next(0)),l=zn(l,f,u,a),h.length||f.length){var r=Jn(t,h,f);if(h.length=0,f.length=0,!1===r.value)return i=!0,r}else{if(c.done||l.done)return i=!0,W(c.done===l.done);if(p||(p=Zn(e,t,n,c.value,l.value)),r=p.next(0),p=null,!1===r.value)return i=!0,r;l=c=null}return K}}}function Wn(e,t,n,r,o){return r=De(t.h,r.value),o=De(t.h,o.value),r=r.filter((function(e){return Yn(e)})),o=o.filter((function(e){return Yn(e)})),r=ge.create(r.map((function(e){return Xe(e)}))),o=ge.create(o.map((function(e){return Xe(e)}))),Kn(e,t,n,r,o)}function Zn(e,t,n,r,o){if(ee(r.type,46)&&ee(o.type,46))return Wt(Qn(r,o));if(ee(r.type,61)&&ee(o.type,61))return function(e,t,n,r,o){return r.h.length!==o.h.length?Wt(!1):Vn(r.h,(function(r){var i=o.h.find((function(e){return Qn(e.key,r.key)}));return i?Kn(e,t,n,r.value(),i.value()):Wt(!1)}))}(e,t,n,r,o);if(ee(r.type,62)&&ee(o.type,62))return function(e,t,n,r,o){return r.R.length!==o.R.length?Wt(!1):Vn(r.R,(function(r,i){return i=o.R[i],Kn(e,t,n,r(),i())}))}(e,t,n,r,o);if(ee(r.type,53)&&ee(o.type,53)){if(ee(r.type,55)&&ee(o.type,55))return Wn(e,t,n,r,o);if(ee(r.type,54)&&ee(o.type,54))return function(e,t,n,r,o){var i=Kn(e,t,n,Fn(0,0,0,ge.o(r)),Fn(0,0,0,ge.o(o))),a=Wn(e,t,n,r,o);r=Oe(t.h,r.value).filter((function(e){return"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI})).sort((function(e,t){return e.node.nodeName>t.node.nodeName?1:-1})).map((function(e){return Xe(e)})),o=Oe(t.h,o.value).filter((function(e){return"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI})).sort((function(e,t){return e.node.nodeName>t.node.nodeName?1:-1})).map((function(e){return Xe(e)}));var s=Kn(e,t,n,ge.create(r),ge.create(o)),u=!1;return{next:function(){if(u)return K;var e=i.next(0);return!e.done&&!1===e.value||!(e=s.next(0)).done&&!1===e.value?(u=!0,e):(e=a.next(0),u=!0,e)}}}(e,t,n,r,o);if(ee(r.type,47)&&ee(o.type,47)||ee(r.type,57)&&ee(o.type,57)||ee(r.type,58)&&ee(o.type,58))return function(e,t,n,r,o){var i=Kn(e,t,n,Fn(0,0,0,ge.o(r)),Fn(0,0,0,ge.o(o))),a=!1;return{next:function(){if(a)return K;var e=i.next(0);return e.done||!1!==e.value?W(Qn(Dt(r,t).first(),Dt(o,t).first())):(a=!0,e)}}}(e,t,n,r,o)}return Wt(!1)}function er(e){return Error("XUST0001: "+(void 0===e?"Can not execute an updating expression in a non-updating context.":e))}function tr(e){return Error("XUTY0004: The attribute "+e.name+'="'+e.value+'" follows a node that is not an attribute node.')}function nr(){return Error("XUTY0005: The target of a insert expression with into must be a single element or document node.")}function rr(){return Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node.")}function or(){return Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node.")}function ir(){return Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node.")}function ar(e){return Error("XUDY0017: The target "+e.outerHTML+" is used in more than one replace value of expression.")}function sr(e){return Error("XUDY0021: Applying the updates will result in the XDM instance violating constraint: '"+e+"'")}function ur(e){return Error("XUDY0023: The namespace binding "+e+" is conflicting.")}function cr(e){return Error("XUDY0024: The namespace binding "+e+" is conflicting.")}function lr(){return Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.")}function pr(e,t,n,r,o){n=void 0===n?{C:!1,Y:!1,S:"unsorted",subtree:!1}:n,this.s=e,this.O=n.S||"unsorted",this.subtree=!!n.subtree,this.Y=!!n.Y,this.C=!!n.C,this.ha=t,this.I=!1,this.$a=null,this.dc=void 0!==r&&r,this.type=o}function hr(e,t,n){return t&&null!==t.M&&e.C?(null===e.$a&&(e.$a=ye(e.h(null,n).qb())),e=e.$a()):e=e.h(t,n),e}function fr(e,t){this.H=e,this.fa=t}function dr(e){e&&"object"==typeof e&&"nodeType"in e&&("function"==typeof(e=e.ownerDocument||e).createElementNS&&"function"==typeof e.createProcessingInstruction&&"function"==typeof e.createTextNode&&"function"==typeof e.createComment&&(this.h=e)),this.h||(this.h=null)}function mr(e,t,n){t.forEach((function(t){n.insertBefore(e.node,t.node,null)}))}function gr(e,t,n,r){var o=Ge(n,e),i=e.node.nodeType;if(2===i){if(t.some((function(e){return 2!==e.node.nodeType})))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');var a=o?o.node:null;r.removeAttributeNS(a,e.node.namespaceURI,e.node.nodeName),t.forEach((function(e){var t=e.node.nodeName;if(Re(n,o,t))throw sr("An attribute "+t+" already exists.");r.setAttributeNS(a,e.node.namespaceURI,t,Ue(n,e))}))}if(1===i||3===i||8===i||7===i){var s=(i=Fe(n,e))?i.node:null;r.removeChild(o.node,e.node),t.forEach((function(e){r.insertBefore(o.node,e.node,s)}))}}function yr(e,t,n,r){if(function(e,t){function n(e){return new ve(e.node.prefix,e.node.namespaceURI,e.node.localName)}function r(t,n){var r=new Set;e.filter((function(e){return e.type===t})).map((function(e){return e.target})).forEach((function(e){e=e?e.node:null,r.has(e)&&n(e),r.add(e)}))}r("rename",(function(e){throw Error("XUDY0015: The target "+e.outerHTML+" is used in more than one rename expression.")})),r("replaceNode",(function(e){throw Error("XUDY0016: The target "+e.outerHTML+" is used in more than one replace expression.")})),r("replaceValue",(function(e){throw ar(e)})),r("replaceElementContent",(function(e){throw ar(e)}));var o=new Map;e.filter((function(e){return"replaceNode"===e.type&&2===e.target.node.nodeType})).forEach((function(e){var r=Ge(t,e.target);r=r?r.node:null;var i=o.get(r);i?i.push.apply(i,p(e.s.map(n))):o.set(r,e.s.map(n))})),e.filter((function(e){return"rename"===e.type&&2===e.target.node.nodeType})).forEach((function(e){var n=Ge(t,e.target);if(n){n=n.node;var r=o.get(n);r?r.push(e.s):o.set(n,[e.s])}})),o.forEach((function(e){var t={};e.forEach((function(e){if(t[e.prefix]||(t[e.prefix]=e.namespaceURI),t[e.prefix]!==e.namespaceURI)throw cr(e.namespaceURI)}))}))}(e,t),e.filter((function(e){return-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type)})).forEach((function(e){switch(e.type){case"insertInto":mr(e.target,e.content,r);break;case"insertAttributes":!function(e,t,n,r){t.forEach((function(t){var o=t.node.nodeName;if(Re(n,e,o))throw sr("An attribute "+o+" already exists.");r.setAttributeNS(e.node,t.node.namespaceURI,o,Ue(n,t))}))}(e.target,e.content,t,r);break;case"rename":!function(e,t,n,r,o){switch(r||(r=new dr(e?e.node:null)),e.node.nodeType){case 1:var i=n.getAllAttributes(e.node),a=n.getChildNodes(e.node),s=r.createElementNS(t.namespaceURI,t.ya()),u={node:s,F:null};i.forEach((function(e){o.setAttributeNS(s,e.namespaceURI,e.nodeName,e.value)})),a.forEach((function(e){o.insertBefore(s,e,null)}));break;case 2:(t=r.createAttributeNS(t.namespaceURI,t.ya())).value=Ue(n,e),u={node:t,F:null};break;case 7:u={node:r.createProcessingInstruction(t.ya(),Ue(n,e)),F:null}}if(!Ge(n,e))throw Error("Not supported: renaming detached nodes.");gr(e,[u],n,o)}(e.target,e.s,t,n,r);break;case"replaceValue":var o=e.target;if(e=e.s,2===o.node.nodeType){var i=Ge(t,o);i?r.setAttributeNS(i.node,o.node.namespaceURI,o.node.nodeName,e):o.node.value=e}else r.setData(o.node,e)}})),e.filter((function(e){return-1!==["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type)})).forEach((function(e){switch(e.type){case"insertAfter":!function(e,t,n,r){var o=Ge(n,e).node,i=(e=Fe(n,e))?e.node:null;t.forEach((function(e){r.insertBefore(o,e.node,i)}))}(e.target,e.content,t,r);break;case"insertBefore":!function(e,t,n,r){var o=Ge(n,e).node;t.forEach((function(t){r.insertBefore(o,t.node,e.node)}))}(e.target,e.content,t,r);break;case"insertIntoAsFirst":!function(e,t,n,r){var o=(n=Me(n,e))?n.node:null;t.forEach((function(t){r.insertBefore(e.node,t.node,o)}))}(e.target,e.content,t,r);break;case"insertIntoAsLast":mr(e.target,e.content,r)}})),e.filter((function(e){return"replaceNode"===e.type})).forEach((function(e){gr(e.target,e.s,t,r)})),e.filter((function(e){return"replaceElementContent"===e.type})).forEach((function(e){!function(e,t,n,r){n.getChildNodes(e.node).forEach((function(t){return r.removeChild(e.node,t)})),t&&r.insertBefore(e.node,t.node,null)}(e.target,e.text,t,r)})),e.filter((function(e){return"delete"===e.type})).forEach((function(e){e=e.target;var n=Ge(t,e);(n=n?n.node:null)&&(2===e.node.nodeType?r.removeAttributeNS(n,e.node.namespaceURI,e.node.nodeName):r.removeChild(n,e.node))})),e.some((function(e){return"put"===e.type})))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.')}function vr(e,t){for(var n=[],r=1;r<arguments.length;++r)n[r-1]=arguments[r];return e.concat.apply(e,p(n.filter(Boolean)))}function wr(e,t,n,r){pr.call(this,e,t,n,!0,r),this.I=!0}function Ar(e){return e.I?function(t,n){return e.u(t,n)}:function(t,n){var r=e.h(t,n);return{next:function(){return W({fa:[],H:r.N()})}}}}function xr(e,t){return t((e=e.next(0)).value.fa),ge.create(e.value.H)}function br(e,t,n,r){wr.call(this,e,t,n,r),this.I=this.ha.some((function(e){return e.I}))}pr.prototype.A=function(){return null},pr.prototype.P=function(e){if(this.ha.forEach((function(t){return t.P(e)})),!this.dc&&this.ha.some((function(e){return e.I})))throw er()},(r=dr.prototype).createAttributeNS=function(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)},r.createCDATASection=function(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createCDATASection(e)},r.createComment=function(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(e)},r.createDocument=function(){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)},r.createElementNS=function(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)},r.createProcessingInstruction=function(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)},r.createTextNode=function(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(e)},y(wr,pr),wr.prototype.h=function(){throw er()},y(br,wr),br.prototype.h=function(e,t){return this.B(e,t,this.ha.map((function(e){return function(n){return e.h(n,t)}})))},br.prototype.u=function(e,t){var n=[],r=this.B(e,t,this.ha.map((function(e){return e.I?function(r){return xr(r=e.u(r,t),(function(e){return n=vr(n,e)}))}:function(n){return e.h(n,t)}}))),o=!1;return{next:function(){if(o)return K;var e=r.N();return o=!0,W(new fr(e,n))}}},br.prototype.P=function(e){wr.prototype.P.call(this,e),function(e){e.ha.some((function(e){return e.I}))&&(e.I=!0)}(this)};var Er=["external","attribute","nodeName","nodeType","universal"],Nr=Er.length;function Br(e){if(this.h=Er.map((function(t){return e[t]||0})),Object.keys(e).some((function(e){return!Er.includes(e)})))throw Error("Invalid specificity kind passed")}function Tr(e,t){for(var n=0;n<Nr;++n){if(t.h[n]<e.h[n])return 1;if(t.h[n]>e.h[n])return-1}return 0}function Ir(){return St("Expected base expression of a function call to evaluate to a sequence of single function item")}function Cr(e,t,n,r){for(var o=[],i=0;i<t.length;++i)if(null===t[i])o.push(null);else{var a=fn(e[i],t[i],n,r,!1);o.push(a)}return o}function Sr(e,t){if(!ee(e.type,60))throw St("Expected base expression to evaluate to a function item");if(e.A!==t)throw Ir();return e}function Or(e,t,n,r,o,i,a){var s=0;return o=o.map((function(e){return e?null:i[s++](n)})),0<=(o=Cr(e.s,o,r,e.j)).indexOf(null)?function(e,t){var n=e.value,r=t.map((function(e){return null===e?null:ye(e)}));return t=t.reduce((function(t,n,r){return null===n&&t.push(e.s[r]),t}),[]),t=new we({l:t,arity:t.length,Ra:!0,I:e.I,localName:"boundFunction",namespaceURI:e.u,i:e.O,value:function(e,t,o){var i=Array.from(arguments).slice(3),a=r.map((function(e){return null===e?i.shift():e()}));return n.apply(void 0,[e,t,o].concat(a))}}),ge.o(t)}(e,o):(t=t.apply(void 0,[n,r,a].concat(p(o))),fn(e.O,t,r,e.j,!0))}function Rr(e,t,n){var r={};br.call(this,new Br((r.external=1,r)),[e].concat(t.filter((function(e){return!!e}))),{S:"unsorted",Y:!1,subtree:!1,C:!1},n),this.ka=t.length,this.T=t.map((function(e){return null===e})),this.J=null,this.pa=e,this.xa=t}function Dr(e,t,n,r,o,i){return Le([r,o,i],(function(e){var t=c(e);e=t.next().value;var n=t.next().value;if(t=t.next().value,n=n.value,t=t.value,n>e.R.length||0>=n)throw Error("FOAY0001: subarray start out of bounds.");if(0>t)throw Error("FOAY0002: subarray length out of bounds.");if(n+t>e.R.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return ge.o(new _e(e.R.slice(n-1,t+n-1)))}))}function Ur(e,t,n,r,o){return Le([r],(function(e){var t=c(e).next().value;return o.L((function(e){e=e.map((function(e){return e.value})).sort((function(e,t){return t-e})).filter((function(e,t,n){return n[t-1]!==e}));for(var n=t.R.concat(),r=0,o=e.length;r<o;++r){var i=e[r];if(i>t.R.length||0>=i)throw Error("FOAY0001: subarray position out of bounds.");n.splice(i-1,1)}return ge.o(new _e(n))}))}))}function Mr(e){return ee(e,1)||ee(e,20)||ee(e,19)}function kr(e,t,n,r,o){return 0===r.length?0!==o.length:0!==o.length&&Zn(e,t,n,r[0],o[0]).next(0).value?kr(e,t,n,r.slice(1),o.slice(1)):r[0].value!=r[0].value||(Mr(r[0].type)&&0!==o.length&&Mr(o[0].type)||0!==o.length)&&r[0].value<o[0].value}function Fr(e,t,n,r){return r.sort((function(r,o){return Kn(e,t,n,ge.create(r),ge.create(o)).next(0).value?0:kr(e,t,n,r,o)?-1:1})),ge.o(new _e(r.map((function(e){return function(){return ge.create(e)}}))))}function Gr(e,t){return ee(t.type,62)?t.R.reduce((function(e,t){return t().L((function(t){return t.reduce(Gr,e)}))}),e):It([e,ge.o(t)])}Br.prototype.add=function(e){var t=this,n=Er.reduce((function(n,r,o){return n[r]=t.h[o]+e.h[o],n}),Object.create(null));return new Br(n)},y(Rr,br),Rr.prototype.u=function(e,t){var n=this;if(!this.j||!this.j.I)return br.prototype.u.call(this,e,t);var r=[],o=Or(this.j,(function(e,t,o,i){for(var a=[],s=3;s<arguments.length;++s)a[s-3]=arguments[s];return xr(n.j.value.apply(n.j,[e,t,o].concat(p(a))),(function(e){r=vr(r,e)}))}),e,t,this.T,this.xa.map((function(n){return function(){return n.I?xr(n.u(e,t),(function(e){r=vr(r,e)})):hr(n,e,t)}})),this.J),i=!1;return{next:function(){if(i)return K;var e=o.N();return i=!0,W({fa:r,H:e})}}},Rr.prototype.B=function(e,t,n){var r=this,o=(n=c(n)).next().value,i=l(n);if(this.j)return Or(this.j,(function(e,t,n,o){for(var i=[],a=3;a<arguments.length;++a)i[a-3]=arguments[a];return r.j.value.apply(r.j,[e,t,n].concat(p(i)))}),e,t,this.T,i,this.J);var a=o(e);return a.$({default:function(){throw Ir()},o:function(){return a.L((function(n){if((n=Sr(n=c(n).next().value,r.ka)).I)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return Or(n,n.value,e,t,r.T,i,r.J)}))}})},Rr.prototype.P=function(e){if(this.J=Bo(e),br.prototype.P.call(this,e),this.pa.C){if(!(e=hr(this.pa,null,null)).ta())throw Ir();this.j=Sr(e.first(),this.ka),this.j.I&&(this.I=!0)}};var Pr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",l:[{type:62,g:3}],i:{type:5,g:3},m:function(e,t,n,r){return Le([r],(function(e){return e=c(e).next().value,ge.o(V(e.R.length,5))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"get",l:[{type:62,g:3},{type:5,g:3}],i:{type:59,g:2},m:He},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"put",l:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},m:function(e,t,n,r,o,i){return Le([o,r],(function(e){var t=c(e);if(e=t.next().value,t=t.next().value,0>=(e=e.value)||e>t.R.length)throw Error("FOAY0001: array position out of bounds.");return(t=t.R.concat()).splice(e-1,1,ye(i)),ge.o(new _e(t))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"append",l:[{type:62,g:3},{type:59,g:2}],i:{type:62,g:3},m:function(e,t,n,r,o){return Le([r],(function(e){return e=c(e).next().value.R.concat([ye(o)]),ge.o(new _e(e))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",l:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],i:{type:62,g:3},m:Dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",l:[{type:62,g:3},{type:5,g:3}],i:{type:62,g:3},m:function(e,t,n,r,o){var i=ge.o(V(r.first().value.length-o.first().value+1,5));return Dr(0,0,0,r,o,i)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"remove",l:[{type:62,g:3},{type:5,g:2}],i:{type:62,g:3},m:Ur},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",l:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},m:function(e,t,n,r,o,i){return Le([r,o],(function(e){var t=c(e);if(e=t.next().value,(t=t.next().value.value)>e.R.length+1||0>=t)throw Error("FOAY0001: subarray position out of bounds.");return(e=e.R.concat()).splice(t-1,0,ye(i)),ge.o(new _e(e))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",l:[{type:62,g:3}],i:{type:59,g:2},m:function(e,t,n,r){return He(0,0,0,r,ge.o(V(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",l:[{type:62,g:3}],i:{type:59,g:2},m:function(e,t,n,r){return Ur(0,0,0,r,ge.o(V(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",l:[{type:62,g:3}],i:{type:62,g:3},m:function(e,t,n,r){return Le([r],(function(e){return e=c(e).next().value,ge.o(new _e(e.R.concat().reverse()))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",l:[{type:62,g:2}],i:{type:62,g:3},m:function(e,t,n,r){return r.L((function(e){return e=e.reduce((function(e,t){return e.concat(t.R)}),[]),ge.o(new _e(e))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each",l:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},m:function(e,t,n,r,o){return Le([r,o],(function(r){var o=(r=c(r)).next().value,i=r.next().value;if(1!==i.A)throw St("The callback passed into array:for-each has a wrong arity.");return r=o.R.map((function(r){return ye(i.value.call(void 0,e,t,n,Cr(i.s,[r()],t,"array:for-each")[0]))})),ge.o(new _e(r))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"filter",l:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},m:function(e,t,n,r,o){return Le([r,o],(function(r){var o=(r=c(r)).next().value,i=r.next().value;if(1!==i.A)throw St("The callback passed into array:filter has a wrong arity.");var a=o.R.map((function(r){return r=Cr(i.s,[r()],t,"array:filter")[0],(0,i.value)(e,t,n,r)})),s=[],u=!1;return ge.create({next:function(){if(u)return K;for(var e=0,t=o.R.length;e<t;++e){var n=a[e].getEffectiveBooleanValue();s[e]=n}return e=o.R.filter((function(e,t){return s[t]})),u=!0,W(new _e(e))}})}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-left",l:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},m:function(e,t,n,r,o,i){return Le([r,i],(function(r){var i=(r=c(r)).next().value,a=r.next().value;if(2!==a.A)throw St("The callback passed into array:fold-left has a wrong arity.");return i.R.reduce((function(r,o){return o=Cr(a.s,[o()],t,"array:fold-left")[0],a.value.call(void 0,e,t,n,r,o)}),o)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-right",l:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},m:function(e,t,n,r,o,i){return Le([r,i],(function(r){var i=(r=c(r)).next().value,a=r.next().value;if(2!==a.A)throw St("The callback passed into array:fold-right has a wrong arity.");return i.R.reduceRight((function(r,o){return o=Cr(a.s,[o()],t,"array:fold-right")[0],a.value.call(void 0,e,t,n,r,o)}),o)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each-pair",l:[{type:62,g:3},{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},m:function(e,t,n,r,o,i){return Le([r,o,i],(function(r){var o=c(r);r=o.next().value;var i=o.next().value;if(2!==(o=o.next().value).A)throw St("The callback passed into array:for-each-pair has a wrong arity.");for(var a=[],s=0,u=Math.min(r.R.length,i.R.length);s<u;++s){var l=c(Cr(o.s,[r.R[s](),i.R[s]()],t,"array:for-each-pair")),p=l.next().value;l=l.next().value,a[s]=ye(o.value.call(void 0,e,t,n,p,l))}return ge.o(new _e(a))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"sort",l:[{type:62,g:3}],i:{type:62,g:3},m:function(e,t,n,r){return Le([r],(function(r){return r=c(r).next().value.R.map((function(e){return e().N()})),Fr(e,t,n,r)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",l:[{type:59,g:2}],i:{type:59,g:2},m:function(e,t,n,r){return r.L((function(e){return e.reduce(Gr,ge.empty())}))}}];function Hr(e,t,n,r,o){return o.G()?o:ge.o(Kt(o.first(),e))}var _r=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",l:[{type:46,g:0}],i:{type:19,g:0},m:Hr.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",l:[{type:46,g:0}],i:{type:39,g:0},m:Hr.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",l:[{type:46,g:0}],i:{type:1,g:0},m:Hr.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",l:[{type:46,g:0}],i:{type:0,g:0},m:Hr.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",l:[{type:46,g:0}],i:{type:4,g:0},m:Hr.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",l:[{type:46,g:0}],i:{type:6,g:0},m:Hr.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",l:[{type:46,g:0}],i:{type:3,g:0},m:Hr.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",l:[{type:46,g:0}],i:{type:18,g:0},m:Hr.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",l:[{type:46,g:0}],i:{type:9,g:0},m:Hr.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",l:[{type:46,g:0}],i:{type:10,g:0},m:Hr.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",l:[{type:46,g:0}],i:{type:8,g:0},m:Hr.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",l:[{type:46,g:0}],i:{type:7,g:0},m:Hr.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",l:[{type:46,g:0}],i:{type:11,g:0},m:Hr.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",l:[{type:46,g:0}],i:{type:12,g:0},m:Hr.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",l:[{type:46,g:0}],i:{type:13,g:0},m:Hr.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gDay",l:[{type:46,g:0}],i:{type:15,g:0},m:Hr.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",l:[{type:46,g:0}],i:{type:14,g:0},m:Hr.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",l:[{type:46,g:0}],i:{type:22,g:0},m:Hr.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",l:[{type:46,g:0}],i:{type:21,g:0},m:Hr.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"QName",l:[{type:46,g:0}],i:{type:23,g:0},m:function(e,t,n,r){if(r.G())return r;if(ee((e=r.first()).type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");if(!Ft(e=kt(e=Kt(e,1).value,23),23))throw Error("FORG0001: The provided QName is invalid.");if(!e.includes(":"))return n=n.ba(""),ge.o(V(new ve("",n,e),23));if(t=(r=c(e.split(":"))).next().value,r=r.next().value,!(n=n.ba(t)))throw Error("FONS0004: The value "+e+" can not be cast to a QName. Did you mean to use fn:QName?");return ge.o(V(new ve(t,n,r),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",l:[{type:46,g:0}],i:{type:20,g:0},m:Hr.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",l:[{type:46,g:0}],i:{type:48,g:0},m:Hr.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",l:[{type:46,g:0}],i:{type:52,g:0},m:Hr.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",l:[{type:46,g:0}],i:{type:51,g:0},m:Hr.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",l:[{type:46,g:0}],i:{type:50,g:0},m:Hr.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",l:[{type:46,g:0}],i:{type:49,g:2},m:Hr.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",l:[{type:46,g:0}],i:{type:25,g:0},m:Hr.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",l:[{type:46,g:0}],i:{type:24,g:0},m:Hr.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",l:[{type:46,g:0}],i:{type:42,g:0},m:Hr.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",l:[{type:46,g:0}],i:{type:41,g:0},m:Hr.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",l:[{type:46,g:0}],i:{type:43,g:2},m:Hr.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITY",l:[{type:46,g:0}],i:{type:26,g:0},m:Hr.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",l:[{type:46,g:0}],i:{type:40,g:2},m:Hr.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",l:[{type:46,g:0}],i:{type:5,g:0},m:Hr.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",l:[{type:46,g:0}],i:{type:27,g:0},m:Hr.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"negativeInteger",l:[{type:46,g:0}],i:{type:28,g:0},m:Hr.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",l:[{type:46,g:0}],i:{type:31,g:0},m:Hr.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",l:[{type:46,g:0}],i:{type:32,g:0},m:Hr.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",l:[{type:46,g:0}],i:{type:33,g:0},m:Hr.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"byte",l:[{type:46,g:0}],i:{type:34,g:0},m:Hr.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",l:[{type:46,g:0}],i:{type:30,g:0},m:Hr.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",l:[{type:46,g:0}],i:{type:36,g:0},m:Hr.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",l:[{type:46,g:0}],i:{type:35,g:0},m:Hr.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedShort",l:[{type:46,g:0}],i:{type:38,g:0},m:Hr.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",l:[{type:46,g:0}],i:{type:37,g:0},m:Hr.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",l:[{type:46,g:0}],i:{type:29,g:0},m:Hr.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",l:[{type:46,g:0}],i:{type:16,g:0},m:Hr.bind(null,16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",l:[{type:46,g:0}],i:{type:17,g:0},m:Hr.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",l:[{type:46,g:0}],i:{type:10,g:0},m:Hr.bind(null,10)}];function jr(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getYear(),5))}function Xr(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getMonth(),5))}function Lr(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getDay(),5))}function $r(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getHours(),5))}function qr(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getMinutes(),5))}function Vr(e,t,n,r){return r.G()||(t=(e=ge).o,r=r.first().value,r=t.call(e,V(r.j+r.ra,4))),r}function Yr(e,t,n,r){return r.G()?r:(e=r.first().value.Z)?ge.o(V(e,17)):ge.empty()}var Qr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"dateTime",l:[{type:7,g:0},{type:8,g:0}],i:{type:9,g:0},m:function(e,t,n,r,o){if(r.G())return r;if(o.G())return o;if(e=r.first().value,o=o.first().value,t=e.Z,n=o.Z,t||n){if(!t||n)if(!t&&n)t=n;else if(!Qe(t,n))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.")}else t=null;return ge.o(V(new at(e.getYear(),e.getMonth(),e.getDay(),o.getHours(),o.getMinutes(),o.getSeconds(),o.ra,t),9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",l:[{type:9,g:0}],i:{type:5,g:0},m:jr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",l:[{type:9,g:0}],i:{type:5,g:0},m:Xr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",l:[{type:9,g:0}],i:{type:5,g:0},m:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",l:[{type:9,g:0}],i:{type:5,g:0},m:$r},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",l:[{type:9,g:0}],i:{type:5,g:0},m:qr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",l:[{type:9,g:0}],i:{type:4,g:0},m:Vr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",l:[{type:9,g:0}],i:{type:17,g:0},m:Yr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-date",l:[{type:7,g:0}],i:{type:5,g:0},m:jr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",l:[{type:7,g:0}],i:{type:5,g:0},m:Xr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",l:[{type:7,g:0}],i:{type:5,g:0},m:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",l:[{type:7,g:0}],i:{type:17,g:0},m:Yr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-time",l:[{type:8,g:0}],i:{type:5,g:0},m:$r},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",l:[{type:8,g:0}],i:{type:5,g:0},m:qr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",l:[{type:8,g:0}],i:{type:4,g:0},m:Vr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",l:[{type:8,g:0}],i:{type:17,g:0},m:Yr}];function Jr(e,t){var n=t.h,r=t.s,o=t.j;switch(e.node.nodeType){case 1:var i=r.createElementNS(e.node.namespaceURI,e.node.nodeName);for(n.getAllAttributes(e.node).forEach((function(e){return o.setAttributeNS(i,e.namespaceURI,e.nodeName,e.value)})),e=(r=c(De(n,e))).next();!e.done;e=r.next())e=Jr(e.value,t),o.insertBefore(i,e.node,null);return{node:i,F:null};case 2:return(t=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Ue(n,e),{node:t,F:null};case 4:return{node:r.createCDATASection(Ue(n,e)),F:null};case 8:return{node:r.createComment(Ue(n,e)),F:null};case 9:for(r=r.createDocument(),e=(n=c(De(n,e))).next();!e.done;e=n.next())e=Jr(e.value,t),o.insertBefore(r,e.node,null);return{node:r,F:null};case 7:return{node:r.createProcessingInstruction(e.node.target,Ue(n,e)),F:null};case 3:return{node:r.createTextNode(Ue(n,e)),F:null}}}function zr(e,t){var n=t.j,r=t.s,o=t.h;if(!Ie(e.node))return Jr(e,t).node;switch(e.node.nodeType){case 2:return(r=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Ue(o,e),r;case 8:return r.createComment(Ue(o,e));case 1:var i=e.node.prefix,a=e.node.localName,s=r.createElementNS(e.node.namespaceURI,i?i+":"+a:a);return De(o,e).forEach((function(e){e=zr(e,t),n.insertBefore(s,e,null)})),Oe(o,e).forEach((function(e){n.setAttributeNS(s,e.node.namespaceURI,e.node.nodeName,Ue(o,e))})),s.normalize(),s;case 7:return r.createProcessingInstruction(e.node.target,Ue(o,e));case 3:return r.createTextNode(Ue(o,e))}}function Kr(e,t,n){var r=e.node;if(!(Ie(r)||n||e.F))return r;r=t.ha;var o=[];return n?zr(e,t):(e=function(e,t,n){var r=e;for(e=Ge(n,r);null!==e;){if(2===r.node.nodeType)t.push(r.node.nodeName);else{var o=De(n,e);t.push(o.findIndex((function(e){return en(e,r)})))}e=Ge(n,r=e)}return r}(e,o,t.h),(n=r.get(e.node))||(n={node:zr(e,t),F:null},r.set(e.node,n)),function(e,t,n){for(var r={};0<t.length;)r.Za=t.pop(),e="string"==typeof r.Za?Oe(n,e).find(function(e){return function(t){return t.node.nodeName===e.Za}}(r)):De(n,e)[r.Za],r={Za:r.Za};return e.node}(n,o,t.h))}function Wr(e,t,n,r,o){return r.L((function(e){for(var n="",r=0;r<e.length;r++){var i=e[r],a=t.A&&ee(i.type,53)?t.A.serializeToString(Kr(i.value,t,!1)):Ut(ge.o(i),t).map((function(e){return Kt(e,1)})).first().value;n+="{type: "+ie[i.type]+", value: "+a+"}\n"}return void 0!==o&&(n+=o.first().value),t.O.trace(n),ge.create(e)}))}var Zr=[{l:[{type:59,g:2}],m:Wr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:1,g:3}],m:Wr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];function eo(e,t,n,r,o){throw e=void 0===r||r.G()?new ve("err","http://www.w3.org/2005/xqt-errors","FOER0000"):r.first().value,t="",void 0===o||o.G()||(t=": "+o.first().value),Error(""+e.localName+t)}var to=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",l:[],i:{type:63,g:3},m:eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",l:[{type:23,g:0}],i:{type:63,g:3},m:eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",l:[{type:23,g:0},{type:1,g:3}],i:{type:63,g:3},m:eo},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",l:[{type:23,g:0},{type:1,g:3},{type:59,g:2}],i:{type:63,g:3},m:function(){throw Error("Not implemented: Using an error object in error is not supported")}}];function no(e){return"string"==typeof e?e:(e=(new Ee).getChildNodes(e).find((function(e){return 8===e.nodeType})))?e.data:"some expression"}function ro(e,t){e=Error.call(this,e),this.message=e.message,"stack"in e&&(this.stack=e.stack),this.position={end:{la:t.end.la,line:t.end.line,offset:t.end.offset},start:{la:t.start.la,line:t.start.line,offset:t.start.offset}}}function oo(e,t){if(t instanceof Error)throw t;"string"!=typeof e&&(e=no(e));var n=Di(t);e=e.replace("\r","").split("\n");var r=Math.floor(Math.log10(Math.min(n.end.line+2,e.length)))+1;throw e=e.reduce((function(e,t,o){var i=o+1;if(2<n.start.line-i||2<i-n.end.line)return e;if(o=Array(r).fill(" ",0,Math.floor(Math.log10(i))+1-r).join("")+i+": ",e.push(o+t),i>=n.start.line&&i<=n.end.line){var a=i<n.end.line?t.length+o.length:n.end.la-1+o.length;i=i>n.start.line?o.length:n.start.la-1+o.length,e.push(Array(o.length+t.length).fill(" ",0,i).fill("^",i,a).join(""))}return e}),[]),t=Ui(t).join("\n"),new ro(e.join("\n")+"\n\n"+t,n)}y(ro,Error);var io=Object.create(null);function ao(e,t){for(var n=[],r=0;r<e.length+1;++r)n[r]=[];return function r(o,i){if(0===o)return i;if(0===i)return o;if(void 0!==n[o][i])return n[o][i];var a=0;return e[o-1]!==t[i-1]&&(a=1),a=Math.min(r(o-1,i)+1,r(o,i-1)+1,r(o-1,i-1)+a),n[o][i]=a}(e.length,t.length)}function so(e){var t=io[e]?io[e]:Object.keys(io).map((function(t){return{name:t,yb:ao(e,t.slice(t.lastIndexOf(":")+1))}})).sort((function(e,t){return e.yb-t.yb})).slice(0,5).filter((function(t){return t.yb<e.length/2})).reduce((function(e,t){return e.concat(io[t.name])}),[]).slice(0,5);return t.length?t.map((function(e){return'"Q{'+e.namespaceURI+"}"+e.localName+" ("+e.l.map((function(e){return 4===e?"...":se(e)})).join(", ")+')"'})).reduce((function(e,t,n,r){return 0===n?e+t:e+(n!==r.length-1?", ":" or ")+t}),"Did you mean ")+"?":"No similar functions found."}function uo(e,t,n,r,o){io[e+":"+t]||(io[e+":"+t]=[]),io[e+":"+t].push({l:n,arity:n.length,m:o,I:!1,localName:t,namespaceURI:e,i:r})}var co={},lo=(co.xml="http://www.w3.org/XML/1998/namespace",co.xs="http://www.w3.org/2001/XMLSchema",co.fn="http://www.w3.org/2005/xpath-functions",co.map="http://www.w3.org/2005/xpath-functions/map",co.array="http://www.w3.org/2005/xpath-functions/array",co.math="http://www.w3.org/2005/xpath-functions/math",co.fontoxpath="http://fontoxml.com/fontoxpath",co.local="http://www.w3.org/2005/xquery-local-functions",co);function po(e,t,n,r){this.Ea=[Object.create(null)],this.Fa=Object.create(null),this.O=e,this.ha=Object.keys(t).reduce((function(e,n){return void 0===t[n]||(e[n]="Q{}"+n+"[0]"),e}),Object.create(null)),this.s=Object.create(null),this.h=Object.create(null),this.A=n,this.u=r,this.j=[]}function ho(e){return Error("XPTY0004: "+e)}function fo(e,t){return e=2===e.node.nodeType?e.node.nodeName+'="'+Ue(t,e)+'"':e.node.outerHTML,Error("XQTY0024: The node "+e+" follows a node that is not an attribute node or a namespace node.")}function mo(e){return Error('XQDY0044: The node name "'+e.ya()+'" is invalid for a computed attribute constructor.')}function go(){return Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs.")}function yo(){return Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace.")}function vo(){return Error("XQST0066: A Prolog may contain at most one default function namespace declaration.")}function wo(){return Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI.")}function Ao(e){return Error('XQDY0074: The value "'+e+'" of a name expressions cannot be converted to an expanded QName.')}function xo(e){return Error('XPST0081: The prefix "'+e+'" could not be resolved')}function bo(e,t){return"Q{"+(e||"")+"}"+t}function Eo(e,t){for(var n=e.length-1;0<=n;--n)if(t in e[n])return e[n][t]}function No(e){this.s=e,this.O=this.h=0,this.j=[Object.create(null)],this.u=Object.create(null),this.A=null,this.Fa=e&&e.Fa,this.Ea=e&&e.Ea}function Bo(e){for(var t=new No(e.s),n=0;n<e.h+1;++n)t.j=[Object.assign(Object.create(null),t.j[0],e.j[n])],t.Ea=[Object.assign(Object.create(null),t.Ea[0],e.Ea[n])],t.u=Object.assign(Object.create(null),e.u),t.Fa=e.Fa,t.A=e.A;return t}function To(e){e.O++,e.h++,e.j[e.h]=Object.create(null),e.Ea[e.h]=Object.create(null)}function Io(e,t,n,r,o){if(r=bo(t,n)+"~"+r,e.u[r])throw Error('XQST0049: The function or variable "Q{'+t+"}"+n+'" is declared more than once.');e.u[r]=o}function Co(e,t,n){e.j[e.h][t]=n}function So(e,t,n){return t=bo(t||"",n),e.Ea[e.h][t]=t+"["+e.O+"]"}function Oo(e,t,n,r){e.Fa[bo(t||"",n)+"["+e.O+"]"]=r}function Ro(e){e.j.length=e.h,e.Ea.length=e.h,e.h--}function Do(e,t){"*"===t||Array.isArray(t)||(t=[t]);for(var n=1;n<e.length;++n)if(Array.isArray(e[n])){var r=e[n];if("*"===t||t.includes(r[0]))return r}return null}function Uo(e){return 2>e.length?"":"object"==typeof e[1]?e[2]||"":e[1]||""}function Mo(e,t){return Array.isArray(e)?"object"!=typeof(e=e[1])||Array.isArray(e)?null:t in e?e[t]:null:null}function ko(e,t){return t.reduce(Do,e)}function Fo(e,t){for(var n=[],r=1;r<e.length;++r)if(Array.isArray(e[r])){var o=e[r];"*"!==t&&o[0]!==t||n.push(o)}return n}function Go(e){return{localName:Uo(e),namespaceURI:Mo(e,"URI"),prefix:Mo(e,"prefix")}}function Po(e){var t=Do(e,"typeDeclaration");if(!t||Do(t,"voidSequenceType"))return{type:59,g:2};e={type:function e(n){switch(n[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 ue([Mo(n,"prefix"),Uo(n)].join(":"));case"parenthesizedItemType":return e(Do(n,"*"));default:throw Error('Type declaration "'+Do(t,"*")[0]+'" is not supported.')}}(Do(t,"*")),g:3};var n=null,r=Do(t,"occurrenceIndicator");switch(r&&(n=Uo(r)),n){case"*":return e.g=2,e;case"?":return e.g=0,e;case"+":return e.g=1,e;case"":case null:return e}}function Ho(e,t,n){if("object"!=typeof e[1]||Array.isArray(e[1])){var r={};r[t]=n,e.splice(1,0,r)}else e[1][t]=n}function _o(e,t,n){return(e<<20)+(t<<12)+(n.charCodeAt(0)<<8)+n.charCodeAt(1)}po.prototype.Ba=function(e,t,n){return function(e,t,n){var r=io[e+":"+t];return r&&(r=r.find((function(e){return e.l.some((function(e){return 4===e}))?e.l.length-1<=n:e.l.length===n})))?{l:r.l,arity:n,m:r.m,I:r.I,localName:t,namespaceURI:e,i:r.i}:null}(e,t,n)},po.prototype.sb=function(e,t){return e?null:(e=this.ha[t],this.s[t]||(this.s[t]={name:t}),e)},po.prototype.Ta=function(e,t){var n=this.u(e,t);if(n)this.j.push({Dc:e,arity:t,Jb:n});else if(""===e.prefix){if(this.A)return{namespaceURI:this.A,localName:e.localName}}else if(t=this.ba(e.prefix,!0))return{namespaceURI:t,localName:e.localName};return n},po.prototype.ba=function(e,t){return void 0===t||t?lo[e]?lo[e]:(t=this.O(e),this.h[e]||(this.h[e]={namespaceURI:t,prefix:e}),void 0!==t||e?t:null):null},No.prototype.Ba=function(e,t,n,r){r=void 0!==r&&r;var o=this.u[bo(e,t)+"~"+n];return!o||r&&o.Db?null===this.s?null:this.s.Ba(e,t,n,r):o},No.prototype.sb=function(e,t){var n=Eo(this.Ea,bo(e,t));return n||(null===this.s?null:this.s.sb(e,t))},No.prototype.Ta=function(e,t){var n=e.prefix,r=e.localName;return""===n&&this.A?{localName:r,namespaceURI:this.A}:n&&(n=this.ba(n,!1))?{localName:r,namespaceURI:n}:null===this.s?null:this.s.Ta(e,t)},No.prototype.ba=function(e,t){var n=Eo(this.j,e||"");return void 0===n?null===this.s?void 0:this.s.ba(e||"",void 0===t||t):n};var jo={},Xo=(jo[_o(2,2,"idivOp")]=5,jo[_o(16,16,"addOp")]=16,jo[_o(16,16,"subtractOp")]=16,jo[_o(16,16,"divOp")]=4,jo[_o(16,2,"multiplyOp")]=16,jo[_o(16,2,"divOp")]=16,jo[_o(2,16,"multiplyOp")]=16,jo[_o(17,17,"addOp")]=17,jo[_o(17,17,"subtractOp")]=17,jo[_o(17,17,"divOp")]=4,jo[_o(17,2,"multiplyOp")]=17,jo[_o(17,2,"divOp")]=17,jo[_o(2,17,"multiplyOp")]=17,jo[_o(9,9,"subtractOp")]=17,jo[_o(7,7,"subtractOp")]=17,jo[_o(8,8,"subtractOp")]=17,jo[_o(9,16,"addOp")]=9,jo[_o(9,16,"subtractOp")]=9,jo[_o(9,17,"addOp")]=9,jo[_o(9,17,"subtractOp")]=9,jo[_o(7,16,"addOp")]=7,jo[_o(7,16,"subtractOp")]=7,jo[_o(7,17,"addOp")]=7,jo[_o(7,17,"subtractOp")]=7,jo[_o(8,17,"addOp")]=8,jo[_o(8,17,"subtractOp")]=8,jo[_o(9,16,"addOp")]=9,jo[_o(9,16,"subtractOp")]=9,jo[_o(9,17,"addOp")]=9,jo[_o(9,17,"subtractOp")]=9,jo[_o(7,17,"addOp")]=7,jo[_o(7,17,"subtractOp")]=7,jo[_o(7,16,"addOp")]=7,jo[_o(7,16,"subtractOp")]=7,jo[_o(8,17,"addOp")]=8,jo[_o(8,17,"subtractOp")]=8,jo),Lo={},$o=(Lo[_o(2,2,"addOp")]=function(e,t){return e+t},Lo[_o(2,2,"subtractOp")]=function(e,t){return e-t},Lo[_o(2,2,"multiplyOp")]=function(e,t){return e*t},Lo[_o(2,2,"divOp")]=function(e,t){return e/t},Lo[_o(2,2,"modOp")]=function(e,t){return e%t},Lo[_o(2,2,"idivOp")]=function(e,t){return Math.trunc(e/t)},Lo[_o(16,16,"addOp")]=function(e,t){return new Ht(e.ga+t.ga)},Lo[_o(16,16,"subtractOp")]=function(e,t){return new Ht(e.ga-t.ga)},Lo[_o(16,16,"divOp")]=function(e,t){return e.ga/t.ga},Lo[_o(16,2,"multiplyOp")]=Xt,Lo[_o(16,2,"divOp")]=function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");if((e=Math.round(e.ga/t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new Ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)},Lo[_o(2,16,"multiplyOp")]=function(e,t){return Xt(t,e)},Lo[_o(17,17,"addOp")]=function(e,t){return new Je(e.ea+t.ea)},Lo[_o(17,17,"subtractOp")]=function(e,t){return new Je(e.ea-t.ea)},Lo[_o(17,17,"divOp")]=function(e,t){if(0===t.ea)throw Error("FOAR0001: Division by 0");return e.ea/t.ea},Lo[_o(17,2,"multiplyOp")]=et,Lo[_o(17,2,"divOp")]=function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");if((e=e.ea/t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");return new Je(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)},Lo[_o(2,17,"multiplyOp")]=function(e,t){return et(t,e)},Lo[_o(9,9,"subtractOp")]=ht,Lo[_o(7,7,"subtractOp")]=ht,Lo[_o(8,8,"subtractOp")]=ht,Lo[_o(9,16,"addOp")]=ft,Lo[_o(9,16,"subtractOp")]=dt,Lo[_o(9,17,"addOp")]=ft,Lo[_o(9,17,"subtractOp")]=dt,Lo[_o(7,16,"addOp")]=ft,Lo[_o(7,16,"subtractOp")]=dt,Lo[_o(7,17,"addOp")]=ft,Lo[_o(7,17,"subtractOp")]=dt,Lo[_o(8,17,"addOp")]=ft,Lo[_o(8,17,"subtractOp")]=dt,Lo[_o(9,16,"addOp")]=ft,Lo[_o(9,16,"subtractOp")]=dt,Lo[_o(9,17,"addOp")]=ft,Lo[_o(9,17,"subtractOp")]=dt,Lo[_o(7,17,"addOp")]=ft,Lo[_o(7,17,"subtractOp")]=dt,Lo[_o(7,16,"addOp")]=ft,Lo[_o(7,16,"subtractOp")]=dt,Lo[_o(8,17,"addOp")]=ft,Lo[_o(8,17,"subtractOp")]=dt,Lo);function qo(e,t){return ee(e,5)&&ee(t,5)?5:ee(e,4)&&ee(t,4)?4:ee(e,6)&&ee(t,6)?6:3}var Vo=[2,16,17,9,7,8];function Yo(e,t,n){function r(e,t){return{V:o?o(e):e,W:i?i(t):t}}var o=null,i=null;ee(t,19)&&(o=function(e){return Kt(e,3)},t=3),ee(n,19)&&(i=function(e){return Kt(e,3)},n=3);var a=Vo.filter((function(e){return ee(t,e)})),s=Vo.filter((function(e){return ee(n,e)}));if(a.includes(2)&&s.includes(2)){var u=$o[_o(2,2,e)],l=Xo[_o(2,2,e)];return l||(l=qo(t,n)),"divOp"===e&&5===l&&(l=4),"idivOp"===e?Qo(r,u)[0]:function(e,t){return e=r(e,t),V(u(e.V.value,e.W.value),l)}}for(var p=(a=c(a)).next();!p.done;p=a.next()){p=p.value;for(var h={},f=c(s),d=f.next();!d.done;h={kb:h.kb,nb:h.nb},d=f.next())if(d=d.value,h.kb=$o[_o(p,d,e)],h.nb=Xo[_o(p,d,e)],h.kb&&void 0!==h.nb)return function(e){return function(t,n){return t=r(t,n),V(e.kb(t.V.value,t.W.value),e.nb)}}(h)}}function Qo(e,t){return[function(n,r){if(n=(r=e(n,r)).V,0===(r=r.W).value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(n.value)||Number.isNaN(r.value)||!Number.isFinite(n.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(n.value)&&!Number.isFinite(r.value)?V(0,5):V(t(n.value,r.value),5)},5]}var Jo=Object.create(null);function zo(e,t,n,r,o){pr.call(this,t.s.add(n.s),[t,n],{C:!1},!1,r),this.B=t,this.J=n,this.j=e,this.u=o}function Ko(e,t,n){var r=Go(ko(e,["forClauseItem","typedVariableBinding","varName"]));(e=ko(e,["forClauseItem","forExpr","sequenceExpr"]))&&(e=Fo(e,"*").map((function(e){return n(e,t)})),e.includes(void 0)||e.includes(null)||1===(e=Wo(e)).length&&li(t,r.localName,e[0]))}function Wo(e){return e.filter((function(e,t,n){return n.findIndex((function(t){return t.type===e.type&&t.g===e.g}))===t}))}function Zo(e,t,n){var r=Fo(e,"*"),o=Do(e,"atomicType");if(!o)return{type:59,g:2};if(ue(Mo(o,"prefix")+":"+o[2])===t.type)if(1===r.length){if(3===t.g)return n}else if(e=Do(e,"occurrenceIndicator")[1],t.g===function(e){switch(e){case"*":return 2;case"?":return 0;case"+":return 1;default:return 3}}(e))return n}function ei(e,t){ti(e,t)}function ti(e,t){var n=ui.get(e[0]);if(n)return n(e,t);for(n=1;n<e.length;n++)e[n]&&ti(e[n],t)}function ni(e,t){var n=ti(Do(e,"firstOperand")[1],t),r=ti(Do(e,"secondOperand")[1],t),o=e[0];if(n&&r){if(!(t=function(e,t,n){var r=[2,53,59,46,47];if(r.includes(t)||r.includes(n))return 2;var o=null,i=null;ee(t,19)&&(o=function(e){return Kt(e,3)},t=3),ee(n,19)&&(i=function(e){return Kt(e,3)},n=3);var a=Vo.filter((function(e){return ee(t,e)}));if(r=Vo.filter((function(e){return ee(n,e)})),a.includes(2)&&r.includes(2))return void 0===(r=Xo[_o(2,2,e)])&&(r=qo(t,n)),"divOp"===e&&5===r&&(r=4),"idivOp"===e?Qo((function(e,t){return{V:o?o(e):e,W:i?i(t):t}}),(function(e,t){return Math.trunc(e/t)}))[1]:r;for(var s=(a=c(a)).next();!s.done;s=a.next()){s=s.value;for(var u=c(r),l=u.next();!l.done;l=u.next())if(void 0!==(l=Xo[_o(s,l.value,e)]))return l}}(o,n.type,r.type)))throw Error("XPTY0004: "+o+" not available for types "+se(n)+" and "+se(r));n={type:t,g:n.g},2!==t&&59!==t&&Ho(e,"type",n),e=n}else e={type:2,g:3};return e}function ri(e,t){ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t);e:{switch(e[0]){case"orOp":case"andOp":Ho(e,"type",t={type:0,g:3}),e=t;break e}e=void 0}return e}function oi(e,t){ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t);e:{switch(e[0]){case"unionOp":case"intersectOp":case"exceptOp":Ho(e,"type",t={type:53,g:2}),e=t;break e}e=void 0}return e}function ii(e,t){return ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t),Ho(e,"type",t={type:0,g:3}),t}function ai(e,t){return ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t),Ho(e,"type",t={type:0,g:3}),t}function si(e,t){return ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t),Ho(e,"type",t={type:0,g:3}),t}y(zo,pr),zo.prototype.h=function(e,t){var n=this;return Ut(hr(this.B,e,t),t).L((function(r){return 0===r.length?ge.empty():Ut(hr(n.J,e,t),t).L((function(e){if(0===e.length)return ge.empty();if(1<r.length||1<e.length)throw Error('XPTY0004: the operands of the "'+n.j+'" operator should be empty or singleton.');var t=r[0];if(e=e[0],n.u&&n.type)return ge.o(n.u(t,e));var o=t.type,i=e.type,a=n.j,s=o+"~"+i+"~"+a,u=Jo[s];if(u||(u=Jo[s]=Yo(a,o,i)),!(o=u))throw Error("XPTY0004: "+n.j+" not available for types "+ie[t.type]+" and "+ie[e.type]);return ge.o(o(t,e))}))}))};var ui=new Map([["unaryMinusOp",function(e,t){return(t=ti(Do(e,"operand")[1],t))?ee(t.type,2)?(Ho(e,"type",t={type:t.type,g:t.g}),e=t):(Ho(e,"type",t={type:3,g:3}),e=t):(Ho(e,"type",t={type:2,g:2}),e=t),e}],["unaryPlusOp",function(e,t){return(t=ti(Do(e,"operand")[1],t))?ee(t.type,2)?(Ho(e,"type",t={type:t.type,g:t.g}),e=t):(Ho(e,"type",t={type:3,g:3}),e=t):(Ho(e,"type",t={type:2,g:2}),e=t),e}],["addOp",ni],["subtractOp",ni],["divOp",ni],["idivOp",ni],["modOp",ni],["multiplyOp",ni],["andOp",ri],["orOp",ri],["sequenceExpr",function(e,t){var n=Fo(e,"*"),r=n.map((function(e){return ti(e,t)}));return function(e,t,n){return t=0===t?{type:53,g:2}:1===t?n[0]:n.includes(void 0)||n.includes(null)||1<(t=Wo(n)).length?{type:59,g:2}:{type:t[0].type,g:2},t&&59!==t.type&&Ho(e,"type",t),t}(e,n.length,r)}],["unionOp",oi],["intersectOp",oi],["exceptOp",oi],["stringConcatenateOp",function(e,t){return ti(Do(e,"firstOperand")[1],t),ti(Do(e,"secondOperand")[1],t),Ho(e,"type",t={type:1,g:3}),t}],["rangeSequenceExpr",function(e,t){return ti(Do(e,"startExpr")[1],t),ti(Do(e,"endExpr")[1],t),Ho(e,"type",t={type:5,g:1}),t}],["equalOp",ii],["notEqualOp",ii],["lessThanOrEqualOp",ii],["lessThanOp",ii],["greaterThanOrEqualOp",ii],["greaterThanOp",ii],["eqOp",ai],["neOp",ai],["ltOp",ai],["leOp",ai],["gtOp",ai],["geOp",ai],["isOp",si],["nodeBeforeOp",si],["nodeAfterOp",si],["pathExpr",function(e,t){var n=Do(e,"rootExpr");return n&&n[1]&&ti(n[1],t),Fo(e,"stepExpr").map((function(e){return ti(e,t)})),function(e,t){var n=Fo(e,"stepExpr");if(!n)return{type:59,g:2};for(var r=(n=c(n)).next();!r.done;r=n.next()){var o=r.value;r=t;var i=null;if(o){for(var a=Fo(o,"*"),s="",u=(a=c(a)).next();!u.done;u=a.next())switch(u=u.value,u[0]){case"filterExpr":i=Mo(ko(u,["*"]),"type");break;case"xpathAxis":e:{switch(s=u[1]){case"attribute":i={type:47,g:2};break e;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 e}i=void 0}break;case"nameTest":var l=Go(u);if(null!==l.namespaceURI)break;if("attribute"===s&&!l.prefix)break;void 0!==(l=r.ba(l.prefix||""))&&Ho(u,"URI",l);break;case"lookup":i={type:59,g:2}}i&&59!==i.type&&Ho(o,"type",i)}o=Mo(o,"type")}return o&&59!==o.type&&Ho(e,"type",o),o}(e,t)}],["contextItemExpr",function(){return{type:59,g:2}}],["ifThenElseExpr",function(e,t){ti(Do(Do(e,"ifClause"),"*"),t);var n=ti(Do(Do(e,"thenClause"),"*"),t);return t=ti(Do(Do(e,"elseClause"),"*"),t),n&&t&&n.type===t.type&&n.g===t.g?(59!==n.type&&Ho(e,"type",n),e=n):e={type:59,g:2},e}],["instanceOfExpr",function(e,t){return ti(Do(e,"argExpr"),t),ti(Do(e,"sequenceType"),t),Ho(e,"type",t={type:0,g:3}),t}],["integerConstantExpr",function(e){var t={type:5,g:3};return Ho(e,"type",t),t}],["doubleConstantExpr",function(e){var t={type:3,g:3};return Ho(e,"type",t),t}],["decimalConstantExpr",function(e){var t={type:4,g:3};return Ho(e,"type",t),t}],["stringConstantExpr",function(e){var t={type:1,g:3};return Ho(e,"type",t),t}],["functionCallExpr",function(e,t){return Fo(Do(e,"arguments"),"*").map((function(e){return ti(e,t)})),function(e,t){if(!t||!t.ia)return{type:59,g:2};var n=Do(e,"functionName"),r=Go(n),o=r.localName,i=r.prefix,a=r.namespaceURI;if(r=Fo(Do(e,"arguments"),"*"),null===a){if(!(i=t.ia.Ta({localName:o,prefix:i},r.length)))return{type:59,g:2};o=i.localName,Ho(n,"URI",a=i.namespaceURI),n[2]=o}return(t=t.ia.Ba(a,o,r.length))&&63!==t.i.type?(59!==t.i.type&&Ho(e,"type",t.i),t.i):{type:59,g:2}}(e,t)}],["arrowExpr",function(e,t){return ti(Do(e,"argExpr")[1],t),function(e,t){if(!t||!t.ia)return{type:59,g:2};var n=Do(e,"EQName");if(!n)return{type:59,g:2};var r=Go(n);n=r.localName;var o=r.prefix;return r=Fo(Do(e,"arguments"),"*"),(n=t.ia.Ta({localName:n,prefix:o},r.length))&&(t=t.ia.Ba(n.namespaceURI,n.localName,r.length+1))?(59!==t.i.type&&Ho(e,"type",t.i),t.i):{type:59,g:2}}(e,t)}],["dynamicFunctionInvocationExpr",function(e,t){return ti(ko(e,["functionItem","*"]),t),(e=Do(e,"arguments"))&&ti(e,t),{type:59,g:2}}],["namedFunctionRef",function(e,t){return function(e,t){if(!t||!t.ia)return{type:59,g:2};var n=Do(e,"functionName"),r=Go(n),o=r.localName,i=r.namespaceURI,a=r.prefix;if(r=Number(ko(e,["integerConstantExpr","value"])[1]),!i){if(!(i=t.ia.Ta({localName:o,prefix:a},r)))return{type:59,g:2};o=i.localName,Ho(n,"URI",i=i.namespaceURI)}return(t=t.ia.Ba(i,o,r)||null)?(59!==t.i.type&&63!==t.i.type&&Ho(e,"type",t.i),t.i):{type:59,g:2}}(e,t)}],["inlineFunctionExpr",function(e,t){return ti(Do(e,"functionBody")[1],t),Ho(e,"type",t={type:60,g:3}),t}],["castExpr",function(e){var t=ko(e,["singleType","atomicType"]);return 59!==(t={type:ue(Mo(t,"prefix")+":"+t[2]),g:3}).type&&Ho(e,"type",t),t}],["castableExpr",function(e){var t={type:0,g:3};return Ho(e,"type",t),t}],["simpleMapExpr",function(e,t){for(var n,r=Fo(e,"pathExpr"),o=0;o<r.length;o++)n=ti(r[o],t);return null!=n?(59!==(t={type:n.type,g:2}).type&&Ho(e,"type",t),e=t):e={type:59,g:2},e}],["mapConstructor",function(e,t){return Fo(e,"mapConstructorEntry").map((function(e){return{key:ti(ko(e,["mapKeyExpr","*"]),t),value:ti(ko(e,["mapValueExpr","*"]),t)}})),function(e){var t={type:61,g:3};return Ho(e,"type",t),t}(e)}],["arrayConstructor",function(e,t){return Fo(Do(e,"*"),"arrayElem").map((function(e){return ti(e,t)})),function(e){var t={type:62,g:3};return Ho(e,"type",t),t}(e)}],["unaryLookup",function(e){return Do(e,"NCName"),{type:59,g:2}}],["typeswitchExpr",function(e,t){var n=ti(Do(e,"argExpr")[1],t),r=Fo(e,"typeswitchExprCaseClause").map((function(e){return ti(ko(e,["resultExpr"])[1],t)}));return function(e,t,n,r){if(!t||n.includes(void 0))return{type:59,g:2};for(var o=Fo(e,"typeswitchExprCaseClause"),i=0;i<n.length;i++){var a=Do(o[i],"*");switch(a[0]){case"sequenceType":if(a=Zo(a,t,n[i]))return 59!==a.type&&Ho(e,"type",a),a;continue;case"sequenceTypeUnion":for(r=Fo(a,"*"),o=0;2>o;o++)if(a=Zo(r[o],t,n[i]))return 59!==a.type&&Ho(e,"type",a),a;default:return{type:59,g:2}}}return 59!==r.type&&Ho(e,"type",r),r}(e,n,r,ti(ko(e,["typeswitchExprDefaultClause","resultExpr"])[1],t))}],["quantifiedExpr",function(e,t){return Fo(e,"*").map((function(e){return ti(e,t)})),function(e){var t={type:0,g:3};return Ho(e,"type",t),t}(e)}],["x:stackTrace",function(e,t){return ti((e=Fo(e,"*"))[0],t)}],["queryBody",function(e,t){return ti(e[1],t)}],["flworExpr",function(e,t){return function(e,t){for(var n=ti,r=!1,o=1;o<e.length;o++)switch(e[o][0]){case"letClause":pi(t);var i=e[o],a=t,s=n,u=ko(i,["letClauseItem","typedVariableBinding","varName"]);u=Go(u),s=s((i=ko(i,["letClauseItem","letExpr"]))[1],a),li(a,u.localName,s);break;case"forClause":r=!0,pi(t),Ko(e[o],t,n);break;case"whereClause":pi(t),n(a=e[o],t),Ho(a,"type",{type:0,g:3});break;case"orderByClause":pi(t);break;case"returnClause":return a=n,Ho(n=ko(o=e[o],["*"]),"type",t=a(n,t)),Ho(o,"type",t),(n=t)?(r&&(n={type:n.type,g:2}),59!==n.type&&Ho(e,"type",n),n):{type:59,g:2};default:return(n=n(e[o],t))?(r&&(n={type:n.type,g:2}),59!==n.type&&Ho(e,"type",n),n):{type:59,g:2}}if(!(0<t.h))throw Error("Variable scope out of bound");t.h--,t.s.pop(),t.A.pop()}(e,t)}],["varRef",function(e,t){var n,r=Go(Do(e,"name"));e:{for(n=t.h;0<=n;n--){var o=t.s[n][r.localName];if(o){n=o;break e}}n=void 0}return n&&59!==n.type&&Ho(e,"type",n),null===r.namespaceURI&&(void 0!==(t=t.ba(r.prefix))&&Ho(e,"URI",t)),n}]]);function ci(e){this.h=0,this.ia=e,this.s=[{}],this.A=[{}]}function li(e,t,n){if(e.s[e.h][t])throw Error("Another variable of in the scope "+e.h+" with the same name "+t+" already exists");e.s[e.h][t]=n}function pi(e){e.h++,e.s.push({}),e.A.push({})}function hi(e,t){var n={};pr.call(this,new Br((n.external=1,n)),e,{C:e.every((function(e){return e.C}))},!1,t),this.j=e}function fi(e,t){var n={};pr.call(this,new Br((n.external=1,n)),e,{C:e.every((function(e){return e.C}))},!1,t),this.j=e}function di(e){if(null===e)throw Error("XPDY0002: context is absent, it needs to be present to use axes.");if(!ee(e.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return e.value}function mi(e,t){t=t||{Qa:!1},pr.call(this,e.s,[e],{S:"reverse-sorted",Y:!1,subtree:!1,C:!1}),this.j=e,this.u=!!t.Qa}ci.prototype.ba=function(e){for(var t=this.h;0<=t;t--){var n=this.A[t][e];if(void 0!==n)return n}return this.ia?this.ia.ba(e):void 0},y(hi,pr),hi.prototype.h=function(e,t){return 0===this.j.length?ge.o(new _e([])):hr(this.j[0],e,t).L((function(e){return ge.o(new _e(e.map((function(e){return ye(ge.o(e))}))))}))},y(fi,pr),fi.prototype.h=function(e,t){return ge.o(new _e(this.j.map((function(n){return ye(hr(n,e,t))}))))},y(mi,pr),mi.prototype.h=function(e,t){var n=this;t=t.h,e=di(e.M);var r=this.j.A();return r=r&&(r.startsWith("name-")||"type-1"===r)?"type-1":null,ge.create(function(e,t,n){var r=t;return{next:function(){if(!r)return K;var t=r;return r=Ge(e,t,n),W(Xe(t))}}}(t,this.u?e:Ge(t,e,r),r)).filter((function(e){return n.j.j(e)}))};var gi=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function yi(e,t){if(null===e)return t;if(null===t||e===t)return e;var n=e.startsWith("name-")?"name":e,r=t.startsWith("name-")?"name":t,o=gi.get(n);return void 0!==o&&o.includes(r)?t:void 0!==(t=gi.get(r))&&t.includes(n)?e:"empty"}function vi(e,t){var n={};pr.call(this,new Br((n.attribute=1,n)),[e],{S:"unsorted",subtree:!0,Y:!0,C:!1}),this.j=e,this.u=yi(this.j.A(),t)}function wi(e,t){pr.call(this,e.s,[e],{S:"sorted",subtree:!0,Y:!0,C:!1}),this.u=e,this.j=yi(t,e.A())}function Ai(e,t,n){var r=t.node.nodeType;if(1!==r&&9!==r)return{next:function(){return K}};var o=Me(e,t,n);return{next:function(){if(!o)return K;var t=o;return o=Fe(e,o,n),W(t)}}}function xi(e,t){t=t||{Qa:!1},pr.call(this,e.s,[e],{C:!1,Y:!1,S:"sorted",subtree:!0}),this.j=e,this.u=!!t.Qa,this.B=(e=this.j.A())&&(e.startsWith("name-")||"type-1"===e)||"type-1-or-type-2"===e?"type-1":null}function bi(e,t,n){var r=e.node.nodeType;if(1!==r&&9!==r)return e;for(r=ke(t,e,n);null!==r;){if(1!==r.node.nodeType)return r;r=ke(t,e=r,n)}return e}function Ei(e,t,n,r){if(void 0!==n&&n){var o=t,i=!1;return{next:function(){if(i)return K;if(en(o,t))return en(o=bi(t,e,r),t)?(i=!0,K):W(Xe(o));var n=o.node.nodeType,a=9===n||2===n?null:Pe(e,o,r);return null!==a?W(Xe(o=bi(a,e,r))):en(o=9===n?null:Ge(e,o,r),t)?(i=!0,K):W(Xe(o))}}}var a=[Ai(e,t,r)];return{next:function(){if(!a.length)return K;for(var t=a[0].next(0);t.done;){if(a.shift(),!a.length)return K;t=a[0].next(0)}return a.unshift(Ai(e,t.value,r)),W(Xe(t.value))}}}function Ni(e){pr.call(this,e.s,[e],{S:"sorted",Y:!0,subtree:!1,C:!1}),this.j=e,this.u=(e=this.j.A())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}function Bi(e,t){pr.call(this,e.s,[e],{S:"sorted",Y:!0,subtree:!1,C:!1}),this.j=e,this.u=yi(this.j.A(),t)}function Ti(e,t){pr.call(this,e.s,[e],{S:"reverse-sorted",Y:!0,subtree:!0,C:!1}),this.j=e,this.u=yi(t,this.j.A())}function Ii(e){pr.call(this,e.s,[e],{C:!1,Y:!0,S:"reverse-sorted",subtree:!1}),this.j=e,this.u=(e=this.j.A())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}function Ci(e,t){pr.call(this,e.s,[e],{C:!1,Y:!0,S:"reverse-sorted",subtree:!1}),this.j=e,this.u=yi(this.j.A(),t)}function Si(e,t){pr.call(this,e.s,[e],{S:"sorted",subtree:!0,Y:!0,C:!1}),this.j=e,this.u=yi(this.j.A(),t)}function Oi(e,t,n,r){var o=e.s.add(t.s).add(n.s);br.call(this,o,[e,t,n],{C:e.C&&t.C&&n.C,Y:t.Y===n.Y&&t.Y,S:t.O===n.O?t.O:"unsorted",subtree:t.subtree===n.subtree&&t.subtree},r),this.j=e}function Ri(e,t,n){this.location=e,this.s=t,this.h=n}function Di(e){return e.h instanceof Error?e.location:Di(e.h)}function Ui(e){var t=e.h instanceof ro?["Inner error:",e.h.message]:e.h instanceof Error?[e.h.toString()]:Ui(e.h);return t.push(" at <"+e.s+">:"+e.location.start.line+":"+e.location.start.la+" - "+e.location.end.line+":"+e.location.end.la),t}function Mi(e,t,n){br.call(this,n.s,[n],{C:n.C,Y:n.Y,S:n.O,subtree:n.subtree}),this.j=t,this.J={end:{la:e.end.la,line:e.end.line,offset:e.end.offset},start:{la:e.start.la,line:e.start.line,offset:e.start.offset}}}function ki(e,t,n,r){pr.call(this,e,t,n,!0),this.j=r,this.I=this.j.I}function Fi(e,t,n,r){var o=[],i=e.J(t,n,r,(function(n){if(e.j instanceof ki)return xr(Fi(e.j,t,n,r),(function(e){return o=e}));var i=null;return ge.create({next:function(){for(;;){if(!i){var t=n.next(0);if(t.done)return K;t=e.j.u(t.value,r),i=xr(t,(function(e){return o=vr(o,e)})).value}if(!(t=i.next(0)).done)return t;i=null}}})})),a=!1;return{next:function(){if(a)return K;var e=i.N();return a=!0,W(new fr(e,o))}}}function Gi(e,t,n,r){return e.J(t,n,r,(function(n){if(e.j instanceof ki)return Gi(e.j,t,n,r);var o=null;return ge.create({next:function(){for(;;){if(!o){var t=n.next(0);if(t.done)return K;o=hr(e.j,t.value,r).value}if(!(t=o.next(0)).done)return t;o=null}}})}))}function Pi(e,t,n,r){ki.call(this,t.s.add(r.s),[t,r],{C:!1},r),this.T=e.prefix,this.ka=e.namespaceURI,this.bc=e.localName,this.ob=null,this.B=n,this.xa=null,this.pa=t}function Hi(e,t,n){var r={};pr.call(this,new Br((r.external=1,r)),[n],{C:!1,S:"unsorted"}),this.T=e.map((function(e){return e.name})),this.B=e.map((function(e){return e.type})),this.u=null,this.J=t,this.j=n}function _i(e,t,n){if(ki.call(this,t.s.add(n.s),[t,n],{C:!1,Y:n.Y,S:n.O,subtree:n.subtree},n),e.prefix||e.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.B=e.prefix,this.T=e.namespaceURI,this.xa=e.localName,this.ka=t,this.pa=null}function ji(e,t){switch(pr.call(this,new Br({}),[],{C:!0,S:"sorted"},!1,t),t.type){case 5:var 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.j=function(){return ge.o(n)}}function Xi(e,t){var n={};pr.call(this,new Br((n.external=1,n)),e.reduce((function(e,t){return e.concat(t.key,t.value)}),[]),{C:!1},!1,t),this.j=e}function Li(e,t,n){var r={};pr.call(this,new Br((r.external=1,r)),[],{C:!0},!1,n),this.u=t,this.B=e,this.j=null}y(vi,pr),vi.prototype.h=function(e,t){var n=this;return t=t.h,1!==(e=di(e.M)).node.nodeType?ge.empty():(e=Oe(t,e,this.u).filter((function(e){return"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI})).map((function(e){return Xe(e)})).filter((function(e){return n.j.j(e)})),ge.create(e))},vi.prototype.A=function(){return"type-1"},y(wi,pr),wi.prototype.h=function(e,t){var n=this,r=t.h,o=di(e.M);if(1!==(e=o.node.nodeType)&&9!==e)return ge.empty();var i=null,a=!1;return ge.create({next:function(){for(;!a;){if(!i){if(!(i=Me(r,o,n.j))){a=!0;continue}return W(Xe(i))}if(i=Fe(r,i,n.j))return W(Xe(i));a=!0}return K}}).filter((function(e){return n.u.j(e)}))},y(xi,pr),xi.prototype.h=function(e,t){var n=this;return e=function(e,t,n){var r=[Wt(t)];return{next:function(t){if(0<r.length&&0!=(1&t)&&r.shift(),!r.length)return K;for(t=r[0].next(0);t.done;){if(r.shift(),!r.length)return K;t=r[0].next(0)}return r.unshift(Ai(e,t.value,n)),W(Xe(t.value))}}}(t=t.h,e=di(e.M),this.B),this.u||e.next(0),ge.create(e).filter((function(e){return n.j.j(e)}))},y(Ni,pr),Ni.prototype.h=function(e,t){var n=this;return t=t.h,e=di(e.M),ge.create(function(e,t,n){for(var r=[];t&&9!==t.node.nodeType;t=Ge(e,t,null)){var o=Fe(e,t,n);o&&r.push(o)}var i=null;return{next:function(){for(;i||r.length;){if(!i){i=Ei(e,r[0],!1,n);var t=W(Xe(r[0])),o=Fe(e,r[0],n);return o?r[0]=o:r.shift(),t}if(!(t=i.next(0)).done)return t;i=null}return K}}}(t,e,this.u)).filter((function(e){return n.j.j(e)}))},y(Bi,pr),Bi.prototype.h=function(e,t){var n=this;return t=t.h,e=di(e.M),ge.create(function(e,t,n){return{next:function(){return(t=t&&Fe(e,t,n))?W(Xe(t)):K}}}(t,e,this.u)).filter((function(e){return n.j.j(e)}))},y(Ti,pr),Ti.prototype.h=function(e,t){return(e=Ge(t=t.h,e=di(e.M),this.u))?(e=Xe(e),this.j.j(e)?ge.o(e):ge.empty()):ge.empty()},y(Ii,pr),Ii.prototype.h=function(e,t){var n=this;return t=t.h,e=di(e.M),ge.create(function(e,t,n){for(var r=[];t&&9!==t.node.nodeType;t=Ge(e,t,null)){var o=Pe(e,t,n);null!==o&&r.push(o)}var i=null;return{next:function(){for(;i||r.length;){i||(i=Ei(e,r[0],!0,n));var t=i.next(0);if(t.done){i=null,t=Pe(e,r[0],n);var o=W(Xe(r[0]));return null===t?r.shift():r[0]=t,o}return t}return K}}}(t,e,this.u)).filter((function(e){return n.j.j(e)}))},y(Ci,pr),Ci.prototype.h=function(e,t){var n=this;return t=t.h,e=di(e.M),ge.create(function(e,t,n){return{next:function(){return(t=t&&Pe(e,t,n))?W(Xe(t)):K}}}(t,e,this.u)).filter((function(e){return n.j.j(e)}))},y(Si,pr),Si.prototype.h=function(e){return di(e.M),this.j.j(e.M)?ge.o(e.M):ge.empty()},Si.prototype.A=function(){return this.u},y(Oi,br),Oi.prototype.B=function(e,t,n){var r=null,o=n[0](e);return ge.create({next:function(t){return r||(r=(o.getEffectiveBooleanValue()?n[1](e):n[2](e)).value),r.next(t)}})},Oi.prototype.P=function(e){if(br.prototype.P.call(this,e),this.j.I)throw er()},y(Mi,br),Mi.prototype.B=function(e,t,n){var r=this;t=c(n).next().value;try{var o=t(e)}catch(e){throw new Ri(this.J,this.j,e)}return ge.create({next:function(e){try{return o.value.next(e)}catch(e){throw new Ri(r.J,r.j,e)}}})},Mi.prototype.P=function(e){try{br.prototype.P.call(this,e)}catch(e){throw new Ri(this.J,this.j,e)}},y(ki,pr),ki.prototype.h=function(e,t){var n=this;return this.J(e,Wt(e),t,(function(r){if(n.j instanceof ki)return Gi(n.j,e,r,t);var o=null;return ge.create({next:function(e){for(;;){if(!o){var i=r.next(0);if(i.done)return K;o=hr(n.j,i.value,t).value}if(!(i=o.next(e)).done)return i;o=null}}})}))},ki.prototype.u=function(e,t){return Fi(this,e,Wt(e),t)},ki.prototype.P=function(e){pr.prototype.P.call(this,e),this.I=this.j.I;for(var t=(e=c(this.ha)).next();!t.done;t=e.next())if((t=t.value)!==this.j&&t.I)throw er()},y(Pi,ki),Pi.prototype.J=function(e,t,n,r){var o=this,i=null,a=null,s=0;return r({next:function(){for(var e={};;){if(!i){var r=t.next(0);if(r.done)return K;a=r.value,s=0,i=hr(o.pa,a,n).value}if(e.jb=i.next(0),!e.jb.done)return s++,(r={})[o.ob]=function(e){return function(){return ge.o(e.jb.value)}}(e),e=r,o.xa&&(e[o.xa]=function(){return ge.o(new re(5,s))}),W(Bt(a,e));i=null,e={jb:e.jb}}}})},Pi.prototype.P=function(e){if(this.T&&(this.ka=e.ba(this.T),!this.ka&&this.T))throw Error("XPST0081: Could not resolve namespace for prefix "+this.T+" in a for expression");if(this.pa.P(e),To(e),this.ob=So(e,this.ka,this.bc),this.B){if(this.B.prefix&&(this.B.namespaceURI=e.ba(this.B.prefix),!this.B.namespaceURI&&this.B.prefix))throw Error("XPST0081: Could not resolve namespace for prefix "+this.T+" in the positionalVariableBinding in a for expression");this.xa=So(e,this.B.namespaceURI,this.B.localName)}if(this.j.P(e),Ro(e),this.pa.I)throw er();this.j.I&&(this.I=!0)},y(Hi,pr),Hi.prototype.h=function(e,t){var n=this,r=new we({l:this.B,arity:this.B.length,Ra:!0,I:this.j.I,localName:"dynamic-function",namespaceURI:"",i:this.J,value:function(r,o,i,a){for(var s=[],u=3;u<arguments.length;++u)s[u-3]=arguments[u];return u=Bt(Nt(e,-1,null,ge.empty()),n.u.reduce((function(e,t,n){return e[t]=ye(s[n]),e}),Object.create(null))),hr(n.j,u,t)}});return ge.o(r)},Hi.prototype.P=function(e){if(To(e),this.u=this.T.map((function(t){return So(e,t.namespaceURI,t.localName)})),this.j.P(e),Ro(e),this.j.I)throw Error("Not implemented: inline functions can not yet be updating.")},y(_i,ki),_i.prototype.J=function(e,t,n,r){var o=this;return r({next:function(){var e=t.next(0);if(e.done)return K;var r={};return W(e=Bt(e=e.value,(r[o.pa]=ye(hr(o.ka,e,n)),r)))}})},_i.prototype.P=function(e){if(this.B&&(this.T=e.ba(this.B),!this.T&&this.B))throw Error("XPST0081: Could not resolve namespace for prefix "+this.B+" using in a for expression");if(this.ka.P(e),To(e),this.pa=So(e,this.T,this.xa),this.j.P(e),Ro(e),this.I=this.j.I,this.ka.I)throw er()},y(ji,pr),ji.prototype.h=function(){return this.j()},y(Xi,pr),Xi.prototype.h=function(e,t){var n=this,r=this.j.map((function(n){return Ut(hr(n.key,e,t),t).$({default:function(){throw Error("XPTY0004: A key of a map should be a single atomizable value.")},o:function(e){return e}})}));return Le(r,(function(r){return ge.o(new Ve(r.map((function(r,o){return{key:r,value:ye(hr(n.j[o].value,e,t))}}))))}))},y(Li,pr),Li.prototype.h=function(){var e=new we({l:this.j.l,I:this.j.I,arity:this.u,localName:this.j.localName,namespaceURI:this.j.namespaceURI,i:this.j.i,value:this.j.m});return ge.o(e)},Li.prototype.P=function(e){var t=this.B.namespaceURI,n=this.B.localName,r=this.B.prefix;if(null===t){var o=e.Ta({localName:n,prefix:r},this.u);if(!o)throw Error("XPST0017: The function "+(r?r+":":"")+n+" with arity "+this.u+" could not be resolved. "+so(n));t=o.namespaceURI,n=o.localName}if(this.j=e.Ba(t,n,this.u)||null,!this.j)throw e=this.B,Error("XPST0017: Function "+(e.namespaceURI?"Q{"+e.namespaceURI+"}":e.prefix?e.prefix+":":"")+e.localName+" with arity of "+this.u+" not registered. "+so(n));pr.prototype.P.call(this,e)};var $i={},qi=($i[5]=5,$i[27]=5,$i[28]=5,$i[31]=5,$i[32]=5,$i[33]=5,$i[34]=5,$i[30]=5,$i[36]=5,$i[35]=5,$i[38]=5,$i[37]=5,$i[29]=5,$i[4]=4,$i[6]=6,$i[3]=3,$i);function Vi(e,t,n){pr.call(this,t.s,[t],{C:!1},!1,n),this.u=t,this.j=e}function Yi(e,t){pr.call(this,e.reduce((function(e,t){return e.add(t.s)}),new Br({})),e,{C:e.every((function(e){return e.C}))},!1,t),this.j=e,this.u=e.reduce((function(e,t){return yi(e,t.A())}),null)}function Qi(e,t){var n,r=e.reduce((function(e,t){return 0<Tr(e,t.s)?e:t.s}),new Br({}));for(pr.call(this,r,e,{C:e.every((function(e){return e.C}))},!1,t),t=0;t<e.length&&(void 0===n&&(n=e[t].A()),null!==n);++t)if(n!==e[t].A()){n=null;break}this.u=n,this.j=e}function Ji(e,t){var n;return ge.create({next:function(r){for(;;){if(!n){var o=e.value.next(r);if(o.done)return K;n=Dt(o.value,t)}if(!(o=n.value.next(r)).done)return o;n=null}}})}function zi(e,t,n){function r(e,t){return{V:a?a(e):e,W:s?s(t):t}}function o(e){return ee(t,e)&&ee(n,e)}function i(e){return 0<e.filter((function(e){return ee(t,e)})).length&&0<e.filter((function(e){return ee(n,e)})).length}var a=null,s=null;if(ee(t,19)&&ee(n,19)?t=n=1:ee(t,19)?(a=function(e){return Kt(e,n)},t=n):ee(n,19)&&(s=function(e){return Kt(e,t)},n=t),ee(t,23)&&ee(n,23))return function(e,t){if("eqOp"===e)return function(e,n){return e=(n=t(e,n)).V,n=n.W,e.value.namespaceURI===n.value.namespaceURI&&e.value.localName===n.value.localName};if("neOp"===e)return function(e,n){return e=(n=t(e,n)).V,n=n.W,e.value.namespaceURI!==n.value.namespaceURI||e.value.localName!==n.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName')}(e,r);if(o(0)||i([1,47,61])||i([2,47,61])||o(20)||o(22)||o(21)||i([1,20])){var u=function(e,t){switch(e){case"eqOp":return function(e,n){return(e=t(e,n)).V.value===e.W.value};case"neOp":return function(e,n){return(e=t(e,n)).V.value!==e.W.value};case"ltOp":return function(e,n){return(e=t(e,n)).V.value<e.W.value};case"leOp":return function(e,n){return(e=t(e,n)).V.value<=e.W.value};case"gtOp":return function(e,n){return(e=t(e,n)).V.value>e.W.value};case"geOp":return function(e,n){return(e=t(e,n)).V.value>=e.W.value}}}(e,r);if(void 0!==u)return u}if(o(16)&&(u=function(e,t){switch(e){case"ltOp":return function(e,n){return(e=t(e,n)).V.value.ga<e.W.value.ga};case"leOp":return function(e,n){return e=(n=t(e,n)).V,n=n.W,Qe(e.value,n.value)||e.value.ga<n.value.ga};case"gtOp":return function(e,n){return(e=t(e,n)).V.value.ga>e.W.value.ga};case"geOp":return function(e,n){return e=(n=t(e,n)).V,n=n.W,Qe(e.value,n.value)||e.value.ga>n.value.ga}}}(e,r),void 0!==u)||o(17)&&(u=function(e,t){switch(e){case"eqOp":return function(e,n){return Qe((e=t(e,n)).V.value,e.W.value)};case"ltOp":return function(e,n){return(e=t(e,n)).V.value.ea<e.W.value.ea};case"leOp":return function(e,n){return e=(n=t(e,n)).V,n=n.W,Qe(e.value,n.value)||e.value.ea<n.value.ea};case"gtOp":return function(e,n){return(e=t(e,n)).V.value.ea>e.W.value.ea};case"geOp":return function(e,n){return e=(n=t(e,n)).V,n=n.W,Qe(e.value,n.value)||e.value.ea>n.value.ea}}}(e,r),void 0!==u)||o(18)&&(u=function(e,t){switch(e){case"eqOp":return function(e,n){return Qe((e=t(e,n)).V.value,e.W.value)};case"neOp":return function(e,n){return!Qe((e=t(e,n)).V.value,e.W.value)}}}(e,r),void 0!==u))return u;if((o(9)||o(7)||o(8))&&(u=function(e,t){switch(e){case"eqOp":return function(e,n,r){return pt((e=t(e,n)).V.value,e.W.value,Et(r))};case"neOp":return function(e,n,r){return!pt((e=t(e,n)).V.value,e.W.value,Et(r))};case"ltOp":return function(e,n,r){return e=t(e,n),r=Et(r),0>lt(e.V.value,e.W.value,r)};case"leOp":return function(e,n,r){var o;return e=(n=t(e,n)).V,n=n.W,(o=pt(e.value,n.value,Et(r)))||(r=Et(r),o=0>lt(e.value,n.value,r)),o};case"gtOp":return function(e,n,r){return e=t(e,n),r=Et(r),0<lt(e.V.value,e.W.value,r)};case"geOp":return function(e,n,r){var o;return e=(n=t(e,n)).V,n=n.W,(o=pt(e.value,n.value,Et(r)))||(r=Et(r),o=0<lt(e.value,n.value,r)),o}}}(e,r),void 0!==u))return u;if((o(11)||o(12)||o(13)||o(14)||o(15))&&(u=function(e,t){switch(e){case"eqOp":return function(e,n,r){return pt((e=t(e,n)).V.value,e.W.value,Et(r))};case"neOp":return function(e,n,r){return!pt((e=t(e,n)).V.value,e.W.value,Et(r))}}}(e,r),void 0!==u))return u;throw Error("XPTY0004: "+e+" not available for "+ie[t]+" and "+ie[n])}y(Vi,pr),Vi.prototype.h=function(e,t){var n=this;return Ut(hr(this.u,e,t),t).L((function(e){if(0===e.length)return ge.empty();var t=e[0];if(n.type)return e="+"===n.j?+t.value:-t.value,0===t.type&&(e=Number.NaN),ge.o(V(e,n.type.type));if(1<e.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return ee(t.type,19)?(t=Kt(t,3).value,ge.o(V("+"===n.j?t:-t,3))):ee(t.type,2)?"+"===n.j?ge.o(t):ge.o(V(-1*t.value,qi[t.type])):ge.o(V(Number.NaN,3))}))},y(Yi,pr),Yi.prototype.h=function(e,t){var n=this,r=0,o=null,i=!1,a=null;if(null!==e){var s=e.M;null!==s&&ee(s.type,53)&&(a=xe(s.value))}return ge.create({next:function(){if(!i){for(;r<n.j.length;){if(!o){var s=n.j[r];if(null!==a&&null!==s.A()&&!a.includes(s.A()))return r++,i=!0,W(Q);o=hr(s,e,t)}if(!1===o.getEffectiveBooleanValue())return i=!0,W(Q);o=null,r++}return i=!0,W(Y)}return K}})},Yi.prototype.A=function(){return this.u},y(Qi,pr),Qi.prototype.h=function(e,t){var n=this,r=0,o=null,i=!1,a=null;if(null!==e){var s=e.M;null!==s&&ee(s.type,53)&&(a=xe(s.value))}return ge.create({next:function(){if(!i){for(;r<n.j.length;){if(!o){var s=n.j[r];if(null!==a&&null!==s.A()&&!a.includes(s.A())){r++;continue}o=hr(s,e,t)}if(!0===o.getEffectiveBooleanValue())return i=!0,W(Y);o=null,r++}return i=!0,W(Q)}return K}})},Qi.prototype.A=function(){return this.u};var Ki=Object.create(null);function Wi(e,t,n){var r=t+"~"+n+"~"+e,o=Ki[r];return o||(o=Ki[r]=zi(e,t,n)),o}function Zi(e,t,n){pr.call(this,t.s.add(n.s),[t,n],{C:!1}),this.j=t,this.B=n,this.u=e}y(Zi,pr),Zi.prototype.h=function(e,t){var n=this,r=hr(this.j,e,t),o=hr(this.B,e,t),i=Ji(r,t),a=Ji(o,t);return i.$({empty:function(){return ge.empty()},o:function(){return a.$({empty:function(){return ge.empty()},o:function(){var t=i.first(),r=a.first();return Wi(n.u,t.type,r.type)(t,r,e)?ge.ca():ge.X()},multiple:function(){throw Error("XPTY0004: Sequences to compare are not singleton.")}})},multiple:function(){throw Error("XPTY0004: Sequences to compare are not singleton.")}})};var ea={},ta=(ea.equalOp="eqOp",ea.notEqualOp="neOp",ea.lessThanOrEqualOp="leOp",ea.lessThanOp="ltOp",ea.greaterThanOrEqualOp="geOp",ea.greaterThanOp="gtOp",ea);function na(e,t,n){pr.call(this,t.s.add(n.s),[t,n],{C:!1}),this.j=t,this.B=n,this.u=e}function ra(e,t,n,r){if(!ee(n,53)||!ee(r,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(e){case"isOp":return function(e,t){return e!==t||47!==e&&53!==e&&54!==e&&55!==e&&56!==e&&57!==e&&58!==e?function(){return!1}:function(e,t){return en(e.first().value,t.first().value)}}(n,r);case"nodeBeforeOp":return t?function(e,n){return 0>an(t,e.first(),n.first())}:void 0;case"nodeAfterOp":return t?function(e,n){return 0<an(t,e.first(),n.first())}:void 0;default:throw Error("Unexpected operator")}}function oa(e,t,n){pr.call(this,t.s.add(n.s),[t,n],{C:!1}),this.j=t,this.B=n,this.u=e}function ia(e,t,n,r){return n.L((function(n){if(n.some((function(e){return!ee(e.type,53)})))throw Error("XPTY0004: Sequences given to "+e+" should only contain nodes.");return"sorted"===r?ge.create(n):"reverse-sorted"===r?ge.create(n.reverse()):ge.create(sn(t,n))}))}function aa(e,t,n,r){pr.call(this,0<Tr(t.s,n.s)?t.s:n.s,[t,n],{C:t.C&&n.C},!1,r),this.j=e,this.u=t,this.B=n}function sa(e,t){br.call(this,e.reduce((function(e,t){return e.add(t.s)}),new Br({})),e,{S:"unsorted",C:e.every((function(e){return e.C}))},t)}function ua(e,t,n){pr.call(this,new Br({}).add(e.s),[e,t],{C:e.C&&t.C},!1,n),this.j=e,this.u=t}function ca(e,t,n){if(pr.call(this,e.s,[e],{C:!1}),this.j=ue(t.prefix?t.prefix+":"+t.localName:t.localName),46===this.j||45===this.j||44===this.j)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.B=e,this.u=n}function la(e,t,n){if(pr.call(this,e.s,[e],{C:!1}),this.j=ue(t.prefix?t.prefix+":"+t.localName:t.localName),46===this.j||45===this.j||44===this.j)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.B=e,this.u=n}function pa(e,t){var n=e.value,r=null,o=!1;return ge.create({next:function(){for(;!o;){if(!r){var e=n.next(0);if(e.done)return o=!0,W(Y);r=t(e.value)}if(e=r.getEffectiveBooleanValue(),r=null,!1===e)return o=!0,W(Q)}return K}})}function ha(e,t,n,r){pr.call(this,e.s,[e],{C:!1},!1,r),this.B=e,this.u=t,this.j=n}function fa(e,t){return!(null===e||null===t||!ee(e.type,53)||!ee(t.type,53))&&en(e.value,t.value)}function da(e){var t=e.next(0);if(t.done)return ge.empty();var n=null,r=null;return ge.create({next:function(o){if(t.done)return K;n||(n=t.value.value);do{var i=n.next(o);if(i.done){if((t=e.next(0)).done)return i;n=t.value.value}}while(i.done||fa(i.value,r));return r=i.value,i}})}function ma(e,t){var n=[];!function(){for(var e=t.next(0),r={};!e.done;)r.lb=e.value.value,e={current:r.lb.next(0),next:function(e){return function(t){return e.lb.next(t)}}(r)},e.current.done||n.push(e),e=t.next(0),r={lb:r.lb}}();var r=null,o=!1,i={};return ge.create((i[Symbol.iterator]=function(){return this},i.next=function(){o||(o=!0,n.every((function(e){return ee(e.current.value.type,53)}))&&n.sort((function(t,n){return an(e,t.current.value,n.current.value)})));do{if(!n.length)return K;var t=n.shift(),i=t.current;if(t.current=t.next(0),!ee(i.value.type,53))return i;if(!t.current.done){for(var a=0,s=n.length-1,u=0;a<=s;){u=Math.floor((a+s)/2);var c=an(e,t.current.value,n[u].current.value);if(0===c){a=u;break}0<c?a=u+1:s=u-1}n.splice(a,0,t)}}while(fa(i.value,r));return r=i.value,i},i))}function ga(e,t){var n=e.reduce((function(e,t){return 0<Tr(e,t.s)?e:t.s}),new Br({}));pr.call(this,n,e,{C:e.every((function(e){return e.C}))},!1,t),this.j=e}function ya(e){return e.every((function(e){return null===e||ee(e.type,5)||ee(e.type,4)}))||null!==e.map((function(e){return e?Mt(e.type):null})).reduce((function(e,t){return null===t||t===e?e:null}))?e:e.every((function(e){return null===e||ee(e.type,1)||ee(e.type,20)}))?e.map((function(e){return e?Kt(e,1):null})):e.every((function(e){return null===e||ee(e.type,4)||ee(e.type,6)}))?e.map((function(e){return e?Kt(e,6):e})):e.every((function(e){return null===e||ee(e.type,4)||ee(e.type,6)||ee(e.type,3)}))?e.map((function(e){return e?Kt(e,3):e})):null}function va(e,t){var n=new Br({});ki.call(this,n,[t].concat(p(e.map((function(e){return e.da})))),{C:!1,Y:!1,S:"unsorted",subtree:!1},t),this.B=e}function wa(e){pr.call(this,e?e.s:new Br({}),e?[e]:[],{S:"sorted",subtree:!1,Y:!1,C:!1}),this.j=e}function Aa(e){pr.call(this,new Br({}),[],{S:"sorted"},!1,e)}function xa(e,t){var n=e.every((function(e){return e.Y})),r=e.every((function(e){return e.subtree}));pr.call(this,e.reduce((function(e,t){return e.add(t.s)}),new Br({})),e,{C:!1,Y:n,S:t?"sorted":"unsorted",subtree:r}),this.j=e,this.u=t}function ba(e,t){pr.call(this,e.s.add(t.s),[e,t],{C:e.C&&t.C,Y:e.Y,S:e.O,subtree:e.subtree}),this.u=e,this.j=t}function Ea(e,t,n){if(n=[n],ee(e.type,62))if("*"===t)n.push.apply(n,p(e.R.map((function(e){return e()}))));else{if(!ee(t.type,5))throw ho("The key specifier is not an integer.");var r=t.value;if(e.R.length<r||0>=r)throw Error("FOAY0001: Array index out of bounds");n.push(e.R[r-1]())}else{if(!ee(e.type,61))throw ho("The provided context item is not a map or an array.");"*"===t?n.push.apply(n,p(e.h.map((function(e){return e.value()})))):(e=e.h.find((function(e){return $e(e.key,t)})))&&n.push(e.value())}return It(n)}function Na(e,t,n,r,o){return"*"===t?Ea(e,t,n):(t=ye(t=hr(t,r,o))().L((function(t){return t.reduce((function(t,n){return Ea(e,n,t)}),new ne)})),It([n,t]))}function Ba(e,t){pr.call(this,e.s,[e].concat("*"===t?[]:[t]),{C:e.C,S:e.O,subtree:e.subtree}),this.j=e,this.u=t}function Ta(e,t){var n={};pr.call(this,new Br((n.external=1,n)),"*"===e?[]:[e],{C:!1},!1,t),this.j=e}function Ia(e,t,n,r){var o=t.map((function(e){return e.gb}));t=t.map((function(e){return e.name}));var i=o.reduce((function(e,t){return e.add(t.s)}),n.s);pr.call(this,i,o.concat(n),{C:!1},!1,r),this.u=e,this.B=t,this.J=o,this.T=n,this.j=null}function Ca(e){pr.call(this,e,[],{C:!1})}function Sa(e){var t={};Ca.call(this,new Br((t.nodeType=1,t))),this.u=e}function Oa(e,t){t=void 0===t?{kind:null}:t;var n=e.prefix,r=e.namespaceURI,o={};"*"!==(e=e.localName)&&(o.nodeName=1),o.nodeType=1,Ca.call(this,new Br(o)),this.u=e,this.J=r,this.B=n,this.T=t.kind}function Ra(e){var t={};Ca.call(this,new Br((t.nodeName=1,t))),this.u=e}function Da(e){Ca.call(this,new Br({})),this.u=e}function Ua(e,t,n){pr.call(this,new Br({}),[],{C:!1,S:"unsorted"}),this.B=n,this.u=t,this.J=e,this.j=null}function Ma(e,t){var n=new Br({});ki.call(this,n,[e,t],{C:!1,Y:!1,S:"unsorted",subtree:!1},t),this.B=e}function ka(e){this.type=e}function Fa(e){this.type="delete",this.target=e}function Ga(e,t,n){this.type=n,this.target=e,this.content=t}function Pa(e,t){Ga.call(this,e,t,"insertAfter")}function Ha(e,t){this.type="insertAttributes",this.target=e,this.content=t}function _a(e,t){Ga.call(this,e,t,"insertBefore")}function ja(e,t){Ga.call(this,e,t,"insertIntoAsFirst")}function Xa(e,t){Ga.call(this,e,t,"insertIntoAsLast")}function La(e,t){Ga.call(this,e,t,"insertInto")}function $a(e,t){this.type="rename",this.target=e,this.s=t.ya?t:new ve(t.prefix,t.namespaceURI,t.localName)}function qa(e,t){this.type="replaceElementContent",this.target=e,this.text=t}function Va(e,t){this.type="replaceNode",this.target=e,this.s=t}function Ya(e,t){this.type="replaceValue",this.target=e,this.s=t}function Qa(e,t){return new Va(e,t)}function Ja(e){wr.call(this,new Br({}),[e],{C:!1,S:"unsorted"}),this.j=e}function za(e,t,n,r,o,i){var a=t.h;return e.reduce((function e(t,n){return ee(n.type,62)?(n.R.forEach((function(n){return n().N().forEach((function(n){return e(t,n)}))})),t):(t.push(n),t)}),[]).forEach((function(e,s,u){if(ee(e.type,47)){if(o)throw i(e.value,a);n.push(e.value.node)}else if(ee(e.type,46)||ee(e.type,53)&&3===e.value.node.nodeType){var c=ee(e.type,46)?Kt(Dt(e,t).first(),1).value:Ue(a,e.value);0!==s&&ee(u[s-1].type,46)&&ee(e.type,46)?(r.push({data:" "+c,Sa:!0,nodeType:3}),o=!0):c&&(r.push({data:""+c,Sa:!0,nodeType:3}),o=!0)}else if(ee(e.type,55)){var l=[];De(a,e.value).forEach((function(e){return l.push(Xe(e))})),o=za(l,t,n,r,o,i)}else{if(!ee(e.type,53)){if(ee(e.type,60))throw Ot(e.type);throw Error("Atomizing "+e.type+" is not implemented.")}r.push(e.value.node),o=!0}})),o}function Ka(e,t,n){var r=[],o=[],i=!1;return e.forEach((function(e){i=za(e,t,r,o,i,n)})),{attributes:r,Va:o}}function Wa(e,t,n,r,o){var i=[];switch(e){case 4:r.length&&i.push(new Ha(t,r)),o.length&&i.push(new ja(t,o));break;case 5:r.length&&i.push(new Ha(t,r)),o.length&&i.push(new Xa(t,o));break;case 3:r.length&&i.push(new Ha(t,r)),o.length&&i.push(new La(t,o));break;case 2:r.length&&i.push(new Ha(n,r)),o.length&&i.push(new _a(t,o));break;case 1:r.length&&i.push(new Ha(n,r)),o.length&&i.push(new Pa(t,o))}return i}function Za(e,t,n){wr.call(this,new Br({}),[e,n],{C:!1,S:"unsorted"}),this.J=e,this.j=t,this.B=n}function es(){return St("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types.")}y(na,pr),na.prototype.h=function(e,t){var n=this,r=hr(this.j,e,t),o=hr(this.B,e,t);return r.$({empty:function(){return ge.X()},default:function(){return o.$({empty:function(){return ge.X()},default:function(){var i=Ji(r,t),a=Ji(o,t);return function(e,t,n,r){return e=ta[e],n.L((function(n){return t.filter((function(t){for(var o=0,i=n.length;o<i;++o){var a=n[o],s=void 0,u=void 0,l=t.type,p=a.type;if((ee(l,19)||ee(p,19))&&(ee(l,2)?s=3:ee(p,2)?u=3:ee(l,17)?s=17:ee(p,17)?u=17:ee(l,16)?s=16:ee(p,16)?u=16:ee(l,19)?u=p:ee(p,19)&&(s=l)),s=(u=c([u,s])).next().value,u=u.next().value,s?t=Kt(t,s):u&&(a=Kt(a,u)),Wi(e,t.type,a.type)(t,a,r))return!0}return!1})).$({default:function(){return ge.ca()},empty:function(){return ge.X()}})}))}(n.u,i,a,e)}})}})},y(oa,pr),oa.prototype.h=function(e,t){var n=this,r=hr(this.j,e,t),o=hr(this.B,e,t);return r.$({empty:function(){return ge.empty()},multiple:function(){throw Error("XPTY0004: Sequences to compare are not singleton")},o:function(){return o.$({empty:function(){return ge.empty()},multiple:function(){throw Error("XPTY0004: Sequences to compare are not singleton")},o:function(){var i=r.first(),a=o.first();return ra(n.u,t.h,i.type,a.type)(r,o,e)?ge.ca():ge.X()}})}})},y(aa,pr),aa.prototype.h=function(e,t){var n=this,r=ia(this.j,t.h,hr(this.u,e,t),this.u.O);e=ia(this.j,t.h,hr(this.B,e,t),this.B.O);var o=r.value,i=e.value,a=null,s=null,u=!1,c=!1;return ge.create({next:function(){if(u)return K;for(;!c;){if(!a){var e=o.next(0);if(e.done)return u=!0,K;a=e.value}if(!s){if((e=i.next(0)).done){c=!0;break}s=e.value}if(en(a.value,s.value)){if(e=W(a),s=a=null,"intersectOp"===n.j)return e}else if(0>an(t.h,a,s)){if(e=W(a),a=null,"exceptOp"===n.j)return e}else s=null}return"exceptOp"===n.j?null!==a?(e=W(a),a=null,e):o.next(0):(u=!0,K)}})},y(sa,br),sa.prototype.B=function(e,t,n){return n.length?It(n.map((function(t){return t(e)}))):ge.empty()},y(ua,pr),ua.prototype.h=function(e,t){var n=this,r=xt(e,hr(this.j,e,t)),o=null,i=null,a=!1;return ge.create({next:function(e){for(;!a;){if(!o&&(o=r.next(e)).done)return a=!0,K;i||(i=hr(n.u,o.value,t));var s=i.value.next(e);if(!s.done)return s;o=i=null}}})},y(ca,pr),ca.prototype.h=function(e,t){var n=this,r=Ut(hr(this.B,e,t),t);return r.$({empty:function(){return n.u?ge.ca():ge.X()},o:function(){return r.map((function(e){return zt(e,n.j).v?Y:Q}))},multiple:function(){return ge.X()}})},y(la,pr),la.prototype.h=function(e,t){var n=this,r=Ut(hr(this.B,e,t),t);return r.$({empty:function(){if(!n.u)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");return ge.empty()},o:function(){return r.map((function(e){return Kt(e,n.j)}))},multiple:function(){throw Error("XPTY0004: Sequence to cast is not singleton or empty.")}})},y(ha,pr),ha.prototype.h=function(e,t){var n=this,r=hr(this.B,e,t);return r.$({empty:function(){return"?"===n.j||"*"===n.j?ge.ca():ge.X()},multiple:function(){return"+"===n.j||"*"===n.j?pa(r,(function(r){var o=ge.o(r);return r=Nt(e,0,r,o),hr(n.u,r,t)})):ge.X()},o:function(){return pa(r,(function(r){var o=ge.o(r);return r=Nt(e,0,r,o),hr(n.u,r,t)}))}})},y(ga,pr),ga.prototype.h=function(e,t){var n=this;if(this.j.every((function(e){return"sorted"===e.O}))){var r=0;return ma(t.h,{next:function(){return r>=n.j.length?K:W(hr(n.j[r++],e,t))}}).map((function(e){if(!ee(e.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return e}))}return It(this.j.map((function(n){return hr(n,e,t)}))).L((function(e){if(e.some((function(e){return!ee(e.type,53)})))throw Error("XPTY0004: The sequences to union are not of type node()*");return e=sn(t.h,e),ge.create(e)}))},y(va,ki),va.prototype.J=function(e,t,n,r){if(this.B[1])throw Error("More than one order spec is not supported for the order by clause.");var o,i,a=[],s=!1,u=null,l=this.B[0];return ge.create({next:function(){if(!s){for(var p=t.next(0);!p.done;)a.push(p.value),p=t.next(0);if((p=a.map((function(e){return l.da.h(e,n)})).map((function(e){return Ut(e,n)}))).find((function(e){return!e.G()&&!e.ta()})))throw ho("Order by only accepts empty or singleton sequences");if(function(e){return(e=e.find((function(e){return!!e})))?Mt(e.type):null}(o=(o=p.map((function(e){return e.first()}))).map((function(e){return null===e?e:ee(19,e.type)?Kt(e,1):e})))&&!(o=ya(o)))throw ho("Could not cast values");p=o.length,i=o.map((function(e,t){return t}));for(var h=0;h<p;h++)if(h+1!==p)for(var f=h;0<=f;f--){var d=f,m=f+1;if(m!==p){var g=o[i[d]],y=o[i[m]];if(null!==y||null!==g){if(l.Bc){if(null===g)continue;if(null===y&&null!==g){g=c([i[m],i[d]]),i[d]=g.next().value,i[m]=g.next().value;continue}if(isNaN(y.value)&&null!==g&&!isNaN(g.value)){g=c([i[m],i[d]]),i[d]=g.next().value,i[m]=g.next().value;continue}}else{if(null===y)continue;if(null===g&&null!==y){g=c([i[m],i[d]]),i[d]=g.next().value,i[m]=g.next().value;continue}if(isNaN(g.value)&&null!==y&&!isNaN(y.value)){g=c([i[m],i[d]]),i[d]=g.next().value,i[m]=g.next().value;continue}}Wi("gtOp",g.type,y.type)(g,y,e)&&(g=c([i[m],i[d]]),i[d]=g.next().value,i[m]=g.next().value)}}}var v=l.Ib?0:o.length-1;u=r({next:function(){return l.Ib?v>=o.length?K:W(a[i[v++]]):0>v?K:W(a[i[v--]])}}).value,s=!0}return u.next(0)}})},y(wa,pr),wa.prototype.h=function(e,t){if(null===e.M)throw Error("XPDY0002: context is absent, it needs to be present to use paths.");for(var n=t.h,r=e.M.value;9!==r.node.nodeType;)if(null===(r=Ge(n,r)))throw Error("XPDY0050: the root node of the context node is not a document node.");return n=ge.o(Xe(r)),this.j?hr(this.j,Nt(e,0,n.first(),n),t):n},y(Aa,pr),Aa.prototype.h=function(e){if(null===e.M)throw Error('XPDY0002: context is absent, it needs to be present to use the "." operator');return ge.o(e.M)},y(xa,pr),xa.prototype.h=function(e,t){var n=this,r=!0;return this.j.reduce((function(o,i,a){var s=null===o?Wt(e):xt(e,o);if(o={next:function(e){if((e=s.next(e)).done)return K;if(null!==e.value.M&&!ee(e.value.M.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 W(hr(i,e.value,t))}},n.u)switch(i.O){case"reverse-sorted":var u=o;o={next:function(e){return(e=u.next(e)).done?e:W(e.value.L((function(e){return ge.create(e.reverse())})))}};case"sorted":if(i.subtree&&r){var c=da(o);break}c=ma(t.h,o);break;case"unsorted":return da(o).L((function(e){return ge.create(function(e,t){var n=!1,r=!1;if(t.forEach((function(e){ee(e.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?sn(e,t):t}(t.h,e))}))}else c=da(o);return r=r&&i.Y,c}),null)},xa.prototype.A=function(){return this.j[0].A()},y(ba,pr),ba.prototype.h=function(e,t){var n=this,r=hr(this.u,e,t);if(this.j.C){var o=hr(this.j,e,t);if(o.G())return o;var i=o.first();if(ee(i.type,2)){var a=i.value;if(!Number.isInteger(a))return ge.empty();var s=r.value,u=!1;return ge.create({next:function(){if(!u){for(var e=s.next(0);!e.done;e=s.next(0))if(1==a--)return u=!0,e;u=!0}return K}})}return o.getEffectiveBooleanValue()?r:ge.empty()}var c=r.value,l=null,p=0,h=null;return ge.create({next:function(o){for(var i=!1;(!l||!l.done)&&(l||(l=c.next(i?0:o),i=!0),!l.done);){h||(h=hr(n.j,Nt(e,p,l.value,r),t));var a=h.first();a=null!==a&&(ee(a.type,2)?a.value===p+1:h.getEffectiveBooleanValue()),h=null;var s=l.value;if(l=null,p++,a)return W(s)}return l}})},ba.prototype.A=function(){return this.u.A()},y(Ba,pr),Ba.prototype.h=function(e,t){var n=this;return hr(this.j,e,t).L((function(r){return r.reduce((function(r,o){return Na(o,n.u,r,e,t)}),new ne)}))},Ba.prototype.A=function(){return this.j.A()},y(Ta,pr),Ta.prototype.h=function(e,t){return Na(e.M,this.j,new ne,e,t)},y(Ia,pr),Ia.prototype.h=function(e,t){var n=this,r=e,o=this.j.map((function(o,i){var a=hr(n.J[i],r,t).N();return r=Bt(e,((i={})[o]=function(){return ge.create(a)},i)),a}));if(o.some((function(e){return 0===e.length})))return"every"===this.u?ge.ca():ge.X();var i=Array(o.length).fill(0);i[0]=-1;for(var a=!0;a;){a=!1;for(var s=0,u=i.length;s<u;++s){var c=o[s];if(!(++i[s]>c.length-1)){for(a=Object.create(null),s={},u=0;u<i.length;s={wb:s.wb},u++)s.wb=o[u][i[u]],a[this.j[u]]=function(e){return function(){return ge.o(e.wb)}}(s);if(a=Bt(e,a),(a=hr(this.T,a,t)).getEffectiveBooleanValue()&&"some"===this.u)return ge.ca();if(!a.getEffectiveBooleanValue()&&"every"===this.u)return ge.X();a=!0;break}i[s]=0}}return"every"===this.u?ge.ca():ge.X()},Ia.prototype.P=function(e){this.j=[];for(var t=0,n=this.B.length;t<n;++t){this.J[t].P(e),To(e);var r=this.B[t],o=r.prefix?e.ba(r.prefix):null;r=So(e,o,r.localName),this.j[t]=r}for(this.T.P(e),t=0,n=this.B.length;t<n;++t)Ro(e)},y(Ca,pr),Ca.prototype.h=function(e){return this.j(e.M)?ge.ca():ge.X()},y(Sa,Ca),Sa.prototype.j=function(e){return!!ee(e.type,53)&&(e=e.value.node.nodeType,3===this.u&&4===e||this.u===e)},Sa.prototype.A=function(){return"type-"+this.u},y(Oa,Ca),Oa.prototype.j=function(e){var t=ee(e.type,54),n=ee(e.type,47);return!(!t&&!n)&&(e=e.value,!(null!==this.T&&(1===this.T&&!t||2===this.T&&!n))&&(null===this.B&&""!==this.J&&"*"===this.u||("*"===this.B?"*"===this.u||this.u===e.node.localName:("*"===this.u||this.u===e.node.localName)&&(e.node.namespaceURI||null)===((""===this.B?t?this.J:null:this.J)||null))))},Oa.prototype.A=function(){return"*"===this.u?null===this.T?"type-1-or-type-2":"type-"+this.T:"name-"+this.u},Oa.prototype.P=function(e){if(null===this.J&&"*"!==this.B&&(this.J=e.ba(this.B||"")||null,!this.J&&this.B))throw Error("XPST0081: The prefix "+this.B+" could not be resolved.")},y(Ra,Ca),Ra.prototype.j=function(e){return ee(e.type,57)&&e.value.node.target===this.u},Ra.prototype.A=function(){return"type-7"},y(Da,Ca),Da.prototype.j=function(e){return ee(e.type,ue(this.u.prefix?this.u.prefix+":"+this.u.localName:this.u.localName))},y(Ua,pr),Ua.prototype.h=function(e,t){if(!e.Ga[this.j]){if(this.T)return this.T(e,t);throw Error("XQDY0054: The variable "+this.B+" is declared but not in scope.")}return e.Ga[this.j]()},Ua.prototype.P=function(e){if(null===this.u&&this.J&&(this.u=e.ba(this.J)),this.j=e.sb(this.u||"",this.B),!this.j)throw Error("XPST0008, The variable "+this.B+" is not in scope.");(e=e.Fa[this.j])&&(this.T=e)},y(Ma,ki),Ma.prototype.J=function(e,t,n,r){var o=this,i=null,a=null;return r({next:function(){for(;;){if(!a){var e=t.next(0);if(e.done)return K;i=e.value,a=hr(o.B,i,n)}e=a.getEffectiveBooleanValue();var r=i;if(a=i=null,e)return W(r)}}})},y(Fa,ka),Fa.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t},y(Ga,ka),Ga.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t.content=this.content.map((function(t){return Kr(t,e,!0)})),t},y(Pa,Ga),y(Ha,ka),Ha.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t.content=this.content.map((function(t){return Kr(t,e,!0)})),t},y(_a,Ga),y(ja,Ga),y(Xa,Ga),y(La,Ga),y($a,ka),$a.prototype.h=function(e){var t={},n={};return n.type=this.type,n.target=Kr(this.target,e,!1),n.newName=(t.prefix=this.s.prefix,t.namespaceURI=this.s.namespaceURI,t.localName=this.s.localName,t),n},y(qa,ka),qa.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t.text=this.text?Kr(this.text,e,!0):null,t},y(Va,ka),Va.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t.replacement=this.s.map((function(t){return Kr(t,e,!0)})),t},y(Ya,ka),Ya.prototype.h=function(e){var t={};return t.type=this.type,t.target=Kr(this.target,e,!1),t["string-value"]=this.s,t},y(Ja,wr),Ja.prototype.u=function(e,t){var n,r,o=Ar(this.j)(e,t),i=t.h;return{next:function(){if(!n){var e=o.next(0);if(e.value.H.some((function(e){return!ee(e.type,53)})))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");n=e.value.H,r=e.value.fa}return n=n.filter((function(e){return Ge(i,e.value)})),W({fa:vr(n.map((function(e){return new Fa(e.value)})),r),H:[]})}}},y(Za,wr),Za.prototype.u=function(e,t){var n,r,o,i,a,s,u=this,c=Ar(this.J)(e,t),l=Ar(this.B)(e,t),p=t.h;return{next:function(){if(!n){var e=c.next(0),h=Ka([e.value.H],t,tr);n=h.attributes.map((function(e){return{node:e,F:null}})),r=h.Va.map((function(e){return{node:e,F:null}})),o=e.value.fa}if(!i){if(0===(e=l.next(0)).value.H.length)throw lr();if(3<=u.j){if(1!==e.value.H.length)throw nr();if(!ee(e.value.H[0].type,54)&&!ee(e.value.H[0].type,55))throw nr()}else{if(1!==e.value.H.length)throw rr();if(!(ee(e.value.H[0].type,54)||ee(e.value.H[0].type,56)||ee(e.value.H[0].type,58)||ee(e.value.H[0].type,57)))throw rr();if(null===(s=Ge(p,e.value.H[0].value,null)))throw Error("XUDY0029: The target "+e.value.H[0].value.outerHTML+" for inserting a node before or after must have a parent.")}i=e.value.H[0],a=e.value.fa}if(n.length){if(3<=u.j){if(!ee(i.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.")}else if(1!==s.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");n.reduce((function(e,t){var n=t.node.prefix||"",r=t.node.prefix||"",o=t.node.namespaceURI,a=r?i.value.node.lookupNamespaceURI(r):null;if(a&&a!==o)throw ur(o);if((r=e[r])&&o!==r)throw cr(o);return e[n]=t.node.namespaceURI,e}),{})}return W({H:[],fa:vr(Wa(u.j,i.value,s||null,n,r),o,a)})}}};var ts=/([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])/,ns=new RegExp(ts.source+new RegExp("("+ts.source+"|[-.0-9·̀-ͯ‿⁀])").source+"*","g");function rs(e){return!!(e=e.match(ns))&&1===e.length}function os(e,t){return Ut(t,e).$({o:function(e){if(ee((e=e.first()).type,1)||ee(e.type,19)){if(!rs(e.value))throw Error('XQDY0041: The value "'+e.value+'" of a name expressions cannot be converted to a NCName.');return ge.o(e)}throw es()},default:function(){throw es()}}).value}function is(e,t,n){return Ut(n,t).$({o:function(t){if(ee((t=t.first()).type,23))return ge.o(t);if(ee(t.type,1)||ee(t.type,19)){if(1===(t=t.value.split(":")).length)t=t[0];else{var n=t[0],r=e.ba(n);t=t[1]}if(!rs(t)||n&&!rs(n))throw Ao(n?n+":"+t:t);if(n&&!r)throw Ao(n+":"+t);return ge.o({type:23,value:new ve(n,r,t)})}throw es()},default:function(){throw es()}}).value}function as(e,t){wr.call(this,new Br({}),[e,t],{C:!1,S:"unsorted"}),this.B=e,this.J=t,this.j=void 0}function ss(e,t,n){wr.call(this,new Br({}),[t,n],{C:!1,S:"unsorted"}),this.J=e,this.j=t,this.B=n}function us(e){switch(e.type){case"delete":return new Fa({node:e.target,F:null});case"insertAfter":return new Pa({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"insertBefore":return new _a({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"insertInto":return new La({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"insertIntoAsFirst":return new ja({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"insertIntoAsLast":return new Xa({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"insertAttributes":return new Ha({node:e.target,F:null},e.content.map((function(e){return{node:e,F:null}})));case"rename":return new $a({node:e.target,F:null},e.newName);case"replaceNode":return new Va({node:e.target,F:null},e.replacement.map((function(e){return{node:e,F:null}})));case"replaceValue":return new Ya({node:e.target,F:null},e["string-value"]);case"replaceElementContent":return new qa({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 cs(e,t,n){if(t.find((function(t){return en(t,e)})))return!0;var r=Ge(n,e);return!!r&&cs(r,t,n)}function ls(e,t,n){wr.call(this,new Br({}),e.reduce((function(e,t){return e.push(t.gb),e}),[t,n]),{C:!1,S:"unsorted"}),this.j=e,this.J=t,this.B=n,this.I=null}function ps(e,t){return{node:{nodeType:2,Sa:!0,nodeName:e.ya(),namespaceURI:e.namespaceURI,prefix:e.prefix,localName:e.localName,name:e.ya(),value:t},F:null}}function hs(e,t){var n=t.vb||[];n=n.concat(e.Ma||[]),pr.call(this,new Br({}),n,{C:!1,S:"unsorted"}),e.Ma?this.u=e.Ma:this.name=new ve(e.prefix,e.namespaceURI,e.localName),this.j=t,this.B=void 0}function fs(e){pr.call(this,e?e.s:new Br({}),e?[e]:[],{C:!1,S:"unsorted"}),this.j=e}function ds(e,t,n,r){pr.call(this,new Br({}),r.concat(t).concat(e.Ma||[]),{C:!1,S:"unsorted"}),e.Ma?this.u=e.Ma:this.j=new ve(e.prefix,e.namespaceURI,e.localName),this.T=n.reduce((function(e,t){if(t.prefix in e)throw Error("XQST0071: The namespace declaration with the prefix "+t.prefix+" has already been declared on the constructed element.");return e[t.prefix||""]=t.uri,e}),{}),this.J=t,this.ka=r,this.B=void 0}function ms(e){if(/^xml$/i.test(e))throw Error('XQDY0064: The target of a created PI may not be "'+e+'"')}function gs(e,t){return{node:{data:t,Sa:!0,nodeName:e,nodeType:7,target:e},F:null}}function ys(e,t){var n=e.Eb?[e.Eb].concat(t):[t];pr.call(this,n.reduce((function(e,t){return e.add(t.s)}),new Br({})),n,{C:!1,S:"unsorted"}),this.j=e,this.u=t}function vs(e){pr.call(this,e?e.s:new Br({}),e?[e]:[],{C:!1,S:"unsorted"}),this.j=e}function ws(e,t,n,r){var o,i=new Br({});br.call(this,i,(o=[e].concat(p(t.map((function(e){return e.zc}))),[n])).concat.apply(o,p(t.map((function(e){return e.Nb.map((function(e){return e.Mb}))})))),{C:!1,Y:!1,S:"unsorted",subtree:!1},r),this.J=e,this.j=t.length,this.T=t.map((function(e){return e.Nb}))}y(as,wr),as.prototype.u=function(e,t){var n=this,r=Ar(this.B)(e,t),o=Ar(this.J)(e,t);return{next:function(){var e=r.next(0),i=e.value.H;if(0===i.length)throw lr();if(1!==i.length)throw ir();if(!ee(i[0].type,54)&&!ee(i[0].type,47)&&!ee(i[0].type,57))throw ir();i=i[0];var a=o.next(0);e:{var s=n.j,u=ge.create(a.value.H);switch(i.type){case 54:if(s=is(s,t,u).next(0).value.value,(u=i.value.node.lookupNamespaceURI(s.prefix))&&u!==s.namespaceURI)throw ur(s.namespaceURI);break e;case 47:if((s=is(s,t,u).next(0).value.value).namespaceURI&&(u=i.value.node.lookupNamespaceURI(s.prefix))&&u!==s.namespaceURI)throw ur(s.namespaceURI);break e;case 57:s=new ve("",null,s=os(t,u).next(0).value.value);break e}s=void 0}return W({H:[],fa:vr([new $a(i.value,s)],e.value.fa,a.value.fa)})}}},as.prototype.P=function(e){this.j=Bo(e),wr.prototype.P.call(this,e)},y(ss,wr),ss.prototype.u=function(e,t){var n=Ar(this.j)(e,t);return e=Ar(this.B)(e,t),this.J?function(e,t,n){var r,o,i,a,s=!1;return{next:function(){if(s)return K;if(!i){var u=n.next(0),c=Ut(ge.create(u.value.H),e).map((function(e){return Kt(e,1)})).N().map((function(e){return e.value})).join(" ");i=0===c.length?null:{node:e.s.createTextNode(c),F:null},a=u.value.fa}if(!r){if(0===(u=t.next(0)).value.H.length)throw lr();if(1!==u.value.H.length)throw or();if(!(ee(u.value.H[0].type,54)||ee(u.value.H[0].type,47)||ee(u.value.H[0].type,56)||ee(u.value.H[0].type,58)||ee(u.value.H[0].type,57)))throw or();r=u.value.H[0],o=u.value.fa}if(ee(r.type,54))return s=!0,W({H:[],fa:vr([new qa(r.value,i)],a,o)});if(ee(r.type,47)||ee(r.type,56)||ee(r.type,58)||ee(r.type,57)){if(u=i?Ue(e.h,i):"",ee(r.type,58)&&(u.includes("--")||u.endsWith("-")))throw Error('XQDY0072: The content "'+u+'" for a comment node contains two adjacent hyphens or ends with a hyphen.');if(ee(r.type,57)&&u.includes("?>"))throw Error('XQDY0026: The content "'+u+'" for a processing instruction node contains "?>".');return s=!0,W({H:[],fa:vr([new Ya(r.value,u)],a,o)})}}}}(t,n,e):function(e,t,n){var r,o,i;return{next:function(){if(!r){var a=n.next(0),s=Ka([a.value.H],e,cr);r={attributes:s.attributes.map((function(e){return{node:e,F:null}})),Va:s.Va.map((function(e){return{node:e,F:null}}))},o=a.value.fa}if(0===(s=t.next(0)).value.H.length)throw lr();if(1!==s.value.H.length)throw or();if(!(ee(s.value.H[0].type,54)||ee(s.value.H[0].type,47)||ee(s.value.H[0].type,56)||ee(s.value.H[0].type,58)||ee(s.value.H[0].type,57)))throw or();if(null===(i=Ge(e.h,s.value.H[0].value,null)))throw Error("XUDY0009: The target "+s.value.H[0].value.outerHTML+" for replacing a node must have a parent.");if(a=s.value.H[0],s=s.value.fa,ee(a.type,47)){if(r.Va.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");r.attributes.reduce((function(e,t){var n=t.node.prefix||"";t=t.node.namespaceURI;var r=i.node.lookupNamespaceURI(n);if(r&&r!==t)throw ur(t);if((r=e[n])&&t!==r)throw cr(t);return e[n]=t,e}),{})}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 W({H:[],fa:vr([Qa(a.value,[].concat(r.attributes,r.Va))],o,s)})}}}(t,n,e)},y(ls,wr),ls.prototype.h=function(e,t){return xr(e=this.u(e,t),(function(){}))},ls.prototype.u=function(e,t){var n,r,o,i=this,a=t.h,s=t.s,u=t.j,c=[],l=[],h=[];return{next:function(){if(l.length!==i.j.length)for(var f={},d=l.length;d<i.j.length;f={ib:f.ib},d++){var m=i.j[d],g=c[d];if(g||(c[d]=g=Ar(m.gb)(e,t)),1!==(g=g.next(0)).value.H.length||!ee(g.value.H[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");f.ib=Xe(Jr(g.value.H[0].value,t)),l.push(f.ib.value),h.push(g.value.fa),e=Bt(e,((g={})[m.Gc]=function(e){return function(){return ge.o(e.ib)}}(f),g))}return o||(n||(n=Ar(i.J)(e,t)),o=n.next(0).value.fa),o.forEach((function(e){if(e.target&&!cs(e.target,l,a))throw Error("XUDY0014: The target "+e.target.node.outerHTML+" must be a node created by the copy clause.");if("put"===e.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.")})),f=o.map((function(e){return us(e=e.h(t))})),yr(f,a,s,u),r||(r=Ar(i.B)(e,t)),W({H:(f=r.next(0)).value.H,fa:vr.apply(null,[f.value.fa].concat(p(h)))})}}},ls.prototype.P=function(e){To(e),this.j.forEach((function(t){return t.Gc=So(e,t.Pb.namespaceURI,t.Pb.localName)})),wr.prototype.P.call(this,e),Ro(e),this.I=this.j.some((function(e){return e.gb.I}))||this.B.I},y(hs,pr),hs.prototype.h=function(e,t){var n,r,o,i=this,a=!1;return ge.create({next:function(){if(a)return K;if(!r){if(i.u){if(!n){var s=i.u.h(e,t);n=is(i.B,t,s)}r=n.next(0).value.value}else r=i.name;if(r){if("xmlns"===r.prefix)throw mo(r);if(""===r.prefix&&"xmlns"===r.localName)throw mo(r);if("http://www.w3.org/2000/xmlns/"===r.namespaceURI)throw mo(r);if("xml"===r.prefix&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI)throw mo(r);if(""!==r.prefix&&"xml"!==r.prefix&&"http://www.w3.org/XML/1998/namespace"===r.namespaceURI)throw mo(r)}}return i.j.vb?(s=i.j.vb,o||(o=It(s.map((function(n){return Ut(n.h(e,t),t).L((function(e){return ge.o(V(e.map((function(e){return e.value})).join(" "),1))}))}))).L((function(e){return ge.o(Xe(ps(r,e.map((function(e){return e.value})).join(""))))})).value),o.next(0)):(a=!0,W(Xe(ps(r,i.j.value))))}})},hs.prototype.P=function(e){if(this.B=Bo(e),this.name&&this.name.prefix&&!this.name.namespaceURI){var t=e.ba(this.name.prefix);if(void 0===t&&this.name.prefix)throw Rt(this.name.prefix);this.name.namespaceURI=t||null}pr.prototype.P.call(this,e)},y(fs,pr),fs.prototype.h=function(e,t){var n={data:"",Sa:!0,nodeType:8},r={node:n,F:null};return this.j?Ut(e=hr(this.j,e,t),t).L((function(e){if(e=e.map((function(e){return Kt(e,1).value})).join(" "),-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');return n.data=e,ge.o(Xe(r))})):ge.o(Xe(r))},y(ds,pr),ds.prototype.h=function(e,t){var n,r,o,i,a,s=this,u=!1,c=!1,l=!1;return ge.create({next:function(){if(l)return K;if(u||(n||(n=It(s.J.map((function(n){return hr(n,e,t)})))),r=n.N(),u=!0),!c){o||(o=s.ka.map((function(n){return hr(n,e,t)})));for(var p=[],h=0;h<o.length;h++){var f=o[h].N();p.push(f)}i=p,c=!0}if(s.u&&(a||(p=s.u.h(e,t),a=is(s.B,t,p)),p=a.next(0),s.j=p.value.value),"xmlns"===s.j.prefix||"http://www.w3.org/2000/xmlns/"===s.j.namespaceURI||"xml"===s.j.prefix&&"http://www.w3.org/XML/1998/namespace"!==s.j.namespaceURI||s.j.prefix&&"xml"!==s.j.prefix&&"http://www.w3.org/XML/1998/namespace"===s.j.namespaceURI)throw Error('XQDY0096: The node name "'+s.j.ya()+'" is invalid for a computed element constructor.');var d={nodeType:1,Sa:!0,attributes:[],childNodes:[],nodeName:s.j.ya(),namespaceURI:s.j.namespaceURI,prefix:s.j.prefix,localName:s.j.localName};for(p={node:d,F:null},r.forEach((function(e){d.attributes.push(e.value.node)})),(h=Ka(i,t,fo)).attributes.forEach((function(e){if(d.attributes.find((function(t){return t.namespaceURI===e.namespaceURI&&t.localName===e.localName})))throw Error("XQDY0025: The attribute "+e.name+" does not have an unique name in the constructed element.");d.attributes.push(e)})),h.Va.forEach((function(e){d.childNodes.push(e)})),h=0;h<d.childNodes.length;h++)if(Ie(f=d.childNodes[h])&&3===f.nodeType){var m=d.childNodes[h-1];m&&Ie(m)&&3===m.nodeType&&(m.data+=f.data,d.childNodes.splice(h,1),h--)}return l=!0,W(Xe(p))}})},ds.prototype.P=function(e){var t=this;if(To(e),Object.keys(this.T).forEach((function(n){return Co(e,n,t.T[n])})),this.ha.forEach((function(t){return t.P(e)})),this.J.reduce((function(t,n){if(n.name){if(n="Q{"+(null===n.name.namespaceURI?e.ba(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.j&&null===this.j.namespaceURI){var n=e.ba(this.j.prefix);if(void 0===n&&this.j.prefix)throw Rt(this.j.prefix);this.j.namespaceURI=n}this.B=Bo(e),Ro(e)},y(ys,pr),ys.prototype.h=function(e,t){var n=this;return Ut(hr(this.u,e,t),t).L((function(r){var o=r.map((function(e){return Kt(e,1).value})).join(" ");if(-1!==o.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==n.j.Lb)return ms(r=n.j.Lb),ge.o(Xe(gs(r,o)));r=hr(n.j.Eb,e,t);var i=os(t,r);return ge.create({next:function(){var e=i.next(0);return e.done?e:(ms(e=e.value.value),W(Xe(gs(e,o))))}})}))},y(vs,pr),vs.prototype.h=function(e,t){return this.j?Ut(e=hr(this.j,e,t),t).L((function(e){return 0===e.length?ge.empty():(e={node:{data:e.map((function(e){return Kt(e,1).value})).join(" "),Sa:!0,nodeType:3},F:null},ge.o(Xe(e)))})):ge.empty()},y(ws,br),ws.prototype.B=function(e,t,n){var r=this;return n[0](e).L((function(o){for(var i=0;i<r.j;i++)if(r.T[i].some((function(n){switch(n.Ec){case"?":if(1<o.length)return!1;break;case"*":break;case"+":if(1>o.length)return!1;break;default:if(1!==o.length)return!1}var r=ge.create(o);return o.every((function(o,i){return o=Nt(e,i,o,r),hr(n.Mb,o,t).getEffectiveBooleanValue()}))})))return n[i+1](e);return n[r.j+1](e)}))},ws.prototype.P=function(e){if(br.prototype.P.call(this,e),this.J.I)throw er()};var As={aa:!1,sa:!1},xs={aa:!0,sa:!1},bs={aa:!0,sa:!0};function Es(e){return e.aa?e.sa?bs:xs:As}function Ns(e,t){switch(e[0]){case"andOp":var n=Mo(e,"type");return new Yi(Ts("andOp",e,Es(t)),n);case"orOp":return n=Mo(e,"type"),new Qi(Ts("orOp",e,Es(t)),n);case"unaryPlusOp":return n=Do(Do(e,"operand"),"*"),e=Mo(e,"type"),new Vi("+",Ns(n,t),e);case"unaryMinusOp":return n=Do(Do(e,"operand"),"*"),e=Mo(e,"type"),new Vi("-",Ns(n,t),e);case"addOp":case"subtractOp":case"multiplyOp":case"divOp":case"idivOp":case"modOp":var r=e[0],o=Ns(ko(e,["firstOperand","*"]),Es(t));t=Ns(ko(e,["secondOperand","*"]),Es(t));var i=Mo(e,"type"),a=Mo(ko(e,["firstOperand","*"]),"type"),s=Mo(ko(e,["secondOperand","*"]),"type");return a&&s&&Mo(e,"type")&&(n=Yo(r,a.type,s.type)),new zo(r,o,t,i,n);case"sequenceExpr":return function(e,t){var n=Fo(e,"*").map((function(e){return Ns(e,t)}));return 1===n.length?n[0]:(n=Mo(e,"type"),new sa(Fo(e,"*").map((function(e){return Ns(e,t)})),n))}(e,t);case"unionOp":return n=Mo(e,"type"),new ga([Ns(ko(e,["firstOperand","*"]),Es(t)),Ns(ko(e,["secondOperand","*"]),Es(t))],n);case"exceptOp":case"intersectOp":return n=Mo(e,"type"),new aa(e[0],Ns(ko(e,["firstOperand","*"]),Es(t)),Ns(ko(e,["secondOperand","*"]),Es(t)),n);case"stringConcatenateOp":return function(e,t){var n=Mo(e,"type");return new Rr(new Li({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},(e=[ko(e,["firstOperand","*"]),ko(e,["secondOperand","*"])]).length,n),e.map((function(e){return Ns(e,Es(t))})),n)}(e,t);case"rangeSequenceExpr":return function(e,t){var n=Mo(e,"type");return new Rr(new Li({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},(e=[Do(Do(e,"startExpr"),"*"),Do(Do(e,"endExpr"),"*")]).length,n),e.map((function(e){return Ns(e,Es(t))})),n)}(e,t);case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":return Cs("generalCompare",e,t);case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":return Cs("valueCompare",e,t);case"isOp":case"nodeBeforeOp":case"nodeAfterOp":return Cs("nodeCompare",e,t);case"pathExpr":return function(e,t){var n=Mo(e,"type"),r=Fo(e,"stepExpr"),o=!1,i=r.map((function(e){for(var r=Do(e,"xpathAxis"),i=Fo(e,"*"),a=[],s=null,u=(i=c(i)).next();!u.done;u=i.next())switch(u=u.value,u[0]){case"lookup":a.push(["lookup",Is(u,t)]);break;case"predicate":case"predicates":for(var l=(u=c(Fo(u,"*"))).next();!l.done;l=u.next())s=yi(s,(l=Ns(l.value,Es(t))).A()),a.push(["predicate",l])}if(r)switch(o=!0,e=Do(e,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),e=Bs(e),Uo(r)){case"ancestor":var p=new mi(e,{Qa:!1});break;case"ancestor-or-self":p=new mi(e,{Qa:!0});break;case"attribute":p=new vi(e,s);break;case"child":p=new wi(e,s);break;case"descendant":p=new xi(e,{Qa:!1});break;case"descendant-or-self":p=new xi(e,{Qa:!0});break;case"parent":p=new Ti(e,s);break;case"following-sibling":p=new Bi(e,s);break;case"preceding-sibling":p=new Ci(e,s);break;case"following":p=new Ni(e);break;case"preceding":p=new Ii(e);break;case"self":p=new Si(e,s)}else p=Ns(p=ko(e,["filterExpr","*"]),Es(t));for(r=(a=c(a)).next();!r.done;r=a.next())switch(r=r.value,r[0]){case"lookup":p=new Ba(p,r[1]);break;case"predicate":p=new ba(p,r[1])}return p.type=n,p}));return e=Do(e,"rootExpr"),!(r=o||null!==e||1<r.length)&&1===i.length||!e&&1===i.length&&"sorted"===i[0].O?i[0]:e&&0===i.length?new wa(null):(i=new xa(i,r),e?new wa(i):i)}(e,t);case"contextItemExpr":return new Aa(Mo(e,"type"));case"functionCallExpr":return function(e,t){var n=Do(e,"functionName"),r=Fo(Do(e,"arguments"),"*");return e=Mo(e,"type"),new Rr(new Li(Go(n),r.length,e),r.map((function(e){return"argumentPlaceholder"===e[0]?null:Ns(e,t)})),e)}(e,t);case"inlineFunctionExpr":return function(e,t){var n=Fo(Do(e,"paramList"),"*"),r=ko(e,["functionBody","*"]),o=Mo(e,"type");return new Hi(n.map((function(e){return{name:Go(Do(e,"varName")),type:Po(e)}})),Po(e),r?Ns(r,t):new sa([],o))}(e,t);case"arrowExpr":return function(e,t){var n=Mo(e,"type"),r=ko(e,["argExpr","*"]);e=Fo(e,"*").slice(1),r=[Ns(r,t)];for(var o=0;o<e.length;o++)if("arguments"!==e[o][0]){if("arguments"===e[o+1][0]){var i=Fo(e[o+1],"*");r=r.concat(i.map((function(e){return"argumentPlaceholder"===e[0]?null:Ns(e,t)})))}r=[new Rr(i="EQName"===e[o][0]?new Li(Go(e[o]),r.length,n):Ns(e[o],Es(t)),r,n)]}return r[0]}(e,t);case"dynamicFunctionInvocationExpr":return function(e,t){var n=ko(e,["functionItem","*"]),r=Mo(e,"type");e=Do(e,"arguments");var o=[];return e&&(o=Fo(e,"*").map((function(e){return"argumentPlaceholder"===e[0]?null:Ns(e,t)}))),new Rr(Ns(n,t),o,r)}(e,t);case"namedFunctionRef":return t=Do(e,"functionName"),n=Mo(e,"type"),e=Uo(ko(e,["integerConstantExpr","value"])),new Li(Go(t),parseInt(e,10),n);case"integerConstantExpr":return new ji(Uo(Do(e,"value")),{type:5,g:3});case"stringConstantExpr":return new ji(Uo(Do(e,"value")),{type:1,g:3});case"decimalConstantExpr":return new ji(Uo(Do(e,"value")),{type:4,g:3});case"doubleConstantExpr":return new ji(Uo(Do(e,"value")),{type:3,g:3});case"varRef":return new Ua((e=Go(Do(e,"name"))).prefix,e.namespaceURI,e.localName);case"flworExpr":return function(e,t){var n=Fo(e,"*");if(e=Do(n[n.length-1],"*"),1<(n=n.slice(0,-1)).length&&!t.aa)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return n.reduceRight((function(e,n){switch(n[0]){case"forClause":for(var r=(n=Fo(n,"*")).length-1;0<=r;--r){var o=n[r],i=ko(o,["forExpr","*"]),a=Do(o,"positionalVariableBinding");e=new Pi(Go(ko(o,["typedVariableBinding","varName"])),Ns(i,Es(t)),a?Go(a):null,e)}return e;case"letClause":for(r=(n=Fo(n,"*")).length-1;0<=r;--r)i=ko(o=n[r],["letExpr","*"]),e=new _i(Go(ko(o,["typedVariableBinding","varName"])),Ns(i,Es(t)),e);return e;case"whereClause":for(r=(n=Fo(n,"*")).length-1;0<=r;--r)e=new Ma(Ns(n[r],t),e);return e;case"windowClause":case"groupByClause":case"countClause":throw Error("Not implemented: "+n[0]+" is not implemented yet.");case"orderByClause":return function(e,t,n){return new va((e=Fo(e,"*")).filter((function(e){return"stable"!==e[0]})).map((function(e){var n=Do(e,"orderModifier"),r=n?Do(n,"orderingKind"):null;return n=n?Do(n,"emptyOrderingMode"):null,r=!r||"ascending"===Uo(r),n=!n||"empty least"===Uo(n),{da:Ns(ko(e,["orderByExpr","*"]),t),Ib:r,Bc:n}})),n)}(n,t,e);default:throw Error("Not implemented: "+n[0]+" is not supported in a flwor expression")}}),Ns(e,t))}(e,t);case"quantifiedExpr":return function(e,t){var n=Mo(e,"type"),r=Uo(Do(e,"quantifier")),o=ko(e,["predicateExpr","*"]);return e=Fo(e,"quantifiedExprInClause").map((function(e){return{name:Go(ko(e,["typedVariableBinding","varName"])),gb:Ns(e=ko(e,["sourceExpr","*"]),Es(t))}})),new Ia(r,e,Ns(o,Es(t)),n)}(e,t);case"ifThenElseExpr":return n=Mo(e,"type"),new Oi(Ns(Do(Do(e,"ifClause"),"*"),Es(t)),Ns(Do(Do(e,"thenClause"),"*"),t),Ns(Do(Do(e,"elseClause"),"*"),t),n);case"instanceOfExpr":return n=Ns(ko(e,["argExpr","*"]),t),r=ko(e,["sequenceType","*"]),o=ko(e,["sequenceType","occurrenceIndicator"]),e=Mo(e,"type"),new ha(n,Ns(r,Es(t)),o?Uo(o):"",e);case"castExpr":return t=Ns(Do(Do(e,"argExpr"),"*"),Es(t)),n=Do(e,"singleType"),new la(t,e=Go(Do(n,"atomicType")),n=null!==Do(n,"optional"));case"castableExpr":return t=Ns(Do(Do(e,"argExpr"),"*"),Es(t)),n=Do(e,"singleType"),new ca(t,e=Go(Do(n,"atomicType")),n=null!==Do(n,"optional"));case"simpleMapExpr":return function(e,t){var n=Mo(e,"type");return Fo(e,"*").reduce((function(e,r){return null===e?Ns(r,Es(t)):new ua(e,Ns(r,Es(t)),n)}),null)}(e,t);case"mapConstructor":return function(e,t){var n=Mo(e,"type");return new Xi(Fo(e,"mapConstructorEntry").map((function(e){return{key:Ns(ko(e,["mapKeyExpr","*"]),Es(t)),value:Ns(ko(e,["mapValueExpr","*"]),Es(t))}})),n)}(e,t);case"arrayConstructor":return function(e,t){var n=Mo(e,"type"),r=Fo(e=Do(e,"*"),"arrayElem").map((function(e){return Ns(Do(e,"*"),Es(t))}));switch(e[0]){case"curlyArray":return new hi(r,n);case"squareArray":return new fi(r,n);default:throw Error("Unrecognized arrayType: "+e[0])}}(e,t);case"unaryLookup":return n=Mo(e,"type"),new Ta(Is(e,t),n);case"typeswitchExpr":return function(e,t){if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");var n=Mo(e,"type"),r=Ns(Do(Do(e,"argExpr"),"*"),t),o=Fo(e,"typeswitchExprCaseClause").map((function(e){var n=0===Fo(e,"sequenceTypeUnion").length?[Do(e,"sequenceType")]:Fo(Do(e,"sequenceTypeUnion"),"sequenceType");return{zc:Ns(ko(e,["resultExpr","*"]),t),Nb:n.map((function(e){var n=Do(e,"occurrenceIndicator");return{Ec:n?Uo(n):"",Mb:Ns(Do(e,"*"),t)}}))}}));return e=Ns(ko(e,["typeswitchExprDefaultClause","resultExpr","*"]),t),new ws(r,o,e,n)}(e,t);case"elementConstructor":return function(e,t){if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");var n=Go(Do(e,"tagName")),r=Do(e,"attributeList"),o=r?Fo(r,"attributeConstructor").map((function(e){return Ns(e,Es(t))})):[];return r=r?Fo(r,"namespaceDeclaration").map((function(e){var t=Do(e,"prefix");return{prefix:t?Uo(t):"",uri:Uo(Do(e,"uri"))}})):[],e=(e=Do(e,"elementContent"))?Fo(e,"*").map((function(e){return Ns(e,Es(t))})):[],new ds(n,o,r,e)}(e,t);case"attributeConstructor":return function(e,t){if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");var n=Go(Do(e,"attributeName")),r=Do(e,"attributeValue");return r=r?Uo(r):null,e=(e=Do(e,"attributeValueExpr"))?Fo(e,"*").map((function(e){return Ns(e,Es(t))})):null,new hs(n,{value:r,vb:e})}(e,t);case"computedAttributeConstructor":return(n=Do(e,"tagName"))?n=Go(n):(n=Do(e,"tagNameExpr"),n={Ma:Ns(Do(n,"*"),Es(t))}),new hs(n,{vb:[e=Ns(Do(Do(e,"valueExpr"),"*"),Es(t))]});case"computedCommentConstructor":if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return new fs(e=(e=Do(e,"argExpr"))?Ns(Do(e,"*"),Es(t)):null);case"computedTextConstructor":if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return new vs(e=(e=Do(e,"argExpr"))?Ns(Do(e,"*"),Es(t)):null);case"computedElementConstructor":return function(e,t){var n=Do(e,"tagName");return n?n=Go(n):(n=Do(e,"tagNameExpr"),n={Ma:Ns(Do(n,"*"),Es(t))}),e=(e=Do(e,"contentExpr"))?Fo(e,"*").map((function(e){return Ns(e,Es(t))})):[],new ds(n,[],[],e)}(e,t);case"computedPIConstructor":if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return n=Do(e,"piTargetExpr"),r=Do(e,"piTarget"),o=Do(e,"piValueExpr"),e=Mo(e,"type"),new ys({Eb:n?Ns(Do(n,"*"),Es(t)):null,Lb:r?Uo(r):null},o?Ns(Do(o,"*"),Es(t)):new sa([],e));case"CDataSection":return new ji(Uo(e),{type:1,g:3});case"deleteExpr":return new Ja(e=Ns(ko(e,["targetExpr","*"]),t));case"insertExpr":switch(n=Ns(ko(e,["sourceExpr","*"]),t),(o=Fo(e,"*")[1])[0]){case"insertAfter":r=1;break;case"insertBefore":r=2;break;case"insertInto":r=(r=Do(o,"*"))?"insertAsFirst"===r[0]?4:5:3}return new Za(n,r,e=Ns(ko(e,["targetExpr","*"]),t));case"renameExpr":return new as(n=Ns(ko(e,["targetExpr","*"]),t),e=Ns(ko(e,["newNameExpr","*"]),t));case"replaceExpr":return new ss(n=!!Do(e,"replaceValue"),r=Ns(ko(e,["targetExpr","*"]),t),e=Ns(ko(e,["replacementExpr","*"]),t));case"transformExpr":return function(e,t){var n=Fo(Do(e,"transformCopies"),"transformCopy").map((function(e){var n=Go(Do(Do(e,"varRef"),"name"));return{gb:Ns(Do(Do(e,"copySource"),"*"),t),Pb:new ve(n.prefix,n.namespaceURI,n.localName)}})),r=Ns(Do(Do(e,"modifyExpr"),"*"),t);return e=Ns(Do(Do(e,"returnExpr"),"*"),t),new ls(n,r,e)}(e,t);case"x:stackTrace":for(n=e[1],e=e[2];"x:stackTrace"===e[0];)e=e[2];return new Mi(n,e[0],Ns(e,t));default:return Bs(e)}}function Bs(e){switch(e[0]){case"nameTest":return new Oa(Go(e));case"piTest":return(e=Do(e,"piTarget"))?new Ra(Uo(e)):new Sa(7);case"commentTest":return new Sa(8);case"textTest":return new Sa(3);case"documentTest":return new Sa(9);case"attributeTest":var t=(e=Do(e,"attributeName"))&&Do(e,"star");return!e||t?new Sa(2):new Oa(Go(Do(e,"QName")),{kind:2});case"elementTest":return t=(e=Do(e,"elementName"))&&Do(e,"star"),!e||t?new Sa(1):new Oa(Go(Do(e,"QName")),{kind:1});case"anyKindTest":return new Da({prefix:"",namespaceURI:null,localName:"node()"});case"anyMapTest":return new Da({prefix:"",namespaceURI:null,localName:"map(*)"});case"anyArrayTest":return new Da({prefix:"",namespaceURI:null,localName:"array(*)"});case"Wildcard":return Do(e,"star")?(t=Do(e,"uri"))?e=new Oa({localName:"*",namespaceURI:Uo(t),prefix:""}):(t=Do(e,"NCName"),e="star"===Do(e,"*")[0]?new Oa({localName:Uo(t),namespaceURI:null,prefix:"*"}):new Oa({localName:"*",namespaceURI:null,prefix:Uo(t)})):e=new Oa({localName:"*",namespaceURI:null,prefix:"*"}),e;case"atomicType":return new Da(Go(e));case"anyItemType":return new Da({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+e[0]+".")}}function Ts(e,t,n){var r=[];return function t(o){var i=Do(Do(o,"firstOperand"),"*");o=Do(Do(o,"secondOperand"),"*"),i[0]===e?t(i):r.push(Ns(i,n)),o[0]===e?t(o):r.push(Ns(o,n))}(t),r}function Is(e,t){switch((e=Do(e,"*"))[0]){case"NCName":return new ji(Uo(e),{type:1,g:3});case"star":return"*";default:return Ns(e,Es(t))}}function Cs(e,t,n){var r=ko(t,["firstOperand","*"]),o=ko(t,["secondOperand","*"]);switch(r=Ns(r,Es(n)),n=Ns(o,Es(n)),e){case"valueCompare":return new Zi(t[0],r,n);case"nodeCompare":return new oa(t[0],r,n);case"generalCompare":return new na(t[0],r,n)}}function Ss(e,t){return Ns(e,t)}var Os=new Map;function Rs(e,t,n,r,o,i){this.j=e,this.u=t,this.h=n,this.A=r,this.s=o,this.O=i}function Ds(e,t,n,r,o,i,a){var s=Os.get(e);s||(s=Object.create(null),Os.set(e,s)),(t=s[e=t+(i?"_DEBUG":"")])||(t=s[e]=[]),t.push(new Rs(Object.values(n.h),Object.values(n.s),o,Object.keys(r).map((function(e){return{namespaceURI:r[e],prefix:e}})),a,n.j))}function Us(e){var t=new Ee;if("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"!==e.namespaceURI)throw St("The XML structure passed as an XQueryX program was not valid XQueryX");var n=["stackTrace"===e.localName?"x:stackTrace":e.localName],r=t.getAllAttributes(e);for(r&&0<r.length&&n.push(Array.from(r).reduce((function(t,n){return"start"===n.localName||"end"===n.localName&&"stackTrace"===e.localName?t[n.localName]=JSON.parse(n.value):"type"===n.localName?t[n.localName]=ce(n.value):t[n.localName]=n.value,t}),{})),r=(t=c(t=t.getChildNodes(e))).next();!r.done;r=t.next())switch(r=r.value,r.nodeType){case 1:n.push(Us(r));break;case 3:n.push(r.data)}return n}var Ms=Object.create(null);function ks(e,t){var n=Ms[e];n||(n=Ms[e]={Oa:[],Wa:[]}),n.Oa=n.Oa.concat(t.Oa),n.Wa=n.Wa.concat(t.Wa)}function Fs(e,t){var n=Ms[t];if(!n)throw Error("XQST0051: No modules found with the namespace uri "+t);n.Oa.forEach((function(n){return Io(e,t,n.localName,n.arity,n.Gb)})),n.Wa.forEach((function(n){So(e,t,n.localName),Oo(e,t,n.localName,(function(e,t){return hr(n.da,e,t)}))}))}function Gs(e){return e.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))}var Ps=t;function Hs(e,t){return function(n,r){return t.has(r)?t.get(r):(n=e(n,r),t.set(r,n),n)}}function _s(e,t){return Ps.delimited(t,e,t)}function js(e,t){return e.reverse().reduce((function(e,t){return Ps.preceded(t,e)}),t)}function Xs(e,t,n,r){return Ps.then(Ps.then(e,t,(function(e,t){return[e,t]})),n,(function(e,t){var n=c(e);return e=n.next().value,n=n.next().value,r(e,n,t)}))}function Ls(e,t,n,r,o){return Ps.then(Ps.then(Ps.then(e,t,(function(e,t){return[e,t]})),n,(function(e,t){var n=c(e);return[e=n.next().value,n=n.next().value,t]})),r,(function(e,t){var n=c(e);e=n.next().value;var r=n.next().value;return n=n.next().value,o(e,r,n,t)}))}function $s(e){return Ps.map(e,(function(e){return[e]}))}function qs(e,t){return Ps.map(Ps.or(e),(function(){return t}))}function Vs(e){return function(t,n){return(t=e.exec(t.substring(n)))&&0===t.index?Ps.okWithValue(n+t[0].length,t[0]):Ps.error(n,[e.source],!1)}}var Ys=Ps.or([Ps.token(" "),Ps.token("\t"),Ps.token("\r"),Ps.token("\n")]),Qs=Ps.token("(:"),Js=Ps.token(":)"),zs=Ps.token("(#"),Ks=Ps.token("#)"),Ws=Ps.token("("),Zs=Ps.token(")"),eu=Ps.token("["),tu=Ps.token("]"),nu=Ps.token("{"),ru=Ps.token("}"),ou=Ps.token("{{"),iu=Ps.token("}}"),au=Ps.token("'"),su=Ps.token("''"),uu=Ps.token('"'),cu=Ps.token('""'),lu=Ps.token("<![CDATA["),pu=Ps.token("]]>"),hu=Ps.token("/>"),fu=Ps.token("</"),du=Ps.token("\x3c!--"),mu=Ps.token("--\x3e"),gu=Ps.token("<?"),yu=Ps.token("?>"),vu=Ps.token("&#x"),wu=Ps.token("&#"),Au=Ps.token(":*"),xu=Ps.token("*:"),bu=Ps.token(":="),Eu=Ps.token("&"),Nu=Ps.token(":"),Bu=Ps.token(";"),Tu=Ps.token("*"),Iu=Ps.token("@"),Cu=Ps.token("$"),Su=Ps.token("#"),Ou=Ps.token("%"),Ru=Ps.token("?"),Du=Ps.token("!"),Uu=Ps.token("|"),Mu=Ps.token("||"),ku=Ps.token("="),Fu=Ps.token("!="),Gu=Ps.token("<"),Pu=Ps.token("<<"),Hu=Ps.token("<="),_u=Ps.token(">"),ju=Ps.token(">>"),Xu=Ps.token(">="),Lu=Ps.token(","),$u=Ps.token("."),qu=Ps.token(".."),Vu=Ps.token("+"),Yu=Ps.token("-"),Qu=Ps.token("/"),Ju=Ps.token("//"),zu=Ps.token("=>"),Ku=Ps.token("e"),Wu=Ps.token("E"),Zu=Ps.token("l"),ec=Ps.token("L"),tc=Ps.token("m"),nc=Ps.token("M"),rc=Ps.token("Q"),oc=Ps.token("x"),ic=Ps.token("X"),ac=Ps.token("as"),sc=Ps.token("cast"),uc=Ps.token("castable"),cc=Ps.token("treat"),lc=Ps.token("instance"),pc=Ps.token("of"),hc=Ps.token("node"),fc=Ps.token("nodes"),dc=Ps.token("delete"),mc=Ps.token("value"),gc=Ps.token("function"),yc=Ps.token("map"),vc=Ps.token("element"),wc=Ps.token("attribute"),Ac=Ps.token("schema-element"),xc=Ps.token("intersect"),bc=Ps.token("except"),Ec=Ps.token("union"),Nc=Ps.token("to"),Bc=Ps.token("is"),Tc=Ps.token("or"),Ic=Ps.token("and"),Cc=Ps.token("div"),Sc=Ps.token("idiv"),Oc=Ps.token("mod"),Rc=Ps.token("eq"),Dc=Ps.token("ne"),Uc=Ps.token("lt"),Mc=Ps.token("le"),kc=Ps.token("gt"),Fc=Ps.token("ge"),Gc=Ps.token("amp"),Pc=Ps.token("quot"),Hc=Ps.token("apos"),_c=Ps.token("if"),jc=Ps.token("then"),Xc=Ps.token("else"),Lc=Ps.token("allowing"),$c=Ps.token("empty"),qc=Ps.token("at"),Vc=Ps.token("in"),Yc=Ps.token("for"),Qc=Ps.token("let"),Jc=Ps.token("where"),zc=Ps.token("collation"),Kc=Ps.token("group"),Wc=Ps.token("by"),Zc=Ps.token("order"),el=Ps.token("stable"),tl=Ps.token("return"),nl=Ps.token("array"),rl=Ps.token("document"),ol=Ps.token("namespace"),il=Ps.token("text"),al=Ps.token("comment"),sl=Ps.token("processing-instruction"),ul=Ps.token("lax"),cl=Ps.token("strict"),ll=Ps.token("validate"),pl=Ps.token("type"),hl=Ps.token("declare"),fl=Ps.token("default"),dl=Ps.token("boundary-space"),ml=Ps.token("strip"),gl=Ps.token("preserve"),yl=Ps.token("no-preserve"),vl=Ps.token("inherit"),wl=Ps.token("no-inherit"),Al=Ps.token("greatest"),xl=Ps.token("least"),bl=Ps.token("copy-namespaces"),El=Ps.token("decimal-format"),Nl=Ps.token("case"),Bl=Ps.token("typeswitch"),Tl=Ps.token("some"),Il=Ps.token("every"),Cl=Ps.token("satisfies"),Sl=Ps.token("replace"),Ol=Ps.token("with"),Rl=Ps.token("copy"),Dl=Ps.token("modify"),Ul=Ps.token("first"),Ml=Ps.token("last"),kl=Ps.token("before"),Fl=Ps.token("after"),Gl=Ps.token("into"),Pl=Ps.token("insert"),Hl=Ps.token("rename"),_l=Ps.token("switch"),jl=Ps.token("variable"),Xl=Ps.token("external"),Ll=Ps.token("updating"),$l=Ps.token("import"),ql=Ps.token("schema"),Vl=Ps.token("module"),Yl=Ps.token("base-uri"),Ql=Ps.token("construction"),Jl=Ps.token("ordering"),zl=Ps.token("ordered"),Kl=Ps.token("unordered"),Wl=Ps.token("option"),Zl=Ps.token("context"),ep=Ps.token("item"),tp=Ps.token("xquery"),np=Ps.token("version"),rp=Ps.token("encoding"),op=Ps.token("document-node"),ip=Ps.token("namespace-node"),ap=Ps.token("schema-attribute"),sp=Ps.token("ascending"),up=Ps.token("descending"),cp=Ps.token("empty-sequence"),lp=Ps.token("child::"),pp=Ps.token("descendant::"),hp=Ps.token("attribute::"),fp=Ps.token("self::"),dp=Ps.token("descendant-or-self::"),mp=Ps.token("following-sibling::"),gp=Ps.token("following::"),yp=Ps.token("parent::"),vp=Ps.token("ancestor::"),wp=Ps.token("preceding-sibling::"),Ap=Ps.token("preceding::"),xp=Ps.token("ancestor-or-self::"),bp=Ps.token("decimal-separator"),Ep=Ps.token("grouping-separator"),Np=Ps.token("infinity"),Bp=Ps.token("minus-sign"),Tp=Ps.token("NaN"),Ip=Ps.token("per-mille"),Cp=Ps.token("zero-digit"),Sp=Ps.token("digit"),Op=Ps.token("pattern-separator"),Rp=Ps.token("exponent-separator"),Dp=Ps.token("schema-attribute("),Up=Ps.token("document-node("),Mp=Ps.token("processing-instruction("),kp=Ps.token("processing-instruction()"),Fp=Ps.token("comment()"),Gp=Ps.token("text()"),Pp=Ps.token("namespace-node()"),Hp=Ps.token("node()"),_p=Ps.token("item()"),jp=Ps.token("empty-sequence()"),Xp=new Map,Lp=new Map,$p=Ps.or([Vs(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Vs(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),qp=Ps.preceded(Ps.peek(Ps.not(Ps.or([Qs,Js]),['comment contents cannot contain "(:" or ":)"'])),$p),Vp=Ps.map(Ps.delimited(Qs,Ps.star(Ps.or([qp,function(e,t){return Vp(e,t)}])),Js),(function(e){return e.join("")})),Yp=Ps.or([Ys,Vp]),Qp=Ps.map(Ps.plus(Ys),(function(e){return e.join("")})),Jp=Hs(Ps.map(Ps.star(Yp),(function(e){return e.join("")})),Xp),zp=Hs(Ps.map(Ps.plus(Yp),(function(e){return e.join("")})),Lp),Kp=Ps.or([Vs(/[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]/),Ps.then(Vs(/[\uD800-\uDB7F]/),Vs(/[\uDC00-\uDFFF]/),(function(e,t){return e+t}))]),Wp=Ps.or([Kp,Vs(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]),Zp=Ps.then(Kp,Ps.star(Wp),(function(e,t){return e+t.join("")})),eh=Ps.map(Zp,(function(e){return["prefix",e]})),th=Ps.or([Kp,Nu]),nh=Ps.or([Wp,Nu]),rh=Ps.then(th,Ps.star(nh),(function(e,t){return e+t.join("")})),oh=Ps.map(Zp,(function(e){var t={};return[(t.prefix="",t.URI=null,t),e]})),ih=Ps.then(Zp,Ps.preceded(Nu,Zp),(function(e,t){var n={};return[(n.prefix=e,n.URI=null,n),t]})),ah=Ps.or([ih,oh]),sh=Ps.followed(js([rc,Jp,nu],Ps.map(Ps.star(Vs(/[^{}]/)),(function(e){return e.join("").replace(/\s+/g," ").trim()}))),ru),uh=Ps.then(sh,Zp,(function(e,t){return[e,t]})),ch=Ps.or([Ps.map(uh,(function(e){var t={};return[(t.prefix=null,t.URI=e[0],t),e[1]]})),ah]),lh=Ps.or([Ps.map(ch,(function(e){return["QName"].concat(p(e))})),Ps.map(Tu,(function(){return["star"]}))]),ph=Ps.map(Ps.preceded(Cu,ch),(function(e){return["varRef",["name"].concat(p(e))]})),hh=Ps.peek(Ps.or([Ws,uu,au,Yp])),fh=Ps.map(Ps.or([lp,pp,hp,fp,dp,mp,gp]),(function(e){return e.substring(0,e.length-2)})),dh=Ps.map(Ps.or([yp,vp,wp,Ap,xp]),(function(e){return e.substring(0,e.length-2)})),mh=Xs(Eu,Ps.or([Uc,kc,Gc,Pc,Hc]),Bu,(function(e,t,n){return e+t+n})),gh=Ps.or([Xs(vu,Vs(/[0-9a-fA-F]+/),Bu,(function(e,t,n){return e+t+n})),Xs(wu,Vs(/[0-9]+/),Bu,(function(e,t,n){return e+t+n}))]),yh=qs([cu],'"'),vh=qs([su],"'"),wh=$s(qs([Fp],"commentTest")),Ah=$s(qs([Gp],"textTest")),xh=$s(qs([Pp],"namespaceTest")),bh=$s(qs([Hp],"anyKindTest")),Eh=Vs(/[0-9]+/),Nh=Ps.then(Ps.or([Ps.then($u,Eh,(function(e,t){return e+t})),Ps.then(Eh,Ps.optional(Ps.preceded($u,Vs(/[0-9]*/))),(function(e,t){return e+(null!==t?"."+t:"")}))]),Xs(Ps.or([Ku,Wu]),Ps.optional(Ps.or([Vu,Yu])),Eh,(function(e,t,n){return e+(t||"")+n})),(function(e,t){return["doubleConstantExpr",["value",e+t]]})),Bh=Ps.or([Ps.map(Ps.preceded($u,Eh),(function(e){return["decimalConstantExpr",["value","."+e]]})),Ps.then(Ps.followed(Eh,$u),Ps.optional(Eh),(function(e,t){return["decimalConstantExpr",["value",e+"."+(null!==t?t:"")]]}))]),Th=Ps.map(Eh,(function(e){return["integerConstantExpr",["value",e]]})),Ih=Ps.followed(Ps.or([Nh,Bh,Th]),Ps.peek(Ps.not(Vs(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),Ch=Ps.map(Ps.followed($u,Ps.peek(Ps.not($u,["context item should not be followed by another ."]))),(function(){return["contextItemExpr"]})),Sh=Ps.or([nl,wc,al,op,vc,cp,gc,_c,ep,yc,ip,hc,sl,ap,Ac,_l,il,Bl]),Oh=$s(qs([Ru],"argumentPlaceholder")),Rh=Ps.or([Ru,Tu,Vu]),Dh=Ps.preceded(Ps.peek(Ps.not(Vs(/[{}<&]/),["elementContentChar cannot be {, }, <, or &"])),$p),Uh=Ps.map(Ps.delimited(lu,Ps.star(Ps.preceded(Ps.peek(Ps.not(pu,['CDataSection content may not contain "]]>"'])),$p)),pu),(function(e){return["CDataSection",e.join("")]})),Mh=Ps.preceded(Ps.peek(Ps.not(Vs(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),$p),kh=Ps.preceded(Ps.peek(Ps.not(Vs(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),$p),Fh=Ps.map(Ps.star(Ps.or([Ps.preceded(Ps.peek(Ps.not(Yu,[])),$p),Ps.map(js([Yu,Ps.peek(Ps.not(Yu,[]))],$p),(function(e){return"-"+e}))])),(function(e){return e.join("")})),Gh=Ps.map(Ps.delimited(du,Fh,mu),(function(e){return["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",e]]]]})),Ph=Ps.preceded(Ps.peek(Ps.not(Xs(Ps.or([ic,oc]),Ps.or([nc,tc]),Ps.or([ec,Zu]),(function(){return[]})),[])),rh),Hh=Ps.map(Ps.star(Ps.preceded(Ps.peek(Ps.not(yu,[])),$p)),(function(e){return e.join("")})),_h=Ps.then(Ps.preceded(gu,Ph),Ps.followed(Ps.optional(Ps.preceded(Qp,Hh)),yu),(function(e,t){return["computedPIConstructor",["piTarget",e],["piValueExpr",["stringConstantExpr",["value",t]]]]})),jh=Ps.map(Ju,(function(){return["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]]})),Xh=Ps.or([ul,cl]),Lh=Ps.map(Ps.star(Ps.followed($p,Ps.peek(Ps.not(Ks,["Pragma contents should not contain '#)'"])))),(function(e){return e.join("")})),$h=Ps.map(Ps.followed(Ps.or([Rc,Dc,Uc,Mc,kc,Fc]),hh),(function(e){return e+"Op"})),qh=Ps.or([Ps.followed(qs([Bc],"isOp"),hh),qs([Pu],"nodeBeforeOp"),qs([ju],"nodeAfterOp")]),Vh=Ps.or([qs([ku],"equalOp"),qs([Fu],"notEqualOp"),qs([Hu],"lessThanOrEqualOp"),qs([Gu],"lessThanOp"),qs([Xu],"greaterThanOrEqualOp"),qs([_u],"greaterThanOp")]),Yh=Ps.map(Ll,(function(){return["annotation",["annotationName","updating"]]})),Qh=Ps.or([gl,yl]),Jh=Ps.or([vl,wl]),zh=Ps.or([bp,Ep,Np,Bp,Tp,Ou,Ip,Cp,Sp,Op,Rp]),Kh=Ps.map(js([hl,zp,dl,zp],Ps.or([gl,ml])),(function(e){return["boundarySpaceDecl",e]})),Wh=Ps.map(js([hl,zp,Ql,zp],Ps.or([gl,ml])),(function(e){return["constructionDecl",e]})),Zh=Ps.map(js([hl,zp,Jl,zp],Ps.or([zl,Kl])),(function(e){return["orderingModeDecl",e]})),ef=Ps.map(js([hl,zp,fl,zp,Zc,zp,$c,zp],Ps.or([Al,xl])),(function(e){return["emptyOrderDecl",e]})),tf=Ps.then(js([hl,zp,bl,zp],Qh),js([Jp,Lu,Jp],Jh),(function(e,t){return["copyNamespacesDecl",["preserveMode",e],["inheritMode",t]]}));function nf(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 rf(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 of(e){return e.replace(/(&[^;]+);/g,(function(e){if(/^&#x/.test(e))return rf(e=parseInt(e.slice(3,-1),16)),String.fromCodePoint(e);if(/^&#/.test(e))return rf(e=parseInt(e.slice(2,-1),10)),String.fromCodePoint(e);switch(e){case"<":return"<";case">":return">";case"&":return"&";case""":return String.fromCharCode(34);case"'":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: "'+e+'"')}))}function af(e,t,n){if(!e.length)return[];for(var r=[e[0]],o=1;o<e.length;++o){var i=r[r.length-1];"string"==typeof i&&"string"==typeof e[o]?r[r.length-1]=i+e[o]:r.push(e[o])}if("string"==typeof r[0]&&0===r.length)return[];if(r=r.reduce((function(e,t,o){if("string"!=typeof t)e.push(t);else if(n&&/^\s*$/.test(t)){var i=r[o+1];(i&&"CDataSection"===i[0]||(o=r[o-1])&&"CDataSection"===o[0])&&e.push(of(t))}else e.push(of(t));return e}),[]),!r.length)return r;if(1<r.length||t)for(e=0;e<r.length;e++)"string"==typeof r[e]&&(r[e]=["stringConstantExpr",["value",r[e]]]);return r}function sf(e){return e[0].prefix?e[0].prefix+":"+e[1]:e[1]}var uf=Ps.then(ch,Ps.optional(Ru),(function(e,t){return null!==t?["singleType",["atomicType"].concat(p(e)),["optional"]]:["singleType",["atomicType"].concat(p(e))]})),cf=Ps.map(ch,(function(e){return["atomicType"].concat(p(e))})),lf=new Map;function pf(e){function t(e,t){return t.reduce((function(e,t){return[t[0],["firstOperand",e],["secondOperand",t[1]]]}),e)}function n(e,t,n){return Ps.then(e,Ps.star(Ps.then(_s(t,Jp),e,(function(e,t){return[e,t]}))),n)}function r(e,t,n,r){return n=void 0===n?"firstOperand":n,r=void 0===r?"secondOperand":r,Ps.then(e,Ps.optional(Ps.then(_s(t,Jp),e,(function(e,t){return[e,t]}))),(function(e,t){return null===t?e:[t[0],[n,e],[r,t[1]]]}))}function o(t){return e.ub?function(e,n){if(!(e=t(e,n)).success)return e;var r=l.has(n)?l.get(n):{offset:n,line:-1,la:-1},o=l.has(e.offset)?l.get(e.offset):{offset:e.offset,line:-1,la:-1};return l.set(n,r),l.set(e.offset,o),Ps.okWithValue(e.offset,["x:stackTrace",{start:r,end:o},e.value])}:t}function i(e,t){return K(e,t)}function a(e,t){return He(e,t)}function s(e,t){return o(Ps.or([It,Ut,Xt,Ot,st,Ht,Mt,_t,kt,Gt,at]))(e,t)}function u(e,t){return n(s,Lu,(function(e,t){return 0===t.length?e:["sequenceExpr",e].concat(p(t.map((function(e){return e[1]}))))}))(e,t)}var l=new Map,h=Ps.preceded(eu,Ps.followed(_s(u,Jp),tu)),f=Ps.map(e.Xa?Ps.or([_s(Ps.star(Ps.or([mh,gh,yh,Vs(/[^"&]/)])),uu),_s(Ps.star(Ps.or([mh,gh,vh,Vs(/[^'&]/)])),au)]):Ps.or([_s(Ps.star(Ps.or([yh,Vs(/[^"]/)])),uu),_s(Ps.star(Ps.or([vh,Vs(/[^']/)])),au)]),(function(e){return e.join("")})),d=Ps.or([Ps.map(js([vc,Jp],Ps.delimited(Ps.followed(Ws,Jp),Ps.then(lh,js([Jp,Lu,Jp],ch),(function(e,t){return[["elementName",e],["typeName"].concat(p(t))]})),Ps.preceded(Jp,Zs))),(function(e){var t=c(e);return["elementTest",e=t.next().value,t=t.next().value]})),Ps.map(js([vc,Jp],Ps.delimited(Ws,lh,Zs)),(function(e){return["elementTest",["elementName",e]]})),Ps.map(js([vc,Jp],Ps.delimited(Ws,Jp,Zs)),(function(){return["elementTest"]}))]),m=Ps.or([Ps.map(ch,(function(e){return["QName"].concat(p(e))})),Ps.map(Tu,(function(){return["star"]}))]),g=Ps.or([Ps.map(js([wc,Jp],Ps.delimited(Ps.followed(Ws,Jp),Ps.then(m,js([Jp,Lu,Jp],ch),(function(e,t){return[["attributeName",e],["typeName"].concat(p(t))]})),Ps.preceded(Jp,Zs))),(function(e){var t=c(e);return["attributeTest",e=t.next().value,t=t.next().value]})),Ps.map(js([wc,Jp],Ps.delimited(Ws,m,Zs)),(function(e){return["attributeTest",["attributeName",e]]})),Ps.map(js([wc,Jp],Ps.delimited(Ws,Jp,Zs)),(function(){return["attributeTest"]}))]),y=Ps.map(js([Ac,Jp,Ws],Ps.followed(ch,Zs)),(function(e){return["schemaElementTest"].concat(p(e))})),v=Ps.map(Ps.delimited(Dp,_s(ch,Jp),Zs),(function(e){return["schemaAttributeTest"].concat(p(e))})),w=Ps.map(Ps.preceded(Up,Ps.followed(_s(Ps.optional(Ps.or([d,y])),Jp),Zs)),(function(e){return["documentTest"].concat(p(e?[e]:[]))})),A=Ps.or([Ps.map(Ps.preceded(Mp,Ps.followed(_s(Ps.or([Zp,f]),Jp),Zs)),(function(e){return["piTest",["piTarget",e]]})),$s(qs([kp],"piTest"))]),x=Ps.or([w,d,g,y,v,A,wh,Ah,xh,bh]),b=Ps.or([Ps.map(Ps.preceded(xu,Zp),(function(e){return["Wildcard",["star"],["NCName",e]]})),$s(qs([Tu],"Wildcard")),Ps.map(Ps.followed(sh,Tu),(function(e){return["Wildcard",["uri",e],["star"]]})),Ps.map(Ps.followed(Zp,Au),(function(e){return["Wildcard",["NCName",e],["star"]]}))]),E=Ps.or([b,Ps.map(ch,(function(e){return["nameTest"].concat(p(e))}))]),N=Ps.or([x,E]),B=Ps.then(Ps.optional(Iu),N,(function(e,t){return null!==e||"attributeTest"===t[0]||"schemaAttributeTest"===t[0]?["stepExpr",["xpathAxis","attribute"],t]:["stepExpr",["xpathAxis","child"],t]})),T=Ps.or([Ps.then(fh,N,(function(e,t){return["stepExpr",["xpathAxis",e],t]})),B]),I=Ps.map(qu,(function(){return["stepExpr",["xpathAxis","parent"],["anyKindTest"]]})),C=Ps.or([Ps.then(dh,N,(function(e,t){return["stepExpr",["xpathAxis",e],t]})),I]),S=Ps.map(Ps.star(Ps.preceded(Jp,h)),(function(e){return 0<e.length?["predicates"].concat(p(e)):void 0})),O=Ps.then(Ps.or([C,T]),S,(function(e,t){return void 0===t?e:e.concat([t])})),R=Ps.or([Ih,Ps.map(f,(function(t){return["stringConstantExpr",["value",e.Xa?of(t):t]]}))]),D=Ps.or([Ps.delimited(Ws,_s(u,Jp),Zs),Ps.map(Ps.delimited(Ws,Jp,Zs),(function(){return["sequenceExpr"]}))]),U=Ps.or([s,Oh]),M=Ps.map(Ps.delimited(Ws,_s(Ps.optional(Ps.then(U,Ps.star(Ps.preceded(_s(Lu,Jp),U)),(function(e,t){return[e].concat(p(t))}))),Jp),Zs),(function(e){return null!==e?e:[]})),k=Ps.preceded(Ps.not(Xs(Sh,Jp,Ws,(function(){})),["cannot use reseved keyword for function names"]),Ps.then(ch,Ps.preceded(Jp,M),(function(e,t){return["functionCallExpr",["functionName"].concat(p(e)),null!==t?["arguments"].concat(p(t)):["arguments"]]}))),F=Ps.then(ch,Ps.preceded(Su,Th),(function(e,t){return["namedFunctionRef",["functionName"].concat(p(e)),t]})),G=Ps.delimited(nu,_s(Ps.optional(u),Jp),ru),P=Ps.map(G,(function(e){return e||["sequenceExpr"]})),H=Ps.or([Ps.map(jp,(function(){return[["voidSequenceType"]]})),Ps.then(i,Ps.optional(Ps.preceded(Jp,Rh)),(function(e,t){return[e].concat(p(null!==t?[["occurrenceIndicator",t]]:[]))}))]),_=Ps.then(js([Ou,Jp],ch),Ps.optional(Ps.followed(Ps.then(js([Ws,Jp],R),Ps.star(js([Lu,Jp],R)),(function(e,t){return e.concat(t)})),Zs)),(function(e,t){return["annotation",["annotationName"].concat(p(e))].concat(p(t?["arguments",t]:[]))})),j=Ps.map(js([gc,Jp,Ws,Jp,Tu,Jp],Zs),(function(){return["anyFunctionTest"]})),X=Ps.then(js([gc,Jp,Ws,Jp],Ps.optional(n(H,Lu,(function(e,t){return e.concat.apply(e,t.map((function(e){return e[1]})))})))),js([Jp,Zs,zp,ac,zp],H),(function(e,t){return["typedFunctionTest",["paramTypeList",["sequenceType"].concat(p(e||[]))],["sequenceType"].concat(p(t))]})),L=Ps.then(Ps.star(_),Ps.or([j,X]),(function(e,t){return[t[0]].concat(p(e),p(t.slice(1)))})),$=Ps.map(js([yc,Jp,Ws,Jp,Tu,Jp],Zs),(function(){return["anyMapTest"]})),q=Ps.then(js([yc,Jp,Ws,Jp],cf),js([Jp,Lu],Ps.followed(_s(H,Jp),Zs)),(function(e,t){return["typedMapTest",e,["sequenceType"].concat(p(t))]})),V=Ps.or([$,q]),Y=Ps.map(js([nl,Jp,Ws,Jp,Tu,Jp],Zs),(function(){return["anyArrayTest"]})),Q=Ps.map(js([nl,Jp,Ws],Ps.followed(_s(H,Jp),Zs)),(function(e){return["typedArrayTest",["sequenceType"].concat(p(e))]})),J=Ps.or([Y,Q]),z=Ps.map(Ps.delimited(Ws,_s(i,Jp),Zs),(function(e){return["parenthesizedItemType",e]})),K=Ps.or([x,$s(qs([_p],"anyItemType")),L,V,J,cf,z]),W=Ps.map(js([ac,zp],H),(function(e){return["typeDeclaration"].concat(p(e))})),Z=Ps.then(Ps.preceded(Cu,ch),Ps.optional(Ps.preceded(zp,W)),(function(e,t){return["param",["varName"].concat(p(e))].concat(p(t?[t]:[]))})),ee=n(Z,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))})),te=Ls(Ps.star(_),js([Jp,gc,Jp,Ws,Jp],Ps.optional(ee)),js([Jp,Zs,Jp],Ps.optional(Ps.map(js([ac,Jp],Ps.followed(H,Jp)),(function(e){return["typeDeclaration"].concat(p(e))})))),P,(function(e,t,n,r){return["inlineFunctionExpr"].concat(p(e),[["paramList"].concat(p(t||[]))],p(n?[n]:[]),[["functionBody",r]])})),ne=Ps.or([F,te]),re=Ps.map(s,(function(e){return["mapKeyExpr",e]})),oe=Ps.map(s,(function(e){return["mapValueExpr",e]})),ie=Ps.then(re,Ps.preceded(_s(Nu,Jp),oe),(function(e,t){return["mapConstructorEntry",e,t]})),ae=Ps.preceded(yc,Ps.delimited(_s(nu,Jp),Ps.map(Ps.optional(n(ie,_s(Lu,Jp),(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))}))),(function(e){return e?["mapConstructor"].concat(p(e)):["mapConstructor"]})),Ps.preceded(Jp,ru))),se=Ps.map(Ps.delimited(eu,_s(Ps.optional(n(s,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]})))).map((function(e){return["arrayElem",e]}))}))),Jp),tu),(function(e){return["squareArray"].concat(p(null!==e?e:[]))})),ue=Ps.map(Ps.preceded(nl,Ps.preceded(Jp,G)),(function(e){return["curlyArray"].concat(p(null!==e?[["arrayElem",e]]:[]))})),ce=Ps.map(Ps.or([se,ue]),(function(e){return["arrayConstructor",e]})),le=Ps.or([Zp,Th,D,Tu]),pe=Ps.map(Ps.preceded(Ru,Ps.preceded(Jp,le)),(function(e){return"*"===e?["unaryLookup",["star"]]:"string"==typeof e?["unaryLookup",["NCName",e]]:["unaryLookup",e]})),he=Ps.or([mh,gh,qs([ou],"{"),qs([iu],"}"),Ps.map(G,(function(e){return e||["sequenceExpr"]}))]),fe=Ps.or([Uh,function(e,t){return Ae(e,t)},he,Dh]),de=Ps.or([Ps.map(Mh,(function(e){return e.replace(/[\x20\x0D\x0A\x09]/g," ")})),he]),me=Ps.or([Ps.map(kh,(function(e){return e.replace(/[\x20\x0D\x0A\x09]/g," ")})),he]),ge=Ps.map(Ps.or([_s(Ps.star(Ps.or([yh,de])),uu),_s(Ps.star(Ps.or([vh,me])),au)]),(function(e){return af(e,!1,!1)})),ye=Ps.then(ah,Ps.preceded(_s(ku,Ps.optional(Qp)),ge),(function(e,t){if(""===e[0].prefix&&"xmlns"===e[1]){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",t.length?["uri",t[0]]:["uri"]]}if("xmlns"===e[0].prefix){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+e[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",e[1]],t.length?["uri",t[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(e),0===t.length?["attributeValue"]:1===t.length&&"string"==typeof t[0]?["attributeValue",t[0]]:["attributeValueExpr"].concat(t)]})),ve=Ps.map(Ps.star(Ps.preceded(Qp,Ps.optional(ye))),(function(e){return e.filter(Boolean)})),we=Xs(Ps.preceded(Gu,ah),ve,Ps.or([Ps.map(hu,(function(){return null})),Ps.then(Ps.preceded(_u,Ps.star(fe)),js([Jp,fu],Ps.followed(ah,Ps.then(Ps.optional(Qp),_u,(function(){return null})))),(function(e,t){return[af(e,!0,!0),t]}))]),(function(e,t,n){var r=n;if(n&&n.length){r=sf(e);var o=sf(n[1]);if(r!==o)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+r+'" does not match "'+o+'"');r=n[0]}return["elementConstructor",["tagName"].concat(p(e))].concat(p(t.length?[["attributeList"].concat(p(t))]:[]),p(r&&r.length?[["elementContent"].concat(p(r))]:[]))})),Ae=Ps.or([we,Gh,_h]),xe=Ps.map(js([rl,Jp],G),(function(e){return["computedDocumentConstructor"].concat(p(e?[["argExpr",e]]:[]))})),be=Ps.map(G,(function(e){return e?[["contentExpr",e]]:[]})),Ee=Ps.then(js([vc,Jp],Ps.or([Ps.map(ch,(function(e){return["tagName"].concat(p(e))})),Ps.map(Ps.delimited(nu,_s(u,Jp),ru),(function(e){return["tagNameExpr",e]}))])),Ps.preceded(Jp,be),(function(e,t){return["computedElementConstructor",e].concat(p(t))})),Ne=Ps.then(Ps.preceded(wc,Ps.or([Ps.map(js([hh,Jp],ch),(function(e){return["tagName"].concat(p(e))})),Ps.map(Ps.preceded(Jp,Ps.delimited(nu,_s(u,Jp),ru)),(function(e){return["tagNameExpr",e]}))])),Ps.preceded(Jp,G),(function(e,t){return["computedAttributeConstructor",e,["valueExpr",t||["sequenceExpr"]]]})),Be=Ps.map(G,(function(e){return e?[["prefixExpr",e]]:[]})),Te=Ps.map(G,(function(e){return e?[["URIExpr",e]]:[]})),Ie=Ps.then(js([ol,Jp],Ps.or([eh,Be])),Ps.preceded(Jp,Te),(function(e,t){return["computedNamespaceConstructor"].concat(p(e),p(t))})),Ce=Ps.map(js([il,Jp],G),(function(e){return["computedTextConstructor"].concat(p(e?[["argExpr",e]]:[]))})),Se=Ps.map(js([al,Jp],G),(function(e){return["computedCommentConstructor"].concat(p(e?[["argExpr",e]]:[]))})),Oe=js([sl,Jp],Ps.then(Ps.or([Ps.map(Zp,(function(e){return["piTarget",e]})),Ps.map(Ps.delimited(nu,_s(u,Jp),ru),(function(e){return["piTargetExpr",e]}))]),Ps.preceded(Jp,G),(function(e,t){return["computedPIConstructor",e].concat(p(t?[["piValueExpr",t]]:[]))}))),Re=Ps.or([xe,Ee,Ne,Ie,Ce,Se,Oe]),De=Ps.or([Ae,Re]),Ue=Ps.or([R,ph,D,Ch,k,De,ne,ae,ce,pe]),Me=Ps.map(js([Ru,Jp],le),(function(e){return"*"===e?["lookup",["star"]]:"string"==typeof e?["lookup",["NCName",e]]:["lookup",e]})),ke=Ps.then(Ps.map(Ue,(function(e){return nf(e)})),Ps.star(Ps.or([Ps.map(Ps.preceded(Jp,h),(function(e){return["predicate",e]})),Ps.map(Ps.preceded(Jp,M),(function(e){return["argumentList",e]})),Ps.preceded(Jp,Me)])),(function(e,t){function n(){s&&1===i.length?a.push(["predicate",i[0]]):0!==i.length&&a.push(["predicates"].concat(p(i))),i.length=0}function r(e){n(),0!==a.length?("sequenceExpr"===o[0][0]&&2<o[0].length&&(o=[["sequenceExpr"].concat(p(o))]),o=[["filterExpr"].concat(p(o))].concat(p(a)),a.length=0):e&&(o=[["filterExpr"].concat(p(o))])}var o=[e],i=[],a=[],s=!1;for(t=(e=c(t)).next();!t.done;t=e.next())switch(t=t.value,t[0]){case"predicate":i.push(t[1]);break;case"lookup":s=!0,n(),a.push(t);break;case"argumentList":r(!1),1<o.length&&(o=[["sequenceExpr",["pathExpr",["stepExpr"].concat(p(o))]]]),o=[["dynamicFunctionInvocationExpr",["functionItem"].concat(p(o))].concat(p(t[1].length?[["arguments"].concat(p(t[1]))]:[]))];break;default:throw Error("unreachable")}return r(!0),o})),Fe=Ps.or([Ps.map(ke,(function(e){return["stepExpr"].concat(p(e))})),O]),Ge=Ps.followed(Ue,Ps.peek(Ps.not(Ps.preceded(Jp,Ps.or([h,M,Me])),["primary expression not followed by predicate, argumentList, or lookup"]))),Pe=Ps.or([Xs(Fe,Ps.preceded(Jp,jh),Ps.preceded(Jp,a),(function(e,t,n){return["pathExpr",e,t].concat(p(n))})),Ps.then(Fe,Ps.preceded(_s(Qu,Jp),a),(function(e,t){return["pathExpr",e].concat(p(t))})),Ge,Ps.map(Fe,(function(e){return["pathExpr",e]}))]),He=Ps.or([Xs(Fe,Ps.preceded(Jp,jh),Ps.preceded(Jp,a),(function(e,t,n){return[e,t].concat(p(n))})),Ps.then(Fe,Ps.preceded(_s(Qu,Jp),a),(function(e,t){return[e].concat(p(t))})),Ps.map(Fe,(function(e){return[e]}))]),_e=Ps.or([Ps.map(js([Qu,Jp],He),(function(e){return["pathExpr",["rootExpr"]].concat(p(e))})),Ps.then(jh,Ps.preceded(Jp,He),(function(e,t){return["pathExpr",["rootExpr"],e].concat(p(t))})),Ps.map(Ps.followed(Qu,Ps.not(Ps.preceded(Jp,e.Xa?Vs(/[*<a-zA-Z]/):Vs(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),(function(){return["pathExpr",["rootExpr"]]}))]),je=Hs(Ps.or([Pe,_e]),lf),Xe=Ps.preceded(ll,Ps.then(Ps.optional(Ps.or([Ps.map(Ps.preceded(Jp,Xh),(function(e){return["validationMode",e]})),Ps.map(js([Jp,pl,Jp],ch),(function(e){return["type"].concat(p(e))}))])),Ps.delimited(Ps.preceded(Jp,nu),_s(u,Jp),ru),(function(e,t){return["validateExpr"].concat(p(e?[e]:[]),[["argExpr",t]])}))),Le=Ps.delimited(zs,Ps.then(Ps.preceded(Jp,ch),Ps.optional(Ps.preceded(zp,Lh)),(function(e,t){return t?["pragma",["pragmaName",e],["pragmaContents",t]]:["pragma",["pragmaName",e]]})),Ps.preceded(Jp,Ks)),$e=Ps.map(Ps.followed(Ps.plus(Le),Ps.preceded(Jp,Ps.delimited(nu,_s(Ps.optional(u),Jp),ru))),(function(e){return["extensionExpr"].concat(p(e))})),qe=o(n(je,Du,(function(e,t){return 0===t.length?e:["simpleMapExpr","pathExpr"===e[0]?e:["pathExpr",["stepExpr",["filterExpr",nf(e)]]]].concat(t.map((function(e){return"pathExpr"===(e=e[1])[0]?e:["pathExpr",["stepExpr",["filterExpr",nf(e)]]]})))}))),Ve=Ps.or([Xe,$e,qe]),Ye=Ps.or([Ps.then(Ps.or([qs([Yu],"unaryMinusOp"),qs([Vu],"unaryPlusOp")]),Ps.preceded(Jp,(function(e,t){return Ye(e,t)})),(function(e,t){return[e,["operand",t]]})),Ve]),Qe=Ps.or([Ps.map(ch,(function(e){return["EQName"].concat(p(e))})),ph,D]),Je=Ps.then(Ye,Ps.star(js([Jp,zu,Jp],Ps.then(Qe,Ps.preceded(Jp,M),(function(e,t){return[e,t]})))),(function(e,t){return t.reduce((function(e,t){return["arrowExpr",["argExpr",e],t[0],["arguments"].concat(p(t[1]))]}),e)})),ze=Ps.then(Je,Ps.optional(js([Jp,sc,zp,ac,hh,Jp],uf)),(function(e,t){return null!==t?["castExpr",["argExpr",e],t]:e})),Ke=Ps.then(ze,Ps.optional(js([Jp,uc,zp,ac,hh,Jp],uf)),(function(e,t){return null!==t?["castableExpr",["argExpr",e],t]:e})),We=Ps.then(Ke,Ps.optional(js([Jp,cc,zp,ac,hh,Jp],H)),(function(e,t){return null!==t?["treatExpr",["argExpr",e],["sequenceType"].concat(p(t))]:e})),Ze=Ps.then(We,Ps.optional(js([Jp,lc,zp,pc,hh,Jp],H)),(function(e,t){return null!==t?["instanceOfExpr",["argExpr",e],["sequenceType"].concat(p(t))]:e})),et=n(Ze,Ps.followed(Ps.or([qs([xc],"intersectOp"),qs([bc],"exceptOp")]),hh),t),tt=n(et,Ps.or([qs([Uu],"unionOp"),Ps.followed(qs([Ec],"unionOp"),hh)]),t),nt=n(tt,Ps.or([qs([Tu],"multiplyOp"),Ps.followed(qs([Cc],"divOp"),hh),Ps.followed(qs([Sc],"idivOp"),hh),Ps.followed(qs([Oc],"modOp"),hh)]),t),rt=n(nt,Ps.or([qs([Yu],"subtractOp"),qs([Vu],"addOp")]),t),ot=n(r(rt,Ps.followed(qs([Nc],"rangeSequenceExpr"),hh),"startExpr","endExpr"),qs([Mu],"stringConcatenateOp"),t),it=n(r(ot,Ps.or([$h,qh,Vh])),Ps.followed(qs([Ic],"andOp"),hh),t),at=n(it,Ps.followed(qs([Tc],"orOp"),hh),t),st=Ps.then(Ps.then(js([_c,Jp,Ws,Jp],u),js([Jp,Zs,Jp,jc,hh,Jp],s),(function(e,t){return[e,t]})),js([Jp,Xc,hh,Jp],s),(function(e,t){return["ifThenElseExpr",["ifClause",e[0]],["thenClause",e[1]],["elseClause",t]]})),ut=Ps.delimited(Lc,zp,$c),ct=Ps.map(js([qc,zp,Cu],ch),(function(e){return["positionalVariableBinding"].concat(p(e))})),lt=function(e,t,n,r,o,i){return Ps.then(Ps.then(Ps.then(Ps.then(e,t,(function(e,t){return[e,t]})),n,(function(e,t){var n=c(e);return[e=n.next().value,n=n.next().value,t]})),r,(function(e,t){var n=c(e);return[e=n.next().value,n.next().value,n=n.next().value,t]})),o,(function(e,t){var n=c(e);e=n.next().value;var r=n.next().value,o=n.next().value;return n=n.next().value,i(e,r,o,n,t)}))}(Ps.preceded(Cu,ch),Ps.preceded(Jp,Ps.optional(W)),Ps.preceded(Jp,Ps.optional(ut)),Ps.preceded(Jp,Ps.optional(ct)),Ps.preceded(_s(Vc,Jp),s),(function(e,t,n,r,o){return["forClauseItem",["typedVariableBinding",["varName"].concat(p(e),p(t?[t]:[]))]].concat(p(n?[["allowingEmpty"]]:[]),p(r?[r]:[]),[["forExpr",o]])})),pt=js([Yc,zp],n(lt,Lu,(function(e,t){return["forClause",e].concat(p(t.map((function(e){return e[1]}))))}))),ht=Xs(Ps.preceded(Cu,ch),Ps.preceded(Jp,Ps.optional(W)),Ps.preceded(_s(bu,Jp),s),(function(e,t,n){return["letClauseItem",["typedVariableBinding",["varName"].concat(p(e))].concat(p(t?[t]:[])),["letExpr",n]]})),ft=Ps.map(js([Qc,Jp],n(ht,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))}))),(function(e){return["letClause"].concat(p(e))})),dt=Ps.or([pt,ft]),mt=Ps.map(js([Jc,hh,Jp],s),(function(e){return["whereClause",e]})),gt=Ps.map(Ps.preceded(Cu,ch),(function(e){return["varName"].concat(p(e))})),yt=Ps.then(Ps.preceded(Jp,Ps.optional(W)),Ps.preceded(_s(bu,Jp),s),(function(e,t){return["groupVarInitialize"].concat(p(e?[["typeDeclaration"].concat(p(e))]:[]),[["varValue",t]])})),vt=Xs(gt,Ps.optional(yt),Ps.optional(Ps.map(Ps.preceded(_s(zc,Jp),f),(function(e){return["collation",e]}))),(function(e,t,n){return["groupingSpec",e].concat(p(t?[t]:[]),p(n?[n]:[]))})),wt=n(vt,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))})),At=Ps.map(js([Kc,zp,Wc,Jp],wt),(function(e){return["groupByClause"].concat(p(e))})),xt=Xs(Ps.optional(Ps.or([sp,up])),Ps.optional(js([Jp,$c,Jp],Ps.or([Al,xl].map((function(e){return Ps.map(e,(function(e){return"empty "+e}))}))))),Ps.preceded(Jp,Ps.optional(js([zc,Jp],f))),(function(e,t,n){return e||t||n?["orderModifier"].concat(p(e?[["orderingKind",e]]:[]),p(t?[["emptyOrderingMode",t]]:[]),p(n?[["collation",n]]:[])):null})),bt=Ps.then(s,Ps.preceded(Jp,xt),(function(e,t){return["orderBySpec",["orderByExpr",e]].concat(p(t?[t]:[]))})),Et=n(bt,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))})),Nt=Ps.then(Ps.or([Ps.map(js([Zc,zp],Wc),(function(){return!1})),Ps.map(js([el,zp,Zc,zp],Wc),(function(){return!0}))]),Ps.preceded(Jp,Et),(function(e,t){return["orderByClause"].concat(p(e?[["stable"]]:[]),p(t))})),Bt=Ps.or([dt,mt,At,Nt]),Tt=Ps.map(js([tl,Jp],s),(function(e){return["returnClause",e]})),It=Xs(dt,Ps.star(Ps.preceded(Jp,Bt)),Ps.preceded(Jp,Tt),(function(e,t,n){return["flworExpr",e].concat(p(t),[n])})),Ct=n(H,Uu,(function(e,t){return 0===t.length?["sequenceType"].concat(p(e)):["sequenceTypeUnion",["sequenceType"].concat(p(e))].concat(p(t.map((function(e){return["sequenceType"].concat(p(e[1]))}))))})),St=Xs(js([Nl,Jp],Ps.optional(Ps.preceded(Cu,Ps.followed(Ps.followed(ch,zp),ac)))),Ps.preceded(Jp,Ct),js([zp,tl,zp],s),(function(e,t,n){return["typeswitchExprCaseClause"].concat(e?[["variableBinding"].concat(p(e))]:[],[t],[["resultExpr",n]])})),Ot=Ls(Ps.preceded(Bl,_s(Ps.delimited(Ws,_s(u,Jp),Zs),Jp)),Ps.plus(Ps.followed(St,Jp)),js([fl,zp],Ps.optional(Ps.preceded(Cu,Ps.followed(ch,zp)))),js([tl,zp],s),(function(e,t,n,r){return["typeswitchExpr",["argExpr",e]].concat(p(t),[["typeswitchExprDefaultClause"].concat(p(n||[]),[["resultExpr",r]])])})),Rt=Xs(Ps.preceded(Cu,ch),Ps.optional(Ps.preceded(zp,W)),Ps.preceded(_s(Vc,zp),s),(function(e,t,n){return["quantifiedExprInClause",["typedVariableBinding",["varName"].concat(p(e))].concat(p(t?[t]:[])),["sourceExpr",n]]})),Dt=n(Rt,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))})),Ut=Xs(Ps.or([Tl,Il]),Ps.preceded(zp,Dt),Ps.preceded(_s(Cl,Jp),s),(function(e,t,n){return["quantifiedExpr",["quantifier",e]].concat(p(t),[["predicateExpr",n]])})),Mt=Ps.map(js([dc,zp,Ps.or([fc,hc]),zp],s),(function(e){return["deleteExpr",["targetExpr",e]]})),kt=Xs(js([Sl,zp],Ps.optional(js([mc,zp,pc],zp))),js([hc,zp],s),Ps.preceded(_s(Ol,zp),s),(function(e,t,n){return e?["replaceExpr",["replaceValue"],["targetExpr",t],["replacementExpr",n]]:["replaceExpr",["targetExpr",t],["replacementExpr",n]]})),Ft=Ps.then(ph,Ps.preceded(_s(bu,Jp),s),(function(e,t){return["transformCopy",e,["copySource",t]]})),Gt=Xs(js([Rl,zp],n(Ft,Lu,(function(e,t){return[e].concat(p(t.map((function(e){return e[1]}))))}))),js([Jp,Dl,zp],s),Ps.preceded(_s(tl,zp),s),(function(e,t,n){return["transformExpr",["transformCopies"].concat(p(e)),["modifyExpr",t],["returnExpr",n]]})),Pt=Ps.or([Ps.followed(Ps.map(Ps.optional(Ps.followed(js([ac,zp],Ps.or([Ps.map(Ul,(function(){return["insertAsFirst"]})),Ps.map(Ml,(function(){return["insertAsLast"]}))])),zp)),(function(e){return e?["insertInto",e]:["insertInto"]})),Gl),Ps.map(Fl,(function(){return["insertAfter"]})),Ps.map(kl,(function(){return["insertBefore"]}))]),Ht=Xs(js([Pl,zp,Ps.or([fc,hc]),zp],s),Ps.preceded(zp,Pt),Ps.preceded(zp,s),(function(e,t,n){return["insertExpr",["sourceExpr",e],t,["targetExpr",n]]})),_t=Ps.then(js([Hl,zp,hc,Jp],s),js([zp,ac,zp],s),(function(e,t){return["renameExpr",["targetExpr",e],["newNameExpr",t]]})),jt=Ps.then(Ps.plus(Ps.map(js([Nl,zp],s),(function(e){return["switchCaseExpr",e]}))),js([zp,tl,zp],s),(function(e,t){return["switchExprCaseClause"].concat(p(e),[["resultExpr",t]])})),Xt=Xs(js([_l,Jp,Ws],u),js([Jp,Zs,Jp],Ps.plus(Ps.followed(jt,Jp))),js([fl,zp,tl,zp],s),(function(e,t,n){return["switchExpr",["argExpr",e]].concat(p(t),[["switchExprDefaultClause",["resultExpr",n]]])})),Lt=Ps.map(u,(function(e){return["queryBody",e]})),$t=js([hl,zp,ol,zp],Ps.then(Zp,Ps.preceded(_s(ku,Jp),f),(function(e,t){return["namespaceDecl",["prefix",e],["uri",t]]}))),qt=Ps.then(js([jl,zp,Cu,Jp],Ps.then(ch,Ps.optional(Ps.preceded(Jp,W)),(function(e,t){return[e,t]}))),Ps.or([Ps.map(js([Jp,bu,Jp],s),(function(e){return["varValue",e]})),Ps.map(js([zp,Xl],Ps.optional(js([Jp,bu,Jp],s))),(function(e){return["external"].concat(p(e?[["varValue",e]]:[]))}))]),(function(e,t){var n=c(e);return e=n.next().value,n=n.next().value,["varDecl",["varName"].concat(p(e))].concat(p(null!==n?[n]:[]),[t])})),Vt=Ls(js([gc,zp,Ps.peek(Ps.not(Sh,["Cannot use reserved function name"]))],ch),js([Jp,Ws,Jp],Ps.optional(ee)),js([Jp,Zs],Ps.optional(js([zp,ac,zp],H))),Ps.preceded(Jp,Ps.or([Ps.map(P,(function(e){return["functionBody",e]})),Ps.map(Xl,(function(){return["externalDefinition"]}))])),(function(e,t,n,r){return["functionDecl",["functionName"].concat(p(e)),["paramList"].concat(p(t||[]))].concat(p(n?[["typeDeclaration"].concat(p(n))]:[]),[r])})),Yt=js([hl,zp],Ps.then(Ps.star(Ps.followed(Ps.or([_,Yh]),zp)),Ps.or([qt,Vt]),(function(e,t){return[t[0]].concat(p(e),p(t.slice(1)))}))),Qt=Ps.then(js([hl,zp,fl,zp],Ps.or([vc,gc])),js([zp,ol,zp],f),(function(e,t){return["defaultNamespaceDecl",["defaultNamespaceCategory",e],["uri",t]]})),Jt=Ps.or([Ps.map(Ps.followed(js([ol,zp],Zp),Ps.preceded(Jp,ku)),(function(e){return["namespacePrefix",e]})),Ps.map(js([fl,zp,vc,zp],ol),(function(){return["defaultElementNamespace"]}))]),zt=js([$l,zp,ql],Xs(Ps.optional(Ps.preceded(zp,Jt)),Ps.preceded(Jp,f),Ps.optional(Ps.then(js([zp,qc,zp],f),Ps.star(js([Jp,Lu,Jp],f)),(function(e,t){return[e].concat(p(t))}))),(function(e,t,n){return["schemaImport"].concat(p(e?[e]:[]),[["targetNamespace",t]],p(n?[n]:[]))}))),Kt=js([$l,zp,Vl],Xs(Ps.optional(Ps.followed(js([zp,ol,zp],Zp),Ps.preceded(Jp,ku))),Ps.preceded(Jp,f),Ps.optional(Ps.then(js([zp,qc,zp],f),Ps.star(js([Jp,Lu,Jp],f)),(function(e,t){return[e].concat(p(t))}))),(function(e,t){return["moduleImport",["namespacePrefix",e],["targetNamespace",t]]}))),Wt=Ps.or([zt,Kt]),Zt=Ps.map(js([hl,zp,fl,zp,zc,zp],f),(function(e){return["defaultCollationDecl",e]})),en=Ps.map(js([hl,zp,Yl,zp],f),(function(e){return["baseUriDecl",e]})),tn=Ps.then(js([hl,zp],Ps.or([Ps.map(js([El,zp],ch),(function(e){return["decimalFormatName"].concat(p(e))})),Ps.map(js([fl,zp],El),(function(){return null}))])),Ps.star(Ps.then(Ps.preceded(zp,zh),Ps.preceded(_s(ku,zp),f),(function(e,t){return["decimalFormatParam",["decimalFormatParamName",e],["decimalFormatParamValue",t]]}))),(function(e,t){return["decimalFormatDecl"].concat(p(e?[e]:[]),p(t))})),nn=Ps.or([Kh,Zt,en,Wh,Zh,ef,tf,tn]),rn=Ps.then(js([hl,zp,Wl,zp],ch),Ps.preceded(zp,f),(function(e,t){return["optionDecl",["optionName",e],["optionContents",t]]})),on=Ps.then(js([hl,zp,Zl,zp,ep],Ps.optional(js([zp,ac],K))),Ps.or([Ps.map(Ps.preceded(_s(bu,Jp),s),(function(e){return["varValue",e]})),Ps.map(js([zp,Xl],Ps.optional(Ps.preceded(_s(bu,Jp),s))),(function(){return["external"]}))]),(function(e,t){return["contextItemDecl"].concat(p(e?[["contextItemType",e]]:[]),[t])})),an=Ps.then(Ps.star(Ps.followed(Ps.or([Qt,nn,$t,Wt]),_s(Bu,Jp))),Ps.star(Ps.followed(Ps.or([on,Yt,rn]),_s(Bu,Jp))),(function(e,t){return 0===e.length&&0===t.length?null:["prolog"].concat(p(e),p(t))})),sn=js([Vl,zp,ol,zp],Ps.then(Ps.followed(Zp,_s(ku,Jp)),Ps.followed(f,_s(Bu,Jp)),(function(e,t){return["moduleDecl",["prefix",e],["uri",t]]}))),un=Ps.then(sn,Ps.preceded(Jp,an),(function(e,t){return["libraryModule",e].concat(p(t?[t]:[]))})),cn=Ps.then(an,Ps.preceded(Jp,Lt),(function(e,t){return["mainModule"].concat(p(e?[e]:[]),[t])})),ln=Ps.map(js([tp,Jp],Ps.followed(Ps.or([Ps.then(Ps.preceded(rp,zp),f,(function(e){return["encoding",e]})),Ps.then(js([np,zp],f),Ps.optional(js([zp,rp,zp],f)),(function(e,t){return[["version",e]].concat(p(t?[["encoding",t]]:[]))}))]),Ps.preceded(Jp,Bu))),(function(e){return["versionDecl"].concat(p(e))})),pn=Ps.then(Ps.optional(_s(ln,Jp)),Ps.or([un,cn]),(function(e,t){return["module"].concat(p(e?[e]:[]),[t])})),hn=Ps.complete(_s(pn,Jp));return function(e,t){l.clear(),t=hn(e,t);for(var n=1,r=1,o=0;o<e.length+1;o++){if(l.has(o)){var i=l.get(o);i.line=r,i.la=n}"\r"===(i=e[o])||"\n"===i?(r++,n=1):n++}return t}}var hf=pf({ub:!1,Xa:!1}),ff=pf({ub:!0,Xa:!1}),df=pf({ub:!1,Xa:!0}),mf=pf({ub:!0,Xa:!0});function gf(e,t){var n=!!t.aa;if(t=!!t.debug,Xp.clear(),Lp.clear(),lf.clear(),!0===(n=n?t?mf(e,0):df(e,0):t?ff(e,0):hf(e,0)).success)return n.value;throw Error("XPST0003: Failed to parse '"+e+"' expected: "+n.expected+"\n"+e.slice(0,n.offset)+"[Error is around here]"+e.slice(n.offset))}var yf="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 vf(e,t,n){n=void 0===n||n;var r=[],o=[];Fo(e,"*").forEach((function(e){switch(e[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")}}));var i=new Set;Fo(e,"moduleImport").forEach((function(e){var n=Uo(Do(e,"namespacePrefix"));if(e=Uo(Do(e,"targetNamespace")),i.has(e))throw Error('XQST0047: The namespace "'+e+'" is imported more than once.');i.add(e),Co(t,n,e),Fs(t,e)})),Fo(e,"namespaceDecl").forEach((function(e){var n=Uo(Do(e,"prefix"));if(e=Uo(Do(e,"uri")),"xml"===n||"xmlns"===n)throw wo();if("http://www.w3.org/XML/1998/namespace"===e||"http://www.w3.org/2000/xmlns/"===e)throw wo();Co(t,n,e)}));for(var a=null,s=null,u=c(Fo(e,"defaultNamespaceDecl")),l=u.next();!l.done;l=u.next()){var h=l.value;if(l=Uo(Do(h,"defaultNamespaceCategory")),!(h=Uo(Do(h,"uri"))))throw yo();if("http://www.w3.org/XML/1998/namespace"===h||"http://www.w3.org/2000/xmlns/"===h)throw wo();if("function"===l){if(a)throw vo();a=h}else if("element"===l){if(s)throw vo();s=h}}a&&(t.A=a),s&&Co(t,"",s),Fo(e,"functionDecl").forEach((function(e){!function(e,t,n,r,o){var i=Do(e,"functionName"),a=Mo(i,"prefix")||"",s=Mo(i,"URI"),u=Uo(i);if(null===s&&!(s=""===a?null===t.A?"http://www.w3.org/2005/xpath-functions":t.A:t.ba(a))&&a)throw xo(a);if(yf.includes(s))throw go();if(a=Fo(e,"annotation").map((function(e){return Do(e,"annotationName")})),i=a.every((function(e){return!Mo(e,"URI")&&"private"!==Uo(e)})),a=a.some((function(e){return!Mo(e,"URI")&&"updating"===Uo(e)})),!s)throw yo();var c=Po(e),l=Fo(Do(e,"paramList"),"param"),h=l.map((function(e){return Do(e,"varName")})),f=l.map((function(e){return Po(e)}));if(e=Do(e,"functionBody")){if(t.Ba(s,u,f.length))throw Error("XQST0049: The function Q{"+s+"}"+u+"#"+f.length+" has already been declared.");if(!o)return;var d=Ss(e[1],{sa:!1,aa:!0}),m=new No(t),g=h.map((function(e){var n=Mo(e,"URI"),r=Mo(e,"prefix");return e=Uo(e),r&&null===n&&(n=t.ba(r||"")),So(m,n,e)}));o=a?{l:f,arity:h.length,m:function(e,t,n,r){for(var o=[],i=3;i<arguments.length;++i)o[i-3]=arguments[i];return i=Bt(Nt(e,-1,null,ge.empty()),g.reduce((function(e,t,n){return e[t]=ye(o[n]),e}),Object.create(null))),d.u(i,t)},Db:!1,I:!0,localName:u,namespaceURI:s,i:c}:{l:f,arity:h.length,m:function(e,t,n,r){for(var o=[],i=3;i<arguments.length;++i)o[i-3]=arguments[i];return i=Bt(Nt(e,-1,null,ge.empty()),g.reduce((function(e,t,n){return e[t]=ye(o[n]),e}),Object.create(null))),hr(d,i,t)},Db:!1,I:!1,localName:u,namespaceURI:s,i:c},n.push({da:d,Kb:m}),i&&r.push({arity:h.length,da:d,Gb:o,localName:u,namespaceURI:s})}else{if(a)throw Error("Updating external function declarations are not supported");o={l:f,arity:h.length,m:function(e,t,n,r){for(var o=[],i=3;i<arguments.length;++i)o[i-3]=arguments[i];if(!(i=n.Ba(s,u,h.length,!0)))throw Error("XPST0017: Function Q{"+s+"}"+u+" with arity of "+h.length+" not registered. "+so(u));if(i.i.type!==c.type||i.l.some((function(e,t){return e.type!==f[t].type})))throw Error("External function declaration types do not match actual function");return i.m.apply(i,[e,t,n].concat(p(o)))},Db:!0,I:!1,localName:u,namespaceURI:s,i:c}}Io(t,s,u,h.length,o)}(e,t,r,o,n)}));var f=[];return Fo(e,"varDecl").forEach((function(e){var o=Go(Do(e,"varName")),i=o.namespaceURI;if(null===i&&(!(i=t.ba(o.prefix))&&o.prefix))throw xo(o.prefix);if(yf.includes(i))throw go();var a,s,u=Do(e,"external");if(e=Do(e,"varValue"),null!==u?null!==(u=Do(u,"varValue"))&&(a=Do(u,"*")):null!==e&&(a=Do(e,"*")),f.some((function(e){return e.namespaceURI===i&&e.localName===o.localName})))throw Error("XQST0049: The variable "+(i?"Q{"+i+"}":"")+o.localName+" has already been declared.");if(So(t,i||"",o.localName),n&&(a&&(s=Ss(a,{sa:!1,aa:!0})),a&&!function(e,t,n){return(e=e.Fa[bo(t,n)])?e:null}(t,i||"",o.localName))){var c=null;Oo(t,i,o.localName,(function(e,t){return c?c():(c=ye(hr(s,e,t)))()})),r.push({da:s,Kb:t}),f.push({da:s,localName:o.localName,namespaceURI:i})}})),r.forEach((function(e){e.da.P(e.Kb)})),o.forEach((function(e){if(!e.Gb.I&&e.da.I)throw er("The function Q{"+e.namespaceURI+"}"+e.localName+" is updating but the %updating annotation is missing.")})),{Oa:o,Wa:f}}function wf(e,t,n,r,o,i,a){var s=t.aa?"XQuery":"XPath";return n=t.Ja?null:function(e,t,n,r,o,i,a,s){return(e=Os.get(e))&&(t=e[t+(i?"_DEBUG":"")])&&(t=t.find((function(e){return e.s===a&&e.j.every((function(e){return n(e.prefix)===e.namespaceURI}))&&e.u.every((function(e){return void 0!==r[e.name]}))&&e.A.every((function(e){return o[e.prefix]===e.namespaceURI}))&&e.O.every((function(e){var t=s(e.Dc,e.arity);return t&&t.namespaceURI===e.Jb.namespaceURI&&t.localName===e.Jb.localName}))})))?{da:t.h,Hc:!1}:null}(e,s,n,r,o,t.debug,i,a),null!==n?{state:n.Hc?1:2,da:n.da}:{state:0,yc:"string"==typeof e?gf(e,t):Us(e)}}function Af(e,t,n,r,o,i,a){var s=new po(n,r,i,a),u=new No(s);switch(Object.keys(o).forEach((function(e){var t=o[e];Fs(u,t),Co(u,e,t)})),"string"==typeof e&&(e=Gs(e)),(n=wf(e,t,n,r,o,i,a)).state){case 2:return{ia:u,da:n.da};case 1:return n.da.P(u),Ds(e,t.aa?"XQuery":"XPath",s,o,n.da,t.debug,i),{ia:u,da:n.da};case 0:return n=function(e,t,n){var r=Do(e,"mainModule");if(!r)throw Error("Can not execute a library module.");var o=Do(r,"prolog");if(o){if(!t.aa)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");vf(o,n)}return ti(e,new ci(n)),Ns(e=ko(r,["queryBody","*"]),t)}(n.yc,t,u),n.P(u),t.Ja||Ds(e,t.aa?"XQuery":"XPath",s,o,n,t.debug,i),{ia:u,da:n}}}function xf(e,t,n){if(1!==t.node.nodeType&&9!==t.node.nodeType)return[];var r=De(e,t).reduce((function(t,r){for(var o=(r=c(xf(e,r,n))).next();!o.done;o=r.next())t.push(o.value);return t}),[]);return n(t)&&r.unshift(t),r}function bf(e,t,n,r,o){if(!(e=o.first()))throw Error("XPDY0002: The context is absent, it needs to be present to use id function.");if(!ee(e.type,53))throw St("The context item is not a node, it needs to be node to use id function.");var i=t.h,a=r.N().reduce((function(e,t){return t.value.split(/\s+/).forEach((function(t){e[t]=!0})),e}),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=Ge(i,t)))throw Error("FODC0001: the root node of the target node is not a document node.");return t=xf(i,t,(function(e){return 1===e.node.nodeType&&(!(!(e=Re(i,e,"id"))||!a[e])&&(a[e]=!1,!0))})),ge.create(t.map((function(e){return Xe(e)})))}function Ef(e,t,n,r,o){if(!(e=o.first()))throw Error("XPDY0002: The context is absent, it needs to be present to use idref function.");if(!ee(e.type,53))throw St("The context item is not a node, it needs to be node to use idref function.");var i=t.h,a=r.N().reduce((function(e,t){return e[t.value]=!0,e}),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=Ge(i,t)))throw Error("FODC0001: the root node of the context node is not a document node.");return t=xf(i,t,(function(e){return 1===e.node.nodeType&&(!!(e=Re(i,e,"idref"))&&e.split(/\s+/).some((function(e){return a[e]})))})),ge.create(t.map((function(e){return Xe(e)})))}function Nf(e){switch(typeof e){case"object":return Array.isArray(e)?ge.o(new _e(e.map((function(e){return ye(Nf(e))})))):null===e?ge.empty():ge.o(new Ve(Object.keys(e).map((function(t){return{key:V(t,1),value:ye(Nf(e[t]))}}))));case"number":return ge.o(V(e,3));case"string":return ge.o(V(e,1));case"boolean":return e?ge.ca():ge.X();default:throw Error("Unexpected type in JSON parse")}}function Bf(e,t,n,r,o){var i=(e=qe(0,0,0,o,ge.o(V("duplicates",1)))).G()?"use-first":e.first().value;return r.L((function(e){return ge.o(new Ve(e.reduce((function(e,t){return t.h.forEach((function(t){var n=e.findIndex((function(e){return $e(e.key,t.key)}));if(0<=n)switch(i){case"reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case"use-last":return void e.splice(n,1,t);case"combine":return void e.splice(n,1,{key:t.key,value:ye(ge.create(e[n].value().N().concat(t.value().N())))});default:return}e.push(t)})),e}),[])))}))}function Tf(e,t,n){var r=1,o=e.value;e=e.Pa(!0);var i=null,a=Math.max(t-1,0);return-1!==e&&(i=Math.max(0,(null===n?e:Math.max(0,Math.min(e,n+(t-1))))-a)),ge.create({next:function(e){for(;r<t;)o.next(e),r++;return null!==n&&r>=t+n?K:(e=o.next(e),r++,e)}},i)}function If(e){return e.map((function(e){return ee(e.type,19)?Kt(e,3):e}))}function Cf(e){if((e=If(e)).some((function(e){return Number.isNaN(e.value)})))return[V(NaN,3)];if(!(e=ya(e)))throw Error("FORG0006: Incompatible types to be converted to a common type");return e}function Sf(e,t,n,r,o,i){return Le([o,i],(function(e){var t=c(e);if(e=t.next().value,t=t.next().value,1/0===e.value)return ge.empty();if(-1/0===e.value)return t&&1/0===t.value?ge.empty():r;if(t){if(isNaN(t.value))return ge.empty();1/0===t.value&&(t=null)}return isNaN(e.value)?ge.empty():Tf(r,Math.round(e.value),t?Math.round(t.value):null)}))}function Of(e,t,n,r,o){if(r.G())return o;if(!(e=ya(e=If(r.N()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((function(e){return ee(e.type,2)})))throw Error("FORG0006: items passed to fn:sum are not all numeric.");return t=e.reduce((function(e,t){return e+t.value}),0),e.every((function(e){return ee(e.type,5)}))?ge.o(V(t,5)):e.every((function(e){return ee(e.type,3)}))?ge.o(V(t,3)):e.every((function(e){return ee(e.type,4)}))?ge.o(V(t,4)):ge.o(V(t,6))}var Rf=[].concat(Pr,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",l:[{type:59,g:2}],i:{type:0,g:3},m:function(e,t,n,r){return r.getEffectiveBooleanValue()?ge.ca():ge.X()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",l:[],i:{type:0,g:3},m:function(){return ge.ca()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",l:[{type:59,g:2}],i:{type:0,g:3},m:function(e,t,n,r){return!1===r.getEffectiveBooleanValue()?ge.ca():ge.X()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",l:[],i:{type:0,g:3},m:function(){return ge.X()}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",l:[],i:{type:5,g:3},m:function(e){if(null===e.M)throw Error("XPDY0002: The fn:last() function depends on dynamic context, which is absent.");var t=!1;return ge.create({next:function(){if(t)return K;var n=e.Ia.Pa();return t=!0,W(V(n,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",l:[],i:{type:5,g:3},m:function(e){if(null===e.M)throw Error("XPDY0002: The fn:position() function depends on dynamic context, which is absent.");return ge.o(V(e.La+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",l:[],i:{type:10,g:3},m:function(e){return ge.o(V(bt(e),10))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",l:[],i:{type:7,g:3},m:function(e){return ge.o(V(ut(bt(e),7),7))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",l:[],i:{type:8,g:3},m:function(e){return ge.o(V(ut(bt(e),8),8))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",l:[],i:{type:17,g:3},m:function(e){return ge.o(V(Et(e),17))}}],_r,Qr,Zr,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",l:[{type:18,g:0}],i:{type:5,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.fb(),5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",l:[{type:18,g:0}],i:{type:5,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.bb(),5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",l:[{type:18,g:0}],i:{type:5,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.ab(),5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",l:[{type:18,g:0}],i:{type:5,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getHours(),5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-duration",l:[{type:18,g:0}],i:{type:5,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getMinutes(),5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-duration",l:[{type:18,g:0}],i:{type:4,g:0},m:function(e,t,n,r){return r.G()?r:ge.o(V(r.first().value.getSeconds(),4))}}],to,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",l:[{type:1,g:2},{type:53,g:3}],i:{type:54,g:2},m:bf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",l:[{type:1,g:2}],i:{type:54,g:2},m:function(e,t,n,r){return bf(e,t,0,r,ge.o(e.M))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",l:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},m:Ef},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",l:[{type:1,g:2}],i:{type:53,g:2},m:function(e,t,n,r){return Ef(e,t,0,r,ge.o(e.M))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",l:[{type:1,g:3}],i:{type:59,g:0},m:function(e,t,n,r){try{var o=JSON.parse(r.first().value)}catch(e){throw Error("FOJS0001: parsed JSON string contains illegal JSON.")}return Nf(o)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"contains",l:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},m:function(e,t,n,r,o){return Le([r,o],(function(e){var t=(e=c(e)).next().value,n=e.next().value;return t.h.some((function(e){return $e(e.key,n)}))?ge.ca():ge.X()}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"entry",l:[{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},m:function(e,t,n,r,o){return r.map((function(e){return new Ve([{key:e,value:ye(o)}])}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"for-each",l:[{type:61,g:3},{type:59,g:2}],i:{type:59,g:2},m:function(e,t,n,r,o){return Le([r,o],(function(r){var o=(r=c(r)).next().value,i=r.next().value;return It(o.h.map((function(r){return i.value.call(void 0,e,t,n,ge.o(r.key),r.value())})))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"get",l:[{type:61,g:3},{type:46,g:3}],i:{type:59,g:2},m:qe},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",l:[{type:61,g:3}],i:{type:46,g:2},m:function(e,t,n,r){return Le([r],(function(e){return e=c(e).next().value,ge.create(e.h.map((function(e){return e.key})))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",l:[{type:61,g:2},{type:61,g:3}],i:{type:61,g:3},m:Bf},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",l:[{type:61,g:2}],i:{type:61,g:3},m:function(e,t,n,r){return Bf(e,0,0,r,ge.o(new Ve([{key:V("duplicates",1),value:function(){return ge.o(V("use-first",1))}}])))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"put",l:[{type:61,g:3},{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},m:function(e,t,n,r,o,i){return Le([r,o],(function(e){var t=(e=c(e)).next().value,n=e.next().value;return e=t.h.concat(),t=e.findIndex((function(e){return $e(e.key,n)})),0<=t?e.splice(t,1,{key:n,value:ye(i)}):e.push({key:n,value:ye(i)}),ge.o(new Ve(e))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"remove",l:[{type:61,g:3},{type:46,g:2}],i:{type:61,g:3},m:function(e,t,n,r,o){return Le([r],(function(e){var t=c(e).next().value.h.concat();return o.L((function(e){return e.forEach((function(e){var n=t.findIndex((function(t){return $e(t.key,e)}));0<=n&&t.splice(n,1)})),ge.o(new Ve(t))}))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",l:[{type:61,g:3}],i:{type:5,g:3},m:function(e,t,n,r){return r.map((function(e){return V(e.h.length,5)}))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",l:[],i:{type:3,g:3},m:function(){return ge.o(V(Math.PI,3))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.pow(Math.E,e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.pow(10,e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.log(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.log10(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pow",l:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},m:function(e,t,n,r,o){return o.L((function(e){var t=c(e).next().value;return r.map((function(e){return 1!==Math.abs(e.value)||Number.isFinite(t.value)?V(Math.pow(e.value,t.value),3):V(1,3)}))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.sqrt(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.sin(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.cos(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.tan(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.asin(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.acos(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",l:[{type:3,g:0}],i:{type:3,g:0},m:function(e,t,n,r){return r.map((function(e){return V(Math.atan(e.value),3)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan2",l:[{type:3,g:0},{type:3,g:3}],i:{type:3,g:0},m:function(e,t,n,r,o){return o.L((function(e){var t=c(e).next().value;return r.map((function(e){return V(Math.atan2(e.value,t.value),3)}))}))}}],qn,bn,[{namespaceURI:"http://fontoxpath/operators",localName:"to",l:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},m:function(e,t,n,r,o){if(e=r.first(),o=o.first(),null===e||null===o)return ge.empty();var i=e.value;return o=o.value,i>o?ge.empty():ge.create({next:function(){return W(V(i++,5))}},o-i+1)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"QName",l:[{type:1,g:0},{type:1,g:3}],i:{type:23,g:3},m:function(e,t,n,r,o){return Le([r,o],(function(e){var t=c(e);if(e=t.next().value,!Ft(t=t.next().value.value,23))throw Error("FOCA0002: The provided QName is invalid.");if(null===(e=e&&e.value||null)&&t.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(r.G())return ge.o(V(new ve("",null,t),23));if(!t.includes(":"))return ge.o(V(new ve("",e,t),23));var n=c(t.split(":"));return t=n.next().value,n=n.next().value,ge.o(V(new ve(t,e,n),23))}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",l:[{type:23,g:0}],i:{type:24,g:0},m:function(e,t,n,r){return Le([r],(function(e){return null===(e=c(e).next().value)?ge.empty():(e=e.value).prefix?ge.o(V(e.prefix,24)):ge.empty()}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"local-name-from-QName",l:[{type:23,g:0}],i:{type:24,g:0},m:function(e,t,n,r){return r.map((function(e){return V(e.value.localName,24)}))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"namespace-uri-from-QName",l:[{type:23,g:0}],i:{type:20,g:0},m:function(e,t,n,r){return r.map((function(e){return V(e.value.namespaceURI||"",20)}))}}],[{l:[{type:59,g:2}],m:function(e,t,n,r){return r.$({empty:function(){return ge.ca()},multiple:function(){return ge.X()},o:function(){return ge.X()}})},localName:"empty",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:59,g:2}],m:function(e,t,n,r){return r.$({empty:function(){return ge.X()},multiple:function(){return ge.ca()},o:function(){return ge.ca()}})},localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:59,g:2}],m:function(e,t,n,r){return Tf(r,1,1)},localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{l:[{type:59,g:2}],m:function(e,t,n,r){return Tf(r,2,null)},localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],m:function(e,t,n,r,o,i){return r.G()?i:i.G()?r:(e=r.N(),0>(o=o.first().value-1)?o=0:o>e.length&&(o=e.length),t=e.slice(o),ge.create(e.slice(0,o).concat(i.N(),t)))},localName:"insert-before",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:5,g:3}],m:function(e,t,n,r,o){return e=o.first().value,!(r=r.N()).length||1>e||e>r.length||r.splice(e-1,1),ge.create(r)},localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(e,t,n,r){return r.L((function(e){return ge.create(e.reverse())}))},localName:"reverse",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:3,g:3}],m:function(e,t,n,r,o){return Sf(0,0,0,r,o,ge.empty())},localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:3,g:3},{type:3,g:3}],m:Sf,localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(e,t,n,r){return r},localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:46,g:2}],m:function(e,t,n,r){var o=Ut(r,t).N();return ge.create(o).filter((function(e,t){return o.slice(0,t).every((function(t){return!Qn(e,t)}))}))},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{l:[{type:46,g:2},{type:1,g:3}],m:function(){throw Error("FOCH0002: No collations are supported")},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{l:[{type:46,g:2},{type:46,g:3}],m:function(e,t,n,r,o){return o.L((function(n){var o=c(n).next().value;return Ut(r,t).map((function(t,n){return Wi("eqOp",t.type,o.type)(t,o,e)?V(n+1,5):V(-1,5)})).filter((function(e){return-1!==e.value}))}))},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{l:[{type:46,g:2},{type:46,g:3},{type:1,g:3}],m:function(){throw Error("FOCH0002: No collations are supported")},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{l:[{type:59,g:2},{type:59,g:2}],m:function(e,t,n,r,o){var i=!1,a=Kn(e,t,n,r,o);return ge.create({next:function(){if(i)return K;var e=a.next(0);return e.done?e:(i=!0,W(V(e.value,0)))}})},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:59,g:2},{type:59,g:2},{type:1,g:3}],m:function(){throw Error("FOCH0002: No collations are supported")},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{l:[{type:59,g:2}],m:function(e,t,n,r){var o=!1;return ge.create({next:function(){if(o)return K;var e=r.Pa();return o=!0,W(V(e,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{l:[{type:46,g:2}],m:function(e,t,n,r){if(r.G())return r;if(!(e=ya(e=If(r.N()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((function(e){return ee(e.type,2)})))throw Error("FORG0006: items passed to fn:avg are not all numeric.");return t=e.reduce((function(e,t){return e+t.value}),0)/e.length,e.every((function(e){return ee(e.type,5)||ee(e.type,3)}))?ge.o(V(t,3)):e.every((function(e){return ee(e.type,4)}))?ge.o(V(t,4)):ge.o(V(t,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:46,g:2}],m:function(e,t,n,r){return r.G()?r:(e=Cf(r.N()),ge.o(e.reduce((function(e,t){return e.value<t.value?t:e}))))},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:46,g:2},{type:1,g:3}],m:function(){throw Error("FOCH0002: No collations are supported")},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:46,g:2}],m:function(e,t,n,r){return r.G()?r:(e=Cf(r.N()),ge.o(e.reduce((function(e,t){return e.value>t.value?t:e}))))},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:46,g:2},{type:1,g:3}],m:function(){throw Error("FOCH0002: No collations are supported")},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:46,g:2}],m:function(e,t,n,r){return Of(e,t,0,r,ge.o(V(0,5)))},localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:3}},{l:[{type:46,g:2},{type:46,g:0}],m:Of,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{l:[{type:59,g:2}],m:function(e,t,n,r){if(!r.G()&&!r.ta())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}},{l:[{type:59,g:2}],m:function(e,t,n,r){if(r.G())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}},{l:[{type:59,g:2}],m:function(e,t,n,r){if(!r.ta())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}},{l:[{type:59,g:2},{type:60,g:3}],m:function(e,t,n,r,o){if(r.G())return r;var i=o.first(),a=i.s;if(1!==a.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.filter((function(r){if(r=fn(a[0],ge.o(r),t,"fn:filter",!1),!(r=i.value.call(void 0,e,t,n,r)).ta()||!ee(r.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.first().value}))},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:60,g:3}],m:function(e,t,n,r,o){if(r.G())return r;var i=o.first(),a=i.s;if(1!==a.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");var s,u=r.value;return ge.create({next:function(r){for(;;){if(!s){var o=u.next(0);if(o.done)return o;o=fn(a[0],ge.o(o.value),t,"fn:for-each",!1),s=i.value.call(void 0,e,t,n,o).value}if(!(o=s.next(r)).done)return o;s=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],m:function(e,t,n,r,o,i){if(r.G())return r;var a=i.first(),s=a.s;if(2!==s.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return r.L((function(r){return r.reduce((function(r,o){return r=fn(s[0],r,t,"fn:fold-left",!1),o=fn(s[1],ge.o(o),t,"fn:fold-left",!1),a.value.call(void 0,e,t,n,r,o)}),o)}))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],m:function(e,t,n,r,o,i){if(r.G())return r;var a=i.first(),s=a.s;if(2!==s.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return r.L((function(r){return r.reduceRight((function(r,o){return r=fn(s[0],r,t,"fn:fold-right",!1),o=fn(s[1],ge.o(o),t,"fn:fold-right",!1),a.value.call(void 0,e,t,n,o,r)}),o)}))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(e,t,n,r){if(!t.A)throw Error("serialize() called but no xmlSerializer set in execution parameters.");if(!(e=r.N()).every((function(e){return ee(e.type,53)})))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return ge.o(V(e.map((function(e){return t.A.serializeToString(Kr(e.value,t,!1))})).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],Mn,[{l:[{type:59,g:3},{type:61,g:3}],m:function(e,t,n,r,o){var i,a;return ge.create({next:function(){if(!i){var e=function(e,t,n,r){e=e.first();var o=t.first().h.reduce((function(e,t){return e[t.key.value]=ye(t.value()),e}),Object.create(null));t=o["."]?o["."]():ge.empty(),delete o["."];try{if(ee(e.type,1))var i=e.value;else{if(!ee(e.type,54))throw St("Unable to convert selector argument of type "+ie[e.type]+" to either an "+ie[1]+" or an "+ie[54]+" representing an XQueryX program while calling 'fontoxpath:evaluate'");i=e.value.node}var a=Af(i,{sa:!1,aa:!0,debug:r.debug,Ja:r.Ja},(function(e){return n.ba(e)}),Object.keys(o).reduce((function(e,t){return e[t]=t,e}),{}),{},"http://www.w3.org/2005/xpath-functions",(function(e,t){return n.Ta(e,t)})),s=a.da,u=a.ia,c=!t.G(),l=new At({M:c?t.first():null,La:c?0:-1,Ia:t,Ga:Object.keys(o).reduce((function(e,t){return e[u.sb(null,t)]=o[t],e}),Object.create(null))});return{Ic:s.h(l,r).value,Fc:e}}catch(t){oo(e.value,t)}}(r,o,n,t);i=e.Ic,a=e.Fc}try{return i.next(0)}catch(e){oo(a.value,e)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{l:[],m:function(){return ge.o(V("3.27.1",1))},localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{l:[{type:23,g:3},{type:5,g:3}],m:function(e,t,n,r,o){return Le([r,o],(function(e){var t=c(e);e=t.next().value,t=t.next().value;var r=n.Ba(e.value.namespaceURI,e.value.localName,t.value);return null===r?ge.empty():(e=new we({l:r.l,arity:t.value,localName:e.value.localName,namespaceURI:e.value.namespaceURI,i:r.i,value:r.m}),ge.o(e))}))},localName:"function-lookup",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{l:[{type:60,g:3}],m:function(e,t,n,r){return Le([r],(function(e){return(e=c(e).next().value).Ra()?ge.empty():ge.o(V(new ve("",e.u,e.j),23))}))},localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{l:[{type:60,g:3}],m:function(e,t,n,r){return Le([r],(function(e){return e=c(e).next().value,ge.o(V(e.A,5))}))},localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);function Df(e){this.h=e}(r=Df.prototype).createAttributeNS=function(e,t){return this.h.createAttributeNS(e,t)},r.createCDATASection=function(e){return this.h.createCDATASection(e)},r.createComment=function(e){return this.h.createComment(e)},r.createDocument=function(){return this.h.createDocument()},r.createElementNS=function(e,t){return this.h.createElementNS(e,t)},r.createProcessingInstruction=function(e,t){return this.h.createProcessingInstruction(e,t)},r.createTextNode=function(e){return this.h.createTextNode(e)};var Uf=Symbol("IS_XPATH_VALUE_SYMBOL");function Mf(e){return e&&"object"==typeof e&&"lookupNamespaceURI"in e?function(t){return e.lookupNamespaceURI(t||null)}:function(){return null}}function kf(e){return function(t){var n=t.localName;return t.prefix?null:{namespaceURI:e,localName:n}}}function Ff(e,t,n,r,o,i){var a,s,u,l,p,h,f;null==r&&(r=r||{}),o?(a=o.logger||{trace:console.log.bind(console)},s=o.documentWriter,u=o.moduleImports,l=o.namespaceResolver,p=o.functionNameResolver,h=o.nodesFactory,f=o.xmlSerializer):(a={trace:console.log.bind(console)},u={},l=null,h=null,s=null,f=null,p=void 0);var d=new Se(null===n?new Ee:n);n=u||Object.create(null),u=void 0===o.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":o.defaultFunctionNamespaceURI;var m=Af(e,i,l||Mf(t),r,n,u,p||kf(u));for(e=t?wt(0,t):ge.empty(),t=!h&&i.aa?new dr(t):new Df(h),s=s?new Te(s):Be,h=Object.keys(r).reduce((function(e,t){var n=r[t];return e["Q{}"+t+"[0]"]=n&&"object"==typeof n&&Uf in n?function(){return ge.create(n.Fb)}:function(){return wt(0,r[t])},e}),Object.create(null)),l={},n=(p=c(Object.keys(m.ia.Fa))).next();!n.done;l={Ya:l.Ya},n=p.next())l.Ya=n.value,h[l.Ya]||(h[l.Ya]=function(e){return function(){return(0,m.ia.Fa[e.Ya])(g,y)}}(l));var g=new At({M:e.first(),La:0,Ia:e,Ga:h}),y=new Tt(i.debug,i.Ja,d,t,s,o.currentContext,a,f);return{zb:g,Bb:y,da:m.da}}function Gf(e,t){var n={},r=0,o=!1,i=null;return{next:function(){if(o)return K;for(var a={};r<e.h.length;){e:{var s=e.h[r].key.value;if(!i){a.mb=e.h[r];var u=a.mb.value().$({default:function(e){return e},multiple:function(e){return function(){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 "+e.mb.key.value+" holds multiple items")}}(a)}).first();if(null===u){n[s]=null,r++;break e}i=Hf(u,t)}u=i.next(0),i=null,n[s]=u.value,r++}a={mb:a.mb}}return o=!0,W(n)}}}function Pf(e,t){var n=[],r=0,o=!1,i=null;return{next:function(){if(o)return K;for(;r<e.R.length;){if(!i){var a=e.R[r]().$({default:function(e){return e},multiple:function(){throw Error("Serialization error: The value of an entry in an array is expected to be a single item or an empty sequence. Use nested arrays when putting multiple values in an array.")}}).first();if(null===a){n[r++]=null;continue}i=Hf(a,t)}a=i.next(0),i=null,n[r++]=a.value}return o=!0,W(n)}}}function Hf(e,t){if(ee(e.type,61))return Gf(e,t);if(ee(e.type,62))return Pf(e,t);if(ee(e.type,23)){var n=e.value;return{next:function(){return W("Q{"+(n.namespaceURI||"")+"}"+n.localName)}}}switch(e.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:var r=e.value;return{next:function(){return W(ct(r))}};case 47:case 53:case 54:case 55:case 56:case 57:case 58:var o=e.value;return{next:function(){return W(Kr(o,t,!1))}};default:return{next:function(){return W(e.value)}}}}Rf.forEach((function(e){uo(e.namespaceURI,e.localName,e.l,e.i,e.m)}));var _f={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};function jf(e,t,n,r){switch(n){case 3:return t.getEffectiveBooleanValue();case 2:return(t=Ut(t,r).N()).length?t.map((function(e){return Kt(e,1).value})).join(" "):"";case 10:return(t=Ut(t,r).N()).length?t.map((function(e){return e.value+""})):[];case 1:return null!==(t=t.first())&&ee(t.type,2)?t.value:NaN;case 9:if(null===(t=t.first()))return null;if(!ee(t.type,53))throw Error("Expected XPath "+no(e)+" to resolve to Node. Got "+ie[t.type]);return Kr(t.value,r,!1);case 7:if(!(t=t.N()).every((function(e){return ee(e.type,53)})))throw Error("Expected XPath "+no(e)+" to resolve to a sequence of Nodes.");return t.map((function(e){return Kr(e.value,r,!1)}));case 11:if(1!==(t=t.N()).length)throw Error("Expected XPath "+no(e)+" to resolve to a single map.");if(!ee((t=t[0]).type,61))throw Error("Expected XPath "+no(e)+" to resolve to a map");return Gf(t,r).next(0).value;case 12:if(1!==(t=t.N()).length)throw Error("Expected XPath "+no(e)+" to resolve to a single array.");if(!ee((t=t[0]).type,62))throw Error("Expected XPath "+no(e)+" to resolve to an array");return Pf(t,r).next(0).value;case 13:return t.N().map((function(t){if(!ee(t.type,2))throw Error("Expected XPath "+no(e)+" to resolve to numbers");return t.value}));case 99:var o=t.value,i=null,a=!1,s=function(){for(;!a;){if(!i){var e=o.next(0);if(e.done){a=!0;break}i=Hf(e.value,r)}return e=i.next(0),i=null,e}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?((t={})[Symbol.asyncIterator]=function(){return this},t.next=function(){return new Promise((function(e){return e(s())})).catch((function(t){oo(e,t)}))}):t={next:function(){return new Promise((function(e){return e(s())}))}},t;case 14:return t.N().map((function(e){return Hf(e,r).next(0).value}));default:return(t=t.N()).every((function(e){return ee(e.type,53)&&!ee(e.type,47)}))?(t=t.map((function(e){return Kr(e.value,r,!1)})),1===t.length?t[0]:t):1===t.length?ee((t=t[0]).type,62)?Pf(t,r).next(0).value:ee(t.type,61)?Gf(t,r).next(0).value:Dt(t,r).first().value:Ut(ge.create(t),r).N().map((function(e){return e.value}))}}_f[_f.ANY]="ANY",_f[_f.NUMBER]="NUMBER",_f[_f.STRING]="STRING",_f[_f.BOOLEAN]="BOOLEAN",_f[_f.NODES]="NODES",_f[_f.FIRST_NODE]="FIRST_NODE",_f[_f.STRINGS]="STRINGS",_f[_f.MAP]="MAP",_f[_f.ARRAY]="ARRAY",_f[_f.NUMBERS]="NUMBERS",_f[_f.ALL_RESULTS]="ALL_RESULTS",_f[_f.ASYNC_ITERATOR]="ASYNC_ITERATOR";var Xf=!1,Lf=null,$f={getPerformanceSummary:function(){var e=Lf.getEntriesByType("measure").filter((function(e){return e.name.startsWith("XPath: ")}));return Array.from(e.reduce((function(e,t){var n=t.name.substring(7);return e.has(n)?((n=e.get(n)).times+=1,n.totalDuration+=t.duration):e.set(n,{xpath:n,times:1,totalDuration:t.duration,average:0}),e}),new Map).values()).map((function(e){return e.average=e.totalDuration/e.times,e})).sort((function(e,t){return t.totalDuration-e.totalDuration}))},setPerformanceImplementation:function(e){Lf=e},startProfiling:function(){if(null===Lf)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");Lf.clearMarks(),Lf.clearMeasures(),Xf=!0},stopProfiling:function(){Xf=!1}},qf=0;function Vf(e,t,n,r,o,i){if(o=o||0,!e||"string"!=typeof e&&!("nodeType"in e))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");i=i||{};try{var a=Ff(e,t,n||null,r||{},i,{sa:"XQueryUpdate3.1"===i.language,aa:"XQuery3.1"===i.language||"XQueryUpdate3.1"===i.language,debug:!!i.debug,Ja:!!i.disableCache}),s=a.zb,u=a.Bb,c=a.da}catch(t){oo(e,t)}if(c.I)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(3===o&&t&&"object"==typeof t&&"nodeType"in t&&(n=c.A(),t=be(t),null!==n&&!t.includes(n)))return!1;try{t=e,Xf&&("string"!=typeof t&&(t=no(t)),Lf.mark(t+(0===qf?"":"@"+qf)),qf++);var l=jf(e,hr(c,s,u),o,u);return o=e,Xf&&("string"!=typeof o&&(o=no(o)),s=o+(0===--qf?"":"@"+qf),Lf.measure("XPath: "+o,s),Lf.clearMarks(s)),l}catch(t){oo(e,t)}}Object.assign(Vf,{Jc:14,ANY_TYPE:0,Rb:12,Sb:99,BOOLEAN_TYPE:3,Wb:9,jc:11,mc:7,qc:13,NUMBER_TYPE:1,tc:10,STRING_TYPE:2,Kc:"XPath3.1",Lc:"XQuery3.1",xc:"XQueryUpdate3.1"});var Yf={};function Qf(e,t,n,r,o){return Vf(e,t,n,r,Vf.Sb,o)}function Jf(e,t,n,r){var o={};return o.pendingUpdateList=e.fa.map((function(e){return e.h(r)})),o.xdmValue=jf(t,ge.create(e.H),n,r),o}function zf(e,t,n){switch(t.type){case 0:return[e,{type:0}];case 1:return[e,{type:1}];case 3:return[""+zf(e+"("+(n||"contextItem")+")",t.i,n)[0],t.i];case 4:return[e,{type:4}];case 5:throw Error("Trying to get value of generated code with type None");default:throw Error("Unreachable! Trying to get compiled value of unsupported GeneratedCodeType.")}}function Kf(e,t,n){return{code:e,Aa:t,isAstAccepted:!0,wa:n}}function Wf(e){return{isAstAccepted:!1,reason:e}}function Zf(e,t,n,r){switch(r=void 0===r?"contextItem":r,n.type){case 0:case 1:return Kf("!!"+e,{type:0},[t]);case 3:return(e=Zf(e+"("+r+")","",n.i,r)).isAstAccepted?Kf("!!"+e.code,e.Aa,[t]):e;case 4:return Kf("(() => {\n\t\t\t\t\tconst result = "+e+".next();\n\t\t\t\t\treturn result.done ? false : !!result.value;\n\t\t\t\t})()",{type:0});case 5:throw Error("Trying to get value of generated code with type None");default:throw Error("Unreachable! Trying to get compiled value of unsupported GeneratedCodeType.")}}Object.assign(Vf,(Yf.ALL_RESULTS_TYPE=14,Yf.ANY_TYPE=0,Yf.ARRAY_TYPE=12,Yf.ASYNC_ITERATOR_TYPE=99,Yf.BOOLEAN_TYPE=3,Yf.FIRST_NODE_TYPE=9,Yf.MAP_TYPE=11,Yf.NODES_TYPE=7,Yf.NUMBERS_TYPE=13,Yf.NUMBER_TYPE=1,Yf.STRINGS_TYPE=10,Yf.STRING_TYPE=2,Yf.XPATH_3_1_LANGUAGE="XPath3.1",Yf.XQUERY_3_1_LANGUAGE="XQuery3.1",Yf.XQUERY_UPDATE_3_1_LANGUAGE="XQueryUpdate3.1",Yf));var ed={DONE_TOKEN:K,getEffectiveBooleanValue:le,isSubtypeOf:ee,ready:W},td={sc:"pathExpr",Qb:"andOp",rc:"orOp",uc:"stringConstantExpr",Ub:"equalOp",pc:"notEqualOp",fc:"lessThanOrEqualOp",ec:"lessThanOp",$b:"greaterThanOrEqualOp",Zb:"greaterThanOp",Vb:"eqOp",lc:"neOp",ic:"ltOp",hc:"leOp",ac:"gtOp",Yb:"geOp",cc:"isOp",oc:"nodeBeforeOp",nc:"nodeAfterOp",Xb:"functionCallExpr"},nd=Object.values(td);function rd(e,t,n,r,o){return e=Do(e,n),(e=Do(e,nd))?(t+=n,n=c(r.Ab(e,t,r)),r=n.next().value,n=n.next().value,r.isAstAccepted?0===o?[Zf(t,r.code,r.Aa),null]:[Kf(t,r.Aa,[r.code]),n]:[r,null]):[Wf("Unsupported: a base expression used with an operand."),null]}function od(e,t,n){return 4===t&&(e+=".next().value"),47===n&&(e="(function () { const attr = "+e+"; return attr ? domFacade.getData(attr) : null})()"),e}function id(e,t,n,r,o){var i=Mo(Do(e,"firstOperand")[1],"type");if(e=Mo(Do(e,"secondOperand")[1],"type"),!i||!e)return Wf("Left or right type of compare are not found, annotation failed.");var a=[47,1];if(!a.includes(i.type)||!a.includes(e.type))return Wf("Unsupported types in compare: ["+ie[i.type]+", "+ie[e.type]+"]");if(!n.isAstAccepted)return n;if(!r.isAstAccepted)return r;if(!i||!e)return Wf("Operands in compare weren't annotated");if(!(a=new Map([["eqOp","==="],["neOp","!=="]])).has(t))return Wf(t+" not yet implemented");t=a.get(t),a=zf(n.code,n.Aa);var s=zf(r.code,r.Aa);return Kf("function "+o+"(contextItem) {\n\t\t\t\t"+n.wa.join("\n")+"\n\t\t\t \t"+r.wa.join("\n")+"\n\t \t \treturn "+od(a[0],a[1].type,i.type)+" "+t+" "+od(s[0],s[1].type,e.type)+";\n\t\t}",{type:3,i:{type:0}})}var ad={},sd=(ad.equalOp="eqOp",ad.notEqualOp="neOp",ad.lessThanOrEqualOp="leOp",ad.lessThanOp="ltOp",ad.greaterThanOrEqualOp="geOp",ad.greaterThanOp="gtOp",ad),ud={"local-name":function(e,t,n){return pd(e,t,n,cd,"local-name()")},name:function(e,t,n){return pd(e,t,n,ld,"name()")}};function cd(e){return"("+e+".localName || "+e+".target || '')"}function ld(e){return"((("+e+".prefix || '').length !== 0 ? "+e+".prefix + ':' : '')\n\t\t+ ("+e+".localName || "+e+".target || ''))"}function pd(e,t,n,r,o){if(1===(e=Do(e,"arguments")).length)t="function "+t+"(contextItem) {\n\t\t\tif (contextItem === undefined || contextItem === null) {\n\tthrow new Error('XPDY0002: The function which was called depends on dynamic context, which is absent.');\n}\n\t\t\treturn "+r("contextItem")+";\n\t\t}";else{if(2!==e.length)return Wf("Incorrect arg count for "+o+" function");if(o=e[1],e=(n=c(n.Ab(o,"arg",n))).next().value,n.next(),n=e.isAstAccepted?Kf("arg",e.Aa,[e.code]):e,"contextItemExpr"===o[0])t="function "+t+"(contextItem) {\n\t\t\t\tif (contextItem === undefined || contextItem === null) {\n\tthrow new Error('XPDY0002: The function which was called depends on dynamic context, which is absent.');\n}\n\t\t\t\treturn "+r("contextItem")+";\n\t\t\t}";else{if(!n.isAstAccepted)return n;t="function "+t+"(contextItem) {\n\t\t\t\t"+n.wa+"\n\t\t\t\tconst value = "+zf(n.code,n.Aa)[0]+';\n\t\t\t\tconst childElement = value.next().value;\n\t\t\t\treturn (value.done ? "" : '+r("childElement")+");\n\t\t\t}"}}return Kf(t,{type:3,i:{type:0}})}function hd(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function fd(e,t,n,r){var o=c(rd(e,t,"firstOperand",n,0)),i=o.next().value;return o=o.next().value,i.isAstAccepted?(e=(n=c(rd(e,t,"secondOperand",n,0))).next().value,n=n.next().value,e.isAstAccepted?[Kf("\n\tfunction "+t+"(contextItem) {\n\t\t"+i.wa.join("\n")+"\n\t\t"+e.wa.join("\n")+"\n\t\treturn "+i.code+" "+r+" "+e.code+";\n\t}\n\t",{type:3,i:{type:0}}),"&&"===r?yi(o,n):o||n]:[e,null]):[i,null]}function dd(e){for(var t=[],n=0;n<arguments.length;++n)t[n]=arguments[n];return t.filter((function(e){return""!==e})).join(" && ")}function md(e,t,n,r,o,i){var a=1!==n?"i"+n+" = 0;":"";return Kf("\n\t"+i+"\n\twhile ("+dd(o+n,"i"+n+" < "+o+n+".length")+") {\n\t\tconst contextItem"+n+" = "+o+n+"[i"+n+"];\n\t\tif (!("+(e=dd("contextItem"+n,e,t))+")) {\n\t\t\ti"+n+"++;\n\t\t\tcontinue;\n\t\t}\n\t\t"+r+"\n\t}\n\t"+a+"\n\t",{type:2},["let i"+n+" = 0;"])}function gd(e,t,n,r,o){return Kf("\n\t\t"+o+"\n\t\tif ("+(e=dd("i"+n+" === 0","contextItem"+n,e,t))+") {\n\t\t\t"+r+"\n\t\t}\n\t\t",{type:2},["let i"+n+" = 0;"])}var yd={vc:"textTest",Tb:"elementTest",kc:"nameTest",wc:"Wildcard"},vd=Object.values(yd);function wd(e,t,n){if(null===t.namespaceURI&&"*"!==t.prefix){if(!(n=n.ba(t.prefix||"")||null)&&t.prefix)throw Error("XPST0081: The prefix "+t.prefix+" could not be resolved.");t.namespaceURI=n}n=t.prefix;var r=t.namespaceURI;t=t.localName;var o=e+".nodeType\n\t\t&& ("+e+".nodeType === /*ELEMENT_NODE*/ 1\n\t\t|| "+e+".nodeType === /*ATTRIBUTE_NODE*/ 2)";return"*"===n?"*"===t?[Kf(o,{type:0}),null]:[Kf(o+" && "+e+".localName === "+hd(t),{type:0}),"name-"+t]:[Kf((o="*"!==t?o+" && "+e+".localName === "+hd(t)+" && ":"")+"("+e+".namespaceURI || null) === (("+(n=""===n?e+".nodeType\n&& "+e+".nodeType === /*ELEMENT_NODE*/ 1 ? "+hd(r)+" : null":hd(r))+") || null)",{type:0}),"name-"+t]}function Ad(e,t,n){var r=e[0];switch(r){case yd.Tb:return r=(e=Do(e,"elementName"))&&Do(e,"star"),null===e||r?t=[Kf(t+".nodeType === /*ELEMENT_NODE*/ 1",{type:0}),null]:t=wd(t,e=Go(Do(e,"QName")),n),t;case yd.vc:return[Kf(t+".nodeType === /*TEXT_NODE*/ 3",{type:0}),null];case yd.kc:return wd(t,Go(e),n);case yd.wc:return Do(e,"star")?null!==(r=Do(e,"uri"))?t=wd(t,{localName:"*",namespaceURI:Uo(r),prefix:""},n):(r=Do(e,"NCName"),t="star"===Do(e,"*")[0]?wd(t,{localName:Uo(r),namespaceURI:null,prefix:"*"},n):wd(t,{localName:"*",namespaceURI:null,prefix:Uo(r)},n)):t=wd(t,{localName:"*",namespaceURI:null,prefix:"*"},n),t;default:return[Wf("Unsupported: the test '"+r+"'."),null]}}function xd(e,t,n){var r=e[0];switch(r){case td.sc:r="",Do(e,"rootExpr")&&(r="\n\t\tlet documentNode = contextItem;\n\t\twhile (documentNode.nodeType !== /*DOCUMENT_NODE*/9) {\n\t\t\tdocumentNode = domFacade.getParentNode(documentNode);\n\t\t\tif (documentNode === null) {\n\t\t\t\tthrow new Error('XPDY0050: the root node of the context node is not a document node.');\n\t\t\t}\n\t\t}\n\t\tcontextItem = documentNode;\n\t\t");var o=c(function(e,t){if(0===e.length)return[Kf("\n\t\t\tif (!hasReturned) {\n\t\t\t\thasReturned = true;\n\t\t\t\treturn ready(contextItem);\n\t\t\t}\n\t\t\t",{type:2},["let hasReturned = false;"]),null];for(var n="",r=[],o=null,i=e.length-1;0<=i;i--){var a=e[i],s=i+1,u=Do(a,"predicates");e:{var l=t,h="",f=[];if(u){u=Fo(u,"*");for(var d=null,m=0;m<u.length;m++){var g="step"+s+"_predicate"+m,y=c(l.Ab(u[m],g,l)),v=y.next().value;if(y=y.next().value,!v.isAstAccepted){l=[v,null];break e}if(d=yi(d,y),!(g=Zf(g,"",v.Aa,"contextItem"+s)).isAstAccepted){l=[g,null];break e}h=0===m?h+g.code:h+" && "+g.code,f.push(v.code)}l=[Kf(h,{type:0},f),d]}else l=[Kf("",{type:5},f),null]}if(l=(h=c(l)).next().value,f=h.next().value,!l.isAstAccepted)return[l,null];if(!(h=Do(a,"xpathAxis")))return[Wf("Unsupported: filter expressions."),null];if(!(u=Do(a,vd)))return[Wf("Unsupported: the test in the '"+a+"' step."),null];if(n=i===e.length-1?"i"+s+"++;\n\t\t\t\t\t return ready(contextItem"+s+");":n+"\n\t\t\t\t\t i"+s+"++;",u=(d=c(Ad(u,"contextItem"+s,t))).next().value,d=d.next().value,!u.isAstAccepted)return[u,null];f=yi(d,f);e:switch(u=u.code,d=l.code,h=Uo(h),h){case"attribute":s=[md(u,d,s,n,"attributeNodes","\n\tlet attributeNodes"+s+";\n\tif (contextItem && contextItem"+(s-1)+".nodeType === /*ELEMENT_NODE*/ 1) {\n\t\tattributeNodes"+s+" = domFacade.getAllAttributes(contextItem"+(s-1)+" "+(f?', "'+f+'"':"")+");\n\t}\n\t"),"type-1"];break e;case"child":s=[md(u,d,s,n,"childNodes","const childNodes"+s+" = domFacade.getChildNodes(contextItem"+(s-1)+" "+(f?', "'+f+'"':"")+");"),null];break e;case"parent":s=[gd(u,d,s,n,"\n\tconst contextItem"+s+" = domFacade.getParentNode(contextItem"+(s-1)+" "+(f?', "'+f+'"':"")+");\n\t"),null];break e;case"self":s=[gd(u,d,s,n,"const contextItem"+s+" = contextItem"+(s-1)+";"),f];break e;default:s=[Wf("Unsupported: the "+h+" axis"),null]}if(s=(n=c(s)).next().value,n=n.next().value,!s.isAstAccepted)return[s,null];if(0===i&&(o=n),r.push.apply(r,[].concat(p(s.wa),p(l.wa))),n=s.code,0<Fo(a,"lookup").length)return[Wf("Unsupported: lookups."),null]}return[Kf("const contextItem0 = contextItem;"+n,{type:2},r),o]}(Fo(e,"stepExpr"),n));return e=o.next().value,o=o.next().value,e.isAstAccepted?[Kf("\n\tfunction "+t+"(contextItem) {\n\t\t"+r+"\n\t\t"+e.wa.join("\n")+"\n\t\tconst next = () => {\n\t\t\t"+e.code+"\n\t\t\treturn DONE_TOKEN;\n\t\t};\n\t\treturn {\n\t\t\tnext,\n\t\t\t[Symbol.iterator]() { return this; }\n\t\t};\n\t}\n\t",{type:3,i:{type:4}}),o]:[e,null];case td.Qb:return fd(e,t,n,"&&");case td.rc:return fd(e,t,n,"||");case td.uc:return[Kf("const "+t+" = "+(e=hd(e=Do(e,"value")[1]||""))+";",{type:1}),null];case td.Ub:case td.pc:case td.fc:case td.ec:case td.$b:case td.Zb:case td.Vb:case td.lc:case td.ic:case td.hc:case td.ac:case td.Yb:case td.cc:case td.oc:case td.nc:e:{var i=c(rd(e,t,"firstOperand",n));if(o=i.next().value,i.next(),o.isAstAccepted)if(n=(i=c(rd(e,t,"secondOperand",n))).next().value,i.next(),n.isAstAccepted)switch(r){case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":t=id(e,r,o,n,t);break e;case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":i=Mo(e,"type");var a=Mo(e,"type");t=i&&a?3===i.g&&3===a.g?id(e,sd[r],o,n,t):Wf("generalCompare with sequences is still in development"):Wf("types of compare are not known");break e;default:t=Wf("Unsupported compare type")}else t=n;else t=o}return[t,null];case td.Xb:return r=Uo(Do(e,"functionName")),[void 0!==ud[r]?ud[r](e,t,n):Wf("Unsupported function: "+r),null];default:return[Wf("Unsupported: the base expression '"+r+"'."),null]}}function bd(e,t,n){var r=Do(e,"mainModule");if(!r)return Wf("Unsupported: Can not execute a library module.");if(Do(r,"prolog"))return Wf("Unsupported: XQuery.");r=ko(r,["queryBody","*"]),n.Ab=xd;var o=c(xd(r,"compiledXPathExpression",n));return n=o.next().value,o.next(),!1===n.isAstAccepted?n:(o=n.wa?n.wa.join("\n"):"",r=Mo(r,"type"),t=function(e,t,n){switch(e){case 9:if(e=(n=c(zf("compiledXPathExpression",t))).next().value,4!==n.next().value.type)throw Error("Trying access generated code as an iterator while this is not the case.");return Kf("\n\tconst firstResult = "+e+".next();\n\tif (!firstResult.done) {\n\t\treturn firstResult.value\n\t}\n\treturn null;\n\t",{type:2});case 7:return e=(n=c(zf("compiledXPathExpression",t))).next().value,4!==n.next().value.type?Wf("Return type was not an iterator"):Kf("\n\tconst nodes = [];\n\tfor (const node of "+e+") {\n\t\tnodes.push(node);\n\t}\n\treturn nodes;\n\t",{type:2});case 3:return(n=Zf("compiledXPathExpression","",t)).isAstAccepted?Kf("return "+n.code+";",{type:2}):n;case 2:return n=void 0===n?Wf("Full AST wasn't annotated so we cannot correctly emit a string return"):ee(n,1)||ee(n,47)?Kf("return "+od(e=(t=c(zf("compiledXPathExpression",t))).next().value,(t=t.next().value).type,n)+" || '';",{type:2}):Wf("Not implemented: returning anything but strings and attributes from codegen");default:return Wf("Unsupported: the return type '"+e+"'.")}}(t,n.Aa,r?r.type:void 0),!1===t.isAstAccepted?t:(t=o+n.code+t.code,n="\n\treturn (contextItem, domFacade, runtimeLib) => {\n\t\tconst {\n\t\t\tDONE_TOKEN,\n\t\t\tValueType,\n\t\t\tXPDY0002,\n\t\t\tdeterminePredicateTruthValue,\n\t\t\tisSubtypeOf,\n\t\t\tready,\n\t\t\tatomize,\n\t\t} = runtimeLib;",Ed(e)&&(n+='\n\t\tif (!contextItem) {\n\t\t\tthrow XPDY0002("Context is needed to evaluate the given path expression.");\n\t\t}\n\n\t\tif (!contextItem.nodeType) {\n\t\t\tthrow new Error("Context item must be subtype of node().");\n\t\t}\n\t\t'),{code:n+(t+"}\n//# sourceURL=generated.js"),isAstAccepted:!0}))}function Ed(e){var t=Fo(e,"*");if("pathExpr"===e[0])return!0;for(t=(e=c(t)).next();!t.done;t=e.next())if(Ed(t.value))return!0;return!1}var Nd={},Bd=(Nd["http://www.w3.org/2005/XQueryX"]="xqx",Nd["http://www.w3.org/2007/xquery-update-10"]="xquf",Nd["http://fontoxml.com/fontoxpath"]="x",Nd);function Td(e,t,n,r,o){if("string"==typeof n)return 0===n.length?null:t.createTextNode(n);if(!Array.isArray(n))throw new TypeError("JsonML element should be an array or string");r=function(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,tb:t||"http://www.w3.org/2005/XQueryX"};case"deleteExpr":case"insertExpr":case"renameExpr":case"replaceExpr":case"transformExpr":return{localName:e,tb:"http://www.w3.org/2007/xquery-update-10"};case"x:stackTrace":return{localName:"stackTrace",tb:"http://fontoxml.com/fontoxpath"};default:return{localName:e,tb:"http://www.w3.org/2005/XQueryX"}}}(n[0],r);var i=r.localName;r=r.tb;var a=t.createElementNS(r,Bd[r]+":"+i),s=n[1],u=1;if("object"==typeof s&&!Array.isArray(s)){if(null!==s)for(var l=(u=c(Object.keys(s))).next();!l.done;l=u.next()){var p=s[l=l.value];null!==p&&("type"===l?void 0!==p&&e.setAttributeNS(a,r,"fontoxpath:"+l,se(p)):("start"!==l&&"end"!==l||"stackTrace"!==i||(p=JSON.stringify(p)),o&&"prefix"===l&&""===p||e.setAttributeNS(a,r,Bd[r]+":"+l,p)))}u=2}for(i=u,s=n.length;i<s;++i)null!==(u=Td(e,t,n[i],r,o))&&e.insertBefore(a,u,null);return a}function Id(e,t,n){var r=e.stack;r&&(r.includes(e.message)&&(r=r.substr(r.indexOf(e.message)+e.message.length).trim()),(r=r.split("\n")).splice(10),r=r.map((function(e){return e.startsWith(" ")||e.startsWith("\t")?e:" "+e})),r=r.join("\n")),e=Error.call(this,"Custom XPath function Q{"+n+"}"+t+" raised:\n"+e.message+"\n"+r),this.message=e.message,"stack"in e&&(this.stack=e.stack)}function Cd(e,t,n){return 0===t.g?e.G()?null:Hf(e.first(),n).next(0).value:2===t.g||1===t.g?e.N().map((function(e){if(ee(e.type,47))throw Error("Cannot pass attribute nodes to custom functions");return Hf(e,n).next(0).value})):Hf(e.first(),n).next(0).value}y(Id,Error);var Sd=new Map;function Od(e){var t;e:{if(t=Os.get(e))for(var n=c(Object.keys(t)),r=n.next();!r.done;r=n.next())if(t[r=r.value]&&t[r].length){t=t[r][0].h;break e}t=null}if(t)return t;if(Sd.has(e))return Sd.get(e);if(null===(t=ko(t="string"==typeof e?gf(e,{aa:!1}):Us(e),["mainModule","queryBody","*"])))throw Error("Library modules do not have a specificity");return t=Ss(t,{sa:!1,aa:!1}),Sd.set(e,t),t}var Rd=new Ee;return void 0!==n&&(n.compareSpecificity=function(e,t){return Tr(Od(e).s,Od(t).s)},n.compileXPathToJavaScript=function(e,t,n){n=n||{},t=t||0,"string"==typeof e?e=gf(e=Gs(e),{aa:"XQuery3.1"===n.language||"XQueryUpdate3.1"===n.language,debug:!1}):e=Us(e);var r=Do(e,"mainModule");return r?Do(r,"prolog")?Wf("Unsupported: XQuery Prologs are not supported."):(ti(e,n=new ci(new No(new po((r={ba:n.namespaceResolver||Mf(null)}).ba,{},void 0===n.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":n.defaultFunctionNamespaceURI,n.functionNameResolver||kf("http://www.w3.org/2005/xpath-functions"))))),bd(e,t,r)):Wf("Unsupported: XQuery Library modules are not supported.")},n.domFacade=Rd,n.evaluateXPath=Vf,n.evaluateXPathToArray=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.Rb,o)},n.evaluateXPathToAsyncIterator=Qf,n.evaluateXPathToBoolean=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.BOOLEAN_TYPE,o)},n.evaluateXPathToFirstNode=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.Wb,o)},n.evaluateXPathToMap=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.jc,o)},n.evaluateXPathToNodes=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.mc,o)},n.evaluateXPathToNumber=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.NUMBER_TYPE,o)},n.evaluateXPathToNumbers=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.qc,o)},n.evaluateXPathToString=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.STRING_TYPE,o)},n.evaluateXPathToStrings=function(e,t,n,r,o){return Vf(e,t,n,r,Vf.tc,o)},n.evaluateUpdatingExpression=function(e,t,n,r,o){var i,a,s,u,c,l,p,h,f,d;return function(e){function t(t){return e.next(t)}function n(t){return e.throw(t)}return new Promise((function(r,o){!function e(i){i.done?r(i.value):Promise.resolve(i.value).then(t,n).then(e,o)}(e.next())}))}(new N(new x((function(m){switch(m.h){case 1:o=o||{};try{u=Ff(e,t,n||null,r||{},o||{},{sa:!0,aa:!0,debug:!!o.debug,Ja:!!o.disableCache}),i=u.zb,a=u.Bb,s=u.da}catch(t){oo(e,t)}if(s.I){m.h=2;break}c=[];var g=(l=Qf(e,t,n,r,Object.assign(Object.assign({},o),{language:"XQueryUpdate3.1"}))).next();return m.h=3,{value:g};case 3:p=m.u;case 4:if(p.done){m.h=6;break}return c.push(p.value),g=l.next(),m.h=7,{value:g};case 7:p=m.u,m.h=4;break;case 6:return h={},m.return(Promise.resolve((h.pendingUpdateList=[],h.xdmValue=c,h)));case 2:try{d=s.u(i,a),f=d.next(0)}catch(t){oo(e,t)}return m.return(Jf(f.value,e,o.returnType,a))}}))))},n.evaluateUpdatingExpressionSync=function(e,t,n,r,o){o=o||{};try{var i=Ff(e,t,n||null,r||{},o||{},{sa:!0,aa:!0,debug:!!o.debug,Ja:!!o.disableCache}),a=i.zb,s=i.Bb,u=i.da}catch(t){oo(e,t)}if(!u.I)return a={},(s={}).pendingUpdateList=[],s.xdmValue=Vf(e,t,n,r,o.i,Object.assign(Object.assign({},o),(a.language=Vf.xc,a))),s;try{var c=u.u(a,s).next(0)}catch(t){oo(e,t)}return Jf(c.value,e,o.returnType,s)},n.executeJavaScriptCompiledXPath=function(e,t,n){return n=n||new Ee,e()(t,n,ed)},n.executePendingUpdateList=function(e,t,n,r){t=new Se(t||new Ee),r=r?new Te(r):Be,n=n?n=new Df(n):null,yr(e=e.map(us),t,n,r)},n.getBucketForSelector=function(e){return Od(e).A()},n.getBucketsForNode=be,n.precompileXPath=function(e){return Promise.resolve(e)},n.registerXQueryModule=function(e,t){if(ei(t=gf(e,{aa:!0,debug:(t=void 0===t?{debug:!1}:t).debug}),new ci(void 0)),!(t=Do(t,"libraryModule")))throw Error("XQuery module must be declared in a library module.");var n=Do(t,"moduleDecl"),r=Do(n,"uri"),o=Uo(r);if(r=Uo(n=Do(n,"prefix")),Co(n=new No(new po((function(){return null}),Object.create(null),"http://www.w3.org/2005/xpath-functions",kf("http://www.w3.org/2005/xpath-functions"))),r,o),null!==(t=Do(t,"prolog"))){try{var i=vf(t,n)}catch(t){oo(e,t)}i.Oa.forEach((function(e){if(o!==e.namespaceURI)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.")})),ks(o,i)}else ks(o,{Oa:[],Wa:[]});return o},n.registerCustomXPathFunction=function(e,t,n,r){e=function(e){if("object"==typeof e)return e;if(2!==(e=e.split(":")).length)throw Error("Do not register custom functions in the default function namespace");var t=c(e);e=t.next().value,t=t.next().value;var n=lo[e];if(!n){if(n="generated_namespace_uri_"+e,lo[e])throw Error("Prefix already registered: Do not register the same prefix twice.");lo[e]=n}return{localName:t,namespaceURI:n}}(e);var o=e.namespaceURI,i=e.localName;if(!o)throw yo();var a=t.map((function(e){return ce(e)})),s=ce(n);uo(o,i,a,s,(function(e,t,n){var u=Array.from(arguments);u.splice(0,3),u=u.map((function(e,n){return Cd(e,a[n],t)}));var c={};c.currentContext=t.u,c.domFacade=t.h.h;try{var l=r.apply(void 0,[c].concat(p(u)))}catch(e){throw new Id(e,i,o)}return l&&"object"==typeof l&&Object.getOwnPropertySymbols(l).includes(Uf)?ge.create(l.Fb):wt(t.h,l,s)}))},n.parseScript=function(e,t,n,r){r=void 0===r?Be:r;var o=gf(e=Gs(e),{aa:"XQuery3.1"===t.language||"XQueryUpdate3.1"===t.language,debug:t.debug}),i=new po(t.namespaceResolver||function(){return null},{},void 0===t.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":t.defaultFunctionNamespaceURI,t.functionNameResolver||function(){return null});i=new No(i);var a=Do(o,["mainModule","libraryModule"]),s=Do(a,"moduleDecl");return s&&Co(i,Uo(Do(s,"prefix")),s=Uo(Do(s,"uri"))),(a=Do(a,"prolog"))&&vf(a,i,!1),!1!==t.annotateAst&&ei(o,new ci(i)),i=new Ee,t=Td(r,n,o,null,!1===t.Mc),r.insertBefore(t,n.createComment(e),i.getFirstChild(t)),t},n.profiler=$f,n.createTypedValueFactory=function(e){return function(t,n){return t=vt(new Se(null===n?new Ee:n),t,ce(e)),(n={})[Uf]=!0,n.Fb=t,n}},n.Language={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"},n.ReturnType=_f),n}.call("undefined"==typeof window?void 0:window,be,_e);je.compareSpecificity,je.compileXPathToJavaScript,je.createTypedValueFactory,je.domFacade,je.evaluateUpdatingExpression,je.evaluateUpdatingExpressionSync;const Xe=je.evaluateXPath;je.evaluateXPathToArray,je.evaluateXPathToAsyncIterator;const Le=je.evaluateXPathToBoolean,$e=je.evaluateXPathToFirstNode;je.evaluateXPathToMap;const qe=je.evaluateXPathToNodes,Ve=je.evaluateXPathToNumber;je.evaluateXPathToNumbers;const Ye=je.evaluateXPathToString,Qe=je.evaluateXPathToStrings;je.executeJavaScriptCompiledXPath,je.executePendingUpdateList,je.getBucketForSelector;const Je=je.getBucketsForNode;je.Language;const ze=je.parseScript;je.precompileXPath,je.profiler;const Ke=je.registerCustomXPathFunction,We=je.registerXQueryModule;je.ReturnType;class Ze{constructor(e){this._onNodeTouched=e}getAllAttributes(e){return Array.from(e.attributes)}getAttribute(e,t){return e.getAttribute(t)}getChildNodes(e,t){const n=Array.from(e.childNodes).filter((e=>!t||Je(e).includes(t)));return n.forEach((e=>this._onNodeTouched(e))),n}getData(e){return e.nodeType===Node.ATTRIBUTE_NODE?(this._onNodeTouched(e),e.value):(this._onNodeTouched(e.parentNode),e.data)}getFirstChild(e,t){for(const n of e.childNodes)if(!t||Je(n).includes(t))return this._onNodeTouched(n),n;return null}getLastChild(e,t){const n=e.getChildNodes().filter((e=>!t||Je(e).includes(t))),r=n[n.length-1];return r||null}getNextSibling(e,t){for(let n=e.nextSibling;n;n=n.nextSibling)if(Je(n).includes(t))return this._onNodeTouched(n),n;return null}getParentNode(e){return e.parentNode}getPreviousSibling(e,t){for(let{previousSibling:n}=e;n;n=n.previousSibling)if(Je(n).includes(t))return n;return null}}class et{static getParentBindingElement(e){return e.parentNode&&e.parentNode.nodeType!==Node.DOCUMENT_NODE?e.parentNode.hasAttribute("ref")?e.parentNode:et.getParentBindingElement(e.parentNode):null}static isAbsolutePath(e){return null!=e&&(e.startsWith("/")||e.startsWith("instance("))}static isSelfReference(e){return"."===e||"./text()"===e||"text()"===e||""===e||null===e}static getInstanceId(e){if(!e)return"default";if(e.startsWith("instance()"))return"default";if(e.startsWith("instance(")){const t=e.substring(e.indexOf("(")+1);return t.substring(1,t.indexOf(")")-1)}return null}static resolveInstance(e){const t=et.getInstanceId(e.getAttribute("ref"));if(null!==t)return t;const n=et.getParentBindingElement(e);return n?this.resolveInstance(n):"default"}static getPath(e){const t=Ye("path()",e);return et.shortenPath(t)}static shortenPath(e){const t=e.replaceAll(/(Q{(.*?)\})/g,""),n=t.substring(1,t.length);return n.substring(n.indexOf("/"),t.length)}static getBasePath(e){return e.split(":")[0]}}function tt(e,t,n,r){const o={};return function(i){if(o[i])return;const a={},s=[],u=[];for(u.push({node:i,processed:!1});u.length>0;){const i=u[u.length-1],{processed:c}=i,{node:l}=i;if(c)u.pop(),s.pop(),a[l]=!1,o[l]=!0,t&&0!==e[l].length||n.push(l);else{if(o[l]){u.pop();continue}if(a[l]){if(r){u.pop();continue}throw s.push(l),window.dispatchEvent(new CustomEvent("compute-exception",{composed:!1,bubbles:!0,detail:{path:s,message:"cyclic graph"}})),new Error(`Cyclic at ${s}`)}a[l]=!0,s.push(l);const t=e[l];for(let e=t.length-1;e>=0;e-=1)u.push({node:t[e],processed:!1});i.processed=!0}}}}function nt(e){this.nodes={},this.outgoingEdges={},this.incomingEdges={},this.circular=e&&!!e.circular}nt.prototype={size(){return Object.keys(this.nodes).length},addNode(e,t){this.hasNode(e)||(this.nodes[e]=2===arguments.length?t:e,this.outgoingEdges[e]=[],this.incomingEdges[e]=[])},removeNode(e){this.hasNode(e)&&(delete this.nodes[e],delete this.outgoingEdges[e],delete this.incomingEdges[e],[this.incomingEdges,this.outgoingEdges].forEach((t=>{Object.keys(t).forEach((n=>{const r=t[n].indexOf(e);r>=0&&t[n].splice(r,1)}),this)})))},hasNode(e){return Object.prototype.hasOwnProperty.call(this.nodes,e)},getNodeData(e){if(this.hasNode(e))return this.nodes[e];throw new Error(`Node does not exist: ${e}`)},setNodeData(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);this.nodes[e]=t},addDependency(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);if(!this.hasNode(t))throw new Error(`Node does not exist: ${t}`);return-1===this.outgoingEdges[e].indexOf(t)&&this.outgoingEdges[e].push(t),-1===this.incomingEdges[t].indexOf(e)&&this.incomingEdges[t].push(e),!0},removeDependency(e,t){let n;this.hasNode(e)&&(n=this.outgoingEdges[e].indexOf(t),n>=0&&this.outgoingEdges[e].splice(n,1)),this.hasNode(t)&&(n=this.incomingEdges[t].indexOf(e),n>=0&&this.incomingEdges[t].splice(n,1))},clone(){const e=this,t=new nt;return Object.keys(e.nodes).forEach((n=>{t.nodes[n]=e.nodes[n],t.outgoingEdges[n]=e.outgoingEdges[n].slice(0),t.incomingEdges[n]=e.incomingEdges[n].slice(0)})),t},directDependenciesOf(e){if(this.hasNode(e))return this.outgoingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},directDependantsOf(e){if(this.hasNode(e))return this.incomingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},dependenciesOf(e,t){if(this.hasNode(e)){const n=[];tt(this.outgoingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},dependantsOf(e,t){if(this.hasNode(e)){const n=[];tt(this.incomingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},entryNodes(){const e=this;return Object.keys(this.nodes).filter((t=>0===e.incomingEdges[t].length))},overallOrder(e){const t=this,n=[],r=Object.keys(this.nodes);if(0===r.length)return n;if(!this.circular){const e=tt(this.outgoingEdges,!1,[],this.circular);r.forEach((t=>{e(t)}))}const o=tt(this.outgoingEdges,e,n,this.circular);return r.filter((e=>0===t.incomingEdges[e].length)).forEach((e=>{o(e)})),this.circular&&r.filter((e=>-1===n.indexOf(e))).forEach((e=>o(e))),n}},nt.prototype.directDependentsOf=nt.prototype.directDependantsOf,nt.prototype.dependentsOf=nt.prototype.dependantsOf;class rt{static getFore(e){return e.nodeType===Node.TEXT_NODE?e.parentNode.closest("fx-fore"):e.closest("fx-fore")}static get ACTION_ELEMENTS(){return["FX-ACTION","FX-DELETE","FX-DISPATCH","FX-HIDE","FX-INSERT","FX-LOAD","FX-MESSAGE","FX-REBUILD","FX-RECALCULATE","FX-REFRESH","FX-RENEW","FX-RELOAD","FX-REPLACE","FX-RESET","FX-RETAIN","FX-RETURN","FX-REVALIDATE","FX-SEND","FX-SETFOCUS","FX-SETINDEX","FX-SETVALUE","FX-SHOW","FX-TOGGLE","FX-UPDATE"]}static createUUID(){const e=[],t="0123456789abcdef";for(let n=0;n<36;n+=1)e[n]=t.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";return e.join("")}static get XFORMS_NAMESPACE_URI(){return"http://www.w3.org/2002/xforms"}static isActionElement(e){return rt.ACTION_ELEMENTS.includes(e)}static get UI_ELEMENTS(){return["FX-ALERT","FX-CONTROL","FX-DIALOG","FX-FILENAME","FX-MEDIATYPE","FX-GROUP","FX-HINT","FX-ITEMS","FX-OUTPUT","FX-RANGE","FX-REPEAT","FX-REPEATITEM","FX-REPEAT-ATTRIBUTES","FX-SWITCH","FX-SECRET","FX-SELECT","FX-SUBMIT","FX-TEXTAREA","FX-TRIGGER","FX-UPLOAD","FX-VAR"]}static get MODEL_ELEMENTS(){return["FX-BIND","FX-FUNCTION","FX-MODEL","FX-INSTANCE","FX-SUBMISSION"]}static isUiElement(e){return rt.UI_ELEMENTS.includes(e)}static async refreshChildren(e,t){return new Promise((n=>{const{children:r}=e;r&&Array.from(r).forEach((e=>{"FX-FORE"===e.nodeName.toUpperCase()&&n("done"),rt.isUiElement(e.nodeName)&&"function"==typeof e.refresh?e.refresh(t):"FX-MODEL"!==e.nodeName.toUpperCase()&&rt.refreshChildren(e,t)})),n("done")}))}static copyDom(e){console.time("convert");const t=(new DOMParser).parseFromString("<fx-fore></fx-fore>","text/html");console.log("copyDom new doc",t),console.log("copyDom new body",t.body),console.log("copyDom new body",t.querySelector("fx-fore"));const n=t.querySelector("fx-fore");return this.convertFromSimple(e,n),n.removeAttribute("convert"),console.log("converted",n),n}static convertFromSimple(e,t){const n=e.childNodes;n&&Array.from(n).forEach((e=>{const n=`FX-${e.nodeName.toUpperCase()}`;if(rt.MODEL_ELEMENTS.includes(n)||rt.UI_ELEMENTS.includes(n)||rt.ACTION_ELEMENTS.includes(n)){const r=t.ownerDocument.createElement(n);console.log("conv",e,r),t.appendChild(r),rt.copyAttributes(e,r),rt.convertFromSimple(e,r)}else{if(e.nodeType===Node.TEXT_NODE){const n=t.ownerDocument.createTextNode(e.textContent);t.appendChild(n)}if(e.nodeType===Node.ELEMENT_NODE){const n=t.ownerDocument.createElement(e.nodeName);t.appendChild(n),rt.copyAttributes(e,t),rt.convertFromSimple(e,n)}}}))}static copyAttributes(e,t){return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.nodeName,e.nodeValue)}))}static getClosest(e,t){for(;!t.matches(e);){if(t.matches("fx-fore"))return null;if(!(t=t.parentNode))return null}return t}static getContentType(e,t){return"application/x-www-form-urlencoded"===t?"application/x-www-form-urlencoded; charset=UTF-8":"xml"===e.type?"application/xml; charset=UTF-8":"json"===e.type?"application/json":(console.warn("content-type unknown ",e.type),null)}static fadeInElement(e){let t=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),t=e.animate({opacity:[0,1]},600),t.finished);return t()}static fadeOutElement(e,t){let n=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),n=e.animate({opacity:[1,0]},t),n.finished);return n()}static async dispatch(e,t,n){const r=new CustomEvent(t,{composed:!1,bubbles:!0,detail:n});r.listenerPromises=[],e.dispatchEvent(r),r.listenerPromises.length&&await Promise.all(r.listenerPromises)}static prettifyXml(e){const t=(new DOMParser).parseFromString(e,"application/xml"),n=(new DOMParser).parseFromString(['<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',' <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>',' <xsl:strip-space elements="*"/>',' <xsl:template match="text()">',' <xsl:value-of select="normalize-space(.)"/>'," </xsl:template>",' <xsl:template match="node()|@*">'," <xsl:copy>",' <xsl:apply-templates select="node()|@*"/>'," </xsl:copy>"," </xsl:template>","</xsl:stylesheet>"].join("\n"),"application/xml"),r=new XSLTProcessor;r.importStylesheet(n);const o=r.transformToDocument(t);return(new XMLSerializer).serializeToString(o)}static formatXml(e){for(var t=(e=e.replace(/(>)(<)(\/*)/g,"$1\n$2$3").replace(/ *(.*) +\n/g,"$1\n").replace(/(<.+>)(.+\n)/g,"$1\n$2")).split("\n"),n=0;n<t.length;n++){var r=t[n];Boolean(r.match(/<.+\/>/)),Boolean(r.match(/<\/.+>/)),Boolean(r.match(/<[^!].*>/))}}static async loadForeFromUrl(e,t){console.log("########## loading Fore from ",this.src,"##########"),await fetch(t,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":"text/html"}}).then((e=>{const t=e.headers.get("content-type").toLowerCase();return console.log("********** responseContentType *********",t),t.startsWith("text/html")?e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done"})).then((t=>{const n=t.querySelector("fx-fore");n||e.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{message:"cyclic graph"}}));const r=document.importNode(n,!0);console.log(`########## loaded fore as component ##### ${e.url}`),r.addEventListener("model-construct-done",(t=>{console.log("subcomponent ready",t.target);const n=r.querySelector("fx-instance");if(e.initialNode){const t=(new DOMParser).parseFromString("<data></data>","application/xml");t.firstElementChild.appendChild(e.initialNode.cloneNode(!0)),n.setInstanceData(t)}return r.getModel().updateModel(),r.refresh(),"done"}),{once:!0});const o=e.querySelector("input");e.hasAttribute("shadow")?(o.parentNode.removeChild(o),e.shadowRoot.appendChild(r)):(console.log(this,"replacing widget with",n),o.replaceWith(r))}))}}rt.READONLY_DEFAULT=!1,rt.REQUIRED_DEFAULT=!1,rt.RELEVANT_DEFAULT=!0,rt.CONSTRAINT_DEFAULT=!0,rt.TYPE_DEFAULT="xs:string";const ot="http://www.w3.org/2002/xforms",it=new Map,at=[];function st(e,t,n){return it.has(e)?it.get(e).set(t,n):it.set(e,new Map)}const ut=e=>{if(!e)return"http://www.w3.org/1999/xhtml"};function ct(e,t,n=null){const r=qe("outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]",t,null,{id:e},{namespaceResolver:ut});if(0===r.length)return null;if(1===r.length&&Le("(ancestor::fx-fore | ancestor::fx-repeat)[last()]/self::fx-fore",r[0],null,null,{namespaceResolver:ut})){const e=r[0];return n&&e.localName!==n?null:e}for(const e of qe("ancestor::fx-repeatitem => reverse()",t,null,null,{namespaceResolver:ut})){const t=r.filter((t=>e.contains(t)));switch(t.length){case 0:break;case 1:{const e=t[0];return n&&e.localName!==n?null:e}default:{const e=t.find((e=>qe("every $ancestor of ancestor::fx-repeatitem satisfies $ancestor is $ancestor/../child::fx-repeatitem[../@repeat-index]",e,null,{})));return e?n&&e.localName!==n?null:e:null}}}return null}const lt=(new DOMParser).parseFromString("<xml />","text/xml");function pt(e,t){const n=(r=e,o=t,it.has(r)&&it.get(r).get(o)||null);var r,o;if(n)return n;let i=function(e){if(!e.includes("instance"))return[];const t=ze(e,{},lt);return Qe('descendant::xqx:functionCallExpr\n\t\t\t\t[xqx:functionName = "instance"]\n\t\t\t\t/xqx:arguments\n\t\t\t\t/xqx:stringConstantExpr\n\t\t\t\t/xqx:value',t,null,{},{namespaceResolver:e=>"xqx"===e?"http://www.w3.org/2005/XQueryX":void 0})}(e);if(0===i.length){const n=t.parentNode&&t.parentNode.nodeType===t.ELEMENT&&t.parentNode.closest("[ref]");if(n){const r=pt(n.getAttribute("ref"),n);return st(e,t,r),r}i=["default"]}if(1===i.length){let n;if("default"===i[0]){const e=$e("ancestor-or-self::fx-fore[1]",t,null,null,{namespaceResolver:ut});n=e&&e.querySelector("fx-instance")}else n=ct(i[0],t,"fx-instance");if(n&&n.hasAttribute("xpath-default-namespace")){const r=n.getAttribute("xpath-default-namespace"),o=e=>{if(!e)return r};return st(e,t,o),o}}i.length>1&&console.warn(`More than one instance is used in the query "${e}". The default namespace resolving will be used`);const a=Ye("ancestor-or-self::*/@xpath-default-namespace[last()]",t)||"",s=function(e){return""===e?a:Ye('ancestor-or-self::*/@*[name() = "xmlns:" || $prefix][last()]',t,null,{prefix:e})};return st(e,t,s),s}function ht(e,t,n){return(t&&t.ownerDocument||t)===window.document?ut:pt(e,n)}function ft({prefix:e,localName:t},n){switch(t){case"context":case"base64encode":case"boolean-from-string":case"current":case"depends":case"event":case"index":case"instance":case"log":case"parse":case"logtree":return{namespaceURI:ot,localName:t};default:return""===e&&at.includes(t)?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:"fn"===e||""===e?{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:t}:"local"===e?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:null}}function dt(e){let t=e;for(;t&&!("inScopeVariables"in t);)t=t.parentNode;if(!t)return{};const n={};if(t.inScopeVariables)for(const e of t.inScopeVariables.keys()){const r=t.inScopeVariables.get(e);r&&(n[e]=r.value)}return n}function mt(e,t,n,r={},o={}){const i=ht(e,t,n),a=dt(n);return Xe(e,t,null,{...a,...r},Xe.ALL_RESULTS_TYPE,{currentContext:{formElement:n,variables:r},moduleImports:{xf:ot},functionNameResolver:ft,namespaceResolver:i,language:o.language||mt.XPATH_3_1})}function gt(e,t,n){const r=ht(e,t,n),o=dt(n);return $e(e,t,null,o,{defaultFunctionNamespaceURI:ot,moduleImports:{xf:ot},currentContext:{formElement:n},functionNameResolver:ft,namespaceResolver:r})}function yt(e,t,n){const r=ht(e,t,n),o=dt(n);return qe(e,t,null,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}function vt(e,t,n){const r=ht(e,t,n),o=dt(n);return Le(e,t,null,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}function wt(e,t,n,r=null,o=n){const i=ht(e,t,n),a=dt(n);return Ye(e,t,r,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:i})}function At(e,t,n,r=null,o=n){const i=ht(e,t,n),a=dt(n);return Ve(e,t,r,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:i})}const xt=(e,t)=>{const n=e.currentContext.formElement;if(t){const e=ct(t,n);if(e){if("FX-REPEAT"===e.nodeName){const{nodeset:t}=e;for(let r=n;r;r=r.parentNode)if(r.parentNode===e){return t[Array.from(r.parentNode.children).indexOf(r)]}}return e.nodeset}}const r=et.getParentBindingElement(n);return r?r.nodeset:n.getInScopeContext()};function bt(e,t){if(t&&t.nodeType===Node.ELEMENT_NODE&&t.children){const n=document.createElement("details");n.setAttribute("data-path",t.nodeName);const r=document.createElement("summary");let o,i=` <${t.nodeName}`;Array.from(t.attributes).forEach((e=>{i+=` ${e.nodeName}="${e.nodeValue}"`})),t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE&&""!==t.firstChild.data.trim()?(o=t.firstChild.nodeValue,i+=`>${o}</${t.nodeName}>`):i+=">",r.textContent=i,n.appendChild(r),0!==t.childElementCount?n.setAttribute("open","open"):r.setAttribute("style","list-style:none;"),e.appendChild(n),Array.from(t.children).forEach((e=>{bt(n,e)}))}}Ke({namespaceURI:ot,localName:"context"},[],"item()?",xt),Ke({namespaceURI:ot,localName:"context"},["xs:string"],"item()?",xt),Ke({namespaceURI:ot,localName:"current"},["xs:string"],"item()?",((e,t)=>(e.currentContext.formElement,null))),Ke({namespaceURI:ot,localName:"log"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext,r=ct(t,n,"fx-instance");if(r){if("json"!==r.getAttribute("type")){const e=(new XMLSerializer).serializeToString(r.getDefaultContext());return rt.prettifyXml(e)}console.warn("log() does not work for JSON yet")}return null})),Ke({namespaceURI:ot,localName:"parse"},["xs:string?"],"element()?",((e,t)=>{const n=(new DOMParser).parseFromString(t,"application/xml");return console.log("parse",n),n.firstElementChild})),Ke({namespaceURI:ot,localName:"logtree"},["xs:string?"],"element()?",((e,t)=>{const{formElement:n}=e.currentContext,r=ct(t,n,"fx-instance");if(r){const t=document.createElement("div");t.setAttribute("class","logtree");const n=e.currentContext.formElement,o=n.querySelector(".logtree");o&&o.parentNode.removeChild(o);const i=bt(t,r.getDefaultContext());i&&n.appendChild(i)}return null}));const Et=(e,t)=>{const n=$e("ancestor-or-self::fx-fore[1]",e.currentContext.formElement,null,null,{namespaceResolver:ut}),r=t?n.querySelector(`#${t}`):n.querySelector("fx-instance");return r?r.getDefaultContext():null};Ke({namespaceURI:ot,localName:"index"},["xs:string?"],"xs:integer?",((e,t)=>{const{formElement:n}=e.currentContext;if(null===t)return 1;const r=ct(t,n,"fx-repeat");return r?r.getAttribute("index"):Number(1)})),Ke({namespaceURI:ot,localName:"instance"},[],"item()?",(e=>Et(e,null))),Ke({namespaceURI:ot,localName:"instance"},["xs:string?"],"item()?",Et),Ke({namespaceURI:ot,localName:"depends"},["node()*"],"item()?",((e,t)=>t[0])),Ke({namespaceURI:ot,localName:"event"},["xs:string?"],"item()?",((e,t)=>{if(!t)return[];if(e.currentContext.variables){const n=e.currentContext.variables[t];if(n.nodeType&&console.log("got some node as js object"),n)return e.currentContext.variables[t]}return e.currentContext.formElement.inScopeVariables?(console.log("event()",e.currentContext.formElement.inScopeVariables),console.log("event()",e.currentContext.formElement.inScopeVariables.get(t)),e.currentContext.formElement.inScopeVariables.get(t)):[]})),We(`\n module namespace xf="${ot}";\n\n declare %public function xf:boolean-from-string($str as xs:string) as xs:boolean {\n lower-case($str) = "true" or $str = "1"\n };\n`),Ke({namespaceURI:ot,localName:"base64encode"},["xs:string?"],"xs:string?",((e,t)=>btoa(t)));class Nt extends HTMLElement{constructor(){super(),this.model=this.parentNode,this.attachShadow({mode:"open"})}connectedCallback(){this.hasAttribute("src")&&(this.src=this.getAttribute("src")),this.hasAttribute("id")?this.id=this.getAttribute("id"):this.id="default",this.hasAttribute("type")?this.type=this.getAttribute("type"):this.type="xml";this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: none;\n }\n :host * {\n display:none;\n }\n ::slotted(*){\n display:none;\n }\n \n </style>\n \n \n "}async init(){return await this._initInstance(),this.dispatchEvent(new CustomEvent("instance-loaded",{composed:!0,bubbles:!0,detail:{instance:this}})),this}evalXPath(e){const t=this.parentElement.parentElement;return gt(e,this.getDefaultContext(),t)}getInstanceData(){return this.instanceData||this.createInstanceData(),this.instanceData}setInstanceData(e){e?this.instanceData=e:this.createInstanceData()}getDefaultContext(){return"xml"===this.type?this.instanceData.firstElementChild:this.instanceData}async _initInstance(){if("#querystring"===this.src){const e=new URLSearchParams(location.search),t=(new DOMParser).parseFromString("<data></data>","application/xml"),n=t.firstElementChild;for(const r of e){const e=t.createElement(r[0]);e.appendChild(t.createTextNode(r[1])),n.appendChild(e)}this.instanceData=t}else this.src?await this._loadData():0!==this.childNodes.length&&this._useInlineData()}createInstanceData(){if("xml"===this.type){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.instanceData=e}"json"===this.type&&(this.instanceData={})}async _loadData(){const e=`${this.src}`;if(e.startsWith("localStore")){const t=e.substring(e.indexOf(":")+1),n=(new DOMParser).parseFromString("<data></data>","application/xml");if(n.firstElementChild,this.instanceData=n,!t)return void console.warn("no key specified for localStore");const r=localStorage.getItem(t);if(!r)return console.warn(`Data for key ${t} cannot be found`),void this._useInlineData();const o=(new DOMParser).parseFromString(r,"application/xml");return void n.firstElementChild.replaceWith(o.firstElementChild)}const t=rt.getContentType(this,"get");try{const n=await fetch(e,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":t}}),{status:r}=n,o=await async function(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/plain")||n.startsWith("text/markdown"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}return"done"}(n);if(o.nodeType)return this.instanceData=o,void console.log("instanceData loaded: ",this.id,this.instanceData);this.instanceData=o}catch(e){throw new Error(`failed loading data ${e}`)}}_getContentType(){return"xml"===this.type?"application/xml":"json"===this.type?"application/json":(console.warn("content-type unknown ",this.type),null)}_useInlineData(){if("xml"===this.type){const e=(new DOMParser).parseFromString(this.innerHTML,"application/xml");this.instanceData=e}else"json"===this.type?this.instanceData=JSON.parse(this.textContent):"html"===this.type?this.instanceData=this.firstElementChild.children:"text"===this.type?this.instanceData=this.textContent:console.warn("unknow type for data ",this.type)}_handleResponse(){console.log("_handleResponse ");const e=this.shadowRoot.getElementById("loader"),t=(new DOMParser).parseFromString(e.lastResponse,"application/xml");this.instanceData=t,console.log("data: ",this.instanceData)}_handleError(){const e=this.shadowRoot.getElementById("loader");console.log("_handleResponse ",e.lastError)}}customElements.get("fx-instance")||customElements.define("fx-instance",Nt);class Bt{constructor(e,t,n,r,o,i,a,s,u){this.path=e,this.ref=t,this.constraint=i,this.readonly=n,this.relevant=r,this.required=o,this.type=a,this.node=s,this.bind=u,this.changed=!1,this.alerts=[],this.boundControls=[]}get value(){return this.node.nodeType?this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue:this.node.textContent:this.node}set value(e){e.nodeType===Node.DOCUMENT_NODE?this.node.replaceWith(e.firstElementChild):e.nodeType===Node.ELEMENT_NODE?this.node.replaceWith(e):this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue=e:this.node.textContent=e}addAlert(e){this.alerts.includes(e)||this.alerts.push(e)}cleanAlerts(){this.alerts=[]}}class Tt extends HTMLElement{constructor(){super(),this.instances=[],this.modelItems=[],this.defaultContext={},this.changed=[],this.inited=!1,this.modelConstructed=!1,this.attachShadow({mode:"open"}),this.computes=0}get formElement(){return this.parentElement}connectedCallback(){this.shadowRoot.innerHTML="\n <slot></slot>\n ",this.addEventListener("model-construct-done",(()=>{this.modelConstructed=!0}),{once:!0}),this.skipUpdate=!1}static lazyCreateModelItem(e,t,n){let r,o={};if(null==n)return null;o=n.nodeType===n.TEXT_NODE?n.parentNode:n,n.nodeType?r=et.getPath(n):(r=null,o=n);const i=new Bt(r,t,rt.READONLY_DEFAULT,rt.RELEVANT_DEFAULT,rt.REQUIRED_DEFAULT,rt.CONSTRAINT_DEFAULT,rt.TYPE_DEFAULT,o,this);return e.registerModelItem(i),i}async modelConstruct(){rt.dispatch(this,"model-construct",{model:this});const e=this.querySelectorAll("fx-instance");if(e.length>0){console.group("init instances");const t=[];e.forEach((e=>{t.push(e.init())})),await Promise.all(t),this.instances=Array.from(e),await rt.dispatch(this,"model-construct-done",{model:this}),this.inited=!0,this.updateModel(),console.groupEnd()}else await this.dispatchEvent(new CustomEvent("model-construct-done",{composed:!1,bubbles:!0,detail:{model:this}}));this.inited=!0}registerModelItem(e){this.modelItems.push(e)}updateModel(){this.rebuild(),this.skipUpdate?console.info("%crecalculate/revalidate skipped - no bindings","font-style: italic; background: #90a4ae; color:lightgrey; padding:0.3rem 5rem 0.3rem 0.3rem;display:block;width:100%;"):(this.recalculate(),this.revalidate())}rebuild(){console.info("%crebuild","font-style: italic; background: #90a4ae; color:white; padding:0.3rem 5rem 0.3rem 0.3rem;display:block;width:100%;"),this.mainGraph=new nt(!1),this.modelItems=[];const e=this.querySelectorAll("fx-model > fx-bind");0!==e.length?(e.forEach((e=>{e.init(this)})),console.log("mainGraph",this.mainGraph),rt.dispatch(this,"rebuild-done",{maingraph:this.mainGraph}),console.log(`rebuild finished with modelItems ${this.modelItems.length} item(s)`,this.modelItems)):this.skipUpdate=!0}recalculate(){if(console.info("%crecalculate","font-style: italic; background: #90a4ae; color:white; padding:0.3rem 5rem 0.3rem 0.3rem;display:block;width:100%;"),this.mainGraph){if(console.group("### recalculate"),console.log("changed nodes ",this.changed),console.time("recalculate"),this.computes=0,this.subgraph=new nt(!1),0!==this.changed.length){this.changed.forEach((e=>{if(this.subgraph.addNode(e.path,e.node),this.mainGraph.hasNode(e.path)){const t=this.mainGraph.dependantsOf(e.path,!1).reverse();0!==t.length&&t.forEach((t=>{const n=this.mainGraph.getNodeData(t);if(this.subgraph.addNode(t,n),t.includes(":")){const r=t.substring(0,t.indexOf(":"));this.subgraph.addNode(r,n);0!==this.mainGraph.dependentsOf(e.path,!1).indexOf(t)&&this.subgraph.addDependency(t,e.path)}}))}}));this.subgraph.overallOrder(!1).forEach((e=>{if(this.mainGraph.hasNode(e)){const t=this.mainGraph.getNodeData(e);this.compute(t,e)}}));const e=[...this.changed];this.formElement.toRefresh=e,this.changed=[],console.log("subgraph",this.subgraph),this.dispatchEvent(new CustomEvent("recalculate-done",{detail:{subgraph:this.subgraph}}))}else{this.mainGraph.overallOrder(!1).forEach((e=>{const t=this.mainGraph.getNodeData(e);this.compute(t,e)}))}console.log(`recalculated ${this.computes} modelItems`),console.timeEnd("recalculate"),console.log("recalculate finished with modelItems ",this.modelItems),console.groupEnd()}}compute(e,t){const n=this.getModelItem(e);if(n&&t.includes(":")){const e=t.split(":")[1];if(e)if("calculate"===e){const t=mt(n.bind[e],n.node,this);n.value=t,n.readonly=!0}else if("constraint"!==e&&"type"!==e){const t=n.bind[e];if(t){const r=vt(t,n.node,this);n[e]=r}}this.computes+=1}}revalidate(){if(console.info("%crevalidate","font-style: italic; background: #90a4ae; color:white; padding:0.3rem 5rem 0.3rem 0.3rem;display:block;width:100%;"),0===this.modelItems.length)return!0;console.group("### revalidate"),console.time("revalidate");let e=!0;return this.modelItems.forEach((t=>{const{bind:n}=t;if(n){if("function"==typeof n.hasAttribute&&n.hasAttribute("constraint")){const r=n.getAttribute("constraint");if(r){const n=vt(r,t.node,this);t.constraint=n,this.formElement.addToRefresh(t),n||(e=!1)}}if("function"==typeof n.hasAttribute&&n.hasAttribute("required")){const r=n.getAttribute("required");if(r){const n=vt(r,t.node,this);t.required=n,this.formElement.addToRefresh(t),t.node.textContent||(console.log("modelItem required check failed: "),e=!1)}}}})),console.timeEnd("revalidate"),console.log("modelItems after revalidate: ",this.modelItems),console.groupEnd(),e}getModelItem(e){return this.modelItems.find((t=>t.node===e))}getDefaultContext(){return this.instances[0].getDefaultContext()}getDefaultInstance(){return this?.instances[0]}getDefaultInstanceData(){return console.log("default instance data ",this.instances[0].instanceData),this.instances[0].instanceData}getInstance(e){return Array.from(this.instances).find((t=>t.id===e))}evalBinding(e){return this.instances[0].evalXPath(e)}}function It(e){return e.closest("fx-fore")}function Ct(e,t){const n=rt.getClosest("[ref]",e),r=rt.getClosest("fx-fore",e),o=function(e){return It(e).getModel()}(e);if(null!==n){return r===n.closest("fx-fore")?n.nodeset:o.getDefaultInstance().getDefaultContext()}if(et.isAbsolutePath(t)){const e=et.getInstanceId(t);return e?o.getInstance(e).getDefaultContext():o.getDefaultInstance().getDefaultContext()}return o.getDefaultInstance().getDefaultContext()}function St(e,t){const n=function(e){return e&&e.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.nodeType===Node.ELEMENT_NODE?e:e.parentNode}(e);if("FX-FORE"===n.nodeName)return n.getModel().getDefaultInstance().getDefaultContext();const r=rt.getClosest("[ref]",n.parentNode);if(r&&"FX-GROUP"===r.nodeName)return r.nodeset;const o=rt.getClosest("fx-repeatitem",n);if(o)return"context"===e.nodeName?gt(e.nodeValue,o.nodeset,It(n)):o.nodeset;const i=n.closest(".fx-repeatitem");if(i){const e=i.parentNode,t=Array.from(e.children).indexOf(i);return rt.getClosest("fx-repeat-attributes",n).nodeset[t]}if(n.hasAttribute("context")){const e=Ct(n.parentNode,t);return gt(n.getAttribute("context"),e,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"context"===e.nodeName){const r=Ct(e.ownerElement.parentNode,t);return gt(e.ownerElement.getAttribute("context"),r,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"ref"===e.nodeName){if(e.ownerElement.hasAttribute("context")){const r=Ct(e.ownerElement.parentNode,t);return gt(e.ownerElement.getAttribute("context"),r,It(n))}return Ct(n.parentNode,t)}return Ct(n,t)}Tt.dataChanged=!1,customElements.get("fx-model")||customElements.define("fx-model",Tt);const Ot=e=>class extends e{static get properties(){return{context:{type:Object},model:{type:Object},modelItem:{type:Object},nodeset:{type:Object},ref:{type:String},inScopeVariables:{type:Map}}}constructor(){super(),this.context=null,this.model=null,this.modelItem={},this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):"",this.inScopeVariables=new Map}getModel(){if(this.model)return this.model;return this.getOwnerForm().querySelector("fx-model")}getOwnerForm(){let e=this;for(;e&&e.parentNode;){if("FX-FORE"===e.nodeName.toUpperCase())return e;e=e.parentNode instanceof DocumentFragment?e.parentNode.host:e.parentNode}return e}evalInContext(){if(!this.getModel())return;let e;if(this.hasAttribute("context")&&(e=St(this.getAttributeNode("context")||this,this.context)),this.hasAttribute("ref")&&(e=St(this.getAttributeNode("ref")||this,this.ref)),e||0===this.getModel().instances.length||(e=this.getModel().getDefaultInstance().getDefaultContext()),""===this.ref)this.nodeset=e;else if(Array.isArray(e))this.nodeset=gt(this.ref,e[0],this);else{const{nodeType:t}=e;t?this.nodeset=gt(this.ref,e,this):[this.nodeset]=mt(this.ref,e,this)}}isNotBound(){return!this.hasAttribute("ref")}isBound(){return this.hasAttribute("ref")}getBindingExpr(){if(this.hasAttribute("ref"))return this.getAttribute("ref");const e=rt.getClosest("[ref]",this.parentNode);return e?e.getAttribute("ref"):"instance()"}getInstance(){if(this.ref.startsWith("instance(")){const e=et.getInstanceId(this.ref);return this.getModel().getInstance(e)}return this.getModel().getInstance("default")}_getParentBindingElement(e){if(e.parentNode.host){const{host:t}=e.parentNode;if(t.hasAttribute("ref"))return t}else if(e.parentNode){if(e.parentNode.hasAttribute("ref"))return this.parentNode;this._getParentBindingElement(this.parentNode)}return null}getModelItem(){const e=this.getModel().getModelItem(this.nodeset);e&&(this.modelItem=e);const t=rt.getClosest("fx-repeatitem",this);let n;if(t){const{index:e}=t;n=Array.isArray(this.nodeset)?this.getModel().getModelItem(this.nodeset[e-1]):this.getModel().getModelItem(this.nodeset)}else n=this.getModel().getModelItem(this.nodeset);return n||Tt.lazyCreateModelItem(this.getModel(),this.ref,this.nodeset)}getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return wt(e,St(this,e),this.getOwnerForm())}catch(e){console.error(e),rt.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}getInScopeContext(){return St(this.getAttributeNode("ref")||this,this.ref)}setInScopeVariables(e){this.inScopeVariables=e}};class Rt extends(Ot(HTMLElement)){constructor(){super(),this.nodeset=[],this.model={},this.contextNode={},this.inited=!1}connectedCallback(){this.ref=this.getAttribute("ref"),this.readonly=this.getAttribute("readonly"),this.required=this.getAttribute("required"),this.relevant=this.getAttribute("relevant"),this.type=this.hasAttribute("type")?this.getAttribute("type"):Rt.TYPE_DEFAULT,this.calculate=this.getAttribute("calculate")}init(e){this.model=e,this.instanceId=this._getInstanceId(),this.bindType=this.getModel().getInstance(this.instanceId).type,"xml"===this.bindType&&(this._evalInContext(),this._buildBindGraph(),this._createModelItems()),this._processChildren(e)}_buildBindGraph(){"xml"===this.bindType&&this.nodeset.forEach((e=>{const t=et.getPath(e);this.model.mainGraph.addNode(t,e),this.calculate&&(this.model.mainGraph.addNode(`${t}:calculate`,e),this.model.mainGraph.addDependency(t,`${t}:calculate`));const n=this._getReferencesForProperty(this.calculate,e);if(0!==n.length&&this._addDependencies(n,e,t,"calculate"),!this.calculate){const n=this._getReferencesForProperty(this.readonly,e);0!==n.length?this._addDependencies(n,e,t,"readonly"):this.readonly&&this.model.mainGraph.addNode(`${t}:readonly`,e)}const r=this._getReferencesForProperty(this.required,e);0!==r.length?this._addDependencies(r,e,t,"required"):this.required&&this.model.mainGraph.addNode(`${t}:required`,e);const o=this._getReferencesForProperty(this.relevant,e);0!==o.length?this._addDependencies(o,e,t,"relevant"):this.relevant&&this.model.mainGraph.addNode(`${t}:relevant`,e);const i=this._getReferencesForProperty(this.constraint,e);0!==i.length?this._addDependencies(i,e,t,"constraint"):this.constraint&&this.model.mainGraph.addNode(`${t}:constraint`,e)}))}_addDependencies(e,t,n,r){const o=`${n}:${r}`;0!==e.length?(this.model.mainGraph.hasNode(o)||this.model.mainGraph.addNode(o,t),e.forEach((e=>{const t=et.getPath(e);t.endsWith("text()[1]")||(this.model.mainGraph.hasNode(t)||this.model.mainGraph.addNode(t,e),this.model.mainGraph.addDependency(o,t))}))):this.model.mainGraph.addNode(o,t)}_processChildren(e){const t=this.querySelectorAll(":scope > fx-bind");Array.from(t).forEach((t=>{t.init(e)}))}getAlert(){if(this.hasAttribute("alert"))return this.getAttribute("alert");const e=this.querySelector("fx-alert");return e?e.innerHTML:null}_evalInContext(){const e=St(this.getAttributeNode("ref")||this,this.ref);if(this.nodeset=[],""===this.ref||null===this.ref)this.nodeset=e;else if(Array.isArray(e))e.forEach((t=>{if(et.isSelfReference(this.ref))this.nodeset=e;else if(this.ref){yt(this.ref,t,this).forEach((e=>{this.nodeset.push(e)}))}}));else{"xml"===this.getModel().getInstance(this.instanceId).type?this.nodeset=yt(this.ref,e,this):this.nodeset=this.ref}}_createModelItems(){Array.isArray(this.nodeset)?Array.from(this.nodeset).forEach((e=>{this._createModelItem(e)})):this._createModelItem(this.nodeset)}_createModelItem(e){if(et.isSelfReference(this.ref)){const e=rt.getClosest("fx-bind[ref]",this.parentElement);return void(e?e.required=this.required:console.error("no parent bound element"))}const t=e,n=et.getPath(e),r=new Bt(n,this.getBindingExpr(),Rt.READONLY_DEFAULT,Rt.RELEVANT_DEFAULT,Rt.REQUIRED_DEFAULT,Rt.CONSTRAINT_DEFAULT,this.type,t,this),o=this.getAlert();o&&r.addAlert(o),this.getModel().registerModelItem(r)}_getReferencesForProperty(e){return e?this.getReferences(e):[]}getReferences(e){const t=new Set,n=new Ze((e=>t.add(e)));return this.nodeset.forEach((t=>{wt(e,t,this,n)})),Array.from(t.values())}_initBooleanModelItemProperty(e,t){return vt(this[e],t,this)}static shortenPath(e){const t=e.split("/");let n="";for(let e=2;e<t.length;e+=1){const r=t[e];if(-1!==r.indexOf("{}")){n+=`/${r.split("{}")[1]}`}else n+=`/${r}`}return n}_getInstanceId(){const e=this.getBindingExpr();return e.startsWith("instance(")?(this.instanceId=et.getInstanceId(e),this.instanceId):this.instanceId?this.instanceId:"default"}}Rt.READONLY_DEFAULT=!1,Rt.REQUIRED_DEFAULT=!1,Rt.RELEVANT_DEFAULT=!0,Rt.CONSTRAINT_DEFAULT=!0,Rt.TYPE_DEFAULT="xs:string",customElements.get("fx-bind")||customElements.define("fx-bind",Rt)
|
|
1
|
+
function e(e,t,n,r){const a={op:t,func:n,data:r};return e.push(a),a}function t(e,t){return e}class n{constructor(){this.program=[]}test(t,n){return e(this.program,5,t,void 0===n?null:n)}jump(t){return e(this.program,3,null,t)}record(n,r){return e(this.program,4,void 0===r?t:r,n)}bad(t=1){return e(this.program,1,null,t)}accept(){return e(this.program,0,null,null)}fail(t){return e(this.program,2,t||null,null)}}class r{constructor(e,t,n){this.programLength=e,this.maxFromByPc=t,this.maxSurvivorFromByPc=n}static fromProgram(e){const t=e.length,n=[],a=[];return e.forEach((e=>{n.push(0),a.push(0)})),e.forEach(((e,r)=>{switch(e.op){case 2:if(null===e.func)return;if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 1:case 4:if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 3:e.data.forEach((e=>{if(e<0||e>=t)throw new Error("Invalid program: program could run past end");n[e]+=1}));break;case 5:if(r+1>=t)throw new Error("Invalid program: program could run past end");a[r+1]+=1;break;case 0:a[r]+=1}})),new r(t,n,a)}static createStub(e){const t=[],n=[];for(let r=0;r<e;++r)t.push(e),n.push(e);return new r(e,t,n)}}class a{constructor(e){this.acceptingTraces=e,this.success=e.length>0}}class o{constructor(e){this.t=0,this.i=0,this.h=new Uint16Array(e),this.l=new Uint8Array(e)}getBadness(e){return this.l[e]}add(e,t){this.l[e]=t>255?255:t;const n=function(e,t,n,r,a){let o=r,s=a;for(;o<s;){const r=o+s>>>1;n<t[e[r]]?s=r:o=r+1}return o}(this.h,this.l,t,this.i,this.t);this.h.copyWithin(n+1,n,this.t),this.h[n]=e,this.t+=1}reschedule(e,t){const n=Math.max(this.l[e],t>255?255:t);if(this.l[e]!==n){const t=this.h.indexOf(e,this.i);if(t<0||t>=this.t)return void(this.l[e]=n);this.h.copyWithin(t,t+1,this.t),this.t-=1,this.add(e,n)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}}class s{constructor(e){this.o=[];let t=e.length;e.forEach((e=>{this.o.push(e>0?t:-1),t+=e})),this.u=new Uint16Array(t)}clear(){this.u.fill(0,0,this.o.length)}add(e,t){const n=this.u[t],r=this.o[t];this.u[t]+=1,this.u[r+n]=e}has(e){return this.u[e]>0}forEach(e,t){const n=this.u[e],r=this.o[e];for(let e=r;e<r+n;++e)t(this.u[e])}}function i(e,t,n=!1){return null===e?t:Array.isArray(e)?(-1===e.indexOf(t)&&(n&&(e=e.slice()),e.push(t)),e):e===t?e:[e,t]}class l{constructor(e,t){this.prefixes=e,this.record=t}}function c(e,t){let n;if(null===t){if(!Array.isArray(e))return e;n=e}else n=e===l.EMPTY?[]:Array.isArray(e)?e:[e];return new l(n,t)}l.EMPTY=new l([],null);class u{constructor(e){this.p=[],this.v=[];for(let t=0;t<e;++t)this.p.push(0),this.v.push(null)}mergeTraces(e,t,n,r,a,o){let s=!1;return n.forEach(t,(t=>{const n=this.trace(t,r,a,o);var l,c,u;c=n,u=s,e=null===(l=e)?c:null===c?l:Array.isArray(c)?c.reduce(((e,t)=>i(e,t,e===c)),l):i(l,c,u),s=e===n})),e}trace(e,t,n,r){switch(this.p[e]){case 2:return this.v[e];case 1:return null}this.p[e]=1;let a=null;const o=t[e];if(null!==o)a=o;else if(!n.has(e))throw new Error("Trace without source at pc "+e);if(a=this.mergeTraces(a,e,n,t,n,r),null!==a){const t=r[e];null!==t&&(a=c(a,t))}return this.v[e]=a,this.p[e]=2,a}buildSurvivorTraces(e,t,n,r,a){for(let o=0,s=e.length;o<s;++o){if(!n.has(o)){t[o]=null;continue}this.v.fill(null),this.p.fill(0);const s=this.mergeTraces(null,o,n,e,r,a);if(null===s)throw new Error("No non-cyclic paths found to survivor "+o);t[o]=c(s,null)}this.v.fill(null)}}class h{constructor(e){this.g=[],this.k=[],this.m=[],this.A=new s(e.maxFromByPc),this.T=new s(e.maxSurvivorFromByPc),this.S=new u(e.programLength);for(let t=0;t<e.programLength;++t)this.g.push(null),this.k.push(null),this.m.push(null);this.k[0]=l.EMPTY}reset(e){this.A.clear(),this.T.clear(),this.g.fill(null),e&&(this.k.fill(null),this.m.fill(null),this.k[0]=l.EMPTY)}record(e,t){this.g[e]=t}has(e){return this.A.has(e)||null!==this.k[e]}add(e,t){this.A.add(e,t)}hasSurvivor(e){return this.T.has(e)}addSurvivor(e,t){this.T.add(e,t)}buildSurvivorTraces(){const e=this.k;this.S.buildSurvivorTraces(e,this.m,this.T,this.A,this.g),this.k=this.m,this.m=e}getTraces(e){const t=e.reduce(((e,t)=>i(e,this.k[t])),null);return null===t?[]:Array.isArray(t)?t:[t]}}class p{constructor(e){this.I=[],this.N=new o(e.programLength),this.M=new o(e.programLength),this.P=new h(e)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(e,t,n){const r=this.P.has(t);this.P.add(e,t);const a=this.N.getBadness(e)+n;r?this.N.reschedule(t,a):this.N.add(t,a)}stepToNextGeneration(e,t){const n=this.P.hasSurvivor(t);this.P.addSurvivor(e,t);const r=this.N.getBadness(e);n?this.M.reschedule(t,r):this.M.add(t,r)}accept(e){this.I.push(e),this.P.addSurvivor(e,e)}fail(e){}record(e,t){this.P.record(e,t)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);const e=this.N;e.reset(),this.N=this.M,this.M=e}getAcceptingTraces(){return this.P.getTraces(this.I)}}class d{constructor(e){this.U=[],this.G=e,this.V=r.fromProgram(e),this.U.push(new p(this.V))}execute(e,t){const n=this.U.pop()||new p(this.V);n.reset();const r=e.length;let o,s=-1;do{let a=n.getNextThreadPc();if(null===a)break;for(++s,o=s>=r?null:e[s];null!==a;){const e=this.G[a];switch(e.op){case 0:null===o?n.accept(a):n.fail(a);break;case 2:{const r=e.func;if(null===r||r(t)){n.fail(a);break}n.step(a,a+1,0);break}case 1:n.step(a,a+1,e.data);break;case 5:if(null===o){n.fail(a);break}if(!(0,e.func)(o,e.data,t)){n.fail(a);break}n.stepToNextGeneration(a,a+1);break;case 3:{const t=e.data,r=t.length;if(0===r){n.fail(a);break}for(let e=0;e<r;++e)n.step(a,t[e],0);break}case 4:{const r=(0,e.func)(e.data,s,t);null!=r&&n.record(a,r),n.step(a,a+1,0);break}}a=n.getNextThreadPc()}n.nextGeneration()}while(null!==o);const i=new a(n.getAcceptingTraces());return n.reset(),this.U.push(n),i}}function m(e){return t=>t===e}function f(e,t){if(null===e||null===t)throw new Error("unescaped hyphen may not be used as a range endpoint");if(t<e)throw new Error("character range is in the wrong order");return n=>e<=n&&n<=t}function g(e){return!0}function y(){return!1}function w(e,t){return n=>e(n)||t(n)}function v(e,t){switch(t.kind){case"predicate":return void e.test(t.value);case"regexp":return void x(e,t.value,!1)}}function x(e,t,n){const r=e.program.length,a=e.jump([]);n&&(a.data.push(e.program.length),e.test((()=>!0)),e.jump([r]));const o=[];if(t.forEach((t=>{a.data.push(e.program.length),function(e,t){t.forEach((t=>{!function(e,t){const[n,{min:r,max:a}]=t;if(null!==a){for(let t=0;t<r;++t)v(e,n);for(let t=r;t<a;++t){const t=e.jump([]);t.data.push(e.program.length),v(e,n),t.data.push(e.program.length)}}else if(r>0){for(let t=0;t<r-1;++t)v(e,n);const t=e.program.length;v(e,n),e.jump([t]).data.push(e.program.length)}else{const t=e.program.length,r=e.jump([]);r.data.push(e.program.length),v(e,n),e.jump([t]),r.data.push(e.program.length)}}(e,t)}))}(e,t),o.push(e.jump([]))})),o.forEach((t=>{t.data.push(e.program.length)})),n){const t=e.program.length,n=e.jump([]);n.data.push(e.program.length),e.test((()=>!0)),e.jump([t]),n.data.push(e.program.length)}}function b(e,t){return{success:!0,offset:e,value:t}}function A(e){return b(e,void 0)}function E(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function N(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?b(r,e):E(n,[e])}}function T(e,t){return(n,r)=>{const a=e(n,r);return a.success?b(a.offset,t(a.value)):a}}function B(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:E(o,n,r):s}}function I(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||E(r,t)}}function C(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:b(n,null)}}function S(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return b(a,r)}}function O(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?b(s.offset,n(o.value,s.value)):s}}function F(e){return O(e,S(e),((e,t)=>[e].concat(t)))}function D(e,t){return e}function k(e,t){return t}function R(e,t){return O(e,t,k)}function M(e,t){return O(e,t,D)}function U(e,t,n,r=!1){return R(e,r?L(M(t,n)):M(t,n))}function G(e,t){return(n,r)=>e(n,r).success?E(r,t):A(r)}function L(e){return(t,n)=>{const r=e(t,n);return r.success?r:E(r.offset,r.expected,!0)}}const $=(e,t)=>e.length===t?A(t):E(t,["end of input"]),H=["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"],P={};function _(e){return e.codePointAt(0)}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(((e,t)=>{P[e]=t}));const j=e=>-1===e||-2===e;function X(e){return t=>!j(t)&&!e(t)}function q(e,t){return null===t?e:n=>e(n)&&!t(n)}const V=function(e,t){const n=new Map;let r=0;return["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"].forEach(((e,a)=>{const o=t[a];null!==e&&e.split("|").forEach((e=>{const t=n.get(e),a=f(r,r+o-1);n.set(e,t?w(t,a):a)})),r+=o})),n}(0,[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]),Y=function(e){const t=new Map,n="bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcATCGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKBEGXZAGFBAcBBFHHGoFAHXcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABGHBIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBBHAGAHCIDBAHCBAHDBGHBBAGCBBGABBGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBFGBBAGBHBBBKJBAGBIABLHBIBGIBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBAHAIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHGBAKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGRHCIABIGSHBIATBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcAHAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAHPBwHDIAGuHAIAHEIAHAIEHAIBGHBCKJTGaJHIaITBBAHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH/gVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYgBOHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBA6oBAACvDvABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMaBTCPAQAPAQAPAQAPAQAOABhaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGfajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm/mBAa/mUIFAFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDAPCCADBECADABADABADAADBXFCCADAGAFBDAGGHAGCHAGDHAGWIBHBIAaDHABCMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDIFAZBBDjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZQBPmqFAAQAPAaPG/BBG1BGaABfGLYAaCHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaMBCaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTACKBACOBACGBACBBADKBADOBADGBADBhCBAAm2EAABIGVBJGHBXFFBAFpBAFIhEBAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMeBAGpBAHBOABBGBhKBAAHCGcMJGABHGVHKMDTEBVGRHDTDBlGUMGBTGWBIIAHAIAG0HOTGBDMTKJHAGBHBGABIHCIAGsICHDIBHBTBcATDHABJcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBGABHGiHATBGABIHBIAGvICHIIBGDTDHDTAIAHAKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAGBHAB9GGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJTBBATAHAGCBdGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGATABFKJB1GaBBHCIBHDIAHEBDKJMBTCaAGGh4CAAGrICHIIAHBTAhjBAACfDfKJMIBLGHBBGABBGHBAGBBAGXIFBAIBBBHBIAHAGAIAGAIAHATCBIKJhFBAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBMmIBAABGTJh1DAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBBGHBGAIAGMBAGhIBHEBCIBHAIAHATMKJhVBAAGABOMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAhLpAAmgBAATBBMmvQAAcPHAGFHOhp+AAmGJAAh4GCAm4IAABGGeBAKJBDTBmOBAABAKJBFGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFAHABKIBBNm3fBABHmVTAABpGIhmLCAFDBAFGBAFBBAmiEAABOGABcGCBBGABNGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbJBAHtBBHWBI6zBAAB761DAABJamBBa7IBHCaCIFcHHHaBHGadHDa8BU6BBAAHCaAh5BAAMTBLMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPRAADJGADTBFDFhUDAAHGBAHQBBHGBAHBBAHEBEF9BgHAhvBAAGsBCHGFGBBKJBDGAaAh/EAAGdHABQGrHDKJBEYAhPHAAGaFAHDKJhlLAAGGBAGDBAGBBAGOBAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMM6gCAAB3acBMarBDaIBGaBBNaFhZCAA66DAAZE6XLAABDaQBCaMBC62BAABD6eBAABFaLBDaABOaLBDa3BHaJBFanBHadBBaBhNBAA6TFAABLaNBBaMBCaIBGatBAaGBHaNBDaIBGaIBG6SCAABAa2BkKJhFQAAmfbKABfm5ABABFmdDAABBmBaBABNmw0BAhewAAmdIAAhhXAAmKNBABEmfBBAhQxtCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA".split(""),r=H.map((()=>[]));let a=0,o=0;for(;o<n.length;){const e=P[n[o]],t=(31&e)-2;let s=1+P[n[o+1]];switch(32&e?(s+=P[n[o+2]]<<6,s+=P[n[o+3]]<<12,s+=P[n[o+4]]<<18,o+=5):o+=2,t){case-2:{let e=0;for(let t=a;t<a+s;++t)r[e].push(m(t)),e=(e+1)%2;break}case-1:break;default:{const e=r[t];1===s?e.push(m(a)):e.push(f(a,a+s-1));break}}a+=s}const s=new Map;return H.forEach(((e,n)=>{const a=r[n].reduce(w,y);t.set(e,a);const o=e.charAt(0),i=s.get(o)||[];s.set(o,i),i.push(a)})),s.forEach(((e,n)=>{t.set(n,e.reduce(w,y))})),t}();function z(e){return 32===e||9===e||10===e||13===e}const J=[m(_(":")),f(_("A"),_("Z")),m(_("_")),f(_("a"),_("z")),f(192,214),f(216,246),f(192,214),f(216,246),f(248,767),f(880,893),f(895,8191),f(8204,8205),f(8304,8591),f(11264,12271),f(12289,55295),f(63744,64975),f(65008,65533),f(65536,983039)].reduce(w),Q=[J,m(_("-")),m(_(".")),f(_("0"),_("9")),m(183),f(768,879),f(8255,8256)].reduce(w),K=Y.get("Nd"),W=X(K),Z=q(f(0,1114111),[Y.get("P"),Y.get("Z"),Y.get("C")].reduce(w)),ee=X(Z);function te(e){return 10!==e&&13!==e&&!j(e)}const ne={s:z,S:X(z),i:J,I:X(J),c:Q,C:X(Q),d:K,D:W,w:Z,W:ee},re=N("*"),ae=N("\\"),oe=N("{"),se=N("}"),ie=N("["),le=N("]"),ce=N("^"),ue=N("$"),he=N(","),pe=N("-"),de=N("("),me=N(")"),fe=N("."),ge=N("|"),ye=N("+"),we=N("?"),ve=N("-["),xe=_("0");function be(e){return[...e].map((e=>e.codePointAt(0)))}var Ae=Object.freeze({__proto__:null,compile:function(e,t={language:"xsd"}){const r=function(e){function t(e){return new Set(e.split("").map((e=>_(e))))}function n(e,t){const n=e.codePointAt(t);return void 0===n?E(t,["any character"]):b(t+String.fromCodePoint(n).length,n)}const r="xpath"===e.language?R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,pe,ce,we,re,ye,oe,se,ue,de,me,ie,le]),(e=>_(e)))])):R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,pe,ce,we,re,ye,oe,se,de,me,ie,le]),(e=>_(e)))]));function a(e,r){const a=t(r);return O(N(e),C(B(n,(e=>a.has(e)),r.split(""))),((e,t)=>function(e){const t=Y.get(e);if(null==t)throw new Error(e+" is not a valid unicode category");return t}(null===t?e:e+String.fromCodePoint(t))))}const o=I([a("L","ultmo"),a("M","nce"),a("N","dlo"),a("P","cdseifo"),a("Z","slp"),a("S","mcko"),a("C","cfon")]),s=[f(_("a"),_("z")),f(_("A"),_("Z")),f(_("0"),_("9")),m(45)].reduce(w),i=I([o,T(R(N("Is"),function(e){return(t,n)=>{const r=e(t,n);return r.success?b(r.offset,t.slice(n,r.offset)):r}}(F(B(n,s,["block identifier"])))),(t=>function(e,t){const n=V.get(e);if(void 0===n){if(t)return g;throw new Error(`The unicode block identifier "${e}" is not known.`)}return n}(t,"xpath"!==e.language)))]),l=U(N("\\p{"),i,se,!0),c=T(U(N("\\P{"),i,se,!0),X),u=R(ae,T(I("sSiIcCdDwW".split("").map((e=>N(e)))),(e=>ne[e]))),h=T(fe,(()=>te)),p=I([u,l,c]),d=t("\\[]"),y=I([r,B(n,(e=>!d.has(e)),["unescaped character"])]),v=I([T(pe,(()=>null)),y]),x=O(v,R(pe,v),f);function A(e,t){return[e].concat(t||[])}const k=T(function(e){return(t,n)=>{const r=e(t,n);return r.success?b(n,r.value):r}}(I([le,ve])),(()=>null)),H=_("-"),P=I([T(M(M(pe,G(ie,["not ["])),k),(()=>H)),R(G(pe,["not -"]),y)]),j=I([O(T(P,m),I([function(e,t){return j(e,t)},k]),A),O(I([x,p]),I([J,k]),A)]),z=I([O(T(y,m),I([j,k]),A),O(I([x,p]),I([J,k]),A)]);function J(e,t){return z(e,t)}const Q=T(z,(e=>e.reduce(w))),K=T(R(ce,Q),X),W=O(I([R(G(ce,["not ^"]),Q),K]),C(R(pe,(function(e,t){return Z(e,t)}))),q),Z=U(ie,W,le,!0),ee="xpath"===e.language?I([T(r,m),p,Z,h,T(ce,(()=>e=>-1===e)),T(ue,(()=>e=>-2===e))]):I([T(r,m),p,Z,h]),be="xpath"===e.language?t(".\\?*+{}()|^$[]"):t(".\\?*+{}()|[]"),Ae=B(n,(e=>!be.has(e)),["NormalChar"]),Ee=T(R(ae,O(T(B(n,f(_("1"),_("9")),["digit"]),(e=>e-xe)),S(T(B(n,f(xe,_("9")),["digit"]),(e=>e-xe))),((e,t)=>{t.reduce(((e,t)=>10*e+t),e)}))),(e=>{throw new Error("Backreferences in XPath patterns are not yet implemented.")})),Ne="xpath"===e.language?I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(de,R(C(N("?:")),Oe),me,!0),(e=>({kind:"regexp",value:e}))),Ee]):I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(de,Oe,me,!0),(e=>({kind:"regexp",value:e})))]),Te=T(F(T(B(n,f(xe,_("9")),["digit"]),(e=>e-xe))),(e=>e.reduce(((e,t)=>10*e+t)))),Be=I([O(Te,R(he,Te),((e,t)=>{if(t<e)throw new Error("quantifier range is in the wrong order");return{min:e,max:t}})),O(Te,he,(e=>({min:e,max:null}))),T(Te,(e=>({min:e,max:e})))]),Ie="xpath"===e.language?O(I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),C(we),((e,t)=>e)):I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),Ce=S(O(Ne,T(C(Ie),(e=>null===e?{min:1,max:1}:e)),((e,t)=>[e,t]))),Se=O(Ce,S(R(ge,L(Ce))),((e,t)=>[e].concat(t)));function Oe(e,t){return Se(e,t)}const Fe=function(e){return O(e,$,D)}(Se);return function(e){let t;try{t=Fe(e,0)}catch(t){throw new Error(`Error parsing pattern "${e}": ${t instanceof Error?t.message:t}`)}return t.success?t.value:function(e,t,n){const r=n.map((e=>`"${e}"`));throw new Error(`Error parsing pattern "${e}" at offset ${t}: expected ${r.length>1?"one of "+r.join(", "):r[0]} but found "${e.slice(t,t+1)}"`)}(e,t.offset,t.expected)}}(t)(e),a=function(e){const t=new n;return e(t),new d(t.program)}((e=>{x(e,r,"xpath"===t.language),e.accept()}));return function(e){const n="xpath"===t.language?[-1,...be(e),-2]:be(e);return a.execute(n).success}}});function Ee(e,t){return{success:!0,offset:e,value:t}}function Ne(e){return Ee(e,void 0)}function Te(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function Be(e){return e>65535?2:1}function Ie(e,t){return(n,r)=>{const a=n.codePointAt(r);return void 0!==a&&e(a)?Ne(r+Be(a)):Te(r,t)}}function Ce(e,t){return(n,r)=>{const a=e(n,r);return a.success?Ee(a.offset,t(a.value)):a}}function Se(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return Ee(a,r)}}function Oe(e){return(t,n)=>{let r=n;for(;;){const n=e(t,r);if(!n.success){if(n.fatal)return n;break}if(n.offset===r)break;r=n.offset}return Ne(r)}}function Fe(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?Ee(s.offset,n(o.value,s.value)):s}}function De(e,t){return e}function ke(e,t){return t}function Re(e,t){return Fe(e,t,ke)}function Me(e,t){return Fe(e,t,De)}function Ue(e,t){return(n,r)=>e(n,r).success?Te(r,t):Ne(r)}function Ge(e){return(t,n)=>{const r=e(t,n);return r.success?r:Te(r.offset,r.expected,!0)}}const Le=(e,t)=>e.length===t?Ne(t):Te(t,["end of input"]);function $e(e){const t=[];let n=e.next();for(;!n.done;)t.push(n.value),n=e.next();return[t,n.value]}var He=Object.freeze({__proto__:null,codepoint:Ie,codepoints:function(e,t){return(n,r)=>{const a=r;for(;;){const t=n.codePointAt(r);if(void 0===t)break;if(!e(t))break;r+=t>65535?2:1}return void 0!==t&&r===a?Te(r,t):Ne(r)}},collect:$e,complete:function(e){return Fe(e,Le,De)},consume:function(e){return Ce(e,(()=>{}))},cut:Ge,delimited:function(e,t,n,r=!1){return Re(e,r?Ge(Me(t,n)):Me(t,n))},dispatch:function(e,t,n=0,r=[]){return(a,o)=>{const s=a.codePointAt(o+n);if(void 0===s)return Te(o,r);const i=e[s];return void 0===i?void 0===t?Te(o,r):t(a,o):i(a,o)}},end:Le,error:Te,except:function(e,t,n){return Re(Ue(t,n),e)},filter:function(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:Te(o,n,r):s}},filterUndefined:function(e){return Ce(e,(e=>e.filter((e=>void 0!==e))))},first:De,followed:Me,map:Ce,not:Ue,ok:Ne,okWithValue:Ee,optional:function(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:Ee(n,null)}},or:function(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||Te(r,t)}},peek:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(n,r.value):r}},plus:function(e){return Fe(e,Se(e),((e,t)=>[e].concat(t)))},plusConsumed:function(e){return Fe(e,Oe(e),ke)},preceded:Re,range:function(e,t,n){return Ie((n=>e<=n&&n<=t),n||[`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`])},recognize:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(r.offset,t.slice(n,r.offset)):r}},second:ke,sequence:function(...e){return(t,n)=>{const r=[];for(const a of e){const e=a(t,n);if(!e.success)return e;n=e.offset,r.push(e.value)}return Ee(n,r)}},sequenceConsumed:function(...e){return(t,n)=>{for(const r of e){const e=r(t,n);if(!e.success)return e;n=e.offset}return Ne(n)}},skipChars:function(e){return(t,n)=>{let r=e;for(;r>0;){const e=t.codePointAt(n);if(void 0===e)return Te(n,["any character"]);n+=Be(e),r-=1}return Ne(n)}},star:Se,starConsumed:Oe,start:(e,t)=>0===t?Ne(t):Te(t,["start of input"]),streaming:function(e){return function*(t,n){const r=e(t,n);return r.success&&(yield r.value),r}},streamingComplete:function(e){return function*(t,n){const r=yield*e(t,n);return r.success?Le(t,r.offset):r}},streamingFilterUndefined:function(e){return function*(t,n){const r=e(t,n);let a=r.next();for(;!a.done;){const e=a.value;void 0!==e&&(yield e),a=r.next()}return a.value}},streamingOptional:function(e){return function*(t,n){const[r,a]=$e(e(t,n));return a.success?(yield*r,a):a.fatal?a:Ne(n)}},streamingStar:function(e){return function*(t,n){for(;;){const[r,a]=$e(e(t,n));if(!a.success)return a.fatal?a:Ne(n);if(yield*r,n===a.offset)return Ne(n);n=a.offset}}},streamingThen:function(e,t){return function*(n,r){const a=yield*e(n,r);return a.success?yield*t(n,a.offset):a}},then:Fe,token:function(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?Ee(r,e):Te(n,[e])}}});const Pe=function(e,t){const n={};function r(e,t){if(!("0"!==e&&"-0"!==e||"0"!==t&&"-0"!==t))return 0;var n=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;e=n.exec(e+"");var r=n.exec(t+""),a=!e[1];const o=!r[1];return t=(e[2]||"").replace(/^0*/,""),n=(r[2]||"").replace(/^0*/,""),e=e[3]||"",r=r[3]||"",a&&!o?1:!a&&o?-1:(a=a&&o,t.length>n.length?a?1:-1:t.length<n.length?a?-1:1:t>n?a?1:-1:t<n?a?-1:1:(t=Math.max(e.length,r.length),(n=e.padEnd(t,"0"))>(t=r.padEnd(t,"0"))?a?1:-1:n<t?a?-1:1:0))}function a(e,t){return!(-1<(e=e.toString()).indexOf(".")&&0===t)&&(!(e=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(e))[2]||e[2].length<=t)}function o(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 s(e){switch(e){case 1:case 0:case 6:case 3:case 18:case 22:case 21:case 20:case 23:case 44:return{};case 4:return{ka:a,ua:function(e,t){return 1>r(e,t)},lc:function(e,t){return 0>r(e,t)},va:function(e,t){return-1<r(e,t)},mc:function(e,t){return 0<r(e,t)}};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Aa:o};default:return null}}var i={},l={};function c(e){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(e)}function u(e){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(e)}function h(e){return u(e)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(e)}function p(e){return 1===(e=e.split(":")).length?h(e[0]):2===e.length&&(h(e[0])&&h(e[1]))}function d(e){return!/[\u0009\u000A\u000D]/.test(e)}function m(e){return h(e)}const f=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 c(e)}],[3,c],[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,p],[48,d],[52,function(e){return d(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,u],[23,p],[24,h],[42,m],[41,m],[26,function(e){return h(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 g=Object.create(null);function y(e,t){if(!g[t])throw Error("Unknown type");return{type:t,value:e}}[{C:0,name:59},{C:0,name:46,parent:59,K:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,K:{Aa:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{C:1,name:10,R:9,K:{whiteSpace:"collapse",Aa:"required"}},{C:1,name:48,R:1,K:{whiteSpace:"replace"}},{C:1,name:52,R:48,K:{whiteSpace:"collapse"}},{C:1,name:51,R:52,K:{whiteSpace:"collapse"}},{C:1,name:50,R:52,K:{whiteSpace:"collapse"}},{C:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,R:52,K:{whiteSpace:"collapse"}},{C:1,name:24,R:25,K:{whiteSpace:"collapse"}},{C:1,name:42,R:24,K:{whiteSpace:"collapse"}},{C:1,name:41,R:24,K:{whiteSpace:"collapse"}},{C:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,R:24,K:{whiteSpace:"collapse"}},{C:2,name:40,type:26,K:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,K:{ka:0,whiteSpace:"collapse"}},{C:1,name:27,R:5,K:{ka:0,ua:"0",whiteSpace:"collapse"}},{C:1,name:28,R:27,K:{ka:0,ua:"-1",whiteSpace:"collapse"}},{C:1,name:31,R:5,K:{ka:0,ua:"9223372036854775807",va:"-9223372036854775808",whiteSpace:"collapse"}},{C:1,name:32,R:31,K:{ka:0,ua:"2147483647",va:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,R:32,K:{ka:0,ua:"32767",va:"-32768",whiteSpace:"collapse"}},{C:1,name:34,R:33,K:{ka:0,ua:"127",va:"-128",whiteSpace:"collapse"}},{C:1,name:30,R:5,K:{ka:0,va:"0",whiteSpace:"collapse"}},{C:1,name:36,R:30,K:{ka:0,ua:"18446744073709551615",va:"0",whiteSpace:"collapse"}},{C:1,name:35,R:36,K:{ka:0,ua:"4294967295",va:"0",whiteSpace:"collapse"}},{C:1,name:38,R:35,K:{ka:0,ua:"65535",va:"0",whiteSpace:"collapse"}},{C:1,name:37,R:38,K:{ka:0,ua:"255",va:"0",whiteSpace:"collapse"}},{C:1,name:29,R:30,K:{ka:0,va:"1",whiteSpace:"collapse"}},{C:1,name:16,R:18,K:{whiteSpace:"collapse"}},{C:1,name:17,R:18,K:{whiteSpace:"collapse"}},{C:1,name:60,R:59},{C:3,name:39,Ba:[]},{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,Ba:[4,5,6,3]},{C:3,name:63,Ba:[]}].forEach((e=>{const t=e.name,n=e.K||{};switch(e.C){case 0:e=e.parent?g[e.parent]:null;var r=f.get(t)||null;g[t]={C:0,type:t,Ja:n,parent:e,fb:r,Oa:s(t),Ba:[]};break;case 1:e=g[e.R],r=f.get(t)||null,g[t]={C:1,type:t,Ja:n,parent:e,fb:r,Oa:e.Oa,Ba:[]};break;case 2:g[t]={C:2,type:t,Ja:n,parent:g[e.type],fb:null,Oa:i,Ba:[]};break;case 3:e=e.Ba.map((e=>g[e])),g[t]={C:3,type:t,Ja:n,parent:null,fb:null,Oa:l,Ba:e}}}));var w=y(!0,0),v=y(!1,0),x=(e="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${e}`),b=class{constructor(e,t){this.done=e,this.value=t}},A=new b(!0);function E(e){return new b(!1,e)}function N(e,t){if(3===t.C)return!!t.Ba.find((t=>N(e,t)));for(;e;){if(e.type===t.type)return!0;if(3===e.C)return!!e.Ba.find((e=>T(e.type,t.type)));e=e.parent}return!1}function T(e,t){return e===t||N(g[e],g[t])}var B=class{constructor(){this.value={next:()=>A}}gb(){return this}filter(){return this}first(){return null}O(){return[]}fa(){return!1}Pa(){return 0}G(){return!0}sa(){return!1}map(){return this}M(e){return e([])}Y(e){return e.empty?e.empty(this):e.default(this)}},I=class{constructor(e,t){this.type=e,this.value=t}};const C={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"},S={"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 O(e){return 2===e.g?C[e.type]+"*":1===e.g?C[e.type]+"+":0===e.g?C[e.type]+"?":C[e.type]}function F(e){if("none"===e)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}`);const t=S[e];if(void 0===t)throw Error(`XPST0051: The type "${e}" could not be found`);return t}function D(e){switch(e[e.length-1]){case"*":return{type:F(e.substr(0,e.length-1)),g:2};case"?":return{type:F(e.substr(0,e.length-1)),g:0};case"+":return{type:F(e.substr(0,e.length-1)),g:1};default:return{type:F(e),g:3}}}function k(e){const t=e.value;if(T(e.type,53))return!0;if(T(e.type,0))return t;if(T(e.type,1)||T(e.type,20)||T(e.type,19))return 0!==t.length;if(T(e.type,2))return!isNaN(t)&&0!==t;throw x(`Cannot determine the effective boolean value of a value with the type ${C[e.type]}`)}function R(e,t=0){e.h=t}var M=class{constructor(e){this.v=L,this.h=e;let t=!1;this.value={next:()=>t?A:(t=!0,E(e))},this.o=null}gb(){return this}filter(e){return e(this.h,0,this)?this:this.v.create()}first(){return this.h}O(){return[this.h]}fa(){return null===this.o&&(this.o=k(this.h)),this.o}Pa(){return 1}G(){return!1}sa(){return!0}map(e){return this.v.create(e(this.h,0,this))}M(e){return e([this.h])}Y(e){return e.m?e.m(this):e.default(this)}};const U=new B;function G(e=null,t=null){if(null===e)return U;if(Array.isArray(e))switch(e.length){case 0:return U;case 1:return new M(e[0]);default:return new class{constructor(e){this.o=L,this.h=e;let t=-1;this.value={next:()=>(t++,t>=e.length?A:E(e[t]))}}gb(){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?A:E(this.h[t])}})}first(){return this.h[0]}O(){return this.h}fa(){if(T(this.h[0].type,53))return!0;throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.")}Pa(){return this.h.length}G(){return!1}sa(){return!1}map(e){let t=-1;return this.o.create({next:()=>++t>=this.h.length?A:E(e(this.h[t],t,this))},this.h.length)}M(e){return e(this.h)}Y(e){return e.multiple?e.multiple(this):e.default(this)}}(e)}return e.next?new class{constructor(e,t=null){this.D=L,this.value={next:t=>null!==this.o&&this.h>=this.o?A:void 0!==this.v[this.h]?E(this.v[this.h++]):(t=e.next(t)).done?(this.o=this.h,t):((this.l||2>this.h)&&(this.v[this.h]=t.value),this.h++,t)},this.l=!1,this.v=[],this.h=0,this.o=t}gb(){return this.D.create(this.O())}filter(e){let t=-1;const 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(void 0!==this.v[0])return this.v[0];const e=this.value.next(0);return R(this),e.done?null:e.value}O(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const e=this.value;this.l=!0;let t=e.next(0);for(;!t.done;)t=e.next(0);return this.v}fa(){const e=this.value,t=this.h;R(this);var n=e.next(0);if(n.done)return R(this,t),!1;if(T((n=n.value).type,53))return R(this,t),!0;if(!e.next(0).done)throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.");return R(this,t),k(n)}Pa(e=!1){if(null!==this.o)return this.o;if(e)return-1;e=this.h;const t=this.O().length;return R(this,e),t}G(){return 0===this.o||null===this.first()}sa(){if(null!==this.o)return 1===this.o;var e=this.value;const t=this.h;return R(this),e.next(0).done?(R(this,t),!1):(e=e.next(0),R(this,t),e.done)}map(e){let t=0;const n=this.value;return this.D.create({next:r=>(r=n.next(r)).done?A:E(e(r.value,t++,this))},this.o)}M(e,t){const n=this.value;let r;const a=[];let o=!0;return function(){for(let e=n.next(o?0:t);!e.done;e=n.next(t))o=!1,a.push(e.value);r=e(a).value}(),this.D.create({next:()=>r.next(0)})}Y(e){let t=null;const n=e=>{t=e.value,-1!==(e=e.Pa(!0))&&(this.o=e)};return this.D.create({next:r=>t?t.next(r):this.G()?(n(e.empty?e.empty(this):e.default(this)),t.next(r)):this.sa()?(n(e.m?e.m(this):e.default(this)),t.next(r)):(n(e.multiple?e.multiple(this):e.default(this)),t.next(r))})}}(e,t):new M(e)}var L={create:G,m:e=>new M(e),empty:()=>G(),aa:()=>G(w),V:()=>G(v)};function $(e){const t=[],n=e.value;return()=>{let e=0;return L.create({next:()=>{if(void 0!==t[e])return t[e++];const r=n.next(0);return r.done?r:t[e++]=r}})}}var H=class{constructor(e,t,n){this.namespaceURI=t||null,this.prefix=e||"",this.localName=n}ya(){return this.prefix?this.prefix+":"+this.localName:this.localName}};var P=class extends I{constructor({j:e,arity:t,Xa:n=!1,J:r=!1,localName:a,namespaceURI:o,i:s,value:i}){for(super(60,null),this.value=i,this.J=r,r=-1,i=0;i<e.length;i++)4===e[i]&&(r=i);-1<r&&(i=Array(t-(e.length-1)).fill(e[r-1]),e=e.slice(0,r).concat(i)),this.o=e,this.v=t,this.ia=n,this.D=a,this.l=o,this.s=s}Xa(){return this.ia}};function _(e,t){const n=[];return 2!==e&&1!==e||n.push("type-1-or-type-2"),n.push(`type-${e}`),t&&n.push(`name-${t}`),n}function j(e){const t=e.node.nodeType;let n;return 2!==t&&1!==t||(n=e.node.localName),_(t,n)}function X(e){const t=e.nodeType;let n;return 2!==t&&1!==t||(n=e.localName),_(t,n)}var q=class{getAllAttributes(e,t=null){return 1!==e.nodeType?[]:(e=Array.from(e.attributes),null===t?e:e.filter((e=>X(e).includes(t))))}getAttribute(e,t){return 1!==e.nodeType?null:e.getAttribute(t)}getChildNodes(e,t=null){return e=Array.from(e.childNodes),null===t?e:e.filter((e=>X(e).includes(t)))}getData(e){return 2===e.nodeType?e.value:e.data}getFirstChild(e,t=null){for(e=e.firstChild;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getLastChild(e,t=null){for(e=e.lastChild;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}getNextSibling(e,t=null){for(e=e.nextSibling;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getParentNode(e,t=null){return(e=2===e.nodeType?e.ownerElement:e.parentNode)&&(null===t||X(e).includes(t))?e:null}getPreviousSibling(e,t=null){for(e=e.previousSibling;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}};var V=new class{insertBefore(e,t,n){return e.insertBefore(t,n)}removeAttributeNS(e,t,n){return e.removeAttributeNS(t,n)}removeChild(e,t){return e.removeChild(t)}setAttributeNS(e,t,n,r){e.setAttributeNS(t,n,r)}setData(e,t){e.data=t}};class Y{constructor(e){this.h=e}insertBefore(e,t,n){return this.h.insertBefore(e,t,n)}removeAttributeNS(e,t,n){return this.h.removeAttributeNS(e,t,n)}removeChild(e,t){return this.h.removeChild(e,t)}setAttributeNS(e,t,n,r){this.h.setAttributeNS(e,t,n,r)}setData(e,t){this.h.setData(e,t)}}function z(e){return void 0!==e.Ra}function J(e,t,n){let r=null;return t&&(z(t.node)?r={F:t.F,offset:n,parent:t.node}:t.F&&(r=t.F)),{node:e,F:r}}function Q(e,t,n=null){return e.getAllAttributes(t.node,n).map((e=>J(e,t,e.nodeName)))}function K(e,t,n){return z(t=t.node)?(e=t.attributes.find((e=>n===e.name)))?e.value:null:(e=e.h.getAttribute(t,n))?e:null}function W(e,t,n=null){return e.getChildNodes(t.node,n).map(((e,n)=>J(e,t,n)))}function Z(e,t){return e.getData(t.node)}function ee(e,t,n=null){const r=t.node;return z(r)?e=r.childNodes[0]:((n=e.h.getFirstChild(r,n))&&10===n.nodeType&&(n=e.h.getNextSibling(n)),e=n),e?J(e,t,0):null}function te(e,t,n=null){var r=t.node;return z(r)?(e=r.childNodes.length-1,r=r.childNodes[e]):((r=e.h.getLastChild(r,n))&&10===r.nodeType&&(r=e.h.getPreviousSibling(r)),e=e.getChildNodes(t.node,n).length-1),r?J(r,t,e):null}function ne(e,t,n=null){const r=t.node,a=t.F;if(a)"number"==typeof a.offset&&r===a.parent.childNodes[a.offset]||"string"==typeof a.offset&&r===a.parent.attributes.find((e=>a.offset===e.nodeName))?(e=a.parent,t=a.F):(e=e.getParentNode(r,n),t=a);else{if(z(r))return null;e=e.getParentNode(r,n),t=null}return e?{node:e,F:t}:null}function re(e,t,n=null){const r=t.node;let a,o,s;const i=t.F;if(z(r))i&&(s=i.offset+1,a=i.parent.childNodes[s]);else{if(!i){for(a=r;a&&(!(a=e.h.getNextSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}s=i.offset+1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[s]}return a?J(a,o||ne(e,t,n),s):null}function ae(e,t,n=null){const r=t.node;let a,o;const s=t.F;let i;if(z(r))s&&(i=s.offset-1,a=s.parent.childNodes[i]);else{if(!s){for(a=r;a&&(!(a=e.h.getPreviousSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}i=s.offset-1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[i]}return a?J(a,o||ne(e,t,n),i):null}var oe=class{constructor(e){this.h=e,this.o=[]}getAllAttributes(e,t=null){return z(e)?e.attributes:this.h.getAllAttributes(e,t)}getChildNodes(e,t=null){return t=z(e)?e.childNodes:this.h.getChildNodes(e,t),9===e.nodeType?t.filter((e=>10!==e.nodeType)):t}getData(e){return z(e)?2===e.nodeType?e.value:e.data:this.h.getData(e)||""}getParentNode(e,t=null){return this.h.getParentNode(e,t)}},se=(e,t,n,r,a)=>a.M((([e])=>r.M((([t])=>{const n=e.value;if(0>=n||n>t.h.length)throw Error("FOAY0001: array position out of bounds.");return t.h[n-1]()})))),ie=class extends P{constructor(e){super({value:(e,t,n,r)=>se(0,0,0,L.m(this),r),localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/array",j:[{type:5,g:3}],arity:1,i:{type:59,g:2}}),this.type=62,this.h=e}};function le(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 ce(e){return{type:le(e),value:e}}function ue(e,t){return e=e.map((e=>e.first())),t(e)}function he(e,t){var n=T(e.type,1)||T(e.type,20)||T(e.type,19),r=T(t.type,1)||T(t.type,20)||T(t.type,19);return n&&r?e.value===t.value:(n=T(e.type,4)||T(e.type,3)||T(e.type,6),r=T(t.type,4)||T(t.type,3)||T(t.type,6),n&&r?!(!isNaN(e.value)||!isNaN(t.value))||e.value===t.value:(n=T(e.type,0)||T(e.type,22)||T(e.type,18)||T(e.type,23)||T(e.type,44),r=T(t.type,0)||T(t.type,22)||T(t.type,18)||T(t.type,23)||T(t.type,44),!(!n||!r)&&e.value===t.value))}var pe=(e,t,n,r,a)=>ue([r,a],(([e,t])=>(e=e.h.find((e=>he(e.key,t))))?e.value():L.empty())),de=class extends P{constructor(e){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(e,t,n,r)=>pe(0,0,0,L.m(this),r),i:{type:59,g:2}}),this.type=61,this.h=e}};function me(e,t){return e.h()===t.h()&&e.o()===t.o()}var fe=class{Za(){return 0}getHours(){return 0}getMinutes(){return 0}$a(){return 0}h(){return 0}o(){return 0}getSeconds(){return 0}ab(){return 0}na(){return!0}};function ge(e){var t=Math.abs(e.Za()),n=Math.abs(e.getHours());const r=Math.abs(e.getMinutes());return n=(n?`${n}H`:"")+(r?`${r}M`:"")+((e=Math.abs(e.getSeconds()))?`${e}S`:""),(t=""+(t?`${t}D`:""))&&n?`${t}T${n}`:t||(n?`T${n}`:"T0S")}var ye=class extends fe{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.ca=e}Za(){return Math.trunc(this.ca/86400)}getHours(){return Math.trunc(this.ca%86400/3600)}getMinutes(){return Math.trunc(this.ca%3600/60)}o(){return this.ca}getSeconds(){const e=this.ca%60;return Object.is(-0,e)?0:e}na(){return!Object.is(-0,this.ca)&&0<=this.ca}toString(){return(this.na()?"P":"-P")+ge(this)}},we=(e,t,n,r,a,o)=>(e=86400*e+3600*t+60*n+r+a,new ye(o||0===e?e:-e)),ve=e=>(e=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e))?we(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,xe=e=>"Z"===(e=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(e))[1]?we(0,0,0,0,0,!0):we(0,e[3]?parseInt(e[3],10):0,e[4]?parseInt(e[4],10):0,0,0,"+"===e[2]);function be(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");if((e=e.ca*t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)}function Ae(e){return e?parseInt(e,10):null}function Ee(e){const t=(e+="").startsWith("-");return t&&(e=e.substring(1)),(t?"-":"")+e.padStart(4,"0")}function Ne(e){return(e+"").padStart(2,"0")}function Te(e){return 1===(e+="").split(".")[0].length&&(e=e.padStart(e.length+1,"0")),e}function Be(e){return 0===e.getHours()&&0===e.getMinutes()?"Z":(e.na()?"+":"-")+Ne(Math.abs(e.getHours()))+":"+Ne(Math.abs(e.getMinutes()))}function Ie(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;const n=Ae(t[2]),r=Ae(t[3]),a=t[4],o=Ae(t[5]),s=Ae(t[6]),i=Ae(t[7]),l=t[8]?parseFloat(t[8]):0;if(t=t[9]?xe(t[9]):null,e&&(-271821>e||273860<e))throw Error("FODT0001: Datetime year is out of bounds");return a?new Oe(e,n,r,o,s,i,l,t,9):null!==o&&null!==s&&null!==i?new Oe(1972,12,31,o,s,i,l,t,8):null!==e&&null!==n&&null!==r?new Oe(e,n,r,0,0,0,0,t,7):null!==e&&null!==n?new Oe(e,n,1,0,0,0,0,t,11):null!==n&&null!==r?new Oe(1972,n,r,0,0,0,0,t,13):null!==e?new Oe(e,1,1,0,0,0,0,t,12):null!==n?new Oe(1972,n,1,0,0,0,0,t,14):new Oe(1972,12,r,0,0,0,0,t,15)}function Ce(e,t){switch(t){case 15:return new Oe(1972,12,e.o,0,0,0,0,e.X,15);case 14:return new Oe(1972,e.h,1,0,0,0,0,e.X,14);case 12:return new Oe(e.v,1,1,0,0,0,0,e.X,12);case 13:return new Oe(1972,e.h,e.o,0,0,0,0,e.X,13);case 11:return new Oe(e.v,e.h,1,0,0,0,0,e.X,11);case 8:return new Oe(1972,12,31,e.l,e.s,e.D,e.pa,e.X,8);case 7:return new Oe(e.v,e.h,e.o,0,0,0,0,e.X,7);default:return new Oe(e.v,e.h,e.o,e.l,e.s,e.D,e.pa,e.X,9)}}function Se(e,t){return t=e.X||t||xe("Z"),new Date(Date.UTC(e.v,e.h-1,e.o,e.l-t.getHours(),e.s-t.getMinutes(),e.D,1e3*e.pa))}var Oe=class{constructor(e,t,n,r,a,o,s,i,l=9){this.v=e,this.h=t,this.o=n+(24===r?1:0),this.l=24===r?0:r,this.s=a,this.D=o,this.pa=s,this.X=i,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 Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+"T"+Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 7:return Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 8:return Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 15:return"---"+Ne(this.o)+(this.X?Be(this.X):"");case 14:return"--"+Ne(this.h)+(this.X?Be(this.X):"");case 13:return"--"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 12:return Ee(this.v)+(this.X?Be(this.X):"");case 11:return Ee(this.v)+"-"+Ne(this.h)+(this.X?Be(this.X):"")}throw Error("Unexpected subType")}};function Fe(e,t,n){const r=Se(e,n).getTime();return r===(n=Se(t,n).getTime())?e.pa===t.pa?0:e.pa>t.pa?1:-1:r>n?1:-1}function De(e,t,n){return 0===Fe(e,t,n)}function ke(e,t,n){return e=(Se(e,n).getTime()-Se(t,n).getTime())/1e3,new ye(e)}function Re(e){throw Error(`Not implemented: adding durations to ${C[e.type]}`)}function Me(e){throw Error(`Not implemented: subtracting durations from ${C[e.type]}`)}function Ue(e,t){if(null===e)return null;switch(typeof e){case"boolean":return e?w:v;case"number":return y(e,3);case"string":return y(e,1);case"object":if("nodeType"in e)return ce({node:e,F:null});if(Array.isArray(e))return new ie(e.map((e=>void 0===e?()=>L.empty():$(e=null===(e=Ue(e))?L.empty():L.m(e)))));if(e instanceof Date){const t=Ie(e.toISOString());return y(t,t.type)}return new de(Object.keys(e).filter((t=>void 0!==e[t])).map((t=>{var n=Ue(e[t]);return n=null===n?L.empty():L.m(n),{key:y(t,1),value:$(n)}})))}throw Error(`Value ${String(e)} of type "${typeof e}" is not adaptable to an XPath value.`)}function Ge(e,t){if("number"!=typeof e&&("string"!=typeof e||!f.get(t)(e)))throw Error(`Cannot convert JavaScript value '${e}' to the XPath type ${C[t]} since it is not valid.`)}function Le(e,t,n){if(null===t)return null;switch(e){case 0:return t?w:v;case 1:return y(t+"",1);case 3:case 2:return Ge(t,3),y(+t,3);case 4:return Ge(t,e),y(+t,4);case 5:return Ge(t,e),y(0|t,5);case 6:return Ge(t,e),y(+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 ${C[e]}.`);return y(Ce(Ie(t.toISOString()),e),e);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!=typeof t||!("nodeType"in t))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${C[e]}.`);return ce({node:t,F:null});case 59:case 61:return Ue(t);default:throw Error(`Values of the type "${C[e]}" can not be adapted from JavaScript to equivalent XPath values.`)}}function $e(e,t,n){if(0===n.g)return null===(t=Le(n.type,t))?[]:[t];if(2===n.g||1===n.g){if(!Array.isArray(t))throw Error(`The JavaScript value ${t} should be an array if it is to be converted to ${O(n)}.`);return t.map((e=>Le(n.type,e))).filter((e=>null!==e))}const r=Le(n.type,t);if(null===r)throw Error(`The JavaScript value ${t} should be a single entry if it is to be converted to ${O(n)}.`);return[r]}function He(e,t,n={type:59,g:0}){return L.create($e(0,t,n))}var Pe=2**32;function _e(e,t,n,r){return new ze({N:n,Fa:t,za:r||e.za,wa:e.wa},e.h,e.o)}function je(e,t){let n=0;const r=t.value;return{next:a=>(a=r.next(a)).done?A:E(_e(e,n++,a.value,t))}}function Xe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.ob}function qe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.tb}function Ve(e,t=null){return e=29421*(null!=t?t:e.o.h)%Pe,{pb:Math.floor(e),Yb:e/Pe}}function Ye(e,t){return new ze({N:e.N,Fa:e.Fa,za:e.za,wa:Object.assign(Object.create(null),e.wa,t)},e.h,e.o)}var ze=class{constructor(e,t={ob:null,tb:null,hb:!1},n=new class{constructor(){this.h=Math.abs(Math.floor(Math.random()*Pe)%Pe)}}){this.h=t,this.Fa=e.Fa,this.za=e.za,this.N=e.N,this.wa=e.wa||Object.create(null),this.o=n}},Je=class{constructor(e,t,n,r,a,o,s,i,l){this.debug=e,this.Ga=t,this.h=n,this.Ia=r,this.Ma=a,this.o=o,this.v=s,this.ib=i,this.Ua=l}};function Qe(e){let t=0,n=null,r=!0;return L.create({next:a=>{for(;t<e.length;){n||(n=e[t].value,r=!0);const o=n.next(r?0:a);if(r=!1,!o.done)return o;t++,n=null}return A}})}var Ke=(e,t,n)=>Error(`FORG0001: Cannot cast ${e} to ${C[t]}${n?`, ${n}`:""}`),We=e=>Error(`XPDY0002: ${e}`),Ze=e=>Error(`XPTY0004: ${e}`),et=e=>Error(`FOTY0013: Atomization is not supported for ${C[e]}.`),tt=e=>Error(`XPST0081: The prefix ${e} could not be resolved.`);function nt(e,t){if(T(e.type,46)||T(e.type,19)||T(e.type,0)||T(e.type,4)||T(e.type,3)||T(e.type,6)||T(e.type,5)||T(e.type,2)||T(e.type,23)||T(e.type,1))return L.create(e);const n=t.h;if(T(e.type,53)){const t=e.value;if(2===t.node.nodeType||3===t.node.nodeType)return L.create(y(Z(n,t),19));if(8===t.node.nodeType||7===t.node.nodeType)return L.create(y(Z(n,t),1));const r=[];return function e(a){if(8!==t.node.nodeType&&7!==t.node.nodeType){var o=a.nodeType;3===o||4===o?r.push(n.getData(a)):1!==o&&9!==o||n.getChildNodes(a).forEach((t=>{e(t)}))}}(t.node),L.create(y(r.join(""),19))}if(T(e.type,60)&&!T(e.type,62))throw et(e.type);if(T(e.type,62))return Qe(e.h.map((e=>rt(e(),t))));throw Error(`Atomizing ${e.type} is not implemented.`)}function rt(e,t){let n=!1;const r=e.value;let a=null;return L.create({next:()=>{for(;!n;){if(!a){var e=r.next(0);if(e.done){n=!0;break}a=nt(e.value,t).value}if(!(e=a.next(0)).done)return e;a=null}return A}})}function at(e){for(e=g[e];e&&0!==e.C;)e=e.parent;return e?e.type:null}function ot(e,t){const n=(t=g[t]).Ja;if(!n||!n.whiteSpace)return t.parent?ot(e,t.parent.type):e;switch(t.Ja.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 st(e,t){for(t=g[t];t&&null===t.fb;){if(2===t.C||3===t.C)return!0;t=t.parent}return!t||t.fb(e)}function it(e,t){for(;e;){if(e.Oa&&e.Oa[t])return e.Oa[t];e=e.parent}return()=>!0}function lt(e){return!e||(2===e.g||0===e.g)}function ct(e,t){return e(2)?e=>({u:!0,value:e}):e(0)?e=>({u:!0,value:e?1:0}):e(1)||e(19)?e=>{switch(e){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}}const n=parseFloat(e);return isNaN(n)?{u:!1,error:Ke(e,t)}:{u:!0,value:n}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${t} or any of its derived types.`)})}function ut(e){const t=Math.abs(e.ab());return(t?`${t}Y`:"")+(""+((e=Math.abs(e.$a()))?`${e}M`:""))||"0M"}var ht=class extends fe{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.ea=e}$a(){const e=this.ea%12;return 0===e?0:e}h(){return this.ea}ab(){return Math.trunc(this.ea/12)}na(){return!Object.is(-0,this.ea)&&0<=this.ea}toString(){return(this.na()?"P":"-P")+ut(this)}},pt=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))>Number.MAX_SAFE_INTEGER||!Number.isFinite(t))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");e=new ht(e||0===t?t:-t)}else e=null;return e};function dt(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");if((e=Math.round(e.ea*t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)}var mt=class extends fe{constructor(e,t){super(),this.Va=e,this.Ea=t}Za(){return this.Ea.Za()}getHours(){return this.Ea.getHours()}getMinutes(){return this.Ea.getMinutes()}$a(){return this.Va.$a()}h(){return this.Va.h()}o(){return this.Ea.o()}getSeconds(){return this.Ea.getSeconds()}ab(){return this.Va.ab()}na(){return this.Va.na()&&this.Ea.na()}toString(){const e=this.na()?"P":"-P",t=ut(this.Va),n=ge(this.Ea);return"0M"===t?e+n:"T0S"===n?e+t:e+t+n}};const ft=[3,6,4,5];function gt(e){if(e(1)||e(19))return e=>({u:!0,value:e+""});if(e(20))return e=>({u:!0,value:e});if(e(23))return e=>({u:!0,value:e.prefix?`${e.prefix}:${e.localName}`:e.localName});if(e(44))return e=>({u:!0,value:e.toString()});if(e(2)){if(e(5)||e(4))return e=>({u:!0,value:(e+"").replace("e","E")});if(e(6)||e(3))return e=>isNaN(e)?{u:!0,value:"NaN"}:isFinite(e)?Object.is(e,-0)?{u:!0,value:"-0"}:{u:!0,value:(e+"").replace("e","E").replace("E+","E")}:{u:!0,value:(0>e?"-":"")+"INF"}}return e(9)||e(7)||e(8)||e(15)||e(14)||e(13)||e(12)||e(11)||e(16)||e(17)||e(18)?e=>({u:!0,value:e.toString()}):e(22)?e=>({u:!0,value:e.toUpperCase()}):e=>({u:!0,value:e+""})}const yt=[2,5,17,16];function wt(e,t){const n=t=>T(e,t);if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(t){case 19:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,19)}:e}(n);case 1:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,1)}:e}(n);case 6:return function(e){const t=ct(e,6);return e=>(e=t(e)).u?{u:!0,value:y(e.value,6)}:e}(n);case 3:return function(e){const t=ct(e,3);return e=>(e=t(e)).u?{u:!0,value:y(e.value,3)}:e}(n);case 4:return function(e){return e(5)?e=>({u:!0,value:y(e,4)}):e(6)||e(3)?e=>isNaN(e)||!isFinite(e)?{u:!1,error:Error(`FOCA0002: Can not cast ${e} to xs:decimal`)}:Math.abs(e)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${e} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:y(e,4)}:e(0)?e=>({u:!0,value:y(e?1:0,4)}):e(1)||e(19)?e=>{const t=parseFloat(e);return!isNaN(t)||isFinite(t)?{u:!0,value:y(t,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:decimal`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})}(n);case 5:return function(e){return e(0)?e=>({u:!0,value:y(e?1:0,5)}):e(2)?e=>{const t=Math.trunc(e);return!isFinite(t)||isNaN(t)?{u:!1,error:Error(`FOCA0002: can not cast ${e} to xs:integer`)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${e} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:e(1)||e(19)?e=>{const t=parseInt(e,10);return isNaN(t)?{u:!1,error:Ke(e,5)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${e} 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.")})}(n);case 2:return function(e){var t=wt;return n=>{for(const r of ft){const a=t(e,r)(n);if(a.u)return a}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${n}" given type to xs:numeric or any of its derived types.`)}}}(e);case 18:return function(e){return e(16)?e=>({u:!0,value:y(new mt(e,new ye(e.na()?0:-0)),18)}):e(17)?e=>({u:!0,value:y(e=new mt(new ht(e.na()?0:-0),e),18)}):e(18)?e=>({u:!0,value:y(e,18)}):e(19)||e(1)?e=>({u:!0,value:y(new mt(pt(e),ve(e)),18)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})}(n);case 16:return function(e){return e(18)&&!e(17)?e=>({u:!0,value:y(e.Va,16)}):e(17)?()=>({u:!0,value:y(pt("P0M"),16)}):e(19)||e(1)?e=>{const t=pt(e);return t?{u:!0,value:y(t,16)}:{u:!1,error:Ke(e,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})}(n);case 17:return function(e){return e(18)&&!e(16)?e=>({u:!0,value:y(e.Ea,17)}):e(16)?()=>({u:!0,value:y(ve("PT0.0S"),17)}):e(19)||e(1)?e=>{const t=ve(e);return t?{u:!0,value:y(t,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})}(n);case 9:return function(e){return e(7)?e=>({u:!0,value:y(Ce(e,9),9)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})}(n);case 8:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,8),8)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})}(n);case 7:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,7),7)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})}(n);case 11:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,11),11)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})}(n);case 12:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,12),12)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})}(n);case 13:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,13),13)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})}(n);case 15:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,15),15)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})}(n);case 14:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,14),14)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})}(n);case 0:return function(e){return e(2)?e=>({u:!0,value:0===e||isNaN(e)?v:w}):e(1)||e(19)?e=>{switch(e){case"true":case"1":return{u:!0,value:w};case"false":case"0":return{u:!0,value:v};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.")})}(n);case 21:return function(e){return e(22)?e=>{let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(parseInt(e.substr(n,2),16));return{u:!0,value:y(btoa(t),21)}}:e(1)||e(19)?e=>({u:!0,value:y(e,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})}(n);case 22:return function(e){return e(21)?e=>{let t="";for(let n=0,r=(e=atob(e)).length;n<r;n++)t+=Number(e.charCodeAt(n)).toString(16);return{u:!0,value:y(t.toUpperCase(),22)}}:e(1)||e(19)?e=>({u:!0,value:y(e,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})}(n);case 20:return function(e){return e(1)||e(19)?e=>({u:!0,value:y(e,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})}(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}.`)})}const vt=Object.create(null);function xt(e,t){if(19===e&&1===t)return e=>({u:!0,value:y(e,1)});if(44===t)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===e||45===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===e||46===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(T(e,60)&&1===t)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(e===t)return e=>({u:!0,value:{type:t,value:e}});const n=yt.includes(e)?e:at(e),r=yt.includes(t)?t:at(t);if(null===r||null===n)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${r?C[e]:C[t]} is unknown.`)});const a=[];return 1!==n&&19!==n||a.push((e=>{const n=ot(e,t);return st(n,t)?{u:!0,value:n}:{u:!1,error:Ke(e,t,"pattern validation failed.")}})),n!==r&&(a.push(wt(n,r)),a.push((e=>({u:!0,value:e.value})))),19!==r&&1!==r||a.push((e=>st(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>function(e,t){let n=g[t];for(;n;){if(n.Ja&&!Object.keys(n.Ja).every((t=>{if("whiteSpace"===t)return!0;const r=it(n,t);return!r||r(e,n.Ja[t])})))return!1;n=n.parent}return!0}(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>({u:!0,value:{type:t,value:e}}))),e=>{e={u:!0,value:e};for(let t=0,n=a.length;t<n&&(e=a[t](e.value),!1!==e.u);++t);return e}}function bt(e,t){const n=e.type+1e4*t;let r=vt[n];return r||=vt[n]=xt(e.type,t),r.call(void 0,e.value,t)}function At(e,t){if(!0===(e=bt(e,t)).u)return e.value;throw e.error}function Et(e){let t=!1;return{next:()=>t?A:(t=!0,E(e))}}function Nt(e,t){return e===t||!(!e||!t||e.offset!==t.offset||e.parent!==t.parent)&&Nt(e.F,t.F)}function Tt(e,t){return!!(e===t||e.node===t.node&&Nt(e.F,t.F))}function Bt(e,t){const n=[];for(;t;t=ne(e,t,null))n.unshift(t);return n}function It(e,t){const n=[];for(;t;t=e.getParentNode(t,null))n.unshift(t);return n}function Ct(e,t,n,r){if(n.F||r.F||z(n.node)||z(r.node)){if(Tt(n,r))return 0;n=Bt(t,n),r=Bt(t,r);const o=n[0],s=r[0];if(!Tt(o,s))return t=e.findIndex((e=>Tt(e,o))),n=e.findIndex((e=>Tt(e,s))),-1===t&&(t=e.push(o)),-1===n&&(n=e.push(s)),t-n;e=1;for(var a=Math.min(n.length,r.length);e<a&&Tt(n[e],r[e]);++e);return n[e]?r[e]?function(e,t,n){var r=ne(e,t,null);for(let a=0,o=(e=W(e,r,null)).length;a<o;++a){if(r=e[a],Tt(r,t))return-1;if(Tt(r,n))return 1}}(t,n[e],r[e]):1:-1}if((n=n.node)===(a=r.node))return 0;if(r=It(t,n),n=It(t,a),r[0]!==n[0]){const a={node:r[0],F:null},o={node:n[0],F:null};return t=e.findIndex((e=>Tt(e,a))),n=e.findIndex((e=>Tt(e,o))),-1===t&&(t=e.push(a)),-1===n&&(n=e.push(o)),t-n}for(e=1,a=Math.min(r.length,n.length);e<a&&r[e]===n[e];++e);if(r=r[e],a=n[e],!r)return-1;if(!a)return 1;for(let o=0,s=(t=t.getChildNodes(n[e-1],null)).length;o<s;++o){if(e=t[o],e===r)return-1;if(e===a)return 1}}function St(e,t,n,r){const a=T(n.type,47),o=T(r.type,47);if(a&&!o){if(Tt(n=ne(t,n.value),r=r.value))return 1}else if(o&&!a){if(Tt(n=n.value,r=ne(t,r.value)))return-1}else if(a&&o){if(Tt(ne(t,r.value),ne(t,n.value)))return n.value.node.localName>r.value.node.localName?1:-1;n=ne(t,n.value),r=ne(t,r.value)}else n=n.value,r=r.value;return Ct(e,t,n,r)}function Ot(e,t,n){return St(e.o,e,t,n)}function Ft(e,t){return kt(t,((t,n)=>St(e.o,e,t,n))).filter(((e,t,n)=>0===t||!Tt(e.value,n[t-1].value)))}const Dt=(e,t)=>e<t?-1:0;function kt(e,t=Dt){if(1>=e.length)return e;var n=Math.floor(e.length/2);const r=kt(e.slice(0,n),t);for(e=kt(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))}var Rt=e;function Mt(e,t,n,r,a){if(T(e.type,t.type))return e;if(T(t.type,46)&&T(e.type,53)&&(e=nt(e,n).first()),T(e.type,t.type)||46===t.type)return e;if(T(e.type,19)){if(!(n=At(e,t.type)))throw Error(`XPTY0004 Unable to convert ${a?"return":"argument"} of type ${C[e.type]} to type ${O(t)} while calling ${r}`);return n}if(n=function(e,t){if(T(e.type,2)){if(T(e.type,6))return 3===t?y(e.value,3):null;if(T(e.type,4)){if(6===t)return y(e.value,6);if(3===t)return y(e.value,3)}return null}return T(e.type,20)&&1===t?y(e.value,1):null}(e,t.type),!n)throw Error(`XPTY0004 Unable to cast ${a?"return":"argument"} of type ${C[e.type]} to type ${O(t)} while calling ${r}`);return n}function Ut(e){switch(e){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}var Gt=(e,t,n,r,a)=>0===e.g?t.Y({default:()=>t.map((t=>Mt(t,e,n,r,a))),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "?", but got "+".`)}}):1===e.g?t.Y({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "+", but got "empty-sequence()"`)},default:()=>t.map((t=>Mt(t,e,n,r,a)))}):2===e.g?t.map((t=>Mt(t,e,n,r,a))):t.Y({m:()=>t.map((t=>Mt(t,e,n,r,a))),default:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected exactly one`)}});function Lt(e,t){return T(e,5)?y(t,5):T(e,6)?y(t,6):T(e,3)?y(t,3):y(t,4)}const $t=[{la:"M",ja:1e3},{la:"CM",ja:900},{la:"D",ja:500},{la:"CD",ja:400},{la:"C",ja:100},{la:"XC",ja:90},{la:"L",ja:50},{la:"XL",ja:40},{la:"X",ja:10},{la:"IX",ja:9},{la:"V",ja:5},{la:"IV",ja:4},{la:"I",ja:1}];function Ht(e,t){let n=parseInt(e,10);if(e=0>n,n=Math.abs(n),!n)return"-";let r=$t.reduce(((e,t)=>{const r=Math.floor(n/t.ja);return n-=r*t.ja,e+t.la.repeat(r)}),"");return t&&(r=r.toLowerCase()),e&&(r=`-${r}`),r}const Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");function _t(e,t){const n=0>(e=parseInt(e,10));if(!(e=Math.abs(e)))return"-";let r,a="";for(;0<e;)r=(e-1)%Pt.length,a=Pt[r]+a,e=(e-r)/Pt.length|0;return t&&(a=a.toLowerCase()),n&&(a=`-${a}`),a}function jt(e,t,n,r,a,o){let s=!1;return L.create({next:()=>{if(s)return A;const t=a.first();if(!t)return s=!0,A;if((T(t.type,6)||T(t.type,3))&&(0===t.value||isNaN(t.value)||1/0===t.value||-1/0===t.value))return s=!0,E(t);var n;if(n=o?o.first().value:0,s=!0,function(e){if(Math.floor(e)===e||isNaN(e))return 0;const t=(e=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${e}`))[1]?e[1].length:0;return e[3]?e[2]?t+parseInt(e[3],10):0>(e=t-parseInt(e[3],10))?0:e:t}(t.value)<n)return E(t);const r=[5,4,3,6].find((e=>T(t.type,e)));switch(n=function(e,t,n){return t&&0==e*n%1%.5?0==Math.floor(e*n)%2?Math.floor(e*n)/n:Math.ceil(e*n)/n:Math.round(e*n)/n}(At(t,4).value,e,Math.pow(10,n)),r){case 4:return E(y(n,4));case 3:return E(y(n,3));case 6:return E(y(n,6));case 5:return E(y(n,5))}}})}const Xt=(e,t,n,r)=>rt(r,t).Y({empty:()=>L.m(y(NaN,3)),m:()=>{const e=bt(r.first(),3);return e.u?L.m(e.value):L.m(y(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values")}});const qt=(e,t,n,r=L.empty())=>(t=r.G()?Ve(e):Ve(e,function(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}(At(r.first(),1).value)),function t(n){const r=(t,r,a,o)=>{if(o.G()||o.sa())return o;for(t=o.O(),r=n,a=t.length-1;1<a;a--){const n=t[o=(r=Ve(e,r).pb)%a];t[o]=t[a],t[a]=n}return L.create(t)};return L.m(new de([{key:y("number",1),value:()=>L.m(y(Ve(e,n).Yb,3))},{key:y("next",1),value:()=>L.m(new P({value:()=>t(Ve(e,n).pb),Xa:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:y("permute",1),value:()=>L.m(new P({value:r,Xa:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],arity:1,i:{type:59,g:2}}))}]))}(t.pb));var Vt=[{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((e=>Lt(e.type,Math.abs(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"format-integer",j:[{type:5,g:0},{type:1,g:3}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>{if(e=r.first(),a=a.first(),r.G())return L.m(y("",1));switch(a.value){case"I":return r=Ht(e.value),L.m(y(r,1));case"i":return r=Ht(e.value,!0),L.m(y(r,1));case"A":return L.m(y(_t(e.value),1));case"a":return L.m(y(_t(e.value,!0),1));default:throw Error(`Picture: ${a.value} is not implemented yet. The supported picture strings are "A", "a", "I", and "i"`)}}},{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((e=>Lt(e.type,Math.ceil(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>Lt(e.type,Math.floor(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:jt.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:jt.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:jt.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:jt.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:Xt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[],i:{type:3,g:3},callFunction:(e,t,n)=>{const r=e.N&&Gt({type:46,g:0},L.m(e.N),t,"fn:number",!1);if(!r)throw We("fn:number needs an atomizable context item.");return Xt(0,t,0,r)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:qt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:qt}];function Yt(){throw Error("FOCH0002: No collations are supported")}function zt(e,t,n,r){if(null===t.N)throw We("The function which was called depends on dynamic context, which is absent.");return e(t,n,r,L.m(t.N))}const Jt=(e,t,n,r)=>r.Y({empty:()=>L.m(y("",1)),default:()=>r.map((e=>{if(T(e.type,53)){const n=nt(e,t).first();return T(e.type,47)?At(n,1):n}return At(e,1)}))}),Qt=(e,t,n,r,a)=>ue([a],(([e])=>rt(r,t).M((t=>(t=t.map((e=>At(e,1).value)).join(e.value),L.m(y(t,1))))))),Kt=(e,t,n,r)=>r.G()?L.m(y(0,5)):(e=r.first().value,L.m(y(Array.from(e).length,5))),Wt=(e,t,n,r,a,o)=>{const s=jt(!1,0,0,0,a,null),i=null!==o?jt(!1,0,0,0,o,null):null;let l=!1,c=null,u=null,h=null;return L.create({next:()=>l?A:c||(c=r.first(),null!==c)?(u||=s.first(),!h&&o&&(h=null,h=i.first()),l=!0,E(y(Array.from(c.value).slice(Math.max(u.value-1,0),o?u.value+h.value-1:void 0).join(""),1))):(l=!0,E(y("",1)))})},Zt=(e,t,n,r,a)=>r.G()||0===r.first().value.length?L.empty():(e=r.first().value,a=rn(a=a.first().value),L.create(e.split(a).map((e=>y(e,1))))),en=(e,t,n,r)=>r.G()?L.m(y("",1)):(e=r.first().value.trim(),L.m(y(e.replace(/\s+/g," "),1))),tn=new Map,nn=new Map;function rn(e){if(nn.has(e))return nn.get(e);let t;try{t=new RegExp(e,"g")}catch(e){throw Error(`FORX0002: ${e}`)}if(t.test(""))throw Error(`FORX0003: the pattern ${e} matches the zero length string`);return nn.set(e,t),t}var an=[{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,a)=>r.G()||a.G()?L.empty():(e=r.first().value)>(a=a.first().value)?L.m(y(1,5)):e<a?L.m(y(-1,5)):L.m(y(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:Yt},{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((e=>rt(e,t).M((e=>L.m(y(e.map((e=>null===e?"":At(e,1).value)).join(""),1)))))),ue(r,(e=>L.m(y(e.map((e=>e.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:Yt},{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,a)=>(e=r.G()?"":r.first().value,0===(a=a.G()?"":a.first().value).length?L.aa():0===e.length?L.V():e.includes(a)?L.aa():L.V())},{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,a)=>0===(e=a.G()?"":a.first().value).length?L.aa():0===(r=r.G()?"":r.first().value).length?L.V():r.endsWith(e)?L.aa():L.V()},{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:Yt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:en},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:zt.bind(null,((e,t,n,r)=>en(e,0,0,Jt(0,t,0,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,a)=>0===(e=a.G()?"":a.first().value).length?L.aa():0===(r=r.G()?"":r.first().value).length?L.V():r.startsWith(e)?L.aa():L.V()},{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:Yt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:Jt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[],i:{type:1,g:3},callFunction:zt.bind(null,Jt)},{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,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)||-1===(a=e.indexOf(a))?L.m(y("",1)):L.m(y(e.substring(0,a),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,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)?L.m(y(e,1)):-1===(t=e.indexOf(a))?L.m(y("",1)):L.m(y(e.substring(t+a.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:Wt},{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:Wt},{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.G()?L.m(y("",1)):r.map((e=>y(e.value.toUpperCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"lower-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.G()?L.m(y("",1)):r.map((e=>y(e.value.toLowerCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2},{type:1,g:3}],i:{type:1,g:3},callFunction:Qt},{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)=>Qt(0,t,0,r,L.m(y("",1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:Kt},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:zt.bind(null,((e,t,n,r)=>Kt(e,0,0,Jt(0,t,0,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:Zt},{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)=>Zt(e,0,0,en(e,0,0,r),L.m(y(" ",1)))},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{e=Array.from(e?e.value:"");const r=Array.from(t.value),a=Array.from(n.value);return t=e.map((e=>r.includes(e)?(e=r.indexOf(e))<=a.length?a[e]:void 0:e)),L.m(y(t.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((e=>(e=e.map((e=>{if(9===(e=e.value)||10===e||13===e||32<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e)return String.fromCodePoint(e);throw Error("FOCH0001")})).join(""),L.m(y(e,1))))),localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>0===(e=e?e.value.split(""):[]).length?L.empty():L.create(e.map((e=>y(e.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)=>ue([r],(([e])=>null===e||0===e.value.length?L.create(y("",1)):L.create(y(encodeURIComponent(e.value).replace(/[!'()*]/g,(e=>"%"+e.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)=>ue([r],(([e])=>null===e||0===e.value.length?L.create(y("",1)):L.create(y(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,(e=>encodeURI(e))),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,a)=>ue([r,a],(([e,t])=>{if(null===e||null===t)return L.empty();e=e.value;var n=t.value;if(e.length!==n.length)return L.V();for(t=e.split(""),e=n.split(""),n=0;n<t.length;n++)if(t[n].codePointAt(0)!==e[n].codePointAt(0))return L.V();return L.aa()})),localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:0}},{j:[{type:1,g:0},{type:1,g:3}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{e=e?e.value:"",t=t.value;let n=tn.get(t);if(!n){try{n=(0,Rt.compile)(t,{language:"xpath"})}catch(e){throw Error(`FORX0002: ${e}`)}tn.set(t,n)}return n(e)?L.aa():L.V()})),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,a,o)=>ue([r,a,o],(([e,t,n])=>{if(e=e?e.value:"",t=t.value,(n=n.value).includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");return n=n.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map((e=>{switch(e){case"\\$":return"$$";case"\\\\":return"\\";case"$$":throw Error('FORX0004: invalid replacement: "$$"');default:return e}})).join(""),t=rn(t),e=e.replace(t,n),L.m(y(e,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")}}];function on(e,t,n,r,a){if(null===n.N)throw We(`The function ${e} depends on dynamic context, which is absent.`);return t(n,r,a,L.m(n.N))}const sn=(e,t,n,r)=>ue([r],(([e])=>{if(null===e)return L.empty();switch((e=e.value).node.nodeType){case 1:case 2:return L.m(y(new H(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return L.m(y(new H("","",e.node.target),23));default:return L.empty()}})),ln=(e,t,n,r)=>r.Y({default:()=>Jt(0,t,0,sn(0,0,0,r)),empty:()=>L.m(y("",1))}),cn=(e,t,n,r)=>rt(r,t),un=(e,t,n,r)=>ue([r],(([e])=>null!==(e=e?e.value:null)&&ee(t.h,e,null)?L.aa():L.V())),hn=(e,t,n,r)=>ue([r],(([e])=>{function n(e){let t=0,n=e;for(;null!==n;)(e.node.nodeType!==n.node.nodeType?0:1===n.node.nodeType?n.node.localName===e.node.localName&&n.node.namespaceURI===e.node.namespaceURI:7===n.node.nodeType?n.node.target===e.node.target:1)&&t++,n=ae(r,n,null);return t}if(null===e)return L.empty();const r=t.h;let a="";for(e=e.value;null!==ne(t.h,e,null);e=ne(t.h,e,null))switch(e.node.nodeType){case 1:var o=e;a=`/Q{${o.node.namespaceURI||""}}${o.node.localName}[${n(o)}]${a}`;break;case 2:a=`/@${(o=e).node.namespaceURI?`Q{${o.node.namespaceURI}}`:""}${o.node.localName}${a}`;break;case 3:a=`/text()[${n(e)}]${a}`;break;case 7:a=`/processing-instruction(${(o=e).node.target})[${n(o)}]${a}`;break;case 8:a=`/comment()[${n(e)}]${a}`}return 9===e.node.nodeType?L.create(y(a||"/",1)):L.create(y("Q{http://www.w3.org/2005/xpath-functions}root()"+a,1))})),pn=(e,t,n,r)=>r.map((e=>y(e.value.node.namespaceURI||"",20))),dn=(e,t,n,r)=>r.Y({default:()=>r.map((e=>7===e.value.node.nodeType?y(e.value.node.target,1):y(e.value.node.localName||"",1))),empty:()=>L.m(y("",1))});function mn(e,t,n){if(2===t.node.nodeType)return Tt(t,n);for(;n;){if(Tt(t,n))return!0;if(9===n.node.nodeType)break;n=ne(e,n,null)}return!1}const fn=(e,t,n,r)=>r.map((e=>{if(!T(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let n;for(e=e.value;e;)n=e,e=ne(t.h,n,null);return ce(n)}));var gn=[{j:[{type:53,g:0}],callFunction:ln,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:on.bind(null,"name",ln),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:pn,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:on.bind(null,"namespace-uri",pn),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((e=>e.length?(e=Ft(t.h,e).reduceRight(((e,n,r,a)=>r===a.length-1?(e.push(n),e):(mn(t.h,n.value,e[0].value)||e.unshift(n),e)),[]),L.create(e)):L.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((e=>e.length?(e=Ft(t.h,e).reduce(((e,n,r)=>0===r?(e.push(n),e):(mn(t.h,e[e.length-1].value,n.value)||e.push(n),e)),[]),L.create(e)):L.empty()),1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:un,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:on.bind(null,"has-children",un),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:hn,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[],callFunction:on.bind(null,"path",hn),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:sn,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:on.bind(null,"node-name",sn),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:dn,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:on.bind(null,"local-name",dn),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:fn,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:on.bind(null,"root",fn),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:on.bind(null,"data",cn),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:cn,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}}];function yn(e,t){let n=0;const r=e.length;let a=!1,o=null;return{next:()=>{if(!a){for(;n<r;){o||=t(e[n],n,e);const r=o.next(0);if(o=null,!r.value)return E(!1);n++}return a=!0,E(!0)}return A}}}function wn(e){return 1===(e=e.node.nodeType)||3===e}function vn(e,t){if((T(e.type,4)||T(e.type,6))&&(T(t.type,4)||T(t.type,6))){var n=At(e,6),r=At(t,6);return n.value===r.value||isNaN(e.value)&&isNaN(t.value)}return(T(e.type,4)||T(e.type,6)||T(e.type,3))&&(T(t.type,4)||T(t.type,6)||T(t.type,3))?(n=At(e,3),r=At(t,3),n.value===r.value||isNaN(e.value)&&isNaN(t.value)):T(e.type,23)&&T(t.type,23)?e.value.namespaceURI===t.value.namespaceURI&&e.value.localName===t.value.localName:(T(e.type,9)||T(e.type,7)||T(e.type,8)||T(e.type,11)||T(e.type,12)||T(e.type,13)||T(e.type,14)||T(e.type,15))&&(T(t.type,9)||T(t.type,7)||T(t.type,8)||T(t.type,11)||T(t.type,12)||T(t.type,13)||T(t.type,14)||T(t.type,15))?De(e.value,t.value):(T(e.type,16)||T(e.type,17)||T(e.type,18))&&(T(t.type,16)||T(t.type,17)||T(t.type,17))?me(e.value,t.value):e.value===t.value}function xn(e,t,n){const[r,a]=[t,n].map((t=>({type:1,value:t.reduce(((t,n)=>t+nt(n,e).first().value),"")})));return E(vn(r,a))}function bn(e,t,n,r){for(;e.value&&T(e.value.type,56);){t.push(e.value);const a=re(r,e.value.value);if(e=n.next(0),a&&3!==a.node.nodeType)break}return e}function An(e,t,n,r,a){const o=t.h,s=r.value,i=a.value;let l,c=null,u=null,h=null;const p=[],d=[];return{next:()=>{for(;!l;)if(c||=s.next(0),c=bn(c,p,s,o),u||=i.next(0),u=bn(u,d,i,o),p.length||d.length){var r=xn(t,p,d);if(p.length=0,d.length=0,!1===r.value)return l=!0,r}else{if(c.done||u.done)return l=!0,E(c.done===u.done);if(h||=Nn(e,t,n,c.value,u.value),r=h.next(0),h=null,!1===r.value)return l=!0,r;u=c=null}return A}}}function En(e,t,n,r,a){return r=W(t.h,r.value),a=W(t.h,a.value),r=r.filter((e=>wn(e))),a=a.filter((e=>wn(e))),r=L.create(r.map((e=>ce(e)))),a=L.create(a.map((e=>ce(e)))),An(e,t,n,r,a)}function Nn(e,t,n,r,a){if(T(r.type,46)&&T(a.type,46))return Et(vn(r,a));if(T(r.type,61)&&T(a.type,61))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):yn(r.h,(r=>{const o=a.h.find((e=>vn(e.key,r.key)));return o?An(e,t,n,r.value(),o.value()):Et(!1)}))}(e,t,n,r,a);if(T(r.type,62)&&T(a.type,62))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):yn(r.h,((r,o)=>(o=a.h[o],An(e,t,n,r(),o()))))}(e,t,n,r,a);if(T(r.type,53)&&T(a.type,53)){if(T(r.type,55)&&T(a.type,55))return En(e,t,n,r,a);if(T(r.type,54)&&T(a.type,54))return function(e,t,n,r,a){const o=An(e,t,n,sn(0,0,0,L.m(r)),sn(0,0,0,L.m(a))),s=En(e,t,n,r,a);r=Q(t.h,r.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e))),a=Q(t.h,a.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e)));const i=An(e,t,n,L.create(r),L.create(a));let l=!1;return{next:()=>{if(l)return A;var e=o.next(0);return!e.done&&!1===e.value||!(e=i.next(0)).done&&!1===e.value?(l=!0,e):(e=s.next(0),l=!0,e)}}}(e,t,n,r,a);if(T(r.type,47)&&T(a.type,47)||T(r.type,57)&&T(a.type,57)||T(r.type,58)&&T(a.type,58))return function(e,t,n,r,a){const o=An(e,t,n,sn(0,0,0,L.m(r)),sn(0,0,0,L.m(a)));let s=!1;return{next:()=>{if(s)return A;const e=o.next(0);return e.done||!1!==e.value?E(vn(nt(r,t).first(),nt(a,t).first())):(s=!0,e)}}}(e,t,n,r,a)}return Et(!1)}var Tn=(e="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${e}`),Bn=e=>Error(`XUTY0004: The attribute ${e.name}="${e.value}" follows a node that is not an attribute node.`),In=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Cn=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),Sn=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),On=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Fn=e=>Error(`XUDY0017: The target ${e.outerHTML} is used in more than one replace value of expression.`),Dn=e=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${e}'`),kn=e=>Error(`XUDY0023: The namespace binding ${e} is conflicting.`),Rn=e=>Error(`XUDY0024: The namespace binding ${e} is conflicting.`),Mn=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function Un(e,t,n){return t&&null!==t.N&&e.B?(null===e.nb&&(e.nb=$(e.h(null,n).gb())),e=e.nb()):e=e.h(t,n),e}var Gn=class{constructor(e,t,n={B:!1,W:!1,P:"unsorted",subtree:!1},r=!1,a){this.o=e,this.ia=n.P||"unsorted",this.subtree=!!n.subtree,this.W=!!n.W,this.B=!!n.B,this.Ka=t,this.J=!1,this.nb=null,this.Nb=r,this.type=a}D(){return null}v(e){if(this.Ka.forEach((t=>t.v(e))),!this.Nb&&this.Ka.some((e=>e.J)))throw Tn()}},Ln=class{constructor(e,t){this.I=e,this.da=t}},$n=class{constructor(e){e&&"object"==typeof e&&"nodeType"in e&&("function"==typeof(e=e.ownerDocument||e).createElementNS&&"function"==typeof e.createProcessingInstruction&&"function"==typeof e.createTextNode&&"function"==typeof e.createComment&&(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)}},Hn=(e,t,n)=>{t.forEach((t=>{n.insertBefore(e.node,t.node,null)}))},Pn=(e,t,n,r)=>{const a=ne(n,e);var o=e.node.nodeType;if(2===o){if(t.some((e=>2!==e.node.nodeType)))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const o=a?a.node:null;r.removeAttributeNS(o,e.node.namespaceURI,e.node.nodeName),t.forEach((e=>{const t=e.node.nodeName;if(K(n,a,t))throw Dn(`An attribute ${t} already exists.`);r.setAttributeNS(o,e.node.namespaceURI,t,Z(n,e))}))}if(1===o||3===o||8===o||7===o){const s=(o=re(n,e))?o.node:null;r.removeChild(a.node,e.node),t.forEach((e=>{r.insertBefore(a.node,e.node,s)}))}},_n=(e,t,n,r)=>{if(jn(e,t),e.filter((e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertInto":Hn(e.target,e.content,r);break;case"insertAttributes":((e,t,n,r)=>{t.forEach((t=>{const a=t.node.nodeName;if(K(n,e,a))throw Dn(`An attribute ${a} already exists.`);r.setAttributeNS(e.node,t.node.namespaceURI,a,Z(n,t))}))})(e.target,e.content,t,r);break;case"rename":((e,t,n,r,a)=>{let o;switch(r||=new $n(e?e.node:null),e.node.nodeType){case 1:const s=n.getAllAttributes(e.node),i=n.getChildNodes(e.node),l=r.createElementNS(t.namespaceURI,t.ya());o={node:l,F:null},s.forEach((e=>{a.setAttributeNS(l,e.namespaceURI,e.nodeName,e.value)})),i.forEach((e=>{a.insertBefore(l,e,null)}));break;case 2:(t=r.createAttributeNS(t.namespaceURI,t.ya())).value=Z(n,e),o={node:t,F:null};break;case 7:o={node:r.createProcessingInstruction(t.ya(),Z(n,e)),F:null}}if(!ne(n,e))throw Error("Not supported: renaming detached nodes.");Pn(e,[o],n,a)})(e.target,e.o,t,n,r);break;case"replaceValue":var a=e.target;if(e=e.o,2===a.node.nodeType){const n=ne(t,a);n?r.setAttributeNS(n.node,a.node.namespaceURI,a.node.nodeName,e):a.node.value=e}else r.setData(a.node,e)}})),e.filter((e=>-1!==["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertAfter":((e,t,n,r)=>{const a=ne(n,e).node,o=(e=re(n,e))?e.node:null;t.forEach((e=>{r.insertBefore(a,e.node,o)}))})(e.target,e.content,t,r);break;case"insertBefore":((e,t,n,r)=>{const a=ne(n,e).node;t.forEach((t=>{r.insertBefore(a,t.node,e.node)}))})(e.target,e.content,t,r);break;case"insertIntoAsFirst":((e,t,n,r)=>{const a=(n=ee(n,e))?n.node:null;t.forEach((t=>{r.insertBefore(e.node,t.node,a)}))})(e.target,e.content,t,r);break;case"insertIntoAsLast":Hn(e.target,e.content,r)}})),e.filter((e=>"replaceNode"===e.type)).forEach((e=>{Pn(e.target,e.o,t,r)})),e.filter((e=>"replaceElementContent"===e.type)).forEach((e=>{((e,t,n,r)=>{n.getChildNodes(e.node).forEach((t=>r.removeChild(e.node,t))),t&&r.insertBefore(e.node,t.node,null)})(e.target,e.text,t,r)})),e.filter((e=>"delete"===e.type)).forEach((e=>{e=e.target;var n=ne(t,e);(n=n?n.node:null)&&(2===e.node.nodeType?r.removeAttributeNS(n,e.node.namespaceURI,e.node.nodeName):r.removeChild(n,e.node))})),e.some((e=>"put"===e.type)))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.')};const jn=(e,t)=>{function n(t,n){const r=new Set;e.filter((e=>e.type===t)).map((e=>e.target)).forEach((e=>{e=e?e.node:null,r.has(e)&&n(e),r.add(e)}))}n("rename",(e=>{throw Error(`XUDY0015: The target ${e.outerHTML} is used in more than one rename expression.`)})),n("replaceNode",(e=>{throw Error(`XUDY0016: The target ${e.outerHTML} is used in more than one replace expression.`)})),n("replaceValue",(e=>{throw Fn(e)})),n("replaceElementContent",(e=>{throw Fn(e)}));const r=new Map,a=e=>new H(e.node.prefix,e.node.namespaceURI,e.node.localName);e.filter((e=>"replaceNode"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);n=n?n.node:null;const o=r.get(n);o?o.push(...e.o.map(a)):r.set(n,e.o.map(a))})),e.filter((e=>"rename"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);if(n){n=n.node;var a=r.get(n);a?a.push(e.o):r.set(n,[e.o])}})),r.forEach((e=>{const t={};e.forEach((e=>{if(t[e.prefix]||(t[e.prefix]=e.namespaceURI),t[e.prefix]!==e.namespaceURI)throw Rn(e.namespaceURI)}))}))};var Xn=(e,...t)=>e.concat(...t.filter(Boolean));function qn(e){return e.J?(t,n)=>e.s(t,n):(t,n)=>{const r=e.h(t,n);return{next:()=>E({da:[],I:r.O()})}}}var Vn=class extends Gn{constructor(e,t,n,r){super(e,t,n,!0,r),this.J=!0}h(){throw Tn()}};function Yn(e,t){return t((e=e.next(0)).value.da),L.create(e.value.I)}var zn=class extends Vn{constructor(e,t,n,r){super(e,t,n,r),this.J=this.Ka.some((e=>e.J))}h(e,t){return this.A(e,t,this.Ka.map((e=>n=>e.h(n,t))))}s(e,t){let n=[];const r=this.A(e,t,this.Ka.map((e=>e.J?r=>Yn(r=e.s(r,t),(e=>n=Xn(n,e))):n=>e.h(n,t))));let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E(new Ln(e,n))}}}v(e){super.v(e),function(e){e.Ka.some((e=>e.J))&&(e.J=!0)}(this)}};const Jn=["external","attribute","nodeName","nodeType","universal"],Qn=Jn.length;function Kn(e,t){for(let n=0;n<Qn;++n){if(t.h[n]<e.h[n])return 1;if(t.h[n]>e.h[n])return-1}return 0}var Wn=class{constructor(e){if(this.h=Jn.map((t=>e[t]||0)),Object.keys(e).some((e=>!Jn.includes(e))))throw Error("Invalid specificity kind passed")}add(e){const t=Jn.reduce(((t,n,r)=>(t[n]=this.h[r]+e.h[r],t)),Object.create(null));return new Wn(t)}};const Zn=()=>Ze("Expected base expression of a function call to evaluate to a sequence of single function item");function er(e,t,n,r){const a=[];for(let o=0;o<t.length;++o){if(null===t[o]){a.push(null);continue}const s=Gt(e[o],t[o],n,r,!1);a.push(s)}return a}function tr(e,t){if(!T(e.type,60))throw Ze("Expected base expression to evaluate to a function item");if(e.v!==t)throw Zn();return e}function nr(e,t,n,r,a,o,s){let i=0;return a=a.map((e=>e?null:o[i++](n))),0<=(a=er(e.o,a,r,e.D)).indexOf(null)?function(e,t){const n=e.value,r=t.map((e=>null===e?null:$(e)));return t=t.reduce(((t,n,r)=>(null===n&&t.push(e.o[r]),t)),[]),t=new P({j:t,arity:t.length,Xa:!0,J:e.J,localName:"boundFunction",namespaceURI:e.l,i:e.s,value:function(e,t,a){const o=Array.from(arguments).slice(3),s=r.map((e=>null===e?o.shift():e()));return n.apply(void 0,[e,t,a].concat(s))}}),L.m(t)}(e,a):(t=t.apply(void 0,[n,r,s,...a]),Gt(e.s,t,r,e.D,!0))}var rr=class extends zn{constructor(e,t,n){super(new Wn({external:1}),[e].concat(t.filter((e=>!!e))),{P:"unsorted",W:!1,subtree:!1,B:!1},n),this.ma=t.length,this.S=t.map((e=>null===e)),this.L=null,this.xa=e,this.La=t}s(e,t){if(!this.l||!this.l.J)return super.s(e,t);let n=[];const r=nr(this.l,((e,t,r,...a)=>Yn(this.l.value(e,t,r,...a),(e=>{n=Xn(n,e)}))),e,t,this.S,this.La.map((r=>()=>r.J?Yn(r.s(e,t),(e=>{n=Xn(n,e)})):Un(r,e,t))),this.L);let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E({da:n,I:e})}}}A(e,t,[n,...r]){if(this.l)return nr(this.l,((e,t,n,...r)=>this.l.value(e,t,n,...r)),e,t,this.S,r,this.L);const a=n(e);return a.Y({default:()=>{throw Zn()},m:()=>a.M((([n])=>{if((n=tr(n,this.ma)).J)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return nr(n,n.value,e,t,this.S,r,this.L)}))})}v(e){if(this.L=zr(e),super.v(e),this.xa.B){if(!(e=Un(this.xa,null,null)).sa())throw Zn();this.l=tr(e.first(),this.ma),this.l.J&&(this.J=!0)}}};const ar=(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{if(t=t.value,n=n.value,t>e.h.length||0>=t)throw Error("FOAY0001: subarray start out of bounds.");if(0>n)throw Error("FOAY0002: subarray length out of bounds.");if(t+n>e.h.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return L.m(new ie(e.h.slice(t-1,n+t-1)))})),or=(e,t,n,r,a)=>ue([r],(([e])=>a.M((t=>{t=t.map((e=>e.value)).sort(((e,t)=>t-e)).filter(((e,t,n)=>n[t-1]!==e));const n=e.h.concat();for(let r=0,a=t.length;r<a;++r){const a=t[r];if(a>e.h.length||0>=a)throw Error("FOAY0001: subarray position out of bounds.");n.splice(a-1,1)}return L.m(new ie(n))})))),sr=e=>T(e,1)||T(e,20)||T(e,19),ir=(e,t,n,r,a)=>0===r.length?0!==a.length:0!==a.length&&Nn(e,t,n,r[0],a[0]).next(0).value?ir(e,t,n,r.slice(1),a.slice(1)):r[0].value!=r[0].value||(sr(r[0].type)&&0!==a.length&&sr(a[0].type)||0!==a.length)&&r[0].value<a[0].value;function lr(e,t){return T(t.type,62)?t.h.reduce(((e,t)=>t().M((t=>t.reduce(lr,e)))),e):Qe([e,L.m(t)])}var cr=[{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)=>ue([r],(([e])=>L.m(y(e.h.length,5))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"get",j:[{type:62,g:3},{type:5,g:3}],i:{type:59,g:2},callFunction:se},{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,a,o)=>ue([a,r],(([e,t])=>{if(0>=(e=e.value)||e>t.h.length)throw Error("FOAY0001: array position out of bounds.");return(t=t.h.concat()).splice(e-1,1,$(o)),L.m(new ie(t))}))},{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,a)=>ue([r],(([e])=>L.m(new ie(e.h.concat([$(a)])))))},{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:ar},{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,a){const o=L.m(y(r.first().value.length-a.first().value+1,5));return ar(0,0,0,r,a,o)}},{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:or},{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,a,o)=>ue([r,a],(([e,t])=>{if((t=t.value)>e.h.length+1||0>=t)throw Error("FOAY0001: subarray position out of bounds.");return(e=e.h.concat()).splice(t-1,0,$(o)),L.m(new ie(e))}))},{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)=>se(0,0,0,r,L.m(y(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)=>or(0,0,0,r,L.m(y(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)=>ue([r],(([e])=>L.m(new ie(e.h.concat().reverse()))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r)=>r.M((e=>(e=e.reduce(((e,t)=>e.concat(t.h)),[]),L.m(new ie(e)))))},{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,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:for-each has a wrong arity.");return r=r.h.map((r=>$(a.value.call(void 0,e,t,n,er(a.o,[r()],t,"array:for-each")[0])))),L.m(new ie(r))}))},{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,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:filter has a wrong arity.");const o=r.h.map((r=>{r=er(a.o,[r()],t,"array:filter")[0];return(0,a.value)(e,t,n,r)})),s=[];let i=!1;return L.create({next:()=>{if(i)return A;for(let t=0,n=r.h.length;t<n;++t){var e=o[t].fa();s[t]=e}return e=r.h.filter(((e,t)=>s[t])),i=!0,E(new ie(e))}})}))},{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,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-left has a wrong arity.");return r.h.reduce(((r,a)=>(a=er(o.o,[a()],t,"array:fold-left")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{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,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-right has a wrong arity.");return r.h.reduceRight(((r,a)=>(a=er(o.o,[a()],t,"array:fold-right")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{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,a,o)=>ue([r,a,o],(([r,a,o])=>{if(2!==o.v)throw Ze("The callback passed into array:for-each-pair has a wrong arity.");const s=[];for(let i=0,l=Math.min(r.h.length,a.h.length);i<l;++i){const[l,c]=er(o.o,[r.h[i](),a.h[i]()],t,"array:for-each-pair");s[i]=$(o.value.call(void 0,e,t,n,l,c))}return L.m(new ie(s))}))},{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)=>ue([r],(([r])=>(r=r.h.map((e=>e().O())),((e,t,n,r)=>(r.sort(((r,a)=>An(e,t,n,L.create(r),L.create(a)).next(0).value?0:ir(e,t,n,r,a)?-1:1)),L.m(new ie(r.map((e=>()=>L.create(e)))))))(e,t,n,r))))},{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((e=>e.reduce(lr,L.empty())))}];function ur(e,t,n,r,a){return a.G()?a:L.m(At(a.first(),e))}var hr=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:ur.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:ur.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:ur.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,g:0},callFunction:ur.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:ur.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:ur.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:ur.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,g:0}],i:{type:18,g:0},callFunction:ur.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:ur.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:ur.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:ur.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",j:[{type:46,g:0}],i:{type:7,g:0},callFunction:ur.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:ur.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:ur.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:ur.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:ur.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:ur.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:ur.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:ur.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.G())return r;if(T((e=r.first()).type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");if(!st(e=ot(e=At(e,1).value,23),23))throw Error("FORG0001: The provided QName is invalid.");if(!e.includes(":"))return n=n.$(""),L.m(y(new H("",n,e),23));const[a,o]=e.split(":");if(!(n=n.$(a)))throw Error(`FONS0004: The value ${e} can not be cast to a QName. Did you mean to use fn:QName?`);return L.m(y(new H(a,n,o),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:ur.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:ur.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:ur.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],i:{type:51,g:0},callFunction:ur.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:ur.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:ur.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:ur.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",j:[{type:46,g:0}],i:{type:24,g:0},callFunction:ur.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:ur.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:ur.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:ur.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:ur.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",j:[{type:46,g:0}],i:{type:40,g:2},callFunction:ur.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",j:[{type:46,g:0}],i:{type:5,g:0},callFunction:ur.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",j:[{type:46,g:0}],i:{type:27,g:0},callFunction:ur.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:ur.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:ur.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:ur.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:ur.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:ur.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:ur.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:ur.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:ur.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:ur.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:ur.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:ur.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:ur.bind(null,16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:ur.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:ur.bind(null,10)}];const pr=(e,t,n,r)=>r.G()?r:L.m(y(r.first().value.getYear(),5)),dr=(e,t,n,r)=>r.G()?r:L.m(y(r.first().value.getMonth(),5)),mr=(e,t,n,r)=>r.G()?r:L.m(y(r.first().value.getDay(),5)),fr=(e,t,n,r)=>r.G()?r:L.m(y(r.first().value.getHours(),5)),gr=(e,t,n,r)=>r.G()?r:L.m(y(r.first().value.getMinutes(),5)),yr=(e,t,n,r)=>(r.G()||(t=(e=L).m,r=r.first().value,r=t.call(e,y(r.D+r.pa,4))),r),wr=(e,t,n,r)=>r.G()?r:(e=r.first().value.X)?L.m(y(e,17)):L.empty();var vr=[{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,a)=>{if(r.G())return r;if(a.G())return a;if(e=r.first().value,a=a.first().value,t=e.X,n=a.X,t||n){if(!t||n)if(!t&&n)t=n;else if(!me(t,n))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.")}else t=null;return L.m(y(new Oe(e.getYear(),e.getMonth(),e.getDay(),a.getHours(),a.getMinutes(),a.getSeconds(),a.pa,t),9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:pr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:mr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:gr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:yr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:wr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:pr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:mr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:wr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:gr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:yr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:wr}];function xr(e,t){const n=t.h,r=t.Ia,a=t.Ma;switch(e.node.nodeType){case 1:const s=r.createElementNS(e.node.namespaceURI,e.node.nodeName);for(var o of(n.getAllAttributes(e.node).forEach((e=>a.setAttributeNS(s,e.namespaceURI,e.nodeName,e.value))),W(n,e)))e=xr(o,t),a.insertBefore(s,e.node,null);return{node:s,F:null};case 2:return(t=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(n,e),{node:t,F:null};case 4:return{node:r.createCDATASection(Z(n,e)),F:null};case 8:return{node:r.createComment(Z(n,e)),F:null};case 9:o=r.createDocument();for(const r of W(n,e))e=xr(r,t),a.insertBefore(o,e.node,null);return{node:o,F:null};case 7:return{node:r.createProcessingInstruction(e.node.target,Z(n,e)),F:null};case 3:return{node:r.createTextNode(Z(n,e)),F:null}}}function br(e,t){const n=t.Ma;var r=t.Ia;const a=t.h;if(!z(e.node))return xr(e,t).node;switch(e.node.nodeType){case 2:return(r=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(a,e),r;case 8:return r.createComment(Z(a,e));case 1:const o=e.node.prefix,s=e.node.localName,i=r.createElementNS(e.node.namespaceURI,o?o+":"+s:s);return W(a,e).forEach((e=>{e=br(e,t),n.insertBefore(i,e,null)})),Q(a,e).forEach((e=>{n.setAttributeNS(i,e.node.namespaceURI,e.node.nodeName,Z(a,e))})),i.normalize(),i;case 7:return r.createProcessingInstruction(e.node.target,Z(a,e));case 3:return r.createTextNode(Z(a,e))}}function Ar(e,t,n){var r=e.node;if(!(z(r)||n||e.F))return r;r=t.v;const a=[];return n?br(e,t):(e=function(e,t,n){let r=e;for(e=ne(n,r);null!==e;){if(2===r.node.nodeType)t.push(r.node.nodeName);else{const a=W(n,e);t.push(a.findIndex((e=>Tt(e,r))))}r=e,e=ne(n,r)}return r}(e,a,t.h),(n=r.get(e.node))||(n={node:br(e,t),F:null},r.set(e.node,n)),function(e,t,n){for(;0<t.length;){const r=t.pop();e="string"==typeof r?Q(n,e).find((e=>e.node.nodeName===r)):W(n,e)[r]}return e.node}(n,a,t.h))}const Er=(e,t,n,r,a)=>r.M((e=>{let n="";for(let r=0;r<e.length;r++){const a=e[r],o=t.Ua&&T(a.type,53)?t.Ua.serializeToString(Ar(a.value,t,!1)):rt(L.m(a),t).map((e=>At(e,1))).first().value;n+=`{type: ${C[a.type]}, value: ${o}}\n`}return void 0!==a&&(n+=a.first().value),t.ib.trace(n),L.create(e)}));var Nr=[{j:[{type:59,g:2}],callFunction:Er,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:Er,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const Tr=(e,t,n,r,a)=>{throw e=void 0===r||r.G()?new H("err","http://www.w3.org/2005/xqt-errors","FOER0000"):r.first().value,t="",void 0===a||a.G()||(t=`: ${a.first().value}`),Error(`${e.localName}${t}`)};var Br=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:Tr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:Tr},{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:Tr},{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 Ir(e){return"string"==typeof e?e:(e=(new q).getChildNodes(e).find((e=>8===e.nodeType)))?e.data:"some expression"}var Cr=class extends Error{constructor(e,t){super(e),this.position={end:{ha:t.end.ha,line:t.end.line,offset:t.end.offset},start:{ha:t.start.ha,line:t.start.line,offset:t.start.offset}}}};function Sr(e,t){if(t instanceof Error)throw t;"string"!=typeof e&&(e=Ir(e));const n=Za(t);e=e.replace(/\r/g,"").split("\n");const r=Math.floor(Math.log10(Math.min(n.end.line+2,e.length)))+1;throw e=e.reduce(((e,t,a)=>{var o=a+1;if(2<n.start.line-o||2<o-n.end.line)return e;if(a=`${Array(r).fill(" ",0,Math.floor(Math.log10(o))+1-r).join("")}${o}: `,e.push(`${a}${t}`),o>=n.start.line&&o<=n.end.line){const r=o<n.end.line?t.length+a.length:n.end.ha-1+a.length;o=o>n.start.line?a.length:n.start.ha-1+a.length,t=" ".repeat(a.length)+Array.from(t.substring(0,o-a.length),(e=>"\t"===e?"\t":" ")).join("")+"^".repeat(r-o),e.push(t)}return e}),[]),t=eo(t).join("\n"),new Cr(e.join("\n")+"\n\n"+t,n)}const Or=Object.create(null);function Fr(e,t){const n=new Map;for(let t=0;t<e.length+1;++t)n.set(t,new Map);return function r(a,o){if(0===a)return o;if(0===o)return a;if(n.get(a).has(o))return n.get(a).get(o);var s=0;return e[a-1]!==t[o-1]&&(s=1),s=Math.min(r(a-1,o)+1,r(a,o-1)+1,r(a-1,o-1)+s),n.get(a).set(o,s),s}(e.length,t.length)}function Dr(e){const t=Or[e]?Or[e]:Object.keys(Or).map((t=>({name:t,qb:Fr(e,t.slice(t.lastIndexOf(":")+1))}))).sort(((e,t)=>e.qb-t.qb)).slice(0,5).filter((t=>t.qb<e.length/2)).reduce(((e,t)=>e.concat(Or[t.name])),[]).slice(0,5);return t.length?t.map((e=>`"Q{${e.namespaceURI}}${e.localName} (${e.j.map((e=>4===e?"...":O(e))).join(", ")})"`)).reduce(((e,t,n,r)=>0===n?e+t:e+(n!==r.length-1?", ":" or ")+t),"Did you mean ")+"?":"No similar functions found."}function kr(e,t,n){var r=Or[e+":"+t];return r&&(r=r.find((e=>e.j.some((e=>4===e))?e.j.length-1<=n:e.j.length===n)))?{j:r.j,arity:n,callFunction:r.callFunction,J:r.J,localName:t,namespaceURI:e,i:r.i}:null}function Rr(e,t,n,r,a){Or[e+":"+t]||(Or[e+":"+t]=[]),Or[e+":"+t].push({j:n,arity:n.length,callFunction:a,J:!1,localName:t,namespaceURI:e,i:r})}var Mr={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"},Ur=class{constructor(e,t,n,r){this.Ca=[Object.create(null)],this.Da=Object.create(null),this.s=e,this.ia=Object.keys(t).reduce(((e,n)=>(void 0===t[n]||(e[n]=`Q{}${n}[0]`),e)),Object.create(null)),this.o=Object.create(null),this.h=Object.create(null),this.v=n,this.l=r,this.D=[]}ta(e,t,n){return kr(e,t,n)}cb(e,t){return e?null:(e=this.ia[t],this.o[t]||(this.o[t]={name:t}),e)}Sa(e,t){const n=this.l(e,t);if(n)this.D.push({ac:e,arity:t,Bb:n});else if(""===e.prefix){if(this.v)return{namespaceURI:this.v,localName:e.localName}}else if(t=this.$(e.prefix,!0))return{namespaceURI:t,localName:e.localName};return n}$(e,t=!0){return t?Mr[e]?Mr[e]:(t=this.s(e),this.h[e]||(this.h[e]={namespaceURI:t,prefix:e}),void 0!==t||e?t:null):null}},Gr=(e,t)=>(e=2===e.node.nodeType?`${e.node.nodeName}="${Z(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.ya()}" is invalid for a computed attribute constructor.`),$r=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),Hr=(e,t)=>Error(`XQST0049: The function or variable "Q{${e}}${t}" is declared more than once.`),Pr=()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),_r=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),jr=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),Xr=e=>Error(`XQDY0074: The value "${e}" of a name expressions cannot be converted to an expanded QName.`),qr=e=>Error(`XPST0081: The prefix "${e}" could not be resolved`);function Vr(e,t){return`Q{${e||""}}${t}`}function Yr(e,t){for(let n=e.length-1;0<=n;--n)if(t in e[n])return e[n][t]}function zr(e){const t=new ta(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.Ca=[Object.assign(Object.create(null),t.Ca[0],e.Ca[n])],t.l=Object.assign(Object.create(null),e.l),t.Da=e.Da,t.v=e.v;return t}function Jr(e){e.s++,e.h++,e.D[e.h]=Object.create(null),e.Ca[e.h]=Object.create(null)}function Qr(e,t,n,r,a){if(r=Vr(t,n)+"~"+r,e.l[r])throw Hr(t,n);e.l[r]=a}function Kr(e,t,n){e.D[e.h][t]=n}function Wr(e,t,n){return t=Vr(t||"",n),e.Ca[e.h][t]=`${t}[${e.s}]`}function Zr(e,t,n,r){e.Da[`${Vr(t||"",n)}[${e.s}]`]=r}function ea(e){e.D.length=e.h,e.Ca.length=e.h,e.h--}var ta=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.Da=e&&e.Da,this.Ca=e&&e.Ca}ta(e,t,n,r=!1){const a=this.l[Vr(e,t)+"~"+n];return!a||r&&a.ub?null===this.o?null:this.o.ta(e,t,n,r):a}cb(e,t){const n=Yr(this.Ca,Vr(e,t));return n||(null===this.o?null:this.o.cb(e,t))}Sa(e,t){var n=e.prefix;const r=e.localName;return""===n&&this.v?{localName:r,namespaceURI:this.v}:n&&(n=this.$(n,!1))?{localName:r,namespaceURI:n}:null===this.o?null:this.o.Sa(e,t)}$(e,t=!0){const n=Yr(this.D,e||"");return void 0===n?null===this.o?void 0:this.o.$(e||"",t):n}};function na(e,t){"*"===t||Array.isArray(t)||(t=[t]);for(let n=1;n<e.length;++n){if(!Array.isArray(e[n]))continue;const r=e[n];if("*"===t||t.includes(r[0]))return r}return null}function ra(e){return 2>e.length?"":"object"==typeof e[1]?e[2]||"":e[1]||""}function aa(e,t){return Array.isArray(e)?"object"!=typeof(e=e[1])||Array.isArray(e)?null:t in e?e[t]:null:null}function oa(e,t){return t.reduce(na,e)}function sa(e,t){const n=[];for(let r=1;r<e.length;++r){if(!Array.isArray(e[r]))continue;const a=e[r];"*"!==t&&a[0]!==t||n.push(a)}return n}function ia(e){return{localName:ra(e),namespaceURI:aa(e,"URI"),prefix:aa(e,"prefix")}}function la(e){const t=na(e,"typeDeclaration");if(!t||na(t,"voidSequenceType"))return{type:59,g:2};const n=e=>{switch(e[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 F([aa(e,"prefix"),ra(e)].join(":"));case"parenthesizedItemType":return n(na(e,"*"));default:throw Error(`Type declaration "${na(t,"*")[0]}" is not supported.`)}};e={type:n(na(t,"*")),g:3};let r=null;const a=na(t,"occurrenceIndicator");switch(a&&(r=ra(a)),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 ca(e,t,n){if("object"!=typeof e[1]||Array.isArray(e[1])){const r={};r[t]=n,e.splice(1,0,r)}else e[1][t]=n}function ua(e,t,n){return(e<<20)+(t<<12)+(n.charCodeAt(0)<<8)+n.charCodeAt(1)}var ha={[ua(2,2,"idivOp")]:5,[ua(16,16,"addOp")]:16,[ua(16,16,"subtractOp")]:16,[ua(16,16,"divOp")]:4,[ua(16,2,"multiplyOp")]:16,[ua(16,2,"divOp")]:16,[ua(2,16,"multiplyOp")]:16,[ua(17,17,"addOp")]:17,[ua(17,17,"subtractOp")]:17,[ua(17,17,"divOp")]:4,[ua(17,2,"multiplyOp")]:17,[ua(17,2,"divOp")]:17,[ua(2,17,"multiplyOp")]:17,[ua(9,9,"subtractOp")]:17,[ua(7,7,"subtractOp")]:17,[ua(8,8,"subtractOp")]:17,[ua(9,16,"addOp")]:9,[ua(9,16,"subtractOp")]:9,[ua(9,17,"addOp")]:9,[ua(9,17,"subtractOp")]:9,[ua(7,16,"addOp")]:7,[ua(7,16,"subtractOp")]:7,[ua(7,17,"addOp")]:7,[ua(7,17,"subtractOp")]:7,[ua(8,17,"addOp")]:8,[ua(8,17,"subtractOp")]:8,[ua(9,16,"addOp")]:9,[ua(9,16,"subtractOp")]:9,[ua(9,17,"addOp")]:9,[ua(9,17,"subtractOp")]:9,[ua(7,17,"addOp")]:7,[ua(7,17,"subtractOp")]:7,[ua(7,16,"addOp")]:7,[ua(7,16,"subtractOp")]:7,[ua(8,17,"addOp")]:8,[ua(8,17,"subtractOp")]:8},pa={[ua(2,2,"addOp")]:(e,t)=>e+t,[ua(2,2,"subtractOp")]:(e,t)=>e-t,[ua(2,2,"multiplyOp")]:(e,t)=>e*t,[ua(2,2,"divOp")]:(e,t)=>e/t,[ua(2,2,"modOp")]:(e,t)=>e%t,[ua(2,2,"idivOp")]:(e,t)=>Math.trunc(e/t),[ua(16,16,"addOp")]:function(e,t){return new ht(e.ea+t.ea)},[ua(16,16,"subtractOp")]:function(e,t){return new ht(e.ea-t.ea)},[ua(16,16,"divOp")]:function(e,t){return e.ea/t.ea},[ua(16,2,"multiplyOp")]:dt,[ua(16,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");if((e=Math.round(e.ea/t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)},[ua(2,16,"multiplyOp")]:(e,t)=>dt(t,e),[ua(17,17,"addOp")]:function(e,t){return new ye(e.ca+t.ca)},[ua(17,17,"subtractOp")]:function(e,t){return new ye(e.ca-t.ca)},[ua(17,17,"divOp")]:function(e,t){if(0===t.ca)throw Error("FOAR0001: Division by 0");return e.ca/t.ca},[ua(17,2,"multiplyOp")]:be,[ua(17,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");if((e=e.ca/t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)},[ua(2,17,"multiplyOp")]:(e,t)=>be(t,e),[ua(9,9,"subtractOp")]:ke,[ua(7,7,"subtractOp")]:ke,[ua(8,8,"subtractOp")]:ke,[ua(9,16,"addOp")]:Re,[ua(9,16,"subtractOp")]:Me,[ua(9,17,"addOp")]:Re,[ua(9,17,"subtractOp")]:Me,[ua(7,16,"addOp")]:Re,[ua(7,16,"subtractOp")]:Me,[ua(7,17,"addOp")]:Re,[ua(7,17,"subtractOp")]:Me,[ua(8,17,"addOp")]:Re,[ua(8,17,"subtractOp")]:Me,[ua(9,16,"addOp")]:Re,[ua(9,16,"subtractOp")]:Me,[ua(9,17,"addOp")]:Re,[ua(9,17,"subtractOp")]:Me,[ua(7,17,"addOp")]:Re,[ua(7,17,"subtractOp")]:Me,[ua(7,16,"addOp")]:Re,[ua(7,16,"subtractOp")]:Me,[ua(8,17,"addOp")]:Re,[ua(8,17,"subtractOp")]:Me};function da(e,t){return T(e,5)&&T(t,5)?5:T(e,4)&&T(t,4)?4:T(e,6)&&T(t,6)?6:3}const ma=[2,16,17,9,7,8];function fa(e,t,n){function r(e,t){return{T:a?a(e):e,U:o?o(t):t}}let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);const s=ma.filter((e=>T(t,e))),i=ma.filter((e=>T(n,e)));if(s.includes(2)&&i.includes(2)){const a=pa[ua(2,2,e)];let o=ha[ua(2,2,e)];return o||=da(t,n),"divOp"===e&&5===o&&(o=4),"idivOp"===e?ga(r,a)[0]:(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}for(const t of s)for(const n of i){const a=pa[ua(t,n,e)],o=ha[ua(t,n,e)];if(a&&void 0!==o)return(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}}function ga(e,t){return[(n,r)=>{const{T:a,U:o}=e(n,r);if(0===o.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(a.value)||Number.isNaN(o.value)||!Number.isFinite(a.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(a.value)&&!Number.isFinite(o.value)?y(0,5):y(t(a.value,o.value),5)},5]}const ya=Object.create(null);var wa=class extends Gn{constructor(e,t,n,r,a){super(t.o.add(n.o),[t,n],{B:!1},!1,r),this.A=t,this.L=n,this.l=e,this.s=a}h(e,t){return rt(Un(this.A,e,t),t).M((n=>0===n.length?L.empty():rt(Un(this.L,e,t),t).M((e=>{if(0===e.length)return L.empty();if(1<n.length||1<e.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const t=n[0];if(e=e[0],this.s&&this.type)return L.m(this.s(t,e));var r=t.type,a=e.type,o=this.l;const s=`${r}~${a}~${o}`;let i=ya[s];if(i||=ya[s]=fa(o,r,a),!(r=i))throw Error(`XPTY0004: ${this.l} not available for types ${C[t.type]} and ${C[e.type]}`);return L.m(r(t,e))}))))}};function va(e,t,n){const r=ia(oa(e,["forClauseItem","typedVariableBinding","varName"]));(e=oa(e,["forClauseItem","forExpr","sequenceExpr"]))&&(e=sa(e,"*").map((e=>n(e,t))),e.includes(void 0)||e.includes(null)||1===(e=xa(e)).length&&Da(t,r.localName,e[0]))}function xa(e){return e.filter(((e,t,n)=>n.findIndex((t=>t.type===e.type&&t.g===e.g))===t))}function ba(e,t,n){const r=sa(e,"*"),a=na(e,"atomicType");if(!a)return{type:59,g:2};if(F(aa(a,"prefix")+":"+a[2])===t.type)if(1===r.length){if(3===t.g)return n}else if(e=na(e,"occurrenceIndicator")[1],t.g===function(e){switch(e){case"*":return 2;case"?":return 0;case"+":return 1;default:return 3}}(e))return n}function Aa(e,t){Ea(e,t)}function Ea(e,t){var n=Oa.get(e[0]);if(n)return n(e,t);for(n=1;n<e.length;n++)e[n]&&Ea(e[n],t)}const Na=(e,t)=>{var n=Ea(na(e,"firstOperand")[1],t);const r=Ea(na(e,"secondOperand")[1],t);var a=e[0];if(n&&r){if(!(t=function(e,t,n){var r=[2,53,59,46,47];if(r.includes(t)||r.includes(n))return 2;let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);var s=ma.filter((e=>T(t,e)));if(r=ma.filter((e=>T(n,e))),s.includes(2)&&r.includes(2)){var i=ha[ua(2,2,e)];return void 0===i&&(i=da(t,n)),"divOp"===e&&5===i&&(i=4),"idivOp"===e?ga((function(e,t){return{T:a?a(e):e,U:o?o(t):t}}),((e,t)=>Math.trunc(e/t)))[1]:i}for(i of s)for(const t of r)if(s=ha[ua(i,t,e)],void 0!==s)return s}(a,n.type,r.type)))throw Error(`XPTY0004: ${a} not available for types ${O(n)} and ${O(r)}`);n={type:t,g:n.g},2!==t&&59!==t&&ca(e,"type",n),e=n}else e={type:2,g:3};return e},Ta=(e,t)=>{Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t);e:{switch(e[0]){case"orOp":case"andOp":ca(e,"type",t={type:0,g:3}),e=t;break e}e=void 0}return e},Ba=(e,t)=>{Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t);e:{switch(e[0]){case"unionOp":case"intersectOp":case"exceptOp":ca(e,"type",t={type:53,g:2}),e=t;break e}e=void 0}return e},Ia=(e,t)=>(Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t),ca(e,"type",t={type:0,g:3}),t),Ca=(e,t)=>{Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t),t=aa(oa(e,["firstOperand","*"]),"type");const n=aa(oa(e,["secondOperand","*"]),"type");return ca(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},Sa=(e,t)=>{Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t),t=aa(oa(e,["firstOperand","*"]),"type");const n=aa(oa(e,["secondOperand","*"]),"type");return ca(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},Oa=new Map([["unaryMinusOp",(e,t)=>((t=Ea(na(e,"operand")[1],t))?T(t.type,2)?(ca(e,"type",t={type:t.type,g:t.g}),e=t):(ca(e,"type",t={type:3,g:3}),e=t):(ca(e,"type",t={type:2,g:2}),e=t),e)],["unaryPlusOp",(e,t)=>((t=Ea(na(e,"operand")[1],t))?T(t.type,2)?(ca(e,"type",t={type:t.type,g:t.g}),e=t):(ca(e,"type",t={type:3,g:3}),e=t):(ca(e,"type",t={type:2,g:2}),e=t),e)],["addOp",Na],["subtractOp",Na],["divOp",Na],["idivOp",Na],["modOp",Na],["multiplyOp",Na],["andOp",Ta],["orOp",Ta],["sequenceExpr",(e,t)=>{const n=sa(e,"*"),r=n.map((e=>Ea(e,t)));return function(e,t,n){return t=0===t?{type:53,g:2}:1===t?n[0]:n.includes(void 0)||n.includes(null)||1<(t=xa(n)).length?{type:59,g:2}:{type:t[0].type,g:2},t&&59!==t.type&&ca(e,"type",t),t}(e,n.length,r)}],["unionOp",Ba],["intersectOp",Ba],["exceptOp",Ba],["stringConcatenateOp",(e,t)=>(Ea(na(e,"firstOperand")[1],t),Ea(na(e,"secondOperand")[1],t),ca(e,"type",t={type:1,g:3}),t)],["rangeSequenceExpr",(e,t)=>(Ea(na(e,"startExpr")[1],t),Ea(na(e,"endExpr")[1],t),ca(e,"type",t={type:5,g:1}),t)],["equalOp",Ia],["notEqualOp",Ia],["lessThanOrEqualOp",Ia],["lessThanOp",Ia],["greaterThanOrEqualOp",Ia],["greaterThanOp",Ia],["eqOp",Ca],["neOp",Ca],["ltOp",Ca],["leOp",Ca],["gtOp",Ca],["geOp",Ca],["isOp",Sa],["nodeBeforeOp",Sa],["nodeAfterOp",Sa],["pathExpr",(e,t)=>{const n=na(e,"rootExpr");return n&&n[1]&&Ea(n[1],t),sa(e,"stepExpr").map((e=>Ea(e,t))),function(e,t){var n=sa(e,"stepExpr");if(!n)return{type:59,g:2};for(const e of n){e:{n=e;var r=t;let o=null;if(!n)break e;var a=sa(n,"*");let s="";for(const e of a)switch(e[0]){case"filterExpr":o=aa(oa(e,["*"]),"type");break;case"xpathAxis":s=e[1];t:{switch(s){case"attribute":o={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":o={type:53,g:2};break t}o=void 0}break;case"nameTest":if(a=ia(e),null!==a.namespaceURI)break;if("attribute"===s&&!a.prefix)break;void 0!==(a=r.$(a.prefix||""))&&ca(e,"URI",a);break;case"lookup":o={type:59,g:2}}o&&59!==o.type&&ca(n,"type",o)}r=aa(e,"type")}return r&&59!==r.type&&ca(e,"type",r),r}(e,t)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(e,t)=>{Ea(na(na(e,"ifClause"),"*"),t);const n=Ea(na(na(e,"thenClause"),"*"),t);return t=Ea(na(na(e,"elseClause"),"*"),t),n&&t&&n.type===t.type&&n.g===t.g?(59!==n.type&&ca(e,"type",n),e=n):e={type:59,g:2},e}],["instanceOfExpr",(e,t)=>(Ea(na(e,"argExpr"),t),Ea(na(e,"sequenceType"),t),ca(e,"type",t={type:0,g:3}),t)],["integerConstantExpr",e=>{const t={type:5,g:3};return ca(e,"type",t),t}],["doubleConstantExpr",e=>{const t={type:3,g:3};return ca(e,"type",t),t}],["decimalConstantExpr",e=>{const t={type:4,g:3};return ca(e,"type",t),t}],["stringConstantExpr",e=>{const t={type:1,g:3};return ca(e,"type",t),t}],["functionCallExpr",(e,t)=>(sa(na(e,"arguments"),"*").map((e=>Ea(e,t))),function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=na(e,"functionName");var r=ia(n);let a=r.localName;var o=r.prefix;let s=r.namespaceURI;if(r=sa(na(e,"arguments"),"*"),null===s){if(!(o=t.ga.Sa({localName:a,prefix:o},r.length)))return{type:59,g:2};a=o.localName,s=o.namespaceURI,ca(n,"URI",s),n[2]=a}return(t=t.ga.ta(s,a,r.length))&&63!==t.i.type?(59!==t.i.type&&ca(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["arrowExpr",(e,t)=>(Ea(na(e,"argExpr")[1],t),function(e,t){if(!t||!t.ga)return{type:59,g:2};var n=na(e,"EQName");if(!n)return{type:59,g:2};var r=ia(n);n=r.localName;const a=r.prefix;return r=sa(na(e,"arguments"),"*"),(n=t.ga.Sa({localName:n,prefix:a},r.length))&&(t=t.ga.ta(n.namespaceURI,n.localName,r.length+1))?(59!==t.i.type&&ca(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["dynamicFunctionInvocationExpr",(e,t)=>(Ea(oa(e,["functionItem","*"]),t),(e=na(e,"arguments"))&&Ea(e,t),{type:59,g:2})],["namedFunctionRef",(e,t)=>function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=na(e,"functionName");var r=ia(n);let a=r.localName;var o=r.namespaceURI;const s=r.prefix;if(r=Number(oa(e,["integerConstantExpr","value"])[1]),!o){if(!(o=t.ga.Sa({localName:a,prefix:s},r)))return{type:59,g:2};a=o.localName,ca(n,"URI",o=o.namespaceURI)}return(t=t.ga.ta(o,a,r)||null)?(59!==t.i.type&&63!==t.i.type&&ca(e,"type",t.i),t.i):{type:59,g:2}}(e,t)],["inlineFunctionExpr",(e,t)=>(Ea(na(e,"functionBody")[1],t),ca(e,"type",t={type:60,g:3}),t)],["castExpr",e=>{var t=oa(e,["singleType","atomicType"]);return 59!==(t={type:F(aa(t,"prefix")+":"+t[2]),g:3}).type&&ca(e,"type",t),t}],["castableExpr",e=>{const t={type:0,g:3};return ca(e,"type",t),t}],["simpleMapExpr",(e,t)=>{const n=sa(e,"pathExpr");let r;for(let e=0;e<n.length;e++)r=Ea(n[e],t);return null!=r?(59!==(t={type:r.type,g:2}).type&&ca(e,"type",t),e=t):e={type:59,g:2},e}],["mapConstructor",(e,t)=>(sa(e,"mapConstructorEntry").map((e=>({key:Ea(oa(e,["mapKeyExpr","*"]),t),value:Ea(oa(e,["mapValueExpr","*"]),t)}))),function(e){const t={type:61,g:3};return ca(e,"type",t),t}(e))],["arrayConstructor",(e,t)=>(sa(na(e,"*"),"arrayElem").map((e=>Ea(e,t))),function(e){const t={type:62,g:3};return ca(e,"type",t),t}(e))],["unaryLookup",e=>(na(e,"NCName"),{type:59,g:2})],["typeswitchExpr",(e,t)=>{const n=Ea(na(e,"argExpr")[1],t),r=sa(e,"typeswitchExprCaseClause").map((e=>Ea(oa(e,["resultExpr"])[1],t)));return function(e,t,n,r){if(!t||n.includes(void 0))return{type:59,g:2};var a=sa(e,"typeswitchExprCaseClause");for(let s=0;s<n.length;s++){var o=na(a[s],"*");switch(o[0]){case"sequenceType":if(o=ba(o,t,n[s]))return 59!==o.type&&ca(e,"type",o),o;continue;case"sequenceTypeUnion":for(r=sa(o,"*"),a=0;2>a;a++)if(o=ba(r[a],t,n[s]))return 59!==o.type&&ca(e,"type",o),o;default:return{type:59,g:2}}}return 59!==r.type&&ca(e,"type",r),r}(e,n,r,Ea(oa(e,["typeswitchExprDefaultClause","resultExpr"])[1],t))}],["quantifiedExpr",(e,t)=>(sa(e,"*").map((e=>Ea(e,t))),function(e){const t={type:0,g:3};return ca(e,"type",t),t}(e))],["x:stackTrace",(e,t)=>Ea((e=sa(e,"*"))[0],t)],["queryBody",(e,t)=>Ea(e[1],t)],["flworExpr",(e,t)=>function(e,t){var n=Ea;let r=!1;for(var a=1;a<e.length;a++)switch(e[a][0]){case"letClause":Fa(t);var o=e[a],s=t,i=n,l=oa(o,["letClauseItem","typedVariableBinding","varName"]);l=ia(l),i=i((o=oa(o,["letClauseItem","letExpr"]))[1],s),Da(s,l.localName,i);break;case"forClause":r=!0,Fa(t),va(e[a],t,n);break;case"whereClause":Fa(t),n(s=e[a],t),ca(s,"type",{type:0,g:3});break;case"orderByClause":Fa(t);break;case"returnClause":return s=n,ca(n=oa(a=e[a],["*"]),"type",t=s(n,t)),ca(a,"type",t),(n=t)?(r&&(n={type:n.type,g:2}),59!==n.type&&ca(e,"type",n),n):{type:59,g:2};default:return(n=n(e[a],t))?(r&&(n={type:n.type,g:2}),59!==n.type&&ca(e,"type",n),n):{type:59,g:2}}if(!(0<t.h))throw Error("Variable scope out of bound");t.h--,t.o.pop(),t.v.pop()}(e,t)],["varRef",(e,t)=>{const n=ia(na(e,"name"));var r;e:{for(r=t.h;0<=r;r--){const e=t.o[r][n.localName];if(e){r=e;break e}}r=void 0}return r&&59!==r.type&&ca(e,"type",r),null===n.namespaceURI&&(void 0!==(t=t.$(n.prefix))&&ca(e,"URI",t)),r}]]);function Fa(e){e.h++,e.o.push({}),e.v.push({})}function Da(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 ka=class{constructor(e){this.h=0,this.ga=e,this.o=[{}],this.v=[{}]}$(e){for(let t=this.h;0<=t;t--){const n=this.v[t][e];if(void 0!==n)return n}return this.ga?this.ga.$(e):void 0}},Ra=class extends Gn{constructor(e,t){super(new Wn({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return 0===this.l.length?L.m(new ie([])):Un(this.l[0],e,t).M((e=>L.m(new ie(e.map((e=>$(L.m(e))))))))}},Ma=class extends Gn{constructor(e,t){super(new Wn({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return L.m(new ie(this.l.map((n=>$(Un(n,e,t))))))}};function Ua(e){if(null===e)throw We("context is absent, it needs to be present to use axes.");if(!T(e.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return e.value}var Ga=class extends Gn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{P:"reverse-sorted",W:!1,subtree:!1,B:!1}),this.l=e,this.s=!!t.Qa}h(e,t){t=t.h,e=Ua(e.N);var n=this.l.D();return n=n&&(n.startsWith("name-")||"type-1"===n)?"type-1":null,L.create(function(e,t,n){let r=t;return{next:()=>{if(!r)return A;const t=r;return r=ne(e,t,n),E(ce(t))}}}(t,this.s?e:ne(t,e,n),n)).filter((e=>this.l.l(e)))}};const La=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function $a(e,t){if(null===e)return t;if(null===t||e===t)return e;const n=e.startsWith("name-")?"name":e,r=t.startsWith("name-")?"name":t,a=La.get(n);return void 0!==a&&a.includes(r)?t:void 0!==(t=La.get(r))&&t.includes(n)?e:"empty"}var Ha=class extends Gn{constructor(e,t){super(new Wn({attribute:1}),[e],{P:"unsorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=$a(this.l.D(),t)}h(e,t){return t=t.h,1!==(e=Ua(e.N)).node.nodeType?L.empty():(e=Q(t,e,this.s).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).map((e=>ce(e))).filter((e=>this.l.l(e))),L.create(e))}D(){return"type-1"}},Pa=class extends Gn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.s=e,this.l=$a(t,e.D())}h(e,t){const n=t.h,r=Ua(e.N);if(1!==(e=r.node.nodeType)&&9!==e)return L.empty();let a=null,o=!1;return L.create({next:()=>{for(;!o;){if(!a){if(a=ee(n,r,this.l),!a){o=!0;continue}return E(ce(a))}if(a=re(n,a,this.l))return E(ce(a));o=!0}return A}}).filter((e=>this.s.l(e)))}};function _a(e,t,n){const r=t.node.nodeType;if(1!==r&&9!==r)return{next:()=>A};let a=ee(e,t,n);return{next(){if(!a)return A;const t=a;return a=re(e,a,n),E(t)}}}var ja=class extends Gn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{B:!1,W:!1,P:"sorted",subtree:!0}),this.l=e,this.s=!!t.Qa,this.A=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)||"type-1-or-type-2"===e?"type-1":null}h(e,t){return e=function(e,t,n){const r=[Et(t)];return{next:t=>{if(0<r.length&&0!=(1&t)&&r.shift(),!r.length)return A;for(t=r[0].next(0);t.done;){if(r.shift(),!r.length)return A;t=r[0].next(0)}return r.unshift(_a(e,t.value,n)),E(ce(t.value))}}}(t=t.h,e=Ua(e.N),this.A),this.s||e.next(0),L.create(e).filter((e=>this.l.l(e)))}};function Xa(e,t,n){var r=e.node.nodeType;if(1!==r&&9!==r)return e;for(r=te(t,e,n);null!==r;){if(1!==r.node.nodeType)return r;r=te(t,e=r,n)}return e}function qa(e,t,n=!1,r){if(n){let n=t,a=!1;return{next:()=>{if(a)return A;if(Tt(n,t))return n=Xa(t,e,r),Tt(n,t)?(a=!0,A):E(ce(n));const o=n.node.nodeType,s=9===o||2===o?null:ae(e,n,r);return null!==s?(n=Xa(s,e,r),E(ce(n))):(n=9===o?null:ne(e,n,r),Tt(n,t)?(a=!0,A):E(ce(n)))}}}const a=[_a(e,t,r)];return{next:()=>{if(!a.length)return A;let t=a[0].next(0);for(;t.done;){if(a.shift(),!a.length)return A;t=a[0].next(0)}return a.unshift(_a(e,t.value,r)),E(ce(t.value))}}}var Va=class extends Gn{constructor(e){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Ua(e.N),L.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=re(e,t,n);a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){if(!a){a=qa(e,r[0],!1,n);var t=E(ce(r[0]));const o=re(e,r[0],n);return o?r[0]=o:r.shift(),t}if(!(t=a.next(0)).done)return t;a=null}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var Ya=class extends Gn{constructor(e,t){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=$a(this.l.D(),t)}h(e,t){return t=t.h,e=Ua(e.N),L.create(function(e,t,n){return{next:()=>(t=t&&re(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},za=class extends Gn{constructor(e,t){super(e.o,[e],{P:"reverse-sorted",W:!0,subtree:!0,B:!1}),this.l=e,this.s=$a(t,this.l.D())}h(e,t){return(e=ne(t=t.h,e=Ua(e.N),this.s))?(e=ce(e),this.l.l(e)?L.m(e):L.empty()):L.empty()}};var Ja=class extends Gn{constructor(e){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Ua(e.N),L.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=ae(e,t,n);null!==a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){a||=qa(e,r[0],!0,n);var t=a.next(0);if(t.done){a=null,t=ae(e,r[0],n);const o=E(ce(r[0]));return null===t?r.shift():r[0]=t,o}return t}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var Qa=class extends Gn{constructor(e,t){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=$a(this.l.D(),t)}h(e,t){return t=t.h,e=Ua(e.N),L.create(function(e,t,n){return{next:()=>(t=t&&ae(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},Ka=class extends Gn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=$a(this.l.D(),t)}h(e){return Ua(e.N),this.l.l(e.N)?L.m(e.N):L.empty()}D(){return this.s}},Wa=class extends zn{constructor(e,t,n,r){super(e.o.add(t.o).add(n.o),[e,t,n],{B:e.B&&t.B&&n.B,W:t.W===n.W&&t.W,P:t.ia===n.ia?t.ia:"unsorted",subtree:t.subtree===n.subtree&&t.subtree},r),this.l=e}A(e,t,n){let r=null;const a=n[0](e);return L.create({next:t=>(r||(r=(a.fa()?n[1](e):n[2](e)).value),r.next(t))})}v(e){if(super.v(e),this.l.J)throw Tn()}};function Za(e){return e.h instanceof Error?e.location:Za(e.h)}function eo(e){let t;return t=e.h instanceof Cr?["Inner error:",e.h.message]:e.h instanceof Error?[e.h.toString()]:eo(e.h),t.push(` at <${e.o}>:${e.location.start.line}:${e.location.start.ha} - ${e.location.end.line}:${e.location.end.ha}`),t}var to=class{constructor(e,t,n){this.location=e,this.o=t,this.h=n}},no=class extends zn{constructor(e,t,n){super(n.o,[n],{B:n.B,W:n.W,P:n.ia,subtree:n.subtree}),this.l=t,this.L={end:{ha:e.end.ha,line:e.end.line,offset:e.end.offset},start:{ha:e.start.ha,line:e.start.line,offset:e.start.offset}}}A(e,t,[n]){let r;try{r=n(e)}catch(e){throw new to(this.L,this.l,e)}return L.create({next:e=>{try{return r.value.next(e)}catch(e){throw new to(this.L,this.l,e)}}})}v(e){try{super.v(e)}catch(e){throw new to(this.L,this.l,e)}}};function ro(e,t,n,r){let a=[];const o=e.L(t,n,r,(n=>{if(e.l instanceof oo){return Yn(ro(e.l,t,n,r),(e=>a=e))}let o=null;return L.create({next:()=>{for(;;){if(!o){var t=n.next(0);if(t.done)return A;t=e.l.s(t.value,r),o=Yn(t,(e=>a=Xn(a,e))).value}if(!(t=o.next(0)).done)return t;o=null}}})}));let s=!1;return{next:()=>{if(s)return A;const e=o.O();return s=!0,E(new Ln(e,a))}}}function ao(e,t,n,r){return e.L(t,n,r,(n=>{if(e.l instanceof oo)return ao(e.l,t,n,r);let a=null;return L.create({next:()=>{for(;;){if(!a){var t=n.next(0);if(t.done)return A;a=Un(e.l,t.value,r).value}if(!(t=a.next(0)).done)return t;a=null}}})}))}var oo=class extends Gn{constructor(e,t,n,r){super(e,t,n,!0),this.l=r,this.J=this.l.J}h(e,t){return this.L(e,Et(e),t,(n=>{if(this.l instanceof oo)return ao(this.l,e,n,t);let r=null;return L.create({next:e=>{for(;;){if(!r){var a=n.next(0);if(a.done)return A;r=Un(this.l,a.value,t).value}if(!(a=r.next(e)).done)return a;r=null}}})}))}s(e,t){return ro(this,e,Et(e),t)}v(e){super.v(e),this.J=this.l.J;for(const e of this.Ka)if(e!==this.l&&e.J)throw Tn()}},so=class extends oo{constructor(e,t,n,r){super(t.o.add(r.o),[t,r],{B:!1},r),this.S=e.prefix,this.ma=e.namespaceURI,this.Mb=e.localName,this.wb=null,this.A=n,this.La=null,this.xa=t}L(e,t,n,r){let a=null,o=null,s=0;return r({next:()=>{for(;;){if(!a){var e=t.next(0);if(e.done)return A;o=e.value,s=0,a=Un(this.xa,o,n).value}const r=a.next(0);if(!r.done)return s++,e={[this.wb]:()=>L.m(r.value)},this.La&&(e[this.La]=()=>L.m(new I(5,s))),E(Ye(o,e));a=null}}})}v(e){if(this.S&&(this.ma=e.$(this.S),!this.ma&&this.S))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in a for expression`);if(this.xa.v(e),Jr(e),this.wb=Wr(e,this.ma,this.Mb),this.A){if(this.A.prefix&&(this.A.namespaceURI=e.$(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in the positionalVariableBinding in a for expression`);this.La=Wr(e,this.A.namespaceURI,this.A.localName)}if(this.l.v(e),ea(e),this.xa.J)throw Tn();this.l.J&&(this.J=!0)}},io=class extends Gn{constructor(e,t,n){super(new Wn({external:1}),[n],{B:!1,P:"unsorted"}),this.S=e.map((({name:e})=>e)),this.A=e.map((({type:e})=>e)),this.s=null,this.L=t,this.l=n}h(e,t){const n=new P({j:this.A,arity:this.A.length,Xa:!0,J:this.l.J,localName:"dynamic-function",namespaceURI:"",i:this.L,value:(n,r,a,...o)=>(n=Ye(_e(e,-1,null,L.empty()),this.s.reduce(((e,t,n)=>(e[t]=$(o[n]),e)),Object.create(null))),Un(this.l,n,t))});return L.m(n)}v(e){if(Jr(e),this.s=this.S.map((t=>Wr(e,t.namespaceURI,t.localName))),this.l.v(e),ea(e),this.l.J)throw Error("Not implemented: inline functions can not yet be updating.")}},lo=class extends oo{constructor(e,t,n){if(super(t.o.add(n.o),[t,n],{B:!1,W:n.W,P:n.ia,subtree:n.subtree},n),e.prefix||e.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=e.prefix,this.S=e.namespaceURI,this.La=e.localName,this.ma=t,this.xa=null}L(e,t,n,r){return r({next:()=>{var e=t.next(0);return e.done?A:E(e=Ye(e=e.value,{[this.xa]:$(Un(this.ma,e,n))}))}})}v(e){if(this.A&&(this.S=e.$(this.A),!this.S&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);if(this.ma.v(e),Jr(e),this.xa=Wr(e,this.S,this.La),this.l.v(e),ea(e),this.J=this.l.J,this.ma.J)throw Tn()}},co=class extends Gn{constructor(e,t){let n;switch(super(new Wn({}),[],{B:!0,P:"sorted"},!1,t),t.type){case 5:n=y(parseInt(e,10),t.type);break;case 1:n=y(e,t.type);break;case 4:case 3:n=y(parseFloat(e),t.type);break;default:throw new TypeError("Type "+t+" not expected in a literal")}this.l=()=>L.m(n)}h(){return this.l()}},uo=class extends Gn{constructor(e,t){super(new Wn({external:1}),e.reduce(((e,{key:t,value:n})=>e.concat(t,n)),[]),{B:!1},!1,t),this.l=e}h(e,t){const n=this.l.map((n=>rt(Un(n.key,e,t),t).Y({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.")},m:e=>e})));return ue(n,(n=>L.m(new de(n.map(((n,r)=>({key:n,value:$(Un(this.l[r].value,e,t))})))))))}},ho=class extends Gn{constructor(e,t,n){super(new Wn({external:1}),[],{B:!0},!1,n),this.s=t,this.A=e,this.l=null}h(){const e=new P({j:this.l.j,J:this.l.J,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return L.m(e)}v(e){let t=this.A.namespaceURI,n=this.A.localName;const r=this.A.prefix;if(null===t){const a=e.Sa({localName:n,prefix:r},this.s);if(!a)throw Error(`XPST0017: The function ${r?r+":":""}${n} with arity ${this.s} could not be resolved. ${Dr(n)}`);t=a.namespaceURI,n=a.localName}if(this.l=e.ta(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. ${Dr(n)}`);super.v(e)}};const po={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 mo=class extends Gn{constructor(e,t,n){super(t.o,[t],{B:!1},!1,n),this.s=t,this.l=e}h(e,t){return rt(Un(this.s,e,t),t).M((e=>{if(0===e.length)return L.empty();var t=e[0];if(this.type)return e="+"===this.l?+t.value:-t.value,0===t.type&&(e=Number.NaN),L.m(y(e,this.type.type));if(1<e.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return T(t.type,19)?(t=At(t,3).value,L.m(y("+"===this.l?t:-t,3))):T(t.type,2)?"+"===this.l?L.m(t):L.m(y(-1*t.value,po[t.type])):L.m(y(Number.NaN,3))}))}},fo=class extends Gn{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new Wn({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e,this.s=e.reduce(((e,t)=>$a(e,t.D())),null)}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.N;null!==t&&T(t.type,53)&&(o=j(t.value))}return L.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const s=this.l[n];if(null!==o&&null!==s.D()&&!o.includes(s.D()))return n++,a=!0,E(v);r=Un(s,e,t)}if(!1===r.fa())return a=!0,E(v);r=null,n++}return a=!0,E(w)}return A}})}D(){return this.s}},go=class extends Gn{constructor(e,t){let n;for(super(e.reduce(((e,t)=>0<Kn(e,t.o)?e:t.o),new Wn({})),e,{B:e.every((e=>e.B))},!1,t),t=0;t<e.length&&(void 0===n&&(n=e[t].D()),null!==n);++t)if(n!==e[t].D()){n=null;break}this.s=n,this.l=e}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.N;null!==t&&T(t.type,53)&&(o=j(t.value))}return L.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const a=this.l[n];if(null!==o&&null!==a.D()&&!o.includes(a.D())){n++;continue}r=Un(a,e,t)}if(!0===r.fa())return a=!0,E(w);r=null,n++}return a=!0,E(v)}return A}})}D(){return this.s}};function yo(e,t){let n;return L.create({next:r=>{for(;;){if(!n){var a=e.value.next(r);if(a.done)return A;n=nt(a.value,t)}if(!(a=n.value.next(r)).done)return a;n=null}}})}function wo(e,t,n){function r(e,t){return{T:s?s(e):e,U:i?i(t):t}}function a(e){return T(t,e)&&T(n,e)}function o(e){return 0<e.filter((e=>T(t,e))).length&&0<e.filter((e=>T(n,e))).length}let s=null,i=null;if(T(t,19)&&T(n,19)?t=n=1:T(t,19)?(s=e=>At(e,n),t=n):T(n,19)&&(i=e=>At(e,t),n=t),T(t,23)&&T(n,23))return function(e,t){if("eqOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI===a.value.namespaceURI&&r.value.localName===a.value.localName};if("neOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI!==a.value.namespaceURI||r.value.localName!==a.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName')}(e,r);if(a(0)||o([1,47,61])||o([2,47,61])||a(20)||a(22)||a(21)||o([1,20])){var l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value===a.value};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value!==a.value};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<a.value};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<=a.value};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>a.value};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>=a.value}}}(e,r);if(void 0!==l)return l}if(a(16)&&(l=function(e,t){switch(e){case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea<a.value.ea};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea<a.value.ea};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea>a.value.ea};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea>a.value.ea}}}(e,r),void 0!==l)||a(17)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca<a.value.ca};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca<a.value.ca};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca>a.value.ca};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca>a.value.ca}}}(e,r),void 0!==l)||a(18)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return!me(r.value,a.value)}}}(e,r),void 0!==l))return l;if((a(9)||a(7)||a(8))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))};case"ltOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0>Fe(a.value,o.value,e)};case"leOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0>Fe(a.value,o.value,r)),e};case"gtOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0<Fe(a.value,o.value,e)};case"geOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0<Fe(a.value,o.value,r)),e}}}(e,r),void 0!==l))return l;if((a(11)||a(12)||a(13)||a(14)||a(15))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))}}}(e,r),void 0!==l))return l;throw Error(`XPTY0004: ${e} not available for ${C[t]} and ${C[n]}`)}const vo=Object.create(null);function xo(e,t,n){const r=`${t}~${n}~${e}`;let a=vo[r];return a||=vo[r]=wo(e,t,n),a}var bo=class extends Gn{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){const n=Un(this.l,e,t),r=Un(this.A,e,t),a=yo(n,t),o=yo(r,t);return a.Y({empty:()=>L.empty(),m:()=>o.Y({empty:()=>L.empty(),m:()=>{const t=a.first(),n=o.first();return xo(this.s,t.type,n.type)(t,n,e)?L.aa():L.V()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}})}};const Ao={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};var Eo=class extends Gn{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){const n=Un(this.l,e,t),r=Un(this.A,e,t);return n.Y({empty:()=>L.V(),default:()=>r.Y({empty:()=>L.V(),default:()=>{const a=yo(n,t),o=yo(r,t);return function(e,t,n,r){return e=Ao[e],n.M((n=>t.filter((t=>{for(let s=0,i=n.length;s<i;++s){let i,l,c=n[s];var a=t.type,o=c.type;(T(a,19)||T(o,19))&&(T(a,2)?i=3:T(o,2)?l=3:T(a,17)?i=17:T(o,17)?l=17:T(a,16)?i=16:T(o,16)?l=16:T(a,19)?l=o:T(o,19)&&(i=a));const[u,h]=[l,i];if(a=u,o=h,a?t=At(t,a):o&&(c=At(c,o)),xo(e,t.type,c.type)(t,c,r))return!0}return!1})).Y({default:()=>L.aa(),empty:()=>L.V()})))}(this.s,a,o,e)}})})}};function No(e,t,n,r){if(!T(n,53)||!T(r,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(e){case"isOp":return function(e,t){return e!==t||47!==e&&53!==e&&54!==e&&55!==e&&56!==e&&57!==e&&58!==e?()=>!1:(e,t)=>Tt(e.first().value,t.first().value)}(n,r);case"nodeBeforeOp":return t?(e,n)=>0>Ot(t,e.first(),n.first()):void 0;case"nodeAfterOp":return t?(e,n)=>0<Ot(t,e.first(),n.first()):void 0;default:throw Error("Unexpected operator")}}var To=class extends Gn{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){const n=Un(this.l,e,t),r=Un(this.A,e,t);return n.Y({empty:()=>L.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>r.Y({empty:()=>L.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>{const a=n.first(),o=r.first();return No(this.s,t.h,a.type,o.type)(n,r,e)?L.aa():L.V()}})})}};function Bo(e,t,n,r){return n.M((n=>{if(n.some((e=>!T(e.type,53))))throw Error(`XPTY0004: Sequences given to ${e} should only contain nodes.`);return"sorted"===r?L.create(n):"reverse-sorted"===r?L.create(n.reverse()):L.create(Ft(t,n))}))}var Io=class extends Gn{constructor(e,t,n,r){super(0<Kn(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){const n=Bo(this.l,t.h,Un(this.s,e,t),this.s.ia);e=Bo(this.l,t.h,Un(this.A,e,t),this.A.ia);const r=n.value,a=e.value;let o=null,s=null,i=!1,l=!1;return L.create({next:()=>{if(i)return A;for(;!l;){if(!o){var e=r.next(0);if(e.done)return i=!0,A;o=e.value}if(!s){if((e=a.next(0)).done){l=!0;break}s=e.value}if(Tt(o.value,s.value)){if(e=E(o),s=o=null,"intersectOp"===this.l)return e}else if(0>Ot(t.h,o,s)){if(e=E(o),o=null,"exceptOp"===this.l)return e}else s=null}return"exceptOp"===this.l?null!==o?(e=E(o),o=null,e):r.next(0):(i=!0,A)}})}},Co=class extends zn{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new Wn({})),e,{P:"unsorted",B:e.every((e=>e.B))},t)}A(e,t,n){return n.length?Qe(n.map((t=>t(e)))):L.empty()}},So=class extends Gn{constructor(e,t,n){super(new Wn({}).add(e.o),[e,t],{B:e.B&&t.B},!1,n),this.l=e,this.s=t}h(e,t){const n=je(e,Un(this.l,e,t));let r=null,a=null,o=!1;return L.create({next:e=>{for(;!o;){if(!r&&(r=n.next(e),r.done))return o=!0,A;a||=Un(this.s,r.value,t);const s=a.value.next(e);if(!s.done)return s;r=a=null}}})}},Oo=class extends Gn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Un(this.A,e,t),t);return n.Y({empty:()=>this.s?L.aa():L.V(),m:()=>n.map((e=>bt(e,this.l).u?w:v)),multiple:()=>L.V()})}},Fo=class extends Gn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Un(this.A,e,t),t);return n.Y({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");return L.empty()},m:()=>n.map((e=>At(e,this.l))),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.")}})}};function Do(e,t){const n=e.value;let r=null,a=!1;return L.create({next:()=>{for(;!a;){if(!r){var e=n.next(0);if(e.done)return a=!0,E(w);r=t(e.value)}if(e=r.fa(),r=null,!1===e)return a=!0,E(v)}return A}})}var ko=class extends Gn{constructor(e,t,n,r){super(e.o,[e],{B:!1},!1,r),this.A=e,this.s=t,this.l=n}h(e,t){const n=Un(this.A,e,t);return n.Y({empty:()=>"?"===this.l||"*"===this.l?L.aa():L.V(),multiple:()=>"+"===this.l||"*"===this.l?Do(n,(n=>{const r=L.m(n);return n=_e(e,0,n,r),Un(this.s,n,t)})):L.V(),m:()=>Do(n,(n=>{const r=L.m(n);return n=_e(e,0,n,r),Un(this.s,n,t)}))})}};function Ro(e,t){return!(null===e||null===t||!T(e.type,53)||!T(t.type,53))&&Tt(e.value,t.value)}function Mo(e){let t=e.next(0);if(t.done)return L.empty();let n=null,r=null;return L.create({next(a){if(t.done)return A;let o;n||(n=t.value.value);do{if(o=n.next(a),o.done){if(t=e.next(0),t.done)return o;n=t.value.value}}while(o.done||Ro(o.value,r));return r=o.value,o}})}function Uo(e,t){const n=[];!function(){for(var e=t.next(0);!e.done;){const r=e.value.value;e={current:r.next(0),next:e=>r.next(e)},e.current.done||n.push(e),e=t.next(0)}}();let r=null,a=!1;return L.create({[Symbol.iterator](){return this},next:()=>{let t;a||(a=!0,n.every((e=>T(e.current.value.type,53)))&&n.sort(((t,n)=>Ot(e,t.current.value,n.current.value))));do{if(!n.length)return A;const r=n.shift();if(t=r.current,r.current=r.next(0),!T(t.value.type,53))return t;if(!r.current.done){let t=0,a=n.length-1,o=0;for(;t<=a;){o=Math.floor((t+a)/2);const s=Ot(e,r.current.value,n[o].current.value);if(0===s){t=o;break}0<s?t=o+1:a=o-1}n.splice(t,0,r)}}while(Ro(t.value,r));return r=t.value,t}})}var Go=class extends Gn{constructor(e,t){super(e.reduce(((e,t)=>0<Kn(e,t.o)?e:t.o),new Wn({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){if(this.l.every((e=>"sorted"===e.ia))){let n=0;return Uo(t.h,{next:()=>n>=this.l.length?A:E(Un(this.l[n++],e,t))}).map((e=>{if(!T(e.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return e}))}return Qe(this.l.map((n=>Un(n,e,t)))).M((e=>{if(e.some((e=>!T(e.type,53))))throw Error("XPTY0004: The sequences to union are not of type node()*");return e=Ft(t.h,e),L.create(e)}))}};function Lo(e){return e.every((e=>null===e||T(e.type,5)||T(e.type,4)))||null!==e.map((e=>e?at(e.type):null)).reduce(((e,t)=>null===t||t===e?e:null))?e:e.every((e=>null===e||T(e.type,1)||T(e.type,20)))?e.map((e=>e?At(e,1):null)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)))?e.map((e=>e?At(e,6):e)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)||T(e.type,3)))?e.map((e=>e?At(e,3):e)):null}var $o=class extends oo{constructor(e,t){super(new Wn({}),[t,...e.map((e=>e.ba))],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const a=[];let o,s,i=!1,l=null;const c=this.A[0];return L.create({next:()=>{if(!i){for(var u=t.next(0);!u.done;)a.push(u.value),u=t.next(0);if(u=a.map((e=>c.ba.h(e,n))).map((e=>rt(e,n))),u.find((e=>!e.G()&&!e.sa())))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");if(o=u.map((e=>e.first())),o=o.map((e=>null===e?e:T(19,e.type)?At(e,1):e)),function(e){return(e=e.find((e=>!!e)))?at(e.type):null}(o)&&(o=Lo(o),!o))throw Error("XPTY0004: Could not cast values");u=o.length,s=o.map(((e,t)=>t));for(let t=0;t<u;t++)if(t+1!==u)for(let n=t;0<=n;n--){const t=n,r=n+1;if(r===u)continue;const a=o[s[t]],i=o[s[r]];if(null!==i||null!==a){if(c.$b){if(null===a)continue;if(null===i&&null!==a){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(i.value)&&null!==a&&!isNaN(a.value)){[s[t],s[r]]=[s[r],s[t]];continue}}else{if(null===i)continue;if(null===a&&null!==i){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(a.value)&&null!==i&&!isNaN(i.value)){[s[t],s[r]]=[s[r],s[t]];continue}}xo("gtOp",a.type,i.type)(a,i,e)&&([s[t],s[r]]=[s[r],s[t]])}}let h=c.zb?0:o.length-1;l=r({next:()=>c.zb?h>=o.length?A:E(a[s[h++]]):0>h?A:E(a[s[h--]])}).value,i=!0}return l.next(0)}})}},Ho=class extends Gn{constructor(e){super(e?e.o:new Wn({}),e?[e]:[],{P:"sorted",subtree:!1,W:!1,B:!1}),this.l=e}h(e,t){if(null===e.N)throw We("context is absent, it needs to be present to use paths.");var n=t.h;let r=e.N.value;for(;9!==r.node.nodeType;)if(r=ne(n,r),null===r)throw Error("XPDY0050: the root node of the context node is not a document node.");return n=L.m(ce(r)),this.l?Un(this.l,_e(e,0,n.first(),n),t):n}},Po=class extends Gn{constructor(e){super(new Wn({}),[],{P:"sorted"},!1,e)}h(e){if(null===e.N)throw We('context is absent, it needs to be present to use the "." operator');return L.m(e.N)}};var _o=class extends Gn{constructor(e,t){const n=e.every((e=>e.W)),r=e.every((e=>e.subtree));super(e.reduce(((e,t)=>e.add(t.o)),new Wn({})),e,{B:!1,W:n,P:t?"sorted":"unsorted",subtree:r}),this.l=e,this.s=t}h(e,t){let n=!0;return this.l.reduce(((r,a,o)=>{const s=null===r?Et(e):je(e,r);let i;if(r={next:e=>{if((e=s.next(e)).done)return A;if(null!==e.value.N&&!T(e.value.N.type,53)&&0<o)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return E(Un(a,e.value,t))}},this.s)switch(a.ia){case"reverse-sorted":const e=r;r={next:t=>(t=e.next(t)).done?t:E(t.value.M((e=>L.create(e.reverse()))))};case"sorted":if(a.subtree&&n){i=Mo(r);break}i=Uo(t.h,r);break;case"unsorted":return Mo(r).M((e=>L.create(function(e,t){let n=!1,r=!1;if(t.forEach((e=>{T(e.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?Ft(e,t):t}(t.h,e))))}else i=Mo(r);return n=n&&a.W,i}),null)}D(){return this.l[0].D()}},jo=class extends Gn{constructor(e,t){super(e.o.add(t.o),[e,t],{B:e.B&&t.B,W:e.W,P:e.ia,subtree:e.subtree}),this.s=e,this.l=t}h(e,t){const n=Un(this.s,e,t);if(this.l.B){const r=Un(this.l,e,t);if(r.G())return r;const a=r.first();if(T(a.type,2)){let e=a.value;if(!Number.isInteger(e))return L.empty();const t=n.value;let r=!1;return L.create({next:()=>{if(!r){for(let n=t.next(0);!n.done;n=t.next(0))if(1==e--)return r=!0,n;r=!0}return A}})}return r.fa()?n:L.empty()}const r=n.value;let a=null,o=0,s=null;return L.create({next:i=>{let l=!1;for(;(!a||!a.done)&&(a||(a=r.next(l?0:i),l=!0),!a.done);){s||=Un(this.l,_e(e,o,a.value,n),t);var c=s.first();c=null!==c&&(T(c.type,2)?c.value===o+1:s.fa()),s=null;const r=a.value;if(a=null,o++,c)return E(r)}return a}})}D(){return this.s.D()}};function Xo(e,t,n){if(n=[n],T(e.type,62))if("*"===t)n.push(...e.h.map((e=>e())));else{if(!T(t.type,5))throw Error("XPTY0004: The key specifier is not an integer.");{const r=t.value;if(e.h.length<r||0>=r)throw Error("FOAY0001: Array index out of bounds");n.push(e.h[r-1]())}}else{if(!T(e.type,61))throw Error("XPTY0004: The provided context item is not a map or an array.");"*"===t?n.push(...e.h.map((e=>e.value()))):(e=e.h.find((e=>he(e.key,t))))&&n.push(e.value())}return Qe(n)}function qo(e,t,n,r,a){return"*"===t?Xo(e,t,n):(t=$(t=Un(t,r,a))().M((t=>t.reduce(((t,n)=>Xo(e,n,t)),new B))),Qe([n,t]))}var Vo=class extends Gn{constructor(e,t){super(e.o,[e].concat("*"===t?[]:[t]),{B:e.B,P:e.ia,subtree:e.subtree}),this.l=e,this.s=t}h(e,t){return Un(this.l,e,t).M((n=>n.reduce(((n,r)=>qo(r,this.s,n,e,t)),new B)))}D(){return this.l.D()}},Yo=class extends Gn{constructor(e,t){super(new Wn({external:1}),"*"===e?[]:[e],{B:!1},!1,t),this.l=e}h(e,t){return qo(e.N,this.l,new B,e,t)}},zo=class extends Gn{constructor(e,t,n,r){const a=t.map((e=>e.eb));t=t.map((e=>e.name)),super(a.reduce(((e,t)=>e.add(t.o)),n.o),a.concat(n),{B:!1},!1,r),this.s=e,this.A=t,this.L=a,this.S=n,this.l=null}h(e,t){let n=e;const r=this.l.map(((r,a)=>{const o=Un(this.L[a],n,t).O();return n=Ye(e,{[r]:()=>L.create(o)}),o}));if(r.some((e=>0===e.length)))return"every"===this.s?L.aa():L.V();const a=Array(r.length).fill(0);a[0]=-1;for(var o=!0;o;){o=!1;for(let n=0,i=a.length;n<i;++n){var s=r[n];if(!(++a[n]>s.length-1)){for(o=Object.create(null),s=0;s<a.length;s++){const e=r[s][a[s]];o[this.l[s]]=()=>L.m(e)}if(o=Ye(e,o),(o=Un(this.S,o,t)).fa()&&"some"===this.s)return L.aa();if(!o.fa()&&"every"===this.s)return L.V();o=!0;break}a[n]=0}}return"every"===this.s?L.aa():L.V()}v(e){this.l=[];for(let n=0,r=this.A.length;n<r;++n){this.L[n].v(e),Jr(e);var t=this.A[n];const r=t.prefix?e.$(t.prefix):null;t=Wr(e,r,t.localName),this.l[n]=t}this.S.v(e);for(let t=0,n=this.A.length;t<n;++t)ea(e)}},Jo=class extends Gn{constructor(e){super(e,[],{B:!1})}h(e){return this.l(e.N)?L.aa():L.V()}},Qo=class extends Jo{constructor(e){super(new Wn({nodeType:1})),this.s=e}l(e){return!!T(e.type,53)&&(e=e.value.node.nodeType,3===this.s&&4===e||this.s===e)}D(){return`type-${this.s}`}},Ko=class extends Jo{constructor(e,t={kind:null}){const n=e.prefix,r=e.namespaceURI,a={};"*"!==(e=e.localName)&&(a.nodeName=1),a.nodeType=1,super(new Wn(a)),this.s=e,this.L=r,this.A=n,this.S=t.kind}l(e){const t=T(e.type,54),n=T(e.type,47);return!(!t&&!n)&&(e=e.value,!(null!==this.S&&(1===this.S&&!t||2===this.S&&!n))&&(null===this.A&&""!==this.L&&"*"===this.s||("*"===this.A?"*"===this.s||this.s===e.node.localName:("*"===this.s||this.s===e.node.localName)&&(e.node.namespaceURI||null)===((""===this.A?t?this.L:null:this.L)||null))))}D(){return"*"===this.s?null===this.S?"type-1-or-type-2":`type-${this.S}`:`name-${this.s}`}v(e){if(null===this.L&&"*"!==this.A&&(this.L=e.$(this.A||"")||null,!this.L&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`)}},Wo=class extends Jo{constructor(e){super(new Wn({nodeName:1})),this.s=e}l(e){return T(e.type,57)&&e.value.node.target===this.s}D(){return"type-7"}},Zo=class extends Jo{constructor(e){super(new Wn({})),this.s=e}l(e){return T(e.type,F(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}},es=class extends Gn{constructor(e,t,n){super(new Wn({}),[],{B:!1,P:"unsorted"}),this.A=n,this.s=t,this.L=e,this.l=null}h(e,t){if(!e.wa[this.l]){if(this.S)return this.S(e,t);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.")}return e.wa[this.l]()}v(e){if(null===this.s&&this.L&&(this.s=e.$(this.L)),this.l=e.cb(this.s||"",this.A),!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");(e=e.Da[this.l])&&(this.S=e)}},ts=class extends oo{constructor(e,t){super(new Wn({}),[e,t],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){let a=null,o=null;return r({next:()=>{for(;;){if(!o){var e=t.next(0);if(e.done)return A;a=e.value,o=Un(this.A,a,n)}e=o.fa();const r=a;if(o=a=null,e)return E(r)}}})}},ns=class{constructor(e){this.type=e}},rs=class extends ns{constructor(e){super("delete"),this.target=e}h(e){return{type:this.type,target:Ar(this.target,e,!1)}}},as=class extends ns{constructor(e,t,n){super(n),this.target=e,this.content=t}h(e){return{type:this.type,target:Ar(this.target,e,!1),content:this.content.map((t=>Ar(t,e,!0)))}}},os=class extends as{constructor(e,t){super(e,t,"insertAfter")}},ss=class extends ns{constructor(e,t){super("insertAttributes"),this.target=e,this.content=t}h(e){return{type:this.type,target:Ar(this.target,e,!1),content:this.content.map((t=>Ar(t,e,!0)))}}},is=class extends as{constructor(e,t){super(e,t,"insertBefore")}},ls=class extends as{constructor(e,t){super(e,t,"insertIntoAsFirst")}},cs=class extends as{constructor(e,t){super(e,t,"insertIntoAsLast")}},us=class extends as{constructor(e,t){super(e,t,"insertInto")}},hs=class extends ns{constructor(e,t){super("rename"),this.target=e,this.o=t.ya?t:new H(t.prefix,t.namespaceURI,t.localName)}h(e){return{type:this.type,target:Ar(this.target,e,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}},ps=class extends ns{constructor(e,t){super("replaceElementContent"),this.target=e,this.text=t}h(e){return{type:this.type,target:Ar(this.target,e,!1),text:this.text?Ar(this.text,e,!0):null}}},ds=class extends ns{constructor(e,t){super("replaceNode"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ar(this.target,e,!1),replacement:this.o.map((t=>Ar(t,e,!0)))}}},ms=class extends ns{constructor(e,t){super("replaceValue"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ar(this.target,e,!1),"string-value":this.o}}},fs=(e,t)=>new ds(e,t),gs=class extends Vn{constructor(e){super(new Wn({}),[e],{B:!1,P:"unsorted"}),this.l=e}s(e,t){const n=qn(this.l)(e,t),r=t.h;let a,o;return{next:()=>{if(!a){const e=n.next(0);if(e.value.I.some((e=>!T(e.type,53))))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");a=e.value.I,o=e.value.da}return a=a.filter((e=>ne(r,e.value))),E({da:Xn(a.map((e=>new rs(e.value))),o),I:[]})}}}};function ys(e,t,n,r,a,o){const s=t.h;return e.reduce((function e(t,n){return T(n.type,62)?(n.h.forEach((n=>n().O().forEach((n=>e(t,n))))),t):(t.push(n),t)}),[]).forEach(((e,i,l)=>{if(T(e.type,47)){if(a)throw o(e.value,s);n.push(e.value.node)}else if(T(e.type,46)||T(e.type,53)&&3===e.value.node.nodeType){const n=T(e.type,46)?At(nt(e,t).first(),1).value:Z(s,e.value);0!==i&&T(l[i-1].type,46)&&T(e.type,46)?(r.push({data:" "+n,Ra:!0,nodeType:3}),a=!0):n&&(r.push({data:""+n,Ra:!0,nodeType:3}),a=!0)}else if(T(e.type,55)){const i=[];W(s,e.value).forEach((e=>i.push(ce(e)))),a=ys(i,t,n,r,a,o)}else{if(!T(e.type,53)){if(T(e.type,60))throw et(e.type);throw Error(`Atomizing ${e.type} is not implemented.`)}r.push(e.value.node),a=!0}})),a}function ws(e,t,n){const r=[],a=[];let o=!1;return e.forEach((e=>{o=ys(e,t,r,a,o,n)})),{attributes:r,Wa:a}}function vs(e,t,n,r,a){const o=[];switch(e){case 4:r.length&&o.push(new ss(t,r)),a.length&&o.push(new ls(t,a));break;case 5:r.length&&o.push(new ss(t,r)),a.length&&o.push(new cs(t,a));break;case 3:r.length&&o.push(new ss(t,r)),a.length&&o.push(new us(t,a));break;case 2:r.length&&o.push(new ss(n,r)),a.length&&o.push(new is(t,a));break;case 1:r.length&&o.push(new ss(n,r)),a.length&&o.push(new os(t,a))}return o}var xs=class extends Vn{constructor(e,t,n){super(new Wn({}),[e,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=qn(this.L)(e,t),r=qn(this.A)(e,t),a=t.h;let o,s,i,l,c,u;return{next:()=>{if(!o){var e=n.next(0);const r=ws([e.value.I],t,Bn);o=r.attributes.map((e=>({node:e,F:null}))),s=r.Wa.map((e=>({node:e,F:null}))),i=e.value.da}if(!l){if(0===(e=r.next(0)).value.I.length)throw Mn();if(3<=this.l){if(1!==e.value.I.length)throw In();if(!T(e.value.I[0].type,54)&&!T(e.value.I[0].type,55))throw In()}else{if(1!==e.value.I.length)throw Cn();if(!(T(e.value.I[0].type,54)||T(e.value.I[0].type,56)||T(e.value.I[0].type,58)||T(e.value.I[0].type,57)))throw Cn();if(u=ne(a,e.value.I[0].value,null),null===u)throw Error(`XUDY0029: The target ${e.value.I[0].value.outerHTML} for inserting a node before or after must have a parent.`)}l=e.value.I[0],c=e.value.da}if(o.length){if(3<=this.l){if(!T(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.")}else if(1!==u.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");o.reduce(((e,t)=>{const n=t.node.prefix||"";var r=t.node.prefix||"";const a=t.node.namespaceURI,o=r?l.value.node.lookupNamespaceURI(r):null;if(o&&o!==a)throw kn(a);if((r=e[r])&&a!==r)throw Rn(a);return e[n]=t.node.namespaceURI,e}),{})}return E({I:[],da:Xn(vs(this.l,l.value,u||null,o,s),i,c)})}}}};const bs=()=>Ze("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),As=/([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])/,Es=new RegExp(`${As.source}${new RegExp(`(${As.source}|[-.0-9·̀-ͯ‿⁀])`).source}*`,"g"),Ns=e=>!!(e=e.match(Es))&&1===e.length;function Ts(e,t){return rt(t,e).Y({m:e=>{if(T((e=e.first()).type,1)||T(e.type,19)){if(!Ns(e.value))throw Error(`XQDY0041: The value "${e.value}" of a name expressions cannot be converted to a NCName.`);return L.m(e)}throw bs()},default:()=>{throw bs()}}).value}function Bs(e,t,n){return rt(n,t).Y({m:t=>{if(T((t=t.first()).type,23))return L.m(t);if(T(t.type,1)||T(t.type,19)){let n,r;if(1===(t=t.value.split(":")).length?t=t[0]:(n=t[0],r=e.$(n),t=t[1]),!Ns(t)||n&&!Ns(n))throw Xr(n?`${n}:${t}`:t);if(n&&!r)throw Xr(`${n}:${t}`);return L.m({type:23,value:new H(n,r,t)})}throw bs()},default:()=>{throw bs()}}).value}var Is=class extends Vn{constructor(e,t){super(new Wn({}),[e,t],{B:!1,P:"unsorted"}),this.A=e,this.L=t,this.l=void 0}s(e,t){const n=qn(this.A)(e,t),r=qn(this.L)(e,t);return{next:()=>{const e=n.next(0);var a=e.value.I;if(0===a.length)throw Mn();if(1!==a.length)throw On();if(!T(a[0].type,54)&&!T(a[0].type,47)&&!T(a[0].type,57))throw On();a=a[0];const o=r.next(0);e:{var s=this.l,i=L.create(o.value.I);switch(a.type){case 54:if(s=Bs(s,t,i).next(0).value.value,(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw kn(s.namespaceURI);break e;case 47:if((s=Bs(s,t,i).next(0).value.value).namespaceURI&&(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw kn(s.namespaceURI);break e;case 57:s=Ts(t,i).next(0).value.value,s=new H("",null,s);break e}s=void 0}return E({I:[],da:Xn([new hs(a.value,s)],e.value.da,o.value.da)})}}}v(e){this.l=zr(e),super.v(e)}};var Cs=class extends Vn{constructor(e,t,n){super(new Wn({}),[t,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=qn(this.l)(e,t);return e=qn(this.A)(e,t),this.L?function(e,t,n){let r,a,o,s,i=!1;return{next:()=>{if(i)return A;if(!o){var l=n.next(0);const t=rt(L.create(l.value.I),e).map((e=>At(e,1))).O().map((e=>e.value)).join(" ");o=0===t.length?null:{node:e.Ia.createTextNode(t),F:null},s=l.value.da}if(!r){if(0===(l=t.next(0)).value.I.length)throw Mn();if(1!==l.value.I.length)throw Sn();if(!(T(l.value.I[0].type,54)||T(l.value.I[0].type,47)||T(l.value.I[0].type,56)||T(l.value.I[0].type,58)||T(l.value.I[0].type,57)))throw Sn();r=l.value.I[0],a=l.value.da}if(T(r.type,54))return i=!0,E({I:[],da:Xn([new ps(r.value,o)],s,a)});if(T(r.type,47)||T(r.type,56)||T(r.type,58)||T(r.type,57)){if(l=o?Z(e.h,o):"",T(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(T(r.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);return i=!0,E({I:[],da:Xn([new ms(r.value,l)],s,a)})}}}}(t,n,e):function(e,t,n){let r,a,o;return{next:()=>{if(!r){var s=n.next(0),i=ws([s.value.I],e,Rn);r={attributes:i.attributes.map((e=>({node:e,F:null}))),Wa:i.Wa.map((e=>({node:e,F:null})))},a=s.value.da}if(0===(i=t.next(0)).value.I.length)throw Mn();if(1!==i.value.I.length)throw Sn();if(!(T(i.value.I[0].type,54)||T(i.value.I[0].type,47)||T(i.value.I[0].type,56)||T(i.value.I[0].type,58)||T(i.value.I[0].type,57)))throw Sn();if(o=ne(e.h,i.value.I[0].value,null),null===o)throw Error(`XUDY0009: The target ${i.value.I[0].value.outerHTML} for replacing a node must have a parent.`);if(s=i.value.I[0],i=i.value.da,T(s.type,47)){if(r.Wa.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");r.attributes.reduce(((e,t)=>{const n=t.node.prefix||"";t=t.node.namespaceURI;var r=o.node.lookupNamespaceURI(n);if(r&&r!==t)throw kn(t);if((r=e[n])&&t!==r)throw Rn(t);return e[n]=t,e}),{})}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 E({I:[],da:Xn([fs(s.value,[].concat(r.attributes,r.Wa))],a,i)})}}}(t,n,e)}};function Ss(e){switch(e.type){case"delete":return new rs({node:e.target,F:null});case"insertAfter":return new os({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertBefore":return new is({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertInto":return new us({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsFirst":return new ls({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsLast":return new cs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertAttributes":return new ss({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"rename":return new hs({node:e.target,F:null},e.newName);case"replaceNode":return new ds({node:e.target,F:null},e.replacement.map((e=>({node:e,F:null}))));case"replaceValue":return new ms({node:e.target,F:null},e["string-value"]);case"replaceElementContent":return new ps({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 Os(e,t,n){if(t.find((t=>Tt(t,e))))return!0;const r=ne(n,e);return!!r&&Os(r,t,n)}var Fs=class extends Vn{constructor(e,t,n){super(new Wn({}),e.reduce(((e,t)=>(e.push(t.eb),e)),[t,n]),{B:!1,P:"unsorted"}),this.l=e,this.L=t,this.A=n,this.J=null}h(e,t){return Yn(e=this.s(e,t),(()=>{}))}s(e,t){const n=t.h,r=t.Ia,a=t.Ma,o=[];let s,i,l;const c=[],u=[];return{next:()=>{if(c.length!==this.l.length)for(var h=c.length;h<this.l.length;h++){const n=this.l[h];var p=o[h];if(p||(o[h]=p=qn(n.eb)(e,t)),1!==(p=p.next(0)).value.I.length||!T(p.value.I[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");const r=ce(xr(p.value.I[0].value,t));c.push(r.value),u.push(p.value.da),e=Ye(e,{[n.dc]:()=>L.m(r)})}return l||(s||=qn(this.L)(e,t),l=s.next(0).value.da),l.forEach((e=>{if(e.target&&!Os(e.target,c,n))throw Error(`XUDY0014: The target ${e.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===e.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.")})),h=l.map((e=>Ss(e=e.h(t)))),_n(h,n,r,a),i||=qn(this.A)(e,t),E({I:(h=i.next(0)).value.I,da:Xn(h.value.da,...u)})}}}v(e){Jr(e),this.l.forEach((t=>t.dc=Wr(e,t.Gb.namespaceURI,t.Gb.localName))),super.v(e),ea(e),this.J=this.l.some((e=>e.eb.J))||this.A.J}};function Ds(e,t){return{node:{nodeType:2,Ra:!0,nodeName:e.ya(),namespaceURI:e.namespaceURI,prefix:e.prefix,localName:e.localName,name:e.ya(),value:t},F:null}}var ks=class extends Gn{constructor(e,t){let n=t.mb||[];n=n.concat(e.Na||[]),super(new Wn({}),n,{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.name=new H(e.prefix,e.namespaceURI,e.localName),this.l=t,this.A=void 0}h(e,t){let n,r,a,o=!1;return L.create({next:()=>{if(o)return A;if(!r){if(this.s){if(!n){var s=this.s.h(e,t);n=Bs(this.A,t,s)}r=n.next(0).value.value}else r=this.name;if(r){if("xmlns"===r.prefix)throw Lr(r);if(""===r.prefix&&"xmlns"===r.localName)throw Lr(r);if("http://www.w3.org/2000/xmlns/"===r.namespaceURI)throw Lr(r);if("xml"===r.prefix&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI)throw Lr(r);if(""!==r.prefix&&"xml"!==r.prefix&&"http://www.w3.org/XML/1998/namespace"===r.namespaceURI)throw Lr(r)}}return this.l.mb?(s=this.l.mb,a||(a=Qe(s.map((n=>rt(n.h(e,t),t).M((e=>L.m(y(e.map((e=>e.value)).join(" "),1))))))).M((e=>L.m(ce(Ds(r,e.map((e=>e.value)).join("")))))).value),a.next(0)):(o=!0,E(ce(Ds(r,this.l.value))))}})}v(e){if(this.A=zr(e),this.name&&this.name.prefix&&!this.name.namespaceURI){const t=e.$(this.name.prefix);if(void 0===t&&this.name.prefix)throw tt(this.name.prefix);this.name.namespaceURI=t||null}super.v(e)}},Rs=class extends Gn{constructor(e){super(e?e.o:new Wn({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){const n={data:"",Ra:!0,nodeType:8},r={node:n,F:null};return this.l?rt(e=Un(this.l,e,t),t).M((e=>{if(e=e.map((e=>At(e,1).value)).join(" "),-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');return n.data=e,L.m(ce(r))})):L.m(ce(r))}},Ms=class extends Gn{constructor(e,t,n,r){super(new Wn({}),r.concat(t).concat(e.Na||[]),{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.l=new H(e.prefix,e.namespaceURI,e.localName),this.S=n.reduce(((e,t)=>{if(t.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${t.prefix} has already been declared on the constructed element.`);return e[t.prefix||""]=t.uri,e}),{}),this.L=t,this.ma=r,this.A=void 0}h(e,t){let n,r,a,o,s,i=!1,l=!1,c=!1;return L.create({next:()=>{if(c)return A;if(i||(n||=Qe(this.L.map((n=>Un(n,e,t)))),r=n.O(),i=!0),!l){a||=this.ma.map((n=>Un(n,e,t)));for(var u=[],h=0;h<a.length;h++){var p=a[h].O();u.push(p)}o=u,l=!0}if(this.s&&(s||(u=this.s.h(e,t),s=Bs(this.A,t,u)),this.l=s.next(0).value.value),"xmlns"===this.l.prefix||"http://www.w3.org/2000/xmlns/"===this.l.namespaceURI||"xml"===this.l.prefix&&"http://www.w3.org/XML/1998/namespace"!==this.l.namespaceURI||this.l.prefix&&"xml"!==this.l.prefix&&"http://www.w3.org/XML/1998/namespace"===this.l.namespaceURI)throw Error(`XQDY0096: The node name "${this.l.ya()}" is invalid for a computed element constructor.`);const d={nodeType:1,Ra:!0,attributes:[],childNodes:[],nodeName:this.l.ya(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};for(u={node:d,F:null},r.forEach((e=>{d.attributes.push(e.value.node)})),(h=ws(o,t,Gr)).attributes.forEach((e=>{if(d.attributes.find((t=>t.namespaceURI===e.namespaceURI&&t.localName===e.localName)))throw Error(`XQDY0025: The attribute ${e.name} does not have an unique name in the constructed element.`);d.attributes.push(e)})),h.Wa.forEach((e=>{d.childNodes.push(e)})),h=0;h<d.childNodes.length;h++){if(!z(p=d.childNodes[h])||3!==p.nodeType)continue;const e=d.childNodes[h-1];e&&z(e)&&3===e.nodeType&&(e.data+=p.data,d.childNodes.splice(h,1),h--)}return c=!0,E(ce(u))}})}v(e){if(Jr(e),Object.keys(this.S).forEach((t=>Kr(e,t,this.S[t]))),this.Ka.forEach((t=>t.v(e))),this.L.reduce(((t,n)=>{if(n.name){if(n=`Q{${null===n.name.namespaceURI?e.$(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&&null===this.l.namespaceURI){const t=e.$(this.l.prefix);if(void 0===t&&this.l.prefix)throw tt(this.l.prefix);this.l.namespaceURI=t}this.A=zr(e),ea(e)}};function Us(e){if(/^xml$/i.test(e))throw Error(`XQDY0064: The target of a created PI may not be "${e}"`)}function Gs(e,t){return{node:{data:t,Ra:!0,nodeName:e,nodeType:7,target:e},F:null}}var Ls=class extends Gn{constructor(e,t){const n=e.vb?[e.vb].concat(t):[t];super(n.reduce(((e,t)=>e.add(t.o)),new Wn({})),n,{B:!1,P:"unsorted"}),this.l=e,this.s=t}h(e,t){return rt(Un(this.s,e,t),t).M((n=>{const r=n.map((e=>At(e,1).value)).join(" ");if(-1!==r.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Db)return Us(n=this.l.Db),L.m(ce(Gs(n,r)));n=Un(this.l.vb,e,t);const a=Ts(t,n);return L.create({next:()=>{var e=a.next(0);return e.done?e:(Us(e=e.value.value),E(ce(Gs(e,r))))}})}))}},$s=class extends Gn{constructor(e){super(e?e.o:new Wn({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){return this.l?rt(e=Un(this.l,e,t),t).M((e=>0===e.length?L.empty():(e={node:{data:e.map((e=>At(e,1).value)).join(" "),Ra:!0,nodeType:3},F:null},L.m(ce(e))))):L.empty()}},Hs=class extends zn{constructor(e,t,n,r){super(new Wn({}),[e,...t.map((e=>e.Xb)),n].concat(...t.map((e=>e.Fb.map((e=>e.Eb))))),{B:!1,W:!1,P:"unsorted",subtree:!1},r),this.L=e,this.l=t.length,this.S=t.map((e=>e.Fb))}A(e,t,n){return n[0](e).M((r=>{for(let a=0;a<this.l;a++)if(this.S[a].some((n=>{switch(n.bc){case"?":if(1<r.length)return!1;break;case"*":break;case"+":if(1>r.length)return!1;break;default:if(1!==r.length)return!1}const a=L.create(r);return r.every(((r,o)=>(r=_e(e,o,r,a),Un(n.Eb,r,t).fa())))})))return n[a+1](e);return n[this.l+1](e)}))}v(e){if(super.v(e),this.L.J)throw Tn()}},Ps={Z:!1,qa:!1},_s={Z:!0,qa:!1},js={Z:!0,qa:!0};function Xs(e){return e.Z?e.qa?js:_s:Ps}function qs(e,t){switch(e[0]){case"andOp":var n=aa(e,"type");return new fo(Ys("andOp",e,Xs(t)),n);case"orOp":return n=aa(e,"type"),new go(Ys("orOp",e,Xs(t)),n);case"unaryPlusOp":return n=na(na(e,"operand"),"*"),e=aa(e,"type"),new mo("+",qs(n,t),e);case"unaryMinusOp":return n=na(na(e,"operand"),"*"),e=aa(e,"type"),new mo("-",qs(n,t),e);case"addOp":case"subtractOp":case"multiplyOp":case"divOp":case"idivOp":case"modOp":var r=e[0],a=qs(oa(e,["firstOperand","*"]),Xs(t));t=qs(oa(e,["secondOperand","*"]),Xs(t));const o=aa(e,"type"),s=aa(oa(e,["firstOperand","*"]),"type"),i=aa(oa(e,["secondOperand","*"]),"type");return s&&i&&aa(e,"type")&&(n=fa(r,s.type,i.type)),new wa(r,a,t,o,n);case"sequenceExpr":return function(e,t){var n=sa(e,"*").map((e=>qs(e,t)));return 1===n.length?n[0]:(n=aa(e,"type"),new Co(sa(e,"*").map((e=>qs(e,t))),n))}(e,t);case"unionOp":return n=aa(e,"type"),new Go([qs(oa(e,["firstOperand","*"]),Xs(t)),qs(oa(e,["secondOperand","*"]),Xs(t))],n);case"exceptOp":case"intersectOp":return n=aa(e,"type"),new Io(e[0],qs(oa(e,["firstOperand","*"]),Xs(t)),qs(oa(e,["secondOperand","*"]),Xs(t)),n);case"stringConcatenateOp":return function(e,t){const n=aa(e,"type");return e=[oa(e,["firstOperand","*"]),oa(e,["secondOperand","*"])],new rr(new ho({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},e.length,n),e.map((e=>qs(e,Xs(t)))),n)}(e,t);case"rangeSequenceExpr":return function(e,t){const n=aa(e,"type");e=[na(na(e,"startExpr"),"*"),na(na(e,"endExpr"),"*")];const r=new ho({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},e.length,n);return new rr(r,e.map((e=>qs(e,Xs(t)))),n)}(e,t);case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":return Js("generalCompare",e,t);case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":return Js("valueCompare",e,t);case"isOp":case"nodeBeforeOp":case"nodeAfterOp":return Js("nodeCompare",e,t);case"pathExpr":return function(e,t){const n=aa(e,"type");var r=sa(e,"stepExpr");let a=!1;var o=r.map((e=>{var r=na(e,"xpathAxis");let o;var s=sa(e,"*");const i=[];let l=null;for(const e of s)switch(e[0]){case"lookup":i.push(["lookup",zs(e,t)]);break;case"predicate":case"predicates":for(const n of sa(e,"*"))s=qs(n,Xs(t)),l=$a(l,s.D()),i.push(["predicate",s])}if(r)switch(a=!0,e=na(e,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),e=Vs(e),ra(r)){case"ancestor":o=new Ga(e,{Qa:!1});break;case"ancestor-or-self":o=new Ga(e,{Qa:!0});break;case"attribute":o=new Ha(e,l);break;case"child":o=new Pa(e,l);break;case"descendant":o=new ja(e,{Qa:!1});break;case"descendant-or-self":o=new ja(e,{Qa:!0});break;case"parent":o=new za(e,l);break;case"following-sibling":o=new Ya(e,l);break;case"preceding-sibling":o=new Qa(e,l);break;case"following":o=new Va(e);break;case"preceding":o=new Ja(e);break;case"self":o=new Ka(e,l)}else o=qs(r=oa(e,["filterExpr","*"]),Xs(t));for(const e of i)switch(e[0]){case"lookup":o=new Vo(o,e[1]);break;case"predicate":o=new jo(o,e[1])}return o.type=n,o}));return e=na(e,"rootExpr"),!(r=a||null!==e||1<r.length)&&1===o.length||!e&&1===o.length&&"sorted"===o[0].ia?o[0]:e&&0===o.length?new Ho(null):(o=new _o(o,r),e?new Ho(o):o)}(e,t);case"contextItemExpr":return new Po(aa(e,"type"));case"functionCallExpr":return function(e,t){const n=na(e,"functionName"),r=sa(na(e,"arguments"),"*");return e=aa(e,"type"),new rr(new ho(ia(n),r.length,e),r.map((e=>"argumentPlaceholder"===e[0]?null:qs(e,t))),e)}(e,t);case"inlineFunctionExpr":return function(e,t){const n=sa(na(e,"paramList"),"*"),r=oa(e,["functionBody","*"]),a=aa(e,"type");return new io(n.map((e=>({name:ia(na(e,"varName")),type:la(e)}))),la(e),r?qs(r,t):new Co([],a))}(e,t);case"arrowExpr":return function(e,t){const n=aa(e,"type");var r=oa(e,["argExpr","*"]);e=sa(e,"*").slice(1),r=[qs(r,t)];for(let o=0;o<e.length;o++)if("arguments"!==e[o][0]){if("arguments"===e[o+1][0]){var a=sa(e[o+1],"*");r=r.concat(a.map((e=>"argumentPlaceholder"===e[0]?null:qs(e,t))))}a="EQName"===e[o][0]?new ho(ia(e[o]),r.length,n):qs(e[o],Xs(t)),r=[new rr(a,r,n)]}return r[0]}(e,t);case"dynamicFunctionInvocationExpr":return function(e,t){const n=oa(e,["functionItem","*"]),r=aa(e,"type");e=na(e,"arguments");let a=[];return e&&(a=sa(e,"*").map((e=>"argumentPlaceholder"===e[0]?null:qs(e,t)))),new rr(qs(n,t),a,r)}(e,t);case"namedFunctionRef":return t=na(e,"functionName"),n=aa(e,"type"),e=ra(oa(e,["integerConstantExpr","value"])),new ho(ia(t),parseInt(e,10),n);case"integerConstantExpr":return new co(ra(na(e,"value")),{type:5,g:3});case"stringConstantExpr":return new co(ra(na(e,"value")),{type:1,g:3});case"decimalConstantExpr":return new co(ra(na(e,"value")),{type:4,g:3});case"doubleConstantExpr":return new co(ra(na(e,"value")),{type:3,g:3});case"varRef":const{prefix:l,namespaceURI:c,localName:u}=ia(na(e,"name"));return new es(l,c,u);case"flworExpr":return function(e,t){var n=sa(e,"*");if(e=na(n[n.length-1],"*"),1<(n=n.slice(0,-1)).length&&!t.Z)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return n.reduceRight(((e,n)=>{switch(n[0]){case"forClause":for(var r=(n=sa(n,"*")).length-1;0<=r;--r){var a=n[r],o=oa(a,["forExpr","*"]);const s=na(a,"positionalVariableBinding");e=new so(ia(oa(a,["typedVariableBinding","varName"])),qs(o,Xs(t)),s?ia(s):null,e)}return e;case"letClause":for(r=(n=sa(n,"*")).length-1;0<=r;--r)o=oa(a=n[r],["letExpr","*"]),e=new lo(ia(oa(a,["typedVariableBinding","varName"])),qs(o,Xs(t)),e);return e;case"whereClause":for(r=(n=sa(n,"*")).length-1;0<=r;--r)e=new ts(qs(n[r],t),e);return e;case"windowClause":case"groupByClause":case"countClause":throw Error(`Not implemented: ${n[0]} is not implemented yet.`);case"orderByClause":return function(e,t,n){return e=sa(e,"*"),new $o(e.filter((e=>"stable"!==e[0])).map((e=>{var n=na(e,"orderModifier"),r=n?na(n,"orderingKind"):null;return n=n?na(n,"emptyOrderingMode"):null,r=!r||"ascending"===ra(r),n=!n||"empty least"===ra(n),{ba:qs(oa(e,["orderByExpr","*"]),t),zb:r,$b:n}})),n)}(n,t,e);default:throw Error(`Not implemented: ${n[0]} is not supported in a flwor expression`)}}),qs(e,t))}(e,t);case"quantifiedExpr":return function(e,t){const n=aa(e,"type"),r=ra(na(e,"quantifier")),a=oa(e,["predicateExpr","*"]);return e=sa(e,"quantifiedExprInClause").map((e=>({name:ia(oa(e,["typedVariableBinding","varName"])),eb:qs(e=oa(e,["sourceExpr","*"]),Xs(t))}))),new zo(r,e,qs(a,Xs(t)),n)}(e,t);case"ifThenElseExpr":return n=aa(e,"type"),new Wa(qs(na(na(e,"ifClause"),"*"),Xs(t)),qs(na(na(e,"thenClause"),"*"),t),qs(na(na(e,"elseClause"),"*"),t),n);case"instanceOfExpr":return n=qs(oa(e,["argExpr","*"]),t),r=oa(e,["sequenceType","*"]),a=oa(e,["sequenceType","occurrenceIndicator"]),e=aa(e,"type"),new ko(n,qs(r,Xs(t)),a?ra(a):"",e);case"castExpr":return t=qs(na(na(e,"argExpr"),"*"),Xs(t)),n=na(e,"singleType"),e=ia(na(n,"atomicType")),n=null!==na(n,"optional"),new Fo(t,e,n);case"castableExpr":return t=qs(na(na(e,"argExpr"),"*"),Xs(t)),n=na(e,"singleType"),e=ia(na(n,"atomicType")),n=null!==na(n,"optional"),new Oo(t,e,n);case"simpleMapExpr":return function(e,t){const n=aa(e,"type");return sa(e,"*").reduce(((e,r)=>null===e?qs(r,Xs(t)):new So(e,qs(r,Xs(t)),n)),null)}(e,t);case"mapConstructor":return function(e,t){const n=aa(e,"type");return new uo(sa(e,"mapConstructorEntry").map((e=>({key:qs(oa(e,["mapKeyExpr","*"]),Xs(t)),value:qs(oa(e,["mapValueExpr","*"]),Xs(t))}))),n)}(e,t);case"arrayConstructor":return function(e,t){const n=aa(e,"type"),r=sa(e=na(e,"*"),"arrayElem").map((e=>qs(na(e,"*"),Xs(t))));switch(e[0]){case"curlyArray":return new Ra(r,n);case"squareArray":return new Ma(r,n);default:throw Error("Unrecognized arrayType: "+e[0])}}(e,t);case"unaryLookup":return n=aa(e,"type"),new Yo(zs(e,t),n);case"typeswitchExpr":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=aa(e,"type"),r=qs(na(na(e,"argExpr"),"*"),t),a=sa(e,"typeswitchExprCaseClause").map((e=>{const n=0===sa(e,"sequenceTypeUnion").length?[na(e,"sequenceType")]:sa(na(e,"sequenceTypeUnion"),"sequenceType");return{Xb:qs(oa(e,["resultExpr","*"]),t),Fb:n.map((e=>{const n=na(e,"occurrenceIndicator");return{bc:n?ra(n):"",Eb:qs(na(e,"*"),t)}}))}}));return e=qs(oa(e,["typeswitchExprDefaultClause","resultExpr","*"]),t),new Hs(r,a,e,n)}(e,t);case"elementConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ia(na(e,"tagName"));var r=na(e,"attributeList");const a=r?sa(r,"attributeConstructor").map((e=>qs(e,Xs(t)))):[];return r=r?sa(r,"namespaceDeclaration").map((e=>{const t=na(e,"prefix");return{prefix:t?ra(t):"",uri:ra(na(e,"uri"))}})):[],e=(e=na(e,"elementContent"))?sa(e,"*").map((e=>qs(e,Xs(t)))):[],new Ms(n,a,r,e)}(e,t);case"attributeConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ia(na(e,"attributeName"));var r=na(e,"attributeValue");return r=r?ra(r):null,e=(e=na(e,"attributeValueExpr"))?sa(e,"*").map((e=>qs(e,Xs(t)))):null,new ks(n,{value:r,mb:e})}(e,t);case"computedAttributeConstructor":return(n=na(e,"tagName"))?n=ia(n):(n=na(e,"tagNameExpr"),n={Na:qs(na(n,"*"),Xs(t))}),e=qs(na(na(e,"valueExpr"),"*"),Xs(t)),new ks(n,{mb:[e]});case"computedCommentConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=na(e,"argExpr"))?qs(na(e,"*"),Xs(t)):null,new Rs(e);case"computedTextConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=na(e,"argExpr"))?qs(na(e,"*"),Xs(t)):null,new $s(e);case"computedElementConstructor":return function(e,t){var n=na(e,"tagName");return n?n=ia(n):(n=na(e,"tagNameExpr"),n={Na:qs(na(n,"*"),Xs(t))}),e=(e=na(e,"contentExpr"))?sa(e,"*").map((e=>qs(e,Xs(t)))):[],new Ms(n,[],[],e)}(e,t);case"computedPIConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return n=na(e,"piTargetExpr"),r=na(e,"piTarget"),a=na(e,"piValueExpr"),e=aa(e,"type"),new Ls({vb:n?qs(na(n,"*"),Xs(t)):null,Db:r?ra(r):null},a?qs(na(a,"*"),Xs(t)):new Co([],e));case"CDataSection":return new co(ra(e),{type:1,g:3});case"deleteExpr":return e=qs(oa(e,["targetExpr","*"]),t),new gs(e);case"insertExpr":switch(n=qs(oa(e,["sourceExpr","*"]),t),(a=sa(e,"*")[1])[0]){case"insertAfter":r=1;break;case"insertBefore":r=2;break;case"insertInto":r=(r=na(a,"*"))?"insertAsFirst"===r[0]?4:5:3}return e=qs(oa(e,["targetExpr","*"]),t),new xs(n,r,e);case"renameExpr":return n=qs(oa(e,["targetExpr","*"]),t),e=qs(oa(e,["newNameExpr","*"]),t),new Is(n,e);case"replaceExpr":return n=!!na(e,"replaceValue"),r=qs(oa(e,["targetExpr","*"]),t),e=qs(oa(e,["replacementExpr","*"]),t),new Cs(n,r,e);case"transformExpr":return function(e,t){const n=sa(na(e,"transformCopies"),"transformCopy").map((e=>{const n=ia(na(na(e,"varRef"),"name"));return{eb:qs(na(na(e,"copySource"),"*"),t),Gb:new H(n.prefix,n.namespaceURI,n.localName)}})),r=qs(na(na(e,"modifyExpr"),"*"),t);return e=qs(na(na(e,"returnExpr"),"*"),t),new Fs(n,r,e)}(e,t);case"x:stackTrace":for(n=e[1],e=e[2];"x:stackTrace"===e[0];)e=e[2];return new no(n,e[0],qs(e,t));default:return Vs(e)}}function Vs(e){switch(e[0]){case"nameTest":return new Ko(ia(e));case"piTest":return(e=na(e,"piTarget"))?new Wo(ra(e)):new Qo(7);case"commentTest":return new Qo(8);case"textTest":return new Qo(3);case"documentTest":return new Qo(9);case"attributeTest":var t=(e=na(e,"attributeName"))&&na(e,"star");return!e||t?new Qo(2):new Ko(ia(na(e,"QName")),{kind:2});case"elementTest":return t=(e=na(e,"elementName"))&&na(e,"star"),!e||t?new Qo(1):new Ko(ia(na(e,"QName")),{kind:1});case"anyKindTest":return new Zo({prefix:"",namespaceURI:null,localName:"node()"});case"anyMapTest":return new Zo({prefix:"",namespaceURI:null,localName:"map(*)"});case"anyArrayTest":return new Zo({prefix:"",namespaceURI:null,localName:"array(*)"});case"Wildcard":return na(e,"star")?(t=na(e,"uri"))?e=new Ko({localName:"*",namespaceURI:ra(t),prefix:""}):(t=na(e,"NCName"),e="star"===na(e,"*")[0]?new Ko({localName:ra(t),namespaceURI:null,prefix:"*"}):new Ko({localName:"*",namespaceURI:null,prefix:ra(t)})):e=new Ko({localName:"*",namespaceURI:null,prefix:"*"}),e;case"atomicType":return new Zo(ia(e));case"anyItemType":return new Zo({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+e[0]+".")}}function Ys(e,t,n){const r=[];return function t(a){const o=na(na(a,"firstOperand"),"*");a=na(na(a,"secondOperand"),"*"),o[0]===e?t(o):r.push(qs(o,n)),a[0]===e?t(a):r.push(qs(a,n))}(t),r}function zs(e,t){switch((e=na(e,"*"))[0]){case"NCName":return new co(ra(e),{type:1,g:3});case"star":return"*";default:return qs(e,Xs(t))}}function Js(e,t,n){var r=oa(t,["firstOperand","*"]);const a=oa(t,["secondOperand","*"]);switch(r=qs(r,Xs(n)),n=qs(a,Xs(n)),e){case"valueCompare":return new bo(t[0],r,n);case"nodeCompare":return new To(t[0],r,n);case"generalCompare":return new Eo(t[0],r,n)}}function Qs(e,t){return qs(e,t)}const Ks=new Map;class Ws{constructor(e,t,n,r,a,o){this.v=e,this.D=t,this.h=n,this.jb=r,this.o=a,this.l=o}}function Zs(e,t,n,r,a,o,s){let i=Ks.get(e);i||(i=Object.create(null),Ks.set(e,i)),(t=i[e=t+(o?"_DEBUG":"")])||(t=i[e]=[]),t.push(new Ws(Object.values(n.h),Object.values(n.o),a,Object.keys(r).map((e=>({namespaceURI:r[e],prefix:e}))),s,n.D))}function ei(e){var t=new q;if("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"!==e.namespaceURI)throw Ze("The XML structure passed as an XQueryX program was not valid XQueryX");const n=["stackTrace"===e.localName?"x:stackTrace":e.localName],r=t.getAllAttributes(e);r&&0<r.length&&n.push(Array.from(r).reduce(((t,n)=>("start"===n.localName||"end"===n.localName&&"stackTrace"===e.localName?t[n.localName]=JSON.parse(n.value):"type"===n.localName?t[n.localName]=D(n.value):t[n.localName]=n.value,t)),{})),t=t.getChildNodes(e);for(const e of t)switch(e.nodeType){case 1:n.push(ei(e));break;case 3:n.push(e.data)}return n}const ti=Object.create(null);var ni=(e,t)=>{let n=ti[e];n||=ti[e]={Ha:[],Ta:[],oa:null,source:t.source};const r=n.oa||(()=>{});n.Ha=n.Ha.concat(t.Ha),n.Ta=n.Ta.concat(t.Ta),n.oa=e=>{r(e),t.oa&&t.oa(e)}},ri=(e,t)=>{const n=ti[t];if(!n)throw Error(`XQST0051: No modules found with the namespace uri ${t}`);n.Ha.forEach((n=>{n.bb&&Qr(e,t,n.localName,n.arity,n)})),n.Ta.forEach((n=>{Wr(e,t,n.localName),Zr(e,t,n.localName,((e,t)=>Un(n.ba,e,t)))}))},ai=()=>{Object.keys(ti).forEach((e=>{if((e=ti[e]).oa)try{e.oa(e)}catch(t){e.oa=null,Sr(e.source,t)}e.oa=null}))};function oi(e){return e.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))}var si=t;function ii(e,t){return(n,r)=>t.has(r)?t.get(r):(n=e(n,r),t.set(r,n),n)}function li(e,t){return(0,si.delimited)(t,e,t)}function ci(e,t){return e.reverse().reduce(((e,t)=>(0,si.preceded)(t,e)),t)}function ui(e,t,n,r){return(0,si.then)((0,si.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>r(e,t,n)))}function hi(e,t,n,r,a){return(0,si.then)((0,si.then)((0,si.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>a(e,t,n,r)))}function pi(e){return(0,si.map)(e,(e=>[e]))}function di(e,t){return(0,si.map)((0,si.or)(e),(()=>t))}function mi(e){return(t,n)=>(t=e.exec(t.substring(n)))&&0===t.index?(0,si.okWithValue)(n+t[0].length,t[0]):(0,si.error)(n,[e.source],!1)}var fi=(0,si.or)([(0,si.token)(" "),(0,si.token)("\t"),(0,si.token)("\r"),(0,si.token)("\n")]),gi=(0,si.token)("(:"),yi=(0,si.token)(":)"),wi=(0,si.token)("(#"),vi=(0,si.token)("#)"),xi=(0,si.token)("("),bi=(0,si.token)(")"),Ai=(0,si.token)("["),Ei=(0,si.token)("]"),Ni=(0,si.token)("{"),Ti=(0,si.token)("}"),Bi=(0,si.token)("{{"),Ii=(0,si.token)("}}"),Ci=(0,si.token)("'"),Si=(0,si.token)("''"),Oi=(0,si.token)('"'),Fi=(0,si.token)('""'),Di=(0,si.token)("<![CDATA["),ki=(0,si.token)("]]>"),Ri=(0,si.token)("/>"),Mi=(0,si.token)("</"),Ui=(0,si.token)("\x3c!--"),Gi=(0,si.token)("--\x3e"),Li=(0,si.token)("<?"),$i=(0,si.token)("?>"),Hi=(0,si.token)("&#x"),Pi=(0,si.token)("&#"),_i=(0,si.token)(":*"),ji=(0,si.token)("*:"),Xi=(0,si.token)(":="),qi=(0,si.token)("&"),Vi=(0,si.token)(":"),Yi=(0,si.token)(";"),zi=(0,si.token)("*"),Ji=(0,si.token)("@"),Qi=(0,si.token)("$"),Ki=(0,si.token)("#"),Wi=(0,si.token)("%"),Zi=(0,si.token)("?"),el=(0,si.token)("="),tl=(0,si.followed)((0,si.token)("!"),(0,si.not)((0,si.peek)(el),[])),nl=(0,si.followed)((0,si.token)("|"),(0,si.not)((0,si.peek)((0,si.token)("|")),[])),rl=(0,si.token)("||"),al=(0,si.token)("!="),ol=(0,si.token)("<"),sl=(0,si.token)("<<"),il=(0,si.token)("<="),ll=(0,si.token)(">"),cl=(0,si.token)(">>"),ul=(0,si.token)(">="),hl=(0,si.token)(","),pl=(0,si.token)("."),dl=(0,si.token)(".."),ml=(0,si.token)("+"),fl=(0,si.token)("-"),gl=(0,si.token)("/"),yl=(0,si.token)("//"),wl=(0,si.token)("=>"),vl=(0,si.token)("e"),xl=(0,si.token)("E");(0,si.token)("l"),(0,si.token)("L"),(0,si.token)("m"),(0,si.token)("M");var bl=(0,si.token)("Q");(0,si.token)("x"),(0,si.token)("X");var Al=(0,si.token)("as"),El=(0,si.token)("cast"),Nl=(0,si.token)("castable"),Tl=(0,si.token)("treat"),Bl=(0,si.token)("instance"),Il=(0,si.token)("of"),Cl=(0,si.token)("node"),Sl=(0,si.token)("nodes"),Ol=(0,si.token)("delete"),Fl=(0,si.token)("value"),Dl=(0,si.token)("function"),kl=(0,si.token)("map"),Rl=(0,si.token)("element"),Ml=(0,si.token)("attribute"),Ul=(0,si.token)("schema-element"),Gl=(0,si.token)("intersect"),Ll=(0,si.token)("except"),$l=(0,si.token)("union"),Hl=(0,si.token)("to"),Pl=(0,si.token)("is"),_l=(0,si.token)("or"),jl=(0,si.token)("and"),Xl=(0,si.token)("div"),ql=(0,si.token)("idiv"),Vl=(0,si.token)("mod"),Yl=(0,si.token)("eq"),zl=(0,si.token)("ne"),Jl=(0,si.token)("lt"),Ql=(0,si.token)("le"),Kl=(0,si.token)("gt"),Wl=(0,si.token)("ge"),Zl=(0,si.token)("amp"),ec=(0,si.token)("quot"),tc=(0,si.token)("apos"),nc=(0,si.token)("if"),rc=(0,si.token)("then"),ac=(0,si.token)("else"),oc=(0,si.token)("allowing"),sc=(0,si.token)("empty"),ic=(0,si.token)("at"),lc=(0,si.token)("in"),cc=(0,si.token)("for"),uc=(0,si.token)("let"),hc=(0,si.token)("where"),pc=(0,si.token)("collation"),dc=(0,si.token)("group"),mc=(0,si.token)("by"),fc=(0,si.token)("order"),gc=(0,si.token)("stable"),yc=(0,si.token)("return"),wc=(0,si.token)("array"),vc=(0,si.token)("document"),xc=(0,si.token)("namespace"),bc=(0,si.token)("text"),Ac=(0,si.token)("comment"),Ec=(0,si.token)("processing-instruction"),Nc=(0,si.token)("lax"),Tc=(0,si.token)("strict"),Bc=(0,si.token)("validate"),Ic=(0,si.token)("type"),Cc=(0,si.token)("declare"),Sc=(0,si.token)("default"),Oc=(0,si.token)("boundary-space"),Fc=(0,si.token)("strip"),Dc=(0,si.token)("preserve"),kc=(0,si.token)("no-preserve"),Rc=(0,si.token)("inherit"),Mc=(0,si.token)("no-inherit"),Uc=(0,si.token)("greatest"),Gc=(0,si.token)("least"),Lc=(0,si.token)("copy-namespaces"),$c=(0,si.token)("decimal-format"),Hc=(0,si.token)("case"),Pc=(0,si.token)("typeswitch"),_c=(0,si.token)("some"),jc=(0,si.token)("every"),Xc=(0,si.token)("satisfies"),qc=(0,si.token)("replace"),Vc=(0,si.token)("with"),Yc=(0,si.token)("copy"),zc=(0,si.token)("modify"),Jc=(0,si.token)("first"),Qc=(0,si.token)("last"),Kc=(0,si.token)("before"),Wc=(0,si.token)("after"),Zc=(0,si.token)("into"),eu=(0,si.token)("insert"),tu=(0,si.token)("rename"),nu=(0,si.token)("switch"),ru=(0,si.token)("variable"),au=(0,si.token)("external"),ou=(0,si.token)("updating"),su=(0,si.token)("import"),iu=(0,si.token)("schema"),lu=(0,si.token)("module"),cu=(0,si.token)("base-uri"),uu=(0,si.token)("construction"),hu=(0,si.token)("ordering"),pu=(0,si.token)("ordered"),du=(0,si.token)("unordered"),mu=(0,si.token)("option"),fu=(0,si.token)("context"),gu=(0,si.token)("item"),yu=(0,si.token)("xquery"),wu=(0,si.token)("version"),vu=(0,si.token)("encoding"),xu=(0,si.token)("document-node"),bu=(0,si.token)("namespace-node"),Au=(0,si.token)("schema-attribute"),Eu=(0,si.token)("ascending"),Nu=(0,si.token)("descending"),Tu=(0,si.token)("empty-sequence"),Bu=(0,si.token)("child::"),Iu=(0,si.token)("descendant::"),Cu=(0,si.token)("attribute::"),Su=(0,si.token)("self::"),Ou=(0,si.token)("descendant-or-self::"),Fu=(0,si.token)("following-sibling::"),Du=(0,si.token)("following::"),ku=(0,si.token)("parent::"),Ru=(0,si.token)("ancestor::"),Mu=(0,si.token)("preceding-sibling::"),Uu=(0,si.token)("preceding::"),Gu=(0,si.token)("ancestor-or-self::"),Lu=(0,si.token)("decimal-separator"),$u=(0,si.token)("grouping-separator"),Hu=(0,si.token)("infinity"),Pu=(0,si.token)("minus-sign"),_u=(0,si.token)("NaN"),ju=(0,si.token)("per-mille"),Xu=(0,si.token)("zero-digit"),qu=(0,si.token)("digit"),Vu=(0,si.token)("pattern-separator"),Yu=(0,si.token)("exponent-separator"),zu=(0,si.token)("schema-attribute("),Ju=(0,si.token)("document-node("),Qu=(0,si.token)("processing-instruction("),Ku=(0,si.token)("processing-instruction()"),Wu=(0,si.token)("comment()"),Zu=(0,si.token)("text()"),eh=(0,si.token)("namespace-node()"),th=(0,si.token)("node()"),nh=(0,si.token)("item()"),rh=(0,si.token)("empty-sequence()"),ah=new Map,oh=new Map,sh=(0,si.or)([mi(/[\t\n\r -\uD7FF\uE000\uFFFD]/),mi(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),ih=(0,si.preceded)((0,si.peek)((0,si.not)((0,si.or)([gi,yi]),['comment contents cannot contain "(:" or ":)"'])),sh),lh=(0,si.map)((0,si.delimited)(gi,(0,si.star)((0,si.or)([ih,function(e,t){return lh(e,t)}])),yi,!0),(e=>e.join(""))),ch=(0,si.or)([fi,lh]),uh=(0,si.map)((0,si.plus)(fi),(e=>e.join(""))),hh=ii((0,si.map)((0,si.star)(ch),(e=>e.join(""))),ah),ph=ii((0,si.map)((0,si.plus)(ch),(e=>e.join(""))),oh);const dh=(0,si.or)([mi(/[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,si.then)(mi(/[\uD800-\uDB7F]/),mi(/[\uDC00-\uDFFF]/),((e,t)=>e+t))]),mh=(0,si.or)([dh,mi(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var fh=(0,si.then)(dh,(0,si.star)(mh),((e,t)=>e+t.join(""))),gh=(0,si.map)(fh,(e=>["prefix",e]));const yh=(0,si.or)([dh,Vi]),wh=(0,si.or)([mh,Vi]);(0,si.then)(yh,(0,si.star)(wh),((e,t)=>e+t.join("")));const vh=(0,si.map)(fh,(e=>[{prefix:"",URI:null},e])),xh=(0,si.then)(fh,(0,si.preceded)(Vi,fh),((e,t)=>[{prefix:e,URI:null},t]));var bh=(0,si.or)([xh,vh]),Ah=(0,si.followed)(ci([bl,hh,Ni],(0,si.map)((0,si.star)(mi(/[^{}]/)),(e=>e.join("").replace(/\s+/g," ").trim()))),Ti);const Eh=(0,si.then)(Ah,fh,((e,t)=>[e,t]));var Nh=(0,si.or)([(0,si.map)(Eh,(e=>[{prefix:null,URI:e[0]},e[1]])),bh]),Th=(0,si.or)([(0,si.map)(Nh,(e=>["QName",...e])),(0,si.map)(zi,(()=>["star"]))]),Bh=(0,si.map)((0,si.preceded)(Qi,Nh),(e=>["varRef",["name",...e]])),Ih=(0,si.peek)((0,si.or)([xi,Oi,Ci,ch])),Ch=(0,si.map)((0,si.or)([Bu,Iu,Cu,Su,Ou,Fu,Du]),(e=>e.substring(0,e.length-2))),Sh=(0,si.map)((0,si.or)([ku,Ru,Mu,Uu,Gu]),(e=>e.substring(0,e.length-2))),Oh=ui(qi,(0,si.or)([Jl,Kl,Zl,ec,tc]),Yi,((e,t,n)=>e+t+n)),Fh=(0,si.or)([ui(Hi,mi(/[0-9a-fA-F]+/),Yi,((e,t,n)=>e+t+n)),ui(Pi,mi(/[0-9]+/),Yi,((e,t,n)=>e+t+n))]),Dh=di([Fi],'"'),kh=di([Si],"'"),Rh=pi(di([Wu],"commentTest")),Mh=pi(di([Zu],"textTest")),Uh=pi(di([eh],"namespaceTest")),Gh=pi(di([th],"anyKindTest"));const Lh=mi(/[0-9]+/),$h=(0,si.then)((0,si.or)([(0,si.then)(pl,Lh,((e,t)=>e+t)),(0,si.then)(Lh,(0,si.optional)((0,si.preceded)(pl,mi(/[0-9]*/))),((e,t)=>e+(null!==t?"."+t:"")))]),ui((0,si.or)([vl,xl]),(0,si.optional)((0,si.or)([ml,fl])),Lh,((e,t,n)=>e+(t||"")+n)),((e,t)=>["doubleConstantExpr",["value",e+t]])),Hh=(0,si.or)([(0,si.map)((0,si.preceded)(pl,Lh),(e=>["decimalConstantExpr",["value","."+e]])),(0,si.then)((0,si.followed)(Lh,pl),(0,si.optional)(Lh),((e,t)=>["decimalConstantExpr",["value",e+"."+(null!==t?t:"")]]))]);var Ph=(0,si.map)(Lh,(e=>["integerConstantExpr",["value",e]])),_h=(0,si.followed)((0,si.or)([$h,Hh,Ph]),(0,si.peek)((0,si.not)(mi(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),jh=(0,si.map)((0,si.followed)(pl,(0,si.peek)((0,si.not)(pl,["context item should not be followed by another ."]))),(()=>["contextItemExpr"])),Xh=(0,si.or)([wc,Ml,Ac,xu,Rl,Tu,Dl,nc,gu,kl,bu,Cl,Ec,Au,Ul,nu,bc,Pc]),qh=pi(di([Zi],"argumentPlaceholder")),Vh=(0,si.or)([Zi,zi,ml]),Yh=(0,si.preceded)((0,si.peek)((0,si.not)(mi(/[{}<&]/),["elementContentChar cannot be {, }, <, or &"])),sh),zh=(0,si.map)((0,si.delimited)(Di,(0,si.star)((0,si.preceded)((0,si.peek)((0,si.not)(ki,['CDataSection content may not contain "]]>"'])),sh)),ki,!0),(e=>["CDataSection",e.join("")])),Jh=(0,si.preceded)((0,si.peek)((0,si.not)(mi(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),sh),Qh=(0,si.preceded)((0,si.peek)((0,si.not)(mi(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),sh),Kh=(0,si.map)((0,si.star)((0,si.or)([(0,si.preceded)((0,si.peek)((0,si.not)(fl,[])),sh),(0,si.map)(ci([fl,(0,si.peek)((0,si.not)(fl,[]))],sh),(e=>"-"+e))])),(e=>e.join(""))),Wh=(0,si.map)((0,si.delimited)(Ui,Kh,Gi,!0),(e=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",e]]]]));const Zh=(0,si.filter)(fh,(e=>"xml"!==e.toLowerCase()),['A processing instruction target cannot be "xml"']),ep=(0,si.map)((0,si.star)((0,si.preceded)((0,si.peek)((0,si.not)($i,[])),sh)),(e=>e.join("")));var tp=(0,si.then)((0,si.preceded)(Li,(0,si.cut)(Zh)),(0,si.cut)((0,si.followed)((0,si.optional)((0,si.preceded)(uh,ep)),$i)),((e,t)=>["computedPIConstructor",["piTarget",e],["piValueExpr",["stringConstantExpr",["value",t]]]])),np=(0,si.map)(yl,(()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]])),rp=(0,si.or)([Nc,Tc]),ap=(0,si.map)((0,si.star)((0,si.followed)(sh,(0,si.peek)((0,si.not)(vi,["Pragma contents should not contain '#)'"])))),(e=>e.join(""))),op=(0,si.map)((0,si.followed)((0,si.or)([Yl,zl,Jl,Ql,Kl,Wl]),Ih),(e=>e+"Op")),sp=(0,si.or)([(0,si.followed)(di([Pl],"isOp"),Ih),di([sl],"nodeBeforeOp"),di([cl],"nodeAfterOp")]),ip=(0,si.or)([di([el],"equalOp"),di([al],"notEqualOp"),di([il],"lessThanOrEqualOp"),di([ol],"lessThanOp"),di([ul],"greaterThanOrEqualOp"),di([ll],"greaterThanOp")]),lp=(0,si.map)(ou,(()=>["annotation",["annotationName","updating"]]));const cp=(0,si.or)([Dc,kc]),up=(0,si.or)([Rc,Mc]);var hp=(0,si.or)([Lu,$u,Hu,Pu,_u,Wi,ju,Xu,qu,Vu,Yu]),pp=(0,si.map)(ci([Cc,ph,Oc,ph],(0,si.or)([Dc,Fc])),(e=>["boundarySpaceDecl",e])),dp=(0,si.map)(ci([Cc,ph,uu,ph],(0,si.or)([Dc,Fc])),(e=>["constructionDecl",e])),mp=(0,si.map)(ci([Cc,ph,hu,ph],(0,si.or)([pu,du])),(e=>["orderingModeDecl",e])),fp=(0,si.map)(ci([Cc,ph,Sc,ph,fc,ph,sc,ph],(0,si.or)([Uc,Gc])),(e=>["emptyOrderDecl",e])),gp=(0,si.then)(ci([Cc,ph,Lc,ph],cp),ci([hh,hl,hh],up),((e,t)=>["copyNamespacesDecl",["preserveMode",e],["inheritMode",t]]));function yp(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 wp(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 vp(e){return e.replace(/(&[^;]+);/g,(e=>{if(/^&#x/.test(e))return wp(e=parseInt(e.slice(3,-1),16)),String.fromCodePoint(e);if(/^&#/.test(e))return wp(e=parseInt(e.slice(2,-1),10)),String.fromCodePoint(e);switch(e){case"<":return"<";case">":return">";case"&":return"&";case""":return String.fromCharCode(34);case"'":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: "'+e+'"')}))}function xp(e,t,n){if(!e.length)return[];let r=[e[0]];for(let t=1;t<e.length;++t){const n=r[r.length-1];"string"==typeof n&&"string"==typeof e[t]?r[r.length-1]=n+e[t]:r.push(e[t])}if("string"==typeof r[0]&&0===r.length)return[];if(r=r.reduce(((e,t,a)=>{if("string"!=typeof t)e.push(t);else if(n&&/^\s*$/.test(t)){const n=r[a+1];(n&&"CDataSection"===n[0]||(a=r[a-1])&&"CDataSection"===a[0])&&e.push(vp(t))}else e.push(vp(t));return e}),[]),!r.length)return r;if(1<r.length||t)for(e=0;e<r.length;e++)"string"==typeof r[e]&&(r[e]=["stringConstantExpr",["value",r[e]]]);return r}function bp(e){return e[0].prefix?e[0].prefix+":"+e[1]:e[1]}var Ap=(0,si.then)(Nh,(0,si.optional)(Zi),((e,t)=>null!==t?["singleType",["atomicType",...e],["optional"]]:["singleType",["atomicType",...e]])),Ep=(0,si.map)(Nh,(e=>["atomicType",...e]));const Np=new Map;function Tp(e){function t(e,t){return t.reduce(((e,t)=>[t[0],["firstOperand",e],["secondOperand",t[1]]]),e)}function n(e,t,n){return(0,si.then)(e,(0,si.star)((0,si.then)(li(t,hh),(0,si.cut)(e),((e,t)=>[e,t]))),n)}function r(e,t,n="firstOperand",r="secondOperand"){return(0,si.then)(e,(0,si.optional)((0,si.then)(li(t,hh),(0,si.cut)(e),((e,t)=>[e,t]))),((e,t)=>null===t?e:[t[0],[n,e],[r,t[1]]]))}function a(t){return e.lb?(e,n)=>{if(!(e=t(e,n)).success)return e;const r=c.has(n)?c.get(n):{offset:n,line:-1,ha:-1},a=c.has(e.offset)?c.get(e.offset):{offset:e.offset,line:-1,ha:-1};return c.set(n,r),c.set(e.offset,a),(0,si.okWithValue)(e.offset,["x:stackTrace",{start:r,end:a},e.value])}:t}function o(e,t){return J(e,t)}function s(e,t){return Ge(e,t)}function i(e,t){return a((0,si.or)([Tt,Ft,Ht,Ct,ot,Gt,Dt,Lt,kt,Mt,at]))(e,t)}function l(e,t){return n(i,hl,((e,t)=>0===t.length?e:["sequenceExpr",e,...t.map((e=>e[1]))]))(e,t)}const c=new Map,u=(0,si.preceded)(Ai,(0,si.followed)(li(l,hh),Ei)),h=(0,si.map)(e.Ya?(0,si.or)([li((0,si.star)((0,si.or)([Oh,Fh,Dh,mi(/[^"&]/)])),Oi),li((0,si.star)((0,si.or)([Oh,Fh,kh,mi(/[^'&]/)])),Ci)]):(0,si.or)([li((0,si.star)((0,si.or)([Dh,mi(/[^"]/)])),Oi),li((0,si.star)((0,si.or)([kh,mi(/[^']/)])),Ci)]),(e=>e.join(""))),p=(0,si.or)([(0,si.map)(ci([Rl,hh],(0,si.delimited)((0,si.followed)(xi,hh),(0,si.then)(Th,ci([hh,hl,hh],Nh),((e,t)=>[["elementName",e],["typeName",...t]])),(0,si.preceded)(hh,bi))),(([e,t])=>["elementTest",e,t])),(0,si.map)(ci([Rl,hh],(0,si.delimited)(xi,Th,bi)),(e=>["elementTest",["elementName",e]])),(0,si.map)(ci([Rl,hh],(0,si.delimited)(xi,hh,bi)),(()=>["elementTest"]))]),d=(0,si.or)([(0,si.map)(Nh,(e=>["QName",...e])),(0,si.map)(zi,(()=>["star"]))]),m=(0,si.or)([(0,si.map)(ci([Ml,hh],(0,si.delimited)((0,si.followed)(xi,hh),(0,si.then)(d,ci([hh,hl,hh],Nh),((e,t)=>[["attributeName",e],["typeName",...t]])),(0,si.preceded)(hh,bi))),(([e,t])=>["attributeTest",e,t])),(0,si.map)(ci([Ml,hh],(0,si.delimited)(xi,d,bi)),(e=>["attributeTest",["attributeName",e]])),(0,si.map)(ci([Ml,hh],(0,si.delimited)(xi,hh,bi)),(()=>["attributeTest"]))]),f=(0,si.map)(ci([Ul,hh,xi],(0,si.followed)(Nh,bi)),(e=>["schemaElementTest",...e])),g=(0,si.map)((0,si.delimited)(zu,li(Nh,hh),bi),(e=>["schemaAttributeTest",...e])),y=(0,si.map)((0,si.preceded)(Ju,(0,si.followed)(li((0,si.optional)((0,si.or)([p,f])),hh),bi)),(e=>["documentTest",...e?[e]:[]])),w=(0,si.or)([(0,si.map)((0,si.preceded)(Qu,(0,si.followed)(li((0,si.or)([fh,h]),hh),bi)),(e=>["piTest",["piTarget",e]])),pi(di([Ku],"piTest"))]),v=(0,si.or)([y,p,m,f,g,w,Rh,Mh,Uh,Gh]),x=(0,si.or)([(0,si.map)((0,si.preceded)(ji,fh),(e=>["Wildcard",["star"],["NCName",e]])),pi(di([zi],"Wildcard")),(0,si.map)((0,si.followed)(Ah,zi),(e=>["Wildcard",["uri",e],["star"]])),(0,si.map)((0,si.followed)(fh,_i),(e=>["Wildcard",["NCName",e],["star"]]))]),b=(0,si.or)([x,(0,si.map)(Nh,(e=>["nameTest",...e]))]),A=(0,si.or)([v,b]),E=(0,si.then)((0,si.optional)(Ji),A,((e,t)=>null!==e||"attributeTest"===t[0]||"schemaAttributeTest"===t[0]?["stepExpr",["xpathAxis","attribute"],t]:["stepExpr",["xpathAxis","child"],t])),N=(0,si.or)([(0,si.then)(Ch,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),E]),T=(0,si.map)(dl,(()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]])),B=(0,si.or)([(0,si.then)(Sh,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),T]),I=(0,si.map)((0,si.star)((0,si.preceded)(hh,u)),(e=>0<e.length?["predicates",...e]:void 0)),C=(0,si.then)((0,si.or)([B,N]),I,((e,t)=>void 0===t?e:e.concat([t]))),S=(0,si.or)([_h,(0,si.map)(h,(t=>["stringConstantExpr",["value",e.Ya?vp(t):t]]))]),O=(0,si.or)([(0,si.delimited)(xi,li(l,hh),bi),(0,si.map)((0,si.delimited)(xi,hh,bi),(()=>["sequenceExpr"]))]),F=(0,si.or)([i,qh]),D=(0,si.map)((0,si.delimited)(xi,li((0,si.optional)((0,si.then)(F,(0,si.star)((0,si.preceded)(li(hl,hh),F)),((e,t)=>[e,...t]))),hh),bi),(e=>null!==e?e:[])),k=(0,si.preceded)((0,si.not)(ui(Xh,hh,xi,(()=>{})),["cannot use reseved keyword for function names"]),(0,si.then)(Nh,(0,si.preceded)(hh,D),((e,t)=>["functionCallExpr",["functionName",...e],null!==t?["arguments",...t]:["arguments"]]))),R=(0,si.then)(Nh,(0,si.preceded)(Ki,Ph),((e,t)=>["namedFunctionRef",["functionName",...e],t])),M=(0,si.delimited)(Ni,li((0,si.optional)(l),hh),Ti),U=(0,si.map)(M,(e=>e||["sequenceExpr"])),G=(0,si.or)([(0,si.map)(rh,(()=>[["voidSequenceType"]])),(0,si.then)(o,(0,si.optional)((0,si.preceded)(hh,Vh)),((e,t)=>[e,...null!==t?[["occurrenceIndicator",t]]:[]]))]),L=(0,si.then)(ci([Wi,hh],Nh),(0,si.optional)((0,si.followed)((0,si.then)(ci([xi,hh],S),(0,si.star)(ci([hl,hh],S)),((e,t)=>e.concat(t))),bi)),((e,t)=>["annotation",["annotationName",...e],...t?["arguments",t]:[]])),$=(0,si.map)(ci([Dl,hh,xi,hh,zi,hh],bi),(()=>["anyFunctionTest"])),H=(0,si.then)(ci([Dl,hh,xi,hh],(0,si.optional)(n(G,hl,((e,t)=>e.concat.apply(e,t.map((e=>e[1]))))))),ci([hh,bi,ph,Al,ph],G),((e,t)=>["typedFunctionTest",["paramTypeList",["sequenceType",...e||[]]],["sequenceType",...t]])),P=(0,si.then)((0,si.star)(L),(0,si.or)([$,H]),((e,t)=>[t[0],...e,...t.slice(1)])),_=(0,si.map)(ci([kl,hh,xi,hh,zi,hh],bi),(()=>["anyMapTest"])),j=(0,si.then)(ci([kl,hh,xi,hh],Ep),ci([hh,hl],(0,si.followed)(li(G,hh),bi)),((e,t)=>["typedMapTest",e,["sequenceType",...t]])),X=(0,si.or)([_,j]),q=(0,si.map)(ci([wc,hh,xi,hh,zi,hh],bi),(()=>["anyArrayTest"])),V=(0,si.map)(ci([wc,hh,xi],(0,si.followed)(li(G,hh),bi)),(e=>["typedArrayTest",["sequenceType",...e]])),Y=(0,si.or)([q,V]),z=(0,si.map)((0,si.delimited)(xi,li(o,hh),bi),(e=>["parenthesizedItemType",e])),J=(0,si.or)([v,pi(di([nh],"anyItemType")),P,X,Y,Ep,z]),Q=(0,si.map)(ci([Al,ph],G),(e=>["typeDeclaration",...e])),K=(0,si.then)((0,si.preceded)(Qi,Nh),(0,si.optional)((0,si.preceded)(ph,Q)),((e,t)=>["param",["varName",...e],...t?[t]:[]])),W=n(K,hl,((e,t)=>[e,...t.map((e=>e[1]))])),Z=hi((0,si.star)(L),ci([hh,Dl,hh,xi,hh],(0,si.optional)(W)),ci([hh,bi,hh],(0,si.optional)((0,si.map)(ci([Al,hh],(0,si.followed)(G,hh)),(e=>["typeDeclaration",...e])))),U,((e,t,n,r)=>["inlineFunctionExpr",...e,["paramList",...t||[]],...n?[n]:[],["functionBody",r]])),ee=(0,si.or)([R,Z]),te=(0,si.map)(i,(e=>["mapKeyExpr",e])),ne=(0,si.map)(i,(e=>["mapValueExpr",e])),re=(0,si.then)(te,(0,si.preceded)(li(Vi,hh),ne),((e,t)=>["mapConstructorEntry",e,t])),ae=(0,si.preceded)(kl,(0,si.delimited)(li(Ni,hh),(0,si.map)((0,si.optional)(n(re,li(hl,hh),((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>e?["mapConstructor",...e]:["mapConstructor"])),(0,si.preceded)(hh,Ti))),oe=(0,si.map)((0,si.delimited)(Ai,li((0,si.optional)(n(i,hl,((e,t)=>[e,...t.map((e=>e[1]))].map((e=>["arrayElem",e]))))),hh),Ei),(e=>["squareArray",...null!==e?e:[]])),se=(0,si.map)((0,si.preceded)(wc,(0,si.preceded)(hh,M)),(e=>["curlyArray",...null!==e?[["arrayElem",e]]:[]])),ie=(0,si.map)((0,si.or)([oe,se]),(e=>["arrayConstructor",e])),le=(0,si.or)([fh,Ph,O,zi]),ce=(0,si.map)((0,si.preceded)(Zi,(0,si.preceded)(hh,le)),(e=>"*"===e?["unaryLookup",["star"]]:"string"==typeof e?["unaryLookup",["NCName",e]]:["unaryLookup",e])),ue=(0,si.or)([Oh,Fh,di([Bi],"{"),di([Ii],"}"),(0,si.map)(M,(e=>e||["sequenceExpr"]))]),he=(0,si.or)([zh,function(e,t){return we(e,t)},ue,Yh]),pe=(0,si.or)([(0,si.map)(Jh,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),de=(0,si.or)([(0,si.map)(Qh,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),me=(0,si.map)((0,si.or)([li((0,si.star)((0,si.or)([Dh,pe])),Oi),li((0,si.star)((0,si.or)([kh,de])),Ci)]),(e=>xp(e,!1,!1))),fe=(0,si.then)(bh,(0,si.preceded)(li(el,(0,si.optional)(uh)),me),((e,t)=>{if(""===e[0].prefix&&"xmlns"===e[1]){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",t.length?["uri",t[0]]:["uri"]]}if("xmlns"===e[0].prefix){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+e[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",e[1]],t.length?["uri",t[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(e),0===t.length?["attributeValue"]:1===t.length&&"string"==typeof t[0]?["attributeValue",t[0]]:["attributeValueExpr"].concat(t)]})),ge=(0,si.map)((0,si.star)((0,si.preceded)(uh,(0,si.optional)(fe))),(e=>e.filter(Boolean))),ye=ui((0,si.preceded)(ol,bh),ge,(0,si.or)([(0,si.map)(Ri,(()=>null)),(0,si.then)((0,si.preceded)(ll,(0,si.star)(he)),ci([hh,Mi],(0,si.followed)(bh,(0,si.then)((0,si.optional)(uh),ll,(()=>null)))),((e,t)=>[xp(e,!0,!0),t]))]),((e,t,n)=>{var r=n;if(n&&n.length){r=bp(e);const t=bp(n[1]);if(r!==t)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+r+'" does not match "'+t+'"');r=n[0]}return["elementConstructor",["tagName",...e],...t.length?[["attributeList",...t]]:[],...r&&r.length?[["elementContent",...r]]:[]]})),we=(0,si.or)([ye,Wh,tp]),ve=(0,si.map)(ci([vc,hh],M),(e=>["computedDocumentConstructor",...e?[["argExpr",e]]:[]])),xe=(0,si.map)(M,(e=>e?[["contentExpr",e]]:[])),be=(0,si.then)(ci([Rl,hh],(0,si.or)([(0,si.map)(Nh,(e=>["tagName",...e])),(0,si.map)((0,si.delimited)(Ni,li(l,hh),Ti),(e=>["tagNameExpr",e]))])),(0,si.preceded)(hh,xe),((e,t)=>["computedElementConstructor",e,...t])),Ae=(0,si.then)((0,si.preceded)(Ml,(0,si.or)([(0,si.map)(ci([Ih,hh],Nh),(e=>["tagName",...e])),(0,si.map)((0,si.preceded)(hh,(0,si.delimited)(Ni,li(l,hh),Ti)),(e=>["tagNameExpr",e]))])),(0,si.preceded)(hh,M),((e,t)=>["computedAttributeConstructor",e,["valueExpr",t||["sequenceExpr"]]])),Ee=(0,si.map)(M,(e=>e?[["prefixExpr",e]]:[])),Ne=(0,si.map)(M,(e=>e?[["URIExpr",e]]:[])),Te=(0,si.then)(ci([xc,hh],(0,si.or)([gh,Ee])),(0,si.preceded)(hh,Ne),((e,t)=>["computedNamespaceConstructor",...e,...t])),Be=(0,si.map)(ci([bc,hh],M),(e=>["computedTextConstructor",...e?[["argExpr",e]]:[]])),Ie=(0,si.map)(ci([Ac,hh],M),(e=>["computedCommentConstructor",...e?[["argExpr",e]]:[]])),Ce=ci([Ec,hh],(0,si.then)((0,si.or)([(0,si.map)(fh,(e=>["piTarget",e])),(0,si.map)((0,si.delimited)(Ni,li(l,hh),Ti),(e=>["piTargetExpr",e]))]),(0,si.preceded)(hh,M),((e,t)=>["computedPIConstructor",e,...t?[["piValueExpr",t]]:[]]))),Se=(0,si.or)([ve,be,Ae,Te,Be,Ie,Ce]),Oe=(0,si.or)([we,Se]),Fe=(0,si.or)([S,Bh,O,jh,k,Oe,ee,ae,ie,ce]),De=(0,si.map)(ci([Zi,hh],le),(e=>"*"===e?["lookup",["star"]]:"string"==typeof e?["lookup",["NCName",e]]:["lookup",e])),ke=(0,si.then)((0,si.map)(Fe,(e=>yp(e))),(0,si.star)((0,si.or)([(0,si.map)((0,si.preceded)(hh,u),(e=>["predicate",e])),(0,si.map)((0,si.preceded)(hh,D),(e=>["argumentList",e])),(0,si.preceded)(hh,De)])),((e,t)=>{function n(){i&&1===o.length?s.push(["predicate",o[0]]):0!==o.length&&s.push(["predicates",...o]),o.length=0}function r(e){n(),0!==s.length?("sequenceExpr"===a[0][0]&&2<a[0].length&&(a=[["sequenceExpr",...a]]),a=[["filterExpr",...a],...s],s.length=0):e&&(a=[["filterExpr",...a]])}let a=[e];const o=[],s=[];let i=!1;for(const e of t)switch(e[0]){case"predicate":o.push(e[1]);break;case"lookup":i=!0,n(),s.push(e);break;case"argumentList":r(!1),1<a.length&&(a=[["sequenceExpr",["pathExpr",["stepExpr",...a]]]]),a=[["dynamicFunctionInvocationExpr",["functionItem",...a],...e[1].length?[["arguments",...e[1]]]:[]]];break;default:throw Error("unreachable")}return r(!0),a})),Re=(0,si.or)([(0,si.map)(ke,(e=>["stepExpr",...e])),C]),Me=(0,si.followed)(Fe,(0,si.peek)((0,si.not)((0,si.preceded)(hh,(0,si.or)([u,D,De])),["primary expression not followed by predicate, argumentList, or lookup"]))),Ue=(0,si.or)([ui(Re,(0,si.preceded)(hh,np),(0,si.preceded)(hh,s),((e,t,n)=>["pathExpr",e,t,...n])),(0,si.then)(Re,(0,si.preceded)(li(gl,hh),s),((e,t)=>["pathExpr",e,...t])),Me,(0,si.map)(Re,(e=>["pathExpr",e]))]),Ge=(0,si.or)([ui(Re,(0,si.preceded)(hh,np),(0,si.preceded)(hh,s),((e,t,n)=>[e,t,...n])),(0,si.then)(Re,(0,si.preceded)(li(gl,hh),s),((e,t)=>[e,...t])),(0,si.map)(Re,(e=>[e]))]),Le=(0,si.or)([(0,si.map)(ci([gl,hh],Ge),(e=>["pathExpr",["rootExpr"],...e])),(0,si.then)(np,(0,si.preceded)(hh,Ge),((e,t)=>["pathExpr",["rootExpr"],e,...t])),(0,si.map)((0,si.followed)(gl,(0,si.not)((0,si.preceded)(hh,e.Ya?mi(/[*<a-zA-Z]/):mi(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),(()=>["pathExpr",["rootExpr"]]))]),$e=ii((0,si.or)([Ue,Le]),Np),He=(0,si.preceded)(Bc,(0,si.then)((0,si.optional)((0,si.or)([(0,si.map)((0,si.preceded)(hh,rp),(e=>["validationMode",e])),(0,si.map)(ci([hh,Ic,hh],Nh),(e=>["type",...e]))])),(0,si.delimited)((0,si.preceded)(hh,Ni),li(l,hh),Ti),((e,t)=>["validateExpr",...e?[e]:[],["argExpr",t]]))),Pe=(0,si.delimited)(wi,(0,si.then)((0,si.preceded)(hh,Nh),(0,si.optional)((0,si.preceded)(ph,ap)),((e,t)=>t?["pragma",["pragmaName",e],["pragmaContents",t]]:["pragma",["pragmaName",e]])),(0,si.preceded)(hh,vi)),_e=(0,si.map)((0,si.followed)((0,si.plus)(Pe),(0,si.preceded)(hh,(0,si.delimited)(Ni,li((0,si.optional)(l),hh),Ti))),(e=>["extensionExpr",...e])),je=a(n($e,tl,((e,t)=>0===t.length?e:["simpleMapExpr","pathExpr"===e[0]?e:["pathExpr",["stepExpr",["filterExpr",yp(e)]]]].concat(t.map((e=>"pathExpr"===(e=e[1])[0]?e:["pathExpr",["stepExpr",["filterExpr",yp(e)]]])))))),Xe=(0,si.or)([He,_e,je]),qe=(0,si.or)([(0,si.then)((0,si.or)([di([fl],"unaryMinusOp"),di([ml],"unaryPlusOp")]),(0,si.preceded)(hh,(function(e,t){return qe(e,t)})),((e,t)=>[e,["operand",t]])),Xe]),Ve=(0,si.or)([(0,si.map)(Nh,(e=>["EQName",...e])),Bh,O]),Ye=(0,si.then)(qe,(0,si.star)(ci([hh,wl,hh],(0,si.then)(Ve,(0,si.preceded)(hh,D),((e,t)=>[e,t])))),((e,t)=>t.reduce(((e,t)=>["arrowExpr",["argExpr",e],t[0],["arguments",...t[1]]]),e))),ze=(0,si.then)(Ye,(0,si.optional)(ci([hh,El,ph,Al,Ih,hh],Ap)),((e,t)=>null!==t?["castExpr",["argExpr",e],t]:e)),Je=(0,si.then)(ze,(0,si.optional)(ci([hh,Nl,ph,Al,Ih,hh],Ap)),((e,t)=>null!==t?["castableExpr",["argExpr",e],t]:e)),Qe=(0,si.then)(Je,(0,si.optional)(ci([hh,Tl,ph,Al,Ih,hh],G)),((e,t)=>null!==t?["treatExpr",["argExpr",e],["sequenceType",...t]]:e)),Ke=(0,si.then)(Qe,(0,si.optional)(ci([hh,Bl,ph,Il,Ih,hh],G)),((e,t)=>null!==t?["instanceOfExpr",["argExpr",e],["sequenceType",...t]]:e)),We=n(Ke,(0,si.followed)((0,si.or)([di([Gl],"intersectOp"),di([Ll],"exceptOp")]),Ih),t),Ze=n(We,(0,si.or)([di([nl],"unionOp"),(0,si.followed)(di([$l],"unionOp"),Ih)]),t),et=n(Ze,(0,si.or)([di([zi],"multiplyOp"),(0,si.followed)(di([Xl],"divOp"),Ih),(0,si.followed)(di([ql],"idivOp"),Ih),(0,si.followed)(di([Vl],"modOp"),Ih)]),t),tt=n(et,(0,si.or)([di([fl],"subtractOp"),di([ml],"addOp")]),t),nt=n(r(tt,(0,si.followed)(di([Hl],"rangeSequenceExpr"),Ih),"startExpr","endExpr"),di([rl],"stringConcatenateOp"),t),rt=n(r(nt,(0,si.or)([op,sp,ip])),(0,si.followed)(di([jl],"andOp"),Ih),t),at=n(rt,(0,si.followed)(di([_l],"orOp"),Ih),t),ot=(0,si.then)((0,si.then)(ci([nc,hh,xi,hh],l),ci([hh,bi,hh,rc,Ih,hh],i),((e,t)=>[e,t])),ci([hh,ac,Ih,hh],i),((e,t)=>["ifThenElseExpr",["ifClause",e[0]],["thenClause",e[1]],["elseClause",t]])),st=(0,si.delimited)(oc,ph,sc),it=(0,si.map)(ci([ic,ph,Qi],Nh),(e=>["positionalVariableBinding",...e])),lt=function(e,t,n,r,a,o){return(0,si.then)((0,si.then)((0,si.then)((0,si.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>[e,t,n,r])),a,(([e,t,n,r],a)=>o(e,t,n,r,a)))}((0,si.preceded)(Qi,(0,si.cut)(Nh)),(0,si.cut)((0,si.preceded)(hh,(0,si.optional)(Q))),(0,si.cut)((0,si.preceded)(hh,(0,si.optional)(st))),(0,si.cut)((0,si.preceded)(hh,(0,si.optional)(it))),(0,si.cut)((0,si.preceded)(li(lc,hh),i)),((e,t,n,r,a)=>["forClauseItem",["typedVariableBinding",["varName",...e,...t?[t]:[]]],...n?[["allowingEmpty"]]:[],...r?[r]:[],["forExpr",a]])),ct=ci([cc,ph],n(lt,hl,((e,t)=>["forClause",e,...t.map((e=>e[1]))]))),ut=ui((0,si.preceded)(Qi,Nh),(0,si.preceded)(hh,(0,si.optional)(Q)),(0,si.preceded)(li(Xi,hh),i),((e,t,n)=>["letClauseItem",["typedVariableBinding",["varName",...e],...t?[t]:[]],["letExpr",n]])),ht=(0,si.map)(ci([uc,hh],n(ut,hl,((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>["letClause",...e])),pt=(0,si.or)([ct,ht]),dt=(0,si.map)(ci([hc,Ih,hh],i),(e=>["whereClause",e])),mt=(0,si.map)((0,si.preceded)(Qi,Nh),(e=>["varName",...e])),ft=(0,si.then)((0,si.preceded)(hh,(0,si.optional)(Q)),(0,si.preceded)(li(Xi,hh),i),((e,t)=>["groupVarInitialize",...e?[["typeDeclaration",...e]]:[],["varValue",t]])),gt=ui(mt,(0,si.optional)(ft),(0,si.optional)((0,si.map)((0,si.preceded)(li(pc,hh),h),(e=>["collation",e]))),((e,t,n)=>["groupingSpec",e,...t?[t]:[],...n?[n]:[]])),yt=n(gt,hl,((e,t)=>[e,...t.map((e=>e[1]))])),wt=(0,si.map)(ci([dc,ph,mc,hh],yt),(e=>["groupByClause",...e])),vt=ui((0,si.optional)((0,si.or)([Eu,Nu])),(0,si.optional)(ci([hh,sc,hh],(0,si.or)([Uc,Gc].map((e=>(0,si.map)(e,(e=>"empty "+e))))))),(0,si.preceded)(hh,(0,si.optional)(ci([pc,hh],h))),((e,t,n)=>e||t||n?["orderModifier",...e?[["orderingKind",e]]:[],...t?[["emptyOrderingMode",t]]:[],...n?[["collation",n]]:[]]:null)),xt=(0,si.then)(i,(0,si.preceded)(hh,vt),((e,t)=>["orderBySpec",["orderByExpr",e],...t?[t]:[]])),bt=n(xt,hl,((e,t)=>[e,...t.map((e=>e[1]))])),At=(0,si.then)((0,si.or)([(0,si.map)(ci([fc,ph],mc),(()=>!1)),(0,si.map)(ci([gc,ph,fc,ph],mc),(()=>!0))]),(0,si.preceded)(hh,bt),((e,t)=>["orderByClause",...e?[["stable"]]:[],...t])),Et=(0,si.or)([pt,dt,wt,At]),Nt=(0,si.map)(ci([yc,hh],i),(e=>["returnClause",e])),Tt=ui(pt,(0,si.cut)((0,si.star)((0,si.preceded)(hh,Et))),(0,si.cut)((0,si.preceded)(hh,Nt)),((e,t,n)=>["flworExpr",e,...t,n])),Bt=n(G,nl,((e,t)=>0===t.length?["sequenceType",...e]:["sequenceTypeUnion",["sequenceType",...e],...t.map((e=>["sequenceType",...e[1]]))])),It=ui(ci([Hc,hh],(0,si.optional)((0,si.preceded)(Qi,(0,si.followed)((0,si.followed)(Nh,ph),Al)))),(0,si.preceded)(hh,Bt),ci([ph,yc,ph],i),((e,t,n)=>["typeswitchExprCaseClause"].concat(e?[["variableBinding",...e]]:[],[t],[["resultExpr",n]]))),Ct=hi((0,si.preceded)(Pc,li((0,si.delimited)(xi,li(l,hh),bi),hh)),(0,si.plus)((0,si.followed)(It,hh)),ci([Sc,ph],(0,si.optional)((0,si.preceded)(Qi,(0,si.followed)(Nh,ph)))),ci([yc,ph],i),((e,t,n,r)=>["typeswitchExpr",["argExpr",e],...t,["typeswitchExprDefaultClause",...n||[],["resultExpr",r]]])),St=ui((0,si.preceded)(Qi,Nh),(0,si.optional)((0,si.preceded)(ph,Q)),(0,si.preceded)(li(lc,ph),i),((e,t,n)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...e],...t?[t]:[]],["sourceExpr",n]])),Ot=n(St,hl,((e,t)=>[e,...t.map((e=>e[1]))])),Ft=ui((0,si.or)([_c,jc]),(0,si.preceded)(ph,Ot),(0,si.preceded)(li(Xc,hh),i),((e,t,n)=>["quantifiedExpr",["quantifier",e],...t,["predicateExpr",n]])),Dt=(0,si.map)(ci([Ol,ph,(0,si.or)([Sl,Cl]),ph],i),(e=>["deleteExpr",["targetExpr",e]])),kt=ui(ci([qc,ph],(0,si.optional)(ci([Fl,ph,Il],ph))),ci([Cl,ph],i),(0,si.preceded)(li(Vc,ph),i),((e,t,n)=>e?["replaceExpr",["replaceValue"],["targetExpr",t],["replacementExpr",n]]:["replaceExpr",["targetExpr",t],["replacementExpr",n]])),Rt=(0,si.then)(Bh,(0,si.preceded)(li(Xi,hh),i),((e,t)=>["transformCopy",e,["copySource",t]])),Mt=ui(ci([Yc,ph],n(Rt,hl,((e,t)=>[e,...t.map((e=>e[1]))]))),ci([hh,zc,ph],i),(0,si.preceded)(li(yc,ph),i),((e,t,n)=>["transformExpr",["transformCopies",...e],["modifyExpr",t],["returnExpr",n]])),Ut=(0,si.or)([(0,si.followed)((0,si.map)((0,si.optional)((0,si.followed)(ci([Al,ph],(0,si.or)([(0,si.map)(Jc,(()=>["insertAsFirst"])),(0,si.map)(Qc,(()=>["insertAsLast"]))])),ph)),(e=>e?["insertInto",e]:["insertInto"])),Zc),(0,si.map)(Wc,(()=>["insertAfter"])),(0,si.map)(Kc,(()=>["insertBefore"]))]),Gt=ui(ci([eu,ph,(0,si.or)([Sl,Cl]),ph],i),(0,si.preceded)(ph,Ut),(0,si.preceded)(ph,i),((e,t,n)=>["insertExpr",["sourceExpr",e],t,["targetExpr",n]])),Lt=(0,si.then)(ci([tu,ph,Cl,hh],i),ci([ph,Al,ph],i),((e,t)=>["renameExpr",["targetExpr",e],["newNameExpr",t]])),$t=(0,si.then)((0,si.plus)((0,si.map)(ci([Hc,ph],i),(e=>["switchCaseExpr",e]))),ci([ph,yc,ph],i),((e,t)=>["switchExprCaseClause",...e,["resultExpr",t]])),Ht=ui(ci([nu,hh,xi],l),ci([hh,bi,hh],(0,si.plus)((0,si.followed)($t,hh))),ci([Sc,ph,yc,ph],i),((e,t,n)=>["switchExpr",["argExpr",e],...t,["switchExprDefaultClause",["resultExpr",n]]])),Pt=(0,si.map)(l,(e=>["queryBody",e])),_t=ci([Cc,ph,xc,ph],(0,si.cut)((0,si.then)(fh,(0,si.preceded)(li(el,hh),h),((e,t)=>["namespaceDecl",["prefix",e],["uri",t]])))),jt=(0,si.then)(ci([ru,ph,Qi,hh],(0,si.then)(Nh,(0,si.optional)((0,si.preceded)(hh,Q)),((e,t)=>[e,t]))),(0,si.cut)((0,si.or)([(0,si.map)(ci([hh,Xi,hh],i),(e=>["varValue",e])),(0,si.map)(ci([ph,au],(0,si.optional)(ci([hh,Xi,hh],i))),(e=>["external",...e?[["varValue",e]]:[]]))])),(([e,t],n)=>["varDecl",["varName",...e],...null!==t?[t]:[],n])),Xt=hi(ci([Dl,ph,(0,si.peek)((0,si.not)(Xh,["Cannot use reserved function name"]))],Nh),(0,si.cut)(ci([hh,xi,hh],(0,si.optional)(W))),(0,si.cut)(ci([hh,bi],(0,si.optional)(ci([ph,Al,ph],G)))),(0,si.cut)((0,si.preceded)(hh,(0,si.or)([(0,si.map)(U,(e=>["functionBody",e])),(0,si.map)(au,(()=>["externalDefinition"]))]))),((e,t,n,r)=>["functionDecl",["functionName",...e],["paramList",...t||[]],...n?[["typeDeclaration",...n]]:[],r])),qt=ci([Cc,ph],(0,si.then)((0,si.star)((0,si.followed)((0,si.or)([L,lp]),ph)),(0,si.or)([jt,Xt]),((e,t)=>[t[0],...e,...t.slice(1)]))),Vt=(0,si.then)(ci([Cc,ph,Sc,ph],(0,si.or)([Rl,Dl])),ci([ph,xc,ph],h),((e,t)=>["defaultNamespaceDecl",["defaultNamespaceCategory",e],["uri",t]])),Yt=(0,si.or)([(0,si.map)((0,si.followed)(ci([xc,ph],fh),(0,si.preceded)(hh,el)),(e=>["namespacePrefix",e])),(0,si.map)(ci([Sc,ph,Rl,ph],xc),(()=>["defaultElementNamespace"]))]),zt=ci([su,ph,iu],ui((0,si.optional)((0,si.preceded)(ph,Yt)),(0,si.preceded)(hh,h),(0,si.optional)((0,si.then)(ci([ph,ic,ph],h),(0,si.star)(ci([hh,hl,hh],h)),((e,t)=>[e,...t]))),((e,t,n)=>["schemaImport",...e?[e]:[],["targetNamespace",t],...n?[n]:[]]))),Jt=ci([su,ph,lu],ui((0,si.optional)((0,si.followed)(ci([ph,xc,ph],fh),(0,si.preceded)(hh,el))),(0,si.preceded)(hh,h),(0,si.optional)((0,si.then)(ci([ph,ic,ph],h),(0,si.star)(ci([hh,hl,hh],h)),((e,t)=>[e,...t]))),((e,t)=>["moduleImport",["namespacePrefix",e],["targetNamespace",t]]))),Qt=(0,si.or)([zt,Jt]),Kt=(0,si.map)(ci([Cc,ph,Sc,ph,pc,ph],h),(e=>["defaultCollationDecl",e])),Wt=(0,si.map)(ci([Cc,ph,cu,ph],h),(e=>["baseUriDecl",e])),Zt=(0,si.then)(ci([Cc,ph],(0,si.or)([(0,si.map)(ci([$c,ph],Nh),(e=>["decimalFormatName",...e])),(0,si.map)(ci([Sc,ph],$c),(()=>null))])),(0,si.star)((0,si.then)((0,si.preceded)(ph,hp),(0,si.preceded)(li(el,ph),h),((e,t)=>["decimalFormatParam",["decimalFormatParamName",e],["decimalFormatParamValue",t]]))),((e,t)=>["decimalFormatDecl",...e?[e]:[],...t])),en=(0,si.or)([pp,Kt,Wt,dp,mp,fp,gp,Zt]),tn=(0,si.then)(ci([Cc,ph,mu,ph],Nh),(0,si.preceded)(ph,h),((e,t)=>["optionDecl",["optionName",e],["optionContents",t]])),nn=(0,si.then)(ci([Cc,ph,fu,ph,gu],(0,si.optional)(ci([ph,Al],J))),(0,si.or)([(0,si.map)((0,si.preceded)(li(Xi,hh),i),(e=>["varValue",e])),(0,si.map)(ci([ph,au],(0,si.optional)((0,si.preceded)(li(Xi,hh),i))),(()=>["external"]))]),((e,t)=>["contextItemDecl",...e?[["contextItemType",e]]:[],t])),rn=(0,si.then)((0,si.star)((0,si.followed)((0,si.or)([Vt,en,_t,Qt]),(0,si.cut)(li(Yi,hh)))),(0,si.star)((0,si.followed)((0,si.or)([nn,qt,tn]),(0,si.cut)(li(Yi,hh)))),((e,t)=>0===e.length&&0===t.length?null:["prolog",...e,...t])),an=ci([lu,ph,xc,ph],(0,si.then)((0,si.followed)(fh,li(el,hh)),(0,si.followed)(h,li(Yi,hh)),((e,t)=>["moduleDecl",["prefix",e],["uri",t]]))),on=(0,si.then)(an,(0,si.preceded)(hh,rn),((e,t)=>["libraryModule",e,...t?[t]:[]])),sn=(0,si.then)(rn,(0,si.preceded)(hh,Pt),((e,t)=>["mainModule",...e?[e]:[],t])),ln=(0,si.map)(ci([yu,hh],(0,si.followed)((0,si.or)([(0,si.then)((0,si.preceded)(vu,ph),h,(e=>["encoding",e])),(0,si.then)(ci([wu,ph],h),(0,si.optional)(ci([ph,vu,ph],h)),((e,t)=>[["version",e],...t?[["encoding",t]]:[]]))]),(0,si.preceded)(hh,Yi))),(e=>["versionDecl",...e])),cn=(0,si.then)((0,si.optional)(li(ln,hh)),(0,si.or)([on,sn]),((e,t)=>["module",...e?[e]:[],t])),un=(0,si.complete)(li(cn,hh));return(e,t)=>{c.clear(),t=un(e,t);let n=1,r=1;for(let t=0;t<e.length+1;t++){if(c.has(t)){var a=c.get(t);a.line=r,a.ha=n}"\r"===(a=e[t])||"\n"===a?(r++,n=1):n++}return t}}const Bp=Tp({lb:!1,Ya:!1}),Ip=Tp({lb:!0,Ya:!1}),Cp=Tp({lb:!1,Ya:!0}),Sp=Tp({lb:!0,Ya:!0});function Op(e,t){var n=!!t.Z;if(t=!!t.debug,ah.clear(),oh.clear(),Np.clear(),!0===(n=n?t?Sp(e,0):Cp(e,0):t?Ip(e,0):Bp(e,0)).success)return n.value;throw t=(e=e.substring(0,n.offset).split("\n"))[e.length-1].length+1,new to({start:{offset:n.offset,line:e.length,ha:t},end:{offset:n.offset+1,line:e.length,ha:t+1}},"",Error(`XPST0003: Failed to parse script. Expected ${[...new Set(n.expected)]}`))}const Fp="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 Dp(e,t,n,r){const a=[],o=[];sa(e,"*").forEach((e=>{switch(e[0]){case"moduleImport":case"namespaceDecl":case"defaultNamespaceDecl":case"functionDecl":case"varDecl":break;default:throw Error("Not implemented: only module imports, namespace declarations, and function declarations are implemented in XQuery modules")}}));const s=new Set;sa(e,"moduleImport").forEach((e=>{const n=ra(na(e,"namespacePrefix"));if(e=ra(na(e,"targetNamespace")),s.has(e))throw Error(`XQST0047: The namespace "${e}" is imported more than once.`);s.add(e),Kr(t,n,e)})),sa(e,"namespaceDecl").forEach((e=>{const n=ra(na(e,"prefix"));if(e=ra(na(e,"uri")),"xml"===n||"xmlns"===n)throw jr();if("http://www.w3.org/XML/1998/namespace"===e||"http://www.w3.org/2000/xmlns/"===e)throw jr();Kr(t,n,e)}));let i=null,l=null;for(const t of sa(e,"defaultNamespaceDecl")){const e=ra(na(t,"defaultNamespaceCategory")),n=ra(na(t,"uri"));if(!n)throw Pr();if("http://www.w3.org/XML/1998/namespace"===n||"http://www.w3.org/2000/xmlns/"===n)throw jr();if("function"===e){if(i)throw _r();i=n}else if("element"===e){if(l)throw _r();l=n}}i&&(t.v=i),l&&Kr(t,"",l),sa(e,"functionDecl").forEach((e=>{!function(e,t,n,r,a){var o=na(e,"functionName"),s=aa(o,"prefix")||"";let i=aa(o,"URI");const l=ra(o);if(null===i&&(i=""===s?null===t.v?"http://www.w3.org/2005/xpath-functions":t.v:t.$(s),!i&&s))throw qr(s);if(Fp.includes(i))throw $r();if(s=sa(e,"annotation").map((e=>na(e,"annotationName"))),o=s.every((e=>!aa(e,"URI")&&"private"!==ra(e))),s=s.some((e=>!aa(e,"URI")&&"updating"===ra(e))),!i)throw Pr();const c=la(e),u=sa(na(e,"paramList"),"param"),h=u.map((e=>na(e,"varName"))),p=u.map((e=>la(e)));if(e=na(e,"functionBody")){if(t.ta(i,l,p.length))throw Hr(i,l);if(!a)return;const u=Qs(e[1],{qa:!1,Z:!0}),d=new ta(t),m=h.map((e=>{let n=aa(e,"URI");const r=aa(e,"prefix");return e=ra(e),r&&null===n&&(n=t.$(r||"")),Wr(d,n,e)}));a=s?{j:p,arity:h.length,callFunction:(e,t,n,...r)=>(e=Ye(_e(e,-1,null,L.empty()),m.reduce(((e,t,n)=>(e[t]=$(r[n]),e)),Object.create(null))),u.s(e,t)),ub:!1,J:!0,bb:o,localName:l,namespaceURI:i,i:c}:{j:p,arity:h.length,callFunction:(e,t,n,...r)=>(e=Ye(_e(e,-1,null,L.empty()),m.reduce(((e,t,n)=>(e[t]=$(r[n]),e)),Object.create(null))),Un(u,e,t)),ub:!1,J:!1,bb:o,localName:l,namespaceURI:i,i:c},n.push({ba:u,Cb:d}),r.push({arity:h.length,ba:u,yb:a,localName:l,namespaceURI:i,bb:o})}else{if(s)throw Error("Updating external function declarations are not supported");a={j:p,arity:h.length,callFunction:(e,t,n,...r)=>{const a=n.ta(i,l,h.length,!0);if(!a)throw Error(`XPST0017: Function Q{${i}}${l} with arity of ${h.length} not registered. ${Dr(l)}`);if(a.i.type!==c.type||a.j.some(((e,t)=>e.type!==p[t].type)))throw Error("External function declaration types do not match actual function");return a.callFunction(e,t,n,...r)},ub:!0,J:!1,localName:l,namespaceURI:i,bb:o,i:c}}Qr(t,i,l,h.length,a)}(e,t,a,o,n)}));const c=[];return sa(e,"varDecl").forEach((e=>{const r=ia(na(e,"varName"));let o=r.namespaceURI;if(null===o&&(o=t.$(r.prefix),!o&&r.prefix))throw qr(r.prefix);if(Fp.includes(o))throw $r();var s=na(e,"external");let i,l;if(e=na(e,"varValue"),null!==s?null!==(s=na(s,"varValue"))&&(i=na(s,"*")):null!==e&&(i=na(e,"*")),c.some((e=>e.namespaceURI===o&&e.localName===r.localName)))throw Error(`XQST0049: The variable ${o?`Q{${o}}`:""}${r.localName} has already been declared.`);if(Wr(t,o||"",r.localName),n&&(i&&(l=Qs(i,{qa:!1,Z:!0})),i&&!function(e,t,n){return(e=e.Da[Vr(t,n)])?e:null}(t,o||"",r.localName))){let e=null;Zr(t,o,r.localName,((t,n)=>(e||(e=$(Un(l,t,n))),e()))),a.push({ba:l,Cb:new ta(t)}),c.push({ba:l,localName:r.localName,namespaceURI:o})}})),o.forEach((e=>{if(!e.yb.J&&e.ba.J)throw Tn(`The function Q{${e.namespaceURI}}${e.localName} is updating but the %updating annotation is missing.`)})),{Ha:o.map((e=>e.yb)),Ta:c,source:r,oa:e=>{s.forEach((e=>{ri(t,e)})),a.forEach((({ba:t,Cb:n})=>{s.forEach((e=>{ri(n,e)})),e.Ha.forEach((e=>{n.ta(e.namespaceURI,e.localName,e.arity,!0)||e.bb&&Qr(n,e.namespaceURI,e.localName,e.arity,e)})),e.Ta.forEach((e=>{n.cb(e.namespaceURI,e.localName)||Wr(n,e.namespaceURI,e.localName)})),t.v(n)}))}}}function kp(e,t,n,r,a,o,s){const i=t.Z?"XQuery":"XPath";return n=t.Ga?null:function(e,t,n,r,a,o,s,i){return(e=Ks.get(e))&&(t=e[t+(o?"_DEBUG":"")])&&(t=t.find((e=>e.o===s&&e.v.every((e=>n(e.prefix)===e.namespaceURI))&&e.D.every((e=>void 0!==r[e.name]))&&e.jb.every((e=>a[e.prefix]===e.namespaceURI))&&e.l.every((e=>{const t=i(e.ac,e.arity);return t&&t.namespaceURI===e.Bb.namespaceURI&&t.localName===e.Bb.localName})))))?{ba:t.h,ec:!1}:null}(e,i,n,r,a,t.debug,o,s),null!==n?{state:n.ec?1:2,ba:n.ba}:{state:0,Wb:"string"==typeof e?Op(e,t):ei(e)}}function Rp(e,t,n,r,a,o,s){const i=new Ur(n,r,o,s),l=new ta(i);switch(0<Object.keys(a).length&&ai(),Object.keys(a).forEach((e=>{const t=a[e];ri(l,t),Kr(l,e,t)})),"string"==typeof e&&(e=oi(e)),(n=kp(e,t,n,r,a,o,s)).state){case 2:return{ga:l,ba:n.ba};case 1:return n.ba.v(l),Zs(e,t.Z?"XQuery":"XPath",i,a,n.ba,t.debug,o),{ga:l,ba:n.ba};case 0:return n=function(e,t,n,r){const a=na(e,"mainModule");if(!a)throw Error("Can not execute a library module.");const o=na(a,"prolog");if(o){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");ai(),(r=Dp(o,n,!0,r)).oa(r)}return Ea(e,new ka(n)),qs(e=oa(a,["queryBody","*"]),t)}(n.Wb,t,l,e),n.v(l),t.Ga||Zs(e,t.Z?"XQuery":"XPath",i,a,n,t.debug,o),{ga:l,ba:n}}}function Mp(e,t,n,r){e=e.first();const a=t.first().h.reduce(((e,t)=>(e[t.key.value]=$(t.value()),e)),Object.create(null));t=a["."]?a["."]():L.empty(),delete a["."];try{const{ba:o,ga:s}=Rp(function(e){if(T(e.type,1))return e.value;if(T(e.type,54))return e.value.node;throw Ze(`Unable to convert selector argument of type ${C[e.type]} to either an ${C[1]} or an ${C[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`)}(e),{qa:!1,Z:!0,debug:r.debug,Ga:r.Ga},(e=>n.$(e)),Object.keys(a).reduce(((e,t)=>(e[t]=t,e)),{}),{},"http://www.w3.org/2005/xpath-functions",((e,t)=>n.Sa(e,t))),i=!t.G(),l=new ze({N:i?t.first():null,Fa:i?0:-1,za:t,wa:Object.keys(a).reduce(((e,t)=>(e[s.cb(null,t)]=a[t],e)),Object.create(null))});return{fc:o.h(l,r).value,cc:e}}catch(t){Sr(e.value,t)}}function Up(e,t,n){if(1!==t.node.nodeType&&9!==t.node.nodeType)return[];const r=W(e,t).reduce(((t,r)=>{for(const a of Up(e,r,n))t.push(a);return t}),[]);return n(t)&&r.unshift(t),r}const Gp=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use id function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use id function.");const o=t.h,s=r.O().reduce(((e,t)=>(t.value.split(/\s+/).forEach((t=>{e[t]=!0})),e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the target node is not a document node.");return t=Up(o,t,(e=>1===e.node.nodeType&&(!(!(e=K(o,e,"id"))||!s[e])&&(s[e]=!1,!0)))),L.create(t.map((e=>ce(e))))},Lp=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use idref function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use idref function.");const o=t.h,s=r.O().reduce(((e,t)=>(e[t.value]=!0,e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the context node is not a document node.");return t=Up(o,t,(e=>1===e.node.nodeType&&(!!(e=K(o,e,"idref"))&&e.split(/\s+/).some((e=>s[e]))))),L.create(t.map((e=>ce(e))))};function $p(e){switch(typeof e){case"object":return Array.isArray(e)?L.m(new ie(e.map((e=>$($p(e)))))):null===e?L.empty():L.m(new de(Object.keys(e).map((t=>({key:y(t,1),value:$($p(e[t]))})))));case"number":return L.m(y(e,3));case"string":return L.m(y(e,1));case"boolean":return e?L.aa():L.V();default:throw Error("Unexpected type in JSON parse")}}const Hp=(e,t,n,r,a)=>{const o=L.m(y("duplicates",1)),s=(e=pe(0,0,0,a,o)).G()?"use-first":e.first().value;return r.M((e=>L.m(new de(e.reduce(((e,t)=>(t.h.forEach((t=>{const n=e.findIndex((e=>he(e.key,t.key)));if(0<=n)switch(s){case"reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case"use-last":return void e.splice(n,1,t);case"combine":return void e.splice(n,1,{key:t.key,value:$(L.create(e[n].value().O().concat(t.value().O())))});default:return}e.push(t)})),e)),[])))))};function Pp(e,t,n){let r=1;const a=e.value;e=e.Pa(!0);let o=null;const s=Math.max(t-1,0);return-1!==e&&(o=Math.max(0,(null===n?e:Math.max(0,Math.min(e,n+(t-1))))-s)),L.create({next:e=>{for(;r<t;)a.next(e),r++;return null!==n&&r>=t+n?A:(e=a.next(e),r++,e)}},o)}function _p(e){return e.map((e=>T(e.type,19)?At(e,3):e))}function jp(e){if((e=_p(e)).some((e=>Number.isNaN(e.value))))return[y(NaN,3)];if(!(e=Lo(e)))throw Error("FORG0006: Incompatible types to be converted to a common type");return e}const Xp=(e,t,n,r,a,o)=>ue([a,o],(([e,t])=>{if(1/0===e.value)return L.empty();if(-1/0===e.value)return t&&1/0===t.value?L.empty():r;if(t){if(isNaN(t.value))return L.empty();1/0===t.value&&(t=null)}return isNaN(e.value)?L.empty():Pp(r,Math.round(e.value),t?Math.round(t.value):null)})),qp=(e,t,n,r,a)=>{if(r.G())return a;if(!(e=Lo(e=_p(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:sum are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0),e.every((e=>T(e.type,5)))?L.m(y(t,5)):e.every((e=>T(e.type,3)))?L.m(y(t,3)):e.every((e=>T(e.type,4)))?L.m(y(t,4)):L.m(y(t,6))};var Vp=[].concat(cr,[{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.fa()?L.aa():L.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>L.aa()},{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)=>!1===r.fa()?L.aa():L.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",j:[],i:{type:0,g:3},callFunction:()=>L.V()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.N)throw We("The fn:last() function depends on dynamic context, which is absent.");let t=!1;return L.create({next:()=>{if(t)return A;const n=e.za.Pa();return t=!0,E(y(n,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.N)throw We("The fn:position() function depends on dynamic context, which is absent.");return L.m(y(e.Fa+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:e=>L.m(y(Xe(e),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:e=>L.m(y(Ce(Xe(e),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:e=>L.m(y(Ce(Xe(e),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",j:[],i:{type:17,g:3},callFunction:e=>L.m(y(qe(e),17))}],hr,vr,Nr,[{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.G()?r:L.m(y(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.G()?r:L.m(y(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.G()?r:L.m(y(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.G()?r:L.m(y(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.G()?r:L.m(y(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.G()?r:L.m(y(r.first().value.getSeconds(),4))}],Br,[{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:Gp},{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)=>Gp(e,t,0,r,L.m(e.N))},{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:Lp},{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)=>Lp(e,t,0,r,L.m(e.N))}],[{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 a;try{a=JSON.parse(r.first().value)}catch(e){throw Error("FOJS0001: parsed JSON string contains illegal JSON.")}return $p(a)}}],[{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,a)=>ue([r,a],(([e,t])=>e.h.some((e=>he(e.key,t)))?L.aa():L.V()))},{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,a)=>r.map((e=>new de([{key:e,value:$(a)}])))},{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,a)=>ue([r,a],(([r,a])=>Qe(r.h.map((r=>a.value.call(void 0,e,t,n,L.m(r.key),r.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:pe},{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)=>ue([r],(([e])=>L.create(e.h.map((e=>e.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:Hp},{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)=>Hp(e,0,0,r,L.m(new de([{key:y("duplicates",1),value:()=>L.m(y("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,a,o)=>ue([r,a],(([e,t])=>{const n=(e=e.h.concat()).findIndex((e=>he(e.key,t)));return 0<=n?e.splice(n,1,{key:t,value:$(o)}):e.push({key:t,value:$(o)}),L.m(new de(e))}))},{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,a)=>ue([r],(([e])=>{const t=e.h.concat();return a.M((e=>(e.forEach((e=>{const n=t.findIndex((t=>he(t.key,e)));0<=n&&t.splice(n,1)})),L.m(new de(t)))))}))},{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((e=>y(e.h.length,5)))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>L.m(y(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((e=>y(Math.pow(Math.E,e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.pow(10,e.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((e=>y(Math.log(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.log10(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pow",j:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.M((([e])=>r.map((t=>1!==Math.abs(t.value)||Number.isFinite(e.value)?y(Math.pow(t.value,e.value),3):y(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((e=>y(Math.sqrt(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.sin(e.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((e=>y(Math.cos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.tan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.asin(e.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((e=>y(Math.acos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.atan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan2",j:[{type:3,g:0},{type:3,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.M((([e])=>r.map((t=>y(Math.atan2(t.value,e.value),3)))))}],gn,Vt,[{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,a)=>{if(e=r.first(),a=a.first(),null===e||null===a)return L.empty();let o=e.value;return a=a.value,o>a?L.empty():L.create({next:()=>E(y(o++,5))},a-o+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,a)=>ue([r,a],(([e,t])=>{if(!st(t=t.value,23))throw Error("FOCA0002: The provided QName is invalid.");if(null===(e=e&&e.value||null)&&t.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(r.G())return L.m(y(new H("",null,t),23));if(!t.includes(":"))return L.m(y(new H("",e,t),23));const[n,a]=t.split(":");return L.m(y(new H(n,e,a),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)=>ue([r],(([e])=>null===e?L.empty():(e=e.value).prefix?L.m(y(e.prefix,24)):L.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((e=>y(e.value.localName,24)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"namespace-uri-from-QName",j:[{type:23,g:0}],i:{type:20,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(e.value.namespaceURI||"",20)))}],[{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.Y({empty:()=>L.aa(),multiple:()=>L.V(),m:()=>L.V()}),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.Y({empty:()=>L.V(),multiple:()=>L.aa(),m:()=>L.aa()}),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)=>Pp(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)=>Pp(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,a,o)=>r.G()?o:o.G()?r:(e=r.O(),0>(a=a.first().value-1)?a=0:a>e.length&&(a=e.length),t=e.slice(a),L.create(e.slice(0,a).concat(o.O(),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,a)=>(e=a.first().value,!(r=r.O()).length||1>e||e>r.length||r.splice(e-1,1),L.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((e=>L.create(e.reverse()))),localName:"reverse",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3}],callFunction:(e,t,n,r,a)=>Xp(0,0,0,r,a,L.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:Xp,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)=>{const a=rt(r,t).O();return L.create(a).filter(((e,t)=>a.slice(0,t).every((t=>!vn(e,t)))))},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,a)=>a.M((([n])=>rt(r,t).map(((t,r)=>xo("eqOp",t.type,n.type)(t,n,e)?y(r+1,5):y(-1,5))).filter((e=>-1!==e.value)))),localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:46,g:2},{type:46,g:3},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(e,t,n,r,a)=>{let o=!1;const s=An(e,t,n,r,a);return L.create({next:()=>{if(o)return A;const e=s.next(0);return e.done?e:(o=!0,E(y(e.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 a=!1;return L.create({next:()=>{if(a)return A;const e=r.Pa();return a=!0,E(y(e,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.G())return r;if(!(e=Lo(e=_p(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:avg are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0)/e.length,e.every((e=>T(e.type,5)||T(e.type,3)))?L.m(y(t,3)):e.every((e=>T(e.type,4)))?L.m(y(t,4)):L.m(y(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.G()?r:(e=jp(r.O()),L.m(e.reduce(((e,t)=>e.value<t.value?t:e)))),localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},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.G()?r:(e=jp(r.O()),L.m(e.reduce(((e,t)=>e.value>t.value?t:e)))),localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>qp(e,t,0,r,L.m(y(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:qp,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.G()&&!r.sa())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.G())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.sa())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,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.filter((r=>{if(r=Gt(s[0],L.m(r),t,"fn:filter",!1),!(r=o.value.call(void 0,e,t,n,r)).sa()||!T(r.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.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,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const i=r.value;let l;return L.create({next:r=>{for(;;){if(!l){var a=i.next(0);if(a.done)return a;a=Gt(s[0],L.m(a.value),t,"fn:for-each",!1),l=o.value.call(void 0,e,t,n,a).value}if(!(a=l.next(r)).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,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return r.M((r=>r.reduce(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-left",!1),a=Gt(i[1],L.m(a),t,"fn:fold-left",!1),s.value.call(void 0,e,t,n,r,a))),a)))},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,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return r.M((r=>r.reduceRight(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-right",!1),a=Gt(i[1],L.m(a),t,"fn:fold-right",!1),s.value.call(void 0,e,t,n,a,r))),a)))},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.Ua)throw Error("serialize() called but no xmlSerializer set in execution parameters.");if(!(e=r.O()).every((e=>T(e.type,53))))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return L.m(y(e.map((e=>t.Ua.serializeToString(Ar(e.value,t,!1)))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],an,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(e,t,n,r,a)=>{let o,s;return L.create({next:()=>{o||({fc:o,cc:s}=Mp(r,a,n,t));try{return o.next(0)}catch(e){Sr(s.value,e)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{j:[],callFunction:()=>L.m(y("3.29.1",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,a)=>ue([r,a],(([e,t])=>{const r=n.ta(e.value.namespaceURI,e.value.localName,t.value);return null===r?L.empty():(e=new P({j:r.j,arity:t.value,localName:e.value.localName,namespaceURI:e.value.namespaceURI,i:r.i,value:r.callFunction}),L.m(e))})),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)=>ue([r],(([e])=>e.Xa()?L.empty():L.m(y(new H("",e.l,e.D),23)))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>ue([r],(([e])=>L.m(y(e.v,5)))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class Yp{constructor(e){this.h=e}createAttributeNS(e,t){return this.h.createAttributeNS(e,t)}createCDATASection(e){return this.h.createCDATASection(e)}createComment(e){return this.h.createComment(e)}createDocument(){return this.h.createDocument()}createElementNS(e,t){return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){return this.h.createProcessingInstruction(e,t)}createTextNode(e){return this.h.createTextNode(e)}}var zp=Symbol("IS_XPATH_VALUE_SYMBOL");function Jp(e){return e&&"object"==typeof e&&"lookupNamespaceURI"in e?t=>e.lookupNamespaceURI(t||null):()=>null}function Qp(e){return({prefix:t,localName:n})=>t?null:{namespaceURI:e,localName:n}}function Kp(e,t,n,r,a,o){null==r&&(r=r||{});const s=a?{ib:a.logger||{trace:console.log.bind(console)},Ma:a.documentWriter,jb:a.moduleImports,Ab:a.namespaceResolver,Zb:a.functionNameResolver,Ia:a.nodesFactory,Ua:a.xmlSerializer}:{ib:{trace:console.log.bind(console)},jb:{},Ab:null,Ia:null,Ma:null,Ua:null},i=new oe(null===n?new q:n);n=s.jb||Object.create(null);var l=void 0===a.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":a.defaultFunctionNamespaceURI;const c=Rp(e,o,s.Ab||Jp(t),r,n,l,s.Zb||Qp(l));e=t?He(0,t):L.empty(),t=!s.Ia&&o.Z?new $n(t):new Yp(s.Ia),n=s.Ma?new Y(s.Ma):V,l=s.Ua;const u=Object.keys(r).reduce(((e,t)=>{const n=r[t];return e[`Q{}${t}[0]`]=n&&"object"==typeof n&&zp in n?()=>L.create(n.xb):()=>He(0,r[t]),e}),Object.create(null));let h;for(const e of Object.keys(c.ga.Da))u[e]||(u[e]=()=>(0,c.ga.Da[e])(h,p));h=new ze({N:e.first(),Fa:0,za:e,wa:u});const p=new Je(o.debug,o.Ga,i,t,n,a.currentContext,new Map,s.ib,l);return{rb:h,sb:p,ba:c.ba}}function Wp(e,t){const n={};let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){const a=e.h[r].key.value;if(!o){const i=e.h[r];var s=i.value().Y({default:e=>e,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 ${i.key.value} holds multiple items`)}}).first();if(null===s){n[a]=null,r++;continue}o=ed(s,t)}s=o.next(0),o=null,n[a]=s.value,r++}return a=!0,E(n)}}}function Zp(e,t){const n=[];let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){if(!o){var s=e.h[r]().Y({default:e=>e,multiple:()=>{throw Error("Serialization error: The value of an entry in an array is expected to be a single item or an empty sequence. Use nested arrays when putting multiple values in an array.")}}).first();if(null===s){n[r++]=null;continue}o=ed(s,t)}s=o.next(0),o=null,n[r++]=s.value}return a=!0,E(n)}}}function ed(e,t){if(T(e.type,61))return Wp(e,t);if(T(e.type,62))return Zp(e,t);if(T(e.type,23)){const t=e.value;return{next:()=>E(`Q{${t.namespaceURI||""}}${t.localName}`)}}switch(e.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const n=e.value;return{next:()=>E(Se(n))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const r=e.value;return{next:()=>E(Ar(r,t,!1))};default:return{next:()=>E(e.value)}}}Vp.forEach((e=>{Rr(e.namespaceURI,e.localName,e.j,e.i,e.callFunction)}));var td={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};function nd(e,t,n,r){switch(n){case 3:return t.fa();case 2:return(t=rt(t,r).O()).length?t.map((e=>At(e,1).value)).join(" "):"";case 10:return(t=rt(t,r).O()).length?t.map((e=>e.value+"")):[];case 1:return null!==(t=t.first())&&T(t.type,2)?t.value:NaN;case 9:if(null===(t=t.first()))return null;if(!T(t.type,53))throw Error("Expected XPath "+Ir(e)+" to resolve to Node. Got "+C[t.type]);return Ar(t.value,r,!1);case 7:if(!(t=t.O()).every((e=>T(e.type,53))))throw Error("Expected XPath "+Ir(e)+" to resolve to a sequence of Nodes.");return t.map((e=>Ar(e.value,r,!1)));case 11:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Ir(e)+" to resolve to a single map.");if(!T((t=t[0]).type,61))throw Error("Expected XPath "+Ir(e)+" to resolve to a map");return Wp(t,r).next(0).value;case 12:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Ir(e)+" to resolve to a single array.");if(!T((t=t[0]).type,62))throw Error("Expected XPath "+Ir(e)+" to resolve to an array");return Zp(t,r).next(0).value;case 13:return t.O().map((t=>{if(!T(t.type,2))throw Error("Expected XPath "+Ir(e)+" to resolve to numbers");return t.value}));case 99:const n=t.value;let a=null,o=!1;const s=()=>{for(;!o;){if(!a){var e=n.next(0);if(e.done){o=!0;break}a=ed(e.value,r)}return e=a.next(0),a=null,e}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>new Promise((e=>e(s()))).catch((t=>{Sr(e,t)}))}:{next:()=>new Promise((e=>e(s())))};case 14:return t.O().map((e=>ed(e,r).next(0).value));default:return(t=t.O()).every((e=>T(e.type,53)&&!T(e.type,47)))?(t=t.map((e=>Ar(e.value,r,!1))),1===t.length?t[0]:t):1===t.length?T((t=t[0]).type,62)?Zp(t,r).next(0).value:T(t.type,61)?Wp(t,r).next(0).value:nt(t,r).first().value:rt(L.create(t),r).O().map((e=>e.value))}}td[td.ANY]="ANY",td[td.NUMBER]="NUMBER",td[td.STRING]="STRING",td[td.BOOLEAN]="BOOLEAN",td[td.NODES]="NODES",td[td.FIRST_NODE]="FIRST_NODE",td[td.STRINGS]="STRINGS",td[td.MAP]="MAP",td[td.ARRAY]="ARRAY",td[td.NUMBERS]="NUMBERS",td[td.ALL_RESULTS]="ALL_RESULTS",td[td.ASYNC_ITERATOR]="ASYNC_ITERATOR";let rd=!1,ad=null;var od={getPerformanceSummary(){const e=ad.getEntriesByType("measure").filter((e=>e.name.startsWith("XPath: ")));return Array.from(e.reduce(((e,t)=>{var n=t.name.substring(7);return e.has(n)?((n=e.get(n)).times+=1,n.totalDuration+=t.duration):e.set(n,{xpath:n,times:1,totalDuration:t.duration,average:0}),e}),new Map).values()).map((e=>(e.average=e.totalDuration/e.times,e))).sort(((e,t)=>t.totalDuration-e.totalDuration))},setPerformanceImplementation(e){ad=e},startProfiling(){if(null===ad)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");ad.clearMarks(),ad.clearMeasures(),rd=!0},stopProfiling(){rd=!1}};let sd=0;const id=(e,t,n,r,a,o)=>{if(a=a||0,!e||"string"!=typeof e&&!("nodeType"in e))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");let s,i;o=o||{};try{const a=Kp(e,t,n||null,r||{},o,{qa:"XQueryUpdate3.1"===o.language,Z:"XQuery3.1"===o.language||"XQueryUpdate3.1"===o.language,debug:!!o.debug,Ga:!!o.disableCache});var l=a.rb;s=a.sb,i=a.ba}catch(t){Sr(e,t)}if(i.J)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(3===a&&t&&"object"==typeof t&&"nodeType"in t&&(n=i.D(),t=X(t),null!==n&&!t.includes(n)))return!1;try{t=e,rd&&("string"!=typeof t&&(t=Ir(t)),ad.mark(`${t}${0===sd?"":"@"+sd}`),sd++);const n=nd(e,Un(i,l,s),a,s);return a=e,rd&&("string"!=typeof a&&(a=Ir(a)),sd--,l=`${a}${0===sd?"":"@"+sd}`,ad.measure(`XPath: ${a}`,l),ad.clearMarks(l)),n}catch(t){Sr(e,t)}};function ld(e,t,n,r,a){return id(e,t,n,r,id.Jb,a)}function cd(e,t,n,r){return{pendingUpdateList:e.da.map((e=>e.h(r))),xdmValue:nd(t,L.create(e.I),n,r)}}function ud(e,t,n){return{code:e,ra:t,H:n,isAstAccepted:!0}}function hd(e){return{isAstAccepted:!1,reason:e}}function pd(e,t){return e.isAstAccepted?t(e):e}function dd(e,t){return e.isAstAccepted?t(e):[e,null]}function md(e,t,n){return pd(e,(e=>{switch(e.ra.type){case 0:return e;case 1:return pd(zd(n,e,"nodes"),(e=>pd(zd(n,t,"contextItem"),(t=>ud(`(function () {\n\t\t\t\t\t\t\tconst { done, value } = ${e.code}(${t.code}).next();\n\t\t\t\t\t\t\treturn done ? null : value;\n\t\t\t\t\t\t})()`,{type:0},[...e.H,...t.H])))));default:throw Error(`invalid generated code type to convert to value: ${e.ra.type}`)}}))}function fd(e,t,n,r){return e=md(e,n,r),t&&0===t.type&&3===t.g?e:pd(e,(e=>ud(`!!${e.code}`,{type:0},e.H)))}function gd(e,t,n){return t?e.isAstAccepted&&0!==e.ra.type?hd("Atomization only implemented for single value"):T(t.type,1)?e:T(t.type,47)?pd(zd(n,e,"attr"),(e=>ud(`(${e.code} ? domFacade.getData(${e.code}) : null)`,{type:0},e.H))):hd("Atomization only implemented for string and attribute"):hd("Can not atomize value if type was not annotated")}function yd(e,t,n,r){return r=gd(e=md(e,n,r),t,r),lt(t)?pd(r,(e=>ud(`${e.code} ?? ''`,{type:0},e.H))):r}function wd(e,t,n){return pd(zd(n,e,"node"),(e=>1===e.ra.type?e:t&&!T(t.type,53)?hd("Can not evaluate to node if expression does not result in nodes"):ud(`(function () {\n\t\t\t\tif (${e.code} !== null && !${e.code}.nodeType) {\n\t\t\t\t\tthrow new Error('XPDY0050: The result of the expression was not a node');\n\t\t\t\t}\n\t\t\t\treturn ${e.code};\n\t\t\t})()`,{type:0},e.H)))}function vd(e,t){return pd(e,(e=>pd(t,(t=>{if(0!==e.ra.type||0!==t.ra.type)throw Error("can only use emitAnd with value expressions");return ud(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H])}))))}function xd(e,t,n,r){return(e=oa(e,[t,"*"]))?r.h(e,n,r):[hd(`${t} expression not found`),null]}Object.assign(id,{hc:14,ANY_TYPE:0,Ib:12,Jb:99,BOOLEAN_TYPE:3,Lb:9,Ob:11,Qb:7,Rb:13,NUMBER_TYPE:1,Sb:10,STRING_TYPE:2,ic:"XPath3.1",jc:"XQuery3.1",Vb:"XQueryUpdate3.1"}),Object.assign(id,{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"});const bd={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},Ad={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};function Ed(e,t,n,r){const a=aa(oa(e,["firstOperand","*"]),"type"),o=aa(oa(e,["secondOperand","*"]),"type");if(!a||!o)return hd("Can not generate code for value compare without both types");var s=[47,1];if(!s.includes(a.type)||!s.includes(o.type))return hd(`Unsupported types in compare: [${C[a.type]}, ${C[o.type]}]`);if(!(s=new Map([["eqOp","==="],["neOp","!=="]])).has(t))return hd(t+" not yet implemented");const i=s.get(t);return[t]=xd(e,"firstOperand",n,r),t=gd(t=md(t,n,r),a,r),pd(zd(r,t,"first"),(t=>{var[s]=xd(e,"secondOperand",n,r);return s=gd(s=md(s,n,r),o,r),pd(zd(r,s,"second"),(e=>{const n=[];return lt(a)&&n.push(`${t.code} === null`),lt(o)&&n.push(`${e.code} === null`),ud(`(${n.length?`${n.join(" || ")} ? null : `:""}${t.code} ${i} ${e.code})`,{type:0},[...t.H,...e.H])}))}))}function Nd(e,t,n,r,a,o){var s=aa(oa(e,[t,"*"]),"type");const i=aa(oa(e,[n,"*"]),"type");if(!s||!i)return hd("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(s.type)||!l.includes(i.type))return hd(`Unsupported types in compare: [${C[s.type]}, ${C[i.type]}]`);if(!(l=new Map([["eqOp","==="],["neOp","!=="]])).has(r))return hd(r+" not yet implemented");const c=l.get(r);return[t]=xd(e,t,a,o),s=gd(t=md(t,a,o),s,o),pd(zd(o,s,"single"),(t=>{const[r]=xd(e,n,a,o);return pd(zd(o,r,"multiple"),(e=>{if(1!==e.ra.type)return hd("can only generate general compare for a single value and a generator");const n=Qd(o,Jd(o,"n")),r=gd(n,i,o);return pd(a,(a=>pd(r,(r=>ud(`(function () {\n\t\t\t\t\t\t\t\t\tfor (const ${n.code} of ${e.code}(${a.code})) {\n\t\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t\tif (${r.code} ${c} ${t.code}) {\n\t\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t})()`,{type:0},[...t.H,...n.H,...a.H,...e.H])))))}))}))}function Td(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}const Bd={"false#0":function(){return ud("false",{type:0},[])},"local-name#0":Dd,"local-name#1":Dd,"name#0":Fd,"name#1":Fd,"not#1":function(e,t,n){var r=oa(e,["arguments","*"]);return e=aa(r,"type"),[r]=n.h(r,t,n),pd(t=fd(r,e,t,n),(e=>ud(`!${e.code}`,{type:0},e.H)))},"true#0":function(){return ud("true",{type:0},[])}},Id={"http://fontoxml.com/fontoxpath":["version#0"],"":["root#1","path#1"]};function Cd(e,t,n,r){if(e.length!==t.length||t.some((e=>4===e)))return hd("Not supported: variadic function or mismatch in argument count");if(0===e.length)return ud("",{type:0},[]);const[a,...o]=e,[s,...i]=t;return e=zd(r,function(e,t,n,r){const[a]=r.h(e,n,r);if(e=aa(e,"type"),!t||2===t.g||1===t.g)return hd("Not supported: sequence arguments with multiple items");if(T(t.type,53))return wd(t=md(a,n,r),e,r);switch(t.type){case 59:return md(a,n,r);case 0:return fd(a,e,n,r);case 1:return yd(a,e,n,r)}return hd(`Argument types not supported: ${e?C[e.type]:"unknown"} -> ${C[t.type]}`)}(a,s,n,r),"arg"),0===o.length?e:pd(e,(e=>pd(Cd(o,i,n,r),(t=>ud(`${e.code}, ${t.code}`,{type:0},[...e.H,...t.H])))))}function Sd(e,t,n){const{localName:r,namespaceURI:a}=ia(na(e,"functionName")),o=sa(na(e,"arguments"),"*");var s=o.length;const i=`${r}#${s}`,l=a===n.D;if(l){const r=Bd[i];if(void 0!==r)return r(e,t,n)}return(e=Id[l?"":a])&&!e.includes(i)?hd(`Not supported: built-in function not on allow list: ${i}`):(s=kr(a,r,s))?s.J?hd("Not supported: updating functions"):(t=pd(t=Cd(o,s.j,t,n),(e=>ud(`runtimeLib.callFunction(domFacade, ${Td(a)}, ${Td(r)}, [${e.code}], options)`,{type:0},e.H))),function(e,t){return pd(e,(e=>t&&2!==t.g&&1!==t.g&&([0,1].includes(t.type)||T(t.type,53))?e:hd(`Function return type ${C[t.type]} not supported`)))}(t,s.i)):hd(`Unknown function / arity: ${i}`)}function Od(e,t,n,r){if((e=oa(e,["arguments","*"]))&&"contextItemExpr"!==e[0]){const r=aa(e,"type");if(!r||!T(r.type,53))return hd("name function only implemented if arg is a node");[e]=n.h(e,t,n)}else e=function(e,t){return pd(zd(t,e,"contextItem"),(e=>ud(e.code,{type:0},[...e.H,`if (${e.code} === undefined || ${e.code} === null) {\n\t\t\t\t\tthrow errXPDY0002('The function which was called depends on dynamic context, which is absent.');\n\t\t\t\t}`])))}(t,n);return pd(zd(n,t=md(e,t,n),"arg"),(e=>ud(`(${e.code} ? ${r(e.code)} : '')`,{type:0},e.H)))}function Fd(e,t,n){return Od(e,t,n,(e=>`(((${e}.prefix || '').length !== 0 ? ${e}.prefix + ':' : '')\n\t\t+ (${e}.localName || ${e}.target || ''))`))}function Dd(e,t,n){return Od(e,t,n,(e=>`(${e}.localName || ${e}.target || '')`))}function kd(e,t,n,r){const[a,o]=xd(e,"firstOperand",n,r);var s=aa(oa(e,["firstOperand","*"]),"type");s=fd(a,s,n,r);const[i,l]=xd(e,"secondOperand",n,r);s=pd(s,(a=>{var o=aa(oa(e,["secondOperand","*"]),"type");return pd(o=fd(i,o,n,r),(e=>ud(`(${a.code} ${t} ${e.code})`,{type:0},[...a.H,...e.H])))}));return[s,"&&"===t?$a(o,l):o===l?o:null]}function Rd(e,t,n){return pd(e,(e=>pd(t,(t=>pd(n,(n=>ud(`for (${e.code}) {\n\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\tif (!(${t.code})) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\t${n.code}\n\t\t\t\t\t}`,{type:2},e.H)))))))}function Md(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=pd(r,(e=>pd(a,(t=>ud(`let ${e.code} = domFacade.getFirstChild(${t.code}${o});\n\t\t\t\t\t\t\t${e.code};\n\t\t\t\t\t\t\t${e.code} = domFacade.getNextSibling(${e.code}${o})`,{type:2},[...e.H,...t.H]))))),Rd(t,e,n)}function Ud(e,t,n,r,a){const o=$a(t,"type-2"),s=pd(a,(e=>ud(`(${e.code} && ${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? domFacade.getAllAttributes(${e.code}${o?`, "${o}"`:""}) : [])`,{type:0},e.H)));return t=pd(r,(e=>pd(s,(t=>ud(`const ${e.code} of ${t.code}`,{type:2},[...e.H,...t.H]))))),Rd(t,e,n)}function Gd(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=pd(a,(e=>ud(`domFacade.getParentNode(${e.code}${o})`,{type:0},e.H))),Ld(r,t,e,n)}function Ld(e,t,n,r){const a=vd(e,n);return pd(e,(e=>pd(t,(t=>pd(a,(n=>pd(r,(r=>ud(`const ${e.code} = ${t.code};\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\tif (${n.code}) {\n\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t}`,{type:2},[...e.H,...t.H])))))))))}const $d={Tb:"textTest",Kb:"elementTest",Pb:"nameTest",Ub:"Wildcard",Hb:"anyKindTest"};var Hd=Object.values($d);function Pd(e,t,n,r){!function(e,t){if(null===e.namespaceURI&&"*"!==e.prefix){if(!(t=t.$(e.prefix||"")||null)&&e.prefix)throw Error(`XPST0081: The prefix ${e.prefix} could not be resolved.`);e.namespaceURI=t}}(e,r);const a=e.prefix,o=e.namespaceURI,s=e.localName;return dd(n,(e=>{var n=ud(t?`${e.code}.nodeType\n\t\t\t\t\t\t&& (${e.code}.nodeType === /*ELEMENT_NODE*/ 1\n\t\t\t\t\t\t|| ${e.code}.nodeType === /*ATTRIBUTE_NODE*/ 2)`:`${e.code}.nodeType\n\t\t\t\t\t\t&& ${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]);if("*"===a)return"*"===s?[n,t?"type-1-or-type-2":"type-1"]:[vd(n,ud(`${e.code}.localName === ${Td(s)}`,{type:0},[])),`name-${s}`];n="*"===s?n:vd(n,ud(`${e.code}.localName === ${Td(s)}`,{type:0},[]));var r=ud(Td(o),{type:0},[]);return r=""===a&&t?pd(r,(t=>ud(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? ${t.code} : null`,{type:0},t.H))):r,r=pd(r,(t=>ud(`(${e.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.H))),[vd(n,r),`name-${s}`]}))}function _d(e,t,n,r){var a=e[0];switch(a){case $d.Kb:return function(e,t,n){const r=(e=na(e,"elementName"))&&na(e,"star");return null===e||r?[pd(t,(e=>ud(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]))),"type-1"]:Pd(e=ia(na(e,"QName")),!1,t,n)}(e,n,r);case $d.Tb:return function(e){return[pd(e,(e=>ud(`${e.code}.nodeType === /*TEXT_NODE*/ 3`,{type:0},[]))),"type-3"]}(n);case $d.Pb:return Pd(ia(e),t,n,r);case $d.Ub:return na(e,"star")?null!==(a=na(e,"uri"))?e=Pd({localName:"*",namespaceURI:ra(a),prefix:""},t,n,r):(a=na(e,"NCName"),e="star"===na(e,"*")[0]?Pd({localName:ra(a),namespaceURI:null,prefix:"*"},t,n,r):Pd({localName:"*",namespaceURI:null,prefix:ra(a)},t,n,r)):e=Pd({localName:"*",namespaceURI:null,prefix:"*"},t,n,r),e;case $d.Hb:return function(e){return[pd(e,(e=>ud(`!!${e.code}.nodeType`,{type:0},[]))),null]}(n);default:return[hd(`Test not implemented: '${a}`),null]}}function jd(e,t,n){const[r,a]=n.h(e,t,n);return[fd(r,aa(e,"type"),t,n),a]}function Xd(e,t,n){e=e?sa(e,"*"):[];const[r,a]=e.reduce((([e,r],a)=>{if(!e)return jd(a,t,n);let o=r;return dd(e,(e=>{const[s,i]=jd(a,t,n);return o=$a(r,i),[pd(s,(t=>ud(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H]))),o]}))}),[null,null]);return[r?pd(r,(e=>ud(`(function () {\n\t\t\t\t\t\t\t${e.H.join("\n")}\n\t\t\t\t\t\t\treturn ${e.code};\n\t\t\t\t\t\t})()`,{type:0},[]))):null,a]}function qd(e,t,n,r){if(0===e.length)return[pd(n,(e=>ud(`yield ${e.code};`,{type:2},e.H))),null];const[a,...o]=e;if(0<sa(a,"lookup").length)return[hd("Unsupported: lookups"),null];const s=Qd(r,Jd(r,"contextItem"));e=na(a,"predicates");const[i,l]=Xd(e,s,r);if(e=na(a,"xpathAxis")){var c=na(a,Hd);if(!c)return[hd("Unsupported test in step"),null];var u=ra(e);t="attribute"===u||"self"===u&&t;const[h,p]=_d(c,t,s,r);return c=null===i?h:vd(h,i),u=$a(p,l),[t]=qd(o,t,s,r),function(e,t,n,r,a,o){switch(e=ra(e)){case"attribute":return[Ud(t,n,r,a,o),"type-1"];case"child":return[Md(t,n,r,a,o),null];case"parent":return[Gd(t,n,r,a,o),null];case"self":return[Ld(a,o,t,r),n];default:return[hd(`Unsupported: the ${e} axis`),null]}}(e,c,u,t,s,n)}if(!(e=oa(a,["filterExpr","*"])))return[hd("Unsupported: unknown step type"),null];const[h,p]=r.h(e,n,r);return[pd(h,(e=>{const t=0===o.length?ud("",{type:2},[]):ud(`if (${s.code} !== null && !${s.code}.nodeType) {\n\t\t\t\t\t\t\t\t\tthrow new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');\n\t\t\t\t\t\t\t\t}`,{type:2},[]),[a]=qd(o,!0,s,r),l=null===i?a:pd(i,(e=>pd(a,(t=>ud(`if (${e.code}) {\n\t\t\t\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\t\t}`,{type:2},e.H)))));return pd(l,(r=>{switch(e.ra.type){case 1:return pd(n,(n=>ud(`for (const ${s.code} of ${e.code}(${n.code})) {\n\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H])));case 0:return ud(`const ${s.code} = ${e.code};\n\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\tif (${s.code} !== null) {\n\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H]);default:return hd("Unsupported generated code type for filterExpr")}}))})),p]}function Vd(e,t,n){const r=sa(e,"stepExpr");if(1===r.length){const e=na(r[0],"xpathAxis");if(e&&"self"===ra(e))return function(e,t,n){return dd(t,(t=>{if(0<sa(e,"lookup").length)return[hd("Unsupported: lookups"),null];var r=na(e,"predicates");const[a,o]=Xd(r,t,n);if(!(r=na(e,Hd)))return[hd("Unsupported test in step"),null];const[s,i]=_d(r,!0,t,n);r=null===a?s:vd(s,a);const l=$a(i,o);return[pd(r,(e=>ud(`((${e.code}) ? ${t.code} : null)`,{type:0},[...t.H,...e.H]))),l]}))}(r[0],t,n)}const a=Qd(n,Jd(n,"contextItem"));t=(e=na(e,"rootExpr"))?zd(n,function(e){return pd(e,(e=>ud(`(function () {\n\t\t\t\tlet n = ${e.code};\n\t\t\t\twhile (n.nodeType !== /*DOCUMENT_NODE*/9) {\n\t\t\t\t\tn = domFacade.getParentNode(n);\n\t\t\t\t\tif (n === null) {\n\t\t\t\t\t\tthrow new Error('XPDY0050: the root node of the context node is not a document node.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn n;\n\t\t\t})()`,{type:0},e.H)))}(a),"root"):a;const[o,s]=qd(r,!e,t,n);return[pd(o,(e=>ud(`(function* (${a.code}) {\n\t\t\t${e.H.join("\n")}\n\t\t\t${e.code}\n\t\t})`,{type:1},[]))),s]}function Yd(e,t,n){const r=e[0];switch(r){case"contextItemExpr":return[t,null];case"pathExpr":return Vd(e,t,n);case"andOp":return kd(e,"&&",t,n);case"orOp":return kd(e,"||",t,n);case"stringConstantExpr":return[ud(e=Td(e=na(e,"value")[1]||""),{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=Ed(e,r,t,n);break e;case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":const a=aa(oa(e,["firstOperand","*"]),"type"),o=aa(oa(e,["secondOperand","*"]),"type");e=a&&o?3===a.g&&3===o.g?Ed(e,bd[r],t,n):3===a.g?Nd(e,"firstOperand","secondOperand",bd[r],t,n):3===o.g?Nd(e,"secondOperand","firstOperand",Ad[bd[r]],t,n):hd("General comparison for sequences is not implemented"):hd("types of compare are not known");break e;default:e=hd(`Unsupported compare type: ${r}`)}return[e,null];case"functionCallExpr":return[Sd(e,t,n),null];default:return[hd(`Unsupported: the base expression '${r}'.`),null]}}function zd(e,t,n){return pd(t,(t=>{var r=e.o.get(t);return r||(r=ud(r=Jd(e,n),t.ra,[...t.H,`const ${r} = ${t.code};`]),e.o.set(t,r),e.o.set(r,r)),r}))}function Jd(e,t="v"){const n=e.v.get(t)||0;return e.v.set(t,n+1),`${t}${n}`}function Qd(e,t){return t=ud(t,{type:0},[]),e.o.set(t,t),t}function Kd(e){const t=sa(e,"*");if("pathExpr"===e[0])return!0;for(const e of t)if(Kd(e))return!0;return!1}class Wd extends Error{constructor(e,t,n){var r=e.stack;r&&(r.includes(e.message)&&(r=r.substr(r.indexOf(e.message)+e.message.length).trim()),(r=r.split("\n")).splice(10),r=r.map((e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`)),r=r.join("\n")),super(`Custom XPath function Q{${n}}${t} raised:\n${e.message}\n${r}`)}}function Zd(e,t,n){return 0===t.g?e.G()?null:ed(e.first(),n).next(0).value:2===t.g||1===t.g?e.O().map((e=>{if(T(e.type,47))throw Error("Cannot pass attribute nodes to custom functions");return ed(e,n).next(0).value})):ed(e.first(),n).next(0).value}var em={callFunction(e,t,n,r,a){const o=kr(t,n,r.length);if(!o)throw Error("function not found for codegen function call");t=new ze({N:null,Fa:0,za:L.empty(),wa:{}});const s=new oe(e);return e=new Je(!1,!1,s,null,null,a?a.currentContext:null,null),r=o.callFunction(t,e,null,...r.map(((e,t)=>He(0,e,o.j[t])))),Zd(r,{type:59,g:0},e)},errXPDY0002:We};const tm={"http://www.w3.org/2005/XQueryX":"xqx","http://www.w3.org/2007/xquery-update-10":"xquf","http://fontoxml.com/fontoxpath":"x"};function nm(e,t,n,r,a){if("string"==typeof n)return 0===n.length?null:t.createTextNode(n);if(!Array.isArray(n))throw new TypeError("JsonML element should be an array or string");var o=function(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,kb:t||"http://www.w3.org/2005/XQueryX"};case"deleteExpr":case"insertExpr":case"renameExpr":case"replaceExpr":case"transformExpr":return{localName:e,kb:"http://www.w3.org/2007/xquery-update-10"};case"x:stackTrace":return{localName:"stackTrace",kb:"http://fontoxml.com/fontoxpath"};default:return{localName:e,kb:"http://www.w3.org/2005/XQueryX"}}}(n[0],r);r=o.localName,o=o.kb;const s=t.createElementNS(o,tm[o]+":"+r),i=n[1];var l=1;if("object"==typeof i&&!Array.isArray(i)){if(null!==i)for(var c of Object.keys(i))null!==(l=i[c])&&("type"===c?void 0!==l&&e.setAttributeNS(s,o,"fontoxpath:"+c,O(l)):("start"!==c&&"end"!==c||"stackTrace"!==r||(l=JSON.stringify(l)),a&&"prefix"===c&&""===l||e.setAttributeNS(s,o,tm[o]+":"+c,l)));l=2}for(let r=l,i=n.length;r<i;++r)c=nm(e,t,n[r],o,a),null!==c&&e.insertBefore(s,c,null);return s}const rm=new Map;function am(e){var t;e:{if(t=Ks.get(e))for(const e of Object.keys(t))if(t[e]&&t[e].length){t=t[e][0].h;break e}t=null}if(t)return t;if(rm.has(e))return rm.get(e);if(null===(t=oa(t="string"==typeof e?Op(e,{Z:!1}):ei(e),["mainModule","queryBody","*"])))throw Error("Library modules do not have a specificity");return t=Qs(t,{qa:!1,Z:!1}),rm.set(e,t),t}var om=new q;return void 0!==n&&(n.compareSpecificity=function(e,t){return Kn(am(e).o,am(t).o)},n.compileXPathToJavaScript=function(e,t,n){if(n=n||{},t=t||0,"string"==typeof e){e=oi(e);var r={Z:"XQuery3.1"===n.language||"XQueryUpdate3.1"===n.language,debug:!1};try{var a=Op(e,r)}catch(t){Sr(e,t)}}else a=ei(e);if(!(e=na(a,"mainModule")))return hd("Unsupported: XQuery Library modules are not supported.");if(na(e,"prolog"))return hd("Unsupported: XQuery Prologs are not supported.");if(r=void 0===n.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":n.defaultFunctionNamespaceURI,e=new class{constructor(e,t){this.o=new Map,this.v=new Map,this.$=e,this.D=t,this.h=Yd}}(n.namespaceResolver||Jp(null),r),Ea(a,n=new ka(new ta(new Ur(e.$,{},r,n.functionNameResolver||Qp("http://www.w3.org/2005/xpath-functions"))))),n=na(a,"mainModule"))if(na(n,"prolog"))e=hd("Unsupported: XQuery.");else{var o=oa(n,["queryBody","*"]);n=Qd(e,"contextItem"),[r]=e.h(o,n,e);e:switch(o=aa(o,"type"),t){case 9:e=wd(t=md(r,n,e),o,e);break e;case 7:e=function(e,t,n,r){return pd(e,(e=>{switch(e.ra.type){case 1:return pd(zd(r,e,"nodes"),(e=>pd(zd(r,n,"contextItem"),(t=>ud(`Array.from(${e.code}(${t.code}))`,{type:0},[...e.H,...t.H])))));case 0:return pd(zd(r,wd(e,t,r),"node"),(e=>ud(`(${e.code} === null ? [] : [${e.code}])`,{type:0},e.H)));default:return hd("Unsupported code type to evaluate to nodes")}}))}(r,o,n,e);break e;case 3:e=fd(r,o,n,e);break e;case 2:e=yd(r,o,n,e);break e;default:e=hd(`Unsupported: the return type '${t}'.`)}e.isAstAccepted&&(e=`\n\t\t${e.H.join("\n")}\n\t\treturn ${e.code};`,t="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",Kd(a)&&(t+='\n\t\tif (!contextItem) {\n\t\t\tthrow errXPDY0002("Context is needed to evaluate the given path expression.");\n\t\t}\n\n\t\tif (!contextItem.nodeType) {\n\t\t\tthrow new Error("Context item must be subtype of node().");\n\t\t}\n\t\t'),e={code:t+(e+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else e=hd("Unsupported: Can not execute a library module.");return e},n.domFacade=om,n.evaluateXPath=id,n.evaluateXPathToArray=function(e,t,n,r,a){return id(e,t,n,r,id.Ib,a)},n.evaluateXPathToAsyncIterator=ld,n.evaluateXPathToBoolean=function(e,t,n,r,a){return id(e,t,n,r,id.BOOLEAN_TYPE,a)},n.evaluateXPathToFirstNode=function(e,t,n,r,a){return id(e,t,n,r,id.Lb,a)},n.evaluateXPathToMap=function(e,t,n,r,a){return id(e,t,n,r,id.Ob,a)},n.evaluateXPathToNodes=function(e,t,n,r,a){return id(e,t,n,r,id.Qb,a)},n.evaluateXPathToNumber=function(e,t,n,r,a){return id(e,t,n,r,id.NUMBER_TYPE,a)},n.evaluateXPathToNumbers=function(e,t,n,r,a){return id(e,t,n,r,id.Rb,a)},n.evaluateXPathToString=function(e,t,n,r,a){return id(e,t,n,r,id.STRING_TYPE,a)},n.evaluateXPathToStrings=function(e,t,n,r,a){return id(e,t,n,r,id.Sb,a)},n.evaluateUpdatingExpression=async function(e,t,n,r,a){let o,s,i;a=a||{},ai();try{const i=Kp(e,t,n||null,r||{},a||{},{qa:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});var l=i.rb;o=i.sb,s=i.ba}catch(t){Sr(e,t)}if(!s.J){for(l=[],e=ld(e,t,n,r,Object.assign(Object.assign({},a),{language:"XQueryUpdate3.1"})),t=await e.next();!t.done;t=await e.next())l.push(t.value);return Promise.resolve({pendingUpdateList:[],xdmValue:l})}try{i=s.s(l,o).next(0)}catch(t){Sr(e,t)}return cd(i.value,e,a.returnType,o)},n.evaluateUpdatingExpressionSync=function(e,t,n,r,a){let o,s,i,l;a=a||{},ai();try{const l=Kp(e,t,n||null,r||{},a||{},{qa:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});o=l.rb,s=l.sb,i=l.ba}catch(t){Sr(e,t)}if(!i.J)return{pendingUpdateList:[],xdmValue:id(e,t,n,r,a.i,Object.assign(Object.assign({},a),{language:id.Vb}))};try{l=i.s(o,s).next(0)}catch(t){Sr(e,t)}return cd(l.value,e,a.returnType,s)},n.executeJavaScriptCompiledXPath=(e,t,n,r)=>(n=n||new q,e()(null!=t?t:null,n,em,r)),n.executePendingUpdateList=function(e,t,n,r){t=new oe(t||new q),r=r?new Y(r):V,n=n?n=new Yp(n):null,e=e.map(Ss),_n(e,t,n,r)},n.getBucketForSelector=function(e){return am(e).D()},n.getBucketsForNode=X,n.precompileXPath=function(e){return Promise.resolve(e)},n.registerXQueryModule=function(e,t={debug:!1}){if(Aa(t=Op(e,{Z:!0,debug:t.debug}),new ka),!(t=na(t,"libraryModule")))throw Error("XQuery module must be declared in a library module.");var n=na(t,"moduleDecl"),r=na(n,"uri");const a=ra(r);if(r=ra(n=na(n,"prefix")),Kr(n=new ta(new Ur((()=>null),Object.create(null),"http://www.w3.org/2005/xpath-functions",Qp("http://www.w3.org/2005/xpath-functions"))),r,a),null!==(t=na(t,"prolog"))){let r;try{r=Dp(t,n,!0,e)}catch(t){Sr(e,t)}r.Ha.forEach((({namespaceURI:e})=>{if(a!==e)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.")})),ni(a,r)}else ni(a,{Ha:[],Ta:[],oa:null,source:e});return a},n.registerCustomXPathFunction=function(e,t,n,r){const{namespaceURI:a,localName:o}=function(e){if("object"==typeof e)return e;if(2!==(e=e.split(":")).length)throw Error("Do not register custom functions in the default function namespace");const[t,n]=e;if(!(e=Mr[t])){if(e=`generated_namespace_uri_${t}`,Mr[t])throw Error("Prefix already registered: Do not register the same prefix twice.");Mr[t]=e}return{localName:n,namespaceURI:e}}(e);if(!a)throw Pr();const s=t.map((e=>D(e))),i=D(n);Rr(a,o,s,i,(function(e,t,n){var l=Array.from(arguments);l.splice(0,3),l=l.map(((e,n)=>Zd(e,s[n],t)));const c={currentContext:t.o,domFacade:t.h.h};let u;try{u=r.apply(void 0,[c,...l])}catch(e){throw new Wd(e,o,a)}return u&&"object"==typeof u&&Object.getOwnPropertySymbols(u).includes(zp)?L.create(u.xb):He(t.h,u,i)}))},n.parseScript=function(e,t,n,r=V){let a;e=oi(e);try{a=Op(e,{Z:"XQuery3.1"===t.language||"XQueryUpdate3.1"===t.language,debug:t.debug})}catch(t){Sr(e,t)}var o=new Ur(t.namespaceResolver||(()=>null),{},void 0===t.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":t.defaultFunctionNamespaceURI,t.functionNameResolver||(()=>null));o=new ta(o);var s=na(a,["mainModule","libraryModule"]),i=na(s,"moduleDecl");if(i){Kr(o,ra(na(i,"prefix")),i=ra(na(i,"uri")))}return(s=na(s,"prolog"))&&Dp(s,o,!1,e),!1!==t.annotateAst&&Aa(a,new ka(o)),o=new q,t=nm(r,n,a,null,!1===t.kc),r.insertBefore(t,n.createComment(e),o.getFirstChild(t)),t},n.profiler=od,n.createTypedValueFactory=function(e){return(t,n)=>(t=$e(new oe(null===n?new q:n),t,D(e)),{[zp]:!0,xb:t})},n.finalizeModuleRegistration=ai,n.Language={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"},n.ReturnType=td),n}.call("undefined"==typeof window?void 0:window,Ae,He);Pe.compareSpecificity,Pe.compileXPathToJavaScript,Pe.createTypedValueFactory,Pe.domFacade,Pe.evaluateUpdatingExpression,Pe.evaluateUpdatingExpressionSync;const _e=Pe.evaluateXPath;Pe.evaluateXPathToArray,Pe.evaluateXPathToAsyncIterator;const je=Pe.evaluateXPathToBoolean,Xe=Pe.evaluateXPathToFirstNode;Pe.evaluateXPathToMap;const qe=Pe.evaluateXPathToNodes,Ve=Pe.evaluateXPathToNumber;Pe.evaluateXPathToNumbers;const Ye=Pe.evaluateXPathToString,ze=Pe.evaluateXPathToStrings;Pe.executeJavaScriptCompiledXPath,Pe.executePendingUpdateList,Pe.finalizeModuleRegistration,Pe.getBucketForSelector;const Je=Pe.getBucketsForNode;Pe.Language;const Qe=Pe.parseScript;Pe.precompileXPath,Pe.profiler;const Ke=Pe.registerCustomXPathFunction,We=Pe.registerXQueryModule;Pe.ReturnType;class Ze{constructor(e){this._onNodeTouched=e}getAllAttributes(e){return Array.from(e.attributes)}getAttribute(e,t){return e.getAttribute(t)}getChildNodes(e,t){const n=Array.from(e.childNodes).filter((e=>!t||Je(e).includes(t)));return n.forEach((e=>this._onNodeTouched(e))),n}getData(e){return e.nodeType===Node.ATTRIBUTE_NODE?(this._onNodeTouched(e),e.value):(this._onNodeTouched(e.parentNode),e.data)}getFirstChild(e,t){for(const n of e.childNodes)if(!t||Je(n).includes(t))return this._onNodeTouched(n),n;return null}getLastChild(e,t){const n=e.getChildNodes().filter((e=>!t||Je(e).includes(t))),r=n[n.length-1];return r||null}getNextSibling(e,t){for(let n=e.nextSibling;n;n=n.nextSibling)if(Je(n).includes(t))return this._onNodeTouched(n),n;return null}getParentNode(e){return e.parentNode}getPreviousSibling(e,t){for(let{previousSibling:n}=e;n;n=n.previousSibling)if(Je(n).includes(t))return n;return null}}class et{static contains(e,t){for(;t;){if(t===e)return!0;t=t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t.parentNode}return!1}static getClosest(e,t){for(;t&&!t.matches||!t.matches(e);)if(t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE)if(t.nodeType!==Node.ATTRIBUTE_NODE){if(t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.matches("fx-fore"))return null;if(!(t=t.parentNode))return null}else t=t.ownerElement;else t=t.host;return t}static getParentBindingElement(e){return!e.parentNode||e.parentNode.nodeType===Node.DOCUMENT_NODE&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?null:e.parentNode.closest("[ref]")}static isAbsolutePath(e){return null!=e&&(e.startsWith("/")||e.startsWith("instance("))}static isSelfReference(e){return"."===e||"./text()"===e||"text()"===e||""===e||null===e}static getInstanceId(e){if(!e)return"default";if(e.startsWith("instance()"))return"default";if(e.startsWith("instance(")){const t=e.substring(e.indexOf("(")+1);return t.substring(1,t.indexOf(")")-1)}return null}static resolveInstance(e){const t=et.getInstanceId(e.getAttribute("ref"));if(null!==t)return t;const n=et.getParentBindingElement(e);return n?this.resolveInstance(n):"default"}static getPath(e){const t=Ye("path()",e);return et.shortenPath(t)}static shortenPath(e){const t=e.replaceAll(/(Q{(.*?)\})/g,""),n=t.substring(1,t.length);return n.substring(n.indexOf("/"),t.length)}static getBasePath(e){return e.split(":")[0]}}function tt(e,t,n,r){const a={};return function(o){if(a[o])return;const s={},i=[],l=[];for(l.push({node:o,processed:!1});l.length>0;){const o=l[l.length-1],{processed:c}=o,{node:u}=o;if(c)l.pop(),i.pop(),s[u]=!1,a[u]=!0,t&&0!==e[u].length||n.push(u);else{if(a[u]){l.pop();continue}if(s[u]){if(r){l.pop();continue}throw i.push(u),window.dispatchEvent(new CustomEvent("compute-exception",{composed:!1,bubbles:!0,detail:{path:i,message:"cyclic graph"}})),new Error(`Cyclic at ${i}`)}s[u]=!0,i.push(u);const t=e[u];for(let e=t.length-1;e>=0;e-=1)l.push({node:t[e],processed:!1});o.processed=!0}}}}function nt(e){this.nodes={},this.outgoingEdges={},this.incomingEdges={},this.circular=e&&!!e.circular}function rt(e){const t=(new DOMParser).parseFromString(e,"application/xml"),n=(new DOMParser).parseFromString(['<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',' <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>',' <xsl:strip-space elements="*"/>',' <xsl:template match="text()">',' <xsl:value-of select="normalize-space(.)"/>'," </xsl:template>",' <xsl:template match="node()|@*">'," <xsl:copy>",' <xsl:apply-templates select="node()|@*"/>'," </xsl:copy>"," </xsl:template>","</xsl:stylesheet>"].join("\n"),"application/xml"),r=new XSLTProcessor;r.importStylesheet(n);const a=r.transformToDocument(t);return(new XMLSerializer).serializeToString(a)}nt.prototype={size(){return Object.keys(this.nodes).length},addNode(e,t){this.hasNode(e)||(this.nodes[e]=2===arguments.length?t:e,this.outgoingEdges[e]=[],this.incomingEdges[e]=[])},removeNode(e){this.hasNode(e)&&(delete this.nodes[e],delete this.outgoingEdges[e],delete this.incomingEdges[e],[this.incomingEdges,this.outgoingEdges].forEach((t=>{Object.keys(t).forEach((n=>{const r=t[n].indexOf(e);r>=0&&t[n].splice(r,1)}),this)})))},hasNode(e){return Object.prototype.hasOwnProperty.call(this.nodes,e)},getNodeData(e){if(this.hasNode(e))return this.nodes[e];throw new Error(`Node does not exist: ${e}`)},setNodeData(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);this.nodes[e]=t},addDependency(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);if(!this.hasNode(t))throw new Error(`Node does not exist: ${t}`);return-1===this.outgoingEdges[e].indexOf(t)&&this.outgoingEdges[e].push(t),-1===this.incomingEdges[t].indexOf(e)&&this.incomingEdges[t].push(e),!0},removeDependency(e,t){let n;this.hasNode(e)&&(n=this.outgoingEdges[e].indexOf(t),n>=0&&this.outgoingEdges[e].splice(n,1)),this.hasNode(t)&&(n=this.incomingEdges[t].indexOf(e),n>=0&&this.incomingEdges[t].splice(n,1))},clone(){const e=this,t=new nt;return Object.keys(e.nodes).forEach((n=>{t.nodes[n]=e.nodes[n],t.outgoingEdges[n]=e.outgoingEdges[n].slice(0),t.incomingEdges[n]=e.incomingEdges[n].slice(0)})),t},directDependenciesOf(e){if(this.hasNode(e))return this.outgoingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},directDependantsOf(e){if(this.hasNode(e))return this.incomingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},dependenciesOf(e,t){if(this.hasNode(e)){const n=[];tt(this.outgoingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},dependantsOf(e,t){if(this.hasNode(e)){const n=[];tt(this.incomingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},entryNodes(){const e=this;return Object.keys(this.nodes).filter((t=>0===e.incomingEdges[t].length))},overallOrder(e){const t=this,n=[],r=Object.keys(this.nodes);if(0===r.length)return n;if(!this.circular){const e=tt(this.outgoingEdges,!1,[],this.circular);r.forEach((t=>{e(t)}))}const a=tt(this.outgoingEdges,e,n,this.circular);return r.filter((e=>0===t.incomingEdges[e].length)).forEach((e=>{a(e)})),this.circular&&r.filter((e=>-1===n.indexOf(e))).forEach((e=>a(e))),n}},nt.prototype.directDependentsOf=nt.prototype.directDependantsOf,nt.prototype.dependentsOf=nt.prototype.dependantsOf;const at="http://www.w3.org/2002/xforms",ot=new Map,st=[];function it(e,t,n){return ot.has(e)?ot.get(e).set(t,n):ot.set(e,new Map)}const lt=e=>{if(!e)return"http://www.w3.org/1999/xhtml"};function ct(e,t,n=null){t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.nodeType===Node.ATTRIBUTE_NODE&&(t=t.ownerElement),t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(t=t.parentNode.host);const r=("fx-fore"===t.localName?t:t.closest("fx-fore")).querySelectorAll(`[id='${e}']`);if(1===r.length){const e=r[0];return n&&e.localName!==n?null:e}const a=qe("outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]",t,null,{id:e},{namespaceResolver:lt});if(0===a.length)return null;if(1===a.length&&je("(ancestor::fx-fore | ancestor::fx-repeat)[last()]/self::fx-fore",a[0],null,null,{namespaceResolver:lt})){const e=a[0];return n&&e.localName!==n?null:e}for(const e of qe("ancestor::fx-repeatitem => reverse()",t,null,null,{namespaceResolver:lt})){const t=a.filter((t=>et.contains(e,t)));switch(t.length){case 0:break;case 1:{const e=t[0];return n&&e.localName!==n?null:e}default:{const e=t.find((e=>qe("every $ancestor of ancestor::fx-repeatitem satisfies $ancestor is $ancestor/../child::fx-repeatitem[../@repeat-index]",e,null,{})));return e?n&&e.localName!==n?null:e:null}}}return null}const ut=(new DOMParser).parseFromString("<xml />","text/xml"),ht=new Map;function pt(e,t){const n=function(e,t){return ot.has(e)&&ot.get(e).get(t)||null}(e,t);if(n)return n;let r=function(e){if(!e.includes("instance"))return[];if(ht.has(e))return ht.get(e);const t=Qe(e,{},ut),n=ze('descendant::xqx:functionCallExpr\n\t\t\t\t[xqx:functionName = "instance"]\n\t\t\t\t/xqx:arguments\n\t\t\t\t/xqx:stringConstantExpr\n\t\t\t\t/xqx:value',t,null,{},{namespaceResolver:e=>"xqx"===e?"http://www.w3.org/2005/XQueryX":void 0});return ht.set(e,n),n}(e);if(0===r.length){const n=t.parentNode&&t.parentNode.nodeType===t.ELEMENT&&t.parentNode.closest("[ref]");if(n){const r=pt(n.getAttribute("ref"),n);return it(e,t,r),r}r=["default"]}if(1===r.length){let n;if("default"===r[0]){const e=Xe("ancestor-or-self::fx-fore[1]",t,null,null,{namespaceResolver:lt});n=e&&e.querySelector("fx-instance")}else n=ct(r[0],t,"fx-instance");if(n&&n.hasAttribute("xpath-default-namespace")){const r=n.getAttribute("xpath-default-namespace"),a=e=>{if(!e)return r};return it(e,t,a),a}}r.length>1&&console.warn(`More than one instance is used in the query "${e}". The default namespace resolving will be used`);const a=Ye("ancestor-or-self::*/@xpath-default-namespace[last()]",t)||"",o=function(e){return""===e?a:Ye('ancestor-or-self::*/@*[name() = "xmlns:" || $prefix][last()]',t,null,{prefix:e})};return it(e,t,o),o}function dt(e,t,n){return(t&&t.ownerDocument||t)===window.document?lt:pt(e,n)}function mt({prefix:e,localName:t},n){switch(t){case"context":case"base64encode":case"boolean-from-string":case"current":case"depends":case"event":case"fore-attr":case"index":case"instance":case"log":case"parse":case"logtree":return{namespaceURI:at,localName:t};default:return""===e&&st.includes(t)?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:"fn"===e||""===e?{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:t}:"local"===e?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:null}}function ft(e){let t=e;for(;t&&!("inScopeVariables"in t);)t=t.parentNode;if(!t)return{};const n={};if(t.inScopeVariables)for(const e of t.inScopeVariables.keys()){const r=t.inScopeVariables.get(e);r&&(r.nodeType?n[e]=r.value:n[e]=r)}return n}function gt(e,t,n,r={},a={}){const o=dt(e,t,n),s=ft(n);return _e(e,t,null,{...s,...r},_e.ALL_RESULTS_TYPE,{currentContext:{formElement:n,variables:r},moduleImports:{xf:at},functionNameResolver:mt,namespaceResolver:o,language:a.language||gt.XPATH_3_1})}function yt(e,t,n){const r=dt(e,t,n),a=ft(n);return Xe(e,t,null,a,{defaultFunctionNamespaceURI:at,moduleImports:{xf:at},currentContext:{formElement:n},functionNameResolver:mt,namespaceResolver:r})}function wt(e,t,n){const r=dt(e,t,n),a=ft(n);return qe(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:mt,moduleImports:{xf:at},namespaceResolver:r})}function vt(e,t,n){const r=dt(e,t,n),a=ft(n);return je(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:mt,moduleImports:{xf:at},namespaceResolver:r})}function xt(e,t,n,r=null,a=n){const o=dt(e,t,n),s=ft(n);return Ye(e,t,r,s,{currentContext:{formElement:n},functionNameResolver:mt,moduleImports:{xf:at},namespaceResolver:o})}function bt(e,t,n,r=null,a=n){const o=dt(e,t,n),s=ft(n);return Ve(e,t,r,s,{currentContext:{formElement:n},functionNameResolver:mt,moduleImports:{xf:at},namespaceResolver:o})}const At=(e,t)=>{const n=e.currentContext.formElement;if(t){const e=ct(t,n);if(e){if("FX-REPEAT"===e.nodeName){const{nodeset:t}=e;for(let r=n;r;r=r.parentNode)if(r.parentNode===e){return t[Array.from(r.parentNode.children).indexOf(r)]}}return e.nodeset}}const r=et.getParentBindingElement(n);return r?r.nodeset:n.getInScopeContext()};function Et(e,t){if(t&&t.nodeType===Node.ELEMENT_NODE&&t.children){const n=document.createElement("details");n.setAttribute("data-path",t.nodeName);const r=document.createElement("summary");let a,o=` <${t.nodeName}`;Array.from(t.attributes).forEach((e=>{o+=` ${e.nodeName}="${e.nodeValue}"`})),t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE&&""!==t.firstChild.data.trim()?(a=t.firstChild.nodeValue,o+=`>${a}</${t.nodeName}>`):o+=">",r.textContent=o,n.appendChild(r),0!==t.childElementCount?n.setAttribute("open","open"):r.setAttribute("style","list-style:none;"),e.appendChild(n),Array.from(t.children).forEach((e=>{Et(n,e)}))}}Ke({namespaceURI:at,localName:"context"},[],"item()?",At),Ke({namespaceURI:at,localName:"context"},["xs:string"],"item()?",At),Ke({namespaceURI:at,localName:"current"},["xs:string"],"item()?",((e,t)=>(e.currentContext.formElement,null))),Ke({namespaceURI:at,localName:"element"},["xs:string"],"item()?",((e,t)=>{e.currentContext.formElement;return document.createElement(t)})),Ke({namespaceURI:at,localName:"log"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext,r=ct(t,n,"fx-instance");if(r){if("json"!==r.getAttribute("type")){return rt((new XMLSerializer).serializeToString(r.getDefaultContext()))}console.warn("log() does not work for JSON yet")}return null})),Ke({namespaceURI:at,localName:"fore-attr"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext;let r=n;n.nodeType===Node.TEXT_NODE&&(r=n.parentNode);const a=r.closest("fx-fore");return a.hasAttribute(t)?a.getAttribute(t):null})),Ke({namespaceURI:at,localName:"parse"},["xs:string?"],"element()?",((e,t)=>{const n=(new DOMParser).parseFromString(t,"application/xml");return console.log("parse",n),n.firstElementChild})),Ke({namespaceURI:at,localName:"logtree"},["xs:string?"],"element()?",((e,t)=>{const{formElement:n}=e.currentContext,r=ct(t,n,"fx-instance");if(r){const t=document.createElement("div");t.setAttribute("class","logtree");const n=e.currentContext.formElement,a=n.querySelector(".logtree");a&&a.parentNode.removeChild(a);const o=Et(t,r.getDefaultContext());o&&n.appendChild(o)}return null}));const Nt=(e,t)=>{const n=Xe("ancestor-or-self::fx-fore[1]",e.currentContext.formElement,null,null,{namespaceResolver:lt}),r=t?n.querySelector(`#${t}`):n.querySelector("fx-instance");return r?r.getDefaultContext():null};function Tt(e,t){const n=t.split(".");return 1==n.length?e[n[0]]:Tt(e[n[0]],n.slice(1).join("."))}function Bt(e){return e.closest("fx-fore")}function It(e,t){const n=et.getClosest("[ref]",e),r=et.getClosest("fx-fore",e),a=function(e){return Bt(e).getModel()}(e);if(null!==n){return r===n.closest("fx-fore")?n.nodeset:a.getDefaultInstance().getDefaultContext()}if(et.isAbsolutePath(t)){const e=et.getInstanceId(t);return e?a.getInstance(e).getDefaultContext():a.getDefaultInstance().getDefaultContext()}return a.getDefaultInstance().getDefaultContext()}function Ct(e,t){const n=function(e){return e&&e.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.nodeType===Node.ELEMENT_NODE?e:e.parentNode}(e);if("FX-FORE"===n.nodeName)return n.getModel().getDefaultInstance().getDefaultContext();const r=et.getClosest("[ref]",n.parentNode);if(r&&("FX-GROUP"===r.nodeName||"FX-CONTROL"===r.nodeName))return r.nodeset;const a=et.getClosest("fx-repeatitem",n);if(a)return"context"===e.nodeName?yt(e.nodeValue,a.nodeset,Bt(n)):a.nodeset;const o=n.closest(".fx-repeatitem");if(o){const e=o.parentNode,t=Array.from(e.children).indexOf(o);return et.getClosest("fx-repeat-attributes",n).nodeset[t]}if(n.hasAttribute("context")){const e=It(n.parentNode,t);return yt(n.getAttribute("context"),e,Bt(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"context"===e.nodeName){const r=It(e.ownerElement.parentNode,t);return yt(e.ownerElement.getAttribute("context"),r,Bt(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"ref"===e.nodeName){if(e.ownerElement.hasAttribute("context")){const r=It(e.ownerElement.parentNode,t);return yt(e.ownerElement.getAttribute("context"),r,Bt(n))}return It(n.parentNode,t)}return It(n,t)}Ke({namespaceURI:at,localName:"index"},["xs:string?"],"xs:integer?",((e,t)=>{const{formElement:n}=e.currentContext;if(null===t)return 1;const r=ct(t,n,"fx-repeat");return r?r.getAttribute("index"):Number(1)})),Ke({namespaceURI:at,localName:"instance"},[],"item()?",(e=>Nt(e,null))),Ke({namespaceURI:at,localName:"instance"},["xs:string?"],"item()?",Nt),Ke({namespaceURI:at,localName:"depends"},["node()*"],"item()?",((e,t)=>t[0])),Ke({namespaceURI:at,localName:"event"},["xs:string?"],"item()?",((e,t)=>{if(!t)return null;for(let n=e.currentContext.formElement;n;n=n.parentNode)if(n.currentEvent)return n.currentEvent.detail&&"object"==typeof n.currentEvent.detail&&t in n.currentEvent.detail?n.currentEvent.detail[t]:t.includes(".")?Tt(n.currentEvent,t):n.currentEvent[t]||null;return null})),We(`\n module namespace xf="${at}";\n\n declare %public function xf:boolean-from-string($str as xs:string) as xs:boolean {\n lower-case($str) = "true" or $str = "1"\n };\n`),Ke({namespaceURI:at,localName:"base64encode"},["xs:string?"],"xs:string?",((e,t)=>btoa(t)));class St{static isWidget(e){if(e?.classList.contains("widget"))return!0;let t=e.parentNode;for(;t&&"FX-CONTROL"!==t.nodeName;){if(t.classList.contains("widget"))return!0;t=t.parentNode}return!1}static getDomNodeIndexString(e){const t=[];let n=e;for(;n&&n.parentNode;){const e=n.parentNode;if(e.childNodes&&e.childNodes.length>0){const r=[...e.childNodes].indexOf(n);t.unshift(r)}n=e}return t.join(".")}static getExpression(e){return e.startsWith("{")&&e.endsWith("}")?e.substring(1,e.length-1):e}static getFore(e){return e.nodeType===Node.TEXT_NODE?e.parentNode.closest("fx-fore"):e.closest("fx-fore")}static get ACTION_ELEMENTS(){return["FX-ACTION","FX-DELETE","FX-DISPATCH","FX-HIDE","FX-INSERT","FX-LOAD","FX-MESSAGE","FX-REBUILD","FX-RECALCULATE","FX-REFRESH","FX-RENEW","FX-RELOAD","FX-REPLACE","FX-RESET","FX-RETAIN","FX-RETURN","FX-REVALIDATE","FX-SEND","FX-SETFOCUS","FX-SETINDEX","FX-SETVALUE","FX-SHOW","FX-TOGGLE","FX-UPDATE"]}static createUUID(){const e=[],t="0123456789abcdef";for(let n=0;n<36;n+=1)e[n]=t.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";return e.join("")}static get XFORMS_NAMESPACE_URI(){return"http://www.w3.org/2002/xforms"}static isActionElement(e){return St.ACTION_ELEMENTS.includes(e)}static get UI_ELEMENTS(){return["FX-ALERT","FX-CONTROL","FX-DIALOG","FX-FILENAME","FX-MEDIATYPE","FX-GROUP","FX-HINT","FX-ITEMS","FX-OUTPUT","FX-RANGE","FX-REPEAT","FX-REPEATITEM","FX-REPEAT-ATTRIBUTES","FX-SWITCH","FX-SECRET","FX-SELECT","FX-SUBMIT","FX-TEXTAREA","FX-TRIGGER","FX-UPLOAD","FX-VAR"]}static get MODEL_ELEMENTS(){return["FX-BIND","FX-FUNCTION","FX-MODEL","FX-INSTANCE","FX-SUBMISSION"]}static isUiElement(e){return St.UI_ELEMENTS.includes(e),St.UI_ELEMENTS.includes(e)}static async refreshChildren(e,t){return new Promise((n=>{const{children:r}=e;r&&Array.from(r).forEach((e=>{"FX-FORE"===e.nodeName.toUpperCase()&&n("done"),St.isUiElement(e.nodeName)&&"function"==typeof e.refresh?e.refresh(t):"FX-MODEL"!==e.nodeName.toUpperCase()&&St.refreshChildren(e,t)})),n("done")}))}static copyDom(e){console.time("convert");const t=(new DOMParser).parseFromString("<fx-fore></fx-fore>","text/html");console.log("copyDom new doc",t),console.log("copyDom new body",t.body),console.log("copyDom new body",t.querySelector("fx-fore"));const n=t.querySelector("fx-fore");return this.convertFromSimple(e,n),n.removeAttribute("convert"),console.log("converted",n),console.timeEnd("convert"),n}static convertFromSimple(e,t){const n=e.childNodes;n&&Array.from(n).forEach((e=>{const n=`FX-${e.nodeName.toUpperCase()}`;if(St.MODEL_ELEMENTS.includes(n)||St.UI_ELEMENTS.includes(n)||St.ACTION_ELEMENTS.includes(n)){const r=t.ownerDocument.createElement(n);console.log("conv",e,r),t.appendChild(r),St.copyAttributes(e,r),St.convertFromSimple(e,r)}else{if(e.nodeType===Node.TEXT_NODE){const n=t.ownerDocument.createTextNode(e.textContent);t.appendChild(n)}if(e.nodeType===Node.ELEMENT_NODE){const n=t.ownerDocument.createElement(e.nodeName);t.appendChild(n),St.copyAttributes(e,t),St.convertFromSimple(e,n)}}}))}static copyAttributes(e,t){return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.nodeName,e.nodeValue)}))}static getContentType(e,t){return"application/x-www-form-urlencoded"===t?"application/x-www-form-urlencoded; charset=UTF-8":"xml"===e.type?"application/xml; charset=UTF-8":"json"===e.type?"application/json":(console.warn("content-type unknown ",e.type),null)}static async handleResponse(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/plain")||n.startsWith("text/markdown"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}return"done"}static evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{console.log("match ",n);const r=n.substring(1,n.length-1),a=xt(r,Ct(t,r),t.getOwnerForm()),o=e.replaceAll(n,a);console.log("replacing ",e," with ",o),e=o})),e}static fadeInElement(e){let t=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),t=e.animate({opacity:[0,1]},600),t.finished);return t()}static fadeOutElement(e,t){let n=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),n=e.animate({opacity:[1,0]},t),n.finished);return n()}static async dispatch(e,t,n){if(!et.contains(e?.ownerDocument,e))return;const r=new CustomEvent(t,{composed:!1,bubbles:!0,detail:n});r.listenerPromises=[],e.dispatchEvent(r),r.listenerPromises.length&&await Promise.all(r.listenerPromises)}static formatXml(e){for(var t=(e=e.replace(/(>)(<)(\/*)/g,"$1\n$2$3").replace(/ *(.*) +\n/g,"$1\n").replace(/(<.+>)(.+\n)/g,"$1\n$2")).split("\n"),n=0;n<t.length;n++){var r=t[n];Boolean(r.match(/<.+\/>/)),Boolean(r.match(/<\/.+>/)),Boolean(r.match(/<[^!].*>/))}}static async loadForeFromUrl(e,t){await fetch(t,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":"text/html"}}).then((e=>{const t=e.headers.get("content-type").toLowerCase();return console.log("********** responseContentType *********",t),t.startsWith("text/html")?e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done"})).then((t=>{const n=t.querySelector("fx-fore");n||e.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{message:"cyclic graph"}}));const r=document.importNode(n,!0);console.log(`########## loaded fore as component ##### ${e.url}`),r.addEventListener("model-construct-done",(t=>{const n=r.querySelector("fx-instance");if(e.initialNode){const t=(new DOMParser).parseFromString("<data></data>","application/xml");t.firstElementChild.appendChild(e.initialNode.cloneNode(!0)),n.setInstanceData(t)}return r.getModel().updateModel(),r.refresh(),"done"}),{once:!0});const a=e.querySelector("input");e.hasAttribute("shadow")?(a.parentNode.removeChild(a),e.shadowRoot.appendChild(r)):a.replaceWith(r)}))}}St.READONLY_DEFAULT=!1,St.REQUIRED_DEFAULT=!1,St.RELEVANT_DEFAULT=!0,St.CONSTRAINT_DEFAULT=!0,St.TYPE_DEFAULT="xs:string";class Ot extends HTMLElement{constructor(){super(),this.model=this.parentNode,this.attachShadow({mode:"open"}),this.originalInstance=null}connectedCallback(){this.hasAttribute("src")&&(this.src=this.getAttribute("src")),this.hasAttribute("id")?this.id=this.getAttribute("id"):this.id="default",this.hasAttribute("type")?this.type=this.getAttribute("type"):(this.type="xml",this.setAttribute("type",this.type));this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: none;\n }\n :host * {\n display:none;\n }\n ::slotted(*){\n display:none;\n }\n \n </style>\n \n \n "}async init(){return await this._initInstance(),this.dispatchEvent(new CustomEvent("instance-loaded",{composed:!0,bubbles:!0,detail:{instance:this}})),this}reset(){this.instanceData=this.originalInstance}evalXPath(e){const t=this.parentElement.parentElement;return yt(e,this.getDefaultContext(),t)}getInstanceData(){return this.instanceData||this.createInstanceData(),this.instanceData}setInstanceData(e){e?this._setInitialData(e):this.createInstanceData()}getDefaultContext(){return"xml"===this.type?this.instanceData.firstElementChild:this.instanceData}async _initInstance(){if("#querystring"===this.src){const e=new URLSearchParams(location.search),t=(new DOMParser).parseFromString("<data></data>","application/xml"),n=t.firstElementChild;for(const r of e){const e=t.createElement(r[0]);e.appendChild(t.createTextNode(r[1])),n.appendChild(e)}this._setInitialData(t)}else this.src?await this._loadData():0!==this.childNodes.length&&this._useInlineData()}createInstanceData(){if("xml"===this.type){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.instanceData=e,this.originalInstance=this.instanceData.cloneNode(!0)}"json"===this.type&&(this.instanceData={},this.originalInstance=[...this.instanceData])}async _loadData(){const e=`${this.src}`;if(e.startsWith("localStore")){const t=e.substring(e.indexOf(":")+1),n=(new DOMParser).parseFromString("<data></data>","application/xml");if(this.instanceData=n,!t)return void console.warn("no key specified for localStore");const r=localStorage.getItem(t);if(!r)return console.warn(`Data for key ${t} cannot be found`),void this._useInlineData();const a=(new DOMParser).parseFromString(r,"application/xml");return void n.firstElementChild.replaceWith(a.firstElementChild)}const t=St.getContentType(this,"get");try{const n=await fetch(e,{method:"GET",headers:{"Content-Type":t}}),r=await async function(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/plain")||n.startsWith("text/markdown"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")||n.startsWith("text/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}throw new Error(`unable to handle response content type: ${n}`)}(n);this._setInitialData(r)}catch(e){throw new Error(`failed loading data ${e}`)}}_setInitialData(e){this.instanceData=e,e.nodeType?this.originalInstance=this.instanceData.cloneNode(!0):this.originalInstance={...this.instanceData}}_getContentType(){return"xml"===this.type?"application/xml":"json"===this.type?"application/json":(console.warn("content-type unknown ",this.type),null)}_useInlineData(){if("xml"===this.type){const e=(new DOMParser).parseFromString(this.innerHTML,"application/xml");this._setInitialData(e)}else"json"===this.type?this._setInitialData(JSON.parse(this.textContent)):"html"===this.type?this._setInitialData(this.firstElementChild.children):"text"===this.type?this._setInitialData(this.textContent):console.warn("unknow type for data ",this.type)}}customElements.get("fx-instance")||customElements.define("fx-instance",Ot);class Ft{constructor(e,t,n,r,a,o,s,i,l){this.path=e,this.ref=t,this.constraint=o,this.readonly=n,this.relevant=r,this.required=a,this.type=s,this.node=i,this.bind=l,this.changed=!1,this.alerts=[],this.boundControls=[]}get value(){return this.node.nodeType?this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue:this.node.textContent:this.node}set value(e){e.nodeType===Node.DOCUMENT_NODE?this.node.replaceWith(e.firstElementChild):e.nodeType===Node.ELEMENT_NODE?this.node.replaceWith(e):this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue=e:this.node.textContent=e}addAlert(e){this.alerts.includes(e)||this.alerts.push(e)}cleanAlerts(){this.alerts=[]}}class Dt extends HTMLElement{constructor(){super(),this.instances=[],this.modelItems=[],this.defaultContext={},this.changed=[],this.inited=!1,this.modelConstructed=!1,this.attachShadow({mode:"open"}),this.computes=0}get formElement(){return this.parentElement}connectedCallback(){this.shadowRoot.innerHTML="\n <slot></slot>\n ",this.addEventListener("model-construct-done",(()=>{this.modelConstructed=!0}),{once:!0}),this.skipUpdate=!1}static lazyCreateModelItem(e,t,n){let r,a={};if(null==n)return null;a=n.nodeType===n.TEXT_NODE?n.parentNode:n,n.nodeType?r=et.getPath(n):(r=null,a=n);const o=new Ft(r,t,St.READONLY_DEFAULT,St.RELEVANT_DEFAULT,St.REQUIRED_DEFAULT,St.CONSTRAINT_DEFAULT,St.TYPE_DEFAULT,a,this);return e.registerModelItem(o),o}async modelConstruct(){St.dispatch(this,"model-construct",{model:this});const e=this.querySelectorAll("fx-instance");if(e.length>0){const t=[];e.forEach((e=>{t.push(e.init())})),await Promise.all(t),this.instances=Array.from(e),await St.dispatch(this,"model-construct-done",{model:this}),this.inited=!0,this.updateModel()}else await this.dispatchEvent(new CustomEvent("model-construct-done",{composed:!1,bubbles:!0,detail:{model:this}}));this.inited=!0}registerModelItem(e){this.modelItems.push(e)}updateModel(){this.rebuild(),this.recalculate(),this.revalidate()}rebuild(){this.mainGraph=new nt(!1),this.modelItems=[];const e=this.querySelectorAll("fx-model > fx-bind");0!==e.length?(e.forEach((e=>{e.init(this)})),St.dispatch(this,"rebuild-done",{maingraph:this.mainGraph}),console.log("mainGraph",this.mainGraph)):this.skipUpdate=!0}recalculate(){if(this.mainGraph){if(this.computes=0,this.subgraph=new nt(!1),0!==this.changed.length){this.changed.forEach((e=>{if(this.subgraph.addNode(e.path,e.node),this.mainGraph.hasNode(e.path)){const t=this.mainGraph.dependantsOf(e.path,!1).reverse();0!==t.length&&t.forEach((t=>{const n=this.mainGraph.getNodeData(t);if(this.subgraph.addNode(t,n),t.includes(":")){const r=t.substring(0,t.indexOf(":"));this.subgraph.addNode(r,n);0!==this.mainGraph.dependentsOf(e.path,!1).indexOf(t)&&this.subgraph.addDependency(t,e.path)}}))}}));this.subgraph.overallOrder(!1).forEach((e=>{if(this.mainGraph.hasNode(e)){const t=this.mainGraph.getNodeData(e);this.compute(t,e)}}));const e=[...this.changed];this.formElement.toRefresh=e,this.changed=[],St.dispatch(this,"recalculate-done",{graph:this.subgraph,computes:this.computes})}else{this.mainGraph.overallOrder(!1).forEach((e=>{const t=this.mainGraph.getNodeData(e);this.compute(t,e)})),St.dispatch(this,"recalculate-done",{graph:this.mainGraph,computes:this.computes})}console.log("recalculate finished with modelItems ",this.modelItems)}}compute(e,t){const n=this.getModelItem(e);if(n&&t.includes(":")){const e=t.split(":")[1];if(e){const t=n.bind[e];if("calculate"===e){const e=gt(t,n.node,this);n.value=e,n.readonly=!0}else if("constraint"!==e&&"type"!==e&&t){const r=vt(t,n.node,this);n[e]=r}}this.computes+=1}}revalidate(){if(0===this.modelItems.length)return!0;console.time("revalidate");let e=!0;return this.modelItems.forEach((t=>{const{bind:n}=t;if(n){if("function"==typeof n.hasAttribute&&n.hasAttribute("constraint")){const r=n.getAttribute("constraint");if(r&&t.node){const n=vt(r,t.node,this);t.constraint=n,this.formElement.addToRefresh(t),n||(e=!1)}}if("function"==typeof n.hasAttribute&&n.hasAttribute("required")){const r=n.getAttribute("required");if(r){const n=vt(r,t.node,this);t.required=n,this.formElement.addToRefresh(t),t.node.textContent||(e=!1)}}}})),console.log("modelItems after revalidate: ",this.modelItems),e}addChanged(e){this.inited&&this.changed.push(e)}getModelItem(e){return this.modelItems.find((t=>t.node===e))}getDefaultContext(){return this.instances[0].getDefaultContext()}getDefaultInstance(){return this?.instances[0]}getDefaultInstanceData(){return console.log("default instance data ",this.instances[0].instanceData),this.instances[0].instanceData}getInstance(e){const t=Array.from(this.instances).find((t=>t.id===e));return t||this.getDefaultInstance()}evalBinding(e){return this.instances[0].evalXPath(e)}}Dt.dataChanged=!1,customElements.get("fx-model")||customElements.define("fx-model",Dt);const kt=e=>class extends e{static get properties(){return{context:{type:Object},model:{type:Object},modelItem:{type:Object},nodeset:{type:Object},ref:{type:String},inScopeVariables:{type:Map}}}constructor(){super(),this.context=null,this.model=null,this.modelItem={},this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):"",this.inScopeVariables=new Map}getModel(){if(this.model)return this.model;return this.getOwnerForm().querySelector("fx-model")}getOwnerForm(){let e=this;for(;e&&e.parentNode;){if("FX-FORE"===e.nodeName.toUpperCase())return e;e=e.parentNode instanceof DocumentFragment?e.parentNode.host:e.parentNode}return e}evalInContext(){if(!this.getModel())return;let e;if(this.hasAttribute("context")&&(e=Ct(this.getAttributeNode("context")||this,this.context)),this.hasAttribute("ref")&&(e=Ct(this.getAttributeNode("ref")||this,this.ref)),e||0===this.getModel().instances.length||(e=this.getModel().getDefaultInstance().getDefaultContext()),""===this.ref)this.nodeset=e;else if(Array.isArray(e))this.nodeset=gt(this.ref,e[0],this);else{if(!e)return;const{nodeType:t}=e;t&&!et.isAbsolutePath(this.ref)?this.nodeset=yt(this.ref,e,this):[this.nodeset]=gt(this.ref,e,this)}}evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{const r=n.substring(1,n.length-1),a=xt(r,Ct(t,r),this),o=e.replaceAll(n,a);e=o})),e}isNotBound(){return!this.hasAttribute("ref")}isBound(){return this.hasAttribute("ref")}getBindingExpr(){if(this.hasAttribute("ref"))return this.getAttribute("ref");const e=et.getClosest("[ref]",this.parentNode);return e?e.getAttribute("ref"):"instance()"}getInstance(){if(this.ref.startsWith("instance(")){const e=et.getInstanceId(this.ref);return this.getModel().getInstance(e)}return this.getModel().getInstance("default")}_getParentBindingElement(e){if(e.parentNode.host){const{host:t}=e.parentNode;if(t.hasAttribute("ref"))return t}else if(e.parentNode){if(e.parentNode.hasAttribute("ref"))return this.parentNode;this._getParentBindingElement(this.parentNode)}return null}getModelItem(){const e=this.getModel().getModelItem(this.nodeset);e&&(this.modelItem=e);const t=et.getClosest("fx-repeatitem",this);let n;if(t){const{index:e}=t;n=Array.isArray(this.nodeset)?this.getModel().getModelItem(this.nodeset[e-1]):this.getModel().getModelItem(this.nodeset)}else n=this.getModel().getModelItem(this.nodeset);return n||Dt.lazyCreateModelItem(this.getModel(),this.ref,this.nodeset)}getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return xt(e,Ct(this,e),this.getOwnerForm())}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}getInScopeContext(){return Ct(this.getAttributeNode("ref")||this,this.ref)}setInScopeVariables(e){this.inScopeVariables=e}};class Rt extends(kt(HTMLElement)){constructor(){super(),this.nodeset=[],this.model={},this.contextNode={},this.inited=!1}connectedCallback(){this.ref=this.getAttribute("ref"),this.readonly=this.getAttribute("readonly"),this.required=this.getAttribute("required"),this.relevant=this.getAttribute("relevant"),this.type=this.hasAttribute("type")?this.getAttribute("type"):Rt.TYPE_DEFAULT,this.calculate=this.getAttribute("calculate")}init(e){this.model=e,this.instanceId=this._getInstanceId(),this.bindType=this.getModel().getInstance(this.instanceId).type,"xml"===this.bindType&&(this._evalInContext(),this._buildBindGraph(),this._createModelItems()),this._processChildren(e)}_buildBindGraph(){"xml"===this.bindType&&this.nodeset.forEach((e=>{const t=et.getPath(e);this.model.mainGraph.addNode(t,e),this.calculate&&(this.model.mainGraph.addNode(`${t}:calculate`,e),this.model.mainGraph.addDependency(t,`${t}:calculate`));const n=this._getReferencesForProperty(this.calculate,e);if(0!==n.length&&this._addDependencies(n,e,t,"calculate"),!this.calculate){const n=this._getReferencesForProperty(this.readonly,e);0!==n.length?this._addDependencies(n,e,t,"readonly"):this.readonly&&this.model.mainGraph.addNode(`${t}:readonly`,e)}const r=this._getReferencesForProperty(this.required,e);0!==r.length?this._addDependencies(r,e,t,"required"):this.required&&this.model.mainGraph.addNode(`${t}:required`,e);const a=this._getReferencesForProperty(this.relevant,e);0!==a.length?this._addDependencies(a,e,t,"relevant"):this.relevant&&this.model.mainGraph.addNode(`${t}:relevant`,e);const o=this._getReferencesForProperty(this.constraint,e);0!==o.length?this._addDependencies(o,e,t,"constraint"):this.constraint&&this.model.mainGraph.addNode(`${t}:constraint`,e)}))}_addDependencies(e,t,n,r){const a=`${n}:${r}`;0!==e.length?(this.model.mainGraph.hasNode(a)||this.model.mainGraph.addNode(a,t),e.forEach((e=>{const t=et.getPath(e);t.endsWith("text()[1]")||(this.model.mainGraph.hasNode(t)||this.model.mainGraph.addNode(t,e),this.model.mainGraph.addDependency(a,t))}))):this.model.mainGraph.addNode(a,t)}_processChildren(e){const t=this.querySelectorAll(":scope > fx-bind");Array.from(t).forEach((t=>{t.init(e)}))}getAlert(){if(this.hasAttribute("alert"))return this.getAttribute("alert");const e=this.querySelector("fx-alert");return e?e.innerHTML:null}_evalInContext(){const e=Ct(this.getAttributeNode("ref")||this,this.ref);if(this.nodeset=[],""===this.ref||null===this.ref)this.nodeset=e;else if(Array.isArray(e))e.forEach((t=>{if(et.isSelfReference(this.ref))this.nodeset=e;else if(this.ref){wt(this.ref,t,this).forEach((e=>{this.nodeset.push(e)}))}}));else{"xml"===this.getModel().getInstance(this.instanceId).type?this.nodeset=wt(this.ref,e,this):this.nodeset=this.ref}}_createModelItems(){Array.isArray(this.nodeset)?Array.from(this.nodeset).forEach((e=>{this._createModelItem(e)})):this._createModelItem(this.nodeset)}_createModelItem(e){if(et.isSelfReference(this.ref)){const e=et.getClosest("fx-bind[ref]",this.parentElement);return void(e?e.required=this.required:console.error("no parent bound element"))}const t=e,n=et.getPath(e),r=new Ft(n,this.getBindingExpr(),Rt.READONLY_DEFAULT,Rt.RELEVANT_DEFAULT,Rt.REQUIRED_DEFAULT,Rt.CONSTRAINT_DEFAULT,this.type,t,this),a=this.getAlert();a&&r.addAlert(a),this.getModel().registerModelItem(r)}_getReferencesForProperty(e){return e?this.getReferences(e):[]}getReferences(e){const t=new Set,n=new Ze((e=>t.add(e)));return this.nodeset.forEach((t=>{xt(e,t,this,n)})),Array.from(t.values())}_initBooleanModelItemProperty(e,t){return vt(this[e],t,this)}static shortenPath(e){const t=e.split("/");let n="";for(let e=2;e<t.length;e+=1){const r=t[e];if(-1!==r.indexOf("{}")){n+=`/${r.split("{}")[1]}`}else n+=`/${r}`}return n}_getInstanceId(){const e=this.getBindingExpr();return e.startsWith("instance(")?(this.instanceId=et.getInstanceId(e),this.instanceId):this.instanceId?this.instanceId:"default"}}Rt.READONLY_DEFAULT=!1,Rt.REQUIRED_DEFAULT=!1,Rt.RELEVANT_DEFAULT=!0,Rt.CONSTRAINT_DEFAULT=!0,Rt.TYPE_DEFAULT="xs:string",customElements.get("fx-bind")||customElements.define("fx-bind",Rt)
|
|
2
2
|
/*!
|
|
3
3
|
* Toastify js 1.11.2
|
|
4
4
|
* https://github.com/apvarun/toastify-js
|
|
5
5
|
* @license MIT licensed
|
|
6
6
|
*
|
|
7
7
|
* Copyright (C) 2018 Varun A P
|
|
8
|
-
*/;class Dt{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="✖",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,o="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${o})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},o=this._rootElement.querySelectorAll(".toastify");for(let i=0;i<o.length;i++){e=!0===o[i].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let a=o[i].offsetHeight;e=e.substr(9,e.length-1);let s=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(o[i].style[e]=`${r[e]}px`,r[e]+=a+s):!0===o[i].classList.contains("toastify-left")?(o[i].style[e]=`${t[e]}px`,t[e]+=a+s):(o[i].style[e]=`${n[e]}px`,n[e]+=a+s)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function Ut(e){return new Dt(e)}class Mt extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup",!0),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow",!1),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst",!0),this.position=this._initVar("position","right"),this.stopOnFocus=this._initVar("stopOnFocus",!0),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new Ut({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",Mt);class kt extends(Ot(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){console.log("connectedCallback",this),this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{console.log("handle index event ",e);const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;console.log("handle index event ",e);const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if(console.log("mutations",e),"childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=et.getPath(t);console.log("path mutated",e),rt.dispatch(this,"path-mutated",{path:e,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{console.log("##### repeat-attributes init ",this.id),this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=St(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=mt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),console.time("repeat-refresh",this),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const o=r;if(o<n)for(let e=n;e>o;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(o>n)for(let e=n+1;e<=o;e+=1){const t=this._clone();this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||rt.refreshChildren(this,e),this.setIndex(this.index),console.timeEnd("repeat-refresh"),console.groupEnd()}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),console.log("### init template for repeat ",this.id,this.template),null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){return this.template=this.shadowRoot.querySelector("template"),this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",kt);class Ft extends HTMLElement{static get properties(){return{lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean}}}constructor(){super(),this.model={},this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._displayError),window.addEventListener("compute-exception",(e=>{console.error("circular dependency: ",e)})),this.ready=!1,this.storedTemplateExpressionByNode=new Map;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n \n </style>\n \n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="left" gravity="bottom"></jinn-toast>\n <slot></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>×</a>\n <div id="messageContent"></div>\n </div>\n </div>\n \n ',this.toRefresh=[],this.initialRun=!0,this.someInstanceDataStructureChanged=!1,this.repeatsFromAttributesCreated=!1}connectedCallback(){if(this.style.visibility="hidden",console.time("init"),this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this.shadowRoot.querySelector("slot").addEventListener("slotchange",(async e=>{if(this.hasAttribute("convert"))return void this.replaceWith(rt.copyDom(this));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");this.appendChild(e),t=e}t.inited||(console.info(`%cFore is processing URL ${window.location.href}`,"background:#64b5f6; color:white; padding:1rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;"),this.src&&console.log("########## FORE: loaded from ... ",this.src,"##########"),await t.modelConstruct(),this._handleModelConstructDone()),this.model=t,this._createRepeatsFromAttributes()})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0}))}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}_loadFromSrc(){console.log("########## loading Fore from ",this.src,"##########"),fetch(this.src,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":"text/html"}}).then((e=>{const t=e.headers.get("content-type").toLowerCase();return console.log("********** responseContentType *********",t),t.startsWith("text/html")?e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done"})).then((e=>{const t=e.querySelector("fx-fore");t||rt.dispatch(this,"error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),t.setAttribute("from-src",this.src),this.replaceWith(t)})).catch((()=>{rt.dispatch(this,"error",{message:`'${this.src}' not found or does not contain Fore element.`})}))}handleIntersect(e,t){console.time("refreshLazy"),e.forEach((e=>{const{target:t}=e;rt.getFore(t).initialRun||e.isIntersecting&&(console.log("in view",e),t.classList.add("loaded"),"function"==typeof t.refresh?(console.log("refreshing target",t),t.refresh(t,!0)):(console.log("refreshing children",t),rt.refreshChildren(t,!0)))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done")),console.timeEnd("refreshLazy")}evaluateToNodes(e,t){return yt(e,t,this)}disconnectedCallback(){}async forceRefresh(){console.time("refresh"),console.group("### forced refresh",this),rt.refreshChildren(this,!0),this._updateTemplateExpressions(),this.someInstanceDataStructureChanged=!1,this._processTemplateExpressions(),rt.dispatch(this,"refresh-done",{}),console.groupEnd(),console.timeEnd("refresh")}async refresh(e){if(console.info("%crefresh","font-style: italic; background: #8bc34a; color:white; padding:0.3rem 5rem 0.3rem 0.3rem; display:block; width:100%;"),console.group("refresh",e),console.time("refresh"),console.log("toRefresh",this.toRefresh),e||this.initialRun||0===this.toRefresh.length)rt.refreshChildren(this,!0);else{let t=!1;this.toRefresh.forEach((n=>{const r=n.boundControls;r&&r.forEach((t=>{t.refresh(e)}));const{mainGraph:o}=this.getModel();if(o&&o.hasNode(n.path)){const r=this.getModel().mainGraph.dependentsOf(n.path,!1);0!==r.length&&(r.forEach((t=>{const n=et.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))})),t=!0)}})),this.toRefresh=[],t||console.log("no dependants to refresh")}(this.initialRun||this.someInstanceDataStructureChanged)&&(this._updateTemplateExpressions(),this.someInstanceDataStructureChanged=!1),this._processTemplateExpressions(),console.timeEnd("refresh"),console.groupEnd(),this.style.visibility="visible",rt.dispatch(this,"refresh-done",{})}_updateTemplateExpressions(){const e=yt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!e.ownerDocument.contains(e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!e.ownerDocument.contains(e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=St(t,n);if(!r){const n=t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE?t.parentNode:t;return console.warn("no inscope context for ",n),e}const o=et.getInstanceId(n),i=this.getModel().getInstance(o);try{return wt(n,r,t,null,i)}catch(t){return console.log("ignoring unparseable expr"),e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){t.ownerElement.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&(t.textContent=n)}_getTemplateExpression(e){return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){if(this.hasAttribute("show-confirmation")){const e=this.getAttribute("show-confirmation");e&&"show-confirmation"!==e&&"true"!==e&&""!==e?window.addEventListener("beforeunload",(t=>{if(vt(e,this.getModel().getDefaultContext(),this))return console.log("have to display confirmation"),t.returnValue="are you sure";t.preventDefault(),console.log("do not display confirmation")})):window.addEventListener("beforeunload",(e=>{if(Tt.dataChanged)return console.log("have to display confirmation"),e.returnValue="are you sure";e.preventDefault(),console.log("do not display confirmation")}))}this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model");if(0===e.instances.length){console.log("### lazy creation of instance");const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t),console.log("generatedInstance ",this.getModel().getDefaultInstanceData())}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!rt.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){console.log("complex path to create ",n);n.split("/").forEach((n=>{console.log("step ",n),t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){if(console.log("### _initUI()"),!this.initialRun)return;await this._lazyCreateInstance();const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,rt.dispatch(this,"ready",{}),console.info("%cPage Initialization done","background:#64b5f6; color:white; padding:1rem; display:block; white-space: nowrap; border-radius:0.3rem;width:100%;"),console.timeEnd("init"),console.log("dataChanged",Tt.dataChanged)}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e)this.shadowRoot.querySelector("#sticky").showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new kt;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}customElements.get("fx-fore")||customElements.define("fx-fore",Ft);class Gt{static selectRelevant(e,t){return"xml"===t?Gt._relevantXmlNodes(e):(console.warn(`relevance selection not supported for type:${e.type}`),e.nodeset)}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&Gt._isRelevant(e,e.nodeset)?e.nodeset:Gt._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(Gt._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:o}=t;return o&&Array.from(o).forEach((t=>{Gt._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):"empty"===e.nonrelevant?r.setAttribute(t.nodeName,""):r.removeAttribute(t.nodeName)})),Gt._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return!(n&&!n.relevant)}}class Pt extends(Ot(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id")||console.warn("id is required"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.hasAttribute("url")||console.warn(`url is required for submission: ${this.id}`),this.url=this.getAttribute("url"),this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await rt.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){console.log("submitting....",this.getAttribute("id")),this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate){if(!e.revalidate())return console.log("validation failed. Submission stopped"),this.getOwnerForm().classList.add("submit-validation-failed"),rt.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}console.log("model updated...."),await this._serializeAndSend()}_evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{console.log("match ",n);const r=n.substring(1,n.length-1),o=wt(r,St(t,r),this.getOwnerForm()),i=e.replaceAll(n,o);console.log("replacing ",e," with ",i),e=i})),e}async _serializeAndSend(){const e=this._evaluateAttributeTemplateExpression(this.url,this),t=this.getInstance();let n;if(console.log("instance type",t.type),"none"===this.serialization)n=void 0;else{const e=Gt.selectRelevant(this,t.type);n=this._serialize(t.type,e)}if("get"===this.method.toLowerCase()&&(n=void 0),e.startsWith("#echo")){const e=this._parse(n,t);return this._handleResponse(e),void rt.dispatch(this,"submit-done",{})}if(e.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const n=e.substring(e.indexOf(":")+1),r=localStorage.getItem(n);if(!r)return void rt.dispatch(this,"submit-error",{message:`Error reading key ${n} from localstorage`});let o=this._parse(r,t);this._handleResponse(o),"consume"===this.method&&localStorage.removeItem(n),rt.dispatch(this,"submit-done",{})}if("post"===this.method){const r=e.substring(e.indexOf(":")+1);localStorage.setItem(r,n),this._handleResponse(t.instanceData),rt.dispatch(this,"submit-done",{})}if("delete"===this.method){const t=e.substring(e.indexOf(":")+1);localStorage.removeItem(t);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this._handleResponse(n),rt.dispatch(this,"submit-done",{})}return}const r=this._getHeaders();if(console.log("headers",r),this.methods.includes(this.method.toLowerCase()))try{const t=await fetch(e,{method:this.method,mode:"cors",credentials:"include",headers:r,body:n});if(!t.ok||t.status>400)return void rt.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const o=t.headers.get("content-type").toLowerCase();if(o.startsWith("text/plain")||o.startsWith("text/html")||o.startsWith("text/markdown")){const e=await t.text();this._handleResponse(e)}else if(o.startsWith("application/json")){const e=await t.json();this._handleResponse(e)}else if(o.startsWith("application/xml")){const e=await t.text(),n=(new DOMParser).parseFromString(e,"application/xml");this._handleResponse(n)}else{const e=await t.blob();this._handleResponse(e)}rt.dispatch(this,"submit-done",{})}catch(e){rt.dispatch(this,"submit-error",{error:e.message})}else rt.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.type&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.type&&(n=JSON.parse(e)),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=rt.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e){if(console.log("_handleResponse ",e),"instance"===this.replace){const t=this._getTargetInstance();if(!t)throw new Error(`target instance not found: ${t}`);if(this.targetref){const[n]=mt(this.targetref,t.instanceData.firstElementChild,this);console.log("theTarget",n);const r=e.firstElementChild,o=n.parentNode;o.replaceChild(r,n),console.log("finally ",o)}else if(this.into){const[n]=mt(this.into,t.instanceData.firstElementChild,this);console.log("theTarget",n),e.nodeType===Node.DOCUMENT_NODE?n.appendChild(e.firstElementChild):n.innerHTML=e}else{const n=e;t.instanceData=n,console.log("### replaced instance ",this.getModel().instances),console.log("### replaced instance ",t.instanceData)}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("all"===this.replace&&(document.getElementsByTagName("html")[0].innerHTML=e),"target"===this.replace){const t=this.getAttribute("target");document.querySelector(t).innerHTML=e}"redirect"===this.replace&&(window.location.href=e)}_handleError(){rt.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",Pt);class Ht extends(Ot(HTMLElement)){constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",Ht);class _t extends(Ot(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=St(this,this.valueQuery),t=mt(this.valueQuery,e,this,this.precedingVariables);[this.value]=t}setInScopeVariables(e){if(e.has(this.name))return console.error(`The variable ${this.name} is declared more than once`),void rt.dispatch(this,"xforms-binding-error",{});e.set(this.name,this),this.inScopeVariables=new Map(e)}}customElements.get("fx-var")||customElements.define("fx-var",_t);class jt extends(Ot(HTMLElement)){constructor(){super(),this.value="",this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset)return void(this.style.display="none");if(this.modelItem=this.getModelItem(),this.modelItem instanceof Bt){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),!this.getOwnerForm().ready)return;t!==this.value&&rt.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&rt.dispatch(this,e,{})}handleRequired(){if(this.widget=this.getWidget(),!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(this.isRequired()!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this.isRequired()!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.querySelector("fx-alert"),this.getModelItem(),this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void(this.style.display="none");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.style.display=this.display):(this._dispatchEvent("nonrelevant"),this.style.display="none"))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",jt);class Xt extends jt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){console.log("alert update",this),this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",Xt);class Lt extends jt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):"value",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget();let e=this.widget;if(this.hasAttribute("listen-on")){const t=this.getAttribute("listen-on"),n=this.querySelector(t);n&&(e=n)}this.addEventListener("keyup",(e=>{Tt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this.widget[this.valueProp]))})),this.updateEvent="blur"),this.debounceDelay?e.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...o)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,o)}),n)}}(this,(()=>{this.setValue(this.widget[this.valueProp])}),this.debounceDelay)):e.addEventListener(this.updateEvent,(()=>{this.setValue(this.widget[this.valueProp])})),this.addEventListener("return",(e=>{console.log("catched return action on ",this),console.log("return detail",e.detail),console.log("return triggered on ",this),console.log("this.ref",this.ref),console.log("current outer instance",this.getInstance()),console.log("???? why ???? current nodeset should point to the node of the outer control",e.currentTarget.nodeset),console.log("???? why ???? current nodeset should point to the node of the outer control",this.nodeset);const t=e.detail.nodeset;console.log("new nodeset",t),console.log("currentTarget",e.currentTarget),console.log("target",e.target),e.stopPropagation(),this._replaceNode(t)})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const o=this;clearTimeout(n),n=setTimeout((()=>{e.apply(o,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.classList.add("visited"),t?.readonly)return void console.warn("attempt to change readonly node",t);if("node"===this.getAttribute("as")){const e=this.getWidget().value,n=this.shadowRoot.getElementById("replace");return n.replace(this.nodeset,this.getWidget().value),void(t&&e&&e!==t.value&&(t.value=e,Tt.dataChanged=!0,n.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof Bt&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed(),this.visited=!0}_replaceNode(e){this.modelItem.node.replaceWith(e.cloneNode(!0)),this.getOwnerForm().refresh()}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=rt.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return console.log("changed"),void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.url&&!this.loaded)return this.initial&&(this.initialNode=gt(this.initial,this.nodeset,this),console.log("initialNodes",this.initialNode)),await this._loadForeFromUrl(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromUrl(){console.log("########## loading Fore from ",this.url,"##########"),console.info(`%cFore is processing URL ${this.url}`,"background:#64b5f6; color:white; padding:1rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;");try{const e=await fetch(this.url,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":"text/html"}}),t=e.headers.get("content-type").toLowerCase();let n;console.log("********** responseContentType *********",t),n=t.startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const r=n.querySelector("fx-fore"),o=document.importNode(r,!0);o.classList.add("widget"),console.log(`########## loaded fore as component ##### ${this.url}`),o.addEventListener("model-construct-done",(e=>{console.log("subcomponent ready",e.target);const t=o.querySelector("fx-instance");if(this.initialNode){const e=(new DOMParser).parseFromString("<data></data>","application/xml");e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.setInstanceData(e)}o.getModel().updateModel(),o.refresh()}),{once:!0});const i=this.querySelector("input");this.hasAttribute("shadow")?(i.parentNode.removeChild(i),this.shadowRoot.appendChild(o)):(console.log(this,"replacing widget with",r),i.replaceWith(o)),r||this.dispatchEvent(new CustomEvent("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}})),console.log("loaded"),this.dispatchEvent(new CustomEvent("loaded",{detail:{fore:r}}))}catch(e){console.log("error",e),this.getOwnerForm().dispatchEvent(new CustomEvent("error",{detail:{message:`${this.url} not found`}}))}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),rt.refreshChildren(this,e)}_handleBoundWidget(e){if((!this.boundInitialized||!this.static)&&e&&e.hasAttribute("ref")){const t=e.getAttribute("ref"),n=mt(t,St(this,t),this);if(Array.isArray(n)&&0===n.length)return;const{children:r}=e;if(Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)})),this.template){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}}}updateEntry(e,t){if("SELECT"!==this.widget.nodeName)return;const n=this._getValueAttribute(e),r=n.value,o=wt(r.substring(1,r.length-1),t,e);n.value=o,this.value===o&&e.setAttribute("selected","selected");const i=e.textContent,a=wt(i.substring(1,i.length-1),t,e);e.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",Lt);class $t extends(Ot(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return console.log("container is not relevant"),this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",$t)
|
|
9
|
-
/**
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright 2019 Google LLC
|
|
12
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/;const qt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vt=Symbol(),Yt=new Map;class Qt{constructor(e,t){if(this._$cssResult$=!0,t!==Vt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){let e=Yt.get(this.cssText);return qt&&void 0===e&&(Yt.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const Jt=(e,...t)=>{const n=1===e.length?e[0]:t.reduce(((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[r+1]),e[0]);return new Qt(n,Vt)},zt=qt?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new Qt("string"==typeof e?e:e+"",Vt))(t)})(e):e
|
|
14
|
-
/**
|
|
15
|
-
* @license
|
|
16
|
-
* Copyright 2017 Google LLC
|
|
17
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
-
*/;var Kt;const Wt=window.trustedTypes,Zt=Wt?Wt.emptyScript:"",en=window.reactiveElementPolyfillSupport,tn={toAttribute(e,t){switch(t){case Boolean:e=e?Zt:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},nn=(e,t)=>t!==e&&(t==t||e==e),rn={attribute:!0,type:String,converter:tn,reflect:!1,hasChanged:nn};class on extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(e){var t;null!==(t=this.l)&&void 0!==t||(this.l=[]),this.l.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,n)=>{const r=this._$Eh(n,t);void 0!==r&&(this._$Eu.set(r,n),e.push(r))})),e}static createProperty(e,t=rn){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const n="symbol"==typeof e?Symbol():"__"+e,r=this.getPropertyDescriptor(e,n,t);void 0!==r&&Object.defineProperty(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(r){const o=this[e];this[t]=r,this.requestUpdate(e,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||rn}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const n of t)this.createProperty(n,e[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(zt(e))}else void 0!==e&&t.push(zt(e));return t}static _$Eh(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}o(){var e;this._$Ep=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,n;(null!==(t=this._$Eg)&&void 0!==t?t:this._$Eg=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}removeController(e){var t;null===(t=this._$Eg)||void 0===t||t.splice(this._$Eg.indexOf(e)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Et.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{qt?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style"),r=window.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=t.cssText,e.appendChild(n)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ES(e,t,n=rn){var r,o;const i=this.constructor._$Eh(e,n);if(void 0!==i&&!0===n.reflect){const a=(null!==(o=null===(r=n.converter)||void 0===r?void 0:r.toAttribute)&&void 0!==o?o:tn.toAttribute)(t,n.type);this._$Ei=e,null==a?this.removeAttribute(i):this.setAttribute(i,a),this._$Ei=null}}_$AK(e,t){var n,r,o;const i=this.constructor,a=i._$Eu.get(e);if(void 0!==a&&this._$Ei!==a){const e=i.getPropertyOptions(a),s=e.converter,u=null!==(o=null!==(r=null===(n=s)||void 0===n?void 0:n.fromAttribute)&&void 0!==r?r:"function"==typeof s?s:null)&&void 0!==o?o:tn.fromAttribute;this._$Ei=a,this[a]=u(t,e.type),this._$Ei=null}}requestUpdate(e,t,n){let r=!0;void 0!==e&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||nn)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$Ei!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,n))):r=!1),!this.isUpdatePending&&r&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((e,t)=>this[t]=e)),this._$Et=void 0);let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(n)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;null===(t=this._$Eg)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$ES(t,this[t],e))),this._$EC=void 0),this._$EU()}updated(e){}firstUpdated(e){}}
|
|
19
|
-
/**
|
|
20
|
-
* @license
|
|
21
|
-
* Copyright 2017 Google LLC
|
|
22
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/
|
|
24
|
-
var an;on.finalized=!0,on.elementProperties=new Map,on.elementStyles=[],on.shadowRootOptions={mode:"open"},null==en||en({ReactiveElement:on}),(null!==(Kt=globalThis.reactiveElementVersions)&&void 0!==Kt?Kt:globalThis.reactiveElementVersions=[]).push("1.3.2");const sn=globalThis.trustedTypes,un=sn?sn.createPolicy("lit-html",{createHTML:e=>e}):void 0,cn=`lit$${(Math.random()+"").slice(9)}$`,ln="?"+cn,pn=`<${ln}>`,hn=document,fn=(e="")=>hn.createComment(e),dn=e=>null===e||"object"!=typeof e&&"function"!=typeof e,mn=Array.isArray,gn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,yn=/-->/g,vn=/>/g,wn=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,An=/'/g,xn=/"/g,bn=/^(?:script|style|textarea|title)$/i,En=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),Nn=Symbol.for("lit-noChange"),Bn=Symbol.for("lit-nothing"),Tn=new WeakMap,In=hn.createTreeWalker(hn,129,null,!1),Cn=(e,t)=>{const n=e.length-1,r=[];let o,i=2===t?"<svg>":"",a=gn;for(let t=0;t<n;t++){const n=e[t];let s,u,c=-1,l=0;for(;l<n.length&&(a.lastIndex=l,u=a.exec(n),null!==u);)l=a.lastIndex,a===gn?"!--"===u[1]?a=yn:void 0!==u[1]?a=vn:void 0!==u[2]?(bn.test(u[2])&&(o=RegExp("</"+u[2],"g")),a=wn):void 0!==u[3]&&(a=wn):a===wn?">"===u[0]?(a=null!=o?o:gn,c=-1):void 0===u[1]?c=-2:(c=a.lastIndex-u[2].length,s=u[1],a=void 0===u[3]?wn:'"'===u[3]?xn:An):a===xn||a===An?a=wn:a===yn||a===vn?a=gn:(a=wn,o=void 0);const p=a===wn&&e[t+1].startsWith("/>")?" ":"";i+=a===gn?n+pn:c>=0?(r.push(s),n.slice(0,c)+"$lit$"+n.slice(c)+cn+p):n+cn+(-2===c?(r.push(void 0),t):p)}const s=i+(e[n]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==un?un.createHTML(s):s,r]};class Sn{constructor({strings:e,_$litType$:t},n){let r;this.parts=[];let o=0,i=0;const a=e.length-1,s=this.parts,[u,c]=Cn(e,t);if(this.el=Sn.createElement(u,n),In.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(r=In.nextNode())&&s.length<a;){if(1===r.nodeType){if(r.hasAttributes()){const e=[];for(const t of r.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(cn)){const n=c[i++];if(e.push(t),void 0!==n){const e=r.getAttribute(n.toLowerCase()+"$lit$").split(cn),t=/([.?@])?(.*)/.exec(n);s.push({type:1,index:o,name:t[2],strings:e,ctor:"."===t[1]?Mn:"?"===t[1]?Fn:"@"===t[1]?Gn:Un})}else s.push({type:6,index:o})}for(const t of e)r.removeAttribute(t)}if(bn.test(r.tagName)){const e=r.textContent.split(cn),t=e.length-1;if(t>0){r.textContent=sn?sn.emptyScript:"";for(let n=0;n<t;n++)r.append(e[n],fn()),In.nextNode(),s.push({type:2,index:++o});r.append(e[t],fn())}}}else if(8===r.nodeType)if(r.data===ln)s.push({type:2,index:o});else{let e=-1;for(;-1!==(e=r.data.indexOf(cn,e+1));)s.push({type:7,index:o}),e+=cn.length-1}o++}}static createElement(e,t){const n=hn.createElement("template");return n.innerHTML=e,n}}function On(e,t,n=e,r){var o,i,a,s;if(t===Nn)return t;let u=void 0!==r?null===(o=n._$Cl)||void 0===o?void 0:o[r]:n._$Cu;const c=dn(t)?void 0:t._$litDirective$;return(null==u?void 0:u.constructor)!==c&&(null===(i=null==u?void 0:u._$AO)||void 0===i||i.call(u,!1),void 0===c?u=void 0:(u=new c(e),u._$AT(e,n,r)),void 0!==r?(null!==(a=(s=n)._$Cl)&&void 0!==a?a:s._$Cl=[])[r]=u:n._$Cu=u),void 0!==u&&(t=On(e,u._$AS(e,t.values),u,r)),t}class Rn{constructor(e,t){this.v=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(e){var t;const{el:{content:n},parts:r}=this._$AD,o=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:hn).importNode(n,!0);In.currentNode=o;let i=In.nextNode(),a=0,s=0,u=r[0];for(;void 0!==u;){if(a===u.index){let t;2===u.type?t=new Dn(i,i.nextSibling,this,e):1===u.type?t=new u.ctor(i,u.name,u.strings,this,e):6===u.type&&(t=new Pn(i,this,e)),this.v.push(t),u=r[++s]}a!==(null==u?void 0:u.index)&&(i=In.nextNode(),a++)}return o}m(e){let t=0;for(const n of this.v)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class Dn{constructor(e,t,n,r){var o;this.type=2,this._$AH=Bn,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cg=null===(o=null==r?void 0:r.isConnected)||void 0===o||o}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cg}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=On(this,e,t),dn(e)?e===Bn||null==e||""===e?(this._$AH!==Bn&&this._$AR(),this._$AH=Bn):e!==this._$AH&&e!==Nn&&this.$(e):void 0!==e._$litType$?this.T(e):void 0!==e.nodeType?this.k(e):(e=>{var t;return mn(e)||"function"==typeof(null===(t=e)||void 0===t?void 0:t[Symbol.iterator])})(e)?this.S(e):this.$(e)}M(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.M(e))}$(e){this._$AH!==Bn&&dn(this._$AH)?this._$AA.nextSibling.data=e:this.k(hn.createTextNode(e)),this._$AH=e}T(e){var t;const{values:n,_$litType$:r}=e,o="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=Sn.createElement(r.h,this.options)),r);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.m(n);else{const e=new Rn(o,this),t=e.p(this.options);e.m(n),this.k(t),this._$AH=e}}_$AC(e){let t=Tn.get(e.strings);return void 0===t&&Tn.set(e.strings,t=new Sn(e)),t}S(e){mn(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,r=0;for(const o of e)r===t.length?t.push(n=new Dn(this.M(fn()),this.M(fn()),this,this.options)):n=t[r],n._$AI(o),r++;r<t.length&&(this._$AR(n&&n._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cg=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class Un{constructor(e,t,n,r,o){this.type=1,this._$AH=Bn,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Bn}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,n,r){const o=this.strings;let i=!1;if(void 0===o)e=On(this,e,t,0),i=!dn(e)||e!==this._$AH&&e!==Nn,i&&(this._$AH=e);else{const r=e;let a,s;for(e=o[0],a=0;a<o.length-1;a++)s=On(this,r[n+a],t,a),s===Nn&&(s=this._$AH[a]),i||(i=!dn(s)||s!==this._$AH[a]),s===Bn?e=Bn:e!==Bn&&(e+=(null!=s?s:"")+o[a+1]),this._$AH[a]=s}i&&!r&&this.C(e)}C(e){e===Bn?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class Mn extends Un{constructor(){super(...arguments),this.type=3}C(e){this.element[this.name]=e===Bn?void 0:e}}const kn=sn?sn.emptyScript:"";class Fn extends Un{constructor(){super(...arguments),this.type=4}C(e){e&&e!==Bn?this.element.setAttribute(this.name,kn):this.element.removeAttribute(this.name)}}class Gn extends Un{constructor(e,t,n,r,o){super(e,t,n,r,o),this.type=5}_$AI(e,t=this){var n;if((e=null!==(n=On(this,e,t,0))&&void 0!==n?n:Bn)===Nn)return;const r=this._$AH,o=e===Bn&&r!==Bn||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==Bn&&(r===Bn||o);o&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class Pn{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){On(this,e)}}const Hn=window.litHtmlPolyfillSupport;
|
|
25
|
-
/**
|
|
26
|
-
* @license
|
|
27
|
-
* Copyright 2017 Google LLC
|
|
28
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
29
|
-
*/
|
|
30
|
-
var _n,jn;null==Hn||Hn(Sn,Dn),(null!==(an=globalThis.litHtmlVersions)&&void 0!==an?an:globalThis.litHtmlVersions=[]).push("2.2.5");class Xn extends on{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Dt=((e,t,n)=>{var r,o;const i=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:t;let a=i._$litPart$;if(void 0===a){const e=null!==(o=null==n?void 0:n.renderBefore)&&void 0!==o?o:null;i._$litPart$=a=new Dn(t.insertBefore(fn(),e),e,void 0,null!=n?n:{})}return a._$AI(e),a})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Dt)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Dt)||void 0===e||e.setConnected(!1)}render(){return Nn}}Xn.finalized=!0,Xn._$litElement$=!0,null===(_n=globalThis.litElementHydrateSupport)||void 0===_n||_n.call(globalThis,{LitElement:Xn});const Ln=globalThis.litElementPolyfillSupport;
|
|
31
|
-
/**
|
|
32
|
-
* @license
|
|
33
|
-
* Copyright 2021 Google LLC
|
|
34
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
35
|
-
*/
|
|
36
|
-
var $n;null==Ln||Ln({LitElement:Xn}),(null!==(jn=globalThis.litElementVersions)&&void 0!==jn?jn:globalThis.litElementVersions=[]).push("3.2.0"),null===($n=window.HTMLSlotElement)||void 0===$n||$n.prototype.assignedElements,
|
|
37
|
-
/**
|
|
38
|
-
* @license
|
|
39
|
-
* Copyright 2017 Google LLC
|
|
40
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
41
|
-
*/
|
|
42
|
-
console.warn("The main 'lit-element' module entrypoint is deprecated. Please update your imports to use the 'lit' package: 'lit' and 'lit/decorators.ts' or import from 'lit-element/lit-element.ts'. See https://lit.dev/msg/deprecated-import-path for more information.");class qn extends $t{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}render(){return En`<slot></slot>`}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){const t=Array.from(e.children);console.log("_initializeChildren ",t),t.forEach((e=>{if(console.log("child ",e),rt.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}})),console.groupEnd()}async refresh(e){super.refresh(e),rt.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",qn);class Vn extends jt{static get styles(){return Jt`:host{display:block;height:auto;font-size:.8em;font-weight:400;font-style:italic}`}static get properties(){return{...super.properties}}render(){return En`<slot></slot>`}}customElements.get("fx-hint")||customElements.define("fx-hint",Vn);class Yn extends jt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n table,tbody{\n width:100%;\n }\n th{\n text-align:left;\n }\n td{\n padding-right:1rem;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=St(this,this.valueAttr);return this.hasAttribute("html")?mt(this.valueAttr,e,this)[0]:function(e,t,n,r=null,o=n){const i=ht(e,t,n);return Qe(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:i})}(this.valueAttr,e,this)[0]}catch(e){console.error(e),rt.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if("html"!==this.mediatype){if("image"===this.mediatype){const e=document.createElement("img");return e.setAttribute("src",this.value),void this.appendChild(e)}e.innerHTML=this.value}else{if(this.modelItem.node){const{node:e}=this.modelItem;return e.nodeType?void this.appendChild(e):void Object.entries(e).map((e=>{this.appendChild(e[1])}))}e.innerHTML=this.value.outerHTML}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",Yn);class Qn extends(Ot(HTMLElement)){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0})}_handleFocus(){this.parentNode.setIndex(this.index)}_dispatchIndexChange(){this.parentNode&&this.parentNode.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}connectedCallback(){this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}disconnectedCallback(){this.removeEventListener("click",this._dispatchIndexChange()),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?this.classList.add("nonrelevant"):this.classList.remove("nonrelevant"),rt.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",Qn);class Jn extends(Ot(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){console.log("connectedCallback",this),this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{console.log("handle index event ",e);const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.applyIndex(this.children[n]),this.index=n+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;console.log("handle index event ",e);const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if(console.log("mutations",e),"childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=et.getPath(t);console.log("path mutated",e),rt.dispatch(this,"path-mutated",{path:e,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}init(){this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=St(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=mt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const o=r;if(o<n)for(let e=n;e>o;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(o>n)for(let e=n+1;e<=o;e+=1){const t=document.createElement("fx-repeatitem"),n=this._clone();t.appendChild(n),this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().someInstanceDataStructureChanged=!0}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||rt.refreshChildren(this,e),this.setIndex(this.index),console.groupEnd()}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=document.createElement("fx-repeatitem");n.nodeset=this.nodeset[t],n.index=t+1;const r=this._clone();n.appendChild(r),this.appendChild(n),1===n.index&&this.applyIndex(n),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",Jn);class zn extends $t{connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block !important;\n }\n \n </style>\n \n <slot></slot>\n \n "}async refresh(e){super.refresh();const t=this.querySelectorAll(":scope > fx-case");let n;this.isBound()?Array.from(t).forEach((e=>{e.getAttribute("name")===this.modelItem.value?(rt.dispatch(e,"select",{}),e.classList.add("selected-case"),n=e):(e.classList.contains("selected-case")&&rt.dispatch(e,"deselect",{}),e.classList.remove("selected-case"))})):(n=this.querySelector(":scope > .selected-case"),n||(n=t[0],rt.dispatch(n,"select",{}),n.classList.add("selected-case"))),rt.refreshChildren(n,e)}toggle(e){const t=this.querySelectorAll("fx-case");Array.from(t).forEach((t=>{e===t?(t.classList.add("selected-case"),rt.dispatch(t,"select",{}),this.refresh()):(t.classList.contains("selected-case")&&rt.dispatch(t,"deselect",{}),t.classList.remove("selected-case"))}))}}customElements.get("fx-switch")||window.customElements.define("fx-switch",zn);class Kn extends jt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].setAttribute("tabindex","0"),t[0].setAttribute("role","button");const n=t[0];this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return console.log("debouncing",t),(...o)=>{r||t.apply(e,o),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&(console.log("repeated click"),t.click()),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];"function"==typeof n.execute&&await n.execute(e)}}}customElements.get("fx-trigger")||customElements.define("fx-trigger",Kn);class Wn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-case")||window.customElements.define("fx-case",Wn);class Zn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.type&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.type&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map(((e,t)=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return void console.warn("no data to serialize");const t=(new XMLSerializer).serializeToString(e);return rt.prettifyXml(t)}}customElements.get("fx-inspector")||customElements.define("fx-inspector",Zn);class er extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.addEventListener("transitionend",(()=>{console.log("transitionend")})),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await rt.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",er);class tr extends Lt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("click",(e=>{const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ct(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const o=rt.getClosest("[ref]",this.parentNode);if(!o)return;const i=o.getModelItem(),a=this.shadowRoot.getElementById("setvalue");a.setValue(i,r.trim()),a.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=rt.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=e.querySelector("label");n.textContent=t.textContent;const r=rt.createUUID();n.setAttribute("for",r);const o=e.querySelector("[value]"),i=o.value,a=wt(i.substring(1,i.length-1),t,e),s=` ${a} `,u=` ${this.getAttribute("value")} `;o.value=a,o.setAttribute("id",r),-1!==u.indexOf(s)&&(o.checked=!0)}}async function nr(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fx-items")||customElements.define("fx-items",tr);class rr extends(Ot(HTMLElement)){static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}connectedCallback(){this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")?this.event=this.getAttribute("event"):this.event="activate",this.target=this.getAttribute("target"),this.target?"#window"===this.target?window.addEventListener(this.event,(e=>this.execute(e))):"#document"===this.target?document.addEventListener(this.event,(e=>this.execute(e))):(this.targetElement=ct(this.target,this),this.targetElement.addEventListener(this.event,(e=>this.execute(e)))):(this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)))),this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0}async execute(e){"stop"===this.propagate&&(console.log("event propagation stopped",e),e.stopPropagation());let t=()=>{};if(e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===rr.outermostHandler&&(console.time("outermostHandler"),console.info("%coutermost Action ","background:#e65100; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;",this),rr.outermostHandler=this),rr.outermostHandler!==this&&console.info("%cAction ","background:orange; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;",this),e&&e.code){const t=new Map;t.set("code",e.code),this.setInScopeVariables(new Map([...this.inScopeVariables,...t]))}if(e&&e.detail){this.detail=e.detail;const t=new Map;Object.keys(e.detail).forEach((function(n,r){t.set(n,e.detail[n])})),0!==t.size&&console.log("event detail vars",t),this.setInScopeVariables(new Map([...this.inScopeVariables,...t]))}this.needsUpdate=!1;try{this.evalInContext()}catch(e){console.warn("evaluation faild",e)}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),!this.ifExpr||vt(this.ifExpr,St(this),this)){if(this.whileExpr){const e=async()=>{await nr(this.delay||0),this.ownerDocument.contains(this)&&vt(this.whileExpr,St(this),this)&&(this.perform(),this.delay?e():await e())};return await e(),void this._finalizePerform(t)}if(this.delay&&(await nr(this.delay),!this.ownerDocument.contains(this)))return this.actionPerformed(),void t();await this.perform(),this._finalizePerform(t)}else this._finalizePerform(t)}_finalizePerform(e){this.actionPerformed(),rr.outermostHandler===this&&(rr.outermostHandler=null,console.info("%coutermost Action done","background:#e65100; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;",this),console.timeEnd("outermostHandler")),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext()}actionPerformed(){const e=this.getModel();e&&e.inited&&(rr.outermostHandler&&!rr.outermostHandler.ownerDocument.contains(rr.outermostHandler)&&(console.warn("Unsetting outermost handler"),rr.outermostHandler=null),!this.needsUpdate||rr.outermostHandler!==this&&rr.outermostHandler?this.needsUpdate&&(rr.outermostHandler.needsUpdate=!0,console.log("Update surpressed!")):(console.log("Running actionperformed"),e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){rt.dispatch(this,"action-performed",{})}}rr.outermostHandler=null,rr.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",rr);class or extends rr{static get properties(){return{ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),console.log("connectedCallback ",this),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),o=this._generateInstance(n.content,r);e.appendChild(o)}_dispatch(){const e=ct(this.repeat,this);console.log("dispatching index change ",e.nodeset.length),rt.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",or);class ir extends rr{constructor(){super()}async perform(){console.log("##### fx-delete executing...");const e=St(this.getAttributeNode("ref")||this,this.ref);this.nodeset=yt(this.ref,e,this),console.log("delete nodeset ",this.nodeset);const t=this.nodeset;let n;if(Array.isArray(t)){if(0===t.length)return;n=t[0].parentNode,t.forEach((e=>{this._deleteNode(n,e)}))}else n=t.parentNode,this._deleteNode(n,t);const r=et.resolveInstance(this),o=this.getModel().getInstance(r);rt.dispatch(o,"deleted",{deletedNodes:t}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",ir);class ar extends rr{connectedCallback(){super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){console.log("setting focus",this.control);const e="#"+this.control;let t=this.getOwnerForm().querySelector(e);const n=this.closest("fx-repeatitem");if(n)return console.log("parentRepeat",n),t=n.querySelector(e),void this._focus(t);const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector("[repeat-index] "+e)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&e.getWidget().focus()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",ar);class sr extends rr{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=gt(this.origin,e,this.getOwnerForm()),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t.cloneNode(!0)}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?At(this.getAttribute("at"),e,this.getOwnerForm()):t.length}async perform(){let e,t;this.hasAttribute("context")&&(e=St(this.getAttributeNode("context"),this.getAttribute("context")),t=yt(this.getAttribute("context"),e,this.getOwnerForm())),this.hasAttribute("ref")&&(e||(e=St(this.getAttributeNode("ref"),this.ref)),t=yt(this.ref,e,this.getOwnerForm()));const n=this._cloneOriginSequence(e,t);if(!n)return;let r,o;if(0===t.length)r=e,e.appendChild(n),o=1,console.log("appended",e);else{if(this.hasAttribute("at")?(o=At(this.getAttribute("at"),e,this.getOwnerForm()),r=t[o-1]):(o=t.length,r=t[t.length-1]),!r){o=1,r=t;o=At("count(preceding::*)",t,this.getOwnerForm())+1}this.position&&"before"===this.position&&r.parentNode.insertBefore(n,r),this.position&&"after"===this.position&&(o+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(n):this.hasAttribute("context")?(o=1,r.prepend(n)):r.insertAdjacentElement("afterend",n))}console.log("<<<<<<< at",this.at),console.log("<<<<<<< index",o),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:n,index:o}})),this.needsUpdate=!0}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",sr);class ur extends rr{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){let e;super.perform(),this.hasAttribute("value")?e=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),e=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!0,bubbles:!0,detail:{level:this.level,message:e}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return wt(e,St(this,e),this)}catch(e){console.error(e),rt.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",ur);class cr extends rr{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=mt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",console.log("value",e),e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}setValue(e,t){const n=e;n&&n.value!==t&&(n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0)}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",cr);class lr extends rr{constructor(){super(),this.value=""}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission")}async perform(){super.perform(),console.log("submitting ",this.submission);const e=this.getModel().querySelector(`#${this.submission}`);if(null===e)throw this.dispatchEvent(new CustomEvent("error",{composed:!0,bubbles:!0,detail:{message:`fx-submission element with id: '${this.submission}' not found`}})),new Error(`submission with id: ${this.submission} not found`);console.log("submission",e),await e.submit()}}customElements.get("fx-send")||window.customElements.define("fx-send",lr);class pr extends rr{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),console.log("### fx-toggle.execute "),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void rt.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",pr);class hr extends rr{constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){console.log("### fx-dispatch.perform ",this);const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{console.log("prop ",e);const n=e.getAttribute("name"),r=e.getAttribute("value"),o=e.getAttribute("expr");if(o){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=mt(o,this.getInScopeContext(),this.getOwnerForm());let i=null;if(e.nodeName){i=(new XMLSerializer).serializeToString(e)}t[n]=i||e}r&&(t[n]=r)})),console.log("details ",t),this.targetid){let e=ct(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),console.log("target",e),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",hr);class fr extends rr{async perform(){this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",fr);class dr extends rr{async perform(){if(this.hasAttribute("self")){const e=rt.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))this.getOwnerForm().forceRefresh();else if(this.hasAttribute("control")){const e=ct(this.getAttribute("control"),this);e&&rt.isUiElement(e.nodeName)&&"function"==typeof e.refresh&&e.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",dr);class mr extends rr{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform(),console.log("replace action");const e=gt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}replace(e,t){if(console.log("replace",e,t),e&&t)if(e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName),console.log("owner",n)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}else console.warn("fx-replace: one argument is not a node")}}customElements.get("fx-replace")||window.customElements.define("fx-replace",mr);class gr extends rr{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform(),console.log("performing return with nodes",this.nodeset);const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",gr);class yr extends rr{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="",console.log("### fx-script.perform ");const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",yr);class vr extends yr{connectedCallback(){this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",vr);class wr extends yr{connectedCallback(){this.dialog=this.getAttribute("dialog"),this.dialog||rt.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){const e=ct(this.dialog,this);e||console.error("target dialog with given id does not exist",this.dialog),e.open(),rt.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",wr);class Ar extends rr{connectedCallback(){this.dialog=this.getAttribute("dialog"),this.dialog||rt.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){const e=ct(this.dialog,this);e.hide(),rt.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",Ar);class xr extends rr{connectedCallback(){super.connectedCallback(),this.addEventListener("reload",(e=>{window.location.reload()}),{once:!0})}async perform(){rt.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",xr);class br extends(Ot(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,null===this.signature&&console.error("signature is a required attribute"),this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText;const e=this.getAttribute("type")||"text/xpath",t=this.signature.match(/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>(?:\(\)|[^)])*)\)(?: as (?<returnType>.*))?/);if(!t)throw new Error(`Function signature ${this.signature} could not be parsed`);const{prefix:n,localName:r,params:o,returnType:i}=t.groups,a="local"!==n&&n?`${n}:${r}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:r};n||at.push(r);const s=o?o.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>.+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(e){case"text/javascript":{const e=new Function("_domFacade",...s.map((e=>e.variableName)),"form",this.functionBody);Ke(a,s.map((e=>e.variableType)),i||"item()*",((...t)=>e.apply(this.getInScopeContext(),[...t,this.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const t="text/xpath"===e?"XPath3.1":"text/xquery"===e?"XQuery3.1":"XQueryUpdate3.1",n=(e,...n)=>mt(this.functionBody,this.getInScopeContext(),this.getOwnerForm(),s.reduce(((e,t,r)=>(e[t.variableName.replace("$","")]=n[r],e)),{}),{language:t});Ke(a,s.map((e=>e.variableType)),i||"item()*",n);break}default:throw new Error(`Unexpected mimetype ${e} for function`)}}}customElements.get("fx-function")||customElements.define("fx-function",br);
|
|
8
|
+
*/;class Mt{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="✖",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,a="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${a})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify");for(let o=0;o<a.length;o++){e=!0===a[o].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let s=a[o].offsetHeight;e=e.substr(9,e.length-1);let i=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[o].style[e]=`${r[e]}px`,r[e]+=s+i):!0===a[o].classList.contains("toastify-left")?(a[o].style[e]=`${t[e]}px`,t[e]+=s+i):(a[o].style[e]=`${n[e]}px`,n[e]+=s+i)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function Ut(e){return new Mt(e)}class Gt extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup","true"),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow","false"),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst","true"),this.position=this._initVar("position","right"),this.stopOnFocus="true"===this._initVar("stopOnFocus","true"),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new Ut({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",Gt);class Lt extends(kt(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=et.getPath(t);St.dispatch(this,"path-mutated",{path:e,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=Ct(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=gt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._clone();if(!t)return;this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||St.refreshChildren(this,e),this.setIndex(this.index)}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),this.template&&this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){if(this.template=this.shadowRoot.querySelector("template"),this.template)return this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",Lt);class $t extends HTMLElement{static get properties(){return{lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean},validateOn:{type:String}}}constructor(){super(),this.model={},this.inited=!1,this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._displayError),this.addEventListener("warn",this._displayWarning),this.addEventListener("log",this._logError),window.addEventListener("compute-exception",(e=>{console.error("circular dependency: ",e)})),this.ready=!1,this.storedTemplateExpressionByNode=new Map,this.outermostHandler=null;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n .warning{\n background:orange;\n }\n \n </style>\n \n <noscript>This page uses Web Components and needs JavaScript to be enabled..</noscript>\n\n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="left" gravity="bottom" escape-markup="false"></jinn-toast>\n <jinn-toast id="warn" text="warning" duration="-1" data-class="warning" close="true" position="right" gravity="bottom"></jinn-toast>\n <slot id="default"></slot>\n <slot name="messages"></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>×</a>\n <div id="messageContent"></div>\n </div>\n </div>\n <slot name="event"></slot>\n \n ',this.toRefresh=[],this.initialRun=!0,this.someInstanceDataStructureChanged=!1,this.repeatsFromAttributesCreated=!1,this.validateOn=this.hasAttribute("validate-on")?this.getAttribute("validate-on"):"update"}connectedCallback(){if(this.style.visibility="hidden",console.time("init"),this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this._injectDevtools();this.shadowRoot.querySelector("slot#default").addEventListener("slotchange",(async e=>{if(this.inited)return;if(this.hasAttribute("convert"))return void this.replaceWith(St.copyDom(this));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");return this.appendChild(e),void(t=e)}t.inited||(console.info(`%cFore is processing URL ${window.location.href}`,"background:#64b5f6; color:white; padding:1rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;"),await t.modelConstruct(),this._handleModelConstructDone()),this.model=t,this._createRepeatsFromAttributes(),this.inited=!0})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0}))}_injectDevtools(){if(this.ownerDocument.querySelector("fx-devtools"))return;const e=window.location.search;if(new URLSearchParams(e).has("inspect")){const e=document.createElement("fx-devtools");document.body.appendChild(e)}}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}_loadFromSrc(){fetch(this.src,{method:"GET",mode:"cors",credentials:"include",headers:{"Content-Type":"text/html"}}).then((e=>{const t=e.headers.get("content-type").toLowerCase();return console.log("********** responseContentType *********",t),t.startsWith("text/html")?e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done"})).then((e=>{const t=e.querySelector("fx-fore");t||St.dispatch(this,"error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),t.setAttribute("from-src",this.src);const n=this.attributes;Array.from(n).forEach((e=>{"src"!==e.name&&t.setAttribute(e.name,e.value)})),this.replaceWith(t)})).catch((()=>{St.dispatch(this,"error",{message:`'${this.src}' not found or does not contain Fore element.`})}))}handleIntersect(e,t){e.forEach((e=>{const{target:t}=e;St.getFore(t).initialRun||e.isIntersecting&&(t.classList.add("loaded"),"function"==typeof t.refresh?t.refresh(t,!0):St.refreshChildren(t,!0))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done"))}evaluateToNodes(e,t){return wt(e,t,this)}disconnectedCallback(){}async forceRefresh(){St.refreshChildren(this,!0),this._updateTemplateExpressions(),this.someInstanceDataStructureChanged=!1,this._processTemplateExpressions(),St.dispatch(this,"refresh-done",{})}async refresh(e){e||this.initialRun||0===this.toRefresh.length?St.refreshChildren(this,!0):(this.toRefresh.forEach((t=>{const n=t.boundControls;n&&n.forEach((t=>{t.refresh(e)}));const{mainGraph:r}=this.getModel();if(r&&r.hasNode(t.path)){const n=this.getModel().mainGraph.dependentsOf(t.path,!1);0!==n.length&&n.forEach((t=>{const n=et.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))}))}})),this.toRefresh=[]),(this.initialRun||this.someInstanceDataStructureChanged)&&(this._updateTemplateExpressions(),this.someInstanceDataStructureChanged=!1),this._processTemplateExpressions(),this.style.visibility="visible",St.dispatch(this,"refresh-done",{})}_updateTemplateExpressions(){const e=wt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!et.contains(this,e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!et.contains(this,e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=Ct(t,n);if(!r){const n=t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE?t.parentNode:t;return console.warn("no inscope context for ",n),e}const a=et.getInstanceId(n),o=a?this.getModel().getInstance(a):this.getModel().getDefaultInstance();try{return xt(n,r,t,null,o)}catch(t){return console.warn("ignoring unparseable expr",t),e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){t.ownerElement.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&(t.textContent=n)}_getTemplateExpression(e){return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){if(this.hasAttribute("show-confirmation")){const e=this.getAttribute("show-confirmation");e&&"show-confirmation"!==e&&"true"!==e&&""!==e?window.addEventListener("beforeunload",(t=>{if(vt(e,this.getModel().getDefaultContext(),this))return t.returnValue="are you sure";t.preventDefault()})):window.addEventListener("beforeunload",(e=>{if(Dt.dataChanged)return e.returnValue="are you sure";e.preventDefault()}))}this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model");if(0===e.instances.length){const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t)}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!St.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){n.split("/").forEach((n=>{t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){if(!this.initialRun)return;this.classList.add("initialRun"),await this._lazyCreateInstance();const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,St.dispatch(this,"ready",{}),console.timeEnd("init")}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_displayWarning(e){const t=e.detail.message,n=et.shortenPath(xt("path()",e.target,this));this.shadowRoot.querySelector("#warn").showToast(`WARN: ${n}:${t}`)}_logError(e){e.stopPropagation(),e.preventDefault();const t=document.createElement("div");t.setAttribute("slot","messages"),t.setAttribute("data-level",e.detail.level);const n=document.createElement("div");n.textContent=`"${e.detail.id}"`,t.appendChild(n);const r=document.createElement("div"),a=et.shortenPath(xt("path()",e.target,this));r.textContent=a,t.appendChild(r);const o=document.createElement("div");o.textContent=e.detail.message,t.appendChild(o),this.appendChild(t),t.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"});yt(`/${a}`,document,null).classList.add("fore-error")}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e)this.shadowRoot.querySelector("#sticky").showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{if(e.closest("fx-control"))return;const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new Lt;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}$t.outermostHandler=null,customElements.get("fx-fore")||customElements.define("fx-fore",$t);class Ht{static selectRelevant(e,t){return"xml"===t?Ht._relevantXmlNodes(e):(console.warn(`relevance selection not supported for type:${e.type}`),e.nodeset)}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&Ht._isRelevant(e,e.nodeset)?e.nodeset:Ht._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(Ht._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:a}=t;return a&&Array.from(a).forEach((t=>{"empty"!==e.nonrelevant||Ht._isRelevant(e,t)?Ht._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):r.removeAttribute(t.nodeName):r.setAttribute(t.nodeName,"")})),Ht._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return(t.nodeType!==Node.ATTRIBUTE_NODE||""!==t.nodeValue)&&(!n||!!n.relevant)}}class Pt extends(kt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.parameters=new Map}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id")||console.warn("id is required"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await St.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){console.log("submitting....",this.getAttribute("id")),this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate){if(!e.revalidate())return console.log("validation failed. Submission stopped"),this.getOwnerForm().classList.add("submit-validation-failed"),St.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}await this._serializeAndSend()}_getProperty(e){return this.parameters.has(e)?this.parameters.get(e):this.getAttribute(e)}async _serializeAndSend(){const e=this._getProperty("url"),t=this.evaluateAttributeTemplateExpression(e,this);console.log("resolvedUrl",t);const n=this.getInstance();n||St.dispatch(this,"warn",{message:`instance not found ${n.getAttribute("id")}`});const r=n.getAttribute("type");let a;if("none"===this.serialization)a=void 0;else{const e=Ht.selectRelevant(this,r);a=this._serialize(r,e)}if("get"===this.method.toLowerCase()&&(a=void 0),t.startsWith("#echo")){const e=this._parse(a,n);return this._handleResponse(e),St.dispatch(this,"submit-done",{}),void this.parameters.clear()}if(t.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const e=t.substring(t.indexOf(":")+1),r=localStorage.getItem(e);if(!r)return St.dispatch(this,"submit-error",{message:`Error reading key ${e} from localstorage`}),void this.parameters.clear();const a=this._parse(r,n);this._handleResponse(a),"consume"===this.method&&localStorage.removeItem(e),St.dispatch(this,"submit-done",{})}if("post"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.setItem(e,a),this._handleResponse(n.instanceData),St.dispatch(this,"submit-done",{})}if("delete"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.removeItem(e);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this._handleResponse(n),St.dispatch(this,"submit-done",{})}return}const o=this._getHeaders();if(this.methods.includes(this.method.toLowerCase()))try{const e=await fetch(t,{method:this.method,headers:o,body:a});if(!e.ok||e.status>400)return void St.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/plain")||n.startsWith("text/html")||n.startsWith("text/markdown")){const r=await e.text();this._handleResponse(r,t,n)}else if(n.startsWith("application/json")){const r=await e.json();this._handleResponse(r,t,n)}else if(n.startsWith("application/xml")){const r=await e.text(),a=(new DOMParser).parseFromString(r,"application/xml");this._handleResponse(a,t,n)}else{const r=await e.blob();this._handleResponse(r,t,n)}St.dispatch(this,"submit-done",{})}catch(e){St.dispatch(this,"submit-error",{error:e.message})}finally{this.parameters.clear()}else St.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.getAttribute("type")&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.getAttribute("type")&&(n=JSON.parse(e)),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=St.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e,t,n){if("instance"===this.replace){const t=this._getTargetInstance();if(!t)throw new Error(`target instance not found: ${t}`);if(this.targetref){const[n]=gt(this.targetref,t.instanceData.firstElementChild,this);console.log("theTarget",n);const r=e.firstElementChild,a=n.parentNode;a.replaceChild(r,n),console.log("finally ",a)}else if(this.into){const[n]=gt(this.into,t.instanceData.firstElementChild,this);console.log("theTarget",n),e.nodeType===Node.DOCUMENT_NODE?n.appendChild(e.firstElementChild):n.innerHTML=e}else{const n=e;t.instanceData=n}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("all"===this.replace&&(document.open(),document.write(e),document.close(),window.location.href=t),"target"===this.replace&&n.startsWith("text/html")){const t=this._getProperty("target"),n=document.querySelector(t);n?n.innerHTML=e:St.dispatch(this,"submit-error",{message:`targetNode for selector ${t} not found`})}"redirect"===this.replace&&(window.location.href=e)}_handleError(){St.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",Pt);class _t extends(kt(HTMLElement)){constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",_t);class jt extends(kt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=Ct(this,this.valueQuery),t=gt(this.valueQuery,e,this,this.precedingVariables);[this.value]=t}setInScopeVariables(e){if(e.has(this.name))return console.error(`The variable ${this.name} is declared more than once`),void St.dispatch(this,"xforms-binding-error",{});e.set(this.name,this),this.inScopeVariables=new Map(e)}}customElements.get("fx-var")||customElements.define("fx-var",jt);class Xt extends(kt(HTMLElement)){constructor(){super(),this.value="",this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset){if(this.closest("[create]")){let e,t,n;if(this.ref.includes("/")){t=this.ref.substring(0,this.ref.indexOf("/"));n=yt(t,Ct(this.parentNode,this.ref),this),n&&n.nodeType===Node.ELEMENT_NODE&&(this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("/")+2),n.setAttribute(e,"")):St.dispatch(this,"warn",{message:'"create" is not implemented for elements'}))}else{let t=Ct(this,this.ref);this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("@")+1),t.setAttribute(e,"")):St.dispatch(this,"warn",{message:'"create" is not implemented for elements'})}}else this.style.display="none";return}if(this.modelItem=this.getModelItem(),this.modelItem instanceof Ft){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),this.getOwnerForm().initialRun&&St.dispatch(this,"init",{}),!this.getOwnerForm().ready)return;t!==this.value&&St.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&St.dispatch(this,e,{})}handleRequired(){if(this.widget=this.getWidget(),!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(this.isRequired()!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this.isRequired()!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void(this.style.display="none");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.style.display=this.display):(this._dispatchEvent("nonrelevant"),this.style.display="none"))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",Xt);class qt extends Xt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",qt);class Vt extends Xt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}static get properties(){return{...Xt.properties,initial:{type:Boolean}}}_getValueFromHtmlDom(){return"selectedOptions"===this.valueProp?[...this.widget.selectedOptions].map((e=>e.value)).join(" "):this.widget[this.valueProp]}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget(),this.addEventListener("mousedown",(e=>{St.isWidget(e.target)||e.target?.classList.contains("fx-hint")||e.preventDefault(),this.widget.focus()}));const e=this.widget.hasAttribute("multiple")?"selectedOptions":"value";this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):e;let t=this.widget;if(this.hasAttribute("listen-on")){const e=this.getAttribute("listen-on"),n=this.querySelector(e);n&&(t=n)}this.addEventListener("keyup",(()=>{Dt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this._getValueFromHtmlDom()))})),this.updateEvent="blur"),this.debounceDelay?t.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,a)}),n)}}(this,(()=>{this.setValue(this._getValueFromHtmlDom())}),this.debounceDelay)):(t.addEventListener(this.updateEvent,(e=>{this.setValue(this._getValueFromHtmlDom())})),t.addEventListener("blur",(e=>{this.setValue(this._getValueFromHtmlDom())}),{once:!0})),this.addEventListener("return",(e=>{const t=e.detail.nodeset;e.stopPropagation(),this._replaceNode(t)})),this.widget.addEventListener("focus",(()=>{})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const a=this;clearTimeout(n),n=setTimeout((()=>{e.apply(a,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.getAttribute("class")?this.classList.add("visited"):this.setAttribute("class","visited"),t?.readonly)return void console.warn("attempt to change readonly node",t);if("node"===this.getAttribute("as")){const e=this.shadowRoot.getElementById("replace"),n=this.getWidget()[this.valueProp];return e.replace(this.nodeset,n),void(t&&n&&n!==t.value&&(t.value=n,Dt.dataChanged=!0,e.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof Ft&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed()}_replaceNode(e){e.nodeType===Node.ATTRIBUTE_NODE?this.modelItem.node.nodeValue=e.nodeValue:e.nodeType===Node.ELEMENT_NODE?this.modelItem.node.replaceWith(e.cloneNode(!0)):e.nodeType===Node.TEXT_NODE?this.modelItem.node.nodeValue=e.textContent:St.dispatch(this,"warn",{message:"trying to replace a node that is neither an Attribute, Elemment or Text node"}),this.getOwnerForm().refresh()}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input"),e&&!e.classList.contains("widget")&&e.classList.add("widget")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if("selectedOptions"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=St.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.url&&!this.loaded)return this.initial&&(this.initialNode=yt(this.initial,this.nodeset,this)),await this._loadForeFromUrl(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else{const e=new Set(this.value.split(" "));for(const t of[...this.widget.querySelectorAll("option")])e.has(t.value)?t.selected=!0:t.selected=!1}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromUrl(){console.info(`%cFore is processing URL ${this.url}`,"background:#64b5f6; color:white; padding:0.5rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;");try{const e=await fetch(this.url,{method:"GET",headers:{"Content-Type":"text/html"}});let t;t=e.headers.get("content-type").toLowerCase().startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const n=t.querySelector("fx-fore"),r=document.importNode(n,!0);r.classList.add("widget"),r.addEventListener("model-construct-done",(e=>{const t=r.querySelector("fx-instance");if(this.initialNode){const e=(new DOMParser).parseFromString("<data></data>","application/xml");e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.setInstanceData(e)}r.getModel().updateModel(),r.refresh()}),{once:!0});const a=this.querySelector("input");this.hasAttribute("shadow")?(a.parentNode.removeChild(a),this.shadowRoot.appendChild(r)):this.loaded||a.replaceWith(r),n||this.dispatchEvent(new CustomEvent("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}})),this.dispatchEvent(new CustomEvent("loaded",{detail:{fore:n}}))}catch(e){this.getOwnerForm().dispatchEvent(new CustomEvent("error",{detail:{message:`${this.url} not found`}}))}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),this._handleDataAttributeBinding(),St.refreshChildren(this,e)}_handleDataAttributeBinding(){const e=this.querySelector("[data-ref]");e&&(this.boundList=e,e.getAttribute("data-ref"),this._handleBoundWidget(e))}_handleBoundWidget(e){if(this.boundInitialized&&this.static)return;const t=e.hasAttribute("ref")?e.getAttribute("ref"):e.getAttribute("data-ref");if(e&&t){const n=gt(t,Ct(this,t),this);if(Array.isArray(n)&&0===n.length)return;const{children:r}=e;Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)}));const{template:a}=this;if(a){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}}}updateEntry(e,t){const n=this._getValueAttribute(e);if(!n)return;const r=n.value,a=xt(r.substring(1,r.length-1),t,e);n.value=a,this.value===a&&e.setAttribute("selected","selected");const o=e.textContent;this.evalLabel(o,t,e)}evalLabel(e,t,n){const r=e.substring(1,e.length-1);if(!r)return;const a=xt(r,t,this);n.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",Vt);class Yt extends(kt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this),this.setAttribute("tabindex","0")}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",Yt);class zt extends Yt{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}render(){return"\n <slot></slot>\n "}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){Array.from(e.children).forEach((e=>{if(St.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}})),console.groupEnd()}async refresh(e){super.refresh(e),St.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",zt);class Jt extends Xt{static get styles(){return"\n :host {\n display: block;\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n font-style: italic;\n }\n "}static get properties(){return{...super.properties}}render(){return"\n <slot></slot>\n "}}customElements.get("fx-hint")||customElements.define("fx-hint",Jt);class Qt extends Xt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n max-width:100%;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n #value{\n max-width:100%;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot name="default"></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=Ct(this,this.valueAttr);return this.hasAttribute("html")?gt(this.valueAttr,e,this)[0]:function(e,t,n,r=null,a=n){const o=dt(e,t,n);return ze(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:mt,moduleImports:{xf:at},namespaceResolver:o})}(this.valueAttr,e,this)[0]}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if(e.innerHTML="","html"!==this.mediatype){if("image"===this.mediatype){const t=document.createElement("img");return t.setAttribute("src",this.value),this.innerHTML="",void e.appendChild(t)}e.innerHTML=this.value}else if(this.modelItem.node){this.shadowRoot.querySelector("#default");const{node:t}=this.modelItem;if(t.nodeType)return void e.append(t);const n=(new DOMParser).parseFromString(t,"text/html").body.childNodes;return void Array.from(n).forEach((t=>{e.append(t)}))}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",Qt);class Kt extends(kt(HTMLElement)){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0})}_handleFocus(){this.parentNode.setIndex(this.index)}_dispatchIndexChange(){this.parentNode&&this.parentNode.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}connectedCallback(){this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}disconnectedCallback(){this.removeEventListener("click",this._dispatchIndexChange()),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?this.classList.add("nonrelevant"):this.classList.remove("nonrelevant"),St.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",Kt);class Wt extends(kt(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.applyIndex(this.children[n]),this.index=n+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=et.getPath(t);St.dispatch(this,"path-mutated",{path:e,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}init(){this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=Ct(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=gt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(a>n)for(let e=n+1;e<=a;e+=1){const t=document.createElement("fx-repeatitem"),n=this._clone();t.appendChild(n),this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().someInstanceDataStructureChanged=!0}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||St.refreshChildren(this,e),this.setIndex(this.index)}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=document.createElement("fx-repeatitem");n.nodeset=this.nodeset[t],n.index=t+1;const r=this._clone();n.appendChild(r),this.appendChild(n),1===n.index&&this.applyIndex(n),St.dispatch(this,"item-created",{nodeset:n.nodeset,pos:t+1}),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",Wt);class Zt extends Yt{constructor(){super(),this.formerCase={}}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block !important;\n }\n \n </style>\n \n <slot></slot>\n \n "}async refresh(e){super.refresh();const t=this.querySelectorAll(":scope > fx-case");let n=t[0];if(this.isBound()?Array.from(t).forEach((e=>{e.getAttribute("name")===this.modelItem?.value?(St.dispatch(e,"select",{}),e.classList.add("selected-case"),n=e):(e.classList.contains("selected-case")&&St.dispatch(e,"deselect",{}),e.classList.remove("selected-case"))})):(n=this.querySelector(":scope > .selected-case"),n||(n=t[0],St.dispatch(n,"select",{}),n.classList.add("selected-case"))),this.formerCase!==n){const e=n.querySelectorAll(".visited");Array.from(e).forEach((e=>{e.classList.remove("visited")}))}St.refreshChildren(n,e),this.formerCase=n}toggle(e){const t=this.querySelectorAll("fx-case");Array.from(t).forEach((t=>{e===t?(t.classList.add("selected-case"),St.dispatch(t,"select",{}),this.refresh()):(t.classList.contains("selected-case")&&St.dispatch(t,"deselect",{}),t.classList.remove("selected-case"))}))}}customElements.get("fx-switch")||window.customElements.define("fx-switch",Zt);class en extends Xt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].setAttribute("tabindex","0"),t[0].setAttribute("role","button");const n=t[0];this.addEventListener("mousedown",(e=>{console.log("target",e.target.nodeName),e.target.focus()})),this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return(...a)=>{r||t.apply(e,a),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&t.click(),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];if("function"==typeof n.execute){if(e&&(e.preventDefault(),e.stopPropagation(),e.type&&n.event&&e.type!==n.event))return;await n.execute(e)}}}}customElements.get("fx-trigger")||customElements.define("fx-trigger",en);class tn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-case")||window.customElements.define("fx-case",tn);class nn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.getAttribute("type")&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.getAttribute("type")&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map((e=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return void console.warn("no data to serialize");return rt((new XMLSerializer).serializeToString(e))}}customElements.get("fx-inspector")||customElements.define("fx-inspector",nn);class rn extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await St.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",rn);class an extends Vt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",(e=>{if(St.isWidget(e.target)||(e.preventDefault(),e.stopImmediatePropagation()),"LABEL"===e.target.nodeName){ct(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("mousedown",(e=>{if(this.querySelectorAll("[value]"),"LABEL"===e.target.nodeName){ct(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("click",(e=>{e.preventDefault,e.stopPropagation();const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ct(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const a=et.getClosest("[ref]",this.parentNode);if(!a)return;const o=a.getModelItem(),s=this.shadowRoot.getElementById("setvalue");s.setValue(o,r.trim()),s.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=et.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=St.createUUID(),r=e.querySelector("label"),a=St.getExpression(r.textContent);if(t.nodeType){const e=xt(a,t,this);r.textContent=e}else{const e=St.getExpression(a);r.textContent=t[e]}r.setAttribute("for",n);const o=e.querySelector("[value]"),s=o.value,i=St.getExpression(s);let l;l=t.nodeType?xt(i,t,e):t[i];const c=` ${l} `,u=` ${this.getAttribute("value")} `;o.value=l,o.setAttribute("id",n),-1!==u.indexOf(c)&&(o.checked=!0)}}customElements.get("fx-items")||customElements.define("fx-items",an);class on extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.eventName="",this.shortName="",this.shortInfo="",this.shortPath="",this.xpath=""}connectedCallback(){this.eventName=this.getAttribute("event-name"),this.shortName=this.getAttribute("short-name"),this.shortInfo=this.hasAttribute("short-info")?this.getAttribute("short-info"):"",this.xpath=this.getAttribute("xpath");const e=`\n <details class="info send">\n <summary>\n <span class="log-name"><a href="#" title="${("/"+this.xpath.substring(this.xpath.indexOf("/fx-fore"),this.xpath.length)).replaceAll("fx-","")}" data-path="${this.xpath}">${this.shortName}</a></span>\n <span class="short-info">${this.shortInfo}</span>\n <span class="event-name">${this.eventName}</span> \n </summary>\n <slot></slot>\n </details>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n\n }\n\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n top:1em;\n border.thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n white-space:nowrap;\n overflow-wrap:break-word;\n }\n\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n border:1px solid #ddd;\n border-radius:1em; \n box-shadow: 1px 1px 5px 0px rgba(79, 136, 183, 0.8);\n }\n :host(.action) .info{\n border-radius:0;\n border-color:steelblue;\n }\n\n .info label{\n grid-area:left;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n summary{\n padding:1em;\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n gap:0.25em;\n }\n/*\n .log-name{\n font-size:1.2em;\n }\n .log-name, .short-info{\n width:10em;\n }\n*/\n .event-name{\n width:12em;\n text-align:right;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-log-item")||customElements.define("fx-log-item",on);class sn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=sn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n font-family: Verdana, Sans;\n\n margin:0;\n border:thin solid #ddd;\n }\n .boxes{\n column-width:14rem;\n overflow:auto;\n margin-bottom:5em;\n padding:1em;\n }\n .boxes > span{\n display:inline-block;\n width:14rem;\n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n #settings{\n padding:1em;\n }\n \n \n </style>\n \n <section id="settings">\n <header>log settings <button id="reset">reset</button></header>\n <div class="boxes"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector(".boxes");this.listenTo.forEach((t=>{const n=document.createElement("span");e.append(n);const r=document.createElement("label");r.setAttribute("title",t.description),r.setAttribute("for",t.name),r.innerText=t.name;const a=document.createElement("input");a.setAttribute("type","checkbox"),a.setAttribute("name",t.name),a.setAttribute("id",t.name),t.show&&a.setAttribute("checked",""),n.append(a),n.append(r),a.addEventListener("click",(e=>{if(!e.target.checked){document.querySelector("fx-fore").removeEventListener(t.name,this._log)}const n=this.listenTo.find((e=>e.name===t.name));e.target.checked?n.show=!0:n.show=!1,localStorage.setItem("fx-log-settings",JSON.stringify(this.listenTo))}))}));this.shadowRoot.querySelector("#reset").addEventListener("click",(e=>{localStorage.removeItem("fx-log-settings"),window.location.reload()}))}static defaultSettings(){return[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fires after a fx-return returned"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=et.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="ACTION" class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const a=document.querySelector(`#${r.detail.action.getAttribute("submission")}`);return`\n <fx-log-item short-name="SEND"\n short-info="${a.id}"\n event-name="${r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(a.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${et.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return`\n <fx-log-item event-name="${r.detail.event}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}customElements.get("fx-log-settings")||customElements.define("fx-log-settings",sn);class ln extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-action-log-filters")?this.listenTo=JSON.parse(localStorage.getItem("fx-action-log-filters")):this.listenTo=sn.defaultSettings(),localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=sn.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n background:transparent;\n font-family: Verdana, Sans;\n margin:0;\n padding:0.25rem;\n }\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n bottom:-0.5em;\n border:thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n max-width:90%;\n }\n .details{\n padding:0.25em 0;\n }\n\n .key{\n width:20%;\n display:inline-block;\n min-width:5rem;\n border-bottom:1px solid #ddd;\n background:#efefef;\n vertical-align:top;\n }\n .value{\n display:inline-block;\n width:60%;\n \n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n display:grid;\n grid-template-areas: "left right"\n "bottom .";\n grid-template-columns: 75% 25%;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .details > section{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n }\n fx-log-item{\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n \n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n ol{\n background: #efefef;\n padding: 0.5em 0 0 2em;\n border-left:3px solid red;\n }\n \n .event-name{\n display:inline-block;\n }\n #log{\n margin-bottom:10em;\n margin-right:2em;\n }\n .log-row{\n margin:0;\n padding:0;\n position:relative;\n font-size:0.8em;\n border-left:4px solid transparent;\n padding-left:5px;\n width:calc(100% - 2em);\n margin-bottom:0.25em;\n }\n .log-row summary{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n }\n .log-row summary > span {\n width:calc(90% div 3);\n }\n\n .log-name{\n position:relative;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n .log-row.no-detail summary{\n position:relative;\n }\n .log-row.no-detail summary{\n list-style:none;\n padding-left:1rem;\n }\n .log-row.no-detail summary::-webkit-details-marker {\n display: none;\n }\n .log-row.nested{\n margin-left:1em;\n }\n .nested .event-name{\n display:none;\n }\n \n .setvalue .value{\n background:lightyellow;\n }\n summary{\n padding:1em;\n border-bottom:2px solid #ddd;\n }\n .outer-details{\n height:100%;\n overflow:auto;\n margin-top:2rem;\n background:rgba(250, 250, 250, 0.9);\n }\n \n .outer-details > header{\n position:absolute;\n top:-1px;\n width:calc(100% - 2rem);\n border-bottom:2px solid #ddd;\n font-size:1rem;\n height:1rem;\n }\n .outer-details > summary{\n font-size:1em;\n }\n ul{\n list-style:none;\n padding:0;\n margin:0.1em 0;\n border-left:3px solid steelblue;\n padding:0.1em 0;\n }\n ul .log-row{\n padding-left:3px;\n width:calc(100% - 1em);\n }\n \n </style>\n \n <section open class="outer-details">\n <header>Log \n <span class="buttons">\n <button id="del"" title="empty log - Ctrl+d">\n <svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>\n </button>\n </span>\n </header>\n <div id="log"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector("#log");this.listenTo.forEach((t=>{t.show&&document.addEventListener(t.name,(t=>{this._log(t,e)}))})),document.addEventListener("outermost-action-start",(e=>{this.outermost=!0}),{capture:!0}),document.addEventListener("outermost-action-end",(e=>{this.outermost=!1,this.outermostAppender=null}),{capture:!0});this.shadowRoot.querySelector("#del").addEventListener("click",(e=>{this.shadowRoot.querySelector("#log").innerHTML=""})),document.addEventListener("keydown",(e=>{e.ctrlKey&&"d"===e.key&&(this.shadowRoot.querySelector("#log").innerHTML="")}))}_defaultSettings(){this.listenTo=[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fired by embedded Fore controls to return their bound value"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=et.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){let a;switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}"\n xpath="${t}"\n short-name="ACTION"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const o=document.querySelector(`#${r.detail.action.getAttribute("submission")}`),s=r.detail.event?r.detail.event:"";return`\n <fx-log-item short-name="SEND"\n short-info="${o.getAttribute("id")}"\n event-name="${s}"\n xpath="${t}" class="action"\n data-path="${r.detail.path}" >\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(o.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${et.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event?r.detail.event:""}"\n xpath="${t}"\n data-path="${r.detail.path}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}function cn(e,t){e.classList.add(t)}function un(e,t){e.classList.remove(t)}function hn(e,t){if("object"!=typeof e)throw new Error(`containsOnlyText: Expected argument node of type object, ${typeof e} given.`);let n=!1,r=null;if(t=t||!1)for(let t=0,a=e.childNodes.length;t<a&&(r=e.childNodes[t],n=r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE||r.nodeType===Node.CDATA_SECTION_NODE,n);t+=1);else n=e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||e.nodeType===Node.CDATA_SECTION_NODE;return n}function pn(e,t){const n=document.createElement(e);t=t||{};for(const e of Object.keys(t))n.setAttribute(e,t[e]);return n}function dn(e,t){const n=pn("span",{class:"adi-opt"});return n.innerHTML=`<label><input type="checkbox" data-opt="${e}">${t}</label>`,n}customElements.get("fx-action-log")||customElements.define("fx-action-log",ln);class mn{constructor(e,t){this.sourceNodeByInspectorNodeLookup=new Map,this.uiView=null,this.menuView=null,this.domView=null,this.attrView=null,this.optsView=null,this.activeElement=null,this.vertResizing=!1,this.horizResizing=!1,this.pathScrolling=null,this.elemLookup=!1,this.styleBackup="",this.xPos=0,this.delegatedEvents=[],this.options={align:"right",split:50,minSplit:30,visible:!0,saving:!1,transparent:!0,omitEmptyText:!0,makeVisible:!0,foldText:!0,nodeTypes:[Node.ELEMENT_NODE,Node.TEXT_NODE,Node.COMMENT_NODE,Node.DOCUMENT_NODE]},"#document"===t?(this.instanceId="#document",this.document=window.document,this.isInstanceViewer=!1):(this.instanceId=t.id,t&&"fx-instance"===t.localName||console.error("No instance found!"),this.document=t.getInstanceData(),this.isInstanceViewer=!0,this.options.foldText=!1),this.drawUI(e),this.registerEvents(),this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0),document.addEventListener("execute-action",(e=>this.processExecuteAction))}getSelected(){if(!this.activeElement)return null;let e=document;return e=this.sourceNodeByInspectorNodeLookup.get(this.activeElement),e}loadOptions(){let e={};e=JSON.parse(window.localStorage.getItem("ADI.options"))||{};for(const t of Object.keys(e))this.options[t]=e[t]}saveOptions(){this.options.saving&&window.localStorage.setItem("ADI.options",JSON.stringify(this.options))}hasRequiredNodes(e){if("object"!=typeof e)throw new Error(`hasRequiredNodes: Expected argument node of type object, ${typeof e} given.`);if(e.hasChildNodes())for(let t=0,n=e.childNodes.length;t<n;t+=1){const n=e.childNodes[t];if(this.options.nodeTypes.includes(n.nodeType))return!0}return!1}newTreeNode(e){if("object"!=typeof e)throw new Error(`newTreeNode: Expected argument node of type object, ${typeof e} given.`);const t=this.hasRequiredNodes(e);let n=!1,r=e.nodeName.startsWith("FX-")?`adi-node ${e.nodeName.toLowerCase()}`:"";e.nodeName.startsWith("FX-")&&(r=`adi-node ${e.nodeName.toLowerCase()}`,r+=St.isActionElement(e.nodeName)?" action":"");const a=pn("li",{class:r});if(e===this.uiView)return null;if(t&&a.appendChild(pn("span",{class:"adi-trigger"})),this.options.omitEmptyText&&e.nodeType===Node.TEXT_NODE&&(n=function(e){if("object"!=typeof e)throw new Error(`isEmptyTextNode: Expected argument node of type object, ${typeof e} given.`);return/^\s*$/.test(e.textContent)}(e)),!n){const n=pn("span");this.sourceNodeByInspectorNodeLookup.set(n,e),this.sourceNodeByInspectorNodeLookup.set(e,n);let r=null;if(hn(e))e.nodeType===Node.COMMENT_NODE?(cn(n,"adi-comment-node"),"string"==typeof n.innerText&&(n.innerText=`\x3c!-- ${e.textContent} --\x3e`)):(cn(n,"adi-text-node"),n.textContent=e.textContent);else if(cn(n,"adi-normal-node"),e.nodeType!==Node.DOCUMENT_NODE){if("FX-BIND"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} ref="${e.getAttribute("ref")}">`;else if("FX-INSERT"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} ref="${e.getAttribute("ref")}">`;else if("FX-INSTANCE"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} id="${e.id}">`;else if("FX-CONTROL"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} ref="${e.getAttribute("ref")}">`;else if("FX-SEND"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} submission="${e.getAttribute("submission")}">`;else if("FX-SETVALUE"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} ref="${e.getAttribute("ref")}">`;else if("FX-SUBMISSION"===e.nodeName)n.textContent=`<${e.nodeName.toLowerCase()} id="${e.getAttribute("id")}">`;else{const t=Array.from(e.attributes).filter((e=>{return!!this.isInstanceViewer||("id"===(t=e.name)||"ref"===t||"event"===t);var t})).map((e=>`${e.name}="${e.value}"`)).join(" ");n.textContent=`<${e.nodeName.toLowerCase()}${t?` ${t}`:""}>`}t&&(r=pn("span"),cn(r,"adi-end-node"),r.textContent=`</${e.nodeName.toLowerCase()}>`)}else n.textContent=e.nodeName.toLowerCase();return a.appendChild(n),e.nodeName.startsWith("FX-")&&(n.classList.add("fore-node"),n.classList.add(e.nodeName.toLowerCase())),r&&(a.appendChild(r),e.nodeName.startsWith("FX-")&&r.classList.add("fore-node")),a}return null}drawDOM(e,t,n){if("object"!=typeof e)throw new Error(`drawDOM: Expected argument root of type object, ${typeof e} given.`);let r=null,a=!0;const o=t.nodeName.startsWith("FX-")?`adi-node ${node.nodeName.toLowerCase()}`:"";n&&-1!==this.options.nodeTypes.indexOf(e.nodeType)&&(t.innerHTML="",r=this.newTreeNode(e),this.hasRequiredNodes(e)&&(r.appendChild(pn("ul",{"data-open":!0,class:o})),cn(r.querySelector(".adi-trigger"),"opened")),t.appendChild(r),t=t.querySelector("ul"));for(let n=0,s=e.childNodes.length;n<s;n+=1){const s=e.childNodes[n],i=this.hasRequiredNodes(s);if(-1!==this.options.nodeTypes.indexOf(s.nodeType)&&(r=this.newTreeNode(s),r)){if(i&&(a=!this.options.foldText||!hn(s,!0),"HEAD"===s.nodeName&&(a=!1),"SELECT"===s.nodeName&&(a=!1),"FX-INSTANCE"===s.nodeName&&(a=!1),s.nodeType===Node.DOCUMENT_NODE?r.appendChild(pn("ul",{"data-open":a,class:o})):r.insertBefore(pn("ul",{"data-open":a,class:o}),r.lastChild),cn(r.querySelector(".adi-trigger"),a?"opened":"closed")),t.appendChild(r),this.getSelected()===s){const e=r.querySelector("span.adi-normal-node");e?.classList?.add("adi-active-node"),this.activeElement=e,r.scrollIntoView({block:"nearest",behavior:"instant"})}i&&this.drawDOM(s,r.querySelector("ul"),!1)}}}toggleOptions(){-1!==this.optsView.className.indexOf("adi-hidden")?un(this.optsView,"adi-hidden"):(cn(this.optsView,"adi-hidden"),this.attrView.querySelector(".adi-content").innerHTML="",this.refreshUI(),this.drawDOM(document,this.domView.querySelector(".adi-tree-view"),!0),this.options.saving?this.saveOptions():window.localStorage.removeItem("ADI.options"))}drawUI(e){this.uiView=pn("div",{id:"adi-wrapper",class:this.options.transparent?"transparent":""}),this.domView=pn("div",{id:"adi-dom-view"});const t=pn("div",{class:"adi-content",id:"detailsView"}),n=pn("ul",{class:"adi-tree-view"}),r=pn("div",{class:"adi-path-wrap"}),a=pn("span",{class:"adi-path-left"}),o=pn("span",{class:"adi-path-right"});this.menuView=pn("div",{id:"adi-panel"});const s=pn("div",{class:"adi-menu-wrap"}),i=pn("a",{class:"adi-menu-config",title:"Settings"}),l=pn("a",{class:"adi-menu-lookup",title:"Lookup tool"});if(this.optsView=function(){const e=pn("div",{id:"adi-opts-view",class:"adi-hidden"}),t=pn("span",{class:"adi-opt-heading"}),n=pn("span",{class:"adi-opt-heading"}),r=pn("span",{class:"adi-opt-close"});return t.textContent="General options",n.textContent="Observed nodes",e.appendChild(t),e.appendChild(dn("saving","Enable saving of settings")),e.appendChild(dn("makeVisible","Scroll to the active element in DOM View")),e.appendChild(dn("omitEmptyText","Hide empty text nodes")),e.appendChild(dn("foldText","Fold the text nodes")),e.appendChild(dn("transparent","Enable transparent background")),e.appendChild(n),e.appendChild(dn("nodeTypes-3","Text node")),e.appendChild(dn("nodeTypes-8","Comment node")),e.appendChild(r),e}(),t.appendChild(n),this.domView.appendChild(this.menuView),this.domView.appendChild(t),r.appendChild(a),r.appendChild(o),s.appendChild(l),s.appendChild(i),this.menuView.appendChild(r),this.menuView.appendChild(s),this.uiView.appendChild(this.optsView),this.uiView.appendChild(this.domView),!this.isInstanceViewer){this.attrView=pn("div",{id:"adi-attr-view"});const e=pn("div",{class:"adi-content"});this.attrView.appendChild(e),this.uiView.appendChild(this.attrView)}e.appendChild(this.uiView),this.refreshUI(!0)}refreshUI(e){null!==this.uiView&&(e&&this.loadOptions(),e&&(this.optsView.querySelector('[data-opt="transparent"]').checked=this.options.transparent,this.optsView.querySelector('[data-opt="saving"]').checked=this.options.saving,this.optsView.querySelector('[data-opt="omitEmptyText"]').checked=this.options.omitEmptyText,this.optsView.querySelector('[data-opt="makeVisible"]').checked=this.options.makeVisible,this.optsView.querySelector('[data-opt="foldText"]').checked=this.options.foldText,this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked=-1!==this.options.nodeTypes.indexOf(3),this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked=-1!==this.options.nodeTypes.indexOf(8)),this.uiView.className=this.options.transparent?"transparent":"",this.domView.querySelector(".adi-content").style.height=`${this.domView.clientHeight}px`,this.isInstanceViewer||(this.attrView.querySelector(".adi-content").style.height=this.attrView.clientHeight-this.menuView.clientHeight+"px"),cn(this.uiView,this.options.align))}toggleVisibilityUI(){null!==this.uiView&&(this.uiView.style.display=this.options.visible?"none":"block",this.options.visible=!this.options.visible,this.saveOptions())}drawAttrs(e){if(this.isInstanceViewer)return;const t=this.attrView.querySelector(".adi-content");t.innerHTML="";const n=document.createElement("header");n.innerText="Attributes",t.appendChild(n),[...e.attributes].forEach((e=>{"style"!==e.name&&t.appendChild(function(e,t){const n=pn("span",{class:"adi-attr"});switch(e.toLowerCase()){case"defaultaction":n.innerHTML=`<label>${e}: <select data-attr="${e}" value="${t}"><option>perform</option><option>cancel</option></label>`;break;case"delay":n.innerHTML=`<label>${e}: <input type="number" data-attr="${e}" value="${t}" readonly="readonly"></label>`;break;default:n.innerHTML=`<label>${e}: <input type="text" data-attr="${e}" value="${t}" readonly="readonly"></label>`}return n}(e.name,e.value))}))}changeAttribute(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-attr"),r=t.value,a=this.getSelected();""===r?a.removeAttribute(n):a.setAttribute(n,r)}changeOption(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-opt"),r=t.checked;if(-1!==n.indexOf("nodeTypes")){const e=parseInt(n.match(/\d+/)[0],10);r?this.options.nodeTypes.push(e):this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(e),1)}else this.options[n]=r}processKey(e){if(272===((e=e||window.event).keyCode||e.which))this.toggleVisibilityUI()}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}horizontalResize(e){if(!this.horizResizing)return;e=e||window.event,document.documentElement.style.cursor="n-resize";const t=Math.floor(e.clientY/this.uiView.clientHeight*100);t>=this.options.minSplit&&t<=100-this.options.minSplit&&(this.options.split=t,this.refreshUI(),this.saveOptions())}processExecuteAction(e){this.refreshUI()}handleActive(e){let t=e?e.detail?.target||e.target:window.event.srcElement;const n=this.domView.querySelector(".adi-active-node");if(n&&un(n,"adi-active-node"),!t||t.nodeType===Node.DOCUMENT_NODE)return;if(t&&t.classList&&t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node")),this.activeElement=t,cn(t,"adi-active-node"),this.options.makeVisible){this.domView.querySelector(".adi-content").scrollIntoView({block:"center",behavior:"instant"})}const r=this.getSelected();if(this.drawAttrs(r),r&&"function"==typeof r.getModelItem&&r.getModelItem()?.node){let e=r.modelItem.node;e?.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}highlightElement(e){let t=e?e.target:window.event.srcElement;t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node"));const n=this.sourceNodeByInspectorNodeLookup.get(t);n&&n.ownerDocument===window.document&&n&&("mouseover"===e.type?(this.styleBackup=n.getAttribute("style")||"",n.setAttribute("style",`outline: 2px solid blue; ${this.styleBackup}`)):""===this.styleBackup?n.removeAttribute("style"):n.setAttribute("style",this.styleBackup))}handleLookup(e){const t=e?e.detail?.target||e.target:window.event.srcElement;if(!this.document.contains(t))return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(-1!==t.className.indexOf("adi-menu-lookup"))return this.elemLookup?(un(t,"adi-active"),this.elemLookup=!1,this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),void this.removeEvent(document.body,"click",this.handleLookup,!0)):(cn(t,"adi-active"),this.elemLookup=!0,this.addEventDelegate(document.body,"mouseover",this.handleLookup,!1,"*",!0,"adi-wrapper"),this.addEventDelegate(document.body,"mouseout",this.handleLookup,!1,"*",!0,"adi-wrapper"),void this.addEventDelegate(document.body,"click",this.handleLookup,!1,"*",!0,"adi-wrapper"));if("mouseover"===e.type)return this.styleBackup=t.getAttribute("style")||"",void t.setAttribute("style",`outline: 1px dashed red; ${this.styleBackup}`);if("mouseout"===e.type)return void t.setAttribute("style",this.styleBackup);this.elemLookup=!1,un(this.menuView.querySelector(".adi-menu-lookup"),"adi-active"),t.setAttribute("style",this.styleBackup),this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),this.removeEvent(document.body,"click",this.handleLookup,!0),function(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1}(e);const n=this.sourceNodeByInspectorNodeLookup.get(t);if(!n)return;if(n&&n.click(),!n.parentNode)return;let r,a=n.parentNode;for(a.querySelector("ul")&&a.querySelector("ul").setAttribute("data-open","true");a!==this.domView.querySelector(".adi-content");)-1!==a.className.indexOf("adi-node")&&(r=a.querySelector(".adi-trigger"),r&&(un(r,"closed"),cn(r,"opened")),a=a.parentNode,a.setAttribute("data-open","true")),a=a.parentNode;this.options.makeVisible&&n.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"}),t.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"})}addEventDelegate(e,t,n,r,a,o,s){const i=e=>{const t=e?e.target:window.event.srcElement,r=a.substr(1);let o=!1;if(s){let e=t;for(;e!==document;){if(e.id===s)return;e=e.parentNode}}o=0===a.indexOf("#")?t.id===r:0===a.indexOf(".")?-1!==t.className.indexOf(r):"*"===a||t.nodeName.toLowerCase()===a,o&&n(e)};o&&this.delegatedEvents.push({handle:i,elem:e,fn:n,evt:t}),e.addEventListener(t,i,r)}removeEvent(e,t,n,r){if("object"!=typeof e)throw new Error(`addEvent: Expected argument elem of type object, ${typeof e} given.`);let a=null;if(r)for(let r=0,o=this.delegatedEvents.length;r<o;r+=1)if(a=this.delegatedEvents[r],a.elem===e&&a.evt===t&&a.fn===n){n=a.handle,this.delegatedEvents.splice(r,1);break}}registerEvents(){const e=()=>{if("#document"!==this.instanceId){const e=window.document.querySelector(`#${this.instanceId}`);this.document=e.getInstanceData()}this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0)};document.addEventListener("instance-loaded",e),document.addEventListener("value-changed",e),document.addEventListener("ready",e),document.addEventListener("mouseup",(()=>{document.documentElement.style.cursor="default",this.vertResizing=!1,this.horizResizing=!1}),!1),document.addEventListener("mousemove",(e=>this.verticalResize(e)),!1),document.addEventListener("mousemove",(e=>this.horizontalResize(e)),!1),window.addEventListener("resize",(e=>this.refreshUI(e)),!1),document.addEventListener("keypress",(e=>this.processKey(e)),!1),document.addEventListener("log-active-element",(e=>this.handleLookup(e)),!1);this.addEventDelegate(this.domView,"click",(e=>{const t=e?e.target:window.event.srcElement,n=t.parentNode.querySelector("ul");"true"===n.getAttribute("data-open")?(un(t,"opened"),cn(t,"closed"),n.setAttribute("data-open","false")):(un(t,"closed"),cn(t,"opened"),n.setAttribute("data-open","true"))}),!1,".adi-trigger"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>{cn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>{un((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.menuView.querySelector(".adi-menu-lookup").addEventListener("click",(e=>this.handleLookup(e)),!1),document.addEventListener("handle-active",(e=>{if(e.detail.selected===this.getSelected())return;const{selected:t}=e.detail,n=this.sourceNodeByInspectorNodeLookup.get(t);if(this.options.makeVisible){const e=this.domView.querySelector(".adi-content");(n.offsetTop>=e.clientHeight||n.offsetTop<=e.scrollTop)&&(e.scrollTop=n.offsetTop-Math.floor(e.clientHeight/2))}this.drawAttrs(this.getSelected())})),document.addEventListener("execute-action",(e=>this.processExecuteAction(event)),{capture:!0}),this.addEventDelegate(this.optsView,"change",(e=>this.changeOption(e)),!1,"input"),this.addEventDelegate(this.optsView,"click",(e=>this.toggleOptions(e)),!1,".adi-opt-close"),this.menuView.querySelector(".adi-menu-config").addEventListener("click",(e=>this.toggleOptions(e)),!1),this.isInstanceViewer||this.addEventDelegate(this.attrView,"change",this.changeAttribute,!1,"input")}}class fn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceName=null,this.instance=null}connectedCallback(){this.render(),this.instance?this.shadowRoot.querySelector("#focus-button").style="display: none":this.setupFocusButton()}setInstance(e){this.instance=e}disconnectedCallback(){this.adiInstance=null}setupFocusButton(){let e="",t=null;const n=()=>{""===e?t.removeAttribute("style"):t.setAttribute("style",e),t=null},r=r=>{const{target:a}=r;if("mouseover"===r.type)return e=a.getAttribute("style")||"",a.setAttribute("style",`outline: 2px solid blue; ${e}`),void(t=a);t&&n()},a=this.shadowRoot.querySelector("#focus-button");let o=!1;const s=window.document.head.appendChild(document.createElement("style")),i=()=>{o=!1,window.document.body.removeEventListener("click",l),a.classList.remove("selected-btn"),s.innerHTML="",document.body.style.cursor="auto",window.document.body.removeEventListener("mouseover",r),window.document.body.removeEventListener("mouseout",r),t&&n()},l=e=>{i(),e.preventDefault(),e.stopPropagation(),e.target!==a&&window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e.target}}))},c=()=>{o=!0,a.classList.add("selected-btn"),document.body.style.cursor="crosshair",window.document.body.removeEventListener("click",l),s.innerHTML='fx-fore::before { color:blue; content: "Sub fore!" } fx-fore {border: solid 1px blue}',window.document.body.addEventListener("click",l),window.document.body.addEventListener("mouseover",r),window.document.body.addEventListener("mouseout",r)};window.document.addEventListener("keyup",(e=>{o&&"Escape"===e.code?i():!o&&"KeyI"===e.code&&e.ctrlKey&&c()})),a.addEventListener("click",(e=>{o?i():c(),e.preventDefault(),e.stopPropagation()}))}render(){this.shadowRoot.innerHTML="\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n background:transparent;\n }\n body {\n -webkit-animation: bugfix infinite 1s;\n font-size:1rem;\n }\n \n @-webkit-keyframes bugfix {\n from {\n padding: 0\n }\n to {\n padding: 0\n }\n }\n .adi-content {\n position: relative;\n overflow: auto;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n height: 100% !important;\n padding:0;\n font-size:0.8em;\n }\n .adi-content header{\n padding:0.5rem;\n // background:rgba(255, 255, 255, 0.2);\n border-bottom:2px solid #ddd;\n border-collapse:collapse;\n }\n .adi-content > * {\n padding:0 0.25em;\n }\n \n #adi-wrapper {\n top: 0;\n font-family: \"Segoe UI\", Arial;\n font-size: 1.1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n position:relative;\n height:calc(100% - 8rem);\n display:flex;\n }\n \n #adi-wrapper.left {\n left: 0\n }\n \n #adi-wrapper.right {\n right: 0\n }\n \n #adi-wrapper.transparent {\n background: rgba(250, 250, 250, 0.9)\n }\n \n #adi-panel {\n position:fixed;\n top:0;\n /*bottom: 0;*/\n right: 0;\n height: 24px;\n background: #d4d4d4;\n border-top: 1px solid #bbc5c9\n }\n \n #adi-panel .adi-path-wrap {\n position:absolute;\n bottom: 0;\n left: 0;\n width: 80%;\n height: 24px;\n padding: 0 13px 0 18px;\n line-height: 24px;\n overflow: hidden;\n box-sizing: border-box;\n -moz-box-sizing: border-box\n }\n \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-left, \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-right {\n display: block\n }\n \n #adi-panel .adi-path {\n height: 24px;\n overflow: hidden;\n white-space: nowrap\n }\n \n #adi-panel .adi-path-left, #adi-panel .adi-path-right {\n display: none;\n position: absolute;\n top: 0;\n width: 8px;\n height: 24px;\n background-repeat: no-repeat;\n background-position: center center;\n opacity: .7\n }\n \n #adi-panel .adi-path-left:hover, #adi-panel .adi-path-right:hover {\n opacity: 1\n }\n \n #adi-panel .adi-path-left {\n left: 7px;\n background-image: url('img/left_shift.png')\n }\n \n #adi-panel .adi-path-right {\n position:absolute;\n right: 2px;\n background-image: url('/resources/scripts/dom-inspector/img/right_shift.png')\n }\n \n #adi-panel .adi-menu-wrap {\n bottom: 0;\n right: 24px;\n width: 50px;\n height: 24px\n }\n \n #adi-panel .adi-menu-lookup, #adi-panel .adi-menu-config {\n display: block;\n float: left;\n width: 24px;\n height: 24px;\n border-left: 1px solid #bbc5c9;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: .7;\n border-radius: 0\n }\n \n #adi-panel .adi-menu-lookup:hover, #adi-panel .adi-menu-config:hover {\n background-color: #c5d9d8;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup.adi-active, #adi-panel .adi-menu-config.adi-active {\n background-color: #fafafa;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup {\n background-image: url('/resources/scripts/dom-inspector/img/lookup.png')\n }\n \n #adi-panel .adi-menu-config {\n background-image: url('/resources/scripts/dom-inspector/img/config.png')\n }\n \n \n \n #adi-vert-split {\n position: fixed;\n top: 0;\n width: 4px;\n height: 100%;\n cursor: e-resize;\n border-width: 0 1px 0 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-vert-split:hover {\n background: #c5d9d8;\n }\n \n \n #adi-dom-view {\n border-right:2px solid #ddd;\n overflow:auto;\n flex-grow:3;\n }\n \n #adi-dom-view ul {\n margin: 0;\n padding: 0;\n list-style: none\n }\n \n #adi-dom-view ul[data-open=true] {\n display: block\n }\n \n #adi-dom-view ul[data-open=false] {\n display: none\n }\n \n #adi-dom-view ul ul {\n margin: 4px 0\n }\n \n #adi-dom-view ul li {\n padding-left: 1em;\n padding-bottom: 0.125em;\n margin: 0;\n padding-top: 0.125em; \n }\n \n \n \n \n \n \n \n #adi-dom-view .adi-normal-node, \n #adi-dom-view .adi-end-node {\n margin-right: 5px;\n padding: 0 6px 0px;\n background: #d2e8ff;\n border-radius: 8px;\n cursor: default;\n font-size:0.8rem;\n }\n #adi-dom-view .adi-text-node:after, #adi-dom-view .adi-comment-node:after {\n content: '\"'\n }\n \n #adi-dom-view .adi-text-node:before, #adi-dom-view .adi-comment-node:before {\n content: '\"'\n }\n \n #adi-dom-view .adi-comment-node {\n color: #999;\n font-style: italic\n }\n \n #adi-dom-view .adi-text-node, #adi-dom-view .adi-comment-node {\n display: block;\n padding: 3px 8px;\n color: #444;\n background: #fff;\n border-radius: 8px\n }\n \n #adi-dom-view .adi-normal-node:hover, \n #adi-dom-view .adi-normal-node.hover, \n #adi-dom-view .adi-end-node:hover, \n #adi-dom-view .adi-end-node.hover {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node:hover ~ span,\n #adi-dom-view .adi-normal-node.hover ~ span,\n #adi-dom-view .adi-end-node:hover ~ span,\n #adi-dom-view .adi-end-node.hover ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node, \n #adi-dom-view .adi-end-node.adi-active-node {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node ~ span,\n #adi-dom-view .adi-end-node.adi-active-node ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n \n \n \n \n \n #adi-dom-view .adi-trigger {\n display: inline-block;\n width: 10px;\n height: 10px;\n margin: 0 5px 0 -13px;\n opacity: .7\n }\n \n #adi-dom-view .adi-trigger.closed {\n // background: url('/resources/scripts/dom-inspector/img/node_closed.png') no-repeat;\n } \n #adi-dom-view .adi-trigger.closed::before {\n content:'\\25B8';\n }\n \n #adi-dom-view .adi-trigger.opened {\n // background: url('/resources/scripts/dom-inspector/img/node_opened.png') no-repeat\n }\n #adi-dom-view .adi-trigger.opened::before{\n content:'\\25BE';\n }\n \n #adi-dom-view .adi-trigger:hover {\n opacity: 1\n }\n \n #adi-opts-view {\n position: relative;\n height: 100%;\n padding: 0 15px;\n background: #fff\n }\n \n #adi-opts-view.adi-hidden {\n display: none\n }\n \n #adi-opts-view .adi-opt-heading, #adi-opts-view .adi-opt {\n display: block;\n padding: 5px 0\n }\n \n #adi-opts-view .adi-opt-heading {\n padding: 20px 0 10px;\n font-size: 1rem;\n }\n \n #adi-opts-view .adi-opt-heading:first-child {\n padding-top: 10px\n }\n \n #adi-opts-view .adi-opt input {\n margin-right: 6px\n }\n \n #adi-opts-view .adi-opt-close {\n position: absolute;\n top: 5px;\n right: 28px;\n width: 16px;\n height: 16px;\n background: url('/resources/scripts/dom-inspector/img/options_close.png') no-repeat;\n opacity: .7;\n }\n \n #adi-opts-view .adi-opt-close:hover {\n opacity: 1;\n }\n \n #adi-attr-view {\n top: 0.5rem;\n border: 1px solid #ddd;\n overflow: auto;\n padding: 0.25em;\n height: calc(90% - 1em);\n min-width: 10rem;\n position: absolute;\n z-index: 10;\n right: 0.5rem;\n background:rgba(255,255,255,0.85);\n }\n #adi-attr-view > .adi-content{\n height:calc(100% - 5em);\n overflow:auto;\n }\n \n #adi-attr-view .adi-attr {\n display: block;\n padding: 0.25em;\n }\n \n #adi-attr-view hr {\n height: 1px;\n border: none\n }\n \n #adi-attr-view input[type=text] {\n width: calc(100% - 0.5em);\n margin-top: 3px;\n padding: 2px;\n }\n \n #adi-horiz-split {\n height: 4px;\n cursor: n-resize;\n border-width: 0 0 1px 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-horiz-split:hover {\n background: #c5d9d8;\n }\n \n #adi-dom-view .fore-node{\n background: var(--paper-blue-700);\n font-size:1.1em;\n color:white;\n }\n #adi-dom-view .adi-normal-node.fore-node:hover {\n background: var(--paper-grey-700);\n color:white;\n }\n #adi-dom-view .adi-end-node.fore-node{\n background: var(--paper-blue-700);\n font-size:1em;\n color:white;\n }\n\n #adi-dom-view .adi-node .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node ~ .adi-end-node\n {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-node.fx-fore{\n background:var(--paper-blue-grey-50); \n }\n #adi-dom-view .adi-node.fx-model{\n background:var(--paper-blue-grey-100); \n padding:0.25em 0;\n } \n \n #adi-dom-view .adi-node.action .fore-node {\n background:var(--paper-blue-grey-100);\n color:black;\n font-family:monospace;\n }\n \n .toggleView{\n /*width:20px;*/\n /*height: 20px;*/\n }\n input, select{\n display: block;\n }\n header{\n background:rgba(255, 255, 255, 0.2);\n }\n\n .selected-btn { color: orange }\n \n </style>\n \n <slot name=\"header\"></slot>\n <button id=\"focus-button\">Focus</button>\n <slot></slot>\n \n ",!this.hasAttribute("instance")||this.getAttribute("instance"),this.adiInstance=new mn(this.shadowRoot,this.hasAttribute("instance")?this.instance:"#document")}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}}customElements.get("fx-dom-inspector")||customElements.define("fx-dom-inspector",fn);class gn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceElement=null,this.foreSelector=null}connectedCallback(){this.container=this.querySelector(".json-path-picker-container"),this.foreSelector=this.hasAttribute("fore")?this.getAttribute("fore"):"fx-fore",this.render()}render(){const e=this.hasAttribute("instance")?this.getAttribute("instance"):"default";if(!document.querySelector(this.foreSelector))throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n font-size:0.8em;\n background:rgba(250, 250, 250, 0.9);\n }\n .container{\n margin-left:1em;\n }\n .header{\n margin-left:0;\n }\n\n ::slot[name='header']{\n margin-left:-1em;\n }\n /* Syntax highlighting for JSON objects */\n ul.json-dict, ol.json-array {\n list-style-type: none;\n margin: 0 0 0 1px;\n border-left: 1px dotted #ccc;\n padding-left: 2em;\n }\n .json-string {\n // color: #0B7500;\n }\n .json-literal {\n color: #1A01CC;\n font-weight: bold;\n }\n \n /* Toggle button */\n a.json-toggle {\n position: relative;\n color: inherit;\n text-decoration: none;\n }\n a.json-toggle:focus {\n outline: none;\n }\n a.json-toggle:before {\n content: "\\25BC"; /* down arrow */\n position: absolute;\n display: inline-block;\n width: 1em;\n left: -1.2em;\n font-size:0.8em;\n }\n a.json-toggle.collapsed:before {\n content: "\\25B6"; /* left arrow */\n }\n \n /* Collapsable placeholder links */\n a.json-placeholder {\n color: #aaa;\n padding: 0 1em;\n text-decoration: none;\n }\n a.json-placeholder:hover {\n text-decoration: underline;\n }\n \n /* Copy path icon */\n .pick-path {\n color: lightgray;\n cursor: pointer;\n margin-left: 3px;\n }\n \n .pick-path:hover {\n color: darkgray;\n }\n \n \n </style>\n <slot name="header">\n <header class="header">${e}</header>\n </slot>\n <slot></slot>\n \n <div class="container"></div>\n \n `;const t=document.querySelector(`#${e}`);if(!t||"FX-INSTANCE"!==t.nodeName||"json"!==t.getAttribute("type"))throw new Error(`this '${e}' does not match an fx-instance element or is not of type JSON`);const n=this.shadowRoot.querySelector(".container"),r=t.instanceData;let a=this.json2html(r,{outputWithQuotes:!0});this.isCollapsable(r)&&(a="<a href='#' class=\"json-toggle\"></a>".concat(a)),n.innerHTML=a;this.shadowRoot.querySelectorAll(".json-toggle").forEach((e=>{e.addEventListener("click",this._handleToggleEvent.bind(this))}))}disconnectedCallback(){}_isHidden(e){var t=e.offsetWidth,n=e.offsetHeight;return 0===t&&0===n||"none"===window.getComputedStyle(e).display}_handleToggleEvent(e){const t=e.target;t.classList.toggle("collapsed");for(var n=this._siblings(t,"ul.json-dict, ol.json-array",(function(e){e.style.display=""===e.style.display||"block"===e.style.display?"none":"block"})),r=0;r<n.length;r+=1)if(this._isHidden(n[r])){for(var a=n[r].children,o=0,s=0;s<a.length;s+=1)"LI"===a[s].tagName&&(o+=1);var i=o+(o>1?" items":" item");n[r].insertAdjacentHTML("afterend",'<a href class="json-placeholder">'.concat(i,"</a>"))}else this._siblings(n[r],".json-placeholder",(function(e){return e.parentNode.removeChild(e)}));e.stopPropagation(),e.preventDefault()}_siblings(e,t,n){for(var r=[],a=0;a<e.parentNode.children.length;a+=1){var o=e.parentNode.children[a];o!==e&&"string"==typeof t&&o.matches(t)&&r.push(o)}if(n&&"function"==typeof n)for(var s=0;s<r.length;s+=1)n(r[s]);return r}json2html(e,t){let n="";if("string"==typeof e){const t=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");this.isUrl(t)?n+='<a href="'.concat(t,'" class="json-string">').concat(t,"</a>"):n+='<span class="json-string">"'.concat(t,'"</span>')}else if("number"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if("boolean"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if(null===e)n+='<span class="json-literal">null</span>';else if(e instanceof Array)if(e.length>0){n+='[<ol class="json-array">';for(var r=0;r<e.length;r+=1)n+='<li data-key-type="array" data-key="'.concat(r,'">'),this.isCollapsable(e[r])&&(n+='<a href="#" class="json-toggle"></a>'),n+=this.json2html(e[r],t),r<e.length-1&&(n+=","),n+="</li>";n+="</ol>]"}else n+="[]";else if("object"===this._typeof(e)){let r=Object.keys(e).length;if(r>0){for(var a in n+='{<ul class="json-dict">',e)if(e.hasOwnProperty(a)){n+='<li data-key-type="object" data-key="'.concat(a,'">');const o=t.outputWithQuotes?'<span class="json-string">"'.concat(a,'"</span>'):a;this.isCollapsable(e[a])?n+="<a href='#' class=\"json-toggle\">".concat(o,"</a>"):n+=o,n+=": ".concat(this.json2html(e[a],t)),r-=1,r>0&&(n+=","),n+="</li>"}n+="</ul>}"}else n+="{}"}return n}isUrl(e){return/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/.test(e)}_typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?this._typeof=function(e){return typeof e}:this._typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},this._typeof(e)}isCollapsable(e){return e instanceof Object&&Object.keys(e).length>0}static get observedAttributes(){return["data"]}attributeChangedCallback(e,t,n){"data"===e&&(this.jsonTextarea.value=n,this.updateTree(n))}updateTree(e){try{this.data=JSON.parse(e),this.treeView.innerHTML="",this.treeView.appendChild(this.createTreeView(this.data,""))}catch(e){console.error(e),alert("Invalid JSON")}}createTreeView(e,t){let n=document.createElement("ul");if(n.classList.add("jp-ul"),Array.isArray(e))e.forEach(((e,r)=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"["+r+"]";a.appendChild(this.createItemView(o,e)),n.appendChild(a)}));else if("object"==typeof e&&null!==e)Object.keys(e).forEach((r=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"."+r;a.appendChild(this.createItemView(o,e[r])),n.appendChild(a)}));else{let r=document.createElement("li");r.classList.add("jp-li"),r.appendChild(this.createItemView(t,e)),n.appendChild(r)}return n}}customElements.get("fx-json-instance")||customElements.define("fx-json-instance",gn);class yn extends HTMLElement{static get properties(){return{fore:{type:Object,description:"The fx-fore element the devtools are attached to"},instances:{type:Array,description:"Instances of selected Fore element"},selector:{type:String,description:"optional selector to attach to a certain fx-fore element with given id"}}}constructor(){super(),this.attachShadow({mode:"open"}),Object.keys(this.constructor.properties).forEach((e=>{const t=this.constructor.properties[e],n=t.attribute||e,r=this.getAttribute(n)||t.default,a=t.type(r);this[e]=a})),this.isResizing=!1,this.lastY=0,this.defaultHeight="40vh",this.buttonByInstanceId=new Map;const e=e=>{this.fore=e,this.instances=[...this.fore.getModel().instances];const t=this.shadowRoot.querySelector(".instances header");t.textContent="Data ",this.instances.forEach((e=>{const n=document.createElement("button");n.setAttribute("type","button"),n.textContent=e.id,t.appendChild(n),this.buttonByInstanceId.set(e.id,n),n.addEventListener("click",(()=>this.selectInstance(e.id)))})),this.instances.length&&this.selectInstance(this.instances[0].id)},t=document.querySelector("fx-fore");t&&(t.inited?e(t):t.addEventListener("model-construct-done",(()=>e(t)))),window.document.addEventListener("log-active-element",(t=>{const n=t?t.detail?.target||t.target:window.event.srcElement,r=n.nodeType===Node.DOCUMENT_NODE?null:n.closest("fx-fore");r&&e(r);const a=this.instances.find((e=>"xml"===e.type&&e.instanceData.contains(n)));a&&this.selectInstance(a.id)}))}_getInstanceForTarget(e){this.instances.forEach((t=>"xml"===t.type&&t.instanceData.contains(e)||"json"===t.type?t:void 0))}selectInstance(e){const t=this.buttonByInstanceId.get(e);if(!t)return;if(t.classList.contains("selected-btn"))return;const n=this.shadowRoot.querySelector(".selected-btn");n&&n.classList.remove("selected-btn"),t.classList.add("selected-btn");const r=this.shadowRoot.querySelector(".instance-panel");r.innerHTML="",this.instances=[...this.fore.querySelectorAll("fx-instance")];const a=Array.from(this.instances).find((t=>t.id===e)),o=this._renderInstancePanel(a);r.append(o)}connectedCallback(){this.render()}_startResize(e){this.isResizing=!0,this.lastY=e.clientY}_resizePanel(e){if(!this.isResizing)return;const t=e.clientY-this.lastY;this.style.height=this.offsetHeight-t+"px",this.lastHeight=this.style.height,this.lastY=e.clientY}_stopResize(e){e.preventDefault(),e.stopPropagation(),this.isResizing=!1,document.body.style.height="inherit",document.body.style.width="inherit";const t=document.body.scrollHeight+this.offsetHeight;document.body.style.height=`${t}px`}render(){const e=`\n <section class="wrapper">\n <slot></slot>\n <details class="fx-devtools" open>\n <div class="resizer"></div>\n <summary>Fore Glass \n <div>\n <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">\n <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>\n </svg>\n <button class="optionsBtn" id="optionsTrigger">⚙</button> \n </div>\n </summary>\n <section class="panels">\n <section class="log">\n <fx-action-log selector="${this.selector}"></fx-action-log>\n </section>\n <section class="dom">\n <fx-dom-inspector>\n <header slot="header">Document</header>\n </fx-dom-inspector>\n </section>\n <section class="instances">\n <header></header>\n <div class="instance-panel">\n </div>\n </section>\n <section id="options">\n <fx-log-settings></fx-log-settings>\n </section>\n </section>\n </details>\n </section>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n position:fixed;\n bottom:0;\n left:0;\n width:100vw;\n height:var(--fx-devtools-height);\n font-style:inherit;\n font-family: 'Verdana' , 'Sans';\n font-size:1em;\n max-width:100vw;\n height:3em;\n }\n :host(.open){\n height:40vh;\n }\n \n fx-action-log{\n height:100%;\n }\n fx-dom-inspector{\n max-height:100%;\n height:100%;\n position:relative;\n }\n body {\n }\n details{\n height:100%;\n background:#ebf6ff;\n }\n .dom{\n width:45%;\n border-left:1px solid #999;\n position:relative\n }\n .dom fx-minimap{\n position:absolute;\n right:0;\n top:0;\n width:5rem;\n height:6rem;\n }\n header{\n padding:0.5rem;\n border-bottom:2px solid #ddd;\n font-size:1rem;\n }\n header button{\n margin:0 0.5em;\n border:thin solid #999;\n padding:0 0.5em;\n cursor:pointer;\n }\n header button:hover{\n background:white;\n }\n \n header button.selected-btn{\n background:steelblue;\n color:white;\n }\n .instances{\n width:35%;\n border-left:1px solid #999;\n }\n .instance-panel{\n height:100%;\n overflow:auto;\n }\n .panels{\n display:grid;\n grid-template-columns:20% 50% 30%;\n height:100%;\n width:100%;\n max-height:100%;\n border-top:thin solid #ddd;\n }\n .panels > section {\n min-height:20rem;\n/*\n background:#efefef;\n*/\n position:relative;\n display:inline-block;\n height:100%;\n width:auto;\n }\n #options{\n display:none;\n }\n #options.open{\n position:absolute;\n z-index:10;\n left:0;\n top:3em;\n height:100%;\n display:block;\n padding:0;\n background:rgba(255,255,255,0.95);\n width:100%;\n }\n .optionsBtn{\n font-size:2rem;\n }\n details[open] .optionsBtn{\n display:inline;\n }\n .resizer{\n width:100vw;\n height:6px;\n background:rgba(215,220,235,0.3);\n cursor: ns-resize;\n position:absolute;\n top:0;\n \n }\n summary{\n height:3rem;\n padding:0 1em;\n border-bottom:2px solid #ddd;\n display:flex;\n justify-content:space-between;\n align-items:center;\n color:rgba(0,0,0,0.7);\n background: rgba(235, 255, 255, 0.2);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(255, 255, 255, 0.3);\n \n color:white;\n font-weight:300;\n background: rgb(119,119,119);\n background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);\n\n }\n summary button{\n padding:0;\n border:0;\n background:transparent;\n }\n .wrapper{\n height:100%;\n }\n .vertDevider{\n background:#ddd;\n width:4px;\n height:100%;\n cursor: ew-resize;\n }\n \n </style>\n ${e}\n `,this.resizer=this.shadowRoot.querySelector(".resizer"),this.resizer.addEventListener("mousedown",this._startResize.bind(this)),document.addEventListener("mousemove",this._resizePanel.bind(this)),document.addEventListener("mouseup",this._stopResize.bind(this));const t=this.shadowRoot.querySelector("#optionsTrigger");t.addEventListener("click",(()=>{const e=this.shadowRoot.querySelector("#options");e.classList.toggle("open"),e.classList.contains("open")?t.style.background="lightsteelblue":t.style.background="transparent"}));this.shadowRoot.querySelector(".fx-devtools").addEventListener("click",(e=>{"DIV"===e.target.nodeName&&e.target.classList.contains("resizer")||(e.target.parentNode.open?(this.removeAttribute("open"),this.lastHeight=this.style.height,this.style.height="3em"):(this.setAttribute("open",""),this.style.height=this.lastHeight?this.lastHeight:"40vh"))})),this.classList.add("open")}_handleOpen(e){document.body.style.height=""}_renderInstancePanel(e){if("xml"===e.type){const t=document.createElement("fx-dom-inspector");return t.setInstance(e),t.setAttribute("instance",e.id),t}if("json"===e.type){const t=document.createElement("fx-json-instance");t.setAttribute("instance",e.id);const n=document.createElement("span");return n.setAttribute("slot","header"),t.append(n),t}}}customElements.get("fx-devtools")||customElements.define("fx-devtools",yn);class wn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.src=""}connectedCallback(){this.src=this.getAttribute("src");const e=`\n <fx-fore src="${this.src}">\n </fx-fore>\n <slot id="default"></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n display:block;\n }\n \n </style>\n ${e}\n `;this.shadowRoot.querySelector("#default").addEventListener("slotchange",(async e=>{const t=e.target.assignedElements().filter((e=>"LINK"===e.nodeName.toUpperCase()));if(!t)return;const n=[...document.styleSheets].map((e=>{if(t.find((t=>t.href===e.href)))try{return[...e.cssRules].map((e=>e.cssText)).join("")}catch(t){console.log("Access to stylesheet %s is denied. Ignoring…",e.href)}})).filter(Boolean).join("\n"),r=new CSSStyleSheet;r.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[r]}));const t=this.querySelector("fx-action");if(t){const e=t.cloneNode(!0);this.removeChild(t);this.shadowRoot.querySelector("fx-fore").appendChild(e)}}}customElements.get("fore-component")||customElements.define("fore-component",wn);class vn extends HTMLElement{constructor(){super(),this.canvas=document.createElement("canvas"),this.options=this.getAttribute("options")?JSON.parse(this.getAttribute("options")):{},this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(this.canvas),this.WIN=window,this.DOC=this.WIN.document,this.DOC_EL=this.DOC.documentElement,this.BODY=this.DOC.querySelector("body")}connectedCallback(){this.ctx=this.canvas.getContext("2d"),this.black=e=>`rgba(0,0,0,${e/100})`,this.viewport=this.querySelector(this.getAttribute("selector")),this.settings=Object.assign({viewport:this.viewport,styles:{"header,footer,section,article":this.black(8),"h1,a":this.black(10),"h2,h3,h4":this.black(8)},back:this.black(2),view:this.black(5),drag:this.black(10),interval:null},this.options);const e=(e,t,n,r)=>n.split(/\s+/).forEach((n=>e[t](n,r)));this.on=(t,n,r)=>e(t,"addEventListener",n,r),this.off=(t,n,r)=>e(t,"removeEventListener",n,r),this.Rect=(e,t,n,r)=>({x:e,y:t,w:n,h:r}),this.rect_rel_to=(e,t={x:0,y:0})=>this.Rect(e.x-t.x,e.y-t.y,e.w,e.h),this.rect_of_doc=()=>this.Rect(0,0,document.documentElement.scrollWidth,document.documentElement.scrollHeight),this.rect_of_win=()=>this.Rect(window.pageXOffset,window.pageYOffset,document.documentElement.clientWidth,document.documentElement.clientHeight),this.el_get_offset=e=>{const t=e.getBoundingClientRect();return{x:t.left+window.pageXOffset,y:t.top+window.pageYOffset}},this.rect_of_el=e=>{const{x:t,y:n}=this.el_get_offset(e);return this.Rect(t,n,e.offsetWidth,e.offsetHeight)},this.rect_of_viewport=e=>{const{x:t,y:n}=this.el_get_offset(e);return this.Rect(t+e.clientLeft,n+e.clientTop,e.clientWidth,e.clientHeight)},this.rect_of_content=e=>{const{x:t,y:n}=this.el_get_offset(e);return this.Rect(t+e.clientLeft-e.scrollLeft,n+e.clientTop-e.scrollTop,e.scrollWidth,e.scrollHeight)},this.calc_scale=(()=>{const e=this.canvas.clientWidth,t=this.canvas.clientHeight;return(n,r)=>Math.min(e/n,t/r)})(),this.resize_canvas=(e,t)=>{this.canvas.width=e,this.canvas.height=t,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`},this.viewport=this.settings.viewport,this.find=e=>Array.from((this.viewport||document).querySelectorAll(e)),this.drag=!1,this.root_rect=null,this.view_rect=null,this.scale=null,this.drag_rx=null,this.drag_ry=null}draw_rect(e,t){t&&(this.ctx.beginPath(),this.ctx.rect(e.x,e.y,e.w,e.h),this.ctx.fillStyle=t,this.ctx.fill())}find(e){return Array.from((this.viewport||this.DOC).querySelectorAll(e))}apply_styles(e){Object.keys(e).forEach((t=>{const n=e[t];this.find(t).forEach((e=>{this.draw_rect(this.rect_rel_to(this.rect_of_el(e),this.root_rect),n)}))}))}draw(){this.root_rect=this.viewport?this.rect_of_content(this.viewport):this.rect_of_doc(),this.view_rect=this.viewport?this.rect_of_viewport(this.viewport):this.rect_of_win(),this.scale=this.calc_scale(this.root_rect.w,this.root_rect.h),this.resize_canvas(this.root_rect.w*this.scale,this.root_rect.h*this.scale),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.scale(this.scale,this.scale),this.draw_rect(this.rect_rel_to(this.root_rect,this.root_rect),this.settings.back),this.apply_styles(this.settings.styles),this.draw_rect(this.rect_rel_to(this.view_rect,this.root_rect),this.drag?this.settings.drag:this.settings.view)}on_drag(e){e.preventDefault();const t=this.rect_of_viewport(this.canvas),n=(e.pageX-t.x)/this.scale-this.view_rect.w*this.drag_rx,r=(e.pageY-t.y)/this.scale-this.view_rect.h*this.drag_ry;this.viewport?(this.viewport.scrollLeft=n,this.viewport.scrollTop=r):this.WIN.scrollTo(n,r),this.draw()}on_drag_end(e){this.drag=!1,this.canvas.style.cursor="pointer",this.BODY.style.cursor="auto",this.off(this.WIN,"mousemove",this.on_drag),this.off(this.WIN,"mouseup",this.on_drag_end),this.on_drag(e)}on_drag_start(e){this.drag=!0;const t=this.rect_of_viewport(this.canvas),n=this.rect_rel_to(this.view_rect,this.root_rect);this.drag_rx=((e.pageX-t.x)/this.scale-n.x)/n.w,this.drag_ry=((e.pageY-t.y)/this.scale-n.y)/n.h,(this.drag_rx<0||this.drag_rx>1||this.drag_ry<0||this.drag_ry>1)&&(this.drag_rx=.5,this.drag_ry=.5),this.canvas.style.cursor="crosshair",this.BODY.style.cursor="crosshair",this.on(this.WIN,"mousemove",this.on_drag),this.on(this.WIN,"mouseup",this.on_drag_end),this.on_drag(e)}init(){this.canvas.style.cursor="pointer",this.on(this.canvas,"mousedown",this.on_drag_start),this.on(this.viewport||this.WIN,"load resize scroll",this.draw()),this.settings.interval>0&&setInterval((()=>this.draw()),this.settings.interval),this.draw()}}async function xn(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fx-minimap")||customElements.define("fx-minimap",vn);class bn extends(kt(HTMLElement)){static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},phase:{type:String},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}connectedCallback(){this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")&&(this.event=this.getAttribute("event")),this.hasAttribute("defaultAction")?this.defaultAction=this.getAttribute("defaultAction"):this.defaultAction="perform",this.hasAttribute("phase")?this.phase=this.getAttribute("phase"):this.phase="default",this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0,this._addUpdateListener()}_addUpdateListener(){if(this.target=this.getAttribute("target"),this.target)if("#window"===this.target)window.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else if("#document"===this.target)document.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else{if(this.targetElement=ct(this.target,this),!this.targetElement)return;this?.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}else this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}async performSafe(){try{return await this.perform(),!0}catch(e){const t=`<${this.localName} ${Array.from(this.attributes).map((e=>`${e.name}="${e.value}"`)).join(" ")}>…</${this.localName}>`;return await St.dispatch(this,"error",{message:`The action could not be performed. ${e} The error came from ${t}`}),!1}}async execute(e){if(e&&e.target.nodeType!==Node.DOCUMENT_NODE&&e.target.closest("fx-fore")&&e.target.closest("fx-fore")!==this.closest("fx-fore"))return;"stop"===this.propagate&&e.stopPropagation(),"cancel"===this.defaultAction&&e.preventDefault();let t=()=>{};e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===$t.outermostHandler&&($t.outermostHandler=this,this.dispatchEvent(new CustomEvent("outermost-action-start",{composed:!0,bubbles:!0,cancelable:!0,detail:{cause:e?.type}}))),e&&(this.currentEvent=e),this.needsUpdate=!1;try{this.evalInContext()}catch(e){console.warn("evaluation failed",e)}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),!this.ifExpr||vt(this.ifExpr,Ct(this),this)){if(this.whileExpr){const e=async()=>{await xn(this.delay||0),et.contains(this.getOwnerForm(),this)&&vt(this.whileExpr,Ct(this),this)&&this.performSafe()&&(this.delay?e():await e())};return await e(),void this._finalizePerform(t)}if(this.delay&&(await xn(this.delay),!et.contains(this.getOwnerForm(),this)))return this.actionPerformed(),void t();await this.performSafe(),this._finalizePerform(t)}else this._finalizePerform(t)}_finalizePerform(e){this.currentEvent=null,this.actionPerformed(),$t.outermostHandler===this&&($t.outermostHandler=null,this.dispatchEvent(new CustomEvent("outermost-action-end",{composed:!0,bubbles:!0,cancelable:!0}))),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext(),this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}))}actionPerformed(){const e=this.getModel();e&&e.inited&&($t.outermostHandler&&!et.contains($t.outermostHandler.ownerDocument,$t.outermostHandler)&&($t.outermostHandler=null),!this.needsUpdate||$t.outermostHandler!==this&&$t.outermostHandler?this.needsUpdate&&($t.outermostHandler.needsUpdate=!0):(e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){St.dispatch(this,"action-performed",{})}}bn.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",bn);class An extends bn{static get properties(){return{...bn.properties,ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),a=this._generateInstance(n.content,r);e.appendChild(a)}_dispatch(){const e=ct(this.repeat,this);St.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",An);class En extends bn{static get properties(){return{...super.properties,ref:{type:String}}}async perform(){const e=Ct(this.getAttributeNode("ref")||this,this.ref);this.nodeset=wt(this.ref,e,this);const t=et.resolveInstance(this),n=this.getModel().getInstance(t),r=St.getDomNodeIndexString(this.nodeset),a=this.nodeset;let o;if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:r}})),Array.isArray(a)){if(0===a.length)return;o=a[0].parentNode,a.forEach((e=>{this._deleteNode(o,e)}))}else o=a.parentNode,this._deleteNode(o,a);await St.dispatch(n,"deleted",{ref:r,deletedNodes:a}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",En);class Nn extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e="#"+this.control;let t=document.querySelector(e);if(!t)return void console.warn("targetElement of setfocus action does not exist (yet)",e);const n=t.closest("fx-repeatitem");if(n)return t=n.querySelector(e),void this._focus(t);const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector("[repeat-index] "+e)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&"function"==typeof e.getWidget&&e.getWidget().focus(),e&&e.nodeType===Node.ELEMENT_NODE&&e.click()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",Nn);class Tn extends bn{static get properties(){return{...super.properties,at:{type:Number},position:{type:Number},origin:{type:Object},keepValues:{type:Boolean}}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_getOriginSequence(e,t){let n;if(this.origin){let t;try{t=yt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=t,n&&!this.keepValues&&this._clear(n));return n}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=yt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t.cloneNode(!0)}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?bt(this.getAttribute("at"),e,this):t.length}async perform(){let e,t;this.hasAttribute("context")&&(e=Ct(this.getAttributeNode("context"),this.getAttribute("context")),t=wt(this.getAttribute("context"),e,this.getOwnerForm())),this.hasAttribute("ref")&&(e||(e=Ct(this.getAttributeNode("ref"),this.ref)),t=wt(this.ref,e,this));const n=this._cloneOriginSequence(e,t);if(!n)return;let r,a;if(0===t.length)r=e,e.appendChild(n),a=1;else{if(this.hasAttribute("at")?(a=bt(this.getAttribute("at"),e,this),r=t[a-1]):(a=t.length,r=t[t.length-1]),!r){a=1,r=t;a=bt("count(preceding::*)",t,this.getOwnerForm())+1}this.position&&"before"===this.position&&r.parentNode.insertBefore(n,r),this.position&&"after"===this.position&&(a+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(n):this.hasAttribute("context")?(a=1,r.prepend(n)):r.insertAdjacentElement("afterend",n))}const o=this.getModel().getInstance(et.resolveInstance(this)),s=St.getDomNodeIndexString(n);this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:s}})),St.dispatch(o,"insert",{"inserted-nodes":n,"insert-location-node":r,position:this.position}),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:n,index:a}})),this.needsUpdate=!0}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",Tn);class Bn extends bn{constructor(){super(),this.attachShadow({mode:"open"})}static get properties(){return{...bn.properties,modelItem:void 0,messageTextContent:{type:String,get value(){return"here!"}}}}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.message="",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}renderHTML(){return"\n <slot></slot>\n "}async perform(){super.perform(),this.hasAttribute("value")?this.message=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),this.message=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!1,bubbles:!0,detail:{level:this.level,message:this.message}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return xt(e,Ct(this,e),this)}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",Bn);class In extends bn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=gt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",e?.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}dispatchExecute(){}setValue(e,t){const n=e;if(n&&n.value!==t){const r=St.getDomNodeIndexString(e.node),a=this.event,o=this;this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:o,event:a,value:t,path:r}})),t?.nodeType?(t.nodeType===Node.ELEMENT_NODE&&(n.value=t.textContent),t.nodeType===Node.ATTRIBUTE_NODE&&(n.value=t.getValue())):n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0}}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",In);class Cn extends bn{constructor(){super(),this.value="",this.url=null,this.target=null}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission"),this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.target=this.hasAttribute("target")?this.getAttribute("target"):null}async perform(){super.perform(),console.log("submitting ",this.submission),this.getOwnerForm().classList.remove("submit-validation-failed");const e=this.getModel().querySelector(`#${this.submission}`);if(null!==e){if(this.url){const t=this.evaluateAttributeTemplateExpression(this.url,this);e.parameters.set("url",t)}if(this.target){const t=this.evaluateAttributeTemplateExpression(this.target,this);e.parameters.set("target",t)}console.log("submission",e),await e.submit()}else this.dispatchEvent(new CustomEvent("log",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,message:`fx-submission element with id: '${this.submission}' not found`,level:"Error"}}))}}customElements.get("fx-send")||window.customElements.define("fx-send",Cn);class Sn extends bn{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void St.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",Sn);class On extends bn{static get properties(){return{...super.properties,name:{type:String},targetid:{type:String},details:{type:String}}}constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){super.perform();const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{const n=e.getAttribute("name"),r=e.getAttribute("value"),a=e.getAttribute("expr");if(a){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=gt(a,this.getInScopeContext(),this);let o=null;if(e.nodeName){o=(new XMLSerializer).serializeToString(e)}t[n]=o||e}r&&(t[n]=r)})),this.targetid){let e=ct(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",On);class Fn extends bn{async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",Fn);class Dn extends bn{async perform(){if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.hasAttribute("self")){const e=et.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))this.getOwnerForm().forceRefresh();else if(this.hasAttribute("control")){const e=ct(this.getAttribute("control"),this);e&&St.isUiElement(e.nodeName)&&"function"==typeof e.refresh&&e.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",Dn);class kn extends bn{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform();const e=yt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}replace(e,t){if(e&&t)if(e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}else console.warn("fx-replace: one argument is not a node")}}customElements.get("fx-replace")||window.customElements.define("fx-replace",kn);class Rn extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform();const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",Rn);class Mn extends bn{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="";const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",Mn);class Un extends Mn{static get properties(){return{...Mn.properties,message:{type:String}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",Un);class Gn extends Mn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||St.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ct(this.dialog,this);e||console.error("target dialog with given id does not exist",this.dialog),e.open(),St.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",Gn);class Ln extends bn{static get properties(){return{...super.properties,dialog:{type:String}}}connectedCallback(){super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||St.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ct(this.dialog,this);e.hide(),St.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",Ln);class $n extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.addEventListener("reload",(()=>{window.location.reload()}),{once:!0})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),St.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",$n);class Hn extends bn{static get properties(){return{...super.properties,instance:{type:String}}}connectedCallback(){super.connectedCallback(),this.instance=this.getAttribute("instance"),this.instance||St.dispatch(this,"error",{message:"instance does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));this.getModel().getInstance(this.instance).reset(),this.needsUpdate=!0}}customElements.get("fx-reset")||window.customElements.define("fx-reset",Hn);class Pn extends bn{static get properties(){return{...super.properties,attachTo:{type:String},url:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"}),this.url=""}connectedCallback(){super.connectedCallback(),this.attachTo=this.hasAttribute("attach-to")?this.getAttribute("attach-to"):"_self",this.awaitEvent=this.hasAttribute("await")?this.getAttribute("await"):"",this.url=this.hasAttribute("url")?this.getAttribute("url"):"";this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}`}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){await super.perform();const e=this.querySelector("template");if(e){const t=e.content.cloneNode(!0),n=document.importNode(t,!0);if(this.attachTo.startsWith("#")){const e=ct(this.attachTo.substring(1),this);for(;e.firstChild;)e.removeChild(e.firstChild);if(this.awaitEvent){let t;const r=new Promise((e=>{t=e})),a=()=>{t(),e.removeEventListener(this.awaitEvent,a)};return e.appendChild(n),e.addEventListener(this.awaitEvent,a),await r,this.needsUpdate=!0,void St.dispatch(this,"loaded",{attachPoint:this.attachTo,content:n})}e.appendChild(n),this.needsUpdate=!0}St.dispatch(this,"loaded",{})}else if(this.url){this.url=this.evaluateAttributeTemplateExpression(this.url,this),"_blank"===this.attachTo&&window.open(this.url),"_self"===this.attachTo&&(window.location.href=this.url);try{const e=await fetch(this.url,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),t=await e.text();this.attachTo||(this.innerHtml=t),this._attachToElement(t),St.dispatch(this,"loaded",{url:this.url})}catch(e){throw new Error(`failed loading data ${e}`)}}else this.dispatchEvent(new CustomEvent("log",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,message:"neiter template element nor Url was specified.",level:"Error"}}))}_attachToElement(e){let t;if(e.nodeType)t=e;else try{t=(new DOMParser).parseFromString(e,"text/html").firstElementChild}catch(e){St.dispatch(this,"error",{message:"parsing of content as HTML failed"})}if(this.attachTo.startsWith("_")||this.attachTo.startsWith("#")||St.dispatch(this,"error",{message:'valid values for "attach-to" start with "_" or "#"'}),this.attachTo.startsWith("#")){const e=ct(this.attachTo.substring(1),this);if(e.innerHTML="",t.querySelector("fx-fore"))return void e.append(t.querySelector("fx-fore").cloneNode(!0));const n=t.querySelector("body").cloneNode(!0);e.appendChild(n.firstElementChild)}}_evaluateUrlExpression(){const e=this.getAttribute("url");if(!e)throw new Error("url not specified");return e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const t=e.substring(1,e.length-1),n=Ct(this,t);if(!n)return console.warn("no inscope context for ",this),e;const r=et.getInstanceId(t),a=r?this.getModel().getInstance(r):this.getModel().getDefaultInstance();try{return xt(t,n,this,null,a)}catch(t){return console.warn("ignoring unparseable url",t),e}}))}}customElements.get("fx-load")||window.customElements.define("fx-load",Pn);class _n extends(kt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,null===this.signature&&console.error("signature is a required attribute"),this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText;const e=this.getAttribute("type")||"text/xpath",t=this.signature.match(/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>(?:\(\)|[^)])*)\)(?: as (?<returnType>.*))?/);if(!t)throw new Error(`Function signature ${this.signature} could not be parsed`);const{prefix:n,localName:r,params:a,returnType:o}=t.groups,s="local"!==n&&n?`${n}:${r}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:r};n||st.push(r);const i=a?a.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>.+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(e){case"text/javascript":{const e=new Function("_domFacade",...i.map((e=>e.variableName)),"form",this.functionBody);Ke(s,i.map((e=>e.variableType)),o||"item()*",((...t)=>e.apply(this.getInScopeContext(),[...t,this.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const t="text/xpath"===e?"XPath3.1":"text/xquery"===e?"XQuery3.1":"XQueryUpdate3.1",n=(e,...n)=>gt(this.functionBody,this.getInScopeContext(),this.getOwnerForm(),i.reduce(((e,t,r)=>(e[t.variableName.replace("$","")]=n[r],e)),{}),{language:t});Ke(s,i.map((e=>e.variableType)),o||"item()*",n);break}default:throw new Error(`Unexpected mimetype ${e} for function`)}}}customElements.get("fx-function")||customElements.define("fx-function",_n);
|
|
43
9
|
//# sourceMappingURL=fore-dev.js.map
|