diff --git a/.gitignore b/.gitignore index 9ac1625..88c3620 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules .vscode .DS_Store *.xar +src/data/test.xml diff --git a/README.md b/README.md index 80b454f..ad14507 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Synchronizes your data collection with GitHub and GitLab. ## Current restrictions -In version 1.1.0 not implemented: +In version 1.1.1 not implemented: - webhooks are not fully implemented. ## Building and Installation @@ -48,35 +48,39 @@ Run tests with ```npm test``` ## Configuration -Tuttle is configured in `modules/config.xqm`. +Tuttle is configured in `data/tuttle.xml`. ### Gitservice configuration -The name of the configuration is always the destination collection. It will be configured in `modules/config.xqm` +@name is always the name of the destination collection. It will be configured in `data/tuttle.xml` An example: -```xquery - "sample-collection-github" : map { - "vcs" : "github", - "baseurl" : "https://api.github.com/", - "repo" : "tuttle-demo", - "owner" : "Jinntec", - "ref" : "master", - "token" : "146152be6a97a9efe9dd4647e71da8f3e4faf263", - "hookuser" : "admin", - "hookpasswd" : "" - }, - "sample-collection-gitlab" : map { - "vcs" : "gitlab", - "baseurl" : "https://gitlab.com/api/v4/", - "project-id" : "25852323", - "ref" : "master", - "token" : "9vq6jmzbxCMtNkobUfoM", - "hookuser" : "admin", - "hookpasswd" : "" - } +```xml + + + true + github + https://api.github.com/ + tuttle-sample-data + tuttle-sample-data + XXX + master + admin + + + + + gitlab + https://gitlab.com/api/v4/ + tuttle-sample-data + XXX + master + admin + + + ``` -#### vcs +#### type Gitserver type: 'github' or 'gitlab' #### baseurl @@ -117,7 +121,7 @@ The page below is reachable via [api.html](api.html) in your installed tuttle ap ### API endpoint description -Calling the API without {collection} ``$config:default-collection`` is chosen. +Calling the API without {collection} ``config:default-collection()`` is chosen. #### Fetch to staging collection diff --git a/package.json b/package.json index 57d65cb..9ce7e60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tuttle", - "version": "1.1.0", + "version": "1.1.1", "description": "tuttle - a Git-integration for eXist-db", "scripts": { "test": "gulp install && mocha --exit", diff --git a/src/api.json b/src/api.json index 1042836..44e9d5d 100644 --- a/src/api.json +++ b/src/api.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.1.0", + "version": "1.1.1", "title": "Tuttle API", "description": "API for Tuttle Git integration" }, diff --git a/src/data/tuttle.xml b/src/data/tuttle.xml index e552ca7..c32b7b7 100644 --- a/src/data/tuttle.xml +++ b/src/data/tuttle.xml @@ -1,7 +1,42 @@ - sample-collection-github - - + + true + github + https://api.github.com/ + tuttle-sample-data + tuttle-sample-data + XXX + master + admin + + + + + gitlab + https://gitlab.com/api/v4/ + tuttle-sample-data + XXX + master + admin + + + + + existdb.json + build.xml + README.md + .gitignore + expath-pkg.xml.tmpl + repo.xml.tmpl + build.properties.xml + + + + + + + + \ No newline at end of file diff --git a/src/expath-pkg.xml b/src/expath-pkg.xml index ff514c7..3acb8c5 100644 --- a/src/expath-pkg.xml +++ b/src/expath-pkg.xml @@ -2,7 +2,7 @@ + abbrev="tuttle" version="1.1.1" spec="1.0"> Tuttle - Git for eXist-db diff --git a/src/js/fore-all.js.map b/src/js/fore-all.js.map new file mode 100644 index 0000000..7bc6186 --- /dev/null +++ b/src/js/fore-all.js.map @@ -0,0 +1 @@ +{"version":3,"file":"fore-all.js","sources":["../node_modules/whynot/dist/whynot.esm.js","../node_modules/xspattern/dist/xspattern.esm.js","../node_modules/prsc/dist/prsc.esm.js","../node_modules/fontoxpath/dist/fontoxpath.esm.js","../src/DependencyNotifyingDomFacade.js","../src/xpath-util.js","../src/dep_graph.js","../src/fore.js","../src/xpath-evaluation.js","../src/fx-instance.js","../src/modelitem.js","../src/fx-model.js","../src/getInScopeContext.js","../src/ForeElementMixin.js","../src/fx-bind.js","../node_modules/toastify-js/src/toastify-es.js","../node_modules/@jinntec/jinn-toast/src/JinnToast.js","../src/fx-fore.js","../src/fx-submission.js","../src/fx-header.js","../src/fx-var.js","../src/ui/abstract-control.js","../src/ui/fx-alert.js","../src/ui/fx-control.js","../src/ui/fx-container.js","../node_modules/lit-html/lib/dom.js","../node_modules/lit-html/lib/template.js","../node_modules/lit-html/lib/directive.js","../node_modules/lit-html/lib/part.js","../node_modules/lit-html/lib/template-instance.js","../node_modules/lit-html/lib/template-result.js","../node_modules/lit-html/lib/parts.js","../node_modules/lit-html/lib/default-template-processor.js","../node_modules/lit-html/lit-html.js","../node_modules/lit-html/lib/shady-render.js","../node_modules/lit-element/lib/updating-element.js","../node_modules/lit-element/lib/css-tag.js","../node_modules/lit-element/lit-element.js","../src/ui/fx-group.js","../src/ui/fx-hint.js","../src/ui/fx-output.js","../src/ui/fx-repeatitem.js","../src/ui/fx-repeat.js","../src/ui/fx-switch.js","../src/ui/fx-trigger.js","../src/ui/fx-case.js","../src/ui/fx-inspector.js","../src/ui/fx-dialog.js","../src/actions/abstract-action.js","../src/ui/fx-items.js","../src/actions/fx-append.js","../src/actions/fx-delete.js","../src/actions/fx-insert.js","../src/actions/fx-message.js","../src/actions/fx-setvalue.js","../src/actions/fx-send.js","../src/actions/fx-toggle.js","../src/actions/fx-dispatch.js","../src/actions/fx-update.js","../src/actions/fx-refresh.js","../src/actions/fx-action.js","../src/actions/fx-confirm.js","../src/actions/fx-show.js","../src/actions/fx-hide.js","../src/functions/fx-function.js"],"sourcesContent":["function t(t,s,r,i){const n={op:s,func:r,data:i};return t.push(n),n}function s(t,s){return t}class r{constructor(){this.program=[]}test(s,r){return t(this.program,5,s,void 0===r?null:r)}jump(s){return t(this.program,3,null,s)}record(r,i){return t(this.program,4,void 0===i?s:i,r)}bad(s=1){return t(this.program,1,null,s)}accept(){return t(this.program,0,null,null)}fail(s){return t(this.program,2,s||null,null)}}class i{constructor(t,s,r){this.programLength=t,this.maxFromByPc=s,this.maxSurvivorFromByPc=r}static fromProgram(t){const s=t.length,r=[],n=[];return t.forEach((t=>{r.push(0),n.push(0)})),t.forEach(((t,i)=>{switch(t.op){case 2:if(null===t.func)return;if(i+1>=s)throw new Error(\"Invalid program: program could run past end\");r[i+1]+=1;break;case 1:case 4:if(i+1>=s)throw new Error(\"Invalid program: program could run past end\");r[i+1]+=1;break;case 3:t.data.forEach((t=>{if(t<0||t>=s)throw new Error(\"Invalid program: program could run past end\");r[t]+=1}));break;case 5:if(i+1>=s)throw new Error(\"Invalid program: program could run past end\");n[i+1]+=1;break;case 0:n[i]+=1}})),new i(s,r,n)}static createStub(t){const s=[],r=[];for(let i=0;i0}}class h{constructor(t){this.t=0,this.i=0,this.h=new Uint16Array(t),this.l=new Uint8Array(t)}getBadness(t){return this.l[t]}add(t,s){this.l[t]=s>255?255:s;const r=function(t,s,r,i,n){let h=i,e=n;for(;h>>1;r255?255:s);if(this.l[t]!==r){const s=this.h.indexOf(t,this.i);if(s<0||s>=this.t)return void(this.l[t]=r);this.h.copyWithin(s,s+1,this.t),this.t-=1,this.add(t,r)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}}class e{constructor(t){this.o=[];let s=t.length;t.forEach((t=>{this.o.push(t>0?s:-1),s+=t})),this.u=new Uint16Array(s)}clear(){this.u.fill(0,0,this.o.length)}add(t,s){const r=this.u[s],i=this.o[s];this.u[s]+=1,this.u[i+r]=t}has(t){return this.u[t]>0}forEach(t,s){const r=this.u[t],i=this.o[t];for(let t=i;t{const r=this.trace(s,i,n,h);var c,o,u;o=r,u=e,t=null===(c=t)?o:null===o?c:Array.isArray(o)?o.reduce(((t,s)=>l(t,s,t===o)),c):l(c,o,u),e=t===r})),t}trace(t,s,r,i){switch(this.p[t]){case 2:return this.v[t];case 1:return null}this.p[t]=1;let n=null;const h=s[t];if(null!==h)n=h;else if(!r.has(t))throw new Error(`Trace without source at pc ${t}`);if(n=this.mergeTraces(n,t,r,s,r,i),null!==n){const s=i[t];null!==s&&(n=o(n,s))}return this.v[t]=n,this.p[t]=2,n}buildSurvivorTraces(t,s,r,i,n){for(let h=0,e=t.length;hl(t,this.k[s])),null);return null===s?[]:Array.isArray(s)?s:[s]}}class f{constructor(t){this.I=[],this.N=new h(t.programLength),this.M=new h(t.programLength),this.P=new a(t)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(t,s,r){const i=this.P.has(s);this.P.add(t,s);const n=this.N.getBadness(t)+r;i?this.N.reschedule(s,n):this.N.add(s,n)}stepToNextGeneration(t,s){const r=this.P.hasSurvivor(s);this.P.addSurvivor(t,s);const i=this.N.getBadness(t);r?this.M.reschedule(s,i):this.M.add(s,i)}accept(t){this.I.push(t),this.P.addSurvivor(t,t)}fail(t){}record(t,s){this.P.record(t,s)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);const t=this.N;t.reset(),this.N=this.M,this.M=t}getAcceptingTraces(){return this.P.getTraces(this.I)}}class d{constructor(t){this.U=[],this.G=t,this.V=i.fromProgram(t),this.U.push(new f(this.V))}execute(t,s){const r=this.U.pop()||new f(this.V);r.reset();const i=t.length;let h,e=-1;do{let n=r.getNextThreadPc();if(null===n)break;for(++e,h=e>=i?null:t[e];null!==n;){const t=this.G[n];switch(t.op){case 0:null===h?r.accept(n):r.fail(n);break;case 2:{const i=t.func;if(null===i||i(s)){r.fail(n);break}r.step(n,n+1,0);break}case 1:r.step(n,n+1,t.data);break;case 5:if(null===h){r.fail(n);break}if(!(0,t.func)(h,t.data,s)){r.fail(n);break}r.stepToNextGeneration(n,n+1);break;case 3:{const s=t.data,i=s.length;if(0===i){r.fail(n);break}for(let t=0;tB===A}function a(A,B){if(null===A||null===B)throw new Error(\"unescaped hyphen may not be used as a range endpoint\");if(BA<=a&&a<=B}function n(A){return!0}function e(){return!1}function t(A,B){return a=>A(a)||B(a)}function G(A,B){switch(B.kind){case\"predicate\":return void A.test(B.value);case\"regexp\":return void r(A,B.value,!1)}}function i(A,B){B.forEach((B=>{!function(A,B){const[a,{min:n,max:e}]=B;if(null!==e){for(let B=0;B0){for(let B=0;B!0)),A.jump([n]));const t=[];if(B.forEach((B=>{e.data.push(A.program.length),i(A,B),t.push(A.jump([]))})),t.forEach((B=>{B.data.push(A.program.length)})),a){const B=A.program.length,a=A.jump([]);a.data.push(A.program.length),A.test((()=>!0)),A.jump([B]),a.data.push(A.program.length)}}function o(A,B){return{success:!0,offset:A,value:B}}function l(A){return o(A,void 0)}function H(A,B,a=!1){return{success:!1,offset:A,expected:B,fatal:a}}function u(A){return(B,a)=>{const n=a+A.length;return B.slice(a,n)===A?o(n,A):H(a,[A])}}function C(A,B){return(a,n)=>{const e=A(a,n);return e.success?o(e.offset,B(e.value)):e}}function s(A,B,a){return(n,e)=>{const t=A(n,e);return t.success?B(t.value)?t:H(e,a):t.offset===e?H(e,a):t}}function c(A){return(B,a)=>{let n=null;for(const e of A){const A=e(B,a);if(A.success)return A;if(null===n||A.offset>n.offset?n=A:A.offset===n.offset&&(n.expected=n.expected.concat(A.expected)),A.fatal)break}return n||H(a,[])}}function D(A){return(B,a)=>{const n=A(B,a);return n.success||n.fatal?n:o(a,null)}}function m(A){return(B,a)=>{let n=[],e=a;for(;;){const a=A(B,e);if(!a.success){if(a.fatal)return a;break}n.push(a.value),e=a.offset}return o(e,n)}}function h(A,B,a){return(n,e)=>{const t=A(n,e);if(!t.success)return t;const G=B(n,t.offset);return G.success?o(G.offset,a(t.value,G.value)):G}}function I(A){return h(A,m(A),((A,B)=>[A].concat(B)))}function d(A,B){return A}function T(A,B){return B}function p(A,B){return h(A,B,T)}function E(A,B){return h(A,B,d)}function f(A,B,a,n=!1){return p(A,n?F(E(B,a)):E(B,a))}function g(A,B){return(a,n)=>A(a,n).success?H(n,B):l(n)}function F(A){return(B,a)=>{const n=A(B,a);return n.success?n:H(n.offset,n.expected,!0)}}const P=(A,B)=>A.length===B?l(B):H(B,[\"end of input\"]);const M=[\"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 S(A){return A.codePointAt(0)}\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".split(\"\").forEach(((A,B)=>{J[A]=B}));const K=A=>-1===A||-2===A;function b(A){return B=>!K(B)&&!A(B)}function y(A,B){return null===B?A:a=>A(a)&&!B(a)}const Q=function(A,B){const n=new Map;let e=0;return A.forEach(((A,G)=>{const i=B[G];null!==A&&A.split(\"|\").forEach((A=>{const B=n.get(A),G=a(e,e+i-1);n.set(A,B?t(B,G):G)})),e+=i})),n}([\"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\"],[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]),x=function(A){const n=new Map,G=A.split(\"\"),i=M.map((()=>[]));let r=0,o=0;for(;o{const a=i[B].reduce(t,e);n.set(A,a);const G=A.charAt(0),r=l.get(G)||[];l.set(G,r),r.push(a)})),l.forEach(((A,B)=>{n.set(B,A.reduce(t,e))})),n}(\"bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcABATBGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKB0GUBAGHBUHOcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABHHAIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBCGAHCIDBAHCBAHDBGHBBAGCBEGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBGGABAGBHBBBKJBAGBBMHBIBBAGHBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBBIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHFBBKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGMBAGDHCBKGRHCTBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcABAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAhABAAHDIAGuHAIAHEIAHAIEHAIBGGBDKJTGaJHIaIBCHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH5BAHEgVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYfBPHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBB6nBAACuBADuBAABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMBvaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGaBEajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm1mBABJa/mvHFABPGUFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDALBBABCCBvGAFBDAGGHAGCHAGDHAGWIBHBIAaDBDMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDHBHjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZPBQmqFAAQAPABPG/BBG1BnGLYAaABBHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaLBDaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTAhPCAAm2EAABIGVBJGHhXCAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMehACAAGcMJGABHGVHKMDTEhFCAAGWBIIAHAIAG0HOTGBDMTKJBOHCIAGsICHDIBHBTBcATDBKcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBBIGiHATBGABIHBIAGvICHIIBGDTDHDTABBKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAhABAAGGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJBATABATAHAGABfGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGABGKJB1GaBBHCIBHDIAHEBDKJMBTCaAh/CAAGrICHIIAHBTAhjBAACfDfKJMIBLGAhfCAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBcG4hGEAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBhGDAAMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAh7qAAmuQAABAcIhG/AAmGJAAh4GCAm4IAABGGeBAKJBDTBhfBAAGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFABbm3fBABHmyLAAhMUCAmeEAABwGCBQGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbNBA61DAABJamBBa7IBHCaCIFcHHHaBHGadHDa6BW6BBAAHCaAhZCAAMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPVAAHGBAHQBBHGBAHBBAHEhUDAAGsBCHGFGBBKJBDGAaAhvFAAGrHDKJBEYAh/TAAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMMBC6cBAABCa8B4acBMarBDaIBGaBBNaFhZCAA66DAAZE6VLAABJaMBCaKBE6zBAABL6YBAABGaLBTaLBDa3BHaJBFanBHadhRBAAaLBA6kBAABAaDBCaoBBaFBCacBB6GCAABLaNBBaDBDaCBEaCBMaFhpVAAmWbKABom0ABABKmdDAABBmBaBABNmw0BAhewAAmdIAAhiXwCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA\");function L(A){return 32===A||9===A||10===A||13===A}const Z=[B(S(\":\")),a(S(\"A\"),S(\"Z\")),B(S(\"_\")),a(S(\"a\"),S(\"z\")),a(192,214),a(216,246),a(192,214),a(216,246),a(248,767),a(880,893),a(895,8191),a(8204,8205),a(8304,8591),a(11264,12271),a(12289,55295),a(63744,64975),a(65008,65533),a(65536,983039)].reduce(t),X=[Z,B(S(\"-\")),B(S(\".\")),a(S(\"0\"),S(\"9\")),B(183),a(768,879),a(8255,8256)].reduce(t),k=x.get(\"Nd\"),O=b(k),N=y(a(0,1114111),[x.get(\"P\"),x.get(\"Z\"),x.get(\"C\")].reduce(t)),v=b(N);function w(A){return 10!==A&&13!==A&&!K(A)}const Y={s:L,S:b(L),i:Z,I:b(Z),c:X,C:b(X),d:k,D:O,w:N,W:v},U=u(\"*\"),j=u(\"\\\\\"),R=u(\"{\"),V=u(\"}\"),W=u(\"[\"),q=u(\"]\"),$=u(\"^\"),z=u(\"$\"),_=u(\",\"),AA=u(\"-\"),BA=u(\"(\"),aA=u(\")\"),nA=u(\".\"),eA=u(\"|\"),tA=u(\"+\"),GA=u(\"?\"),iA=u(\"-[\"),rA=S(\"0\");function oA(A){function e(A){return new Set(A.split(\"\").map((A=>S(A))))}function G(A,B){const a=A.codePointAt(B);return void 0===a?H(B,[\"any character\"]):o(B+String.fromCodePoint(a).length,a)}const i=\"xpath\"===A.language?p(j,c([C(u(\"n\"),(()=>10)),C(u(\"r\"),(()=>13)),C(u(\"t\"),(()=>9)),C(c([j,eA,nA,AA,$,GA,U,tA,R,V,z,BA,aA,W,q]),(A=>S(A)))])):p(j,c([C(u(\"n\"),(()=>10)),C(u(\"r\"),(()=>13)),C(u(\"t\"),(()=>9)),C(c([j,eA,nA,AA,$,GA,U,tA,R,V,BA,aA,W,q]),(A=>S(A)))]));function r(A,B){const a=e(B);return h(u(A),D(s(G,(A=>a.has(A)),B.split(\"\"))),((A,B)=>function(A){const B=x.get(A);if(null==B)throw new Error(`${A} is not a valid unicode category`);return B}(null===B?A:A+String.fromCodePoint(B))))}const l=c([r(\"L\",\"ultmo\"),r(\"M\",\"nce\"),r(\"N\",\"dlo\"),r(\"P\",\"cdseifo\"),r(\"Z\",\"slp\"),r(\"S\",\"mcko\"),r(\"C\",\"cfon\")]),T=[a(S(\"a\"),S(\"z\")),a(S(\"A\"),S(\"Z\")),a(S(\"0\"),S(\"9\")),B(45)].reduce(t),M=c([l,C(p(u(\"Is\"),function(A){return(B,a)=>{const n=A(B,a);return n.success?o(n.offset,B.slice(a,n.offset)):n}}(I(s(G,T,[\"block identifier\"])))),(B=>function(A,B){const a=Q.get(A);if(void 0===a){if(B)return n;throw new Error(`The unicode block identifier \"${A}\" is not known.`)}return a}(B,\"xpath\"!==A.language)))]),J=f(u(\"\\\\p{\"),M,V,!0),K=C(f(u(\"\\\\P{\"),M,V,!0),b),L=p(j,C(c(\"sSiIcCdDwW\".split(\"\").map((A=>u(A)))),(A=>Y[A]))),Z=C(nA,(()=>w)),X=c([L,J,K]),k=e(\"\\\\[]\"),O=c([i,s(G,(A=>!k.has(A)),[\"unescaped character\"])]),N=c([C(AA,(()=>null)),O]),v=h(N,p(AA,N),a);function oA(A,B){return[A].concat(B||[])}const lA=C(function(A){return(B,a)=>{const n=A(B,a);return n.success?o(a,n.value):n}}(c([q,iA])),(()=>null)),HA=S(\"-\"),uA=c([C(E(E(AA,g(W,[\"not [\"])),lA),(()=>HA)),p(g(AA,[\"not -\"]),O)]),CA=c([h(C(uA,B),c([function(A,B){return CA(A,B)},lA]),oA),h(c([v,X]),c([cA,lA]),oA)]);const sA=c([h(C(O,B),c([CA,lA]),oA),h(c([v,X]),c([cA,lA]),oA)]);function cA(A,B){return sA(A,B)}const DA=C(sA,(A=>A.reduce(t))),mA=C(p($,DA),b),hA=h(c([p(g($,[\"not ^\"]),DA),mA]),D(p(AA,(function(A,B){return IA(A,B)}))),y),IA=f(W,hA,q,!0);const dA=\"xpath\"===A.language?c([C(i,B),X,IA,Z,C($,(()=>A=>-1===A)),C(z,(()=>A=>-2===A))]):c([C(i,B),X,IA,Z]),TA=\"xpath\"===A.language?e(\".\\\\?*+{}()|^$[]\"):e(\".\\\\?*+{}()|[]\"),pA=s(G,(A=>!TA.has(A)),[\"NormalChar\"]),EA=C(p(j,h(C(s(G,a(S(\"1\"),S(\"9\")),[\"digit\"]),(A=>A-rA)),m(C(s(G,a(rA,S(\"9\")),[\"digit\"]),(A=>A-rA))),((A,B)=>{B.reduce(((A,B)=>10*A+B),A)}))),(A=>{throw new Error(\"Backreferences in XPath patterns are not yet implemented.\")})),fA=\"xpath\"===A.language?c([C(pA,(A=>({kind:\"predicate\",value:B(A)}))),C(dA,(A=>({kind:\"predicate\",value:A}))),C(f(BA,p(D(u(\"?:\")),SA),aA,!0),(A=>({kind:\"regexp\",value:A}))),EA]):c([C(pA,(A=>({kind:\"predicate\",value:B(A)}))),C(dA,(A=>({kind:\"predicate\",value:A}))),C(f(BA,SA,aA,!0),(A=>({kind:\"regexp\",value:A})))]),gA=C(I(C(s(G,a(rA,S(\"9\")),[\"digit\"]),(A=>A-rA))),(A=>A.reduce(((A,B)=>10*A+B)))),FA=c([h(gA,p(_,gA),((A,B)=>{if(B({min:A,max:null}))),C(gA,(A=>({min:A,max:A})))]),PA=\"xpath\"===A.language?h(c([C(GA,(()=>({min:0,max:1}))),C(U,(()=>({min:0,max:null}))),C(tA,(()=>({min:1,max:null}))),f(R,FA,V,!0)]),D(GA),((A,B)=>A)):c([C(GA,(()=>({min:0,max:1}))),C(U,(()=>({min:0,max:null}))),C(tA,(()=>({min:1,max:null}))),f(R,FA,V,!0)]),MA=m(h(fA,C(D(PA),(A=>null===A?{min:1,max:1}:A)),((A,B)=>[A,B]))),JA=h(MA,m(p(eA,F(MA))),((A,B)=>[A].concat(B)));function SA(A,B){return JA(A,B)}const KA=function(A){return h(A,P,d)}(JA);return function(A){let B;try{B=KA(A,0)}catch(B){throw new Error(`Error parsing pattern \"${A}\": ${B.message}`)}return B.success?B.value:function(A,B,a){const n=a.map((A=>`\"${A}\"`));throw new Error(`Error parsing pattern \"${A}\" at offset ${B}: expected ${n.length>1?\"one of \"+n.join(\", \"):n[0]} but found \"${A.slice(B,B+1)}\"`)}(A,B.offset,B.expected)}}function lA(A){return[...A].map((A=>A.codePointAt(0)))}function HA(B,a={language:\"xsd\"}){const n=oA(a)(B),e=A((A=>{r(A,n,\"xpath\"===a.language),A.accept()}));return function(A){const B=\"xpath\"===a.language?[-1,...lA(A),-2]:lA(A);return e.execute(B).success}}export{HA as compile};\n//# sourceMappingURL=xspattern.esm.js.map\n","function t(t,n){return{success:!0,offset:t,value:n}}function n(n){return t(n,void 0)}function e(t,n,e=!1){return{success:!1,offset:t,expected:n,fatal:e}}function u(n){return(u,r)=>{const c=r+n.length;return u.slice(r,c)===n?t(c,n):e(r,[n])}}function r(n,e){return(u,r)=>{const c=n(u,r);return c.success?t(c.offset,e(c.value)):c}}function c(t,n,u){return(r,c)=>{const s=t(r,c);return s.success?n(s.value)?s:e(c,u):s.offset===c?e(c,u):s}}function s(t){return(n,u)=>{let r=null;for(const e of t){const t=e(n,u);if(t.success)return t;if(null===r||t.offset>r.offset?r=t:t.offset===r.offset&&(r.expected=r.expected.concat(t.expected)),t.fatal)break}return r||e(u,[])}}function f(n){return(e,u)=>{const r=n(e,u);return r.success||r.fatal?r:t(u,null)}}function o(n){return(e,u)=>{let r=[],c=u;for(;;){const t=n(e,c);if(!t.success){if(t.fatal)return t;break}r.push(t.value),c=t.offset}return t(c,r)}}function i(n,e,u){return(r,c)=>{const s=n(r,c);if(!s.success)return s;const f=e(r,s.offset);return f.success?t(f.offset,u(s.value,f.value)):f}}function l(t){return i(t,o(t),((t,n)=>[t].concat(n)))}function a(t,n){return t}function p(t,n){return n}function v(t,n){return i(t,n,p)}function d(t,n){return i(t,n,a)}function x(t,n,e,u=!1){return v(t,u?k(d(n,e)):d(n,e))}function h(n){return(e,u)=>{const r=n(e,u);return r.success?t(r.offset,e.slice(u,r.offset)):r}}function b(n){return(e,u)=>{const r=n(e,u);return r.success?t(u,r.value):r}}function g(t,u){return(r,c)=>t(r,c).success?e(c,u):n(c)}function k(t){return(n,u)=>{const r=t(n,u);return r.success?r:e(r.offset,r.expected,!0)}}const j=(t,u)=>0===u?n(u):e(u,[\"start of input\"]),m=(t,u)=>t.length===u?n(u):e(u,[\"end of input\"]);function q(t){return i(t,m,a)}export{q as complete,k as cut,x as delimited,m as end,e as error,c as filter,a as first,d as followed,r as map,g as not,n as ok,t as okWithValue,f as optional,s as or,b as peek,l as plus,v as preceded,h as recognize,p as second,o as star,j as start,i as then,u as token};\n//# sourceMappingURL=prsc.esm.js.map\n","import * as xspattern from 'xspattern';\nimport * as prsc from 'prsc';\nconst fontoxpath = (function (xspattern, prsc) {\nconst VERSION='3.25.1';\nconst fontoxpathGlobal = {};\nvar h;function aa(a){var b=0;return function(){return b>>0)+\"_\",e=0;return b});\np(\"Symbol.iterator\",function(a){if(a)return a;a=Symbol(\"Symbol.iterator\");for(var b=\"Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array\".split(\" \"),c=0;cb||1342177279>>=1)c+=c;return d}});\nfunction Fa(a,b){a=void 0!==a?String(a):\" \";return 0=f}});p(\"Array.prototype.fill\",function(a){return a?a:function(b,c,d){var e=this.length||0;0>c&&(c=Math.max(0,e+c));if(null==d||d>e)d=e;d=Number(d);0>d&&(d=Math.max(0,e+d));for(c=Number(c||0);cc&&(c=Math.max(c+e,0));cb?-c:c}});p(\"Number.isFinite\",function(a){return a?a:function(b){return\"number\"!==typeof b?!1:!isNaN(b)&&Infinity!==b&&-Infinity!==b}});p(\"String.prototype.padStart\",function(a){return a?a:function(b,c){var d=Da(this,null,\"padStart\");return Fa(c,b-d.length)+d}});\nfunction Ia(a,b){a instanceof String&&(a+=\"\");var c=0,d=!1,e={next:function(){if(!d&&c=e}});\np(\"String.fromCodePoint\",function(a){return a?a:function(b){for(var c=\"\",d=0;de||1114111=e?c+=String.fromCharCode(e):(e-=65536,c+=String.fromCharCode(e>>>10&1023|55296),c+=String.fromCharCode(e&1023|56320))}return c}});\np(\"String.prototype.codePointAt\",function(a){return a?a:function(b){var c=Da(this,null,\"codePointAt\"),d=c.length;b=Number(b)||0;if(0<=b&&be||56319b||57343c.length)return e?1:-1;if(b.lengthc)return e?1:-1;if(bb?e?1:-1:cJa(a,b)}}function Na(){return function(a,b){return 0>Ja(a,b)}}function Oa(){return function(a,b){return-1=a.length?z:B(a[b])}}}h=hb.prototype;h.ob=function(){return this};h.filter=function(a){var b=this,c=-1;return this.s.create({next:function(){for(c++;c=b.h.length?z:B(b.h[c])}})};h.first=function(){return this.h[0]};h.N=function(){return this.h};h.getEffectiveBooleanValue=function(){if(C(this.h[0].type,53))return!0;throw eb();};h.Na=function(){return this.h.length};h.G=function(){return!1};\nh.ya=function(){return!1};h.map=function(a){var b=this,c=-1;return this.s.create({next:function(){return++c>=b.h.length?z:B(a(b.h[c],c,b))}},this.h.length)};h.L=function(a){return a(this.h)};h.$=function(a){return a.multiple?a.multiple(this):a.default(this)};function ib(){this.value={next:function(){return z}}}h=ib.prototype;h.ob=function(){return this};h.filter=function(){return this};h.first=function(){return null};h.N=function(){return[]};h.getEffectiveBooleanValue=function(){return!1};h.Na=function(){return 0};h.G=function(){return!0};h.ya=function(){return!1};h.map=function(){return this};h.L=function(a){return a([])};h.$=function(a){return a.empty?a.empty(this):a.default(this)};function lb(a){var b=a.value;if(C(a.type,53))return!0;if(C(a.type,0))return b;if(C(a.type,1)||C(a.type,20)||C(a.type,19))return 0!==b.length;if(C(a.type,2))return!isNaN(b)&&0!==b;throw eb();};function mb(a,b){var c=this;this.j=E;this.value={next:function(d){if(null!==c.s&&c.h>=c.s)return z;if(void 0!==c.A[c.h])return B(c.A[c.h++]);d=a.next(d);if(d.done)return c.s=c.h,d;if(c.u||2>c.h)c.A[c.h]=d.value;c.h++;return d}};this.u=!1;this.A=[];this.h=0;this.s=void 0===b?null:b}h=mb.prototype;h.ob=function(){return this.j.create(this.N())};h.filter=function(a){var b=this,c=-1,d=this.value;return this.j.create({next:function(e){c++;for(e=d.next(e);!e.done&&!a(e.value,c,b);)c++,e=d.next(0);return e}})};\nh.first=function(){if(void 0!==this.A[0])return this.A[0];var a=this.value.next(0);nb(this);return a.done?null:a.value};h.N=function(){if(this.h>this.A.length&&this.s!==this.A.length)throw Error(\"Implementation error: Sequence Iterator has progressed.\");var a=this.value;this.u=!0;for(var b=a.next(0);!b.done;)b=a.next(0);return this.A};\nh.getEffectiveBooleanValue=function(){var a=this.value,b=this.h;nb(this);var c=a.next(0);if(c.done)return nb(this,b),!1;c=c.value;if(C(c.type,53))return nb(this,b),!0;if(!a.next(0).done)throw eb();nb(this,b);return lb(c)};h.Na=function(a){if(null!==this.s)return this.s;if(void 0===a?0:a)return-1;a=this.h;var b=this.N().length;nb(this,a);return b};h.G=function(){return 0===this.s?!0:null===this.first()};\nh.ya=function(){if(null!==this.s)return 1===this.s;var a=this.value,b=this.h;nb(this);if(a.next(0).done)return nb(this,b),!1;a=a.next(0);nb(this,b);return a.done};h.map=function(a){var b=this,c=0,d=this.value;return this.j.create({next:function(e){e=d.next(e);return e.done?z:B(a(e.value,c++,b))}},this.s)};h.L=function(a,b){var c=this.value,d,e=[],f=!0;(function(){for(var g=c.next(f?0:b);!g.done;g=c.next(b))f=!1,e.push(g.value);d=a(e).value})();return this.j.create({next:function(){return d.next(0)}})};\nh.$=function(a){function b(e){d=e.value;e=e.Na(!0);-1!==e&&(c.s=e)}var c=this,d=null;return this.j.create({next:function(e){if(d)return d.next(e);if(c.G())return b(a.empty?a.empty(c):a.default(c)),d.next(e);if(c.ya())return b(a.o?a.o(c):a.default(c)),d.next(e);b(a.multiple?a.multiple(c):a.default(c));return d.next(e)}})};function nb(a,b){a.h=void 0===b?0:b};function ob(a){this.A=E;this.h=a;var b=!1;this.value={next:function(){if(b)return z;b=!0;return B(a)}};this.s=null}h=ob.prototype;h.ob=function(){return this};h.filter=function(a){return a(this.h,0,this)?this:this.A.create()};h.first=function(){return this.h};h.N=function(){return[this.h]};h.getEffectiveBooleanValue=function(){null===this.s&&(this.s=lb(this.h));return this.s};h.Na=function(){return 1};h.G=function(){return!1};h.ya=function(){return!0};\nh.map=function(a){return this.A.create(a(this.h,0,this))};h.L=function(a){return a([this.h])};h.$=function(a){return a.o?a.o(this):a.default(this)};var pb=new ib;function qb(a,b){a=void 0===a?null:a;if(null===a)return pb;if(Array.isArray(a))switch(a.length){case 0:return pb;case 1:return new ob(a[0]);default:return new hb(a)}return a.next?new mb(a,void 0===b?null:b):new ob(a)}var E={create:qb,o:function(a){return new ob(a)},empty:function(){return qb()},ca:function(){return qb(cb)},X:function(){return qb(db)}};function rb(a){var b=[],c=a.value;return function(){var d=0;return E.create({next:function(){if(void 0!==b[d])return b[d++];var e=c.next(0);return e.done?e:b[d++]=e}})}};function sb(a,b){this.type=a;this.value=b}\nvar F={},tb=(F[0]=\"xs:boolean\",F[1]=\"xs:string\",F[2]=\"xs:numeric\",F[3]=\"xs:double\",F[4]=\"xs:decimal\",F[5]=\"xs:integer\",F[6]=\"xs:float\",F[7]=\"xs:date\",F[8]=\"xs:time\",F[9]=\"xs:dateTime\",F[10]=\"xs:dateTimeStamp\",F[11]=\"xs:gYearMonth\",F[12]=\"xs:gYear\",F[13]=\"xs:gMonthDay\",F[14]=\"xs:gMonth\",F[15]=\"xs:gDay\",F[16]=\"xs:yearMonthDuration\",F[17]=\"xs:dayTimeDuration\",F[18]=\"xs:duration\",F[19]=\"xs:untypedAtomic\",F[20]=\"xs:anyURI\",F[21]=\"xs:base64Binary\",F[22]=\"xs:hexBinary\",F[23]=\"xs:QName\",F[24]=\"xs:NCName\",\nF[25]=\"xs:Name\",F[26]=\"xs:ENTITY\",F[27]=\"xs:nonPositiveInteger\",F[28]=\"xs:negativeInteger\",F[29]=\"xs:positiveInteger\",F[30]=\"xs:nonNegativeInteger\",F[31]=\"xs:long\",F[32]=\"xs:int\",F[33]=\"xs:short\",F[34]=\"xs:byte\",F[35]=\"xs:unsignedInt\",F[36]=\"xs:unsignedLong\",F[37]=\"xs:unsignedByte\",F[38]=\"xs:unsignedShort\",F[39]=\"xs:error\",F[40]=\"xs:ENTITIES\",F[41]=\"xs:IDREF\",F[42]=\"xs:ID\",F[43]=\"xs:IDREFS\",F[44]=\"xs:NOTATION\",F[45]=\"xs:anySimpleType\",F[46]=\"xs:anyAtomicType\",F[47]=\"attribute()\",F[48]=\"xs:normalizedString\",\nF[49]=\"xs:NMTOKENS\",F[50]=\"xs:NMTOKEN\",F[51]=\"xs:language\",F[52]=\"xs:token\",F[53]=\"node()\",F[54]=\"element()\",F[55]=\"document-node()\",F[56]=\"text()\",F[57]=\"processing-instruction()\",F[58]=\"comment()\",F[59]=\"item()\",F[60]=\"function(*)\",F[61]=\"map(*)\",F[62]=\"array(*)\",F[63]=\"none\",F),ub={\"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,\n\"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,\n\"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 vb(a){return 2===a.g?tb[a.type]+\"*\":1===a.g?tb[a.type]+\"+\":0===a.g?tb[a.type]+\"?\":tb[a.type]}\nfunction wb(a){if(\"none\"===a)throw Error('XPST0051: The type \"none\" could not be found');if(!a.startsWith(\"xs:\")&&0<=a.indexOf(\":\"))throw Error(\"XPST0081: Invalid prefix for input \"+a);var b=ub[a];if(void 0===b)throw Error('XPST0051: The type \"'+a+'\" could not be found');return b}\nfunction xb(a){switch(a[a.length-1]){case \"*\":return{type:wb(a.substr(0,a.length-1)),g:2};case \"?\":return{type:wb(a.substr(0,a.length-1)),g:0};case \"+\":return{type:wb(a.substr(0,a.length-1)),g:1};default:return{type:wb(a),g:3}}}function yb(a){switch(a){case \"*\":return 2;case \"?\":return 0;case \"+\":return 1;default:return 3}};function Ab(a,b,c){this.namespaceURI=b||null;this.prefix=a||\"\";this.localName=c}Ab.prototype.va=function(){return this.prefix?this.prefix+\":\"+this.localName:this.localName};function Bb(a){var b=a.l,c=a.arity,d=void 0===a.Pa?!1:a.Pa,e=void 0===a.I?!1:a.I,f=a.localName,g=a.namespaceURI,k=a.i;a=a.value;sb.call(this,60,null);this.value=a;this.I=e;e=-1;for(a=0;a=l||l>k.R.length)throw Error(\"FOAY0001: array position out of bounds.\");return k.R[l-1]()})})};function Xb(a){Bb.call(this,{value:function(c,d,e,f){return Wb(c,d,e,E.o(b),f)},localName:\"get\",namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",l:[{type:5,g:3}],arity:1,i:{type:59,g:2}});var b=this;this.type=62;this.R=a}x(Xb,Bb);function Yb(a){switch(a.node.nodeType){case 2:return 47;case 1:return 54;case 3:case 4:return 56;case 7:return 57;case 8:return 58;case 9:return 55;default:return 53}}function Zb(a){return{type:Yb(a),value:a}};function $b(a,b){a=a.map(function(c){return c.first()});return b(a)};function ac(a,b){var c=C(a.type,1)||C(a.type,20)||C(a.type,19),d=C(b.type,1)||C(b.type,20)||C(b.type,19);if(c&&d)return a.value===b.value;c=C(a.type,4)||C(a.type,3)||C(a.type,6);d=C(b.type,4)||C(b.type,3)||C(b.type,6);if(c&&d)return isNaN(a.value)&&isNaN(b.value)?!0:a.value===b.value;c=C(a.type,0)||C(a.type,22)||C(a.type,18)||C(a.type,23)||C(a.type,44);d=C(b.type,0)||C(b.type,22)||C(b.type,18)||C(b.type,23)||C(b.type,44);return c&&d?a.value===b.value:!1};function bc(a,b,c,d,e){return $b([d,e],function(f){f=t(f);var g=f.next().value,k=f.next().value;return(f=g.h.find(function(l){return ac(l.key,k)}))?f.value():E.empty()})};function cc(a){Bb.call(this,{l:[{type:59,g:3}],arity:1,localName:\"get\",namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",value:function(c,d,e,f){return bc(c,d,e,E.o(b),f)},i:{type:59,g:2}});var b=this;this.type=61;this.h=a}x(cc,Bb);function dc(){}function ec(a,b){return a.ab()===b.ab()&&a.bb()===b.bb()}h=dc.prototype;h.Za=function(){return 0};h.getHours=function(){return 0};h.getMinutes=function(){return 0};h.$a=function(){return 0};h.ab=function(){return 0};h.bb=function(){return 0};h.getSeconds=function(){return 0};h.cb=function(){return 0};h.oa=function(){return!0};function fc(a){if(a>Number.MAX_SAFE_INTEGER||aNumber.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error(\"FODT0002: Value overflow while multiplying xs:dayTimeDuration\");return new fc(aa||273860b.pa?1:-1:d>c?1:-1}function vc(a,b,c){return 0===uc(a,b,c)}function xc(a,b,c){a=(sc(a,c).getTime()-sc(b,c).getTime())/1E3;return new fc(a)}\nfunction yc(a){throw Error(\"Not implemented: adding durations to \"+tb[a.type]);}function zc(a){throw Error(\"Not implemented: subtracting durations from \"+tb[a.type]);};function Ac(a,b){if(null===a)return null;switch(typeof a){case \"boolean\":return a?cb:db;case \"number\":return y(a,3);case \"string\":return y(a,1);case \"object\":return\"nodeType\"in a?Zb({node:a,F:null}):Array.isArray(a)?new Xb(a.map(function(c){if(void 0===c)return function(){return E.empty()};c=Ac(c,b);c=null===c?E.empty():E.o(c);return rb(c)})):new cc(Object.keys(a).filter(function(c){return void 0!==a[c]}).map(function(c){var d=Ac(a[c],b);d=null===d?E.empty():E.o(d);return{key:y(c,1),value:rb(d)}}))}throw Error(\"Value \"+\nString(a)+' of type \"'+typeof a+'\" is not adaptable to an XPath value.');}function Bc(a,b){if(\"number\"!==typeof a&&(\"string\"!==typeof a||!$a.get(b)(a)))throw Error(\"Cannot convert JavaScript value '\"+a+\"' to the XPath type \"+tb[b]+\" since it is not valid.\");}\nfunction Cc(a,b,c){if(null===b)return null;switch(a){case 0:return b?cb:db;case 1:return y(b+\"\",1);case 3:case 2:return Bc(b,3),y(+b,3);case 4:return Bc(b,a),y(+b,4);case 5:return Bc(b,a),y(b|0,5);case 6:return Bc(b,a),y(+b,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(b instanceof Date))throw Error(\"The JavaScript value \"+b+\" with type \"+typeof b+\" is not a valid type to be converted to an XPath \"+tb[a]+\".\");return y(rc(tc(b.toISOString()),a),a);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if(\"object\"!==\ntypeof b||!(\"nodeType\"in b))throw Error(\"The JavaScript value \"+b+\" with type \"+typeof b+\" is not a valid type to be converted to an XPath \"+tb[a]+\".\");return Zb({node:b,F:null});case 59:return Ac(b,c);default:throw Error('Values of the type \"'+a+'\" can not be adapted to equivalent XPath values.');}}\nfunction Dc(a,b,c){if(0===c.g)return b=Cc(c.type,b,a),null===b?[]:[b];if(2===c.g||1===c.g){if(!Array.isArray(b))throw Error(\"The JavaScript value \"+b+\" should be an array if it is to be converted to \"+vb(c)+\".\");return b.map(function(e){return Cc(c.type,e,a)}).filter(function(e){return null!==e})}var d=Cc(c.type,b,a);if(null===d)throw Error(\"The JavaScript value \"+b+\" should be a single entry if it is to be converted to \"+vb(c)+\".\");return[d]}\nfunction Ec(a,b,c){c=void 0===c?{type:59,g:0}:c;return E.create(Dc(a,b,c))};function Fc(a,b){this.h=b=void 0===b?{vb:null,Ab:null,pb:!1}:b;this.Ja=a.Ja;this.Ga=a.Ga;this.M=a.M;this.Ea=a.Ea||Object.create(null)}function Gc(a,b){var c=0,d=b.value;return{next:function(e){e=d.next(e);return e.done?z:B(Hc(a,c++,e.value,b))}}}function Ic(a){a.h.pb||(a.h.pb=!0,a.h.vb=tc((new Date).toISOString()),a.h.Ab=ic(\"PT0S\"));return a.h.vb}function Jc(a){a.h.pb||(a.h.pb=!0,a.h.vb=tc((new Date).toISOString()),a.h.Ab=ic(\"PT0S\"));return a.h.Ab}\nfunction Hc(a,b,c,d){return new Fc({M:c,Ja:b,Ga:d||a.Ga,Ea:a.Ea},a.h)}function Kc(a,b){return new Fc({M:a.M,Ja:a.Ja,Ga:a.Ga,Ea:Object.assign(Object.create(null),a.Ea,b)},a.h)};function Lc(a,b,c,d,e,f,g,k){var l=new Map;this.debug=a;this.Ha=b;this.h=c;this.s=d;this.A=e;this.u=f;this.ha=l;this.O=g;this.j=k};function Mc(a){var b=0,c=null,d=!0;return E.create({next:function(e){for(;bNumber.MAX_VALUE?{v:!1,error:Error(\"FOAR0002: Can not cast \"+b+\" to xs:decimal, it is out of bounds for JavaScript numbers\")}:{v:!0,value:y(b,4)}}:a(0)?function(b){return{v:!0,value:y(b?1:0,4)}}:a(1)||a(19)?function(b){var c=parseFloat(b);return!isNaN(c)||isFinite(c)?{v:!0,value:y(c,4)}:{v:!1,error:Error(\"FORG0001: Can not cast \"+\nb+\" 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.\")}}};function hd(a,b){return a(2)?function(c){return{v:!0,value:c}}:a(0)?function(c){return{v:!0,value:c?1:0}}:a(1)||a(19)?function(c){switch(c){case \"NaN\":return{v:!0,value:NaN};case \"INF\":case \"+INF\":return{v:!0,value:Infinity};case \"-INF\":return{v:!0,value:-Infinity};case \"0\":case \"+0\":return{v:!0,value:0};case \"-0\":return{v:!0,value:-0}}var d=parseFloat(c);return isNaN(d)?{v:!1,error:Nc(c,b)}:{v:!0,value:d}}:function(){return{v:!1,error:Error(\"XPTY0004: Casting not supported from given type to \"+b+\n\" or any of its derived types.\")}}};function id(a){var b=hd(a,3);return function(c){c=b(c);return c.v?{v:!0,value:y(c.value,3)}:c}};function jd(a){if(a>Number.MAX_SAFE_INTEGER||aNumber.MAX_SAFE_INTEGER||!Number.isFinite(b))throw Error(\"FODT0002: Value overflow while constructing xs:yearMonthDuration\");a=new jd(a||0===b?b:-b)}else a=null;return a}\nfunction md(a,b){if(isNaN(b))throw Error(\"FOCA0005: Cannot multiply xs:yearMonthDuration by NaN\");a=Math.round(a.ga*b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error(\"FODT0002: Value overflow while constructing xs:yearMonthDuration\");return new jd(ab?\"-\":\"\")+\"INF\"}}}return a(9)||a(7)||a(8)||a(15)||a(14)||a(13)||a(12)||a(11)?function(b){return{v:!0,value:b.toString()}}:a(16)?function(b){return{v:!0,value:b.toString()}}:a(17)?function(b){return{v:!0,value:b.toString()}}:a(18)?function(b){return{v:!0,value:b.toString()}}:a(22)?function(b){return{v:!0,value:b.toUpperCase()}}:function(b){return{v:!0,value:b+\"\"}}};function Cd(a){var b=Bd(a);return function(c){c=b(c);return c.v?{v:!0,value:y(c.value,1)}:c}};function Dd(a){return a(9)?function(b){return{v:!0,value:y(rc(b,8),8)}}:a(19)||a(1)?function(b){return{v:!0,value:y(tc(b),8)}}:function(){return{v:!1,error:Error(\"XPTY0004: Casting not supported from given type to xs:time or any of its derived types.\")}}};function Ed(a){var b=Bd(a);return function(c){c=b(c);return c.v?{v:!0,value:y(c.value,19)}:c}};function Fd(a){return a(18)&&!a(17)?function(b){return{v:!0,value:y(b.Sa,16)}}:a(17)?function(){return{v:!0,value:y(ld(\"P0M\"),16)}}:a(19)||a(1)?function(b){var c=ld(b);return c?{v:!0,value:y(c,16)}:{v:!1,error:Nc(b,16)}}:function(){return{v:!1,error:Error(\"XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.\")}}};var Gd=[2,5,17,16];\nfunction Ad(a,b){function c(d){return C(a,d)}if(39===b)return function(){return{v:!1,error:Error(\"FORG0001: Casting to xs:error is always invalid.\")}};switch(b){case 19:return Ed(c);case 1:return Cd(c);case 6:return pd(c);case 3:return id(c);case 4:return gd(c);case 5:return xd(c);case 2:return zd(a);case 18:return od(c);case 16:return Fd(c);case 17:return fd(c);case 9:return ed(c);case 8:return Dd(c);case 7:return dd(c);case 11:return vd(c);case 12:return ud(c);case 13:return td(c);case 15:return qd(c);\ncase 14:return rd(c);case 0:return cd(c);case 21:return bd(c);case 22:return wd(c);case 20:return ad(c);case 23:throw Error(\"Casting to xs:QName is not implemented.\");}return function(){return{v:!1,error:Error(\"XPTY0004: Casting not supported from \"+a+\" to \"+b+\".\")}}}var Hd=Object.create(null);\nfunction Id(a,b){if(19===a&&1===b)return function(f){return{v:!0,value:y(f,1)}};if(44===b)return function(){return{v:!1,error:Error(\"XPST0080: Casting to xs:NOTATION is not permitted.\")}};if(39===b)return function(){return{v:!1,error:Error(\"FORG0001: Casting to xs:error is not permitted.\")}};if(45===a||45===b)return function(){return{v:!1,error:Error(\"XPST0080: Casting from or to xs:anySimpleType is not permitted.\")}};if(46===a||46===b)return function(){return{v:!1,error:Error(\"XPST0080: Casting from or to xs:anyAtomicType is not permitted.\")}};\nif(C(a,60)&&1===b)return function(){return{v:!1,error:Error(\"FOTY0014: Casting from function item to xs:string is not permitted.\")}};if(a===b)return function(f){return{v:!0,value:{type:b,value:f}}};var c=Gd.includes(a)?a:Wc(a),d=Gd.includes(b)?b:Wc(b);if(null===d||null===c)return function(){return{v:!1,error:Error(\"XPST0081: Can not cast: type \"+(d?tb[a]:tb[b])+\" is unknown.\")}};var e=[];1!==c&&19!==c||e.push(function(f){var g=Xc(f,b);return Yc(g,b)?{v:!0,value:g}:{v:!1,error:Nc(f,b,\"pattern validation failed.\")}});\nc!==d&&(e.push(Ad(c,d)),e.push(function(f){return{v:!0,value:f.value}}));19!==d&&1!==d||e.push(function(f){return Yc(f,b)?{v:!0,value:f}:{v:!1,error:Nc(f,b,\"pattern validation failed.\")}});e.push(function(f){return $c(f,b)?{v:!0,value:f}:{v:!1,error:Nc(f,b,\"pattern validation failed.\")}});e.push(function(f){return{v:!0,value:{type:b,value:f}}});return function(f){f={v:!0,value:f};for(var g=0,k=e.length;gd.value.node.localName?1:-1;c=Ub(b,c.value);d=Ub(b,d.value)}else c=c.value,d=d.value;return Rd(a,b,c,d)}function Td(a,b,c){return Sd(a.s,a,b,c)}\nfunction Ud(a,b){return Vd(b,function(c,d){return Sd(a.s,a,c,d)}).filter(function(c,d,e){return 0===d?!0:!Nd(c.value,e[d-1].value)})}function Wd(a,b){return a=a.length)return a;var c=Math.floor(a.length/2),d=Vd(a.slice(0,c),b);a=Vd(a.slice(c),b);for(c=[];d.length&&a.length;)0>b(d[0],a[0])?c.push(d.shift()):c.push(a.shift());return c.concat(d.concat(a))};var Xd=xspattern;function Yd(a,b){if(C(a.type,2)){if(C(a.type,6))return 3===b?y(a.value,3):null;if(C(a.type,4)){if(6===b)return y(a.value,6);if(3===b)return y(a.value,3)}return null}return C(a.type,20)&&1===b?y(a.value,1):null};function Zd(a,b,c,d,e){if(C(a.type,b.type))return a;C(b.type,46)&&C(a.type,53)&&(a=Uc(a,c).first());if(C(a.type,b.type)||46===b.type)return a;if(C(a.type,19)){c=Kd(a,b.type);if(!c)throw Error(\"XPTY0004 Unable to convert \"+(e?\"return\":\"argument\")+\" of type \"+tb[a.type]+\" to type \"+vb(b)+\" while calling \"+d);return c}c=Yd(a,b.type);if(!c)throw Error(\"XPTY0004 Unable to cast \"+(e?\"return\":\"argument\")+\" of type \"+tb[a.type]+\" to type \"+vb(b)+\" while calling \"+d);return c}\nfunction $d(a){switch(a){case 2:return\"*\";case 1:return\"+\";case 0:return\"?\";case 3:return\"\"}}\nfunction ae(a,b,c,d,e){return 0===a.g?b.$({default:function(){return b.map(function(f){return Zd(f,a,c,d,e)})},multiple:function(){throw Error(\"XPTY0004: Multiplicity of \"+(e?\"function return value\":\"function argument\")+\" of type \"+tb[a.type]+$d(a.g)+\" for \"+d+' is incorrect. Expected \"?\", but got \"+\".');}}):1===a.g?b.$({empty:function(){throw Error(\"XPTY0004: Multiplicity of \"+(e?\"function return value\":\"function argument\")+\" of type \"+tb[a.type]+$d(a.g)+\" for \"+d+' is incorrect. Expected \"+\", but got \"empty-sequence()\"');\n},default:function(){return b.map(function(f){return Zd(f,a,c,d,e)})}}):2===a.g?b.map(function(f){return Zd(f,a,c,d,e)}):b.$({o:function(){return b.map(function(f){return Zd(f,a,c,d,e)})},default:function(){throw Error(\"XPTY0004: Multiplicity of \"+(e?\"function return value\":\"function argument\")+\" of type \"+tb[a.type]+$d(a.g)+\" for \"+d+\" is incorrect. Expected exactly one\");}})};function be(a,b){return C(a,5)?y(b,5):C(a,6)?y(b,6):C(a,3)?y(b,3):y(b,4)}function ce(a){if(Math.floor(a)===a||isNaN(a))return 0;a=/\\d+(?:\\.(\\d*))?(?:[Ee](-)?(\\d+))*/.exec(a+\"\");var b=a[1]?a[1].length:0;if(a[3]){if(a[2])return b+parseInt(a[3],10);a=b-parseInt(a[3],10);return 0>a?0:a}return b}function de(a,b,c){return b&&0===a*c%1%.5?0===Math.floor(a*c)%2?Math.floor(a*c)/c:Math.ceil(a*c)/c:Math.round(a*c)/c}\nfunction ee(a,b,c,d,e,f){var g=!1;return E.create({next:function(){if(g)return z;var k=e.first();if(!k)return g=!0,z;if((C(k.type,6)||C(k.type,3))&&(0===k.value||isNaN(k.value)||Infinity===k.value||-Infinity===k.value))return g=!0,B(k);var l;f?l=f.first().value:l=0;g=!0;if(ce(k.value)e?E.o(y(1,5)):a=f||57344<=f&&65533>=f||65536<=\nf&&1114111>=f)return String.fromCodePoint(f);throw Error(\"FOCH0001\");}).join(\"\");return E.o(y(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(a,b,c,d){return $b([d],function(e){e=(e=t(e).next().value)?e.value.split(\"\"):[];return 0===e.length?E.empty():E.create(e.map(function(f){return y(f.codePointAt(0),5)}))})},localName:\"string-to-codepoints\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:5,\ng:2}},{l:[{type:1,g:0}],m:function(a,b,c,d){return $b([d],function(e){e=t(e).next().value;return null===e||0===e.value.length?E.create(y(\"\",1)):E.create(y(encodeURIComponent(e.value).replace(/[!'()*]/g,function(f){return\"%\"+f.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(a,b,c,d){return $b([d],function(e){e=t(e).next().value;return null===e||0===e.value.length?E.create(y(\"\",\n1)):E.create(y(e.value.replace(/([\\u00A0-\\uD7FF\\uE000-\\uFDCF\\uFDF0-\\uFFEF \"<>{}|\\\\^`/\\n\\u007f\\u0080-\\u009f]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g,function(f){return encodeURI(f)}),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(a,b,c,d,e){return $b([d,e],function(f){var g=t(f);f=g.next().value;g=g.next().value;if(null===f||null===g)return E.empty();f=f.value;g=g.value;if(f.length!==g.length)return E.X();f=f.split(\"\");\ng=g.split(\"\");for(var k=0;kq.node.nodeName?1:-1}).map(function(n){return Zb(n)});e=Nb(b.h,e.value).filter(function(n){return\"http://www.w3.org/2000/xmlns/\"!==n.node.namespaceURI}).sort(function(n,q){return n.node.nodeName>q.node.nodeName?1:-1}).map(function(n){return Zb(n)});var k=Le(a,b,c,E.create(d),\nE.create(e)),l=!1;return{next:function(){if(l)return z;var n=f.next(0);if(!n.done&&!1===n.value)return l=!0,n;n=k.next(0);if(!n.done&&!1===n.value)return l=!0,n;n=g.next(0);l=!0;return n}}}function Se(a,b,c,d,e){var f=Le(a,b,c,we(a,b,c,E.o(d)),we(a,b,c,E.o(e))),g=!1;return{next:function(){if(g)return z;var k=f.next(0);return k.done||!1!==k.value?B(Ie(Uc(d,b).first(),Uc(e,b).first())):(g=!0,k)}}}\nfunction Me(a,b,c,d,e){if(C(d.type,46)&&C(e.type,46))return Ld(Ie(d,e));if(C(d.type,61)&&C(e.type,61))return Ne(a,b,c,d,e);if(C(d.type,62)&&C(e.type,62))return Pe(a,b,c,d,e);if(C(d.type,53)&&C(e.type,53)){if(C(d.type,55)&&C(e.type,55))return Qe(a,b,c,d,e);if(C(d.type,54)&&C(e.type,54))return Re(a,b,c,d,e);if(C(d.type,47)&&C(e.type,47)||C(d.type,57)&&C(e.type,57)||C(d.type,58)&&C(e.type,58))return Se(a,b,c,d,e)}return Ld(!1)};function Te(a){return Error(\"XUST0001: \"+(void 0===a?\"Can not execute an updating expression in a non-updating context.\":a))}function Ue(a){return Error(\"XUTY0004: The attribute \"+a.name+'=\"'+a.value+'\" follows a node that is not an attribute node.')}function Ve(){return Error(\"XUTY0005: The target of a insert expression with into must be a single element or document node.\")}\nfunction We(){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 Xe(){return Error(\"XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node.\")}function Ye(){return Error(\"XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node.\")}\nfunction Ze(a){return Error(\"XUDY0017: The target \"+a.outerHTML+\" is used in more than one replace value of expression.\")}function $e(a){return Error(\"XUDY0021: Applying the updates will result in the XDM instance violating constraint: '\"+a+\"'\")}function af(a){return Error(\"XUDY0023: The namespace binding \"+a+\" is conflicting.\")}function bf(a){return Error(\"XUDY0024: The namespace binding \"+a+\" is conflicting.\")}\nfunction cf(){return Error(\"XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.\")};function I(a,b,c,d,e){c=void 0===c?{C:!1,Y:!1,S:\"unsorted\",subtree:!1}:c;this.s=a;this.O=c.S||\"unsorted\";this.subtree=!!c.subtree;this.Y=!!c.Y;this.C=!!c.C;this.ha=b;this.I=!1;this.Ya=null;this.bc=void 0===d?!1:d;this.type=e}function J(a,b,c){b&&null!==b.M?a.C?(null===a.Ya&&(a.Ya=rb(a.h(null,c).ob())),a=a.Ya()):a=a.h(b,c):a=a.h(b,c);return a}I.prototype.A=function(){return null};\nI.prototype.P=function(a){this.ha.forEach(function(b){return b.P(a)});if(!this.bc&&this.ha.some(function(b){return b.I}))throw Te();};function df(a,b){this.H=a;this.fa=b};function ef(a){a&&\"object\"===typeof a&&\"nodeType\"in a&&(a=a.ownerDocument||a,\"function\"===typeof a.createElementNS&&\"function\"===typeof a.createProcessingInstruction&&\"function\"===typeof a.createTextNode&&\"function\"===typeof a.createComment&&(this.h=a));this.h||(this.h=null)}h=ef.prototype;h.createAttributeNS=function(a,b){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createAttributeNS(a,b)};\nh.createCDATASection=function(a){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createCDATASection(a)};h.createComment=function(a){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createComment(a)};h.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)};\nh.createElementNS=function(a,b){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createElementNS(a,b)};h.createProcessingInstruction=function(a,b){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createProcessingInstruction(a,b)};h.createTextNode=function(a){if(!this.h)throw Error(\"Please pass a node factory if an XQuery script uses node constructors\");return this.h.createTextNode(a)};function ff(a,b,c,d){var e=Ub(c,a).node,f=(a=Tb(c,a))?a.node:null;b.forEach(function(g){d.insertBefore(e,g.node,f)})}function gf(a,b,c,d){var e=Ub(c,a).node;b.forEach(function(f){d.insertBefore(e,f.node,a.node)})}function hf(a,b,c,d){var e=(c=Rb(c,a))?c.node:null;b.forEach(function(f){d.insertBefore(a.node,f.node,e)})}function jf(a,b,c){b.forEach(function(d){c.insertBefore(a.node,d.node,null)})}\nfunction kf(a,b,c,d){b.forEach(function(e){var f=e.node.nodeName;if(Ob(c,a,f))throw $e(\"An attribute \"+f+\" already exists.\");d.setAttributeNS(a.node,e.node.namespaceURI,f,Qb(c,e))})}\nfunction lf(a,b,c,d,e){d||(d=new ef(a?a.node:null));switch(a.node.nodeType){case 1:var f=c.getAllAttributes(a.node),g=c.getChildNodes(a.node),k=d.createElementNS(b.namespaceURI,b.va());var l={node:k,F:null};f.forEach(function(n){e.setAttributeNS(k,n.namespaceURI,n.nodeName,n.value)});g.forEach(function(n){e.insertBefore(k,n,null)});break;case 2:b=d.createAttributeNS(b.namespaceURI,b.va());b.value=Qb(c,a);l={node:b,F:null};break;case 7:l={node:d.createProcessingInstruction(b.va(),Qb(c,a)),F:null}}if(!Ub(c,\na))throw Error(\"Not supported: renaming detached nodes.\");mf(a,[l],c,e)}function nf(a,b,c,d){c.getChildNodes(a.node).forEach(function(e){return d.removeChild(a.node,e)});b&&d.insertBefore(a.node,b.node,null)}\nfunction mf(a,b,c,d){var e=Ub(c,a),f=a.node.nodeType;if(2===f){if(b.some(function(l){return 2!==l.node.nodeType}))throw Error('Constraint \"If $target is an attribute node, $replacement must consist of zero or more attribute nodes.\" failed.');var g=e?e.node:null;d.removeAttributeNS(g,a.node.namespaceURI,a.node.nodeName);b.forEach(function(l){var n=l.node.nodeName;if(Ob(c,e,n))throw $e(\"An attribute \"+n+\" already exists.\");d.setAttributeNS(g,l.node.namespaceURI,n,Qb(c,l))})}if(1===f||3===f||8===f||\n7===f){var k=(f=Tb(c,a))?f.node:null;d.removeChild(e.node,a.node);b.forEach(function(l){d.insertBefore(e.node,l.node,k)})}};function of(a,b,c,d){pf(a,b);a.filter(function(e){return-1!==[\"insertInto\",\"insertAttributes\",\"replaceValue\",\"rename\"].indexOf(e.type)}).forEach(function(e){switch(e.type){case \"insertInto\":jf(e.target,e.content,d);break;case \"insertAttributes\":kf(e.target,e.content,b,d);break;case \"rename\":lf(e.target,e.s,b,c,d);break;case \"replaceValue\":var f=e.target;e=e.s;if(2===f.node.nodeType){var g=Ub(b,f);g?d.setAttributeNS(g.node,f.node.namespaceURI,f.node.nodeName,e):f.node.value=e}else d.setData(f.node,\ne)}});a.filter(function(e){return-1!==[\"insertBefore\",\"insertAfter\",\"insertIntoAsFirst\",\"insertIntoAsLast\"].indexOf(e.type)}).forEach(function(e){switch(e.type){case \"insertAfter\":ff(e.target,e.content,b,d);break;case \"insertBefore\":gf(e.target,e.content,b,d);break;case \"insertIntoAsFirst\":hf(e.target,e.content,b,d);break;case \"insertIntoAsLast\":jf(e.target,e.content,d)}});a.filter(function(e){return\"replaceNode\"===e.type}).forEach(function(e){mf(e.target,e.s,b,d)});a.filter(function(e){return\"replaceElementContent\"===\ne.type}).forEach(function(e){nf(e.target,e.text,b,d)});a.filter(function(e){return\"delete\"===e.type}).forEach(function(e){e=e.target;var f=Ub(b,e);(f=f?f.node:null)&&(2===e.node.nodeType?d.removeAttributeNS(f,e.node.namespaceURI,e.node.nodeName):d.removeChild(f,e.node))});if(a.some(function(e){return\"put\"===e.type}))throw Error('Not implemented: the execution for pendingUpdate \"put\" is not yet implemented.');}\nfunction pf(a,b){function c(f){return new Ab(f.node.prefix,f.node.namespaceURI,f.node.localName)}function d(f,g){var k=new Set;a.filter(function(l){return l.type===f}).map(function(l){return l.target}).forEach(function(l){l=l?l.node:null;k.has(l)&&g(l);k.add(l)})}d(\"rename\",function(f){throw Error(\"XUDY0015: The target \"+f.outerHTML+\" is used in more than one rename expression.\");});d(\"replaceNode\",function(f){throw Error(\"XUDY0016: The target \"+f.outerHTML+\" is used in more than one replace expression.\");\n});d(\"replaceValue\",function(f){throw Ze(f);});d(\"replaceElementContent\",function(f){throw Ze(f);});var e=new Map;a.filter(function(f){return\"replaceNode\"===f.type&&2===f.target.node.nodeType}).forEach(function(f){var g=Ub(b,f.target);g=g?g.node:null;var k=e.get(g);k?k.push.apply(k,w(f.s.map(c))):e.set(g,f.s.map(c))});a.filter(function(f){return\"rename\"===f.type&&2===f.target.node.nodeType}).forEach(function(f){var g=Ub(b,f.target);if(g){g=g.node;var k=e.get(g);k?k.push(f.s):e.set(g,[f.s])}});e.forEach(function(f){var g=\n{};f.forEach(function(k){g[k.prefix]||(g[k.prefix]=k.namespaceURI);if(g[k.prefix]!==k.namespaceURI)throw bf(k.namespaceURI);})})}function qf(a,b){for(var c=[],d=1;da.h[c])return-1}return 0};function Af(){return Oc(\"Expected base expression of a function call to evaluate to a sequence of single function item\")}function Bf(a,b,c,d){for(var e=[],f=0;fg.R.length||0>=l)throw Error(\"FOAY0001: subarray start out of bounds.\");if(0>k)throw Error(\"FOAY0002: subarray length out of bounds.\");if(l+k>g.R.length+1)throw Error(\"FOAY0001: subarray start + length out of bounds.\");return E.o(new Xb(g.R.slice(l-1,k+l-1)))})}\nfunction Hf(a,b,c,d,e){return $b([d],function(f){var g=t(f).next().value;return e.L(function(k){k=k.map(function(v){return v.value}).sort(function(v,A){return A-v}).filter(function(v,A,G){return G[A-1]!==v});for(var l=g.R.concat(),n=0,q=k.length;ng.R.length||0>=u)throw Error(\"FOAY0001: subarray position out of bounds.\");l.splice(u-1,1)}return E.o(new Xb(l))})})}function If(a){return C(a,1)||C(a,20)||C(a,19)}\nfunction Jf(a,b,c,d,e){return 0===d.length?0!==e.length:0!==e.length&&Me(a,b,c,d[0],e[0]).next(0).value?Jf(a,b,c,d.slice(1),e.slice(1)):d[0].value!==d[0].value?!0:If(d[0].type)&&0!==e.length&&If(e[0].type)?d[0].value=g||g>k.R.length)throw Error(\"FOAY0001: array position out of bounds.\");k=k.R.concat();k.splice(g-1,1,rb(f));return E.o(new Xb(k))})}},{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(a,b,c,d,e){return $b([d],function(f){f=t(f).next().value.R.concat([rb(e)]);return E.o(new Xb(f))})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",\nlocalName:\"subarray\",l:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],i:{type:62,g:3},m:Gf},{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(a,b,c,d,e){var f=E.o(y(d.first().value.length-e.first().value+1,5));return Gf(a,b,c,d,e,f)}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",localName:\"remove\",l:[{type:62,g:3},{type:5,g:2}],i:{type:62,g:3},m:Hf},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",\nlocalName:\"insert-before\",l:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},m:function(a,b,c,d,e,f){return $b([d,e],function(g){var k=t(g);g=k.next().value;k=k.next().value.value;if(k>g.R.length+1||0>=k)throw Error(\"FOAY0001: subarray position out of bounds.\");g=g.R.concat();g.splice(k-1,0,rb(f));return E.o(new Xb(g))})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",localName:\"head\",l:[{type:62,g:3}],i:{type:59,g:2},m:function(a,b,c,d){return Wb(a,b,c,d,E.o(y(1,5)))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",\nlocalName:\"tail\",l:[{type:62,g:3}],i:{type:59,g:2},m:function(a,b,c,d){return Hf(a,b,c,d,E.o(y(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(a,b,c,d){return $b([d],function(e){e=t(e).next().value;return E.o(new Xb(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(a,b,c,d){return d.L(function(e){e=e.reduce(function(f,\ng){return f.concat(g.R)},[]);return E.o(new Xb(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(a,b,c,d,e){return $b([d,e],function(f){f=t(f);var g=f.next().value,k=f.next().value;if(1!==k.A)throw Oc(\"The callback passed into array:for-each has a wrong arity.\");f=g.R.map(function(l){return rb(k.value.call(void 0,a,b,c,Bf(k.s,[l()],b,\"array:for-each\")[0]))});return E.o(new Xb(f))})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/array\",\nlocalName:\"filter\",l:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},m:function(a,b,c,d,e){return $b([d,e],function(f){f=t(f);var g=f.next().value,k=f.next().value;if(1!==k.A)throw Oc(\"The callback passed into array:filter has a wrong arity.\");var l=g.R.map(function(u){u=Bf(k.s,[u()],b,\"array:filter\")[0];var v=k.value;return v(a,b,c,u)}),n=[],q=!1;return E.create({next:function(){if(q)return z;for(var u=0,v=g.R.length;u=c.start.line&&k<=c.end.line){var l=kc.start.line?g.length:c.start.la-1+g.length;e.push(Array(g.length+\nf.length).fill(\" \",0,k).fill(\"^\",k,l).join(\"\"))}return e},[]);b=dg(b).join(\"\\n\");throw new ag(a.join(\"\\n\")+\"\\n\\n\"+b,c);};var eg=Object.create(null);function fg(a,b){for(var c=[],d=0;da.length?\"\":\"object\"===typeof a[1]?a[2]||\"\":a[1]||\"\"}function O(a,b){if(!Array.isArray(a))return null;a=a[1];return\"object\"!==typeof a||Array.isArray(a)?null:b in a?a[b]:null}function P(a,b){return b.reduce(M,a)}\nfunction Q(a,b){for(var c=[],d=1;dNumber.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error(\"FODT0002: Value overflow while dividing xs:yearMonthDuration\");return new jd(aNumber.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error(\"FODT0002: Value overflow while dividing xs:dayTimeDuration\");return new fc(ae;e++)if(g=kh(d[e],b,c[f]))return 59!==g.type&&R(a,\"type\",g),g;default:return{type:59,g:2}}}59!==d.type&&R(a,\"type\",d);return d}\nfunction kh(a,b,c){var d=Q(a,\"*\"),e=M(a,\"atomicType\");if(!e)return{type:59,g:2};if(wb(O(e,\"prefix\")+\":\"+e[2])===b.type)if(1===d.length){if(3===b.g)return c}else if(a=M(a,\"occurrenceIndicator\")[1],b.g===yb(a))return c};function lh(a,b){T(a,b)}function T(a,b){var c=mh.get(a[0]);if(c)return c(a,b);for(c=1;c:\"+a.location.start.line+\":\"+a.location.start.la+\" - \"+a.location.end.line+\":\"+a.location.end.la);return b};function Uh(a,b,c){uf.call(this,c.s,[c],{C:c.C,Y:c.Y,S:c.O,subtree:c.subtree});this.j=b;this.J={end:{la:a.end.la,line:a.end.line,offset:a.end.offset},start:{la:a.start.la,line:a.start.line,offset:a.start.offset}}}x(Uh,uf);Uh.prototype.B=function(a,b,c){var d=this;b=t(c).next().value;try{var e=b(a)}catch(f){throw new Th(this.J,this.j,f);}return E.create({next:function(f){try{return e.value.next(f)}catch(g){throw new Th(d.J,d.j,g);}}})};\nUh.prototype.P=function(a){try{uf.prototype.P.call(this,a)}catch(b){throw new Th(this.J,this.j,b);}};function Vh(a,b,c,d){I.call(this,a,b,c,!0);this.j=d;this.I=this.j.I}x(Vh,I);function Wh(a,b,c,d){var e=[],f=a.J(b,c,d,function(k){if(a.j instanceof Vh){var l=Wh(a.j,b,k,d);return tf(l,function(q){return e=q})}var n=null;return E.create({next:function(){for(;;){if(!n){var q=k.next(0);if(q.done)return z;q=a.j.u(q.value,d);n=tf(q,function(u){return e=qf(e,u)}).value}q=n.next(0);if(q.done)n=null;else return q}}})}),g=!1;return{next:function(){if(g)return z;var k=f.N();g=!0;return B(new df(k,e))}}}\nVh.prototype.h=function(a,b){var c=this;return this.J(a,Ld(a),b,function(d){if(c.j instanceof Vh)return Xh(c.j,a,d,b);var e=null;return E.create({next:function(f){for(;;){if(!e){var g=d.next(0);if(g.done)return z;e=J(c.j,g.value,b).value}g=e.next(f);if(g.done)e=null;else return g}}})})};Vh.prototype.u=function(a,b){return Wh(this,a,Ld(a),b)};\nVh.prototype.P=function(a){I.prototype.P.call(this,a);this.I=this.j.I;a=t(this.ha);for(var b=a.next();!b.done;b=a.next())if(b=b.value,b!==this.j&&b.I)throw Te();};function Xh(a,b,c,d){return a.J(b,c,d,function(e){if(a.j instanceof Vh)return Xh(a.j,b,e,d);var f=null;return E.create({next:function(){for(;;){if(!f){var g=e.next(0);if(g.done)return z;f=J(a.j,g.value,d).value}g=f.next(0);if(g.done)f=null;else return g}}})})};function Yh(a,b,c,d){Vh.call(this,b.s.add(d.s),[b,d],{C:!1},d);this.T=a.prefix;this.ka=a.namespaceURI;this.$b=a.localName;this.mb=null;this.B=c;this.ua=null;this.na=b}x(Yh,Vh);\nYh.prototype.J=function(a,b,c,d){var e=this,f=null,g=null,k=0;return d({next:function(){for(var l={};;){if(!f){var n=b.next(0);if(n.done)return z;g=n.value;k=0;f=J(e.na,g,c).value}l.hb=f.next(0);if(l.hb.done)f=null;else return k++,n={},l=(n[e.mb]=function(q){return function(){return E.o(q.hb.value)}}(l),n),e.ua&&(l[e.ua]=function(){return E.o(new sb(5,k))}),B(Kc(g,l));l={hb:l.hb}}}})};\nYh.prototype.P=function(a){if(this.T&&(this.ka=a.ba(this.T),!this.ka&&this.T))throw Error(\"XPST0081: Could not resolve namespace for prefix \"+this.T+\" in a for expression\");this.na.P(a);yg(a);this.mb=Cg(a,this.ka,this.$b);if(this.B){if(this.B.prefix&&(this.B.namespaceURI=a.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.ua=Cg(a,this.B.namespaceURI,this.B.localName)}this.j.P(a);\nEg(a);if(this.na.I)throw Te();this.j.I&&(this.I=!0)};function Zh(a,b,c){var d={};I.call(this,new yf((d.external=1,d)),[c],{C:!1,S:\"unsorted\"});this.T=a.map(function(e){return e.name});this.B=a.map(function(e){return e.type});this.u=null;this.J=b;this.j=c}x(Zh,I);\nZh.prototype.h=function(a,b){var c=this,d=new Bb({l:this.B,arity:this.B.length,Pa:!0,I:this.j.I,localName:\"dynamic-function\",namespaceURI:\"\",i:this.J,value:function(e,f,g,k){for(var l=[],n=3;nc.W.value};case \"geOp\":return function(c,d){c=b(c,d);return c.V.value>=c.W.value}}}\nfunction li(a,b){switch(a){case \"ltOp\":return function(c,d){c=b(c,d);return c.V.value.gac.W.value.ga};case \"geOp\":return function(c,d){d=b(c,d);c=d.V;d=d.W;return ec(c.value,d.value)||c.value.ga>d.value.ga}}}\nfunction mi(a,b){switch(a){case \"eqOp\":return function(c,d){c=b(c,d);return ec(c.V.value,c.W.value)};case \"ltOp\":return function(c,d){c=b(c,d);return c.V.value.eac.W.value.ea};case \"geOp\":return function(c,d){d=b(c,d);c=d.V;d=d.W;return ec(c.value,d.value)||c.value.ea>d.value.ea}}}\nfunction ni(a,b){switch(a){case \"eqOp\":return function(c,d){c=b(c,d);return ec(c.V.value,c.W.value)};case \"neOp\":return function(c,d){c=b(c,d);return!ec(c.V.value,c.W.value)}}}\nfunction oi(a,b){switch(a){case \"eqOp\":return function(c,d,e){c=b(c,d);return vc(c.V.value,c.W.value,Jc(e))};case \"neOp\":return function(c,d,e){c=b(c,d);return!vc(c.V.value,c.W.value,Jc(e))};case \"ltOp\":return function(c,d,e){c=b(c,d);e=Jc(e);return 0>uc(c.V.value,c.W.value,e)};case \"leOp\":return function(c,d,e){d=b(c,d);c=d.V;d=d.W;var f;(f=vc(c.value,d.value,Jc(e)))||(e=Jc(e),f=0>uc(c.value,d.value,e));return f};case \"gtOp\":return function(c,d,e){c=b(c,d);e=Jc(e);return 0Td(b,e.first(),f.first())}:void 0;case \"nodeAfterOp\":return b?function(e,f){return 0Td(b.h,g,k)){if(q=B(g),g=null,\"exceptOp\"===c.j)return q}else k=null}if(\"exceptOp\"===c.j)return null!==\ng?(q=B(g),g=null,q):e.next(0);l=!0;return z}})};function Di(a,b){uf.call(this,a.reduce(function(c,d){return c.add(d.s)},new yf({})),a,{S:\"unsorted\",C:a.every(function(c){return c.C})},b)}x(Di,uf);Di.prototype.B=function(a,b,c){return c.length?Mc(c.map(function(d){return d(a)})):E.empty()};function Ei(a,b,c){I.call(this,(new yf({})).add(a.s),[a,b],{C:a.C&&b.C},!1,c);this.j=a;this.u=b}x(Ei,I);Ei.prototype.h=function(a,b){var c=this,d=J(this.j,a,b),e=Gc(a,d),f=null,g=null,k=!1;return E.create({next:function(l){for(;!k;){if(!f&&(f=e.next(l),f.done))return k=!0,z;g||(g=J(c.u,f.value,b));var n=g.value.next(l);if(n.done)f=g=null;else return n}}})};function Fi(a,b,c){I.call(this,a.s,[a],{C:!1});this.j=wb(b.prefix?b.prefix+\":\"+b.localName:b.localName);if(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(b.namespaceURI)throw Error(\"Not implemented: castable as expressions with a namespace URI.\");this.B=a;this.u=c}x(Fi,I);\nFi.prototype.h=function(a,b){var c=this,d=Vc(J(this.B,a,b),b);return d.$({empty:function(){return c.u?E.ca():E.X()},o:function(){return d.map(function(e){return Jd(e,c.j).v?cb:db})},multiple:function(){return E.X()}})};function Gi(a,b,c){I.call(this,a.s,[a],{C:!1});this.j=wb(b.prefix?b.prefix+\":\"+b.localName:b.localName);if(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(b.namespaceURI)throw Error(\"Not implemented: casting expressions with a namespace URI.\");this.B=a;this.u=c}x(Gi,I);\nGi.prototype.h=function(a,b){var c=this,d=Vc(J(this.B,a,b),b);return d.$({empty:function(){if(!c.u)throw Error(\"XPTY0004: Sequence to cast is empty while target type is singleton.\");return E.empty()},o:function(){return d.map(function(e){return Kd(e,c.j)})},multiple:function(){throw Error(\"XPTY0004: Sequence to cast is not singleton or empty.\");}})};function Hi(a,b){var c=a.value,d=null,e=!1;return E.create({next:function(){for(;!e;){if(!d){var f=c.next(0);if(f.done)return e=!0,B(cb);d=b(f.value)}f=d.getEffectiveBooleanValue();d=null;if(!1===f)return e=!0,B(db)}return z}})};function Ii(a,b,c,d){I.call(this,a.s,[a],{C:!1},!1,d);this.B=a;this.u=b;this.j=c}x(Ii,I);Ii.prototype.h=function(a,b){var c=this,d=J(this.B,a,b);return d.$({empty:function(){return\"?\"===c.j||\"*\"===c.j?E.ca():E.X()},multiple:function(){return\"+\"===c.j||\"*\"===c.j?Hi(d,function(e){var f=E.o(e);e=Hc(a,0,e,f);return J(c.u,e,b)}):E.X()},o:function(){return Hi(d,function(e){var f=E.o(e);e=Hc(a,0,e,f);return J(c.u,e,b)})}})};function Ji(a,b){return null!==a&&null!==b&&C(a.type,53)&&C(b.type,53)?Nd(a.value,b.value):!1}function Ki(a){var b=a.next(0);if(b.done)return E.empty();var c=null,d=null;return E.create({next:function(e){if(b.done)return z;c||(c=b.value.value);do{var f=c.next(e);if(f.done){b=a.next(0);if(b.done)return f;c=b.value.value}}while(f.done||Ji(f.value,d));d=f.value;return f}})}\nfunction Li(a,b){var c=[];(function(){for(var g=b.next(0),k={};!g.done;)k.jb=g.value.value,g={current:k.jb.next(0),next:function(l){return function(n){return l.jb.next(n)}}(k)},g.current.done||c.push(g),g=b.next(0),k={jb:k.jb}})();var d=null,e=!1,f={};return E.create((f[Symbol.iterator]=function(){return this},f.next=function(){e||(e=!0,c.every(function(v){return C(v.current.value.type,53)})&&c.sort(function(v,A){return Td(a,v.current.value,A.current.value)}));do{if(!c.length)return z;var g=c.shift();\nvar k=g.current;g.current=g.next(0);if(!C(k.value.type,53))return k;if(!g.current.done){for(var l=0,n=c.length-1,q=0;l<=n;){q=Math.floor((l+n)/2);var u=Td(a,g.current.value,c[q].current.value);if(0===u){l=q;break}0=c.j.length?z:B(J(c.j[d++],a,b))}}).map(function(e){if(!C(e.type,53))throw Error(\"XPTY0004: The sequences to union are not of type node()*\");return e})}return Mc(this.j.map(function(e){return J(e,a,b)})).L(function(e){if(e.some(function(f){return!C(f.type,53)}))throw Error(\"XPTY0004: The sequences to union are not of type node()*\");e=Ud(b.h,e);return E.create(e)})};function Ni(a){return a.every(function(b){return null===b||C(b.type,5)||C(b.type,4)})||null!==a.map(function(b){return b?Wc(b.type):null}).reduce(function(b,c){return null===c?b:c===b?b:null})?a:a.every(function(b){return null===b||C(b.type,1)||C(b.type,20)})?a.map(function(b){return b?Kd(b,1):null}):a.every(function(b){return null===b||C(b.type,4)||C(b.type,6)})?a.map(function(b){return b?Kd(b,6):b}):a.every(function(b){return null===b||C(b.type,4)||C(b.type,6)||C(b.type,3)})?a.map(function(b){return b?\nKd(b,3):b}):null};function Oi(a){return(a=a.find(function(b){return!!b}))?Wc(a.type):null}function Pi(a,b){var c=new yf({});Vh.call(this,c,[b].concat(w(a.map(function(d){return d.da}))),{C:!1,Y:!1,S:\"unsorted\",subtree:!1},b);this.B=a}x(Pi,Vh);\nPi.prototype.J=function(a,b,c,d){if(this.B[1])throw Error(\"More than one order spec is not supported for the order by clause.\");var e=[],f=!1,g,k,l=null,n=this.B[0];return E.create({next:function(){if(!f){for(var q=b.next(0);!q.done;)e.push(q.value),q=b.next(0);q=e.map(function(ea){return n.da.h(ea,c)}).map(function(ea){return Vc(ea,c)});if(q.find(function(ea){return!ea.G()&&!ea.ya()}))throw mg(\"Order by only accepts empty or singleton sequences\");g=q.map(function(ea){return ea.first()});g=g.map(function(ea){return null===\nea?ea:C(19,ea.type)?Kd(ea,1):ea});if(Oi(g)&&(g=Ni(g),!g))throw mg(\"Could not cast values\");q=g.length;k=g.map(function(ea,Ea){return Ea});for(var u=0;u=g.length?z:B(e[k[fa++]]):0>fa?z:B(e[k[fa--]])}}).value;f=!0}return l.next(0)}})};function Qi(a){I.call(this,a?a.s:new yf({}),a?[a]:[],{S:\"sorted\",subtree:!1,Y:!1,C:!1});this.j=a}x(Qi,I);Qi.prototype.h=function(a,b){if(null===a.M)throw Error(\"XPDY0002: context is absent, it needs to be present to use paths.\");for(var c=b.h,d=a.M.value;9!==d.node.nodeType;)if(d=Ub(c,d),null===d)throw Error(\"XPDY0050: the root node of the context node is not a document node.\");c=E.o(Zb(d));return this.j?J(this.j,Hc(a,0,c.first(),c),b):c};function Ri(a){I.call(this,new yf({}),[],{S:\"sorted\"},!1,a)}x(Ri,I);Ri.prototype.h=function(a){if(null===a.M)throw Error('XPDY0002: context is absent, it needs to be present to use the \".\" operator');return E.o(a.M)};function Si(a,b){var c=!1,d=!1;b.forEach(function(e){C(e.type,53)?c=!0:d=!0});if(d&&c)throw Error(\"XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.\");return c?Ud(a,b):b}function Ti(a,b){var c=a.every(function(e){return e.Y}),d=a.every(function(e){return e.subtree});I.call(this,a.reduce(function(e,f){return e.add(f.s)},new yf({})),a,{C:!1,Y:c,S:b?\"sorted\":\"unsorted\",subtree:d});this.j=a;this.u=b}x(Ti,I);\nTi.prototype.h=function(a,b){var c=this,d=!0;return this.j.reduce(function(e,f,g){var k=null===e?Ld(a):Gc(a,e);e={next:function(q){q=k.next(q);if(q.done)return z;if(null!==q.value.M&&!C(q.value.M.type,53)&&0=d)throw Error(\"FOAY0001: Array index out of bounds\");c.push(a.R[d-1]())}else throw mg(\"The key specifier is not an integer.\");else if(C(a.type,61))\"*\"===b?c.push.apply(c,w(a.h.map(function(e){return e.value()}))):(a=a.h.find(function(e){return ac(e.key,b)}))&&c.push(a.value());else throw mg(\"The provided context item is not a map or an array.\");\nreturn Mc(c)}function Wi(a,b,c,d,e){if(\"*\"===b)return Vi(a,b,c);b=J(b,d,e);b=rb(b)().L(function(f){return f.reduce(function(g,k){return Vi(a,k,g)},new ib)});return Mc([c,b])};function Xi(a,b){I.call(this,a.s,[a].concat(\"*\"===b?[]:[b]),{C:a.C,S:a.O,subtree:a.subtree});this.j=a;this.u=b}x(Xi,I);Xi.prototype.h=function(a,b){var c=this;return J(this.j,a,b).L(function(d){return d.reduce(function(e,f){return Wi(f,c.u,e,a,b)},new ib)})};Xi.prototype.A=function(){return this.j.A()};function Yi(a,b){var c={};I.call(this,new yf((c.external=1,c)),\"*\"===a?[]:[a],{C:!1},!1,b);this.j=a}x(Yi,I);Yi.prototype.h=function(a,b){return Wi(a.M,this.j,new ib,a,b)};function Zi(a,b,c,d){var e=b.map(function(g){return g.eb});b=b.map(function(g){return g.name});var f=e.reduce(function(g,k){return g.add(k.s)},c.s);I.call(this,f,e.concat(c),{C:!1},!1,d);this.u=a;this.B=b;this.J=e;this.T=c;this.j=null}x(Zi,I);\nZi.prototype.h=function(a,b){var c=this,d=a,e=this.j.map(function(q,u){var v=J(c.J[u],d,b).N();u={};d=Kc(a,(u[q]=function(){return E.create(v)},u));return v});if(e.some(function(q){return 0===q.length}))return\"every\"===this.u?E.ca():E.X();var f=Array(e.length).fill(0);f[0]=-1;for(var g=!0;g;){g=!1;for(var k=0,l=f.length;kn.length-1)f[k]=0;else{g=Object.create(null);k={};for(l=0;l\"))throw Error('XQDY0026: The content \"'+l+'\" for a processing instruction node contains \"?>\".');k=!0;return B({H:[],fa:qf([new xj(d.value,\nl)],g,e)})}}}}function Nj(a,b,c){rf.call(this,new yf({}),[b,c],{C:!1,S:\"unsorted\"});this.J=a;this.j=b;this.B=c}x(Nj,rf);Nj.prototype.u=function(a,b){var c=sf(this.j)(a,b);a=sf(this.B)(a,b);return this.J?Mj(b,c,a):Lj(b,c,a)};function Oj(a){switch(a.type){case \"delete\":return new mj({node:a.target,F:null});case \"insertAfter\":return new oj({node:a.target,F:null},a.content.map(function(b){return{node:b,F:null}}));case \"insertBefore\":return new qj({node:a.target,F:null},a.content.map(function(b){return{node:b,F:null}}));case \"insertInto\":return new tj({node:a.target,F:null},a.content.map(function(b){return{node:b,F:null}}));case \"insertIntoAsFirst\":return new rj({node:a.target,F:null},a.content.map(function(b){return{node:b,\nF:null}}));case \"insertIntoAsLast\":return new sj({node:a.target,F:null},a.content.map(function(b){return{node:b,F:null}}));case \"insertAttributes\":return new pj({node:a.target,F:null},a.content.map(function(b){return{node:b,F:null}}));case \"rename\":return new uj({node:a.target,F:null},a.newName);case \"replaceNode\":return new wj({node:a.target,F:null},a.replacement.map(function(b){return{node:b,F:null}}));case \"replaceValue\":return new xj({node:a.target,F:null},a[\"string-value\"]);case \"replaceElementContent\":return new vj({node:a.target,\nF:null},a.text?{node:a.text,F:null}:null);default:throw Error('Unexpected type \"'+a.type+'\" when parsing a transferable pending update.');}};function Pj(a,b,c){if(b.find(function(e){return Nd(e,a)}))return!0;var d=Ub(c,a);return d?Pj(d,b,c):!1}function Qj(a,b,c){rf.call(this,new yf({}),a.reduce(function(d,e){d.push(e.eb);return d},[b,c]),{C:!1,S:\"unsorted\"});this.j=a;this.J=b;this.B=c;this.I=null}x(Qj,rf);Qj.prototype.h=function(a,b){a=this.u(a,b);return tf(a,function(){})};\nQj.prototype.u=function(a,b){var c=this,d=b.h,e=b.s,f=b.A,g=[],k,l,n,q=[],u=[];return{next:function(){if(q.length!==c.j.length)for(var v={},A=q.length;A\"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include \"?>\"');if(null!==c.j.Jb)return e=c.j.Jb,Vj(e),E.o(Zb(Wj(e,f)));e=J(c.j.Cb,a,b);var g=Ij(b,e);return E.create({next:function(){var k=g.next(0);if(k.done)return k;k=k.value.value;Vj(k);return B(Zb(Wj(k,f)))}})})};function Yj(a){I.call(this,a?a.s:new yf({}),a?[a]:[],{C:!1,S:\"unsorted\"});this.j=a}x(Yj,I);Yj.prototype.h=function(a,b){if(!this.j)return E.empty();a=J(this.j,a,b);return Vc(a,b).L(function(c){if(0===c.length)return E.empty();c={node:{data:c.map(function(d){return Kd(d,1).value}).join(\" \"),Qa:!0,nodeType:3},F:null};return E.o(Zb(c))})};function Zj(a,b,c,d){var e=new yf({}),f;uf.call(this,e,(f=[a].concat(w(b.map(function(g){return g.xc})),[c])).concat.apply(f,w(b.map(function(g){return g.Lb.map(function(k){return k.Kb})}))),{C:!1,Y:!1,S:\"unsorted\",subtree:!1},d);this.J=a;this.j=b.length;this.T=b.map(function(g){return g.Lb})}x(Zj,uf);\nZj.prototype.B=function(a,b,c){var d=this;return c[0](a).L(function(e){for(var f=0;fe.length)return!1;break;default:if(1!==e.length)return!1}var k=E.create(e);return e.every(function(l,n){l=Hc(a,n,l,k);return J(g.Kb,l,b).getEffectiveBooleanValue()})}))return c[f+1](a);return c[d.j+1](a)})};Zj.prototype.P=function(a){uf.prototype.P.call(this,a);if(this.J.I)throw Te();};var ak={aa:!1,qa:!1},bk={aa:!0,qa:!1},ck={aa:!0,qa:!0};function dk(a){return a.aa?a.qa?ck:bk:ak}\nfunction U(a,b){switch(a[0]){case \"andOp\":var c=O(a,\"type\");return new gi(ek(\"andOp\",a,dk(b)),c);case \"orOp\":return c=O(a,\"type\"),new hi(ek(\"orOp\",a,dk(b)),c);case \"unaryPlusOp\":return c=M(M(a,\"operand\"),\"*\"),a=O(a,\"type\"),new fi(\"+\",U(c,b),a);case \"unaryMinusOp\":return c=M(M(a,\"operand\"),\"*\"),a=O(a,\"type\"),new fi(\"-\",U(c,b),a);case \"addOp\":case \"subtractOp\":case \"multiplyOp\":case \"divOp\":case \"idivOp\":case \"modOp\":var d=a[0],e=U(P(a,[\"firstOperand\",\"*\"]),dk(b));b=U(P(a,[\"secondOperand\",\"*\"]),dk(b));\nvar f=O(a,\"type\"),g=O(P(a,[\"firstOperand\",\"*\"]),\"type\"),k=O(P(a,[\"secondOperand\",\"*\"]),\"type\");g&&k&&O(a,\"type\")&&(c=Pg(d,g.type,k.type));return new Yg(d,e,b,f,c);case \"sequenceExpr\":return fk(a,b);case \"unionOp\":return c=O(a,\"type\"),new Mi([U(P(a,[\"firstOperand\",\"*\"]),dk(b)),U(P(a,[\"secondOperand\",\"*\"]),dk(b))],c);case \"exceptOp\":case \"intersectOp\":return c=O(a,\"type\"),new Ci(a[0],U(P(a,[\"firstOperand\",\"*\"]),dk(b)),U(P(a,[\"secondOperand\",\"*\"]),dk(b)),c);case \"stringConcatenateOp\":return gk(a,b);\ncase \"rangeSequenceExpr\":return hk(a,b);case \"equalOp\":case \"notEqualOp\":case \"lessThanOrEqualOp\":case \"lessThanOp\":case \"greaterThanOrEqualOp\":case \"greaterThanOp\":return ik(\"generalCompare\",a,b);case \"eqOp\":case \"neOp\":case \"ltOp\":case \"leOp\":case \"gtOp\":case \"geOp\":return ik(\"valueCompare\",a,b);case \"isOp\":case \"nodeBeforeOp\":case \"nodeAfterOp\":return ik(\"nodeCompare\",a,b);case \"pathExpr\":return jk(a,b);case \"contextItemExpr\":return new Ri(O(a,\"type\"));case \"functionCallExpr\":return kk(a,b);case \"inlineFunctionExpr\":return lk(a,\nb);case \"arrowExpr\":return mk(a,b);case \"dynamicFunctionInvocationExpr\":return nk(a,b);case \"namedFunctionRef\":return b=M(a,\"functionName\"),c=O(a,\"type\"),a=N(P(a,[\"integerConstantExpr\",\"value\"])),new ci(Fg(b),parseInt(a,10),c);case \"integerConstantExpr\":return new ai(N(M(a,\"value\")),{type:5,g:3});case \"stringConstantExpr\":return new ai(N(M(a,\"value\")),{type:1,g:3});case \"decimalConstantExpr\":return new ai(N(M(a,\"value\")),{type:4,g:3});case \"doubleConstantExpr\":return new ai(N(M(a,\"value\")),{type:3,\ng:3});case \"varRef\":return a=Fg(M(a,\"name\")),new ej(a.prefix,a.namespaceURI,a.localName);case \"flworExpr\":return ok(a,b);case \"quantifiedExpr\":return pk(a,b);case \"ifThenElseExpr\":return c=O(a,\"type\"),new Sh(U(M(M(a,\"ifClause\"),\"*\"),dk(b)),U(M(M(a,\"thenClause\"),\"*\"),b),U(M(M(a,\"elseClause\"),\"*\"),b),c);case \"instanceOfExpr\":return c=U(P(a,[\"argExpr\",\"*\"]),b),d=P(a,[\"sequenceType\",\"*\"]),e=P(a,[\"sequenceType\",\"occurrenceIndicator\"]),a=O(a,\"type\"),new Ii(c,U(d,dk(b)),e?N(e):\"\",a);case \"castExpr\":return b=\nU(M(M(a,\"argExpr\"),\"*\"),dk(b)),c=M(a,\"singleType\"),a=Fg(M(c,\"atomicType\")),c=null!==M(c,\"optional\"),new Gi(b,a,c);case \"castableExpr\":return b=U(M(M(a,\"argExpr\"),\"*\"),dk(b)),c=M(a,\"singleType\"),a=Fg(M(c,\"atomicType\")),c=null!==M(c,\"optional\"),new Fi(b,a,c);case \"simpleMapExpr\":return qk(a,b);case \"mapConstructor\":return rk(a,b);case \"arrayConstructor\":return sk(a,b);case \"unaryLookup\":return c=O(a,\"type\"),new Yi(tk(a,b),c);case \"typeswitchExpr\":return uk(a,b);case \"elementConstructor\":return vk(a,\nb);case \"attributeConstructor\":return wk(a,b);case \"computedAttributeConstructor\":return(c=M(a,\"tagName\"))?c=Fg(c):(c=M(a,\"tagNameExpr\"),c={Ka:U(M(c,\"*\"),dk(b))}),a=U(M(M(a,\"valueExpr\"),\"*\"),dk(b)),new Sj(c,{tb:[a]});case \"computedCommentConstructor\":if(!b.aa)throw Error(\"XPST0003: Use of XQuery functionality is not allowed in XPath context\");a=(a=M(a,\"argExpr\"))?U(M(a,\"*\"),dk(b)):null;return new Tj(a);case \"computedTextConstructor\":if(!b.aa)throw Error(\"XPST0003: Use of XQuery functionality is not allowed in XPath context\");\na=(a=M(a,\"argExpr\"))?U(M(a,\"*\"),dk(b)):null;return new Yj(a);case \"computedElementConstructor\":return xk(a,b);case \"computedPIConstructor\":if(!b.aa)throw Error(\"XPST0003: Use of XQuery functionality is not allowed in XPath context\");c=M(a,\"piTargetExpr\");d=M(a,\"piTarget\");e=M(a,\"piValueExpr\");a=O(a,\"type\");return new Xj({Cb:c?U(M(c,\"*\"),dk(b)):null,Jb:d?N(d):null},e?U(M(e,\"*\"),dk(b)):new Di([],a));case \"CDataSection\":return new ai(N(a),{type:1,g:3});case \"deleteExpr\":return a=U(P(a,[\"targetExpr\",\n\"*\"]),b),new zj(a);case \"insertExpr\":c=U(P(a,[\"sourceExpr\",\"*\"]),b);e=Q(a,\"*\")[1];switch(e[0]){case \"insertAfter\":d=1;break;case \"insertBefore\":d=2;break;case \"insertInto\":d=(d=M(e,\"*\"))?\"insertAsFirst\"===d[0]?4:5:3}a=U(P(a,[\"targetExpr\",\"*\"]),b);return new Dj(c,d,a);case \"renameExpr\":return c=U(P(a,[\"targetExpr\",\"*\"]),b),a=U(P(a,[\"newNameExpr\",\"*\"]),b),new Kj(c,a);case \"replaceExpr\":return c=!!M(a,\"replaceValue\"),d=U(P(a,[\"targetExpr\",\"*\"]),b),a=U(P(a,[\"replacementExpr\",\"*\"]),b),new Nj(c,d,a);case \"transformExpr\":return yk(a,\nb);case \"x:stackTrace\":c=a[1];for(a=a[2];\"x:stackTrace\"===a[0];)a=a[2];return new Uh(c,a[0],U(a,b));default:return zk(a)}}\nfunction zk(a){switch(a[0]){case \"nameTest\":return new bj(Fg(a));case \"piTest\":return(a=M(a,\"piTarget\"))?new cj(N(a)):new aj(7);case \"commentTest\":return new aj(8);case \"textTest\":return new aj(3);case \"documentTest\":return new aj(9);case \"attributeTest\":var b=(a=M(a,\"attributeName\"))&&M(a,\"star\");return!a||b?new aj(2):new bj(Fg(M(a,\"QName\")),{kind:2});case \"elementTest\":return b=(a=M(a,\"elementName\"))&&M(a,\"star\"),!a||b?new aj(1):new bj(Fg(M(a,\"QName\")),{kind:1});case \"anyKindTest\":return new dj({prefix:\"\",\nnamespaceURI:null,localName:\"node()\"});case \"anyMapTest\":return new dj({prefix:\"\",namespaceURI:null,localName:\"map(*)\"});case \"anyArrayTest\":return new dj({prefix:\"\",namespaceURI:null,localName:\"array(*)\"});case \"Wildcard\":return M(a,\"star\")?(b=M(a,\"uri\"))?a=new bj({localName:\"*\",namespaceURI:N(b),prefix:\"\"}):(b=M(a,\"NCName\"),a=\"star\"===M(a,\"*\")[0]?new bj({localName:N(b),namespaceURI:null,prefix:\"*\"}):new bj({localName:\"*\",namespaceURI:null,prefix:N(b)})):a=new bj({localName:\"*\",namespaceURI:null,\nprefix:\"*\"}),a;case \"atomicType\":return new dj(Fg(a));case \"anyItemType\":return new dj({prefix:\"\",namespaceURI:null,localName:\"item()\"});default:throw Error(\"No selector counterpart for: \"+a[0]+\".\");}}function sk(a,b){var c=O(a,\"type\");a=M(a,\"*\");var d=Q(a,\"arrayElem\").map(function(e){return U(M(e,\"*\"),dk(b))});switch(a[0]){case \"curlyArray\":return new uh(d,c);case \"squareArray\":return new vh(d,c);default:throw Error(\"Unrecognized arrayType: \"+a[0]);}}\nfunction rk(a,b){var c=O(a,\"type\");return new bi(Q(a,\"mapConstructorEntry\").map(function(d){return{key:U(P(d,[\"mapKeyExpr\",\"*\"]),dk(b)),value:U(P(d,[\"mapValueExpr\",\"*\"]),dk(b))}}),c)}function ek(a,b,c){function d(f){var g=M(M(f,\"firstOperand\"),\"*\");f=M(M(f,\"secondOperand\"),\"*\");g[0]===a?d(g):e.push(U(g,c));f[0]===a?d(f):e.push(U(f,c))}var e=[];d(b);return e}function tk(a,b){a=M(a,\"*\");switch(a[0]){case \"NCName\":return new ai(N(a),{type:1,g:3});case \"star\":return\"*\";default:return U(a,dk(b))}}\nfunction ik(a,b,c){var d=P(b,[\"firstOperand\",\"*\"]),e=P(b,[\"secondOperand\",\"*\"]);d=U(d,dk(c));c=U(e,dk(c));switch(a){case \"valueCompare\":return new ti(b[0],d,c);case \"nodeCompare\":return new Ai(b[0],d,c);case \"generalCompare\":return new xi(b[0],d,c)}}\nfunction Ak(a,b,c){a=Q(a,\"*\");return new Pi(a.filter(function(d){return\"stable\"!==d[0]}).map(function(d){var e=M(d,\"orderModifier\"),f=e?M(e,\"orderingKind\"):null;e=e?M(e,\"emptyOrderingMode\"):null;f=f?\"ascending\"===N(f):!0;e=e?\"empty least\"===N(e):!0;return{da:U(P(d,[\"orderByExpr\",\"*\"]),b),Gb:f,zc:e}}),c)}\nfunction ok(a,b){var c=Q(a,\"*\");a=M(c[c.length-1],\"*\");c=c.slice(0,-1);if(1\"),xl=V.token(\"\"),Cl=V.token(\"&#x\"),\nDl=V.token(\"&#\"),El=V.token(\":*\"),Fl=V.token(\"*:\"),Gl=V.token(\":=\"),Hl=V.token(\"&\"),Il=V.token(\":\"),Jl=V.token(\";\"),Kl=V.token(\"*\"),Ll=V.token(\"@\"),Ml=V.token(\"$\"),Nl=V.token(\"#\"),Ol=V.token(\"%\"),Pl=V.token(\"?\"),Ql=V.token(\"!\"),Rl=V.token(\"|\"),Sl=V.token(\"||\"),Tl=V.token(\"=\"),Ul=V.token(\"!=\"),Vl=V.token(\"<\"),Wl=V.token(\"<<\"),Xl=V.token(\"<=\"),Yl=V.token(\">\"),Zl=V.token(\">>\"),$l=V.token(\">=\"),am=V.token(\",\"),bm=V.token(\".\"),cm=V.token(\"..\"),dm=V.token(\"+\"),em=V.token(\"-\"),fm=V.token(\"/\"),gm=V.token(\"//\"),\nhm=V.token(\"=>\"),im=V.token(\"e\"),jm=V.token(\"E\"),km=V.token(\"l\"),lm=V.token(\"L\"),mm=V.token(\"m\"),nm=V.token(\"M\"),om=V.token(\"Q\"),pm=V.token(\"x\"),qm=V.token(\"X\"),rm=V.token(\"as\"),sm=V.token(\"cast\"),tm=V.token(\"castable\"),um=V.token(\"treat\"),vm=V.token(\"instance\"),wm=V.token(\"of\"),xm=V.token(\"node\"),ym=V.token(\"nodes\"),zm=V.token(\"delete\"),Am=V.token(\"value\"),Bm=V.token(\"function\"),Cm=V.token(\"map\"),Dm=V.token(\"element\"),Em=V.token(\"attribute\"),Fm=V.token(\"schema-element\"),Gm=V.token(\"intersect\"),Hm=\nV.token(\"except\"),Im=V.token(\"union\"),Jm=V.token(\"to\"),Km=V.token(\"is\"),Lm=V.token(\"or\"),Mm=V.token(\"and\"),Nm=V.token(\"div\"),Om=V.token(\"idiv\"),Pm=V.token(\"mod\"),Qm=V.token(\"eq\"),Rm=V.token(\"ne\"),Sm=V.token(\"lt\"),Tm=V.token(\"le\"),Um=V.token(\"gt\"),Vm=V.token(\"ge\"),Wm=V.token(\"amp\"),Xm=V.token(\"quot\"),Ym=V.token(\"apos\"),Zm=V.token(\"if\"),$m=V.token(\"then\"),an=V.token(\"else\"),bn=V.token(\"allowing\"),cn=V.token(\"empty\"),dn=V.token(\"at\"),en=V.token(\"in\"),fn=V.token(\"for\"),gn=V.token(\"let\"),hn=V.token(\"where\"),\njn=V.token(\"collation\"),kn=V.token(\"group\"),ln=V.token(\"by\"),mn=V.token(\"order\"),nn=V.token(\"stable\"),on=V.token(\"return\"),pn=V.token(\"array\"),qn=V.token(\"document\"),rn=V.token(\"namespace\"),sn=V.token(\"text\"),tn=V.token(\"comment\"),un=V.token(\"processing-instruction\"),vn=V.token(\"lax\"),wn=V.token(\"strict\"),xn=V.token(\"validate\"),yn=V.token(\"type\"),zn=V.token(\"declare\"),An=V.token(\"default\"),Bn=V.token(\"boundary-space\"),Cn=V.token(\"strip\"),Dn=V.token(\"preserve\"),En=V.token(\"no-preserve\"),Fn=V.token(\"inherit\"),\nGn=V.token(\"no-inherit\"),Hn=V.token(\"greatest\"),In=V.token(\"least\"),Jn=V.token(\"copy-namespaces\"),Kn=V.token(\"decimal-format\"),Ln=V.token(\"case\"),Mn=V.token(\"typeswitch\"),Nn=V.token(\"some\"),On=V.token(\"every\"),Pn=V.token(\"satisfies\"),Qn=V.token(\"replace\"),Rn=V.token(\"with\"),Sn=V.token(\"copy\"),Tn=V.token(\"modify\"),Un=V.token(\"first\"),Vn=V.token(\"last\"),Wn=V.token(\"before\"),Xn=V.token(\"after\"),Yn=V.token(\"into\"),Zn=V.token(\"insert\"),$n=V.token(\"rename\"),ao=V.token(\"switch\"),bo=V.token(\"variable\"),co=\nV.token(\"external\"),eo=V.token(\"updating\"),fo=V.token(\"import\"),go=V.token(\"schema\"),ho=V.token(\"module\"),io=V.token(\"base-uri\"),jo=V.token(\"construction\"),ko=V.token(\"ordering\"),lo=V.token(\"ordered\"),mo=V.token(\"unordered\"),no=V.token(\"option\"),oo=V.token(\"context\"),po=V.token(\"item\"),qo=V.token(\"xquery\"),ro=V.token(\"version\"),so=V.token(\"encoding\"),to=V.token(\"document-node\"),uo=V.token(\"namespace-node\"),vo=V.token(\"schema-attribute\"),wo=V.token(\"ascending\"),xo=V.token(\"descending\"),yo=V.token(\"empty-sequence\"),\nzo=V.token(\"child::\"),Ao=V.token(\"descendant::\"),Bo=V.token(\"attribute::\"),Co=V.token(\"self::\"),Do=V.token(\"descendant-or-self::\"),Eo=V.token(\"following-sibling::\"),Fo=V.token(\"following::\"),Go=V.token(\"parent::\"),Ho=V.token(\"ancestor::\"),Io=V.token(\"preceding-sibling::\"),Jo=V.token(\"preceding::\"),Ko=V.token(\"ancestor-or-self::\"),Lo=V.token(\"decimal-separator\"),Mo=V.token(\"grouping-separator\"),No=V.token(\"infinity\"),Oo=V.token(\"minus-sign\"),Po=V.token(\"NaN\"),Qo=V.token(\"per-mille\"),Ro=V.token(\"zero-digit\"),\nSo=V.token(\"digit\"),To=V.token(\"pattern-separator\"),Uo=V.token(\"exponent-separator\"),Vo=V.token(\"schema-attribute(\"),Wo=V.token(\"document-node(\"),Xo=V.token(\"processing-instruction(\"),Yo=V.token(\"processing-instruction()\"),Zo=V.token(\"comment()\"),$o=V.token(\"text()\"),ap=V.token(\"namespace-node()\"),bp=V.token(\"node()\"),cp=V.token(\"item()\"),dp=V.token(\"empty-sequence()\");var ep=new Map,fp=new Map,gp=V.or([cl(/[\\t\\n\\r -\\uD7FF\\uE000\\uFFFD]/),cl(/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/)]),hp=V.preceded(V.peek(V.not(V.or([el,fl]),['comment contents cannot contain \"(:\" or \":)\"'])),gp),ip=V.map(V.delimited(el,V.star(V.or([hp,function(a,b){return ip(a,b)}])),fl),function(a){return a.join(\"\")}),jp=V.or([dl,ip]),kp=V.map(V.plus(dl),function(a){return a.join(\"\")}),Y=Xk(V.map(V.star(jp),function(a){return a.join(\"\")}),ep),Z=Xk(V.map(V.plus(jp),function(a){return a.join(\"\")}),fp);var lp=V.or([cl(/[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]/),V.then(cl(/[\\uD800-\\uDB7F]/),cl(/[\\uDC00-\\uDFFF]/),function(a,b){return a+b})]),mp=V.or([lp,cl(/[\\-\\.0-9\\xB7\\u0300-\\u036F\\u203F\\u2040]/)]),np=V.then(lp,V.star(mp),function(a,b){return a+b.join(\"\")}),op=V.map(np,function(a){return[\"prefix\",a]}),pp=V.or([lp,Il]),qp=V.or([mp,Il]),rp=V.then(pp,V.star(qp),function(a,b){return a+b.join(\"\")}),sp=\nV.map(np,function(a){var b={};return[(b.prefix=\"\",b.URI=null,b),a]}),tp=V.then(np,V.preceded(Il,np),function(a,b){var c={};return[(c.prefix=a,c.URI=null,c),b]}),up=V.or([tp,sp]),vp=V.followed(X([om,Y,ml],V.map(V.star(cl(/[^{}]/)),function(a){return a.join(\"\").replace(/\\s+/g,\" \").trim()})),nl),wp=V.then(vp,np,function(a,b){return[a,b]}),xp=V.or([V.map(wp,function(a){var b={};return[(b.prefix=null,b.URI=a[0],b),a[1]]}),up]),yp=V.or([V.map(xp,function(a){return[\"QName\"].concat(w(a))}),V.map(Kl,function(){return[\"star\"]})]),\nzp=V.map(V.preceded(Ml,xp),function(a){return[\"varRef\",[\"name\"].concat(w(a))]});var Ap=V.peek(V.or([il,sl,ql,jp])),Bp=V.map(V.or([zo,Ao,Bo,Co,Do,Eo,Fo]),function(a){return a.substring(0,a.length-2)}),Cp=V.map(V.or([Go,Ho,Io,Jo,Ko]),function(a){return a.substring(0,a.length-2)}),Dp=Yk(Hl,V.or([Sm,Um,Wm,Xm,Ym]),Jl,function(a,b,c){return a+b+c}),Ep=V.or([Yk(Cl,cl(/[0-9a-fA-F]+/),Jl,function(a,b,c){return a+b+c}),Yk(Dl,cl(/[0-9]+/),Jl,function(a,b,c){return a+b+c})]),Fp=bl([tl],'\"'),Gp=bl([rl],\"'\"),Hp=al(bl([Zo],\"commentTest\")),Ip=al(bl([$o],\"textTest\")),Jp=al(bl([ap],\"namespaceTest\")),\nKp=al(bl([bp],\"anyKindTest\")),Lp=cl(/[0-9]+/),Mp=V.then(V.or([V.then(bm,Lp,function(a,b){return a+b}),V.then(Lp,V.optional(V.preceded(bm,cl(/[0-9]*/))),function(a,b){return a+(null!==b?\".\"+b:\"\")})]),Yk(V.or([im,jm]),V.optional(V.or([dm,em])),Lp,function(a,b,c){return a+(b?b:\"\")+c}),function(a,b){return[\"doubleConstantExpr\",[\"value\",a+b]]}),Np=V.or([V.map(V.preceded(bm,Lp),function(a){return[\"decimalConstantExpr\",[\"value\",\".\"+a]]}),V.then(V.followed(Lp,bm),V.optional(Lp),function(a,b){return[\"decimalConstantExpr\",\n[\"value\",a+\".\"+(null!==b?b:\"\")]]})]),Op=V.map(Lp,function(a){return[\"integerConstantExpr\",[\"value\",a]]}),Pp=V.followed(V.or([Mp,Np,Op]),V.peek(V.not(cl(/[a-zA-Z]/),[\"no alphabetical characters after numeric literal\"]))),Qp=V.map(V.followed(bm,V.peek(V.not(bm,[\"context item should not be followed by another .\"]))),function(){return[\"contextItemExpr\"]}),Rp=V.or([pn,Em,tn,to,Dm,yo,Bm,Zm,po,Cm,uo,xm,un,vo,Fm,ao,sn,Mn]),Sp=al(bl([Pl],\"argumentPlaceholder\")),Tp=V.or([Pl,Kl,dm]),Up=V.preceded(V.peek(V.not(cl(/[{}<&]/),\n[\"elementContentChar cannot be {, }, <, or &\"])),gp),Vp=V.map(V.delimited(ul,V.star(V.preceded(V.peek(V.not(vl,['CDataSection content may not contain \"]]\\x3e\"'])),gp)),vl),function(a){return[\"CDataSection\",a.join(\"\")]}),Wp=V.preceded(V.peek(V.not(cl(/[\"{}<&]/),['quotAttrValueContentChar cannot be \", {, }, <, or &'])),gp),Xp=V.preceded(V.peek(V.not(cl(/['{}<&]/),[\"aposAttrValueContentChar cannot be ', {, }, <, or &\"])),gp),Yp=V.map(V.star(V.or([V.preceded(V.peek(V.not(em,[])),gp),V.map(X([em,V.peek(V.not(em,\n[]))],gp),function(a){return\"-\"+a})])),function(a){return a.join(\"\")}),Zp=V.map(V.delimited(yl,Yp,zl),function(a){return[\"computedCommentConstructor\",[\"argExpr\",[\"stringConstantExpr\",[\"value\",a]]]]}),$p=V.preceded(V.peek(V.not(Yk(V.or([qm,pm]),V.or([nm,mm]),V.or([lm,km]),function(){return[]}),[])),rp),aq=V.map(V.star(V.preceded(V.peek(V.not(Bl,[])),gp)),function(a){return a.join(\"\")}),bq=V.then(V.preceded(Al,$p),V.followed(V.optional(V.preceded(kp,aq)),Bl),function(a,b){return[\"computedPIConstructor\",\n[\"piTarget\",a],[\"piValueExpr\",[\"stringConstantExpr\",[\"value\",b]]]]}),cq=V.map(gm,function(){return[\"stepExpr\",[\"xpathAxis\",\"descendant-or-self\"],[\"anyKindTest\"]]}),dq=V.or([vn,wn]),eq=V.map(V.star(V.followed(gp,V.peek(V.not(hl,[\"Pragma contents should not contain '#)'\"])))),function(a){return a.join(\"\")}),fq=V.map(V.followed(V.or([Qm,Rm,Sm,Tm,Um,Vm]),Ap),function(a){return a+\"Op\"}),gq=V.or([V.followed(bl([Km],\"isOp\"),Ap),bl([Wl],\"nodeBeforeOp\"),bl([Zl],\"nodeAfterOp\")]),hq=V.or([bl([Tl],\"equalOp\"),\nbl([Ul],\"notEqualOp\"),bl([Xl],\"lessThanOrEqualOp\"),bl([Vl],\"lessThanOp\"),bl([$l],\"greaterThanOrEqualOp\"),bl([Yl],\"greaterThanOp\")]),iq=V.map(eo,function(){return[\"annotation\",[\"annotationName\",\"updating\"]]}),jq=V.or([Dn,En]),kq=V.or([Fn,Gn]),lq=V.or([Lo,Mo,No,Oo,Po,Ol,Qo,Ro,So,To,Uo]),mq=V.map(X([zn,Z,Bn,Z],V.or([Dn,Cn])),function(a){return[\"boundarySpaceDecl\",a]}),nq=V.map(X([zn,Z,jo,Z],V.or([Dn,Cn])),function(a){return[\"constructionDecl\",a]}),oq=V.map(X([zn,Z,ko,Z],V.or([lo,mo])),function(a){return[\"orderingModeDecl\",\na]}),pq=V.map(X([zn,Z,An,Z,mn,Z,cn,Z],V.or([Hn,In])),function(a){return[\"emptyOrderDecl\",a]}),qq=V.then(X([zn,Z,Jn,Z],jq),X([Y,am,Y],kq),function(a,b){return[\"copyNamespacesDecl\",[\"preserveMode\",a],[\"inheritMode\",b]]});function rq(a){switch(a[0]){case \"constantExpr\":case \"varRef\":case \"contextItemExpr\":case \"functionCallExpr\":case \"sequenceExpr\":case \"elementConstructor\":case \"computedElementConstructor\":case \"computedAttributeConstructor\":case \"computedDocumentConstructor\":case \"computedTextConstructor\":case \"computedCommentConstructor\":case \"computedNamespaceConstructor\":case \"computedPIConstructor\":case \"orderedExpr\":case \"unorderedExpr\":case \"namedFunctionRef\":case \"inlineFunctionExpr\":case \"dynamicFunctionInvocationExpr\":case \"mapConstructor\":case \"arrayConstructor\":case \"stringConstructor\":case \"unaryLookup\":return a}return[\"sequenceExpr\",\na]}function sq(a){if(!(1<=a&&55295>=a||57344<=a&&65533>=a||65536<=a&&1114111>=a))throw Error(\"XQST0090: The character reference \"+a+\" (\"+a.toString(16)+\") does not reference a valid codePoint.\");}\nfunction tq(a){return a.replace(/(&[^;]+);/g,function(b){if(/^&#x/.test(b))return b=parseInt(b.slice(3,-1),16),sq(b),String.fromCodePoint(b);if(/^&#/.test(b))return b=parseInt(b.slice(2,-1),10),sq(b),String.fromCodePoint(b);switch(b){case \"<\":return\"<\";case \">\":return\">\";case \"&\":return\"&\";case \""\":return String.fromCharCode(34);case \"'\":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: \"'+b+'\"');})}\nfunction uq(a,b,c){if(!a.length)return[];for(var d=[a[0]],e=1;e=b+c)return z;k=e.next(k);d++;return k}},f)}function Sq(a){return a.map(function(b){return C(b.type,19)?Kd(b,3):b})}\nfunction Tq(a){a=Sq(a);if(a.some(function(b){return Number.isNaN(b.value)}))return[y(NaN,3)];a=Ni(a);if(!a)throw Error(\"FORG0006: Incompatible types to be converted to a common type\");return a}\nfunction Uq(a,b,c,d,e,f){return $b([e,f],function(g){var k=t(g);g=k.next().value;k=k.next().value;if(Infinity===g.value)return E.empty();if(-Infinity===g.value)return k&&Infinity===k.value?E.empty():d;if(k){if(isNaN(k.value))return E.empty();Infinity===k.value&&(k=null)}return isNaN(g.value)?E.empty():Rq(d,Math.round(g.value),k?Math.round(k.value):null)})}\nfunction Vq(a,b,c,d,e){if(d.G())return e;a=Sq(d.N());a=Ni(a);if(!a)throw Error(\"FORG0006: Incompatible types to be converted to a common type\");if(!a.every(function(f){return C(f.type,2)}))throw Error(\"FORG0006: items passed to fn:sum are not all numeric.\");b=a.reduce(function(f,g){return f+g.value},0);return a.every(function(f){return C(f.type,5)})?E.o(y(b,5)):a.every(function(f){return C(f.type,3)})?E.o(y(b,3)):a.every(function(f){return C(f.type,4)})?E.o(y(b,4)):E.o(y(b,6))};var Wq=[].concat(Mf,[{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"boolean\",l:[{type:59,g:2}],i:{type:0,g:3},m:function(a,b,c,d){return d.getEffectiveBooleanValue()?E.ca():E.X()}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"true\",l:[],i:{type:0,g:3},m:function(){return E.ca()}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"not\",l:[{type:59,g:2}],i:{type:0,g:3},m:function(a,b,c,d){return!1===d.getEffectiveBooleanValue()?E.ca():E.X()}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\nlocalName:\"false\",l:[],i:{type:0,g:3},m:function(){return E.X()}}],[{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"last\",l:[],i:{type:5,g:3},m:function(a){if(null===a.M)throw Error(\"XPDY0002: The fn:last() function depends on dynamic context, which is absent.\");var b=!1;return E.create({next:function(){if(b)return z;var c=a.Ga.Na();b=!0;return B(y(c,5))}},1)}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"position\",l:[],i:{type:5,g:3},m:function(a){if(null===\na.M)throw Error(\"XPDY0002: The fn:position() function depends on dynamic context, which is absent.\");return E.o(y(a.Ja+1,5))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"current-dateTime\",l:[],i:{type:10,g:3},m:function(a){return E.o(y(Ic(a),10))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"current-date\",l:[],i:{type:7,g:3},m:function(a){return E.o(y(rc(Ic(a),7),7))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"current-time\",l:[],\ni:{type:8,g:3},m:function(a){return E.o(y(rc(Ic(a),8),8))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"implicit-timezone\",l:[],i:{type:17,g:3},m:function(a){return E.o(y(Jc(a),17))}}],Nf,Vf,Xf,[{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"years-from-duration\",l:[{type:18,g:0}],i:{type:5,g:0},m:function(a,b,c,d){return d.G()?d:E.o(y(d.first().value.cb(),5))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"months-from-duration\",l:[{type:18,\ng:0}],i:{type:5,g:0},m:function(a,b,c,d){return d.G()?d:E.o(y(d.first().value.$a(),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(a,b,c,d){return d.G()?d:E.o(y(d.first().value.Za(),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(a,b,c,d){return d.G()?d:E.o(y(d.first().value.getHours(),5))}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\nlocalName:\"minutes-from-duration\",l:[{type:18,g:0}],i:{type:5,g:0},m:function(a,b,c,d){return d.G()?d:E.o(y(d.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(a,b,c,d){return d.G()?d:E.o(y(d.first().value.getSeconds(),4))}}],Zf,[{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:Nq},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\nlocalName:\"id\",l:[{type:1,g:2}],i:{type:54,g:2},m:function(a,b,c,d){return Nq(a,b,c,d,E.o(a.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:Oq},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"idref\",l:[{type:1,g:2}],i:{type:53,g:2},m:function(a,b,c,d){return Oq(a,b,c,d,E.o(a.M))}}],[{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",localName:\"parse-json\",l:[{type:1,g:3}],i:{type:59,g:0},m:function(a,\nb,c,d){try{var e=JSON.parse(d.first().value)}catch(f){throw Error(\"FOJS0001: parsed JSON string contains illegal JSON.\");}return Pq(e)}}],[{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(a,b,c,d,e){return $b([d,e],function(f){f=t(f);var g=f.next().value,k=f.next().value;return g.h.some(function(l){return ac(l.key,k)})?E.ca():E.X()})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",localName:\"entry\",\nl:[{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},m:function(a,b,c,d,e){return d.map(function(f){return new cc([{key:f,value:rb(e)}])})}},{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(a,b,c,d,e){return $b([d,e],function(f){f=t(f);var g=f.next().value,k=f.next().value;return Mc(g.h.map(function(l){return k.value.call(void 0,a,b,c,E.o(l.key),l.value())}))})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",\nlocalName:\"get\",l:[{type:61,g:3},{type:46,g:3}],i:{type:59,g:2},m:bc},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",localName:\"keys\",l:[{type:61,g:3}],i:{type:46,g:2},m:function(a,b,c,d){return $b([d],function(e){e=t(e).next().value;return E.create(e.h.map(function(f){return f.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:Qq},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",localName:\"merge\",\nl:[{type:61,g:2}],i:{type:61,g:3},m:function(a,b,c,d){return Qq(a,b,c,d,E.o(new cc([{key:y(\"duplicates\",1),value:function(){return E.o(y(\"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(a,b,c,d,e,f){return $b([d,e],function(g){g=t(g);var k=g.next().value,l=g.next().value;g=k.h.concat();k=g.findIndex(function(n){return ac(n.key,l)});0<=k?g.splice(k,1,{key:l,value:rb(f)}):g.push({key:l,\nvalue:rb(f)});return E.o(new cc(g))})}},{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(a,b,c,d,e){return $b([d],function(f){var g=t(f).next().value.h.concat();return e.L(function(k){k.forEach(function(l){var n=g.findIndex(function(q){return ac(q.key,l)});0<=n&&g.splice(n,1)});return E.o(new cc(g))})})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/map\",localName:\"size\",l:[{type:61,g:3}],i:{type:5,g:3},\nm:function(a,b,c,d){return d.map(function(e){return y(e.h.length,5)})}}],[{namespaceURI:\"http://www.w3.org/2005/xpath-functions/math\",localName:\"pi\",l:[],i:{type:3,g:3},m:function(){return E.o(y(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(a,b,c,d){return d.map(function(e){return y(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,\ng:0},m:function(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(Math.log10(e.value),3)})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/math\",\nlocalName:\"pow\",l:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},m:function(a,b,c,d,e){return e.L(function(f){var g=t(f).next().value;return d.map(function(k){return 1!==Math.abs(k.value)||Number.isFinite(g.value)?y(Math.pow(k.value,g.value),3):y(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(a,b,c,d){return d.map(function(e){return y(Math.sqrt(e.value),3)})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions/math\",\nlocalName:\"sin\",l:[{type:3,g:0}],i:{type:3,g:0},m:function(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(Math.tan(e.value),3)})}},\n{namespaceURI:\"http://www.w3.org/2005/xpath-functions/math\",localName:\"asin\",l:[{type:3,g:0}],i:{type:3,g:0},m:function(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(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(a,b,\nc,d){return d.map(function(e){return y(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(a,b,c,d,e){return e.L(function(f){var g=t(f).next().value;return d.map(function(k){return y(Math.atan2(k.value,g.value),3)})})}}],Fe,ie,[{namespaceURI:\"http://fontoxpath/operators\",localName:\"to\",l:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},m:function(a,b,c,d,e){a=d.first();e=e.first();if(null===a||null===\ne)return E.empty();var f=a.value;e=e.value;return f>e?E.empty():E.create({next:function(){return B(y(f++,5))}},e-f+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(a,b,c,d,e){return $b([d,e],function(f){var g=t(f);f=g.next().value;g=g.next().value.value;if(!Yc(g,23))throw Error(\"FOCA0002: The provided QName is invalid.\");f=f?f.value||null:null;if(null===f&&g.includes(\":\"))throw Error(\"FOCA0002: The URI of a QName may not be empty if a prefix is provided.\");\nif(d.G())return E.o(y(new Ab(\"\",null,g),23));if(!g.includes(\":\"))return E.o(y(new Ab(\"\",f,g),23));var k=t(g.split(\":\"));g=k.next().value;k=k.next().value;return E.o(y(new Ab(g,f,k),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(a,b,c,d){return $b([d],function(e){e=t(e).next().value;if(null===e)return E.empty();e=e.value;return e.prefix?E.o(y(e.prefix,24)):E.empty()})}},{namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\nlocalName:\"local-name-from-QName\",l:[{type:23,g:0}],i:{type:24,g:0},m:function(a,b,c,d){return d.map(function(e){return y(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(a,b,c,d){return d.map(function(e){return y(e.value.namespaceURI||\"\",20)})}}],[{l:[{type:59,g:2}],m:function(a,b,c,d){return d.$({empty:function(){return E.ca()},multiple:function(){return E.X()},o:function(){return E.X()}})},\nlocalName:\"empty\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:0,g:3}},{l:[{type:59,g:2}],m:function(a,b,c,d){return d.$({empty:function(){return E.X()},multiple:function(){return E.ca()},o:function(){return E.ca()}})},localName:\"exists\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:0,g:3}},{l:[{type:59,g:2}],m:function(a,b,c,d){return Rq(d,1,1)},localName:\"head\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:0}},{l:[{type:59,g:2}],m:function(a,\nb,c,d){return Rq(d,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(a,b,c,d,e,f){if(d.G())return f;if(f.G())return d;a=d.N();e=e.first().value-1;0>e?e=0:e>a.length&&(e=a.length);b=a.slice(e);return E.create(a.slice(0,e).concat(f.N(),b))},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(a,b,c,d,e){a=e.first().value;\nd=d.N();if(!d.length||1>a||a>d.length)return E.create(d);d.splice(a-1,1);return E.create(d)},localName:\"remove\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(a,b,c,d){return d.L(function(e){return E.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(a,b,c,d,e){return Uq(a,b,c,d,e,E.empty())},localName:\"subsequence\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\ni:{type:59,g:2}},{l:[{type:59,g:2},{type:3,g:3},{type:3,g:3}],m:Uq,localName:\"subsequence\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(a,b,c,d){return d},localName:\"unordered\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:2}},{l:[{type:46,g:2}],m:function(a,b,c,d){var e=Vc(d,b).N();return E.create(e).filter(function(f,g){return e.slice(0,g).every(function(k){return!Ie(f,k)})})},localName:\"distinct-values\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\ni:{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(a,b,c,d,e){return e.L(function(f){var g=t(f).next().value;return Vc(d,b).map(function(k,l){return si(\"eqOp\",k.type,g.type)(k,g,a)?y(l+1,5):y(-1,5)}).filter(function(k){return-1!==k.value})})},localName:\"index-of\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\ni:{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(a,b,c,d,e){var f=!1,g=Le(a,b,c,d,e);return E.create({next:function(){if(f)return z;var k=g.next(0);if(k.done)return k;f=!0;return B(y(k.value,0))}})},localName:\"deep-equal\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:0,\ng: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(a,b,c,d){var e=!1;return E.create({next:function(){if(e)return z;var f=d.Na();e=!0;return B(y(f,5))}})},localName:\"count\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:5,g:3}},{l:[{type:46,g:2}],m:function(a,b,c,d){if(d.G())return d;a=Sq(d.N());\na=Ni(a);if(!a)throw Error(\"FORG0006: Incompatible types to be converted to a common type\");if(!a.every(function(e){return C(e.type,2)}))throw Error(\"FORG0006: items passed to fn:avg are not all numeric.\");b=a.reduce(function(e,f){return e+f.value},0)/a.length;return a.every(function(e){return C(e.type,5)||C(e.type,3)})?E.o(y(b,3)):a.every(function(e){return C(e.type,4)})?E.o(y(b,4)):E.o(y(b,6))},localName:\"avg\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:46,g:0}},{l:[{type:46,g:2}],\nm:function(a,b,c,d){if(d.G())return d;a=Tq(d.N());return E.o(a.reduce(function(e,f){return e.value\nf.value?f: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(a,b,c,d){return Vq(a,b,c,d,E.o(y(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:Vq,localName:\"sum\",\nnamespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:46,g:0}},{l:[{type:59,g:2}],m:function(a,b,c,d){if(!d.G()&&!d.ya())throw Error(\"FORG0003: The argument passed to fn:zero-or-one contained more than one item.\");return d},localName:\"zero-or-one\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:0}},{l:[{type:59,g:2}],m:function(a,b,c,d){if(d.G())throw Error(\"FORG0004: The argument passed to fn:one-or-more was empty.\");return d},localName:\"one-or-more\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",\ni:{type:59,g:1}},{l:[{type:59,g:2}],m:function(a,b,c,d){if(!d.ya())throw Error(\"FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.\");return d},localName:\"exactly-one\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:3}},{l:[{type:59,g:2},{type:60,g:3}],m:function(a,b,c,d,e){if(d.G())return d;var f=e.first(),g=f.s;if(1!==g.length)throw Error(\"XPTY0004: signature of function passed to fn:filter is incompatible.\");return d.filter(function(k){k=\nae(g[0],E.o(k),b,\"fn:filter\",!1);k=f.value.call(void 0,a,b,c,k);if(!k.ya()||!C(k.first().type,0))throw Error(\"XPTY0004: signature of function passed to fn:filter is incompatible.\");return k.first().value})},localName:\"filter\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:2}},{l:[{type:59,g:2},{type:60,g:3}],m:function(a,b,c,d,e){if(d.G())return d;var f=e.first(),g=f.s;if(1!==g.length)throw Error(\"XPTY0004: signature of function passed to fn:for-each is incompatible.\");var k=d.value,\nl;return E.create({next:function(n){for(;;){if(!l){var q=k.next(0);if(q.done)return q;q=ae(g[0],E.o(q.value),b,\"fn:for-each\",!1);l=f.value.call(void 0,a,b,c,q).value}q=l.next(n);if(!q.done)return q;l=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(a,b,c,d,e,f){if(d.G())return d;var g=f.first(),k=g.s;if(2!==k.length)throw Error(\"XPTY0004: signature of function passed to fn:fold-left is incompatible.\");\nreturn d.L(function(l){return l.reduce(function(n,q){n=ae(k[0],n,b,\"fn:fold-left\",!1);q=ae(k[1],E.o(q),b,\"fn:fold-left\",!1);return g.value.call(void 0,a,b,c,n,q)},e)})},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(a,b,c,d,e,f){if(d.G())return d;var g=f.first(),k=g.s;if(2!==k.length)throw Error(\"XPTY0004: signature of function passed to fn:fold-right is incompatible.\");return d.L(function(l){return l.reduceRight(function(n,\nq){n=ae(k[0],n,b,\"fn:fold-right\",!1);q=ae(k[1],E.o(q),b,\"fn:fold-right\",!1);return g.value.call(void 0,a,b,c,q,n)},e)})},localName:\"fold-right\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:59,g:2}},{l:[{type:59,g:2}],m:function(a,b,c,d){if(!b.j)throw Error(\"serialize() called but no xmlSerializer set in execution parameters.\");a=d.N();if(!a.every(function(e){return C(e.type,53)}))throw Error(\"Expected argument to fn:serialize to resolve to a sequence of Nodes.\");return E.o(y(a.map(function(e){return b.j.serializeToString(kj(e.value,\nb,!1))}),1))},localName:\"serialize\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:1,g:3}}],ue,[{l:[{type:59,g:3},{type:61,g:3}],m:function(a,b,c,d,e){var f,g;return E.create({next:function(){if(!f){var k=Lq(d,e,c,b);f=k.Gc;g=k.Dc}try{return f.next(0)}catch(l){bg(g.value,l)}}})},localName:\"evaluate\",namespaceURI:\"http://fontoxml.com/fontoxpath\",i:{type:59,g:2}},{l:[],m:function(){return E.o(y(\"undefined\"===typeof VERSION?\"devbuild\":VERSION,1))},localName:\"version\",namespaceURI:\"http://fontoxml.com/fontoxpath\",\ni:{type:1,g:3}}],[{l:[{type:23,g:3},{type:5,g:3}],m:function(a,b,c,d,e){return $b([d,e],function(f){var g=t(f);f=g.next().value;g=g.next().value;var k=c.za(f.value.namespaceURI,f.value.localName,g.value);if(null===k)return E.empty();f=new Bb({l:k.l,arity:g.value,localName:f.value.localName,namespaceURI:f.value.namespaceURI,i:k.i,value:k.m});return E.o(f)})},localName:\"function-lookup\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{g:0,type:60}},{l:[{type:60,g:3}],m:function(a,b,c,d){return $b([d],\nfunction(e){e=t(e).next().value;return e.Pa()?E.empty():E.o(y(new Ab(\"\",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(a,b,c,d){return $b([d],function(e){e=t(e).next().value;return E.o(y(e.A,5))})},localName:\"function-arity\",namespaceURI:\"http://www.w3.org/2005/xpath-functions\",i:{type:5,g:3}}]);function Xq(a){this.h=a}h=Xq.prototype;h.createAttributeNS=function(a,b){return this.h.createAttributeNS(a,b)};h.createCDATASection=function(a){return this.h.createCDATASection(a)};h.createComment=function(a){return this.h.createComment(a)};h.createDocument=function(){return this.h.createDocument()};h.createElementNS=function(a,b){return this.h.createElementNS(a,b)};h.createProcessingInstruction=function(a,b){return this.h.createProcessingInstruction(a,b)};h.createTextNode=function(a){return this.h.createTextNode(a)};var Yq=Symbol(\"IS_XPATH_VALUE_SYMBOL\");function Zq(a){return function(b,c){b=Dc(new Mb(null===c?new Gb:c),b,xb(a));c={};return c[Yq]=!0,c.Db=b,c}};Wq.forEach(function(a){ig(a.namespaceURI,a.localName,a.l,a.i,a.m)});function $q(a){return a&&\"object\"===typeof a&&\"lookupNamespaceURI\"in a?function(b){return a.lookupNamespaceURI(b||null)}:function(){return null}}function ar(a){return function(b){var c=b.localName;return b.prefix?null:{namespaceURI:a,localName:c}}}\nfunction br(a,b,c,d,e,f){var g,k,l,n,q,u,v;if(null===d||void 0===d)d=d||{};e?(g=e.logger||{trace:console.log.bind(console)},k=e.documentWriter,l=e.moduleImports,n=e.namespaceResolver,q=e.functionNameResolver,u=e.nodesFactory,v=e.xmlSerializer):(g={trace:console.log.bind(console)},l={},n=null,u=null,k=null,v=null,q=void 0);var A=new Mb(null===c?new Gb:c);c=l||Object.create(null);l=void 0===e.defaultFunctionNamespaceURI?\"http://www.w3.org/2005/xpath-functions\":e.defaultFunctionNamespaceURI;var G=Kq(a,\nf,n||$q(b),d,c,l,q||ar(l));a=b?Ec(A,b):E.empty();b=!u&&f.aa?new ef(b):new Xq(u);k=k?new Jb(k):Ib;u=Object.keys(d).reduce(function(fa,ea){var Ea=d[ea];fa[\"Q{}\"+ea+\"[0]\"]=Ea&&\"object\"===typeof Ea&&Yq in Ea?function(){return E.create(Ea.Db)}:function(){return Ec(A,d[ea])};return fa},Object.create(null));n={};q=t(Object.keys(G.ia.Da));for(c=q.next();!c.done;n={Wa:n.Wa},c=q.next())n.Wa=c.value,u[n.Wa]||(u[n.Wa]=function(fa){return function(){return(0,G.ia.Da[fa.Wa])(H,L)}}(n));var H=new Fc({M:a.first(),\nJa:0,Ga:a,Ea:u});var L=new Lc(f.debug,f.Ha,A,b,k,e.currentContext,g,v);return{xb:H,zb:L,da:G.da}};function cr(a,b){var c={},d=0,e=!1,f=null;return{next:function(){if(e)return z;for(var g={};d {\\n\\t\\t\\t\\t\\tconst result = \"+a+\".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.\");\n}}var cu={DONE_TOKEN:z,getEffectiveBooleanValue:lb,isSubtypeOf:C,ready:B};var du={qc:\"pathExpr\",Ob:\"andOp\",pc:\"orOp\",sc:\"stringConstantExpr\",Sb:\"equalOp\",nc:\"notEqualOp\",dc:\"lessThanOrEqualOp\",cc:\"lessThanOp\",Yb:\"greaterThanOrEqualOp\",Xb:\"greaterThanOp\",Tb:\"eqOp\",jc:\"neOp\",fc:\"ltOp\",ec:\"leOp\",Zb:\"gtOp\",Wb:\"geOp\",ac:\"isOp\",mc:\"nodeBeforeOp\",lc:\"nodeAfterOp\",Vb:\"functionCallExpr\"},eu=Object.values(du);\nfunction fu(a,b,c,d,e){a=M(a,c);a=M(a,eu);if(!a)return[au(\"Unsupported: a base expression used with an operand.\"),null];b+=c;c=t(d.yb(a,b,d));d=c.next().value;c=c.next().value;return d.isAstAccepted?0===e?[bu(b,d.code,d.xa),null]:[Dr(b,d.xa,[d.code]),c]:[d,null]};function gu(a,b,c){4===b&&(a+=\".next().value\");47===c&&(a=\"(function () { const attr = \"+a+\"; return attr ? domFacade.getData(attr) : null})()\");return a}\nfunction hu(a,b,c,d,e){var f=O(M(a,\"firstOperand\")[1],\"type\");a=O(M(a,\"secondOperand\")[1],\"type\");if(!f||!a)return au(\"Left or right type of compare are not found, annotation failed.\");var g=[47,1];if(!g.includes(f.type)||!g.includes(a.type))return au(\"Unsupported types in compare: [\"+tb[f.type]+\", \"+tb[a.type]+\"]\");if(!c.isAstAccepted)return c;if(!d.isAstAccepted)return d;if(!f||!a)return au(\"Operands in compare weren't annotated\");g=new Map([[\"eqOp\",\"===\"],[\"neOp\",\"!==\"]]);if(!g.has(b))return au(b+\n\" not yet implemented\");b=g.get(b);g=Cr(c.code,c.xa);var k=Cr(d.code,d.xa);return Dr(\"function \"+e+\"(contextItem) {\\n\\t\\t\\t\\t\"+c.ta.join(\"\\n\")+\"\\n\\t\\t\\t \\t\"+d.ta.join(\"\\n\")+\"\\n\\t \\t \\treturn \"+gu(g[0],g[1].type,f.type)+\" \"+b+\" \"+gu(k[0],k[1].type,a.type)+\";\\n\\t\\t}\",{type:3,i:{type:0}})}var iu={},ju=(iu.equalOp=\"eqOp\",iu.notEqualOp=\"neOp\",iu.lessThanOrEqualOp=\"leOp\",iu.lessThanOp=\"ltOp\",iu.greaterThanOrEqualOp=\"geOp\",iu.greaterThanOp=\"gtOp\",iu);var mu={\"local-name\":ku,name:lu};function nu(a){return\"(\"+a+\".localName || \"+a+\".target || '')\"}function ou(a){return\"(((\"+a+\".prefix || '').length !== 0 ? \"+a+\".prefix + ':' : '')\\n\\t\\t+ (\"+a+\".localName || \"+a+\".target || ''))\"}\nfunction pu(a,b,c,d,e){a=M(a,\"arguments\");if(1===a.length)b=\"function \"+b+\"(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 \"+d(\"contextItem\")+\";\\n\\t\\t}\";else if(2===a.length)if(e=a[1],c=t(c.yb(e,\"arg\",c)),a=c.next().value,c.next(),c=a.isAstAccepted?Dr(\"arg\",a.xa,[a.code]):a,\"contextItemExpr\"===e[0])b=\"function \"+b+\"(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 \"+\nd(\"contextItem\")+\";\\n\\t\\t\\t}\";else{if(!c.isAstAccepted)return c;b=\"function \"+b+\"(contextItem) {\\n\\t\\t\\t\\t\"+c.ta+\"\\n\\t\\t\\t\\tconst value = \"+Cr(c.code,c.xa)[0]+';\\n\\t\\t\\t\\tconst childElement = value.next().value;\\n\\t\\t\\t\\treturn (value.done ? \"\" : '+d(\"childElement\")+\");\\n\\t\\t\\t}\"}else return au(\"Incorrect arg count for \"+e+\" function\");return Dr(b,{type:3,i:{type:0}})}function lu(a,b,c){return pu(a,b,c,ou,\"name()\")}function ku(a,b,c){return pu(a,b,c,nu,\"local-name()\")};function qu(a){return JSON.stringify(a).replace(/\\u2028/g,\"\\\\u2028\").replace(/\\u2029/g,\"\\\\u2029\")};function ru(a,b,c,d){var e=t(fu(a,b,\"firstOperand\",c,0)),f=e.next().value;e=e.next().value;if(!f.isAstAccepted)return[f,null];c=t(fu(a,b,\"secondOperand\",c,0));a=c.next().value;c=c.next().value;return a.isAstAccepted?[Dr(\"\\n\\tfunction \"+b+\"(contextItem) {\\n\\t\\t\"+f.ta.join(\"\\n\")+\"\\n\\t\\t\"+a.ta.join(\"\\n\")+\"\\n\\t\\treturn \"+f.code+\" \"+d+\" \"+a.code+\";\\n\\t}\\n\\t\",{type:3,i:{type:0}}),\"&&\"===d?Ah(e,c):e||c]:[a,null]};function su(a){for(var b=[],c=0;c {\\n\\t\\t\\t\"+a.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}}),e]:[a,null];case du.Ob:return ru(a,b,c,\"&&\");case du.pc:return ru(a,b,c,\"||\");case du.sc:return a=M(a,\"value\")[1]||\"\",a=qu(a),[Dr(\"const \"+b+\" = \"+a+\";\",{type:1}),null];case du.Sb:case du.nc:case du.dc:case du.cc:case du.Yb:case du.Xb:case du.Tb:case du.jc:case du.fc:case du.ec:case du.Zb:case du.Wb:case du.ac:case du.mc:case du.lc:a:{var f=\nt(fu(a,b,\"firstOperand\",c));e=f.next().value;f.next();if(e.isAstAccepted)if(f=t(fu(a,b,\"secondOperand\",c)),c=f.next().value,f.next(),c.isAstAccepted)switch(d){case \"eqOp\":case \"neOp\":case \"ltOp\":case \"leOp\":case \"gtOp\":case \"geOp\":case \"isOp\":b=hu(a,d,e,c,b);break a;case \"equalOp\":case \"notEqualOp\":case \"lessThanOrEqualOp\":case \"lessThanOp\":case \"greaterThanOrEqualOp\":case \"greaterThanOp\":f=O(a,\"type\");var g=O(a,\"type\");b=f&&g?3===f.g&&3===g.g?hu(a,ju[d],e,c,b):au(\"generalCompare with sequences is still in development\"):\nau(\"types of compare are not known\");break a;default:b=au(\"Unsupported compare type\")}else b=c;else b=e}return[b,null];case du.Vb:return d=N(M(a,\"functionName\")),[void 0!==mu[d]?mu[d](a,b,c):au(\"Unsupported function: \"+d),null];default:return[au(\"Unsupported: the base expression '\"+d+\"'.\"),null]}};function Bu(a,b,c){switch(a){case 9:c=t(Cr(\"compiledXPathExpression\",b));a=c.next().value;if(4!==c.next().value.type)throw Error(\"Trying access generated code as an iterator while this is not the case.\");return Dr(\"\\n\\tconst firstResult = \"+a+\".next();\\n\\tif (!firstResult.done) {\\n\\t\\treturn firstResult.value\\n\\t}\\n\\treturn null;\\n\\t\",{type:2});case 7:return c=t(Cr(\"compiledXPathExpression\",b)),a=c.next().value,4!==c.next().value.type?au(\"Return type was not an iterator\"):Dr(\"\\n\\tconst nodes = [];\\n\\tfor (const node of \"+\na+\") {\\n\\t\\tnodes.push(node);\\n\\t}\\n\\treturn nodes;\\n\\t\",{type:2});case 3:return c=bu(\"compiledXPathExpression\",\"\",b),c.isAstAccepted?Dr(\"return \"+c.code+\";\",{type:2}):c;case 2:return void 0===c?c=au(\"Full AST wasn't annotated so we cannot correctly emit a string return\"):C(c,1)||C(c,47)?(b=t(Cr(\"compiledXPathExpression\",b)),a=b.next().value,b=b.next().value,c=Dr(\"return \"+gu(a,b.type,c)+\" || '';\",{type:2})):c=au(\"Not implemented: returning anything but strings and attributes from codegen\"),c;default:return au(\"Unsupported: the return type '\"+\na+\"'.\")}}\nfunction Cu(a,b,c){var d=M(a,\"mainModule\");if(!d)return au(\"Unsupported: Can not execute a library module.\");if(M(d,\"prolog\"))return au(\"Unsupported: XQuery.\");d=P(d,[\"queryBody\",\"*\"]);c.yb=Au;var e=t(Au(d,\"compiledXPathExpression\",c));c=e.next().value;e.next();if(!1===c.isAstAccepted)return c;e=c.ta?c.ta.join(\"\\n\"):\"\";d=O(d,\"type\");b=Bu(b,c.xa,d?d.type:void 0);if(!1===b.isAstAccepted)return b;b=e+c.code+b.code;c=\"\\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;\";Du(a)&&\n(c+='\\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');return{code:c+(b+\"}\\n//# sourceURL=generated.js\"),isAstAccepted:!0}}function Du(a){var b=Q(a,\"*\");if(\"pathExpr\"===a[0])return!0;a=t(b);for(b=a.next();!b.done;b=a.next())if(Du(b.value))return!0;return!1};function Eu(a,b,c){c=c||{};b=b||0;\"string\"===typeof a?(a=Wk(a),a=Eq(a,{aa:\"XQuery3.1\"===c.language||\"XQueryUpdate3.1\"===c.language,debug:!1})):a=Sk(a);var d=M(a,\"mainModule\");if(!d)return au(\"Unsupported: XQuery Library modules are not supported.\");if(M(d,\"prolog\"))return au(\"Unsupported: XQuery Prologs are not supported.\");d={ba:c.namespaceResolver||$q(null)};c=new th(new xg(new lg(d.ba,{},void 0===c.defaultFunctionNamespaceURI?\"http://www.w3.org/2005/xpath-functions\":c.defaultFunctionNamespaceURI,\nc.functionNameResolver||ar(\"http://www.w3.org/2005/xpath-functions\"))));T(a,c);return Cu(a,b,d)};function Fu(a,b,c){c=c?c:new Gb;return a()(b,c,cu)};var Gu={},Hu=(Gu[\"http://www.w3.org/2005/XQueryX\"]=\"xqx\",Gu[\"http://www.w3.org/2007/xquery-update-10\"]=\"xquf\",Gu[\"http://fontoxml.com/fontoxpath\"]=\"x\",Gu);\nfunction Iu(a,b){switch(a){case \"copySource\":case \"insertAfter\":case \"insertAsFirst\":case \"insertAsLast\":case \"insertBefore\":case \"insertInto\":case \"modifyExpr\":case \"newNameExpr\":case \"replacementExpr\":case \"replaceValue\":case \"returnExpr\":case \"sourceExpr\":case \"targetExpr\":case \"transformCopies\":case \"transformCopy\":return{localName:a,rb:b||\"http://www.w3.org/2005/XQueryX\"};case \"deleteExpr\":case \"insertExpr\":case \"renameExpr\":case \"replaceExpr\":case \"transformExpr\":return{localName:a,rb:\"http://www.w3.org/2007/xquery-update-10\"};\ncase \"x:stackTrace\":return{localName:\"stackTrace\",rb:\"http://fontoxml.com/fontoxpath\"};default:return{localName:a,rb:\"http://www.w3.org/2005/XQueryX\"}}}\nfunction Ju(a,b,c,d,e){if(\"string\"===typeof c)return 0===c.length?null:b.createTextNode(c);if(!Array.isArray(c))throw new TypeError(\"JsonML element should be an array or string\");var f=Iu(c[0],d);d=f.rb;f=b.createElementNS(d,Hu[d]+\":\"+f.localName);var g=c[1],k=1;if(\"object\"===typeof g&&!Array.isArray(g)){if(null!==g){k=t(Object.keys(g));for(var l=k.next();!l.done;l=k.next()){l=l.value;var n=g[l];null!==n&&(\"type\"===l?void 0!==n&&a.setAttributeNS(f,d,\"fontoxpath:\"+l,vb(n)):e&&\"prefix\"===l&&\"\"===n||\na.setAttributeNS(f,d,Hu[d]+\":\"+l,n))}}k=2}g=k;for(k=c.length;g !bucket || getBucketsForNode(childNode).includes(bucket),\n );\n return matchingNodes;\n }\n*/\n\n getChildNodes(node, bucket) {\n const matchingNodes = Array.from(node.childNodes).filter(\n childNode => !bucket || getBucketsForNode(childNode).includes(bucket),\n );\n matchingNodes.forEach(matchingNode => this._onNodeTouched(matchingNode));\n return matchingNodes;\n }\n\n /**\n * Get the data of this node.\n *\n * @param node -\n */\n getData(node) {\n if (node.nodeType === Node.ATTRIBUTE_NODE) {\n this._onNodeTouched(node);\n return node.value;\n }\n // Text node\n this._onNodeTouched(node.parentNode);\n return node.data;\n }\n\n /**\n * Get the first child of this element.\n * An implementation of IDomFacade is free to interpret the bucket to skip returning nodes that do not match the bucket, or use this information to its advantage.\n *\n * @param node -\n * @param bucket - The bucket that matches the attribute that will be used.\n */\n getFirstChild(node, bucket) {\n for (const child of node.childNodes) {\n if (!bucket || getBucketsForNode(child).includes(bucket)) {\n this._onNodeTouched(node);\n return child;\n }\n }\n return null;\n }\n\n /**\n * Get the last child of this element.\n * An implementation of IDomFacade is free to interpret the bucket to skip returning nodes that do not match the bucket, or use this information to its advantage.\n *\n * @param node -\n * @param bucket - The bucket that matches the attribute that will be used.\n */\n // eslint-disable-next-line class-methods-use-this\n getLastChild(node, bucket) {\n const matchingNodes = node\n .getChildNodes()\n .filter(childNode => !bucket || getBucketsForNode(childNode).includes(bucket));\n const matchNode = matchingNodes[matchingNodes.length - 1];\n if (matchNode) {\n return matchNode;\n }\n return null;\n }\n\n /**\n * Get the next sibling of this node\n * An implementation of IDomFacade is free to interpret the bucket to skip returning nodes that do not match the bucket, or use this information to its advantage.\n *\n * @param node -\n * @param bucket - The bucket that matches the nextSibling that is requested.\n */\n // eslint-disable-next-line class-methods-use-this\n getNextSibling(node, bucket) {\n for (let { nextSibling } = node; nextSibling; nextSibling = nextSibling.nextSibling) {\n if (!getBucketsForNode(nextSibling).includes(bucket)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n return nextSibling;\n }\n return null;\n }\n\n /**\n * Get the parent of this element.\n * An implementation of IDomFacade is free to interpret the bucket to skip returning nodes that do not match the bucket, or use this information to its advantage.\n *\n * @param node -\n * @param bucket - The bucket that matches the attribute that will be used.\n */\n // eslint-disable-next-line class-methods-use-this\n getParentNode(node) {\n return node.parentNode;\n }\n\n /**\n * Get the previous sibling of this element.\n * An implementation of IDomFacade is free to interpret the bucket to skip returning nodes that do not match the bucket, or use this information to its advantage.\n *\n * @param node -\n * @param bucket - The bucket that matches the attribute that will be used.\n */\n // eslint-disable-next-line class-methods-use-this\n getPreviousSibling(node, bucket) {\n for (\n let { previousSibling } = node;\n previousSibling;\n previousSibling = previousSibling.previousSibling\n ) {\n if (!getBucketsForNode(previousSibling).includes(bucket)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n return previousSibling;\n }\n return null;\n }\n}\n","import * as fx from 'fontoxpath';\n\n/**\n * Checks wether the specified path expression is an absolute path.\n *\n * @param path the path expression.\n * @return true if specified path expression is an absolute\n * path, otherwise false.\n */\n\nexport class XPathUtil {\n static getParentBindingElement(start) {\n /* if (start.parentNode.host) {\n const { host } = start.parentNode;\n if (host.hasAttribute('ref')) {\n return host;\n }\n } else */\n if (start.parentNode && start.parentNode.nodeType !== Node.DOCUMENT_NODE) {\n if (start.parentNode.hasAttribute('ref')) {\n return start.parentNode;\n }\n XPathUtil.getParentBindingElement(start.parentNode);\n }\n return null;\n }\n\n static isAbsolutePath(path) {\n return path != null && (path.startsWith('/') || path.startsWith('instance('));\n }\n\n static isRepeated(element) {\n return element.parentElement.closest('fx-repeatitem');\n }\n\n static isSelfReference(ref) {\n return ref === '.' || ref === './text()' || ref === 'text()' || ref === '' || ref === null;\n }\n\n static getDefaultInstance(boundElement) {\n // const fore = boundElement.closest('fx-fore');\n const fore = XPathUtil.getForeElement(boundElement);\n const defaultInstance = fore.querySelector('fx-instance');\n if (!defaultInstance) {\n throw new Error('no default instance present');\n }\n return defaultInstance;\n }\n\n static getForeElement(start) {\n if (start.nodeName === 'FX-FORE') {\n return start;\n }\n if (start.parentNode) {\n return XPathUtil.getForeElement(start.parentNode);\n }\n throw new Error('no Fore element present');\n }\n\n /**\n * returns the instance id from a complete XPath using `instance()` function.\n *\n * Will return 'default' in case no ref is given at all or the `instance()` function is called without arg.\n *\n * Otherwise instance id is extracted from function and returned. If all fails null is returned.\n * @param ref\n * @returns {string}\n */\n static getInstanceId(ref) {\n if (!ref) {\n return 'default';\n }\n if (ref.startsWith('instance()')) {\n return 'default';\n }\n if (ref.startsWith('instance(')) {\n const result = ref.substring(ref.indexOf('(') + 1);\n return result.substring(1, result.indexOf(')') - 1);\n }\n return null;\n }\n\n // todo: certainly not ideal to rely on duplicating instance id on instance document - better way later ;)\n static getPath(node) {\n const path = fx.evaluateXPath('path()', node);\n /*\n const instanceId = node.ownerDocument.firstElementChild.getAttribute('id');\n if (instanceId !== null && instanceId !== 'default') {\n return `#${instanceId}${XPathUtil.shortenPath(path)}`;\n }\n*/\n return XPathUtil.shortenPath(path);\n }\n\n static shortenPath(path) {\n const tmp = path.replaceAll(/(Q{(.*?)\\})/g, '');\n // cut off leading slash\n const tmp1 = tmp.substring(1, tmp.length);\n // ### cut-off root node ref\n return tmp1.substring(tmp1.indexOf('/'), tmp.length);\n }\n\n static getBasePath(dep) {\n const split = dep.split(':');\n return split[0];\n }\n}\n","/**\n * A simple dependency graph\n *\n * based on the work of https://github.com/jriecken/dependency-graph but working on ES6.\n *\n * Furthermore instead of the DepGraphCycleError a compute-exception event is dispatched.\n *\n *\n */\n\n/**\n * Cycle error, including the path of the cycle.\n */\n// const DepGraphCycleError = (exports.DepGraphCycleError = function (cyclePath) {\n\n/*\nexport function DepGraphCycleError(cyclePath) {\n const message = \"Dependency Cycle Found: \" + cyclePath.join(\" -> \");\n const instance = new Error(message);\n instance.cyclePath = cyclePath;\n Object.setPrototypeOf(instance, Object.getPrototypeOf(this));\n if (Error.captureStackTrace) {\n Error.captureStackTrace(instance, DepGraphCycleError);\n }\n return instance;\n};\n\nDepGraphCycleError.prototype = Object.create(Error.prototype, {\n constructor: {\n value: Error,\n enumerable: false,\n writable: true,\n configurable: true\n }\n});\nObject.setPrototypeOf(DepGraphCycleError, Error);\n*/\n\n/**\n * Helper for creating a Topological Sort using Depth-First-Search on a set of edges.\n *\n * Detects cycles and throws an Error if one is detected (unless the \"circular\"\n * parameter is \"true\" in which case it ignores them).\n *\n * @param edges The set of edges to DFS through\n * @param leavesOnly Whether to only return \"leaf\" nodes (ones who have no edges)\n * @param result An array in which the results will be populated\n * @param circular A boolean to allow circular dependencies\n */\nfunction createDFS(edges, leavesOnly, result, circular) {\n const visited = {};\n // eslint-disable-next-line func-names\n return function(start) {\n // console.log('start ', start);\n if (visited[start]) {\n return;\n }\n const inCurrentPath = {};\n const currentPath = [];\n const todo = []; // used as a stack\n todo.push({ node: start, processed: false });\n while (todo.length > 0) {\n const current = todo[todo.length - 1]; // peek at the todo stack\n const { processed } = current;\n const { node } = current;\n if (!processed) {\n // Haven't visited edges yet (visiting phase)\n if (visited[node]) {\n todo.pop();\n // eslint-disable-next-line no-continue\n continue;\n } else if (inCurrentPath[node]) {\n // It's not a DAG\n if (circular) {\n todo.pop();\n // If we're tolerating cycles, don't revisit the node\n // eslint-disable-next-line no-continue\n continue;\n }\n currentPath.push(node);\n window.dispatchEvent(\n new CustomEvent('compute-exception', {\n composed: true,\n bubbles: true,\n detail: {\n path: currentPath,\n message: 'cyclic graph',\n },\n }),\n );\n // return;\n // console.log('‘circular path: ' + currentPath);\n // throw new DepGraphCycleError(currentPath);\n\n // Stop all processing. This form is broken and we should not break the browser\n throw new Error(`Cyclic at ${currentPath}`);\n }\n\n inCurrentPath[node] = true;\n currentPath.push(node);\n const nodeEdges = edges[node];\n // (push edges onto the todo stack in reverse order to be order-compatible with the old DFS implementation)\n for (let i = nodeEdges.length - 1; i >= 0; i -= 1) {\n todo.push({ node: nodeEdges[i], processed: false });\n }\n current.processed = true;\n } else {\n // Have visited edges (stack unrolling phase)\n todo.pop();\n currentPath.pop();\n inCurrentPath[node] = false;\n visited[node] = true;\n if (!leavesOnly || edges[node].length === 0) {\n result.push(node);\n }\n }\n }\n };\n}\n\n/**\n * Simple Dependency Graph\n */\n\n/*\nvar DepGraph = (exports.DepGraph = function DepGraph(opts) {\n this.nodes = {}; // Node -> Node/Data (treated like a Set)\n this.outgoingEdges = {}; // Node -> [Dependency Node]\n this.incomingEdges = {}; // Node -> [Dependant Node]\n this.circular = opts && !!opts.circular; // Allows circular deps\n});\n*/\n\nexport function DepGraph(opts) {\n this.nodes = {}; // Node -> Node/Data (treated like a Set)\n this.outgoingEdges = {}; // Node -> [Dependency Node]\n this.incomingEdges = {}; // Node -> [Dependant Node]\n this.circular = opts && !!opts.circular; // Allows circular deps\n}\n\nDepGraph.prototype = {\n /**\n * The number of nodes in the graph.\n */\n size() {\n return Object.keys(this.nodes).length;\n },\n /**\n * Add a node to the dependency graph. If a node already exists, this method will do nothing.\n */\n addNode(node, data) {\n if (!this.hasNode(node)) {\n // Checking the arguments length allows the user to add a node with undefined data\n if (arguments.length === 2) {\n this.nodes[node] = data;\n } else {\n this.nodes[node] = node;\n }\n this.outgoingEdges[node] = [];\n this.incomingEdges[node] = [];\n }\n },\n /**\n * Remove a node from the dependency graph. If a node does not exist, this method will do nothing.\n */\n removeNode(node) {\n if (this.hasNode(node)) {\n delete this.nodes[node];\n delete this.outgoingEdges[node];\n delete this.incomingEdges[node];\n // [this.incomingEdges, this.outgoingEdges].forEach(function (edgeList) {\n [this.incomingEdges, this.outgoingEdges].forEach(edgeList => {\n Object.keys(edgeList).forEach(key => {\n const idx = edgeList[key].indexOf(node);\n if (idx >= 0) {\n edgeList[key].splice(idx, 1);\n }\n }, this);\n });\n }\n },\n /**\n * Check if a node exists in the graph\n */\n hasNode(node) {\n // return this.nodes.hasOwnProperty(node);\n\n return Object.prototype.hasOwnProperty.call(this.nodes, node);\n },\n /**\n * Get the data associated with a node name\n */\n getNodeData(node) {\n if (this.hasNode(node)) {\n return this.nodes[node];\n }\n throw new Error(`Node does not exist: ${node}`);\n },\n /**\n * Set the associated data for a given node name. If the node does not exist, this method will throw an error\n */\n setNodeData(node, data) {\n if (this.hasNode(node)) {\n this.nodes[node] = data;\n } else {\n throw new Error(`Node does not exist: ${node}`);\n }\n },\n /**\n * Add a dependency between two nodes. If either of the nodes does not exist,\n * an Error will be thrown.\n */\n addDependency(from, to) {\n if (!this.hasNode(from)) {\n throw new Error(`Node does not exist: ${from}`);\n }\n if (!this.hasNode(to)) {\n throw new Error(`Node does not exist: ${to}`);\n }\n if (this.outgoingEdges[from].indexOf(to) === -1) {\n this.outgoingEdges[from].push(to);\n }\n if (this.incomingEdges[to].indexOf(from) === -1) {\n this.incomingEdges[to].push(from);\n }\n return true;\n },\n /**\n * Remove a dependency between two nodes.\n */\n removeDependency(from, to) {\n let idx;\n if (this.hasNode(from)) {\n idx = this.outgoingEdges[from].indexOf(to);\n if (idx >= 0) {\n this.outgoingEdges[from].splice(idx, 1);\n }\n }\n\n if (this.hasNode(to)) {\n idx = this.incomingEdges[to].indexOf(from);\n if (idx >= 0) {\n this.incomingEdges[to].splice(idx, 1);\n }\n }\n },\n /**\n * Return a clone of the dependency graph. If any custom data is attached\n * to the nodes, it will only be shallow copied.\n */\n clone() {\n const source = this;\n const result = new DepGraph();\n const keys = Object.keys(source.nodes);\n keys.forEach(n => {\n result.nodes[n] = source.nodes[n];\n result.outgoingEdges[n] = source.outgoingEdges[n].slice(0);\n result.incomingEdges[n] = source.incomingEdges[n].slice(0);\n });\n return result;\n },\n /**\n * Get an array containing the direct dependencies of the specified node.\n *\n * Throws an Error if the specified node does not exist.\n */\n directDependenciesOf(node) {\n if (this.hasNode(node)) {\n return this.outgoingEdges[node].slice(0);\n }\n throw new Error(`Node does not exist: ${node}`);\n },\n /**\n * Get an array containing the nodes that directly depend on the specified node.\n *\n * Throws an Error if the specified node does not exist.\n */\n directDependantsOf(node) {\n if (this.hasNode(node)) {\n return this.incomingEdges[node].slice(0);\n }\n throw new Error(`Node does not exist: ${node}`);\n },\n /**\n * Get an array containing the nodes that the specified node depends on (transitively).\n *\n * Throws an Error if the graph has a cycle, or the specified node does not exist.\n *\n * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned\n * in the array.\n */\n dependenciesOf(node, leavesOnly) {\n if (this.hasNode(node)) {\n const result = [];\n const DFS = createDFS(this.outgoingEdges, leavesOnly, result, this.circular);\n DFS(node);\n const idx = result.indexOf(node);\n if (idx >= 0) {\n result.splice(idx, 1);\n }\n return result;\n }\n throw new Error(`Node does not exist: ${node}`);\n },\n /**\n * get an array containing the nodes that depend on the specified node (transitively).\n *\n * Throws an Error if the graph has a cycle, or the specified node does not exist.\n *\n * If `leavesOnly` is true, only nodes that do not have any dependants will be returned in the array.\n */\n dependantsOf(node, leavesOnly) {\n if (this.hasNode(node)) {\n const result = [];\n const DFS = createDFS(this.incomingEdges, leavesOnly, result, this.circular);\n DFS(node);\n const idx = result.indexOf(node);\n if (idx >= 0) {\n result.splice(idx, 1);\n }\n return result;\n }\n throw new Error(`Node does not exist: ${node}`);\n },\n\n /**\n * Get an array of nodes that have no dependants (i.e. nothing depends on them).\n */\n entryNodes() {\n const self = this;\n return Object.keys(this.nodes).filter(node => self.incomingEdges[node].length === 0);\n },\n\n /**\n * Construct the overall processing order for the dependency graph.\n *\n * Throws an Error if the graph has a cycle.\n *\n * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned.\n */\n overallOrder(leavesOnly) {\n const self = this;\n const result = [];\n const keys = Object.keys(this.nodes);\n if (keys.length === 0) {\n return result; // Empty graph\n }\n if (!this.circular) {\n // Look for cycles - we run the DFS starting at all the nodes in case there\n // are several disconnected subgraphs inside this dependency graph.\n const CycleDFS = createDFS(this.outgoingEdges, false, [], this.circular);\n keys.forEach(n => {\n CycleDFS(n);\n });\n }\n\n const DFS = createDFS(this.outgoingEdges, leavesOnly, result, this.circular);\n // Find all potential starting points (nodes with nothing depending on them) an\n // run a DFS starting at these points to get the order\n keys\n .filter(node => self.incomingEdges[node].length === 0)\n .forEach(n => {\n DFS(n);\n });\n\n // If we're allowing cycles - we need to run the DFS against any remaining\n // nodes that did not end up in the initial result (as they are part of a\n // subgraph that does not have a clear starting point)\n if (this.circular) {\n keys.filter(node => result.indexOf(node) === -1).forEach(n => DFS(n));\n }\n\n return result;\n },\n};\n\n// Create some aliases\nDepGraph.prototype.directDependentsOf = DepGraph.prototype.directDependantsOf;\nDepGraph.prototype.dependentsOf = DepGraph.prototype.dependantsOf;\n","export class Fore {\n static READONLY_DEFAULT = false;\n\n static REQUIRED_DEFAULT = false;\n\n static RELEVANT_DEFAULT = true;\n\n static CONSTRAINT_DEFAULT = true;\n\n static TYPE_DEFAULT = 'xs:string';\n\n static get ACTION_ELEMENTS() {\n return [\n 'FX-DELETE',\n 'FX-DISPATCH',\n 'FX-HIDE',\n 'FX-INSERT',\n 'FX-LOAD',\n 'FX-MESSAGE',\n 'FX-REBUILD',\n 'FX-RECALCULATE',\n 'FX-REFRESH',\n 'FX-RENEW',\n 'FX-REPLACE',\n 'FX-RESET',\n 'FX-RETAIN',\n 'FX-RETURN',\n 'FX-REVALIDATE',\n 'FX-SEND',\n 'FX-SETFOCUS',\n 'FX-SETINDEX',\n 'FX-SETVALUE',\n 'FX-SHOW',\n 'FX-TOGGLE',\n 'FX-UPDATE',\n ];\n }\n\n static createUUID() {\n // http://www.ietf.org/rfc/rfc4122.txt\n const s = [];\n const hexDigits = '0123456789abcdef';\n for (let i = 0; i < 36; i += 1) {\n s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);\n }\n s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010\n s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01\n s[8] = s[13] = s[18] = s[23] = '-';\n\n const uuid = s.join('');\n return uuid;\n }\n\n static get XFORMS_NAMESPACE_URI() {\n // todo: should be centralized somewhere as constant. Exists in several? places\n return 'http://www.w3.org/2002/xforms';\n }\n\n static isActionElement(elementName) {\n return Fore.ACTION_ELEMENTS.includes(elementName);\n }\n\n static get UI_ELEMENTS() {\n return [\n 'FX-ALERT',\n 'FX-CONTROL',\n 'FX-BUTTON',\n 'FX-CONTROL',\n 'FX-DIALOG',\n 'FX-FILENAME',\n 'FX-MEDIATYPE',\n 'FX-GROUP',\n 'FX-HINT',\n 'FX-INPUT',\n 'FX-ITEMS',\n 'FX-LABEL',\n 'FX-OUTPUT',\n 'FX-RANGE',\n 'FX-REPEAT',\n 'FX-REPEATITEM',\n 'FX-SWITCH',\n 'FX-SECRET',\n 'FX-SELECT',\n 'FX-SUBMIT',\n 'FX-TEXTAREA',\n 'FX-TRIGGER',\n 'FX-UPLOAD',\n 'FX-VAR',\n ];\n }\n\n static isUiElement(elementName) {\n const found = Fore.UI_ELEMENTS.includes(elementName);\n if (found) {\n // console.log('_isUiElement ', found);\n }\n return Fore.UI_ELEMENTS.includes(elementName);\n }\n\n /**\n * recursively refreshes all UI Elements.\n *\n * todo: this could probably made more efficient with significant impact on rendering perf\n *\n * @param startElement\n * @param force\n * @returns {Promise}\n */\n static async refreshChildren(startElement, force) {\n const refreshed = new Promise(resolve => {\n /*\n if there's an 'refresh-on-view' attribute the element wants to be handled by\n handleIntersect function that calls the refresh of the respective element and\n not the global one.\n */\n // if(!force && startElement.hasAttribute('refresh-on-view')) return;\n\n /* ### attempt with querySelectorAll is even slower than iterating recursively\n\n const children = startElement.querySelectorAll('[ref]');\n Array.from(children).forEach(uiElement => {\n if (Fore.isUiElement(uiElement.nodeName) && typeof uiElement.refresh === 'function') {\n uiElement.refresh();\n }\n });\n*/\n const { children } = startElement;\n if (children) {\n Array.from(children).forEach(element => {\n if (Fore.isUiElement(element.nodeName) && typeof element.refresh === 'function') {\n element.refresh();\n } else if (element.nodeName.toUpperCase() !== 'FX-MODEL') {\n Fore.refreshChildren(element, force);\n }\n });\n }\n resolve('done');\n });\n\n return refreshed;\n }\n\n static isRepeated(element) {\n return element.closest('fx-repeatitem') !== null;\n }\n\n static getRepeatTarget(element, id) {\n const repeatContextItem = element.closest('fx-repeatitem');\n const target = repeatContextItem.querySelector(`#${id}`);\n return target;\n }\n\n /**\n * returns the proper content-type for instance.\n *\n * @param instance an fx-instance element\n * @returns {string|null}\n */\n static getContentType(instance, method) {\n if (method === 'urlencoded-post') {\n return 'application/x-www-form-urlencoded; charset=UTF-8';\n }\n if (instance.type === 'xml') {\n return 'application/xml; charset=UTF-8';\n }\n if (instance.type === 'json') {\n return 'application/json';\n }\n console.warn('content-type unknown ', instance.type);\n return null;\n }\n\n static fadeInElement(element) {\n const duration = 600;\n let fadeIn = () => {\n // Stop all current animations\n if (element.getAnimations) {\n element.getAnimations().map(anim => anim.finish());\n }\n\n // Play the animation with the newly specified duration\n fadeIn = element.animate(\n {\n opacity: [0, 1],\n },\n duration,\n );\n return fadeIn.finished;\n };\n return fadeIn();\n }\n\n static fadeOutElement(element, duration) {\n // const duration = duration;\n let fadeOut = () => {\n\n // Stop all current animations\n if (element.getAnimations) {\n element.getAnimations().map(anim => anim.finish());\n }\n\n\n // Play the animation with the newly specified duration\n fadeOut = element.animate(\n {\n opacity: [1, 0],\n },\n duration,\n );\n return fadeOut.finished;\n };\n return fadeOut();\n }\n\n static dispatch(target, eventName, detail) {\n const event = new CustomEvent(eventName, {\n composed: true,\n bubbles: true,\n detail,\n });\n console.log('firing', event);\n target.dispatchEvent(event);\n }\n\n static prettifyXml(source) {\n const xmlDoc = new DOMParser().parseFromString(source, 'application/xml');\n const xsltDoc = new DOMParser().parseFromString(\n [\n // describes how we want to modify the XML - indent everything\n '',\n ' ',\n ' ', // change to just text() to strip space in text nodes\n ' ',\n ' ',\n ' ',\n ' ',\n ' ',\n ' ',\n '',\n ].join('\\n'),\n 'application/xml',\n );\n\n const xsltProcessor = new XSLTProcessor();\n xsltProcessor.importStylesheet(xsltDoc);\n const resultDoc = xsltProcessor.transformToDocument(xmlDoc);\n const resultXml = new XMLSerializer().serializeToString(resultDoc);\n return resultXml;\n }\n\n\n /**\n * clear all text nodes and attribute values to get a 'clean' template.\n * @param n\n * @private\n */\n /*\n static clear(n) {\n n.textContent = '';\n if (n.hasAttributes()) {\n const attrs = n.attributes;\n for (let i = 0; i < attrs.length; i+= 1) {\n attrs[i].value = '';\n }\n }\n const { children } = n;\n for (let i = 0; i < children.length; i+= 1) {\n Fore.clear(children[i]);\n }\n }\n */\n}\n","import {\n evaluateXPath as fxEvaluateXPath,\n evaluateXPathToBoolean as fxEvaluateXPathToBoolean,\n evaluateXPathToFirstNode as fxEvaluateXPathToFirstNode,\n evaluateXPathToNodes as fxEvaluateXPathToNodes,\n evaluateXPathToNumber as fxEvaluateXPathToNumber,\n evaluateXPathToString as fxEvaluateXPathToString,\n evaluateXPathToStrings as fxEvaluateXPathToStrings,\n parseScript,\n registerCustomXPathFunction,\n registerXQueryModule,\n} from 'fontoxpath';\nimport { Fore } from './fore.js';\n\nimport { XPathUtil } from './xpath-util.js';\n\nconst XFORMS_NAMESPACE_URI = 'http://www.w3.org/2002/xforms';\n\nconst createdNamespaceResolversByXPathQueryAndNode = new Map();\n\nfunction getCachedNamespaceResolver(xpath, node) {\n if (!createdNamespaceResolversByXPathQueryAndNode.has(xpath)) {\n return null;\n }\n return createdNamespaceResolversByXPathQueryAndNode.get(xpath).get(node) || null;\n}\nfunction setCachedNamespaceResolver(xpath, node, resolver) {\n if (!createdNamespaceResolversByXPathQueryAndNode.has(xpath)) {\n return createdNamespaceResolversByXPathQueryAndNode.set(xpath, new Map());\n }\n return createdNamespaceResolversByXPathQueryAndNode.get(xpath).set(node, resolver);\n}\n\nconst xhtmlNamespaceResolver = prefix => {\n if (!prefix) {\n return 'http://www.w3.org/1999/xhtml';\n }\n return undefined;\n};\n\n/**\n * Resolve a namespace. Needs a namespace prefix and the element that is most closely related to the\n * XPath in which the namespace is being resolved. The prefix will be resolved by using the\n * ancestry of said element.\n *\n * It has two ways of doing so:\n *\n * - If the prefix is defined in an `xmlns:XXX=\"YYY\"` namespace declaration, it will return 'YYY'.\n * - If the prefix is the empty prefix and there is an `xpath-default-namespace=\"YYY\"` attribute in the\n * - ancestry, that attribute will be used and 'YYY' will be returned\n *\n * @param {Node} contextElement The element that is most closely related with the XPath in which this prefix is resolved.\n * @param {string} prefix The prefix to resolve\n */\nfunction createNamespaceResolver(xpathQuery, formElement) {\n const cachedResolver = getCachedNamespaceResolver(xpathQuery, formElement);\n if (cachedResolver) {\n return cachedResolver;\n }\n\n // Make namespace resolving use the `instance` element that is related to here\n const xmlDocument = new DOMParser().parseFromString('', 'text/xml');\n\n const xpathAST = parseScript(xpathQuery, {}, xmlDocument);\n let instanceReferences = fxEvaluateXPathToStrings(\n `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`,\n xpathAST,\n null,\n {},\n {\n namespaceResolver: prefix =>\n prefix === 'xqx' ? 'http://www.w3.org/2005/XQueryX' : undefined,\n },\n );\n if (instanceReferences.length === 0) {\n // No instance functions. Look up further in the hierarchy to see if we can deduce the intended context from there\n const ancestorComponent = fxEvaluateXPathToFirstNode('ancestor::*[@ref][1]', formElement);\n if (ancestorComponent) {\n const resolver = createNamespaceResolver(\n ancestorComponent.getAttribute('ref'),\n ancestorComponent,\n );\n setCachedNamespaceResolver(xpathQuery, formElement, resolver);\n return resolver;\n }\n // Nothing found: let's just assume we're supposed to use the `default` instance\n instanceReferences = ['default'];\n }\n\n if (instanceReferences.length === 1) {\n // console.log(`resolving ${xpathQuery} with ${instanceReferences[0]}`);\n let instance;\n if (instanceReferences[0] === 'default') {\n const actualForeElement = fxEvaluateXPathToFirstNode(\n 'ancestor-or-self::fx-fore',\n formElement,\n null,\n null,\n { namespaceResolver: xhtmlNamespaceResolver },\n );\n\n instance = actualForeElement && actualForeElement.querySelector('fx-instance');\n } else {\n instance = resolveId(instanceReferences[0], formElement, 'fx-instance');\n }\n if (instance && instance.hasAttribute('xpath-default-namespace')) {\n const xpathDefaultNamespace = instance.getAttribute('xpath-default-namespace');\n /*\n console.log(\n `Resolving the xpath ${xpathQuery} with the default namespace set to ${xpathDefaultNamespace}`,\n );\n*/\n const resolveNamespacePrefix = prefix => {\n if (!prefix) {\n return xpathDefaultNamespace;\n }\n return undefined;\n };\n setCachedNamespaceResolver(xpathQuery, formElement, resolveNamespacePrefix);\n return resolveNamespacePrefix;\n }\n }\n if (instanceReferences.length > 1) {\n console.warn(\n `More than one instance is used in the query \"${xpathQuery}\". The default namespace resolving will be used`,\n );\n }\n\n const xpathDefaultNamespace =\n fxEvaluateXPathToString('ancestor-or-self::*/@xpath-default-namespace[last()]', formElement) ||\n '';\n\n const resolveNamespacePrefix = function resolveNamespacePrefix(prefix) {\n if (prefix === '') {\n return xpathDefaultNamespace;\n }\n\n // Note: ideally we should use Node#lookupNamespaceURI. However, the nodes we are passed are\n // XML. The best we can do is emulate the `xmlns:xxx` namespace declarations by regarding them as\n // attributes. Which they technically ARE NOT!\n\n return fxEvaluateXPathToString(\n 'ancestor-or-self::*/@*[name() = \"xmlns:\" || $prefix][last()]',\n formElement,\n null,\n { prefix },\n );\n };\n\n setCachedNamespaceResolver(xpathQuery, formElement, resolveNamespacePrefix);\n return resolveNamespacePrefix;\n}\n\nfunction createNamespaceResolverForNode(query, contextNode, formElement) {\n if (((contextNode && contextNode.ownerDocument) || contextNode) === window.document) {\n // Running a query on the HTML DOM. Don't bother resolving namespaces in any other way\n return xhtmlNamespaceResolver;\n }\n return createNamespaceResolver(query, formElement);\n}\n\n/**\n * Implementation of the functionNameResolver passed to FontoXPath to\n * redirect function resolving for unprefixed functions to either the fn or the xf namespace\n */\n// eslint-disable-next-line no-unused-vars\nfunction functionNameResolver({ prefix, localName }, _arity) {\n switch (localName) {\n // TODO: put the full XForms library functions set here\n case 'context':\n case 'base64encode':\n case 'boolean-from-string':\n case 'current':\n case 'depends':\n case 'event':\n case 'index':\n case 'instance':\n case 'log':\n case 'logtree':\n return { namespaceURI: XFORMS_NAMESPACE_URI, localName };\n default:\n if (prefix === '' || prefix === 'fn') {\n return { namespaceURI: 'http://www.w3.org/2005/xpath-functions', localName };\n }\n if (prefix === 'local') {\n return { namespaceURI: 'http://www.w3.org/2005/xquery-local-functions', localName };\n }\n return null;\n }\n}\n\n/**\n * Get the variables in scope of the form element. These are the values of the variables that\n * logically precede the formElement that declares the XPath\n *\n * @param {Node} formElement The element that declares the XPath\n *\n * @return {Object} A key-value mapping of the variables\n */\nfunction getVariablesInScope(formElement) {\n let closestActualFormElement = formElement;\n while (closestActualFormElement && !('inScopeVariables' in closestActualFormElement)) {\n closestActualFormElement = closestActualFormElement.parentNode;\n }\n\n if (!closestActualFormElement) {\n return {};\n }\n\n const variables = {};\n if(closestActualFormElement.inScopeVariables){\n for (const key of closestActualFormElement.inScopeVariables.keys()) {\n const varElement = closestActualFormElement.inScopeVariables.get(key);\n variables[key] = varElement.value;\n }\n }\n return variables;\n}\n\n/**\n * Evaluate an XPath to _any_ type. When possible, prefer to use any other function to ensure the\n * type of the output is more predictable.\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {{parentNode}|ForeElementMixin} formElement The form element associated to the XPath\n */\nexport function evaluateXPath(xpath, contextNode, formElement, variables = {}) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n\n return fxEvaluateXPath(\n xpath,\n contextNode,\n null,\n { ...variablesInScope, ...variables },\n 'xs:anyType',\n {\n currentContext: { formElement, variables },\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n functionNameResolver,\n namespaceResolver,\n },\n );\n}\n\n/**\n * Evaluate an XPath to the first Node\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @return {Node} The first node found by the XPath\n */\nexport function evaluateXPathToFirstNode(xpath, contextNode, formElement) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n return fxEvaluateXPathToFirstNode(xpath, contextNode, null, variablesInScope, {\n defaultFunctionNamespaceURI: XFORMS_NAMESPACE_URI,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n currentContext: { formElement },\n namespaceResolver,\n });\n}\n\n/**\n * Evaluate an XPath to all nodes\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @return {Node[]} All nodes\n */\nexport function evaluateXPathToNodes(xpath, contextNode, formElement) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n\n return fxEvaluateXPathToNodes(xpath, contextNode, null, variablesInScope, {\n currentContext: { formElement },\n functionNameResolver,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n namespaceResolver,\n });\n}\n\n/**\n * Evaluate an XPath to a boolean\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @return {boolean}\n */\nexport function evaluateXPathToBoolean(xpath, contextNode, formElement) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n\n return fxEvaluateXPathToBoolean(xpath, contextNode, null, variablesInScope, {\n currentContext: { formElement },\n functionNameResolver,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n namespaceResolver,\n });\n}\n\n/**\n * Evaluate an XPath to a string\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @param {DomFacade} [domFacade=null] A DomFacade is used in bindings to intercept DOM\n * access. This is used to determine dependencies between bind elements.\n * @param {Node} formElement The element where the XPath is defined: used for namespace resolving\n * @return {string}\n */\nexport function evaluateXPathToString(\n xpath,\n contextNode,\n formElement,\n domFacade = null,\n namespaceReferenceNode = formElement,\n) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n\n return fxEvaluateXPathToString(xpath, contextNode, domFacade, variablesInScope, {\n currentContext: { formElement },\n functionNameResolver,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n namespaceResolver,\n });\n}\n\n/**\n * Evaluate an XPath to a set of strings\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @param {DomFacade} [domFacade=null] A DomFacade is used in bindings to intercept DOM\n * access. This is used to determine dependencies between bind elements.\n * @param {Node} formElement The element where the XPath is defined: used for namespace resolving\n * @return {string}\n */\nexport function evaluateXPathToStrings(\n xpath,\n contextNode,\n formElement,\n domFacade = null,\n namespaceReferenceNode = formElement,\n) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n return fxEvaluateXPathToStrings(\n xpath,\n contextNode,\n domFacade,\n {},\n\n {\n currentContext: { formElement },\n functionNameResolver,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n namespaceResolver,\n },\n );\n}\n\n/**\n * Evaluate an XPath to a number\n *\n * @param {string} xpath The XPath to run\n * @param {Node} contextNode The start of the XPath\n * @param {Node} formElement The form element associated to the XPath\n * @param {DomFacade} [domFacade=null] A DomFacade is used in bindings to intercept DOM\n * @param {Node} formElement The element where the XPath is defined: used for namespace resolving\n * access. This is used to determine dependencies between bind elements.\n * @return {Number}\n */\nexport function evaluateXPathToNumber(\n xpath,\n contextNode,\n formElement,\n domFacade = null,\n namespaceReferenceNode = formElement,\n) {\n const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);\n const variablesInScope = getVariablesInScope(formElement);\n\n return fxEvaluateXPathToNumber(xpath, contextNode, domFacade, variablesInScope, {\n currentContext: { formElement },\n functionNameResolver,\n moduleImports: {\n xf: XFORMS_NAMESPACE_URI,\n },\n namespaceResolver,\n });\n}\n\n/**\n * Resolve an id in scope. Behaves like the algorithm defined on https://www.w3.org/community/xformsusers/wiki/XForms_2.0#idref-resolve\n */\nexport function resolveId(id, sourceObject, nodeName = null) {\n const allMatchingTargetObjects = fxEvaluateXPathToNodes(\n 'outermost(ancestor-or-self::fx-fore[1]/(descendant::xf-fore|descendant::*[@id = $id]))[not(self::fx-fore)]',\n sourceObject,\n null,\n { id },\n { namespaceResolver: xhtmlNamespaceResolver },\n );\n\n if (allMatchingTargetObjects.length === 0) {\n return null;\n }\n\n if (\n allMatchingTargetObjects.length === 1 &&\n fxEvaluateXPathToBoolean(\n '(ancestor::fx-fore | ancestor::fx-repeat)[last()]/self::fx-fore',\n allMatchingTargetObjects[0],\n null,\n null,\n { namespaceResolver: xhtmlNamespaceResolver },\n )\n ) {\n // If the target element is not repeated, then the search for the target object is trivial since\n // there is only one associated with the target element that bears the matching ID. This is true\n // regardless of whether or not the source object is repeated. However, if the target element is\n // repeated, then additional information must be used to help select a target object from among\n // those associated with the identified target element.\n const targetObject = allMatchingTargetObjects[0];\n if (nodeName && targetObject.localName !== nodeName) {\n return null;\n }\n return targetObject;\n }\n\n // SPEC:\n\n // 12.2.1 References to Elements within a repeat Element\n\n // When the target element that is identified by the IDREF of a source object has one or more\n // repeat elements as ancestors, then the set of ancestor repeats are partitioned into two\n // subsets, those in common with the source element and those that are not in common. Any ancestor\n // repeat elements of the target element not in common with the source element are descendants of\n // the repeat elements that the source and target element have in common, if any.\n\n // For the repeat elements that are in common, the desired target object exists in the same set of\n // run-time objects that contains the source object. Then, for each ancestor repeat of the target\n // element that is not in common with the source element, the current index of the repeat\n // determines the set of run-time objects that contains the desired target object.\n for (const ancestorRepeatItem of fxEvaluateXPathToNodes(\n 'ancestor::fx-repeatitem => reverse()',\n sourceObject,\n null,\n null,\n { namespaceResolver: xhtmlNamespaceResolver },\n )) {\n const foundTargetObjects = allMatchingTargetObjects.filter(to =>\n ancestorRepeatItem.contains(to),\n );\n switch (foundTargetObjects.length) {\n case 0:\n // Nothing found: ignore\n break;\n case 1: {\n // A single one is found: the target object is directly in a common repeat\n const targetObject = foundTargetObjects[0];\n if (nodeName && targetObject.localName !== nodeName) {\n return null;\n }\n return targetObject;\n }\n default: {\n // Multiple target objects are found: they are in a repeat that is not common with the source object\n // We found a target object in a common repeat! We now need to find the one that is in the repeatitem identified at the current index\n const targetObject = foundTargetObjects.find(to =>\n fxEvaluateXPathToNodes(\n 'every $ancestor of ancestor::fx-repeatitem satisfies $ancestor is $ancestor/../child::fx-repeatitem[../@repeat-index]',\n to,\n null,\n {},\n ),\n );\n if (!targetObject) {\n // Nothing valid found for whatever reason. This might be something dynamic?\n return null;\n }\n if (nodeName && targetObject.localName !== nodeName) {\n return null;\n }\n return targetObject;\n }\n }\n }\n // We found no target objects in common repeats. The id is unresolvable\n return null;\n}\n\nconst contextFunction = (dynamicContext, string) => {\n const caller = dynamicContext.currentContext.formElement;\n if (string) {\n const instance = resolveId(string, caller);\n if (instance) {\n if (instance.nodeName === 'FX-REPEAT') {\n const { nodeset } = instance;\n for (let parent = caller; parent; parent = parent.parentNode) {\n if (parent.parentNode === instance) {\n const offset = Array.from(parent.parentNode.children).indexOf(parent);\n return nodeset[offset];\n }\n }\n }\n return instance.nodeset;\n }\n }\n const parent = XPathUtil.getParentBindingElement(caller);\n const p = caller.nodeName;\n // const p = dynamicContext.domFacade.getParentElement();\n\n if (parent) return parent;\n return caller.getInScopeContext();\n};\n\n/**\n * @param id as string\n * @return instance data for given id serialized to string.\n */\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'context' },\n [],\n 'item()?',\n contextFunction,\n);\n\n/**\n * @param id as string\n * @return instance data for given id serialized to string.\n */\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'context' },\n ['xs:string'],\n 'item()?',\n contextFunction,\n);\n\n/**\n * @param id as string\n * @return instance data for given id serialized to string.\n */\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'log' },\n ['xs:string?'],\n 'xs:string?',\n (dynamicContext, string) => {\n const { formElement } = dynamicContext.currentContext;\n const instance = resolveId(string, formElement, 'fx-instance');\n if (instance) {\n if (instance.getAttribute('type') === 'json') {\n console.warn('log() does not work for JSON yet');\n // return JSON.stringify(instance.getDefaultContext());\n } else {\n const def = new XMLSerializer().serializeToString(instance.getDefaultContext());\n return Fore.prettifyXml(def);\n }\n }\n return null;\n },\n);\n\nfunction buildTree(tree, data) {\n if (!data) return;\n if (data.nodeType === Node.ELEMENT_NODE) {\n if (data.children) {\n const details = document.createElement('details');\n details.setAttribute('data-path', data.nodeName);\n const summary = document.createElement('summary');\n\n let display = ` <${data.nodeName}`;\n Array.from(data.attributes).forEach(attr => {\n display += ` ${attr.nodeName}=\"${attr.nodeValue}\"`;\n });\n\n let contents;\n if (\n data.firstChild &&\n data.firstChild.nodeType === Node.TEXT_NODE &&\n data.firstChild.data.trim() !== ''\n ) {\n // console.log('whoooooooooopp');\n contents = data.firstChild.nodeValue;\n display += `>${contents}`;\n } else {\n display += '>';\n }\n summary.textContent = display;\n\n details.appendChild(summary);\n if (data.childElementCount !== 0) {\n details.setAttribute('open', 'open');\n } else {\n summary.setAttribute('style', 'list-style:none;');\n }\n tree.appendChild(details);\n\n Array.from(data.children).forEach(child => {\n // if(child.nodeType === Node.ELEMENT_NODE){\n // child.parentNode.appendChild(buildTree(child));\n buildTree(details, child);\n // }\n });\n }\n } /* else if(data.nodeType === Node.ATTRIBUTE_NODE){\n //create span for now\n // const span = document.createElement('span');\n // span.style.background = 'grey';\n // span.textContent = data.value;\n // tree.appendChild(span);\n tree.setAttribute(data.nodeName,data.value);\n }else {\n tree.textContent = data;\n } */\n\n // return tree;\n}\n\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'logtree' },\n ['xs:string?'],\n 'element()?',\n (dynamicContext, string) => {\n const { formElement } = dynamicContext.currentContext;\n const instance = resolveId(string, formElement, 'fx-instance');\n\n if (instance) {\n // const def = new XMLSerializer().serializeToString(instance.getDefaultContext());\n // const def = JSON.stringify(instance.getDefaultContext());\n\n const treeDiv = document.createElement('div');\n treeDiv.setAttribute('class', 'logtree');\n // const datatree = buildTree(tree,instance.getDefaultContext());\n // return tree.appendChild(datatree);\n // return buildTree(root,instance.getDefaultContext());;\n const form = dynamicContext.currentContext.formElement;\n const logtree = form.querySelector('.logtree');\n if (logtree) {\n logtree.parentNode.removeChild(logtree);\n }\n const tree = buildTree(treeDiv, instance.getDefaultContext());\n if (tree) {\n form.appendChild(tree);\n }\n }\n return null;\n },\n);\n\nconst instance = (dynamicContext, string) => {\n // Spec: https://www.w3.org/TR/xforms-xpath/#The_XForms_Function_Library#The_instance.28.29_Function\n // TODO: handle no string passed (null will be passed instead)\n\n const formElement = fxEvaluateXPathToFirstNode(\n 'ancestor-or-self::fx-fore',\n dynamicContext.currentContext.formElement,\n null,\n null,\n { namespaceResolver: xhtmlNamespaceResolver },\n );\n\n // console.log('fnInstance dynamicContext: ', dynamicContext);\n // console.log('fnInstance string: ', string);\n\n const inst = string\n ? resolveId(string, formElement, 'fx-instance')\n : formElement.querySelector(`fx-instance`);\n\n // const def = instance.getInstanceData();\n if (inst) {\n const def = inst.getDefaultContext();\n // console.log('target instance root node: ', def);\n\n return def;\n }\n return null;\n};\n\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'index' },\n ['xs:string?'],\n 'xs:integer?',\n (dynamicContext, string) => {\n const { formElement } = dynamicContext.currentContext;\n if (string === null) {\n return 1;\n }\n const repeat = resolveId(string, formElement, 'fx-repeat');\n\n // const def = instance.getInstanceData();\n if (repeat) {\n return repeat.getAttribute('index');\n }\n return Number(1);\n },\n);\n\n// Note that this is not to spec. The spec enforces elements to be returned from the\n// instance. However, we allow instances to actually be JSON!\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'instance' },\n [],\n 'item()?',\n domFacade => instance(domFacade, null),\n);\n\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'instance' },\n ['xs:string?'],\n 'item()?',\n instance,\n);\n\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'depends' },\n ['node()*'],\n 'item()?',\n (dynamicContext, nodes) =>\n // console.log('depends on : ', nodes[0]);\n nodes[0],\n);\n\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'event' },\n ['xs:string?'],\n 'item()?',\n (dynamicContext, arg) => {\n const payload = dynamicContext.currentContext.variables[arg];\n if (payload.nodeType) {\n console.log('got some node as js object');\n }\n\n return dynamicContext.currentContext.variables[arg];\n },\n);\n\n// Implement the XForms standard functions here.\nregisterXQueryModule(`\n module namespace xf=\"${XFORMS_NAMESPACE_URI}\";\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`);\n\n// How to run XQUERY:\n/**\nregisterXQueryModule(`\nmodule namespace my-custom-namespace = \"my-custom-uri\";\n(:~\n\tInsert attribute somewhere\n\t~:)\ndeclare %public %updating function my-custom-namespace:do-something ($ele as element()) as xs:boolean {\n\tif ($ele/@done) then false() else\n\t(insert node\n\tattribute done {\"true\"}\n\tinto $ele, true())\n};\n`)\n// At some point:\nconst contextNode = null;\nconst pendingUpdatesAndXdmValue = evaluateUpdatingExpressionSync('ns:do-something(.)', contextNode, null, null, {moduleImports: {'ns': 'my-custom-uri'}})\n\nconsole.log(pendingUpdatesAndXdmValue.xdmValue); // this is true or false, see function\n\nexecutePendingUpdateList(pendingUpdatesAndXdmValue.pendingUpdateList, null, null, null);\n*/\n\n/**\n * @param input as string\n * @return {string}\n */\nregisterCustomXPathFunction(\n { namespaceURI: XFORMS_NAMESPACE_URI, localName: 'base64encode' },\n ['xs:string?'],\n 'xs:string?',\n (dynamicContext, string) => btoa(string),\n);\n","import { Fore } from './fore.js';\nimport { evaluateXPathToFirstNode } from './xpath-evaluation.js';\n\n/**\n * Container for data instances.\n *\n * Offers several ways of loading data from either inline content or via 'src' attribute which will use the fetch\n * API to resolve data.\n */\nexport class FxInstance extends HTMLElement {\n constructor() {\n super();\n this.model = this.parentNode;\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n // console.log('connectedCallback ', this);\n if (this.hasAttribute('src')) {\n this.src = this.getAttribute('src');\n }\n\n if (this.hasAttribute('id')) {\n this.id = this.getAttribute('id');\n } else {\n this.id = 'default';\n }\n\n if (this.hasAttribute('type')) {\n this.type = this.getAttribute('type');\n } else {\n this.type = 'xml';\n }\n const style = `\n :host {\n display: none;\n }\n :host * {\n display:none;\n }\n ::slotted(*){\n display:none;\n }\n `;\n\n const html = `\n `;\n this.shadowRoot.innerHTML = `\n \n ${html}\n `;\n }\n\n /**\n * Is called by fx-model during initialization phase (model-construct)\n * @returns {Promise}\n */\n async init() {\n // console.log('fx-instance init');\n await this._initInstance().then(() => {\n this.dispatchEvent(\n new CustomEvent('instance-loaded', {\n composed: true,\n bubbles: true,\n detail: { instance: this },\n }),\n );\n return this;\n });\n }\n\n evalXPath(xpath) {\n const formElement = this.parentElement.parentElement;\n const result = evaluateXPathToFirstNode(xpath, this.getDefaultContext(), formElement);\n return result;\n }\n\n /**\n * returns the current instance data\n *\n * @returns {Document | T | any}\n */\n getInstanceData() {\n if (!this.instanceData) {\n this._createInstanceData();\n }\n return this.instanceData;\n }\n\n setInstanceData(data) {\n if (!data) {\n this._createInstanceData();\n return;\n }\n this.instanceData = data;\n }\n\n /**\n * return the default context (root node of respective instance) for XPath evalution.\n *\n * @returns {Document|T|any|Element}\n */\n getDefaultContext() {\n // console.log('getDefaultContext ', this.instanceData.firstElementChild);\n if (this.type === 'xml') {\n return this.instanceData.firstElementChild;\n }\n return this.instanceData;\n }\n\n /**\n * does the actual loading of data. Handles inline data, data loaded via fetch() or data constructed from\n * querystring.\n *\n * @returns {Promise}\n * @private\n */\n async _initInstance() {\n if (this.src === '#querystring') {\n /*\n * generate XML data from URL querystring\n * todo: there's no variant to generate JSON yet\n */\n // eslint-disable-next-line no-restricted-globals\n const query = new URLSearchParams(location.search);\n const doc = new DOMParser().parseFromString('', 'application/xml');\n const root = doc.firstElementChild;\n for (const p of query) {\n const newNode = doc.createElement(p[0]);\n newNode.appendChild(doc.createTextNode(p[1]));\n root.appendChild(newNode);\n }\n this.instanceData = doc;\n // this.instanceData.firstElementChild.setAttribute('id', this.id);\n // resolve('done');\n } else if (this.src) {\n await this._loadData();\n } else if (this.childNodes.length !== 0) {\n this._useInlineData();\n }\n }\n\n _createInstanceData() {\n if (this.type === 'xml') {\n // const doc = new DOMParser().parseFromString('', 'application/xml');\n const doc = new DOMParser().parseFromString('', 'application/xml');\n this.instanceData = doc;\n }\n if (this.type === 'json') {\n this.instanceData = {};\n }\n }\n\n async _loadData() {\n const url = `${this.src}`;\n const contentType = Fore.getContentType(this, 'get');\n\n await fetch(url, {\n method: 'GET',\n mode: 'cors',\n credentials: 'include',\n headers: {\n 'Content-Type': contentType,\n },\n })\n .then(response => {\n const status = response.status;\n if(status >= 400){\n console.log('response status', status);\n alert(`response status: ${status} - failed to load data for '${this.src}' - stopping.`);\n throw new Error(`failed to load data - status: ${status}`);\n }\n const responseContentType = response.headers.get('content-type').toLowerCase();\n console.log('********** responseContentType *********', responseContentType);\n if (responseContentType.startsWith('text/html')) {\n // const htmlResponse = response.text();\n // return new DOMParser().parseFromString(htmlResponse, 'text/html');\n // return response.text();\n return response.text().then(result =>\n // console.log('xml ********', result);\n new DOMParser().parseFromString(result, 'text/html'),\n );\n }\n if (\n responseContentType.startsWith('text/plain') ||\n responseContentType.startsWith('text/markdown')\n ) {\n // console.log(\"********** inside res plain *********\");\n return response.text();\n }\n if (responseContentType.startsWith('application/json')) {\n // console.log(\"********** inside res json *********\");\n return response.json();\n }\n if (responseContentType.startsWith('application/xml')) {\n return response.text().then(result =>\n // console.log('xml ********', result);\n new DOMParser().parseFromString(result, 'application/xml'),\n );\n }\n return 'done';\n })\n .then(data => {\n if (data.nodeType) {\n this.instanceData = data;\n console.log('instanceData loaded: ', this.instanceData);\n return;\n }\n this.instanceData = data;\n })\n .catch(error => {\n throw new Error(`failed loading data ${error}`);\n });\n }\n\n _getContentType() {\n if (this.type === 'xml') {\n return 'application/xml';\n }\n if (this.type === 'json') {\n return 'application/json';\n }\n console.warn('content-type unknown ', this.type);\n return null;\n }\n\n _useInlineData() {\n if (this.type === 'xml') {\n // console.log('innerHTML ', this.innerHTML);\n const instanceData = new DOMParser().parseFromString(this.innerHTML, 'application/xml');\n\n console.log('fx-instance init id:', this.id);\n this.instanceData = instanceData;\n // console.log('instanceData ', this.instanceData);\n // console.log('instanceData ', this.instanceData.firstElementChild);\n\n console.log('fx-instance data: ', this.instanceData);\n // this.instanceData.firstElementChild.setAttribute('id', this.id);\n // todo: move innerHTML out to shadowDOM (for later reset)\n } else if (this.type === 'json') {\n this.instanceData = JSON.parse(this.textContent);\n } else if (this.type === 'html') {\n this.instanceData = this.firstElementChild.children;\n } else if (this.type === 'text') {\n this.instanceData = this.textContent;\n } else {\n console.warn('unknow type for data ', this.type);\n }\n }\n\n _handleResponse() {\n console.log('_handleResponse ');\n const ajax = this.shadowRoot.getElementById('loader');\n const instanceData = new DOMParser().parseFromString(ajax.lastResponse, 'application/xml');\n this.instanceData = instanceData;\n console.log('data: ', this.instanceData);\n }\n\n _handleError() {\n const loader = this.shadowRoot.getElementById('loader');\n console.log('_handleResponse ', loader.lastError);\n }\n}\ncustomElements.define('fx-instance', FxInstance);\n","/**\n * Class for holding ModelItem facets.\n *\n * A ModelItem annotates nodes that are referred by a fx-bind element with facets for calculation and validation.\n *\n * Each bound node in an instance has exactly one ModelItem associated with it.\n */\nexport class ModelItem {\n /**\n *\n * @param {path} calculated normalized path expression linking to data\n * @param {ref} ref relative binding expression\n * @param {*} isReadonly - boolean to signal readonly/readwrite state\n * @param {*} relevant - boolean to signal relevant/non-relevant state\n * @param {*} required - boolean to signal required/optional state\n * @param {*} required - boolean boolean to signal valid/invalid state\n * @param {*} type - string expression to set a datatype\n * @param {*} node - the node the 'ref' expression is referring to\n * @param {*} bind - the fx-bind element having created this modelItem\n */\n constructor(path, ref, readonly, relevant, required, constraint, type, node, bind) {\n this.path = path;\n this.ref = ref;\n this.constraint = constraint;\n this.readonly = readonly;\n this.relevant = relevant;\n this.required = required;\n this.type = type;\n this.node = node;\n this.bind = bind;\n this.changed = false;\n this.alerts = [];\n this.boundControls = [];\n // this.value = this._getValue();\n }\n\n /*\n get ref(){\n return this.bind.ref;\n }\n*/\n\n get value() {\n if (!this.node.nodeType) return this.node;\n\n if (this.node.nodeType === Node.ATTRIBUTE_NODE) {\n return this.node.nodeValue;\n }\n return this.node.textContent;\n }\n\n set value(newVal) {\n console.log('modelitem.setvalue oldVal', this.value);\n console.log('modelitem.setvalue newVal', newVal);\n\n if (newVal.nodeType === Node.DOCUMENT_NODE) {\n // this.node.replaceWith(newVal.firstElementChild);\n this.node.appendChild(newVal.firstElementChild);\n } else if (newVal.nodeType === Node.ELEMENT_NODE) {\n // this.node.replaceWith(newVal);\n this.node.appendChild(newVal);\n } else if (this.node.nodeType === Node.ATTRIBUTE_NODE) {\n this.node.nodeValue = newVal;\n } else {\n this.node.textContent = newVal;\n }\n }\n\n addAlert(alert) {\n this.alerts.push(alert);\n }\n\n cleanAlerts() {\n this.alerts = [];\n }\n}\n","import { DepGraph } from './dep_graph.js';\nimport { Fore } from './fore.js';\nimport './fx-instance.js';\nimport { ModelItem } from './modelitem.js';\nimport { evaluateXPath, evaluateXPathToBoolean } from './xpath-evaluation.js';\nimport { XPathUtil } from './xpath-util.js';\n\n/**\n * @ts-check\n */\nexport class FxModel extends HTMLElement {\n constructor() {\n super();\n // this.id = '';\n\n this.instances = [];\n this.modelItems = [];\n this.defaultContext = {};\n this.changed = [];\n\n // this.mainGraph = new DepGraph(false);\n this.inited = false;\n this.modelConstructed = false;\n this.attachShadow({ mode: 'open' });\n this.computes = 0;\n }\n\n get formElement() {\n return this.parentElement;\n }\n\n connectedCallback() {\n // console.log('connectedCallback ', this);\n this.shadowRoot.innerHTML = `\n \n `;\n\n this.addEventListener('model-construct-done', e => {\n this.modelConstructed = true;\n // console.log('model-construct-done fired ', this.modelConstructed);\n console.log('model-construct-done fired ', e.detail.model.instances);\n });\n\n this.skipUpdate = false;\n }\n\n static lazyCreateModelItem(model, ref, node) {\n // console.log('lazyCreateModelItem ', node);\n\n let targetNode = {};\n if (node === null || node === undefined) return null;\n if (node.nodeType === node.TEXT_NODE) {\n // const parent = node.parentNode;\n // console.log('PARENT ', parent);\n targetNode = node.parentNode;\n } else {\n targetNode = node;\n }\n\n // const path = fx.evaluateXPath('path()',node);\n let path;\n if (node.nodeType) {\n path = XPathUtil.getPath(node);\n } else {\n path = null;\n targetNode = node;\n }\n // const path = XPathUtil.getPath(node);\n\n // ### intializing ModelItem with default values (as there is no matching for given ref)\n const mi = new ModelItem(\n path,\n ref,\n Fore.READONLY_DEFAULT,\n Fore.RELEVANT_DEFAULT,\n Fore.REQUIRED_DEFAULT,\n Fore.CONSTRAINT_DEFAULT,\n Fore.TYPE_DEFAULT,\n targetNode,\n this,\n );\n\n // console.log('new ModelItem is instanceof ModelItem ', mi instanceof ModelItem);\n model.registerModelItem(mi);\n return mi;\n }\n\n /**\n * modelConstruct starts actual processing of the model by\n *\n * 1. loading instances if present or constructing one\n * 2. calling updateModel to run the model update cycle of rebuild, recalculate and revalidate\n *\n * @event model-construct-done is fired once all instances have be loaded or after generating instance\n *\n */\n modelConstruct() {\n console.log('### <<<<< dispatching model-construct >>>>>');\n this.dispatchEvent(new CustomEvent('model-construct', { detail: this }));\n\n console.time('instance-loading');\n const instances = this.querySelectorAll('fx-instance');\n if (instances.length > 0) {\n console.group('init instances');\n const promises = [];\n instances.forEach(instance => {\n promises.push(instance.init());\n });\n\n Promise.all(promises).then(() => {\n this.instances = Array.from(instances);\n console.log('_modelConstruct this.instances ', this.instances);\n this.updateModel();\n this.inited = true;\n\n console.log('### <<<<< dispatching model-construct-done >>>>>');\n this.dispatchEvent(\n new CustomEvent('model-construct-done', {\n composed: true,\n bubbles: true,\n detail: { model: this },\n }),\n );\n });\n console.groupEnd();\n } else {\n // ### if there's no instance one will created\n this.dispatchEvent(\n new CustomEvent('model-construct-done', {\n composed: true,\n bubbles: true,\n detail: { model: this },\n }),\n );\n }\n console.timeEnd('instance-loading');\n this.inited = true;\n }\n\n registerModelItem(modelItem) {\n // console.log('ModelItem registered ', modelItem);\n this.modelItems.push(modelItem);\n }\n\n /**\n * update action triggering the update cycle\n */\n updateModel() {\n console.time('updateModel');\n this.rebuild();\n if(this.skipUpdate) return;\n this.recalculate();\n this.revalidate();\n console.timeEnd('updateModel');\n }\n\n rebuild() {\n console.group('### rebuild');\n console.time('rebuild');\n this.mainGraph = new DepGraph(false); //do: should be moved down below binds.length check but causes errors in tests.\n this.modelItems = [];\n\n // trigger recursive initialization of the fx-bind elements\n const binds = this.querySelectorAll('fx-model > fx-bind');\n if(binds.length === 0 ) {\n console.log('skipped model update');\n this.skipUpdate = true;\n return ;\n }\n\n binds.forEach(bind => {\n bind.init(this);\n });\n console.timeEnd('rebuild');\n\n // console.log(`dependencies of a `, this.mainGraph.dependenciesOf(\"/Q{}data[1]/Q{}a[1]:required\"));\n // console.log(`dependencies of b `, this.mainGraph.dependenciesOf(\"/Q{}data[1]/Q{}b[1]:required\"));\n console.log(`rebuild mainGraph`, this.mainGraph);\n console.log(`rebuild mainGraph calc order`, this.mainGraph.overallOrder());\n\n this.dispatchEvent(new CustomEvent('rebuild-done', { detail: { maingraph: this.mainGraph } }));\n\n /*\n console.log(\n `rebuild finished with modelItems ${this.modelItems.length} item(s)`,\n this.modelItems,\n );\n */\n console.groupEnd();\n }\n\n /**\n * recalculation of all modelItems. Uses dependency graph to determine order of computation.\n *\n * todo: use 'changed' flag on modelItems to determine subgraph for recalculation. Flag already exists but is not used.\n */\n recalculate() {\n console.group('### recalculate');\n console.log('changed nodes ', this.changed);\n\n console.time('recalculate');\n this.computes = 0;\n\n this.subgraph = new DepGraph(false);\n if (this.changed.length !== 0) {\n // ### build the subgraph\n this.changed.forEach(modelItem => {\n this.subgraph.addNode(modelItem.path, modelItem.node);\n // const dependents = this.mainGraph.dependantsOf(modelItem.path, false);\n // this._addSubgraphDependencies(modelItem.path);\n if (this.mainGraph.hasNode(modelItem.path)) {\n // const dependents = this.mainGraph.directDependantsOf(modelItem.path)\n\n const all = this.mainGraph.dependantsOf(modelItem.path, false);\n const dependents = all.reverse();\n if (dependents.length !== 0) {\n dependents.forEach(dep => {\n // const subdep = this.mainGraph.dependentsOf(dep,false);\n // subgraph.addDependency(dep, modelItem.path);\n const val = this.mainGraph.getNodeData(dep);\n this.subgraph.addNode(dep, val);\n if (dep.includes(':')) {\n const path = dep.substring(0, dep.indexOf(':'));\n this.subgraph.addNode(path, val);\n\n const deps = this.mainGraph.dependentsOf(modelItem.path, false);\n // if we find the dep to be first in list of dependents we are dependent on ourselves not adding edge to modelItem.path\n if (deps.indexOf(dep) !== 0) {\n this.subgraph.addDependency(dep, modelItem.path);\n }\n }\n // subgraph.addDependency(dep,modelItem.path);\n });\n }\n }\n });\n\n // ### compute the subgraph\n const ordered = this.subgraph.overallOrder(false);\n ordered.forEach(path => {\n if (this.mainGraph.hasNode(path)) {\n const node = this.mainGraph.getNodeData(path);\n this.compute(node, path);\n }\n });\n const toRefresh = [...this.changed];\n this.formElement.toRefresh = toRefresh;\n this.changed = [];\n console.log('subgraph', this.subgraph);\n this.dispatchEvent(\n new CustomEvent('recalculate-done', { detail: { subgraph: this.subgraph } }),\n );\n } else {\n const v = this.mainGraph.overallOrder(false);\n v.forEach(path => {\n const node = this.mainGraph.getNodeData(path);\n this.compute(node, path);\n });\n }\n console.log(`recalculated ${this.computes} modelItems`);\n\n console.timeEnd('recalculate');\n console.log(\n `recalculate finished with modelItems ${this.modelItems.length} item(s)`,\n this.modelItems,\n );\n console.groupEnd();\n }\n\n /*\n _addSubgraphDependencies(path){\n const dependents = this.mainGraph.directDependantsOf(path)\n\n const alreadyInGraph = this.subgraph.incomingEdges[path];\n // const alreadyInGraph = path in this.subgraph;\n if(dependents.length !== 0 && alreadyInGraph.length === 0){\n\n dependents.forEach(dep => {\n // const val= this.mainGraph.getNodeData(dep);\n // this.subgraph.addNode(dep,val);\n if(dep.includes(':')){\n const subpath = dep.substring(0, dep.indexOf(':'));\n // this.subgraph.addNode(subpath,val);\n this.subgraph.addDependency(subpath,dep);\n this.subgraph.addDependency(dep,path);\n /!*\n const subdeps = this.mainGraph.directDependantsOf(path);\n console.log('subdeps',path, subdeps);\n subdeps.forEach(sdep => {\n const sval= this.mainGraph.getNodeData(sdep);\n this.subgraph.addNode(sdep,sval);\n console.log('subdep',sdep);\n });\n *!/\n if(this.subgraph.incomingEdges[dep] === 0){\n this._addSubgraphDependencies(subpath)\n }\n\n }\n });\n\n }\n\n }\n*/\n\n /**\n * (re-) computes a modelItem.\n * @param node - the node the modelItem is attached to\n * @param path - the canonical XPath of the node\n */\n compute(node, path) {\n const modelItem = this.getModelItem(node);\n if (modelItem && path.includes(':')) {\n const property = path.split(':')[1];\n if (property) {\n /*\n if (property === 'readonly') {\n // make sure that calculated items are always readonly\n if(modelItem.bind['calculate']){\n modelItem.readonly = true;\n }else {\n const expr = modelItem.bind[property];\n const compute = evaluateXPathToBoolean(expr, modelItem.node, this);\n modelItem.readonly = compute;\n }\n }\n*/\n if (property === 'calculate') {\n const expr = modelItem.bind[property];\n const compute = evaluateXPath(expr, modelItem.node, this);\n modelItem.value = compute;\n modelItem.readonly = true; // calculated nodes are always readonly\n } else if (property !== 'constraint' && property !== 'type') {\n const expr = modelItem.bind[property];\n if (expr) {\n const compute = evaluateXPathToBoolean(expr, modelItem.node, this);\n modelItem[property] = compute;\n console.log(\n `recalculating path ${path} - Expr:'${expr}' computed`,\n modelItem[property],\n );\n }\n }\n }\n this.computes += 1;\n }\n }\n\n /**\n * Iterates all modelItems to calculate the validation status.\n *\n * Model alerts are given on 'fx-bind' elements as either attribute `alert` or as `fx-alert` child elements.\n *\n * During model-construct all model alerts are added to the modelItem if any\n *\n * to revalidate:\n * Gets the `constraint` attribute declaration from modelItem.bind\n * Computes the XPath to a Boolean\n * Updates the modelItem.constraint property\n *\n * todo: type checking\n * todo: run browser validation API\n *\n */\n revalidate() {\n console.group('### revalidate');\n\n console.time('revalidate');\n let valid = true;\n this.modelItems.forEach(modelItem => {\n // console.log('validating node ', modelItem.node);\n\n const { bind } = modelItem;\n if (bind) {\n /*\n todo: investigate why bind is an element when created in fx-bind.init() and an fx-bind object when\n created lazily.\n */\n if (typeof bind.hasAttribute === 'function' && bind.hasAttribute('constraint')) {\n const constraint = bind.getAttribute('constraint');\n if (constraint) {\n const compute = evaluateXPathToBoolean(constraint, modelItem.node, this);\n console.log('modelItem validity computed: ', compute);\n modelItem.constraint = compute;\n this.formElement.addToRefresh(modelItem); // let fore know that modelItem needs refresh\n if (!compute) valid = false;\n // ### alerts are added only once during model-construct. Otherwise they would add up in each run of revalidate()\n if (!this.modelConstructed) {\n // todo: get alert from attribute or child element\n const alert = bind.getAlert();\n if (alert) {\n modelItem.addAlert(alert);\n }\n }\n }\n }\n }\n });\n console.timeEnd('revalidate');\n console.log('modelItems after revalidate: ', this.modelItems);\n console.groupEnd();\n return valid;\n }\n\n /**\n *\n * @param node\n * @returns {ModelItem}\n */\n getModelItem(node) {\n return this.modelItems.find(m => m.node === node);\n }\n\n /**\n * get the default evaluation context for this model.\n * @returns {Element} the\n */\n getDefaultContext() {\n return this.instances[0].getDefaultContext();\n }\n\n getDefaultInstance() {\n return this.instances[0];\n }\n\n getDefaultInstanceData() {\n console.log('default instance data ', this.instances[0].instanceData);\n return this.instances[0].instanceData;\n }\n\n getInstance(id) {\n // console.log('getInstance ', id);\n // console.log('instances ', this.instances);\n // console.log('instances array ',Array.from(this.instances));\n\n const instArray = Array.from(this.instances);\n return instArray.find(inst => inst.id === id);\n }\n\n evalBinding(bindingExpr) {\n // console.log('MODEL.evalBinding ', bindingExpr);\n // default context of evaluation is always the default instance\n const result = this.instances[0].evalXPath(bindingExpr);\n return result;\n }\n}\n\ncustomElements.define('fx-model', FxModel);\n","import { evaluateXPathToFirstNode } from './xpath-evaluation.js';\n\nimport { XPathUtil } from './xpath-util.js';\n\n\nfunction _getElement(node) {\n if (node && node.nodeType && node.nodeType === Node.ATTRIBUTE_NODE) {\n // The context of an attribute is the ref of the element it's defined on\n return node.ownerElement;\n }\n\n\n if (node.nodeType === Node.ELEMENT_NODE) {\n // The context of a query should be the element having a ref\n return node;\n }\n\n // For text nodes, just start looking from the parent element\n return node.parentNode;\n}\n\nfunction _getForeContext(node) {\n return node.closest('fx-fore');\n}\n\nfunction _getModelInContext(node) {\n // const ownerForm = node.closest('fx-fore');\n const ownerForm = _getForeContext(node);\n return ownerForm.getModel();\n}\n\nfunction _getInitialContext(node, ref) {\n const parentBind = node.closest('[ref]');\n\n if (parentBind !== null) {\n return parentBind.nodeset;\n }\n\n const model = _getModelInContext(node);\n if (XPathUtil.isAbsolutePath(ref)) {\n const instanceId = XPathUtil.getInstanceId(ref);\n if(instanceId){\n return model.getInstance(instanceId).getDefaultContext();\n }\n return model.getDefaultInstance().getDefaultContext();\n }\n if (model.getDefaultInstance() !== null && model.inited) {\n return model.getDefaultInstance().getDefaultContext();\n }\n return [];\n}\n\nexport default function getInScopeContext(node, ref) {\n const parentElement = _getElement(node);\n /*\n if(parentElement.nodeName.toUpperCase() === 'FX-REPEATITEM'){\n return parentElement.nodeset;\n }\n*/\n\n const repeatItem = parentElement.closest('fx-repeatitem');\n if (repeatItem) {\n if(node.nodeName === 'context'){\n return evaluateXPathToFirstNode(node.nodeValue, repeatItem.nodeset, _getForeContext(parentElement));\n }\n return repeatItem.nodeset;\n }\n\n if (parentElement.hasAttribute('context')) {\n const initialContext = _getInitialContext(node.ownerElement.parentNode, ref);\n const contextAttr = node.ownerElement.getAttribute('context');\n return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));\n }\n\n if (node.nodeType === Node.ATTRIBUTE_NODE && node.nodeName === 'context') {\n const initialContext = _getInitialContext(node.ownerElement.parentNode, ref);\n const contextAttr = node.ownerElement.getAttribute('context');\n return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));\n }\n if (node.nodeType === Node.ATTRIBUTE_NODE && node.nodeName === 'ref') {\n // Note: do not consider the ref of the owner element since it should not be used to define the\n // context\n if (node.ownerElement.hasAttribute('context')) {\n const initialContext = _getInitialContext(node.ownerElement.parentNode, ref);\n const contextAttr = node.ownerElement.getAttribute('context');\n return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));\n }\n\n // Never resolve the context from a ref itself!\n return _getInitialContext(parentElement.parentNode, ref);\n }\n\n // if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute('context')) {\n // const initialContext = _getInitialContext(node.parentNode, ref);\n // const contextAttr = node.getAttribute('context');\n // return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));\n // }\n return _getInitialContext(parentElement, ref);\n}\n","import { XPathUtil } from './xpath-util.js';\nimport { FxModel } from './fx-model.js';\nimport {\n evaluateXPath,\n evaluateXPathToFirstNode,\n evaluateXPathToString,\n} from './xpath-evaluation.js';\nimport getInScopeContext from './getInScopeContext.js';\n\n/**\n * Mixin containing all general functions that are shared by all Fore element classes.\n * @param superclass\n * @returns {{readonly properties: {ref: {type: StringConstructor}, context: {type: ObjectConstructor}, nodeset: {type: ObjectConstructor}, model: {type: ObjectConstructor}, inScopeVariables: {type: MapConstructor}, modelItem: {type: ObjectConstructor}}, new(): ForeElementMixin, context: null, model: null, modelItem: {}, ref: *|string, inScopeVariables: null, nodeset: *, prototype: ForeElementMixin}}\n */\nexport const foreElementMixin = superclass =>\n class ForeElementMixin extends superclass {\n static get properties() {\n return {\n /**\n * context object for evaluation\n */\n context: {\n type: Object,\n },\n /**\n * the model of this element\n */\n model: {\n type: Object,\n },\n /**\n * The modelitem object associated to the bound node holding the evaluated state.\n */\n modelItem: {\n type: Object,\n },\n /**\n * the node(s) bound by this element\n */\n nodeset: {\n type: Object,\n },\n /**\n * XPath binding expression pointing to bound node\n */\n ref: {\n type: String,\n },\n inScopeVariables: {\n type: Map,\n },\n };\n }\n\n constructor() {\n super();\n this.context = null;\n this.model = null;\n this.modelItem = {};\n this.ref = this.hasAttribute('ref') ? this.getAttribute('ref') : '';\n this.inScopeVariables = null;\n }\n\n getModel() {\n // console.log('getModel this ', this);\n if (this.model) {\n return this.model;\n }\n // const ownerForm = this.closest('fx-fore');\n // const ownerForm = this.getOwnerForm(this);\n const ownerForm = this.getOwnerForm();\n return ownerForm.querySelector('fx-model');\n }\n\n /**\n *\n * @returns {{parentNode}|ForeElementMixin}\n */\n getOwnerForm() {\n let currentElement = this;\n while (currentElement && currentElement.parentNode) {\n // console.log('current ', currentElement);\n\n if (currentElement.nodeName.toUpperCase() === 'FX-FORE') {\n return currentElement;\n }\n\n if (currentElement.parentNode instanceof DocumentFragment) {\n currentElement = currentElement.parentNode.host;\n } else {\n currentElement = currentElement.parentNode;\n }\n }\n return currentElement;\n }\n\n /**\n * evaluation of fx-bind and UiElements differ in details so that each class needs it's own implementation.\n */\n evalInContext() {\n // const inscopeContext = this.getInScopeContext();\n let inscopeContext;\n if(this.hasAttribute('context')){\n inscopeContext = getInScopeContext(this.getAttributeNode('context') || this, this.context);\n }\n if(this.hasAttribute('ref')){\n inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);\n }\n if (!inscopeContext) {\n // ### always fall back to default context with there's neither a 'context' or 'ref' present\n inscopeContext = this.getModel().getDefaultInstance().getDefaultContext();\n console.warn('no in scopeContext for ', this);\n console.warn('using default context ', this);\n // return;\n }\n if (this.ref === '') {\n this.nodeset = inscopeContext;\n } else if (Array.isArray(inscopeContext)) {\n /*\n inscopeContext.forEach(n => {\n if (XPathUtil.isSelfReference(this.ref)) {\n this.nodeset = inscopeContext;\n } else {\n const localResult = evaluateXPathToFirstNode(this.ref, n, this);\n // console.log('local result: ', localResult);\n this.nodeset.push(localResult);\n }\n });\n*/\n this.nodeset = evaluateXPathToFirstNode(this.ref, inscopeContext[0], this);\n } else {\n // this.nodeset = fx.evaluateXPathToFirstNode(this.ref, inscopeContext, null, {namespaceResolver: this.namespaceResolver});\n const { nodeType } = inscopeContext;\n if (nodeType) {\n this.nodeset = evaluateXPathToFirstNode(this.ref, inscopeContext, this);\n } else {\n this.nodeset = evaluateXPath(this.ref, inscopeContext, this);\n }\n }\n // console.log('UiElement evaluated to nodeset: ', this.nodeset);\n }\n\n isNotBound() {\n return !this.hasAttribute('ref');\n }\n\n isBound() {\n return this.hasAttribute('ref');\n }\n\n getBindingExpr() {\n if (this.hasAttribute('ref')) {\n return this.getAttribute('ref');\n }\n // try to get closest parent bind\n const parent = this.parentNode.closest('[ref]');\n if (!parent) {\n return 'instance()'; // the default instance\n }\n return parent.getAttribute('ref');\n }\n\n getInstance() {\n if (this.ref.startsWith('instance(')) {\n const instId = XPathUtil.getInstanceId(this.ref);\n return this.getModel().getInstance(instId);\n }\n return this.getModel().getInstance('default');\n }\n\n _getParentBindingElement(start) {\n if (start.parentNode.host) {\n const { host } = start.parentNode;\n if (host.hasAttribute('ref')) {\n return host;\n }\n } else if (start.parentNode) {\n if (start.parentNode.hasAttribute('ref')) {\n return this.parentNode;\n }\n this._getParentBindingElement(this.parentNode);\n }\n return null;\n }\n\n getModelItem() {\n // return this.model.bindingMap.find(m => m.refnode === this.nodeset);\n // return this.getModel().bindingMap.find(m => m.refnode === this.nodeset);\n\n const mi = this.getModel().getModelItem(this.nodeset);\n if (mi) {\n this.modelItem = mi;\n }\n\n const repeated = this.closest('fx-repeatitem');\n let existed;\n if (repeated) {\n const { index } = this.closest('fx-repeatitem');\n if (Array.isArray(this.nodeset)) {\n existed = this.getModel().getModelItem(this.nodeset[index - 1]);\n } else {\n existed = this.getModel().getModelItem(this.nodeset);\n }\n } else {\n existed = this.getModel().getModelItem(this.nodeset);\n }\n\n if (!existed) {\n return FxModel.lazyCreateModelItem(this.getModel(), this.ref, this.nodeset);\n }\n return existed;\n }\n\n /**\n * Returns the effective value for the element.\n * a: look for 'value' attribute and if present evaluate it and return the resulting value\n * b: look for textContent and return the value if present\n * c: return null\n */\n getValue() {\n if (this.hasAttribute('value')) {\n const valAttr = this.getAttribute('value');\n try {\n const inscopeContext = getInScopeContext(this, valAttr);\n return evaluateXPathToString(valAttr, inscopeContext, this.getOwnerForm());\n } catch (error) {\n console.error(error);\n this.dispatch('error', { message: error });\n }\n }\n if (this.textContent) {\n return this.textContent;\n }\n return null;\n }\n\n getInScopeContext() {\n return getInScopeContext(this.getAttributeNode('ref') || this, this.ref);\n }\n\n setInScopeVariables(inScopeVariables) {\n this.inScopeVariables = inScopeVariables;\n }\n\n dispatch(eventName, detail) {\n const event = new CustomEvent(eventName, {\n composed: true,\n bubbles: true,\n detail,\n });\n // console.log('firing', event);\n this.dispatchEvent(event);\n }\n };\n","import { DependencyNotifyingDomFacade } from './DependencyNotifyingDomFacade.js';\nimport { foreElementMixin } from './ForeElementMixin.js';\nimport { ModelItem } from './modelitem.js';\nimport {\n evaluateXPathToBoolean,\n evaluateXPathToNodes,\n evaluateXPathToString,\n} from './xpath-evaluation.js';\nimport { XPathUtil } from './xpath-util.js';\nimport getInScopeContext from './getInScopeContext.js';\n\n/**\n * FxBind declaratively attaches constraints to nodes in the data (instances).\n *\n * It's major task is to create ModelItem Objects for each Node in the data their ref is pointing to.\n *\n * References and constraint attributes use XPath statements to point to the nodes they are attributing.\n *\n * Note: why is fx-bind not extending BoundElement? Though fx-bind has a 'ref' attr it is not bound in the sense of\n * getting updates about changes of the bound nodes. Instead it acts as a factory for modelItems that are used by\n * BoundElements to track their state.\n */\n// export class FxBind extends HTMLElement {\nexport class FxBind extends foreElementMixin(HTMLElement) {\n static READONLY_DEFAULT = false;\n\n static REQUIRED_DEFAULT = false;\n\n static RELEVANT_DEFAULT = true;\n\n static CONSTRAINT_DEFAULT = true;\n\n static TYPE_DEFAULT = 'xs:string';\n\n /*\n static get styles() {\n return css`\n :host {\n display: none;\n }\n `;\n }\n*/\n\n /*\n static get properties() {\n return {\n ...super.properties,\n\n /!**\n * allows to calculate a value. This value will become readonly.\n *!/\n calculate: {\n type: String\n },\n contextNode:{\n type:Object\n },\n /!**\n * arbitrary XPath resolving to xs:boolean - defaults to 'true()'\n *!/\n constraint: {\n type: String\n },\n /!**\n * id of this bind\n *!/\n id:{\n type:String\n },\n /!**\n * the nodeset the bind is referring to by it's binding expression (ref attribute)\n *!/\n nodeset: {\n type: Array\n },\n /!**\n * the owning model of this bind\n *!/\n model:{\n type:Object\n },\n /!**\n * XPath statement resolving to xs:boolean to switch between readonly and readwrite mode - defaults to 'false()'\n *!/\n readonly: {\n type: String\n },\n /!**\n * the XPath binding expression of this bind\n *!/\n ref: {\n type: String\n },\n /!**\n * XPath statement resolving to xs:boolean to switch between relevant and non-relevant mode - defaults to 'true()'\n *!/\n relevant: {\n type: String\n },\n /!**\n * XPath statement resolving to xs:boolean to switch between required and optional - defaults to 'false'.\n *!/\n required: {\n type: String\n },\n /!**\n * XPath statement\n *!/\n type: {\n type: String\n }\n };\n }\n*/\n\n constructor() {\n super();\n // this.id='';\n // this.ref = '';\n // this.readonly = 'false()';\n // this.required = 'false()';\n // this.relevant = 'true()';\n // this.constraint = 'true()';\n // this.type = 'xs:string';\n // this.calculate = '';\n this.nodeset = [];\n this.model = {};\n this.contextNode = {};\n this.inited = false;\n }\n\n connectedCallback() {\n // console.log('connectedCallback ', this);\n // this.id = this.hasAttribute('id')?this.getAttribute('id'):;\n this.ref = this.getAttribute('ref');\n this.readonly = this.getAttribute('readonly');\n this.required = this.getAttribute('required');\n this.relevant = this.getAttribute('relevant');\n this.type = this.hasAttribute('type') ? this.getAttribute('type') : FxBind.TYPE_DEFAULT;\n this.calculate = this.getAttribute('calculate');\n }\n\n /**\n * initializes the bind element by evaluating the binding expression.\n *\n * For each node referred to by the binding expr a ModelItem object is created.\n *\n * @param model\n */\n init(model) {\n this.model = model;\n console.log('init binding ', this);\n this.instanceId = this._getInstanceId();\n this.bindType = this.getModel().getInstance(this.instanceId).type;\n // console.log('binding type ', this.bindType);\n\n if (this.bindType === 'xml') {\n this._evalInContext();\n this._buildBindGraph();\n this._createModelItems();\n }\n\n // ### process child bindings\n this._processChildren(model);\n }\n\n /*\n //todo: certainly not ideal to rely on duplicating instance id on instance document - better way later ;)\n static getPath(node){\n let path = fx.evaluateXPath('path()',node);\n const instanceId = node.ownerDocument.firstElementChild.getAttribute('id');\n if(instanceId !== 'default'){\n return '#' + instanceId + FxBind.shortenPath(path);\n }else {\n return FxBind.shortenPath(path);\n }\n\n }\n*/\n\n _buildBindGraph() {\n if (this.bindType === 'xml') {\n this.nodeset.forEach(node => {\n const path = XPathUtil.getPath(node);\n this.model.mainGraph.addNode(path, node);\n\n if (this.calculate) {\n this.model.mainGraph.addNode(`${path}:calculate`, node);\n // Calculated values are a dependency of the model item.\n this.model.mainGraph.addDependency(path, `${path}:calculate`);\n }\n\n const calculateRefs = this._getReferencesForProperty(this.calculate, node);\n if (calculateRefs.length !== 0) {\n this._addDependencies(calculateRefs, node, path, 'calculate');\n }\n\n if (!this.calculate) {\n const readonlyRefs = this._getReferencesForProperty(this.readonly, node);\n if (readonlyRefs.length !== 0) {\n this._addDependencies(readonlyRefs, node, path, 'readonly');\n } else if (this.readonly) {\n this.model.mainGraph.addNode(`${path}:readonly`, node);\n }\n }\n\n // const requiredRefs = this.requiredReferences;\n const requiredRefs = this._getReferencesForProperty(this.required, node);\n if (requiredRefs.length !== 0) {\n this._addDependencies(requiredRefs, node, path, 'required');\n } else if (this.required) {\n this.model.mainGraph.addNode(`${path}:required`, node);\n }\n\n const relevantRefs = this._getReferencesForProperty(this.relevant, node);\n if (relevantRefs.length !== 0) {\n this._addDependencies(relevantRefs, node, path, 'relevant');\n } else if (this.relevant) {\n this.model.mainGraph.addNode(`${path}:relevant`, node);\n }\n\n const constraintRefs = this._getReferencesForProperty(this.constraint, node);\n if (constraintRefs.length !== 0) {\n this._addDependencies(constraintRefs, node, path, 'constraint');\n } else if (this.constraint) {\n this.model.mainGraph.addNode(`${path}:constraint`, node);\n }\n });\n }\n }\n\n /**\n * Add the dependencies of this bind\n *\n * @param {Node[]} refs The nodes that are referenced by this bind. these need to be resolved before\n * this bind can be resolved.\n * @param {Node} node The start of the reference\n * @param {string} path The path to the start of the reference\n * @param {string} property The property with this dependency\n */\n _addDependencies(refs, node, path, property) {\n // console.log('_addDependencies',path);\n const nodeHash = `${path}:${property}`;\n if (refs.length !== 0) {\n if (!this.model.mainGraph.hasNode(nodeHash)) {\n this.model.mainGraph.addNode(nodeHash, node);\n }\n refs.forEach(ref => {\n const otherPath = XPathUtil.getPath(ref);\n // console.log('otherPath', otherPath)\n\n // todo: nasty hack to prevent duplicate pathes like 'a[1]' and 'a[1]/text()[1]' to end up as separate nodes in the graph\n if (!otherPath.endsWith('text()[1]')) {\n if (!this.model.mainGraph.hasNode(otherPath)) {\n this.model.mainGraph.addNode(otherPath, ref);\n }\n this.model.mainGraph.addDependency(nodeHash, otherPath);\n }\n });\n } else {\n this.model.mainGraph.addNode(nodeHash, node);\n }\n }\n\n _processChildren(model) {\n const childbinds = this.querySelectorAll(':scope > fx-bind');\n Array.from(childbinds).forEach(bind => {\n // console.log('init child bind ', bind);\n bind.init(model);\n });\n }\n\n /*\n render() {\n return html`\n \n `;\n }\n*/\n\n getAlert() {\n if (this.hasAttribute('alert')) {\n return this.getAttribute('alert');\n }\n const alertChild = this.querySelector('fx-alert');\n if (alertChild) {\n return alertChild.innerHTML;\n }\n return null;\n }\n\n /*\n firstUpdated(_changedProperties) {\n super.firstUpdated(_changedProperties);\n }\n */\n\n /*\n namespaceResolver(prefix) {\n // TODO: Do proper namespace resolving. Look at the ancestry / namespacesInScope of the declaration\n\n /!**\n * for (let ancestor = this; ancestor; ancestor = ancestor.parentNode) {\n * \tif (ancestor.getAttribute(`xmlns:${prefix}`)) {\n * // Return value\n * }\n * }\n *!/\n\n // console.log('namespaceResolver prefix', prefix);\n const ns = {\n xhtml: 'http://www.w3.org/1999/xhtml',\n // '' : Fore.XFORMS_NAMESPACE_URI\n };\n return ns[prefix] || null;\n }\n*/\n\n /**\n * overwrites\n */\n _evalInContext() {\n const inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);\n\n // reset nodeset\n this.nodeset = [];\n\n if (this.ref === '' || this.ref === null) {\n this.nodeset = inscopeContext;\n } else if (Array.isArray(inscopeContext)) {\n inscopeContext.forEach(n => {\n if (XPathUtil.isSelfReference(this.ref)) {\n this.nodeset = inscopeContext;\n } else {\n // eslint-disable-next-line no-lonely-if\n if (this.ref) {\n const localResult = evaluateXPathToNodes(this.ref, n, this);\n localResult.forEach(item => {\n this.nodeset.push(item);\n });\n /*\n const localResult = fx.evaluateXPathToFirstNode(this.ref, n, null, {namespaceResolver: this.namespaceResolver});\n this.nodeset.push(localResult);\n */\n }\n // console.log('local result: ', localResult);\n // this.nodeset.push(localResult);\n }\n });\n } else {\n const inst = this.getModel().getInstance(this.instanceId);\n if (inst.type === 'xml') {\n this.nodeset = evaluateXPathToNodes(this.ref, inscopeContext, this);\n } else {\n this.nodeset = this.ref;\n }\n }\n }\n\n _createModelItems() {\n // console.log('#### ', thi+s.nodeset);\n\n /*\n if(XPathUtil.isSelfReference(this.ref)){\n return;\n }\n */\n if (Array.isArray(this.nodeset)) {\n // todo - iterate and create\n // console.log('################################################ ', this.nodeset);\n // Array.from(this.nodeset).forEach((n, index) => {\n Array.from(this.nodeset).forEach(n => {\n // console.log('node ',n);\n // this._createModelItem(n, index);\n this._createModelItem(n);\n });\n } else {\n this._createModelItem(this.nodeset);\n }\n }\n\n static lazyCreateModelitems(model, ref, nodeset) {\n if (Array.isArray(nodeset)) {\n Array.from(nodeset).forEach(n => {\n FxBind.lazyCreateModelItem(model, ref, n);\n });\n } else {\n FxBind.lazyCreateModelItem(model, ref, nodeset);\n }\n }\n\n /*\n static lazyCreateModelItem(model,ref,node){\n console.log('lazyCreateModelItem ', node);\n\n let mItem = {};\n let targetNode = {};\n if(node === null) return null;\n if(node.nodeType === node.TEXT_NODE){\n // const parent = node.parentNode;\n // console.log('PARENT ', parent);\n targetNode = node.parentNode;\n }else {\n targetNode = node;\n }\n\n // const path = fx.evaluateXPath('path()',node);\n const path = FxBind.getPath(node);\n\n // const path = Fore.evaluateXPath ('path()', node, this, Fore.namespaceResolver) ;\n\n // ### intializing ModelItem with default values (as there is no matching for given ref)\n const mi = new ModelItem(path,\n ref,\n FxBind.READONLY_DEFAULT,\n FxBind.RELEVANT_DEFAULT,\n FxBind.REQUIRED_DEFAULT,\n FxBind.CONSTRAINT_DEFAULT,\n FxBind.TYPE_DEFAULT,\n targetNode,\n this);\n\n\n // console.log('new ModelItem is instanceof ModelItem ', mi instanceof ModelItem);\n model.registerModelItem(mi);\n return mi;\n }\n*/\n\n /**\n * creates a ModelItem for given instance node.\n *\n * Please note that for textnode no ModelItem is created but instead the one of its parent is used which either\n * must exist and be initialized already when we hit the textnode.\n * @param node\n * @private\n */\n // _createModelItem(node, index) {\n _createModelItem(node) {\n // console.log('_createModelItem node', node, index);\n\n /*\n this.calculateReferences = this._getReferencesForProperty(this.calculate,node);\n this.readOnlyReferences = this._getReferencesForProperty(this.readonly,node);\n this.requiredReferences = this._getReferencesForProperty(this.required,node);\n this.relevantReferences = this._getReferencesForProperty(this.relevant,node);\n this.constraintReferences = this._getReferencesForProperty(this.constraint,node);\n */\n\n /*\n if bind is the dot expression we use the modelitem of the parent\n */\n if (XPathUtil.isSelfReference(this.ref)) {\n const parentBoundElement = this.parentElement.closest('fx-bind[ref]');\n console.log('parent bound element ', parentBoundElement);\n\n if (parentBoundElement) {\n // todo: Could be fancier by combining them\n parentBoundElement.required = this.required; // overwrite parent property!\n } else {\n console.error('no parent bound element');\n }\n\n return;\n }\n\n // let value = null;\n // const mItem = {};\n /*\n let targetNode = {};\n if (node.nodeType === node.TEXT_NODE) {\n // const parent = node.parentNode;\n // console.log('PARENT ', parent);\n targetNode = node.parentNode;\n } else {\n targetNode = node;\n }\n*/\n const targetNode = node;\n\n // const path = fx.evaluateXPath('path()',node);\n // const path = this.getPath(node);\n const path = XPathUtil.getPath(node);\n // const shortPath = this.shortenPath(path);\n\n // ### constructiong default modelitem - will get evaluated during reaalculate()\n // ### constructiong default modelitem - will get evaluated during reaalculate()\n // ### constructiong default modelitem - will get evaluated during reaalculate()\n // const newItem = new ModelItem(shortPath,\n const newItem = new ModelItem(\n path,\n this.getBindingExpr(),\n FxBind.READONLY_DEFAULT,\n FxBind.RELEVANT_DEFAULT,\n FxBind.REQUIRED_DEFAULT,\n FxBind.CONSTRAINT_DEFAULT,\n this.type,\n targetNode,\n this,\n );\n\n this.getModel().registerModelItem(newItem);\n }\n\n /**\n * Get the nodes that are referred by the given XPath expression\n *\n * @param {string} propertyExpr The XPath to get the referenced nodes from\n *\n * @return {Node[]} The nodes that are referenced by the XPath\n *\n * todo: DependencyNotifyingDomFacade reports back too much in some cases like 'a[1]' and 'a[1]/text[1]'\n */\n _getReferencesForProperty(propertyExpr) {\n if (propertyExpr) {\n const touchedNodes = new Set();\n const domFacade = new DependencyNotifyingDomFacade(otherNode => touchedNodes.add(otherNode));\n this.nodeset.forEach(node => {\n evaluateXPathToString(propertyExpr, node, this, domFacade);\n });\n\n return Array.from(touchedNodes.values());\n }\n return [];\n }\n\n _initBooleanModelItemProperty(property, node) {\n // evaluate expression to boolean\n const propertyExpr = this[property];\n // console.log('####### ', propertyExpr);\n const result = evaluateXPathToBoolean(propertyExpr, node, this);\n return result;\n }\n\n static shortenPath(path) {\n const steps = path.split('/');\n let result = '';\n for (let i = 2; i < steps.length; i += 1) {\n const step = steps[i];\n if (step.indexOf('{}') !== -1) {\n const q = step.split('{}');\n result += `/${q[1]}`;\n } else {\n result += `/${step}`;\n }\n }\n return result;\n }\n\n // todo: more elaborated implementation ;)\n _getInstanceId() {\n const bindExpr = this.getBindingExpr();\n // console.log('_getInstanceId bindExpr ', bindExpr);\n if (bindExpr.startsWith('instance(')) {\n this.instanceId = XPathUtil.getInstanceId(bindExpr);\n return this.instanceId;\n }\n if (this.instanceId) {\n return this.instanceId;\n }\n return 'default';\n }\n}\ncustomElements.define('fx-bind', FxBind);\n","/*!\n * Toastify js 1.11.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n/**\n * Options used for Toastify\n * @typedef {Object} ToastifyConfigurationObject\n * @property {string} text - Message to be displayed in the toast\n * @property {Element} node - Provide a node to be mounted inside the toast. node takes higher precedence over text\n * @property {number} duration - Duration for which the toast should be displayed. -1 for permanent toast\n * @property {string|Element} selector - CSS ID Selector on which the toast should be added\n * @property {url} destination - URL to which the browser should be navigated on click of the toast\n * @property {boolean} newWindow - Decides whether the destination should be opened in a new window or not\n * @property {boolean} close - To show the close icon or not\n * @property {string} gravity - To show the toast from top or bottom\n * @property {string} position - To show the toast on left or right\n * @property {string} backgroundColor - Deprecated: Sets the background color of the toast\n * @property {url} avatar - Image/icon to be shown before text\n * @property {string} className - Ability to provide custom class name for further customization\n * @property {boolean} stopOnFocus - To stop timer when hovered over the toast (Only if duration is set)\n * @property {Function} callback - Invoked when the toast is dismissed\n * @property {Function} onClick - Invoked when the toast is clicked\n * @property {Object} offset - Ability to add some offset to axis\n * @property {boolean} escapeMarkup - Toggle the default behavior of escaping HTML markup\n * @property {Object} style - Use the HTML DOM style property to add styles to toast\n */\n\n\nclass Toastify {\n\n defaults = {\n oldestFirst: true,\n text: \"Toastify is awesome!\",\n node: undefined,\n duration: 3000,\n selector: undefined,\n callback: function() {},\n destination: undefined,\n newWindow: false,\n close: false,\n gravity: \"toastify-top\",\n positionLeft: false,\n position: \"\",\n backgroundColor: \"\",\n avatar: \"\",\n className: \"\",\n stopOnFocus: true,\n onClick: function() {},\n offset: { x: 0, y: 0 },\n escapeMarkup: true,\n style: { background: \"\" },\n };\n\n constructor(options) {\n /**\n * The version of Toastify\n * @type {string}\n * @public\n */\n this.version = \"1.11.0\";\n\n /**\n * The configuration object to configure Toastify\n * @type {ToastifyConfigurationObject}\n * @public\n */\n this.options = {};\n\n /**\n * The element that is the Toast\n * @type {Element}\n * @public\n */\n this.toastElement = null;\n\n /**\n * The root element that contains all the toasts\n * @type {Element}\n * @private\n */\n this._rootElement = document.body;\n\n this._init(options);\n }\n\n /**\n * Display the toast\n * @public\n */\n showToast() {\n // Creating the DOM object for the toast\n this.toastElement = this._buildToast();\n\n // Getting the root element to with the toast needs to be added\n if (typeof this.options.selector === \"string\") {\n this._rootElement = document.getElementById(this.options.selector);\n } else if (this.options.selector instanceof HTMLElement || this.options.selector instanceof ShadowRoot) {\n this._rootElement = this.options.selector;\n } else {\n this._rootElement = document.body;\n }\n\n // Validating if root element is present in DOM\n if (!this._rootElement) {\n throw \"Root element is not defined\";\n }\n\n // Adding the DOM element\n this._rootElement.insertBefore(this.toastElement, this._rootElement.firstChild);\n\n // Repositioning the toasts in case multiple toasts are present\n this._reposition();\n\n if (this.options.duration > 0) {\n this.toastElement.timeOutValue = window.setTimeout(\n () => {\n // Remove the toast from DOM\n this._removeElement(this.toastElement);\n },\n this.options.duration\n ); // Binding `this` for function invocation\n }\n\n // Supporting function chaining\n return this;\n }\n\n /**\n * Hide the toast\n * @public\n */\n hideToast() {\n if (this.toastElement.timeOutValue) {\n clearTimeout(this.toastElement.timeOutValue);\n }\n this._removeElement(this.toastElement);\n }\n\n /**\n * Init the Toastify class\n * @param {ToastifyConfigurationObject} options - The configuration object to configure Toastify\n * @param {string} [options.text=Hi there!] - Message to be displayed in the toast\n * @param {Element} [options.node] - Provide a node to be mounted inside the toast. node takes higher precedence over text\n * @param {number} [options.duration=3000] - Duration for which the toast should be displayed. -1 for permanent toast\n * @param {string} [options.selector] - CSS Selector on which the toast should be added\n * @param {url} [options.destination] - URL to which the browser should be navigated on click of the toast\n * @param {boolean} [options.newWindow=false] - Decides whether the destination should be opened in a new window or not\n * @param {boolean} [options.close=false] - To show the close icon or not\n * @param {string} [options.gravity=toastify-top] - To show the toast from top or bottom\n * @param {string} [options.position=right] - To show the toast on left or right\n * @param {string} [options.backgroundColor] - Sets the background color of the toast (To be deprecated)\n * @param {url} [options.avatar] - Image/icon to be shown before text\n * @param {string} [options.className] - Ability to provide custom class name for further customization\n * @param {boolean} [options.stopOnFocus] - To stop timer when hovered over the toast (Only if duration is set)\n * @param {Function} [options.callback] - Invoked when the toast is dismissed\n * @param {Function} [options.onClick] - Invoked when the toast is clicked\n * @param {Object} [options.offset] - Ability to add some offset to axis\n * @param {boolean} [options.escapeMarkup=true] - Toggle the default behavior of escaping HTML markup\n * @param {Object} [options.style] - Use the HTML DOM style property to add styles to toast\n * @private\n */\n _init(options) {\n\n // Setting defaults\n this.options = Object.assign(this.defaults, options);\n\n if (this.options.backgroundColor) {\n // This is being deprecated in favor of using the style HTML DOM property\n console.warn('DEPRECATION NOTICE: \"backgroundColor\" is being deprecated. Please use the \"style.background\" property.');\n }\n\n this.toastElement = null;\n\n this.options.gravity = options.gravity === \"bottom\" ? \"toastify-bottom\" : \"toastify-top\"; // toast position - top or bottom\n this.options.stopOnFocus = options.stopOnFocus === undefined ? true : options.stopOnFocus; // stop timeout on focus\n\n this.options.style.background = this.options.style.background || options.backgroundColor;\n }\n\n /**\n * Build the Toastify element\n * @returns {Element}\n * @private\n */\n _buildToast() {\n // Validating if the options are defined\n if (!this.options) {\n throw \"Toastify is not initialized\";\n }\n\n // Creating the DOM object\n let divElement = document.createElement(\"div\");\n divElement.className = `toastify on ${this.options.className}`;\n\n // Positioning toast to left or right or center (default right)\n divElement.className += ` toastify-${this.options.position}`;\n\n // Assigning gravity of element\n divElement.className += ` ${this.options.gravity}`;\n\n // Loop through our style object and apply styles to divElement\n for (const property in this.options.style) {\n divElement.style[property] = this.options.style[property];\n }\n\n // Adding the toast message/node\n if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {\n // If we have a valid node, we insert it\n divElement.appendChild(this.options.node)\n } else {\n if (this.options.escapeMarkup) {\n divElement.innerText = this.options.text;\n } else {\n divElement.innerHTML = this.options.text;\n }\n\n if (this.options.avatar !== \"\") {\n let avatarElement = document.createElement(\"img\");\n avatarElement.src = this.options.avatar;\n\n avatarElement.className = \"toastify-avatar\";\n\n if (this.options.position == \"left\") {\n // Adding close icon on the left of content\n divElement.appendChild(avatarElement);\n } else {\n // Adding close icon on the right of content\n divElement.insertAdjacentElement(\"afterbegin\", avatarElement);\n }\n }\n }\n\n // Adding a close icon to the toast\n if (this.options.close === true) {\n // Create a span for close element\n let closeElement = document.createElement(\"span\");\n closeElement.innerHTML = \"✖\";\n\n closeElement.className = \"toast-close\";\n\n // Triggering the removal of toast from DOM on close click\n closeElement.addEventListener(\n \"click\",\n (event) => {\n event.stopPropagation();\n this._removeElement(this.toastElement);\n window.clearTimeout(this.toastElement.timeOutValue);\n }\n );\n\n //Calculating screen width\n const width = window.innerWidth > 0 ? window.innerWidth : screen.width;\n\n // Adding the close icon to the toast element\n // Display on the right if screen width is less than or equal to 360px\n if ((this.options.position == \"left\") && width > 360) {\n // Adding close icon on the left of content\n divElement.insertAdjacentElement(\"afterbegin\", closeElement);\n } else {\n // Adding close icon on the right of content\n divElement.appendChild(closeElement);\n }\n }\n\n // Clear timeout while toast is focused\n if (this.options.stopOnFocus && this.options.duration > 0) {\n // stop countdown\n divElement.addEventListener(\n \"mouseover\",\n (event) => {\n window.clearTimeout(divElement.timeOutValue);\n }\n )\n // add back the timeout\n divElement.addEventListener(\n \"mouseleave\",\n () => {\n divElement.timeOutValue = window.setTimeout(\n () => {\n // Remove the toast from DOM\n this._removeElement(divElement);\n },\n this.options.duration\n )\n }\n )\n }\n\n // Adding an on-click destination path\n if (typeof this.options.destination !== \"undefined\") {\n divElement.addEventListener(\n \"click\",\n (event) => {\n event.stopPropagation();\n if (this.options.newWindow === true) {\n window.open(this.options.destination, \"_blank\");\n } else {\n window.location = this.options.destination;\n }\n }\n );\n }\n\n if (typeof this.options.onClick === \"function\" && typeof this.options.destination === \"undefined\") {\n divElement.addEventListener(\n \"click\",\n (event) => {\n event.stopPropagation();\n this.options.onClick();\n }\n );\n }\n\n // Adding offset\n if (typeof this.options.offset === \"object\") {\n\n const x = this._getAxisOffsetAValue(\"x\", this.options);\n const y = this._getAxisOffsetAValue(\"y\", this.options);\n\n const xOffset = this.options.position == \"left\" ? x : `-${x}`;\n const yOffset = this.options.gravity == \"toastify-top\" ? y : `-${y}`;\n\n divElement.style.transform = `translate(${xOffset},${yOffset})`;\n\n }\n\n // Returning the generated element\n return divElement;\n }\n\n /**\n * Remove the toast from the DOM\n * @param {Element} toastElement\n */\n _removeElement(toastElement) {\n // Hiding the element\n toastElement.className = toastElement.className.replace(\" on\", \"\");\n\n // Removing the element from DOM after transition end\n window.setTimeout(\n () => {\n // remove options node if any\n if (this.options.node && this.options.node.parentNode) {\n this.options.node.parentNode.removeChild(this.options.node);\n }\n\n // Remove the element from the DOM, only when the parent node was not removed before.\n if (toastElement.parentNode) {\n toastElement.parentNode.removeChild(toastElement);\n }\n\n // Calling the callback function\n this.options.callback.call(toastElement);\n\n // Repositioning the toasts again\n this._reposition();\n },\n 400\n ); // Binding `this` for function invocation\n }\n\n /**\n * Position the toast on the DOM\n * @private\n */\n _reposition() {\n\n // Top margins with gravity\n let topLeftOffsetSize = {\n top: 15,\n bottom: 15,\n };\n let topRightOffsetSize = {\n top: 15,\n bottom: 15,\n };\n let offsetSize = {\n top: 15,\n bottom: 15,\n };\n\n // Get all toast messages that have been added to the container (selector)\n let allToasts = this._rootElement.querySelectorAll(\".toastify\");\n\n let classUsed;\n\n // Modifying the position of each toast element\n for (let i = 0; i < allToasts.length; i++) {\n // Getting the applied gravity\n if (allToasts[i].classList.contains(\"toastify-top\") === true) {\n classUsed = \"toastify-top\";\n } else {\n classUsed = \"toastify-bottom\";\n }\n\n let height = allToasts[i].offsetHeight;\n classUsed = classUsed.substr(9, classUsed.length - 1)\n // Spacing between toasts\n let offset = 15;\n\n let width = window.innerWidth > 0 ? window.innerWidth : screen.width;\n\n // Show toast in center if screen with less than or equal to 360px\n if (width <= 360) {\n // Setting the position\n allToasts[i].style[classUsed] = `${offsetSize[classUsed]}px`;\n\n offsetSize[classUsed] += height + offset;\n } else {\n if (allToasts[i].classList.contains(\"toastify-left\") === true) {\n // Setting the position\n allToasts[i].style[classUsed] = `${topLeftOffsetSize[classUsed]}px`;\n\n topLeftOffsetSize[classUsed] += height + offset;\n } else {\n // Setting the position\n allToasts[i].style[classUsed] = `${topRightOffsetSize[classUsed]}px`;\n\n topRightOffsetSize[classUsed] += height + offset;\n }\n }\n }\n }\n\n /**\n * Helper function to get offset\n * @param {string} axis - 'x' or 'y'\n * @param {ToastifyConfigurationObject} options - The options object containing the offset object\n */\n _getAxisOffsetAValue(axis, options) {\n\n if (options.offset[axis]) {\n if (isNaN(options.offset[axis])) {\n return options.offset[axis];\n } else {\n return `${options.offset[axis]}px`;\n }\n }\n\n return '0px';\n\n }\n\n }\n\n\n // Returning the Toastify function to be assigned to the window object/module\n function StartToastifyInstance(options) {\n return new Toastify(options);\n }\n\n export default StartToastifyInstance;\n","import Toastify from 'toastify-js/src/toastify-es';\n\n/**\n *\n * Wrapper component for toastify-js - https://github.com/apvarun/toastify-js\n *\n * @event jinn-toast - will show the toast with text passed in event\n */\nexport class JinnToast extends HTMLElement {\n\n static get properties() {\n return {\n avatar: {type: String},\n backgroundColor: {type: String},\n callback: {type: String},\n classProp: {type: String},\n close: {type: Boolean},\n destination: {type: String},\n duration: {type: Number},\n escapeMarkup: {type: Boolean},\n gravity: {type: String},\n newWindow: {type: Boolean},\n oldestFirst: {type: Boolean},\n position: {type: String},\n selector: {type: String},\n stopOnFocus: {type: Boolean},\n text: {type: String}\n };\n }\n\n constructor() {\n super();\n this.attachShadow({mode: 'open'});\n }\n\n _initVar(name, defaultVal) {\n return this.hasAttribute(name) ? this.getAttribute(name) : defaultVal;\n }\n\n connectedCallback() {\n this.avatar = this._initVar('avatar', '');\n this.backgroundColor = this._initVar('backgroundColor', '');\n this.callback = this._initVar('callback', {});\n this.classProp = this._initVar('data-class', '');\n this.close = (this._initVar('close', false)) === 'true';\n this.destination = this._initVar('destination', undefined);\n this.duration = Number(this._initVar('duration', 3000));\n this.escapeMarkup = (this._initVar('escapeMarkup', true)) === 'true';\n this.gravity = this._initVar('gravity', 'top');\n this.newWindow = (this._initVar('newWindow', false)) === 'true';\n this.offSet = this._initVar('offSet', {});\n this.oldestFirst = (this._initVar('oldestFirst', true)) === 'true';\n this.position = this._initVar('position', 'right');\n // this.selector = this._initVar('selector','');\n this.stopOnFocus = this._initVar('stopOnFocus', true);\n this.text = this._initVar('text', '');\n\n const style = `\n :host{\n display:none;\n }\n `;\n this.shadowRoot.innerHTML = `\n \n ${this.renderHTML}\n `;\n\n /**\n * trigger toast via @jinn-toast events\n */\n this.addEventListener('jinn-toast', (ev) =>{\n this.showToast(ev.detail.text);\n });\n\n }\n\n showToast(text){\n new Toastify({\n avatar: this.avatar,\n // backgroundColor:this.backgroundColor,\n // callback: this.callback,\n className:this.classProp,\n close: this.close,\n destination: this.destination,\n duration: this.duration,\n escapeMarkup: this.escapeMarkup,\n gravity: this.gravity,\n newWindow: false,\n offset:this.offset,\n oldestFirst: this.oldestFirst,\n position: this.position,\n node: this.shadowRoot,\n stopOnFocus: this.stopOnFocus,\n text,\n }).showToast();\n\n }\n\n renderHTML() {\n return `\n \n `;\n }\n\n}\nwindow.customElements.define('jinn-toast', JinnToast);\n","import { Fore } from './fore.js';\nimport './fx-instance.js';\nimport './fx-model.js';\nimport '@jinntec/jinn-toast';\nimport { evaluateXPathToNodes, evaluateXPathToString } from './xpath-evaluation.js';\nimport getInScopeContext from './getInScopeContext.js';\nimport { XPathUtil } from './xpath-util.js';\n\n/**\n * Main class for Fore.Outermost container element for each Fore application.\n *\n * Root element for Fore. Kicks off initialization and displays messages.\n *\n * fx-fore is the outermost container for each form. A form can have exactly one model\n * with arbitrary number of instances.\n *\n * Main responsiblities are initialization and updating of model and instances, update of UI (refresh) and global messaging.\n *\n *\n *\n * @ts-check\n */\nexport class FxFore extends HTMLElement {\n static get properties() {\n return {\n /**\n * Setting this marker attribute will refresh the UI in a lazy fashion just updating elements being\n * in viewport.\n *\n * this feature is still experimental and should be used with caution and extra testing\n */\n lazyRefresh: {\n type: Boolean,\n },\n model: {\n type: Object,\n },\n ready: {\n type: Boolean,\n },\n };\n }\n\n /**\n * attaches handlers for\n *\n * - `model-construct-done` to trigger the processing of the UI\n * - `message` - to display a message triggered by an fx-message action\n * - `error` - to display an error message\n * - 'compute-exception` - warn about circular dependencies in graph\n */\n constructor() {\n super();\n this.model = {};\n this.addEventListener('model-construct-done', this._handleModelConstructDone);\n this.addEventListener('message', this._displayMessage);\n this.addEventListener('error', this._displayError);\n window.addEventListener('compute-exception', e => {\n console.error('circular dependency: ', e);\n });\n\n this.ready = false;\n this.storedTemplateExpressionByNode = new Map();\n\n const style = `\n :host {\n // display: none;\n height:auto;\n padding:var(--model-element-padding);\n font-family:Roboto, sans-serif;\n color:var(--paper-grey-900);\n }\n :host ::slotted(fx-model){\n display:none;\n }\n :host(.fx-ready){\n animation: fadein .4s forwards;\n display:block;\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 @keyframes fadein {\n 0% {\n opacity:0;\n }\n 100% {\n opacity:1;\n }\n }\n `;\n\n const html = `\n \n \n \n \n
\n
\n

\n ×\n
\n
\n
\n `;\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.innerHTML = `\n \n ${html}\n `;\n\n this.toRefresh = [];\n this.initialRun = true;\n this.someInstanceDataStructureChanged = false;\n }\n\n connectedCallback() {\n this.lazyRefresh = this.hasAttribute('refresh-on-view');\n if (this.lazyRefresh) {\n const options = {\n root: null,\n rootMargin: '0px',\n threshold: 0.3,\n };\n this.intersectionObserver = new IntersectionObserver(this.handleIntersect, options);\n }\n\n this.src = this.hasAttribute('src')? this.getAttribute('src'):null;\n if(this.src){\n this._loadFromSrc();\n return ;\n }\n\n const slot = this.shadowRoot.querySelector('slot');\n slot.addEventListener('slotchange', event => {\n const children = event.target.assignedElements();\n let modelElement = children.find(\n modelElem => modelElem.nodeName.toUpperCase() === 'FX-MODEL',\n );\n if (!modelElement) {\n const generatedModel = document.createElement('FX-model');\n this.appendChild(generatedModel);\n modelElement = generatedModel;\n }\n if (!modelElement.inited) {\n console.log(\n `########## FORE: kick off processing for ... ${window.location.href} ##########`,\n );\n if(this.src){\n console.log('########## FORE: loaded from ... ', this.src, '##########');\n }\n modelElement.modelConstruct();\n }\n this.model = modelElement;\n });\n this.addEventListener('path-mutated', (e) =>{\n console.log('path-mutated event received', e.detail.path, e.detail.index);\n this.someInstanceDataStructureChanged = true;\n });\n }\n\n\n addToRefresh(modelItem){\n const found = this.toRefresh.find(mi => mi.path === modelItem.path );\n if(!found){\n this.toRefresh.push(modelItem);\n }\n }\n\n /**\n * loads a Fore from an URL given by `src`.\n *\n * Will extract the `fx-fore` element from that target file and use and replace current `fx-fore` element with the loaded one.\n * @private\n */\n _loadFromSrc() {\n console.log('########## loading Fore from ',this.src ,'##########');\n fetch(this.src, {\n method: 'GET',\n mode: 'cors',\n credentials: 'include',\n headers: {\n 'Content-Type': 'text/html',\n },\n })\n .then(response => {\n const responseContentType = response.headers.get('content-type').toLowerCase();\n console.log('********** responseContentType *********', responseContentType);\n if (responseContentType.startsWith('text/html')) {\n // const htmlResponse = response.text();\n // return new DOMParser().parseFromString(htmlResponse, 'text/html');\n // return response.text();\n return response.text().then(result =>\n // console.log('xml ********', result);\n new DOMParser().parseFromString(result, 'text/html'),\n );\n }\n return 'done';\n })\n .then(data => {\n // const theFore = fxEvaluateXPathToFirstNode('//fx-fore', data.firstElementChild);\n const theFore = data.querySelector('fx-fore');\n\n // console.log('thefore', theFore)\n if(!theFore){\n this.dispatchEvent(new CustomEvent('error',{detail:{message: `Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}));\n }\n theFore.setAttribute('from-src', this.src);\n this.replaceWith(theFore);\n })\n .catch(error => {\n this.dispatchEvent(new CustomEvent('error',{detail:{message: `'${this.src}' not found or does not contain Fore element.`}}));\n });\n }\n\n /**\n * refreshes the UI by using IntersectionObserver API. This is the handler being called\n * by the observer whenever elements come into / move out of viewport.\n * @param entries\n * @param observer\n */\n handleIntersect(entries, observer) {\n console.time('refreshLazy');\n entries.forEach(entry => {\n const { target } = entry;\n\n if (entry.isIntersecting) {\n console.log('in view', entry);\n // console.log('repeat in view entry', entry.target);\n // const target = entry.target;\n // if(target.hasAttribute('refresh-on-view')){\n target.classList.add('loaded');\n // }\n\n // todo: too restrictive here? what if target is a usual html element? shouldn't it refresh downwards?\n if (typeof target.refresh === 'function') {\n console.log('refreshing target', target);\n target.refresh(target, true);\n } else {\n console.log('refreshing children', target);\n Fore.refreshChildren(target, true);\n }\n }\n });\n entries[0].target.getOwnerForm().dispatchEvent(new CustomEvent('refresh-done'));\n\n console.timeEnd('refreshLazy');\n }\n\n evaluateToNodes(xpath, context) {\n return evaluateXPathToNodes(xpath, context, this);\n }\n\n disconnectedCallback() {\n /*\n this.removeEventListener('model-construct-done', this._handleModelConstructDone);\n this.removeEventListener('message', this._displayMessage);\n this.removeEventListener('error', this._displayError);\n this.storedTemplateExpressionByNode=null;\n this.shadowRoot = undefined;\n*/\n }\n\n /**\n * refreshes the whole UI by visiting each bound element (having a 'ref' attribute) and applying the state of\n * the bound modelItem to the bound element.\n *\n *\n * AVT:\n *\n */\n async refresh(force) {\n // refresh () {\n console.group('### refresh');\n\n console.time('refresh');\n\n // ### refresh Fore UI elements\n console.time('refreshChildren');\n console.log('toRefresh',this.toRefresh);\n\n if(!this.initialRun && this.toRefresh.length !== 0){\n let needsRefresh = false;\n\n // ### after recalculation the changed modelItems are copied to 'toRefresh' array for processing\n this.toRefresh.forEach(modelItem => {\n // check if modelItem has boundControls - if so, call refresh() for each of them\n const controlsToRefresh = modelItem.boundControls;\n if(controlsToRefresh){\n controlsToRefresh.forEach(ctrl => {\n ctrl.refresh();\n });\n }\n\n // ### check if other controls depend on current modelItem\n const mainGraph = this.getModel().mainGraph;\n if(mainGraph && mainGraph.hasNode(modelItem.path)){\n const deps = this.getModel().mainGraph.dependentsOf(modelItem.path, false);\n // ### iterate dependant modelItems and refresh all their boundControls\n if(deps.length !== 0){\n deps.forEach(dep => {\n // ### if changed modelItem has a 'facet' path we use the basePath that is the locationPath without facet name\n const basePath = XPathUtil.getBasePath(dep);\n const modelItemOfDep = this.getModel().modelItems.find(mip => mip.path === basePath);\n // ### refresh all boundControls\n modelItemOfDep.boundControls.forEach(control =>{control.refresh()});\n });\n needsRefresh = true;\n }\n }\n });\n this.toRefresh = [];\n if(!needsRefresh){\n console.log('skipping refresh - no dependants');\n }\n }else{\n Fore.refreshChildren(this, true);\n console.timeEnd('refreshChildren');\n }\n\n // ### refresh template expressions\n if(this.initialRun || this.someInstanceDataStructureChanged){\n this._updateTemplateExpressions();\n this.someInstanceDataStructureChanged = false; //reset\n }\n this._processTemplateExpressions();\n\n console.timeEnd('refresh');\n\n console.groupEnd();\n console.log('### <<<<< dispatching refresh-done - end of UI update cycle >>>>>');\n this.dispatchEvent(new CustomEvent('refresh-done'));\n }\n\n /**\n * entry point for processing of template expression enclosed in '{}' brackets.\n *\n * Expressions are found with an XPath search. For each node an entry is added to the storedTemplateExpressionByNode map.\n *\n *\n * @private\n */\n _updateTemplateExpressions() {\n // Note the fact we're going over HTML here: therefore the `html` prefix.\n const search =\n \"(descendant-or-self::*/(text(), @*))[matches(.,'\\\\{.*\\\\}')] except descendant-or-self::fx-model/descendant-or-self::node()/(., @*)\";\n\n const tmplExpressions = evaluateXPathToNodes(search, this, this);\n console.log('template expressions found ', tmplExpressions);\n\n if (!this.storedTemplateExpressions) {\n this.storedTemplateExpressions = [];\n }\n\n console.log('######### storedTemplateExpressions', this.storedTemplateExpressions.length);\n\n /*\n storing expressions and their nodes for re-evaluation\n */\n Array.from(tmplExpressions).forEach(node => {\n if (this.storedTemplateExpressionByNode.has(node)) {\n // If the node is already known, do not process it twice\n return;\n }\n const expr = this._getTemplateExpression(node);\n\n // console.log('storedTemplateExpressionByNode', this.storedTemplateExpressionByNode);\n this.storedTemplateExpressionByNode.set(node, expr);\n });\n console.log('stored template expressions ', this.storedTemplateExpressionByNode);\n\n // TODO: Should we clean up nodes that existed but are now gone?\n this._processTemplateExpressions();\n\n }\n\n _processTemplateExpressions() {\n for (const node of this.storedTemplateExpressionByNode.keys()) {\n this._processTemplateExpression({\n node,\n expr: this.storedTemplateExpressionByNode.get(node),\n });\n }\n }\n\n// eslint-disable-next-line class-methods-use-this\n _processTemplateExpression(exprObj) {\n // console.log('processing template expression ', exprObj);\n\n const { expr } = exprObj;\n const { node } = exprObj;\n // console.log('expr ', expr);\n this.evaluateTemplateExpression(expr, node, this);\n }\n\n /**\n * evaluate a template expression (some expression in {} brackets) on a node (either text- or attribute node.\n * @param expr the XPath to evaluate\n * @param node the node which will get updated with evaluation result\n * @param form the form element\n */\n evaluateTemplateExpression(expr, node) {\n if (expr === '{}') return;\n const matches = expr.match(/{[^}]*}/g);\n const namespaceContextNode =\n node.nodeType === node.TEXT_NODE ? node.parentNode : node.ownerElement;\n if (matches) {\n matches.forEach(match => {\n // console.log('match ', match);\n let naked = match.substring(1, match.length - 1);\n const inscope = getInScopeContext(node, naked);\n if (!inscope) {\n const errNode =\n node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ATTRIBUTE_NODE\n ? node.parentNode\n : node;\n console.warn('no inscope context for ', errNode);\n return;\n }\n // Templates are special: they use the namespace configuration from the place where they are\n // being defined\n const instanceId = XPathUtil.getInstanceId(naked);\n // console.log('target instance ', instanceId);\n const inst = this.getModel().getInstance(instanceId);\n try {\n const result = evaluateXPathToString(naked, inscope, node, null, inst);\n\n // console.log('result of eval ', result);\n const replaced = expr.replaceAll(match, result);\n // console.log('result of replacing ', replaced);\n\n if (node.nodeType === Node.ATTRIBUTE_NODE) {\n const parent = node.ownerElement;\n\n // parent.setAttribute(name, replaced);\n parent.setAttribute(node.nodeName, replaced);\n } else if (node.nodeType === Node.TEXT_NODE) {\n node.textContent = replaced;\n }\n\n if (replaced.includes('{')) {\n // console.log('need to go next round');\n\n // todo: duplicated code here - see above\n naked = replaced.substring(1, replaced.length);\n this.evaluateTemplateExpression(replaced, node);\n }\n } catch (error) {\n this.dispatchEvent(new CustomEvent('error', { detail: error }));\n }\n });\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n _getTemplateExpression(node) {\n if (node.nodeType === Node.ATTRIBUTE_NODE) {\n return node.value;\n }\n if (node.nodeType === Node.TEXT_NODE) {\n return node.textContent.trim();\n }\n return null;\n }\n\n /**\n * called when `model-construct-done` event is received to\n * start initing of the UI.\n *\n * @private\n */\n _handleModelConstructDone() {\n this._initUI();\n }\n\n /**\n * If there's no instance element found in a fx-model during init it will construct\n * an instance from UI bindings.\n *\n * @returns {Promise}\n * @private\n */\n async _lazyCreateInstance() {\n const model = this.querySelector('fx-model');\n if (model.instances.length === 0) {\n console.log('### lazy creation of instance');\n const generatedInstance = document.createElement('fx-instance');\n model.appendChild(generatedInstance);\n\n const generated = document.implementation.createDocument(null, 'data', null);\n // const newData = this._generateInstance(this, generated.firstElementChild);\n this._generateInstance(this, generated.firstElementChild);\n generatedInstance.instanceData = generated;\n model.instances.push(generatedInstance);\n console.log('generatedInstance ', this.getModel().getDefaultInstanceData());\n }\n }\n\n /**\n * @param {Element} start\n * @param {Element} parent\n */\n _generateInstance(start, parent) {\n if (start.hasAttribute('ref') && !Fore.isActionElement(start.nodeName)) {\n const ref = start.getAttribute('ref');\n\n if (ref.includes('/')) {\n console.log('complex path to create ', ref);\n const steps = ref.split('/');\n steps.forEach(step => {\n console.log('step ', step);\n\n // const generated = document.createElement(ref);\n parent = this._generateNode(parent, step, start);\n });\n } else {\n parent = this._generateNode(parent, ref, start);\n }\n }\n\n if (start.hasChildNodes()) {\n const list = start.children;\n for (let i = 0; i < list.length; i += 1) {\n this._generateInstance(list[i], parent);\n }\n }\n return parent;\n }\n\n // eslint-disable-next-line class-methods-use-this\n _generateNode(parent, step, start) {\n const generated = parent.ownerDocument.createElement(step);\n if (start.children.length === 0) {\n generated.textContent = start.textContent;\n }\n parent.appendChild(generated);\n parent = generated;\n return parent;\n }\n\n /*\n _createStep(){\n\n }\n */\n\n /*\n _generateInstance(start, parent) {\n if (start.hasAttribute('ref')) {\n const ref = start.getAttribute('ref');\n\n if(ref.includes('/')){\n console.log('complex path to create ', ref);\n const steps = ref.split('/');\n steps.forEach(step => {\n console.log('step ', step);\n\n\n });\n }\n\n // const generated = document.createElement(ref);\n const generated = parent.ownerDocument.createElement(ref);\n if (start.children.length === 0) {\n generated.textContent = start.textContent;\n }\n parent.appendChild(generated);\n parent = generated;\n }\n\n if (start.hasChildNodes()) {\n const list = start.children;\n for (let i = 0; i < list.length; i += 1) {\n this._generateInstance(list[i], parent);\n }\n }\n return parent;\n }\n */\n\n /**\n * Start the initialization of the UI by\n *\n * 1. checking if a instance needs to be generated\n * 2. attaching lazy loading intersection observers if `refresh-on-view` attributes are found\n * 3. doing a full refresh of the UI\n *\n * @returns {Promise}\n * @private\n */\n async _initUI() {\n console.log('### _initUI()');\n\n await this._lazyCreateInstance();\n\n console.log('registering variables!');\n const variables = new Map();\n (function registerVariables(node) {\n for (const child of node.children) {\n if ('setInScopeVariables' in child) {\n child.setInScopeVariables(variables);\n }\n registerVariables(child);\n }\n })(this);\n console.log('Found variables:', variables);\n\n const options = {\n root: null,\n rootMargin: '0px',\n threshold: 0.3,\n };\n\n await this.refresh();\n // this.style.display='block'\n this.classList.add('fx-ready');\n document.body.classList.add('fx-ready');\n\n this.ready = true;\n this.initialRun = false;\n console.log('### <<<<< dispatching ready >>>>>');\n console.log('########## modelItems: ', this.getModel().modelItems);\n console.log('########## FORE: form fully initialized... ##########');\n this.dispatchEvent(new CustomEvent('ready', {}));\n }\n\n registerLazyElement(element) {\n if (this.intersectionObserver) {\n // console.log('registerLazyElement',element);\n this.intersectionObserver.observe(element);\n }\n }\n\n unRegisterLazyElement(element) {\n if (this.intersectionObserver) {\n this.intersectionObserver.unobserve(element);\n }\n }\n\n /**\n *\n * @returns {FxModel}\n */\n getModel() {\n return this.querySelector('fx-model');\n }\n\n _displayMessage(e) {\n const { level } = e.detail;\n const msg = e.detail.message;\n this._showMessage(level, msg);\n }\n\n _displayError(e) {\n // const { error } = e.detail;\n const msg = e.detail.message;\n // this._showMessage('modal', msg);\n const toast = this.shadowRoot.querySelector('#error');\n toast.showToast(msg);\n }\n\n _showMessage(level, msg) {\n if (level === 'modal') {\n // this.$.messageContent.innerText = msg;\n // this.$.modalMessage.open();\n\n this.shadowRoot.getElementById('messageContent').innerText = msg;\n // this.shadowRoot.getElementById('modalMessage').open();\n this.shadowRoot.getElementById('modalMessage').classList.add('show');\n } else if (level === 'sticky') {\n // const notification = this.$.modeless;\n this.shadowRoot.querySelector('#sticky').showToast(msg);\n } else {\n const toast = this.shadowRoot.querySelector('#message');\n toast.showToast(msg);\n }\n }\n}\n\ncustomElements.define('fx-fore', FxFore);\n","import { Fore } from './fore.js';\nimport { foreElementMixin } from './ForeElementMixin.js';\nimport { evaluateXPathToString, evaluateXPath } from './xpath-evaluation.js';\nimport getInScopeContext from './getInScopeContext.js';\n\n/**\n * todo: validate='false'\n */\nexport class FxSubmission extends foreElementMixin(HTMLElement) {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n // this.style.display = 'none';\n this.methods = ['get', 'put', 'post', 'delete', 'head', 'urlencoded-post'];\n\n this.model = this.parentNode;\n\n // ### initialize properties with defaults\n // if (!this.hasAttribute('id')) throw new Error('id is required');\n if (!this.hasAttribute('id')) console.warn('id is required');\n this.id = this.getAttribute('id');\n\n /** if present should be a existing instance id */\n this.instance = this.hasAttribute('instance') ? this.getAttribute('instance') : null;\n\n /** if present will determine XPath where to insert a response into when mode is 'replace' */\n this.into = this.hasAttribute('into') ? this.getAttribute('into') : null;\n\n /** http method */\n this.method = this.hasAttribute('method') ? this.getAttribute('method') : 'get';\n\n /** relevance processing - one of 'remove, keep or empty' */\n this.nonrelevant = this.hasAttribute('nonrelevant')\n ? this.getAttribute('nonrelevant')\n : 'remove';\n\n /** replace might be 'all', 'instance' or 'none' */\n this.replace = this.hasAttribute('replace') ? this.getAttribute('replace') : 'all';\n\n this.serialization = this.hasAttribute('serialization')\n ? this.getAttribute('serialization')\n : 'xml';\n\n // if (!this.hasAttribute('url')) throw new Error(`url is required for submission: ${this.id}`);\n if (!this.hasAttribute('url')) console.warn(`url is required for submission: ${this.id}`);\n this.url = this.getAttribute('url');\n\n this.targetref = this.hasAttribute('targetref') ? this.getAttribute('targetref') : null;\n\n this.mediatype = this.hasAttribute('mediatype')\n ? this.getAttribute('mediatype')\n : 'application/xml';\n\n this.validate = this.getAttribute('validate') ? this.getAttribute('validate') : 'true';\n this.shadowRoot.innerHTML = this.renderHTML();\n }\n\n // eslint-disable-next-line class-methods-use-this\n renderHTML() {\n return `\n \n `;\n }\n\n async submit() {\n await this.dispatch('submit', { submission: this });\n this._submit();\n }\n\n async _submit() {\n console.log('submitting....');\n this.evalInContext();\n const model = this.getModel();\n\n model.recalculate();\n\n if (this.validate) {\n const valid = model.revalidate();\n if (!valid) {\n console.log('validation failed. Bubmission stopped');\n // ### allow alerts to pop up\n this.dispatch('submit-error', {});\n this.getModel().parentNode.refresh();\n return;\n }\n }\n console.log('model updated....');\n await this._serializeAndSend();\n }\n\n /**\n * resolves template expressions for a single attribute\n * @param expr the attribute value to evaluate\n * @param node the attribute node used for scoped resolution\n * @returns {*}\n * @private\n */\n _evaluateAttributeTemplateExpression(expr, node) {\n const matches = expr.match(/{[^}]*}/g);\n if (matches) {\n matches.forEach(match => {\n console.log('match ', match);\n const naked = match.substring(1, match.length - 1);\n const inscope = getInScopeContext(node, naked);\n const result = evaluateXPathToString(naked, inscope, this.getOwnerForm());\n const replaced = expr.replaceAll(match, result);\n console.log('replacing ', expr, ' with ', replaced);\n expr = replaced;\n });\n }\n return expr;\n }\n\n /**\n * sends the data after evaluating\n *\n * @private\n */\n async _serializeAndSend() {\n const resolvedUrl = this._evaluateAttributeTemplateExpression(this.url, this);\n\n const instance = this.getInstance();\n console.log('instance type', instance.type);\n\n let serialized;\n if (this.serialization === 'none') {\n serialized = undefined;\n } else {\n const relevant = this.selectRelevant(instance.type);\n serialized = this._serialize(instance.type, relevant);\n }\n\n // let serialized = serializer.serializeToString(relevant);\n if (this.method.toLowerCase() === 'get') {\n serialized = undefined;\n }\n // console.log('data being send', serialized);\n // console.log('submitting data',serialized);\n\n if (resolvedUrl === '#echo') {\n let data = null;\n if (serialized && instance.type === 'xml') {\n data = new DOMParser().parseFromString(serialized, 'application/xml');\n }\n if (serialized && instance.type === 'json') {\n data = JSON.parse(serialized);\n }\n this._handleResponse(data);\n this.dispatch('submit-done', {});\n return;\n }\n // ### setting headers\n const headers = this._getHeaders();\n console.log('headers', headers);\n\n // ### map urlencoded-post to post for fetch\n if (this.method === 'urlencoded-post') {\n this.method = 'post';\n }\n\n if (!this.methods.includes(this.method.toLowerCase())) {\n this.dispatch('error', { message: `Unknown method ${this.method}` });\n return;\n }\n const response = await fetch(resolvedUrl, {\n method: this.method,\n mode: 'cors',\n credentials: 'include',\n headers,\n body: serialized,\n });\n\n if (!response.ok || response.status > 400) {\n this.dispatch('submit-error', { message: `Error while submitting ${this.id}` });\n return;\n }\n\n const contentType = response.headers.get('content-type').toLowerCase();\n if (\n contentType.startsWith('text/plain') ||\n contentType.startsWith('text/html') ||\n contentType.startsWith('text/markdown')\n ) {\n const text = await response.text();\n this._handleResponse(text);\n } else if (contentType.startsWith('application/json')) {\n const json = await response.json();\n this._handleResponse(json);\n } else if (contentType.startsWith('application/xml')) {\n const text = await response.text();\n const xml = new DOMParser().parseFromString(text, 'application/xml');\n this._handleResponse(xml);\n } else {\n const blob = await response.blob();\n this._handleResponse(blob);\n }\n\n this.dispatch('submit-done', {});\n }\n\n _serialize(instanceType, relevantNodes) {\n if (this.method === 'urlencoded-post') {\n // this.method = 'post';\n const params = new URLSearchParams();\n // console.log('nodes to serialize', relevantNodes);\n Array.from(relevantNodes.children).forEach(child => {\n params.append(child.nodeName, child.textContent);\n });\n return params;\n }\n if (instanceType === 'xml') {\n const serializer = new XMLSerializer();\n return serializer.serializeToString(relevantNodes);\n }\n if(instanceType === 'json'){\n // console.warn('JSON serialization is not yet supported')\n return JSON.stringify(relevantNodes);\n }\n throw new Error('unknown instance type ', instanceType);\n }\n\n _getHeaders() {\n const headers = new Headers();\n\n // ### set content-type header according to type of instance\n const instance = this.getInstance();\n const contentType = Fore.getContentType(instance, this.method);\n headers.append('Content-Type', contentType);\n // ### needed to overwrite browsers' setting of 'Accept' header\n if (headers.has('Accept')) {\n headers.delete('Accept');\n }\n // headers.append('Accept', 'application/xml');\n\n // ### add header defined by fx-header elements\n const headerElems = this.querySelectorAll('fx-header');\n Array.from(headerElems).forEach(header => {\n const { name } = header;\n const val = header.getValue();\n headers.append(name, val);\n });\n return headers;\n }\n\n _getUrlExpr() {\n return this.storedTemplateExpressions.find(stored => stored.node.nodeName === 'url');\n }\n\n _getTargetInstance() {\n let targetInstance;\n if (this.instance) {\n targetInstance = this.model.getInstance(this.instance);\n } else {\n targetInstance = this.model.getInstance('default');\n }\n if (!targetInstance) {\n throw new Error(`target instance not found: ${targetInstance}`);\n }\n return targetInstance;\n }\n\n /**\n * handles replacement of instance data from response data.\n *\n * Please note that data might be\n * @param data\n * @private\n */\n _handleResponse(data) {\n console.log('_handleResponse ', data);\n\n\n/*\n // ### responses need to be handled depending on their type.\n if(this.type === 'json'){\n\n }\n*/\n\n if (this.replace === 'instance') {\n const targetInstance = this._getTargetInstance();\n if (targetInstance) {\n if (this.targetref) {\n const theTarget = evaluateXPath(\n this.targetref,\n targetInstance.instanceData.firstElementChild,\n this,\n );\n console.log('theTarget', theTarget);\n const clone = data.firstElementChild;\n const parent = theTarget.parentNode;\n parent.replaceChild(clone, theTarget);\n console.log('finally ', parent);\n } else if (this.into) {\n const theTarget = evaluateXPath(\n this.into,\n targetInstance.instanceData.firstElementChild,\n this,\n );\n console.log('theTarget', theTarget);\n theTarget.innerHTML = data;\n } else {\n const instanceData = data;\n targetInstance.instanceData = instanceData;\n console.log('### replaced instance ', this.getModel().instances);\n console.log('### replaced instance ', targetInstance.instanceData);\n }\n\n this.model.updateModel(); // force update\n // this.model.formElement.refresh();\n this.getOwnerForm().refresh();\n } else {\n throw new Error(`target instance not found: ${targetInstance}`);\n }\n }\n\n if (this.replace === 'all') {\n document.getElementsByTagName('html')[0].innerHTML = data;\n }\n if (this.replace === 'target') {\n const target = this.getAttribute('target');\n const targetNode = document.querySelector(target);\n targetNode.innerHTML = data;\n }\n if (this.replace === 'redirect') {\n window.location.href = data;\n }\n }\n\n /**\n * select relevant nodes\n *\n * @returns {*}\n */\n selectRelevant(type) {\n console.log('selectRelevant' ,type)\n switch (type){\n case 'xml':\n return this._relevantXmlNodes();\n default:\n console.warn(`relevance selection not supported for type:${this.type}`);\n return this.nodeset;\n }\n }\n\n // todo: support for 'empty'\n _relevantXmlNodes() {\n // ### no relevance selection - current nodeset is used 'as-is'\n if (this.nonrelevant === 'keep') {\n return this.nodeset;\n }\n\n // first check if nodeset of submission is relevant - otherwise bail out\n const mi = this.getModel().getModelItem(this.nodeset);\n if (mi && !mi.relevant) return null;\n\n const doc = new DOMParser().parseFromString('', 'application/xml');\n const root = doc.firstElementChild;\n\n if (this.nodeset.children.length === 0 && this._isRelevant(this.nodeset)) {\n return this.nodeset;\n }\n return this._filterRelevant(this.nodeset, root);\n }\n\n _filterRelevant(node, result) {\n const { childNodes } = node;\n Array.from(childNodes).forEach(n => {\n if (this._isRelevant(n)) {\n const clone = n.cloneNode(false);\n result.appendChild(clone);\n const { attributes } = n;\n if (attributes) {\n Array.from(attributes).forEach(attr => {\n if (this._isRelevant(attr)) {\n clone.setAttribute(attr.nodeName, attr.value);\n } else if (this.nonrelevant === 'empty') {\n clone.setAttribute(attr.nodeName, '');\n } else {\n clone.removeAttribute(attr.nodeName);\n }\n });\n }\n return this._filterRelevant(n, clone);\n }\n return null;\n });\n return result;\n }\n\n _isRelevant(node) {\n const mi = this.getModel().getModelItem(node);\n if (!mi || mi.relevant) {\n return true;\n }\n return false;\n }\n\n _handleError() {\n this.dispatch('submit-error', {});\n /*\n console.log('ERRRORRRRR');\n this.dispatchEvent(\n new CustomEvent('submit-error', {\n composed: true,\n bubbles: true,\n detail: {},\n }),\n );\n */\n }\n}\n\ncustomElements.define('fx-submission', FxSubmission);\n","import { foreElementMixin } from './ForeElementMixin.js';\n\nexport class FxHeader extends foreElementMixin(HTMLElement) {\n constructor() {\n super();\n this.style.display = 'none';\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.innerHTML = ``;\n\n if (!this.hasAttribute('name')) {\n throw new Error('required attribute \"name\" missing');\n }\n this.name = this.getAttribute('name');\n }\n\n connectedCallback() {\n this.shadowRoot.innerHTML = ``;\n }\n}\ncustomElements.define('fx-header', FxHeader);\n","import './fx-instance.js';\nimport { evaluateXPath } from './xpath-evaluation.js';\nimport { foreElementMixin } from './ForeElementMixin.js';\nimport getInScopeContext from './getInScopeContext.js';\n\n/**\n * @ts-check\n */\nexport class FxVariable extends foreElementMixin(HTMLElement) {\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.name = '';\n this.valueQuery = '';\n this.value = null;\n }\n\n connectedCallback() {\n this.name = this.getAttribute('name');\n this.valueQuery = this.getAttribute('value');\n }\n\n refresh() {\n const inscope = getInScopeContext(this, this.valueQuery);\n\n this.value = evaluateXPath(this.valueQuery, inscope, this, this.precedingVariables);\n }\n\n setInScopeVariables(inScopeVariables) {\n if (inScopeVariables.has(this.name)) {\n console.error(`The variable ${this.name} is declared more than once`);\n this.dispatch('xforms-binding-error');\n return;\n }\n inScopeVariables.set(this.name, this);\n // Clone the preceding variables to make sure we are not going to get access to variables we\n // should not get access to\n this.inScopeVariables = new Map(inScopeVariables);\n }\n}\n\ncustomElements.define('fx-var', FxVariable);\n","import '../fx-model.js';\nimport { foreElementMixin } from '../ForeElementMixin.js';\nimport { ModelItem } from '../modelitem.js';\nimport { Fore } from '../fore.js';\n\n/**\n * `AbstractControl` -\n * is a general base class for control elements.\n *\n */\nexport default class AbstractControl extends foreElementMixin(HTMLElement) {\n constructor() {\n super();\n this.value = '';\n this.display = this.style.display;\n this.required = false;\n this.readonly = false;\n this.widget = null;\n // this.attachShadow({ mode: 'open' });\n }\n\n // eslint-disable-next-line class-methods-use-this\n getWidget() {\n throw new Error('You have to implement the method getWidget!');\n }\n\n /**\n * (re)apply all modelItem state properties to this control. model -> UI\n */\n async refresh(force) {\n // console.log('### AbstractControl.refresh on : ', this);\n\n const currentVal = this.value;\n\n // if(this.repeated) return\n if (this.isNotBound()) return;\n\n // await this.updateComplete;\n // await this.getWidget();\n this.evalInContext();\n\n if (this.isBound()) {\n // this.control = this.querySelector('#control');\n\n if (this.nodeset === null) {\n this.style.display = 'none';\n return;\n }\n\n this.modelItem = this.getModelItem();\n\n if (this.modelItem instanceof ModelItem) {\n // console.log('### XfAbstractControl.refresh modelItem : ', this.modelItem);\n\n this.value = this.modelItem.value;\n\n /*\n this is another case that highlights the fact that an init() function might make sense in general.\n */\n if(!this.modelItem.boundControls.includes(this)){\n this.modelItem.boundControls.push(this);\n }\n\n // console.log('>>>>>>>> abstract refresh ', this.control);\n // this.control[this.valueProp] = this.value;\n await this.updateWidgetValue();\n this.handleModelItemProperties();\n\n // if(!this.closest('fx-fore').ready) return; // state change event do not fire during init phase (initial refresh)\n if (!this.getOwnerForm().ready) return; // state change event do not fire during init phase (initial refresh)\n if (currentVal !== this.value) {\n Fore.dispatch(this,'value-changed', { path: this.modelItem.path });\n }\n }\n }\n }\n\n /**\n *\n * @returns {Promise}\n */\n // eslint-disable-next-line class-methods-use-this\n async updateWidgetValue() {\n throw new Error('You have to implement the method updateWidgetValue!');\n }\n\n handleModelItemProperties() {\n // console.log('form ready', this.getOwnerForm().ready);\n this.handleRequired();\n this.handleReadonly();\n if (this.getOwnerForm().ready) {\n this.handleValid();\n }\n this.handleRelevant();\n }\n\n _getForm() {\n return this.getModel().parentNode;\n }\n\n _dispatchEvent(event) {\n if (this.getOwnerForm().ready) {\n this.dispatch(event, {});\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n handleRequired() {\n // console.log('mip required', this.modelItem.required);\n // const control = this.querySelector('#control');\n this.widget = this.getWidget();\n if (this.isRequired() !== this.modelItem.required) {\n if (this.modelItem.required) {\n this.widget.setAttribute('required', 'required');\n this.classList.add('required');\n this._dispatchEvent('required');\n } else {\n this.widget.removeAttribute('required');\n this.required = false;\n // this.removeAttribute('required');\n this.classList.toggle('required');\n this._dispatchEvent('optional');\n }\n }\n }\n\n handleReadonly() {\n // console.log('mip readonly', this.modelItem.isReadonly);\n if (this.isReadonly() !== this.modelItem.readonly) {\n if (this.modelItem.readonly) {\n this.widget.setAttribute('readonly', 'readonly');\n // this.setAttribute('readonly','readonly');\n this.classList.toggle('readonly');\n this._dispatchEvent('readonly');\n }\n if (!this.modelItem.readonly) {\n this.widget.removeAttribute('readonly');\n // this.removeAttribute('readonly');\n this.classList.toggle('readonly');\n this._dispatchEvent('readwrite');\n }\n }\n }\n\n // todo - review alert handling altogether. There could be potentially multiple ones in model\n handleValid() {\n // console.log('mip valid', this.modelItem.required);\n const alert = this.querySelector('fx-alert');\n\n if (this.isValid() !== this.modelItem.constraint) {\n if (this.modelItem.constraint) {\n this.classList.remove('invalid');\n if (alert) alert.style.display = 'none';\n this._dispatchEvent('valid');\n } else {\n // ### constraint is invalid - handle alerts\n this.classList.add('invalid');\n if (alert) {\n alert.style.display = 'block';\n }\n if (this.modelItem.alerts.length !== 0) {\n const { alerts } = this.modelItem;\n console.log('alerts from bind: ', alerts);\n\n const controlAlert = this.querySelector('fx-alert');\n if (!controlAlert) {\n alerts.forEach(modelAlert => {\n const newAlert = document.createElement('fx-alert');\n newAlert.innerHTML = modelAlert;\n this.appendChild(newAlert);\n newAlert.style.display = 'block';\n });\n }\n }\n\n // this.dispatchEvent(new CustomEvent('invalid', {}));\n this._dispatchEvent('invalid');\n }\n }\n }\n\n handleRelevant() {\n // console.log('mip valid', this.modelItem.enabled);\n if (this.isEnabled() !== this.modelItem.relevant) {\n if (this.modelItem.relevant) {\n this._dispatchEvent('relevant');\n // this._fadeIn(this, this.display);\n this.style.display = this.display;\n } else {\n this._dispatchEvent('nonrelevant');\n // this._fadeOut(this);\n this.style.display = 'none';\n }\n }\n }\n\n isRequired() {\n if (this.widget.hasAttribute('required')) {\n return true;\n }\n return false;\n }\n\n isValid() {\n if (this.classList.contains('invalid')) {\n return false;\n }\n return true;\n }\n\n isReadonly() {\n // const widget = this.querySelector('#widget');\n if (this.widget.hasAttribute('readonly')) {\n return true;\n }\n return false;\n }\n\n isEnabled() {\n // if(this.style.display === 'none' || this.classList.contains('non-relevant')){\n if (this.style.display === 'none') {\n return false;\n }\n return true;\n }\n\n // eslint-disable-next-line class-methods-use-this\n _fadeOut(el) {\n el.style.opacity = 1;\n\n (function fade() {\n // eslint-disable-next-line no-cond-assign\n if ((el.style.opacity -= 0.1) < 0) {\n el.style.display = 'none';\n } else {\n requestAnimationFrame(fade);\n }\n })();\n }\n\n // eslint-disable-next-line class-methods-use-this\n _fadeIn(el, display) {\n el.style.opacity = 0;\n el.style.display = display || 'block';\n\n (function fade() {\n let val = parseFloat(el.style.opacity);\n // eslint-disable-next-line no-cond-assign\n if (!((val += 0.1) > 1)) {\n el.style.opacity = val;\n requestAnimationFrame(fade);\n }\n })();\n }\n}\n\nwindow.customElements.define('fx-abstract-control', AbstractControl);\n","import AbstractControl from './abstract-control.js';\n\nexport class FxAlert extends AbstractControl {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n const style = `\n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n display: none;\n }\n `;\n\n const html = `\n \n `;\n\n this.shadowRoot.innerHTML = `\n \n ${html}\n `;\n }\n\n async updateWidgetValue() {\n console.log('alert update', this);\n this.innerHTML = this.value;\n }\n}\ncustomElements.define('fx-alert', FxAlert);\n","import XfAbstractControl from './abstract-control.js';\nimport { evaluateXPath, evaluateXPathToString, evaluateXPathToNodes } from '../xpath-evaluation.js';\nimport getInScopeContext from '../getInScopeContext.js';\nimport { Fore } from '../fore.js';\n\nconst WIDGETCLASS = 'widget';\n\n/**\n * `fx-control`\n * a generic wrapper for controls\n *\n *\n *\n * @customElement\n * @demo demo/index.html\n */\nexport default class FxControl extends XfAbstractControl {\n constructor() {\n super();\n this.inited = false;\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.updateEvent = this.hasAttribute('update-event')\n ? this.getAttribute('update-event')\n : 'blur';\n this.valueProp = this.hasAttribute('value-prop') ? this.getAttribute('value-prop') : 'value';\n this.label = this.hasAttribute('label') ? this.getAttribute('label') : null;\n const style = `\n :host{\n display:inline-block;\n }\n `;\n\n /*\n const controlHtml = `\n \n \n `;\n*/\n\n /*\n this.shadowRoot.innerHTML = `\n \n ${controlHtml}\n `\n*/\n this.shadowRoot.innerHTML = `\n \n ${this.renderHTML(this.ref)}\n `;\n\n this.widget = this.getWidget();\n // console.log('widget ', this.widget);\n\n // ### convenience marker event\n if (this.updateEvent === 'enter') {\n this.widget.addEventListener('keyup', event => {\n if (event.keyCode === 13) {\n // Cancel the default action, if needed\n event.preventDefault();\n this.setValue(this.widget[this.valueProp]);\n }\n });\n this.updateEvent = 'blur'; // needs to be registered too\n }\n this.widget.addEventListener(this.updateEvent, () => {\n // console.log('eventlistener ', this.updateEvent);\n this.setValue(this.widget[this.valueProp]);\n });\n\n const slot = this.shadowRoot.querySelector('slot');\n this.template = this.querySelector('template');\n // console.log('template',this.template);\n }\n\n setValue(val) {\n const modelitem = this.getModelItem();\n const setval = this.shadowRoot.getElementById('setvalue');\n setval.setValue(modelitem, val);\n setval.actionPerformed();\n }\n\n renderHTML(ref) {\n return `\n ${this.label ? `${this.label}` : ''}\n \n \n `;\n }\n\n /**\n *\n * @returns {HTMLElement|*}\n */\n getWidget() {\n if (this.widget) return this.widget;\n let widget = this.querySelector(`.${WIDGETCLASS}`);\n if (!widget) {\n widget = this.querySelector('input');\n }\n if (!widget) {\n const input = document.createElement('input');\n input.classList.add(WIDGETCLASS);\n input.setAttribute('type', 'text');\n this.appendChild(input);\n return input;\n }\n return widget;\n }\n\n // todo: check again\n async updateWidgetValue() {\n // this.widget[this.valueProp] = this.value;\n if (this.valueProp === 'checked') {\n if (this.value === 'true') {\n this.widget.checked = true;\n } else {\n this.widget.checked = false;\n }\n } else {\n let { widget } = this;\n if (!widget) {\n widget = this;\n }\n if(this.hasAttribute('as')){\n const as = this.getAttribute('as');\n if(as === 'text'){\n const serializer = new XMLSerializer();\n const pretty = Fore.prettifyXml(serializer.serializeToString(this.nodeset))\n widget.value = pretty;\n }\n }else{\n widget.value = this.value;\n }\n }\n }\n\n getTemplate() {\n return this.querySelector('template');\n }\n\n async refresh(force) {\n console.log('fx-control refresh', this);\n super.refresh();\n // console.log('refresh template', this.template);\n // const {widget} = this;\n\n // ### if we find a ref on control we have a 'select' control of some kind\n const widget = this.getWidget();\n if (widget.hasAttribute('ref')) {\n // ### eval nodeset for list control\n const ref = widget.getAttribute('ref');\n /*\n actually a ref on a select or similar component should point to a different instance\n with an absolute expr e.g. 'instance('theId')/...'\n\n todo: even bail out if ref is not absolute?\n */\n\n const inscope = getInScopeContext(this, ref);\n // const nodeset = evaluateXPathToNodes(ref, inscope, this);\n const nodeset = evaluateXPath(ref, inscope, this);\n\n // ### clear items\n const { children } = widget;\n Array.from(children).forEach(child => {\n if (child.nodeName.toLowerCase() !== 'template') {\n child.parentNode.removeChild(child);\n }\n });\n\n // ### build the items\n if (this.template) {\n if (nodeset.length) {\n // console.log('nodeset', nodeset);\n Array.from(nodeset).forEach(node => {\n // console.log('#### node', node);\n const newEntry = this.createEntry();\n\n // ### initialize new entry\n // ### set value\n this.updateEntry(newEntry, node);\n });\n } else {\n const newEntry = this.createEntry();\n this.updateEntry(newEntry, nodeset);\n }\n }\n }\n Fore.refreshChildren(this, force);\n }\n\n updateEntry(newEntry, node) {\n // ### >>> todo: needs rework this code is heavily assuming a select control with 'value' attribute - not generic at all yet.\n\n if (this.widget.nodeName !== 'SELECT') return;\n const valueAttribute = this._getValueAttribute(newEntry);\n const valueExpr = valueAttribute.value;\n const cutted = valueExpr.substring(1, valueExpr.length - 1);\n const evaluated = evaluateXPath(cutted, node, newEntry);\n valueAttribute.value = evaluated;\n\n if (this.value === evaluated) {\n newEntry.setAttribute('selected', 'selected');\n }\n\n // ### set label\n const optionLabel = newEntry.textContent;\n const labelExpr = optionLabel.substring(1, optionLabel.length - 1);\n\n const label = evaluateXPathToString(labelExpr, node, newEntry);\n newEntry.textContent = label;\n // ### <<< needs rework\n }\n\n createEntry() {\n const content = this.template.content.firstElementChild.cloneNode(true);\n const newEntry = document.importNode(content, true);\n this.template.parentNode.appendChild(newEntry);\n return newEntry;\n }\n\n // eslint-disable-next-line class-methods-use-this\n _getValueAttribute(element) {\n let result;\n Array.from(element.attributes).forEach(attribute => {\n const attrVal = attribute.value;\n if (attrVal.indexOf('{') !== -1) {\n // console.log('avt found ', attribute);\n result = attribute;\n }\n });\n return result;\n }\n}\n\nwindow.customElements.define('fx-control', FxControl);\n","import '../fx-model.js';\nimport { Fore } from '../fore.js';\nimport { foreElementMixin } from '../ForeElementMixin.js';\n\n/**\n * `fx-container` -\n * is a general class for container elements.\n *\n */\nexport class FxContainer extends foreElementMixin(HTMLElement) {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n const style = `\n :host {\n display: block;\n }\n `;\n\n const html = `\n \n `;\n\n this.shadowRoot.innerHTML = `\n \n ${html}\n `;\n\n this.getOwnerForm().registerLazyElement(this);\n }\n\n /**\n * (re)apply all state properties to this control.\n */\n refresh(force) {\n if (!force && this.hasAttribute('refresh-on-view')) return;\n // console.log('### FxContainer.refresh on : ', this);\n\n if (this.isBound()) {\n this.evalInContext();\n this.modelItem = this.getModelItem();\n if(!this.modelItem.boundControls.includes(this)){\n this.modelItem.boundControls.push(this);\n }\n\n // this.value = this.modelItem.value;\n }\n\n // await this.updateComplete;\n\n // state change event do not fire during init phase (initial refresh)\n if (this._getForm().ready) {\n this.handleModelItemProperties();\n }\n Fore.refreshChildren(this, force);\n }\n\n handleModelItemProperties() {\n this.handleReadonly();\n this.handleRelevant();\n }\n\n _getForm() {\n return this.getModel().parentNode;\n }\n\n handleReadonly() {\n // console.log('mip readonly', this.modelItem.isReadonly);\n if (this.isReadonly() !== this.modelItem.readonly) {\n if (this.modelItem.readonly) {\n this.setAttribute('readonly', 'readonly');\n this.dispatchEvent(new CustomEvent('readonly', {}));\n }\n if (!this.modelItem.readonly) {\n this.removeAttribute('readonly');\n this.dispatchEvent(new CustomEvent('readwrite', {}));\n }\n }\n }\n\n handleRelevant() {\n // console.log('mip valid', this.modelItem.enabled);\n if (!this.modelItem) return;\n\n if (this.isEnabled() !== this.modelItem.enabled) {\n if (this.modelItem.enabled) {\n this.dispatchEvent(new CustomEvent('enabled', {}));\n } else {\n this.dispatchEvent(new CustomEvent('disabled', {}));\n }\n }\n }\n\n isReadonly() {\n if (this.hasAttribute('readonly')) {\n return true;\n }\n return false;\n }\n\n isEnabled() {\n if (this.style.display === 'none') {\n return false;\n }\n return true;\n }\n}\n\nwindow.customElements.define('fx-container', FxContainer);\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n/**\n * True if the custom elements polyfill is in use.\n */\nexport const isCEPolyfill = typeof window !== 'undefined' &&\n window.customElements != null &&\n window.customElements.polyfillWrapFlushCallback !==\n undefined;\n/**\n * Reparents nodes, starting from `start` (inclusive) to `end` (exclusive),\n * into another container (could be the same container), before `before`. If\n * `before` is null, it appends the nodes to the container.\n */\nexport const reparentNodes = (container, start, end = null, before = null) => {\n while (start !== end) {\n const n = start.nextSibling;\n container.insertBefore(start, before);\n start = n;\n }\n};\n/**\n * Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from\n * `container`.\n */\nexport const removeNodes = (container, start, end = null) => {\n while (start !== end) {\n const n = start.nextSibling;\n container.removeChild(start);\n start = n;\n }\n};\n//# sourceMappingURL=dom.js.map","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n/**\n * An expression marker with embedded unique key to avoid collision with\n * possible text in templates.\n */\nexport const marker = `{{lit-${String(Math.random()).slice(2)}}}`;\n/**\n * An expression marker used text-positions, multi-binding attributes, and\n * attributes with markup-like text values.\n */\nexport const nodeMarker = ``;\nexport const markerRegex = new RegExp(`${marker}|${nodeMarker}`);\n/**\n * Suffix appended to all bound attribute names.\n */\nexport const boundAttributeSuffix = '$lit$';\n/**\n * An updatable Template that tracks the location of dynamic parts.\n */\nexport class Template {\n constructor(result, element) {\n this.parts = [];\n this.element = element;\n const nodesToRemove = [];\n const stack = [];\n // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null\n const walker = document.createTreeWalker(element.content, 133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */, null, false);\n // Keeps track of the last index associated with a part. We try to delete\n // unnecessary nodes, but we never want to associate two different parts\n // to the same index. They must have a constant node between.\n let lastPartIndex = 0;\n let index = -1;\n let partIndex = 0;\n const { strings, values: { length } } = result;\n while (partIndex < length) {\n const node = walker.nextNode();\n if (node === null) {\n // We've exhausted the content inside a nested template element.\n // Because we still have parts (the outer for-loop), we know:\n // - There is a template in the stack\n // - The walker will find a nextNode outside the template\n walker.currentNode = stack.pop();\n continue;\n }\n index++;\n if (node.nodeType === 1 /* Node.ELEMENT_NODE */) {\n if (node.hasAttributes()) {\n const attributes = node.attributes;\n const { length } = attributes;\n // Per\n // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap,\n // attributes are not guaranteed to be returned in document order.\n // In particular, Edge/IE can return them out of order, so we cannot\n // assume a correspondence between part index and attribute index.\n let count = 0;\n for (let i = 0; i < length; i++) {\n if (endsWith(attributes[i].name, boundAttributeSuffix)) {\n count++;\n }\n }\n while (count-- > 0) {\n // Get the template literal section leading up to the first\n // expression in this attribute\n const stringForPart = strings[partIndex];\n // Find the attribute name\n const name = lastAttributeNameRegex.exec(stringForPart)[2];\n // Find the corresponding attribute\n // All bound attributes have had a suffix added in\n // TemplateResult#getHTML to opt out of special attribute\n // handling. To look up the attribute value we also need to add\n // the suffix.\n const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;\n const attributeValue = node.getAttribute(attributeLookupName);\n node.removeAttribute(attributeLookupName);\n const statics = attributeValue.split(markerRegex);\n this.parts.push({ type: 'attribute', index, name, strings: statics });\n partIndex += statics.length - 1;\n }\n }\n if (node.tagName === 'TEMPLATE') {\n stack.push(node);\n walker.currentNode = node.content;\n }\n }\n else if (node.nodeType === 3 /* Node.TEXT_NODE */) {\n const data = node.data;\n if (data.indexOf(marker) >= 0) {\n const parent = node.parentNode;\n const strings = data.split(markerRegex);\n const lastIndex = strings.length - 1;\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for node parts\n for (let i = 0; i < lastIndex; i++) {\n let insert;\n let s = strings[i];\n if (s === '') {\n insert = createMarker();\n }\n else {\n const match = lastAttributeNameRegex.exec(s);\n if (match !== null && endsWith(match[2], boundAttributeSuffix)) {\n s = s.slice(0, match.index) + match[1] +\n match[2].slice(0, -boundAttributeSuffix.length) + match[3];\n }\n insert = document.createTextNode(s);\n }\n parent.insertBefore(insert, node);\n this.parts.push({ type: 'node', index: ++index });\n }\n // If there's no text, we must insert a comment to mark our place.\n // Else, we can trust it will stick around after cloning.\n if (strings[lastIndex] === '') {\n parent.insertBefore(createMarker(), node);\n nodesToRemove.push(node);\n }\n else {\n node.data = strings[lastIndex];\n }\n // We have a part for each match found\n partIndex += lastIndex;\n }\n }\n else if (node.nodeType === 8 /* Node.COMMENT_NODE */) {\n if (node.data === marker) {\n const parent = node.parentNode;\n // Add a new marker node to be the startNode of the Part if any of\n // the following are true:\n // * We don't have a previousSibling\n // * The previousSibling is already the start of a previous part\n if (node.previousSibling === null || index === lastPartIndex) {\n index++;\n parent.insertBefore(createMarker(), node);\n }\n lastPartIndex = index;\n this.parts.push({ type: 'node', index });\n // If we don't have a nextSibling, keep this node so we have an end.\n // Else, we can remove it to save future costs.\n if (node.nextSibling === null) {\n node.data = '';\n }\n else {\n nodesToRemove.push(node);\n index--;\n }\n partIndex++;\n }\n else {\n let i = -1;\n while ((i = node.data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n // TODO (justinfagnani): consider whether it's even worth it to\n // make bindings in comments work\n this.parts.push({ type: 'node', index: -1 });\n partIndex++;\n }\n }\n }\n }\n // Remove text binding nodes after the walk to not disturb the TreeWalker\n for (const n of nodesToRemove) {\n n.parentNode.removeChild(n);\n }\n }\n}\nconst endsWith = (str, suffix) => {\n const index = str.length - suffix.length;\n return index >= 0 && str.slice(index) === suffix;\n};\nexport const isTemplatePartActive = (part) => part.index !== -1;\n// Allows `document.createComment('')` to be renamed for a\n// small manual size-savings.\nexport const createMarker = () => document.createComment('');\n/**\n * This regex extracts the attribute name preceding an attribute-position\n * expression. It does this by matching the syntax allowed for attributes\n * against the string literal directly preceding the expression, assuming that\n * the expression is in an attribute-value position.\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\x09\\x0a\\x0c\\x0d\" are HTML space characters:\n * https://www.w3.org/TR/html5/infrastructure.html#space-characters\n *\n * \"\\0-\\x1F\\x7F-\\x9F\" are Unicode control characters, which includes every\n * space character except \" \".\n *\n * So an attribute is:\n * * The name: any character except a control character, space character, ('),\n * (\"), \">\", \"=\", or \"/\"\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nexport const lastAttributeNameRegex = \n// eslint-disable-next-line no-control-regex\n/([ \\x09\\x0a\\x0c\\x0d])([^\\0-\\x1F\\x7F-\\x9F \"'>=/]+)([ \\x09\\x0a\\x0c\\x0d]*=[ \\x09\\x0a\\x0c\\x0d]*(?:[^ \\x09\\x0a\\x0c\\x0d\"'`<>=]*|\"[^\"]*|'[^']*))$/;\n//# sourceMappingURL=template.js.map","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\nconst directives = new WeakMap();\n/**\n * Brands a function as a directive factory function so that lit-html will call\n * the function during template rendering, rather than passing as a value.\n *\n * A _directive_ is a function that takes a Part as an argument. It has the\n * signature: `(part: Part) => void`.\n *\n * A directive _factory_ is a function that takes arguments for data and\n * configuration and returns a directive. Users of directive usually refer to\n * the directive factory as the directive. For example, \"The repeat directive\".\n *\n * Usually a template author will invoke a directive factory in their template\n * with relevant arguments, which will then return a directive function.\n *\n * Here's an example of using the `repeat()` directive factory that takes an\n * array and a function to render an item:\n *\n * ```js\n * html`
    <${repeat(items, (item) => html`
  • ${item}
  • `)}
`\n * ```\n *\n * When `repeat` is invoked, it returns a directive function that closes over\n * `items` and the template function. When the outer template is rendered, the\n * return directive function is called with the Part for the expression.\n * `repeat` then performs it's custom logic to render multiple items.\n *\n * @param f The directive factory function. Must be a function that returns a\n * function of the signature `(part: Part) => void`. The returned function will\n * be called with the part object.\n *\n * @example\n *\n * import {directive, html} from 'lit-html';\n *\n * const immutable = directive((v) => (part) => {\n * if (part.value !== v) {\n * part.setValue(v)\n * }\n * });\n */\nexport const directive = (f) => ((...args) => {\n const d = f(...args);\n directives.set(d, true);\n return d;\n});\nexport const isDirective = (o) => {\n return typeof o === 'function' && directives.has(o);\n};\n//# sourceMappingURL=directive.js.map","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = {};\n/**\n * A sentinel value that signals a NodePart to fully clear its content.\n */\nexport const nothing = {};\n//# sourceMappingURL=part.js.map","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\nimport { isCEPolyfill } from './dom.js';\nimport { isTemplatePartActive } from './template.js';\n/**\n * An instance of a `Template` that can be attached to the DOM and updated\n * with new values.\n */\nexport class TemplateInstance {\n constructor(template, processor, options) {\n this.__parts = [];\n this.template = template;\n this.processor = processor;\n this.options = options;\n }\n update(values) {\n let i = 0;\n for (const part of this.__parts) {\n if (part !== undefined) {\n part.setValue(values[i]);\n }\n i++;\n }\n for (const part of this.__parts) {\n if (part !== undefined) {\n part.commit();\n }\n }\n }\n _clone() {\n // There are a number of steps in the lifecycle of a template instance's\n // DOM fragment:\n // 1. Clone - create the instance fragment\n // 2. Adopt - adopt into the main document\n // 3. Process - find part markers and create parts\n // 4. Upgrade - upgrade custom elements\n // 5. Update - set node, attribute, property, etc., values\n // 6. Connect - connect to the document. Optional and outside of this\n // method.\n //\n // We have a few constraints on the ordering of these steps:\n // * We need to upgrade before updating, so that property values will pass\n // through any property setters.\n // * We would like to process before upgrading so that we're sure that the\n // cloned fragment is inert and not disturbed by self-modifying DOM.\n // * We want custom elements to upgrade even in disconnected fragments.\n //\n // Given these constraints, with full custom elements support we would\n // prefer the order: Clone, Process, Adopt, Upgrade, Update, Connect\n //\n // But Safari does not implement CustomElementRegistry#upgrade, so we\n // can not implement that order and still have upgrade-before-update and\n // upgrade disconnected fragments. So we instead sacrifice the\n // process-before-upgrade constraint, since in Custom Elements v1 elements\n // must not modify their light DOM in the constructor. We still have issues\n // when co-existing with CEv0 elements like Polymer 1, and with polyfills\n // that don't strictly adhere to the no-modification rule because shadow\n // DOM, which may be created in the constructor, is emulated by being placed\n // in the light DOM.\n //\n // The resulting order is on native is: Clone, Adopt, Upgrade, Process,\n // Update, Connect. document.importNode() performs Clone, Adopt, and Upgrade\n // in one step.\n //\n // The Custom Elements v1 polyfill supports upgrade(), so the order when\n // polyfilled is the more ideal: Clone, Process, Adopt, Upgrade, Update,\n // Connect.\n const fragment = isCEPolyfill ?\n this.template.element.content.cloneNode(true) :\n document.importNode(this.template.element.content, true);\n const stack = [];\n const parts = this.template.parts;\n // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null\n const walker = document.createTreeWalker(fragment, 133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */, null, false);\n let partIndex = 0;\n let nodeIndex = 0;\n let part;\n let node = walker.nextNode();\n // Loop through all the nodes and parts of a template\n while (partIndex < parts.length) {\n part = parts[partIndex];\n if (!isTemplatePartActive(part)) {\n this.__parts.push(undefined);\n partIndex++;\n continue;\n }\n // Progress the tree walker until we find our next part's node.\n // Note that multiple parts may share the same node (attribute parts\n // on a single element), so this loop may not run at all.\n while (nodeIndex < part.index) {\n nodeIndex++;\n if (node.nodeName === 'TEMPLATE') {\n stack.push(node);\n walker.currentNode = node.content;\n }\n if ((node = walker.nextNode()) === null) {\n // We've exhausted the content inside a nested template element.\n // Because we still have parts (the outer for-loop), we know:\n // - There is a template in the stack\n // - The walker will find a nextNode outside the template\n walker.currentNode = stack.pop();\n node = walker.nextNode();\n }\n }\n // We've arrived at our part's node.\n if (part.type === 'node') {\n const part = this.processor.handleTextExpression(this.options);\n part.insertAfterNode(node.previousSibling);\n this.__parts.push(part);\n }\n else {\n this.__parts.push(...this.processor.handleAttributeExpressions(node, part.name, part.strings, this.options));\n }\n partIndex++;\n }\n if (isCEPolyfill) {\n document.adoptNode(fragment);\n customElements.upgrade(fragment);\n }\n return fragment;\n }\n}\n//# sourceMappingURL=template-instance.js.map","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n/**\n * @module lit-html\n */\nimport { reparentNodes } from './dom.js';\nimport { boundAttributeSuffix, lastAttributeNameRegex, marker, nodeMarker } from './template.js';\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = window.trustedTypes &&\n trustedTypes.createPolicy('lit-html', { createHTML: (s) => s });\nconst commentMarker = ` ${marker} `;\n/**\n * The return type of `html`, which holds a Template and the values from\n * interpolated expressions.\n */\nexport class TemplateResult {\n constructor(strings, values, type, processor) {\n this.strings = strings;\n this.values = values;\n this.type = type;\n this.processor = processor;\n }\n /**\n * Returns a string of HTML used to create a `