From 6c331ed7345d392e9579e412b06a910f52bdae9b Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 13 Jun 2024 07:03:50 -0700 Subject: [PATCH] Fix plugins --- plugins/exporter-curl/vite.config.js | 2 +- plugins/filter-jsonpath/vite.config.js | 2 +- plugins/filter-xpath/vite.config.js | 2 +- plugins/importer-curl/vite.config.js | 2 +- plugins/importer-insomnia/vite.config.js | 2 +- plugins/importer-postman/vite.config.js | 2 +- plugins/importer-yaak/vite.config.js | 2 +- src-tauri/plugins/exporter-curl/index.mjs | 49 +-- src-tauri/plugins/exporter-curl/index.mjs.map | 1 + src-tauri/plugins/filter-jsonpath/index.mjs | 43 +-- .../plugins/filter-jsonpath/index.mjs.map | 1 + src-tauri/plugins/filter-xpath/index.mjs | 7 +- src-tauri/plugins/filter-xpath/index.mjs.map | 1 + src-tauri/plugins/importer-curl/index.mjs | 298 ++++++++++++++++++ src-tauri/plugins/importer-curl/index.mjs.map | 1 + src-tauri/plugins/importer-insomnia/index.mjs | 184 +++++++++++ .../plugins/importer-insomnia/index.mjs.map | 1 + src-tauri/plugins/importer-postman/index.mjs | 184 +++++++++++ .../plugins/importer-postman/index.mjs.map | 1 + src-tauri/plugins/importer-yaak/index.mjs | 18 ++ src-tauri/plugins/importer-yaak/index.mjs.map | 1 + src-tauri/src/lib.rs | 10 +- src-tauri/src/plugin.rs | 33 +- src-tauri/tauri.conf.json | 3 +- src-web/components/ExportDataDialog.tsx | 4 +- ...ckForUpdates.ts => useCheckForUpdates.tsx} | 11 +- 26 files changed, 793 insertions(+), 72 deletions(-) create mode 100644 src-tauri/plugins/exporter-curl/index.mjs.map create mode 100644 src-tauri/plugins/filter-jsonpath/index.mjs.map create mode 100644 src-tauri/plugins/filter-xpath/index.mjs.map create mode 100644 src-tauri/plugins/importer-curl/index.mjs create mode 100644 src-tauri/plugins/importer-curl/index.mjs.map create mode 100644 src-tauri/plugins/importer-insomnia/index.mjs create mode 100644 src-tauri/plugins/importer-insomnia/index.mjs.map create mode 100644 src-tauri/plugins/importer-postman/index.mjs create mode 100644 src-tauri/plugins/importer-postman/index.mjs.map create mode 100644 src-tauri/plugins/importer-yaak/index.mjs create mode 100644 src-tauri/plugins/importer-yaak/index.mjs.map rename src-web/hooks/{useCheckForUpdates.ts => useCheckForUpdates.tsx} (60%) diff --git a/plugins/exporter-curl/vite.config.js b/plugins/exporter-curl/vite.config.js index 787b3345..8ae4262f 100644 --- a/plugins/exporter-curl/vite.config.js +++ b/plugins/exporter-curl/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/exporter-curl'), }, }); diff --git a/plugins/filter-jsonpath/vite.config.js b/plugins/filter-jsonpath/vite.config.js index 175fa69e..1067fae6 100644 --- a/plugins/filter-jsonpath/vite.config.js +++ b/plugins/filter-jsonpath/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/filter-jsonpath'), }, }); diff --git a/plugins/filter-xpath/vite.config.js b/plugins/filter-xpath/vite.config.js index 175fa69e..d3e785d6 100644 --- a/plugins/filter-xpath/vite.config.js +++ b/plugins/filter-xpath/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/filter-xpath'), }, }); diff --git a/plugins/importer-curl/vite.config.js b/plugins/importer-curl/vite.config.js index 787b3345..ad176f6d 100644 --- a/plugins/importer-curl/vite.config.js +++ b/plugins/importer-curl/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/importer-curl'), }, }); diff --git a/plugins/importer-insomnia/vite.config.js b/plugins/importer-insomnia/vite.config.js index 787b3345..7a7d6121 100644 --- a/plugins/importer-insomnia/vite.config.js +++ b/plugins/importer-insomnia/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/importer-insomnia'), }, }); diff --git a/plugins/importer-postman/vite.config.js b/plugins/importer-postman/vite.config.js index 787b3345..93e8a483 100644 --- a/plugins/importer-postman/vite.config.js +++ b/plugins/importer-postman/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/importer-postman'), }, }); diff --git a/plugins/importer-yaak/vite.config.js b/plugins/importer-yaak/vite.config.js index 787b3345..c52411a7 100644 --- a/plugins/importer-yaak/vite.config.js +++ b/plugins/importer-yaak/vite.config.js @@ -10,6 +10,6 @@ export default defineConfig({ }, emptyOutDir: true, sourcemap: true, - outDir: resolve(__dirname, 'build'), + outDir: resolve(__dirname, '../../src-tauri/plugins/importer-yaak'), }, }); diff --git a/src-tauri/plugins/exporter-curl/index.mjs b/src-tauri/plugins/exporter-curl/index.mjs index b86fa095..5d490123 100644 --- a/src-tauri/plugins/exporter-curl/index.mjs +++ b/src-tauri/plugins/exporter-curl/index.mjs @@ -1,36 +1,37 @@ const o = `\\ `; -function d(n) { - var h, f, r, u, l, s; - const t = ["curl"]; - n.method && t.push("-X", n.method), n.url && t.push(i(n.url)), t.push(o); - for (const a of (n.urlParameters ?? []).filter(p)) - t.push("--url-query", i(`${a.name}=${a.value}`)), t.push(o); - for (const a of (n.headers ?? []).filter(p)) - t.push("--header", i(`${a.name}: ${a.value}`)), t.push(o); - if (Array.isArray((h = n.body) == null ? void 0 : h.form)) { - const a = n.bodyType === "multipart/form-data" ? "--form" : "--data"; - for (const e of (((f = n.body) == null ? void 0 : f.form) ?? []).filter(p)) { +function y(p, t) { + var f, r, u, l, s, c; + const n = ["curl"]; + t.method && n.push("-X", t.method), t.url && n.push(i(t.url)), n.push(o); + for (const a of (t.urlParameters ?? []).filter(h)) + n.push("--url-query", i(`${a.name}=${a.value}`)), n.push(o); + for (const a of (t.headers ?? []).filter(h)) + n.push("--header", i(`${a.name}: ${a.value}`)), n.push(o); + if (Array.isArray((f = t.body) == null ? void 0 : f.form)) { + const a = t.bodyType === "multipart/form-data" ? "--form" : "--data"; + for (const e of (((r = t.body) == null ? void 0 : r.form) ?? []).filter(h)) { if (e.file) { - let c = `${e.name}=@${e.file}`; - c += e.contentType ? `;type=${e.contentType}` : "", t.push(a, c); + let d = `${e.name}=@${e.file}`; + d += e.contentType ? `;type=${e.contentType}` : "", n.push(a, d); } else - t.push(a, i(`${e.name}=${e.value}`)); - t.push(o); + n.push(a, i(`${e.name}=${e.value}`)); + n.push(o); } } else - typeof ((r = n.body) == null ? void 0 : r.text) == "string" && (t.push("--data-raw", `$${i(n.body.text)}`), t.push(o)); - return (n.authenticationType === "basic" || n.authenticationType === "digest") && (n.authenticationType === "digest" && t.push("--digest"), t.push( + typeof ((u = t.body) == null ? void 0 : u.text) == "string" && (n.push("--data-raw", `$${i(t.body.text)}`), n.push(o)); + return (t.authenticationType === "basic" || t.authenticationType === "digest") && (t.authenticationType === "digest" && n.push("--digest"), n.push( "--user", - i(`${((u = n.authentication) == null ? void 0 : u.username) ?? ""}:${((l = n.authentication) == null ? void 0 : l.password) ?? ""}`) - ), t.push(o)), n.authenticationType === "bearer" && (t.push("--header", i(`Authorization: Bearer ${((s = n.authentication) == null ? void 0 : s.token) ?? ""}`)), t.push(o)), t[t.length - 1] === o && t.splice(t.length - 1, 1), t.join(" "); + i(`${((l = t.authentication) == null ? void 0 : l.username) ?? ""}:${((s = t.authentication) == null ? void 0 : s.password) ?? ""}`) + ), n.push(o)), t.authenticationType === "bearer" && (n.push("--header", i(`Authorization: Bearer ${((c = t.authentication) == null ? void 0 : c.token) ?? ""}`)), n.push(o)), n[n.length - 1] === o && n.splice(n.length - 1, 1), n.join(" "); } -function i(n) { - return `'${n.replace(/'/g, "\\'")}'`; +function i(p) { + return `'${p.replace(/'/g, "\\'")}'`; } -function p(n) { - return n.enabled !== !1 && !!n.name; +function h(p) { + return p.enabled !== !1 && !!p.name; } export { - d as pluginHookExport + y as pluginHookExport }; +//# sourceMappingURL=index.mjs.map diff --git a/src-tauri/plugins/exporter-curl/index.mjs.map b/src-tauri/plugins/exporter-curl/index.mjs.map new file mode 100644 index 00000000..6714617d --- /dev/null +++ b/src-tauri/plugins/exporter-curl/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../../../plugins/exporter-curl/src/index.ts"],"sourcesContent":["import { HttpRequest } from '../../../src-web/lib/models';\n\nconst NEWLINE = '\\\\\\n ';\n\nexport function pluginHookExport(_: any, request: Partial) {\n const xs = ['curl'];\n\n // Add method and URL all on first line\n if (request.method) xs.push('-X', request.method);\n if (request.url) xs.push(quote(request.url));\n\n xs.push(NEWLINE);\n\n // Add URL params\n for (const p of (request.urlParameters ?? []).filter(onlyEnabled)) {\n xs.push('--url-query', quote(`${p.name}=${p.value}`));\n xs.push(NEWLINE);\n }\n\n // Add headers\n for (const h of (request.headers ?? []).filter(onlyEnabled)) {\n xs.push('--header', quote(`${h.name}: ${h.value}`));\n xs.push(NEWLINE);\n }\n\n // Add form params\n if (Array.isArray(request.body?.form)) {\n const flag = request.bodyType === 'multipart/form-data' ? '--form' : '--data';\n for (const p of (request.body?.form ?? []).filter(onlyEnabled)) {\n if (p.file) {\n let v = `${p.name}=@${p.file}`;\n v += p.contentType ? `;type=${p.contentType}` : '';\n xs.push(flag, v);\n } else {\n xs.push(flag, quote(`${p.name}=${p.value}`));\n }\n xs.push(NEWLINE);\n }\n } else if (typeof request.body?.text === 'string') {\n // --data-raw $'...' to do special ANSI C quoting\n xs.push('--data-raw', `$${quote(request.body.text)}`);\n xs.push(NEWLINE);\n }\n\n // Add basic/digest authentication\n if (request.authenticationType === 'basic' || request.authenticationType === 'digest') {\n if (request.authenticationType === 'digest') xs.push('--digest');\n xs.push(\n '--user',\n quote(`${request.authentication?.username ?? ''}:${request.authentication?.password ?? ''}`),\n );\n xs.push(NEWLINE);\n }\n\n // Add bearer authentication\n if (request.authenticationType === 'bearer') {\n xs.push('--header', quote(`Authorization: Bearer ${request.authentication?.token ?? ''}`));\n xs.push(NEWLINE);\n }\n\n // Remove trailing newline\n if (xs[xs.length - 1] === NEWLINE) {\n xs.splice(xs.length - 1, 1);\n }\n\n return xs.join(' ');\n}\n\nfunction quote(arg: string): string {\n const escaped = arg.replace(/'/g, \"\\\\'\");\n return `'${escaped}'`;\n}\n\nfunction onlyEnabled(v: { name?: string; enabled?: boolean }): boolean {\n return v.enabled !== false && !!v.name;\n}\n"],"names":["NEWLINE","pluginHookExport","_","request","_a","_b","_c","_d","_e","_f","xs","quote","p","onlyEnabled","h","flag","v","arg"],"mappings":"AAEA,MAAMA,IAAU;AAAA;AAEA,SAAAC,EAAiBC,GAAQC,GAA+B;AAFxE,MAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAGQ,QAAAC,IAAK,CAAC,MAAM;AAGlB,EAAIP,EAAQ,UAAWO,EAAA,KAAK,MAAMP,EAAQ,MAAM,GAC5CA,EAAQ,OAAKO,EAAG,KAAKC,EAAMR,EAAQ,GAAG,CAAC,GAE3CO,EAAG,KAAKV,CAAO;AAGf,aAAWY,MAAMT,EAAQ,iBAAiB,IAAI,OAAOU,CAAW;AAC3D,IAAAH,EAAA,KAAK,eAAeC,EAAM,GAAGC,EAAE,IAAI,IAAIA,EAAE,KAAK,EAAE,CAAC,GACpDF,EAAG,KAAKV,CAAO;AAIjB,aAAWc,MAAMX,EAAQ,WAAW,IAAI,OAAOU,CAAW;AACrD,IAAAH,EAAA,KAAK,YAAYC,EAAM,GAAGG,EAAE,IAAI,KAAKA,EAAE,KAAK,EAAE,CAAC,GAClDJ,EAAG,KAAKV,CAAO;AAIjB,MAAI,MAAM,SAAQI,IAAAD,EAAQ,SAAR,gBAAAC,EAAc,IAAI,GAAG;AACrC,UAAMW,IAAOZ,EAAQ,aAAa,wBAAwB,WAAW;AAC1D,eAAAS,QAAMP,IAAAF,EAAQ,SAAR,gBAAAE,EAAc,SAAQ,CAAI,GAAA,OAAOQ,CAAW,GAAG;AAC9D,UAAID,EAAE,MAAM;AACV,YAAII,IAAI,GAAGJ,EAAE,IAAI,KAAKA,EAAE,IAAI;AAC5B,QAAAI,KAAKJ,EAAE,cAAc,SAASA,EAAE,WAAW,KAAK,IAC7CF,EAAA,KAAKK,GAAMC,CAAC;AAAA,MAAA;AAEZ,QAAAN,EAAA,KAAKK,GAAMJ,EAAM,GAAGC,EAAE,IAAI,IAAIA,EAAE,KAAK,EAAE,CAAC;AAE7C,MAAAF,EAAG,KAAKV,CAAO;AAAA,IACjB;AAAA,EACS;AAAA,IAAA,SAAOM,IAAAH,EAAQ,SAAR,gBAAAG,EAAc,SAAS,aAEpCI,EAAA,KAAK,cAAc,IAAIC,EAAMR,EAAQ,KAAK,IAAI,CAAC,EAAE,GACpDO,EAAG,KAAKV,CAAO;AAIjB,UAAIG,EAAQ,uBAAuB,WAAWA,EAAQ,uBAAuB,cACvEA,EAAQ,uBAAuB,YAAUO,EAAG,KAAK,UAAU,GAC5DA,EAAA;AAAA,IACD;AAAA,IACAC,EAAM,KAAGJ,IAAAJ,EAAQ,mBAAR,gBAAAI,EAAwB,aAAY,EAAE,MAAIC,IAAAL,EAAQ,mBAAR,gBAAAK,EAAwB,aAAY,EAAE,EAAE;AAAA,EAAA,GAE7FE,EAAG,KAAKV,CAAO,IAIbG,EAAQ,uBAAuB,aAC9BO,EAAA,KAAK,YAAYC,EAAM,2BAAyBF,IAAAN,EAAQ,mBAAR,gBAAAM,EAAwB,UAAS,EAAE,EAAE,CAAC,GACzFC,EAAG,KAAKV,CAAO,IAIbU,EAAGA,EAAG,SAAS,CAAC,MAAMV,KACxBU,EAAG,OAAOA,EAAG,SAAS,GAAG,CAAC,GAGrBA,EAAG,KAAK,GAAG;AACpB;AAEA,SAASC,EAAMM,GAAqB;AAElC,SAAO,IADSA,EAAI,QAAQ,MAAM,KAAK,CACrB;AACpB;AAEA,SAASJ,EAAYG,GAAkD;AACrE,SAAOA,EAAE,YAAY,MAAS,CAAC,CAACA,EAAE;AACpC;"} \ No newline at end of file diff --git a/src-tauri/plugins/filter-jsonpath/index.mjs b/src-tauri/plugins/filter-jsonpath/index.mjs index 43d7285e..37d99330 100644 --- a/src-tauri/plugins/filter-jsonpath/index.mjs +++ b/src-tauri/plugins/filter-jsonpath/index.mjs @@ -1,15 +1,15 @@ var Xe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; -function Nt(le) { - return le && le.__esModule && Object.prototype.hasOwnProperty.call(le, "default") ? le.default : le; +function Nt(ce) { + return ce && ce.__esModule && Object.prototype.hasOwnProperty.call(ce, "default") ? ce.default : ce; } -function Be(le) { - throw new Error('Could not dynamically require "' + le + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +function Be(ce) { + throw new Error('Could not dynamically require "' + ce + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var Ve = { exports: {} }; /*! jsonpath 1.1.1 */ -(function(le, Ne) { +(function(ce, Ne) { (function(T) { - le.exports = T(); + ce.exports = T(); })(function() { return function T(L, B, v) { function y(E, d) { @@ -1131,7 +1131,7 @@ var Ve = { exports: {} }; function Ze() { var e = [], t; for (t = i, O("["); !_("]"); ) - _(",") ? (N(), e.push(null)) : (e.push(ce()), _("]") || O(",")); + _(",") ? (N(), e.push(null)) : (e.push(le()), _("]") || O(",")); return N(), n.markEnd(n.createArrayExpression(e), t); } function _e(e, t) { @@ -1145,11 +1145,11 @@ var Ve = { exports: {} }; function et() { var e, t, u, l, C, x; if (e = i, x = i, e.type === y.Identifier) - return u = De(), e.value === "get" && !_(":") ? (t = De(), O("("), O(")"), l = _e([]), n.markEnd(n.createProperty("get", t, l), x)) : e.value === "set" && !_(":") ? (t = De(), O("("), e = i, e.type !== y.Identifier ? (O(")"), G(e, a.UnexpectedToken, e.value), l = _e([])) : (C = [ye()], O(")"), l = _e(C, e)), n.markEnd(n.createProperty("set", t, l), x)) : (O(":"), l = ce(), n.markEnd(n.createProperty("init", u, l), x)); + return u = De(), e.value === "get" && !_(":") ? (t = De(), O("("), O(")"), l = _e([]), n.markEnd(n.createProperty("get", t, l), x)) : e.value === "set" && !_(":") ? (t = De(), O("("), e = i, e.type !== y.Identifier ? (O(")"), G(e, a.UnexpectedToken, e.value), l = _e([])) : (C = [ye()], O(")"), l = _e(C, e)), n.markEnd(n.createProperty("set", t, l), x)) : (O(":"), l = le(), n.markEnd(n.createProperty("init", u, l), x)); if (e.type === y.EOF || e.type === y.Punctuator) pe(e); else - return t = De(), O(":"), l = ce(), n.markEnd(n.createProperty("init", t, l), x); + return t = De(), O(":"), l = le(), n.markEnd(n.createProperty("init", t, l), x); } function tt() { var e = [], t, u, l, C, x = {}, j = String, W; @@ -1184,7 +1184,7 @@ var Ve = { exports: {} }; function je() { var e = []; if (O("("), !_(")")) - for (; r < h && (e.push(ce()), !_(")")); ) + for (; r < h && (e.push(le()), !_(")")); ) O(","); return O(")"), e; } @@ -1300,17 +1300,17 @@ var Ve = { exports: {} }; } function st() { var e, t, u, l, C; - return C = i, e = at(), _("?") && (N(), t = p.allowIn, p.allowIn = !0, u = ce(), p.allowIn = t, O(":"), l = ce(), e = n.createConditionalExpression(e, u, l), n.markEnd(e, C)), e; + return C = i, e = at(), _("?") && (N(), t = p.allowIn, p.allowIn = !0, u = le(), p.allowIn = t, O(":"), l = le(), e = n.createConditionalExpression(e, u, l), n.markEnd(e, C)), e; } - function ce() { + function le() { var e, t, u, l, C; - return e = i, C = i, l = t = st(), Ye() && (be(t) || G({}, a.InvalidLHSInAssignment), c && t.type === E.Identifier && J(t.name) && G(e, a.StrictLHSAssignment), e = N(), u = ce(), l = n.markEnd(n.createAssignmentExpression(e.value, t, u), C)), l; + return e = i, C = i, l = t = st(), Ye() && (be(t) || G({}, a.InvalidLHSInAssignment), c && t.type === E.Identifier && J(t.name) && G(e, a.StrictLHSAssignment), e = N(), u = le(), l = n.markEnd(n.createAssignmentExpression(e.value, t, u), C)), l; } function te() { var e, t = i; - if (e = ce(), _(",")) { + if (e = le(), _(",")) { for (e = n.createSequenceExpression([e]); r < h && _(","); ) - N(), e.expressions.push(ce()); + N(), e.expressions.push(le()); n.markEnd(e, t); } return e; @@ -1330,7 +1330,7 @@ var Ve = { exports: {} }; } function lt(e) { var t = null, u, l; - return l = i, u = ye(), c && J(u.name) && G({}, a.StrictVarName), e === "const" ? (O("="), t = ce()) : _("=") && (N(), t = ce()), n.markEnd(n.createVariableDeclarator(u, t), l); + return l = i, u = ye(), c && J(u.name) && G({}, a.StrictVarName), e === "const" ? (O("="), t = le()) : _("=") && (N(), t = le()), n.markEnd(n.createVariableDeclarator(u, t), l); } function Te(e) { var t = []; @@ -3176,16 +3176,17 @@ Expecting ` + se.join(", ") + ", got '" + (this.terminals_[w] || w) + "'" : ie = })(Ve); var Pt = Ve.exports; const Lt = /* @__PURE__ */ Nt(Pt); -function Rt(le, Ne) { - let T; +function Rt(ce, Ne, T) { + let L; try { - T = JSON.parse(Ne); + L = JSON.parse(T); } catch { return; } - const L = Lt.query(T, le); - return { filtered: JSON.stringify(L, null, 2) }; + const B = Lt.query(L, Ne); + return { filtered: JSON.stringify(B, null, 2) }; } export { Rt as pluginHookResponseFilter }; +//# sourceMappingURL=index.mjs.map diff --git a/src-tauri/plugins/filter-jsonpath/index.mjs.map b/src-tauri/plugins/filter-jsonpath/index.mjs.map new file mode 100644 index 00000000..57ed164e --- /dev/null +++ b/src-tauri/plugins/filter-jsonpath/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../../../plugins/filter-jsonpath/node_modules/jsonpath/jsonpath.js","../../../plugins/filter-jsonpath/src/index.js"],"sourcesContent":["/*! jsonpath 1.1.1 */\n\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.jsonpath = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o\n Copyright (C) 2013 Thaddee Tyl \n Copyright (C) 2013 Mathias Bynens \n Copyright (C) 2012 Ariya Hidayat \n Copyright (C) 2012 Mathias Bynens \n Copyright (C) 2012 Joost-Wim Boekesteijn \n Copyright (C) 2012 Kris Kowal \n Copyright (C) 2012 Yusuke Suzuki \n Copyright (C) 2012 Arpad Borsos \n Copyright (C) 2011 Ariya Hidayat \n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*jslint bitwise:true plusplus:true */\n/*global esprima:true, define:true, exports:true, window: true,\nthrowErrorTolerant: true,\nthrowError: true, generateStatement: true, peek: true,\nparseAssignmentExpression: true, parseBlock: true, parseExpression: true,\nparseFunctionDeclaration: true, parseFunctionExpression: true,\nparseFunctionSourceElements: true, parseVariableIdentifier: true,\nparseLeftHandSideExpression: true,\nparseUnaryExpression: true,\nparseStatement: true, parseSourceElement: true */\n\n(function (root, factory) {\n 'use strict';\n\n // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,\n // Rhino, and plain browser loading.\n\n /* istanbul ignore next */\n if (typeof define === 'function' && define.amd) {\n define(['exports'], factory);\n } else if (typeof exports !== 'undefined') {\n factory(exports);\n } else {\n factory((root.esprima = {}));\n }\n}(this, function (exports) {\n 'use strict';\n\n var Token,\n TokenName,\n FnExprTokens,\n Syntax,\n PropertyKind,\n Messages,\n Regex,\n SyntaxTreeDelegate,\n source,\n strict,\n index,\n lineNumber,\n lineStart,\n length,\n delegate,\n lookahead,\n state,\n extra;\n\n Token = {\n BooleanLiteral: 1,\n EOF: 2,\n Identifier: 3,\n Keyword: 4,\n NullLiteral: 5,\n NumericLiteral: 6,\n Punctuator: 7,\n StringLiteral: 8,\n RegularExpression: 9\n };\n\n TokenName = {};\n TokenName[Token.BooleanLiteral] = 'Boolean';\n TokenName[Token.EOF] = '';\n TokenName[Token.Identifier] = 'Identifier';\n TokenName[Token.Keyword] = 'Keyword';\n TokenName[Token.NullLiteral] = 'Null';\n TokenName[Token.NumericLiteral] = 'Numeric';\n TokenName[Token.Punctuator] = 'Punctuator';\n TokenName[Token.StringLiteral] = 'String';\n TokenName[Token.RegularExpression] = 'RegularExpression';\n\n // A function following one of those tokens is an expression.\n FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',\n 'return', 'case', 'delete', 'throw', 'void',\n // assignment operators\n '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',\n '&=', '|=', '^=', ',',\n // binary/unary operators\n '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',\n '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',\n '<=', '<', '>', '!=', '!=='];\n\n Syntax = {\n AssignmentExpression: 'AssignmentExpression',\n ArrayExpression: 'ArrayExpression',\n BlockStatement: 'BlockStatement',\n BinaryExpression: 'BinaryExpression',\n BreakStatement: 'BreakStatement',\n CallExpression: 'CallExpression',\n CatchClause: 'CatchClause',\n ConditionalExpression: 'ConditionalExpression',\n ContinueStatement: 'ContinueStatement',\n DoWhileStatement: 'DoWhileStatement',\n DebuggerStatement: 'DebuggerStatement',\n EmptyStatement: 'EmptyStatement',\n ExpressionStatement: 'ExpressionStatement',\n ForStatement: 'ForStatement',\n ForInStatement: 'ForInStatement',\n FunctionDeclaration: 'FunctionDeclaration',\n FunctionExpression: 'FunctionExpression',\n Identifier: 'Identifier',\n IfStatement: 'IfStatement',\n Literal: 'Literal',\n LabeledStatement: 'LabeledStatement',\n LogicalExpression: 'LogicalExpression',\n MemberExpression: 'MemberExpression',\n NewExpression: 'NewExpression',\n ObjectExpression: 'ObjectExpression',\n Program: 'Program',\n Property: 'Property',\n ReturnStatement: 'ReturnStatement',\n SequenceExpression: 'SequenceExpression',\n SwitchStatement: 'SwitchStatement',\n SwitchCase: 'SwitchCase',\n ThisExpression: 'ThisExpression',\n ThrowStatement: 'ThrowStatement',\n TryStatement: 'TryStatement',\n UnaryExpression: 'UnaryExpression',\n UpdateExpression: 'UpdateExpression',\n VariableDeclaration: 'VariableDeclaration',\n VariableDeclarator: 'VariableDeclarator',\n WhileStatement: 'WhileStatement',\n WithStatement: 'WithStatement'\n };\n\n PropertyKind = {\n Data: 1,\n Get: 2,\n Set: 4\n };\n\n // Error messages should be identical to V8.\n Messages = {\n UnexpectedToken: 'Unexpected token %0',\n UnexpectedNumber: 'Unexpected number',\n UnexpectedString: 'Unexpected string',\n UnexpectedIdentifier: 'Unexpected identifier',\n UnexpectedReserved: 'Unexpected reserved word',\n UnexpectedEOS: 'Unexpected end of input',\n NewlineAfterThrow: 'Illegal newline after throw',\n InvalidRegExp: 'Invalid regular expression',\n UnterminatedRegExp: 'Invalid regular expression: missing /',\n InvalidLHSInAssignment: 'Invalid left-hand side in assignment',\n InvalidLHSInForIn: 'Invalid left-hand side in for-in',\n MultipleDefaultsInSwitch: 'More than one default clause in switch statement',\n NoCatchOrFinally: 'Missing catch or finally after try',\n UnknownLabel: 'Undefined label \\'%0\\'',\n Redeclaration: '%0 \\'%1\\' has already been declared',\n IllegalContinue: 'Illegal continue statement',\n IllegalBreak: 'Illegal break statement',\n IllegalReturn: 'Illegal return statement',\n StrictModeWith: 'Strict mode code may not include a with statement',\n StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',\n StrictVarName: 'Variable name may not be eval or arguments in strict mode',\n StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',\n StrictParamDupe: 'Strict mode function may not have duplicate parameter names',\n StrictFunctionName: 'Function name may not be eval or arguments in strict mode',\n StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',\n StrictDelete: 'Delete of an unqualified identifier in strict mode.',\n StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',\n AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',\n AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',\n StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',\n StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',\n StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',\n StrictReservedWord: 'Use of future reserved word in strict mode'\n };\n\n // See also tools/generate-unicode-regex.py.\n Regex = {\n NonAsciiIdentifierStart: new RegExp('[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F0\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]'),\n NonAsciiIdentifierPart: new RegExp('[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0\\u08A2-\\u08AC\\u08E4-\\u08FE\\u0900-\\u0963\\u0966-\\u096F\\u0971-\\u0977\\u0979-\\u097F\\u0981-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C01-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C82\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D02\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F0\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1D00-\\u1DE6\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA697\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A\\uAA7B\\uAA80-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE26\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]')\n };\n\n // Ensure the condition is true, otherwise throw an error.\n // This is only to have a better contract semantic, i.e. another safety net\n // to catch a logic error. The condition shall be fulfilled in normal case.\n // Do NOT use this to enforce a certain condition on any user input.\n\n function assert(condition, message) {\n /* istanbul ignore if */\n if (!condition) {\n throw new Error('ASSERT: ' + message);\n }\n }\n\n function isDecimalDigit(ch) {\n return (ch >= 48 && ch <= 57); // 0..9\n }\n\n function isHexDigit(ch) {\n return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;\n }\n\n function isOctalDigit(ch) {\n return '01234567'.indexOf(ch) >= 0;\n }\n\n\n // 7.2 White Space\n\n function isWhiteSpace(ch) {\n return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||\n (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0);\n }\n\n // 7.3 Line Terminators\n\n function isLineTerminator(ch) {\n return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029);\n }\n\n // 7.6 Identifier Names and Identifiers\n\n function isIdentifierStart(ch) {\n return (ch == 0x40) || (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore)\n (ch >= 0x41 && ch <= 0x5A) || // A..Z\n (ch >= 0x61 && ch <= 0x7A) || // a..z\n (ch === 0x5C) || // \\ (backslash)\n ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));\n }\n\n function isIdentifierPart(ch) {\n return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore)\n (ch >= 0x41 && ch <= 0x5A) || // A..Z\n (ch >= 0x61 && ch <= 0x7A) || // a..z\n (ch >= 0x30 && ch <= 0x39) || // 0..9\n (ch === 0x5C) || // \\ (backslash)\n ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));\n }\n\n // 7.6.1.2 Future Reserved Words\n\n function isFutureReservedWord(id) {\n switch (id) {\n case 'class':\n case 'enum':\n case 'export':\n case 'extends':\n case 'import':\n case 'super':\n return true;\n default:\n return false;\n }\n }\n\n function isStrictModeReservedWord(id) {\n switch (id) {\n case 'implements':\n case 'interface':\n case 'package':\n case 'private':\n case 'protected':\n case 'public':\n case 'static':\n case 'yield':\n case 'let':\n return true;\n default:\n return false;\n }\n }\n\n function isRestrictedWord(id) {\n return id === 'eval' || id === 'arguments';\n }\n\n // 7.6.1.1 Keywords\n\n function isKeyword(id) {\n if (strict && isStrictModeReservedWord(id)) {\n return true;\n }\n\n // 'const' is specialized as Keyword in V8.\n // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next.\n // Some others are from future reserved words.\n\n switch (id.length) {\n case 2:\n return (id === 'if') || (id === 'in') || (id === 'do');\n case 3:\n return (id === 'var') || (id === 'for') || (id === 'new') ||\n (id === 'try') || (id === 'let');\n case 4:\n return (id === 'this') || (id === 'else') || (id === 'case') ||\n (id === 'void') || (id === 'with') || (id === 'enum');\n case 5:\n return (id === 'while') || (id === 'break') || (id === 'catch') ||\n (id === 'throw') || (id === 'const') || (id === 'yield') ||\n (id === 'class') || (id === 'super');\n case 6:\n return (id === 'return') || (id === 'typeof') || (id === 'delete') ||\n (id === 'switch') || (id === 'export') || (id === 'import');\n case 7:\n return (id === 'default') || (id === 'finally') || (id === 'extends');\n case 8:\n return (id === 'function') || (id === 'continue') || (id === 'debugger');\n case 10:\n return (id === 'instanceof');\n default:\n return false;\n }\n }\n\n // 7.4 Comments\n\n function addComment(type, value, start, end, loc) {\n var comment, attacher;\n\n assert(typeof start === 'number', 'Comment must have valid position');\n\n // Because the way the actual token is scanned, often the comments\n // (if any) are skipped twice during the lexical analysis.\n // Thus, we need to skip adding a comment if the comment array already\n // handled it.\n if (state.lastCommentStart >= start) {\n return;\n }\n state.lastCommentStart = start;\n\n comment = {\n type: type,\n value: value\n };\n if (extra.range) {\n comment.range = [start, end];\n }\n if (extra.loc) {\n comment.loc = loc;\n }\n extra.comments.push(comment);\n if (extra.attachComment) {\n extra.leadingComments.push(comment);\n extra.trailingComments.push(comment);\n }\n }\n\n function skipSingleLineComment(offset) {\n var start, loc, ch, comment;\n\n start = index - offset;\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart - offset\n }\n };\n\n while (index < length) {\n ch = source.charCodeAt(index);\n ++index;\n if (isLineTerminator(ch)) {\n if (extra.comments) {\n comment = source.slice(start + offset, index - 1);\n loc.end = {\n line: lineNumber,\n column: index - lineStart - 1\n };\n addComment('Line', comment, start, index - 1, loc);\n }\n if (ch === 13 && source.charCodeAt(index) === 10) {\n ++index;\n }\n ++lineNumber;\n lineStart = index;\n return;\n }\n }\n\n if (extra.comments) {\n comment = source.slice(start + offset, index);\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n addComment('Line', comment, start, index, loc);\n }\n }\n\n function skipMultiLineComment() {\n var start, loc, ch, comment;\n\n if (extra.comments) {\n start = index - 2;\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart - 2\n }\n };\n }\n\n while (index < length) {\n ch = source.charCodeAt(index);\n if (isLineTerminator(ch)) {\n if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) {\n ++index;\n }\n ++lineNumber;\n ++index;\n lineStart = index;\n if (index >= length) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n } else if (ch === 0x2A) {\n // Block comment ends with '*/'.\n if (source.charCodeAt(index + 1) === 0x2F) {\n ++index;\n ++index;\n if (extra.comments) {\n comment = source.slice(start + 2, index - 2);\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n addComment('Block', comment, start, index, loc);\n }\n return;\n }\n ++index;\n } else {\n ++index;\n }\n }\n\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n function skipComment() {\n var ch, start;\n\n start = (index === 0);\n while (index < length) {\n ch = source.charCodeAt(index);\n\n if (isWhiteSpace(ch)) {\n ++index;\n } else if (isLineTerminator(ch)) {\n ++index;\n if (ch === 0x0D && source.charCodeAt(index) === 0x0A) {\n ++index;\n }\n ++lineNumber;\n lineStart = index;\n start = true;\n } else if (ch === 0x2F) { // U+002F is '/'\n ch = source.charCodeAt(index + 1);\n if (ch === 0x2F) {\n ++index;\n ++index;\n skipSingleLineComment(2);\n start = true;\n } else if (ch === 0x2A) { // U+002A is '*'\n ++index;\n ++index;\n skipMultiLineComment();\n } else {\n break;\n }\n } else if (start && ch === 0x2D) { // U+002D is '-'\n // U+003E is '>'\n if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) {\n // '-->' is a single-line comment\n index += 3;\n skipSingleLineComment(3);\n } else {\n break;\n }\n } else if (ch === 0x3C) { // U+003C is '<'\n if (source.slice(index + 1, index + 4) === '!--') {\n ++index; // `<`\n ++index; // `!`\n ++index; // `-`\n ++index; // `-`\n skipSingleLineComment(4);\n } else {\n break;\n }\n } else {\n break;\n }\n }\n }\n\n function scanHexEscape(prefix) {\n var i, len, ch, code = 0;\n\n len = (prefix === 'u') ? 4 : 2;\n for (i = 0; i < len; ++i) {\n if (index < length && isHexDigit(source[index])) {\n ch = source[index++];\n code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());\n } else {\n return '';\n }\n }\n return String.fromCharCode(code);\n }\n\n function getEscapedIdentifier() {\n var ch, id;\n\n ch = source.charCodeAt(index++);\n id = String.fromCharCode(ch);\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n if (ch === 0x5C) {\n if (source.charCodeAt(index) !== 0x75) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n ++index;\n ch = scanHexEscape('u');\n if (!ch || ch === '\\\\' || !isIdentifierStart(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n id = ch;\n }\n\n while (index < length) {\n ch = source.charCodeAt(index);\n if (!isIdentifierPart(ch)) {\n break;\n }\n ++index;\n id += String.fromCharCode(ch);\n\n // '\\u' (U+005C, U+0075) denotes an escaped character.\n if (ch === 0x5C) {\n id = id.substr(0, id.length - 1);\n if (source.charCodeAt(index) !== 0x75) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n ++index;\n ch = scanHexEscape('u');\n if (!ch || ch === '\\\\' || !isIdentifierPart(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n id += ch;\n }\n }\n\n return id;\n }\n\n function getIdentifier() {\n var start, ch;\n\n start = index++;\n while (index < length) {\n ch = source.charCodeAt(index);\n if (ch === 0x5C) {\n // Blackslash (U+005C) marks Unicode escape sequence.\n index = start;\n return getEscapedIdentifier();\n }\n if (isIdentifierPart(ch)) {\n ++index;\n } else {\n break;\n }\n }\n\n return source.slice(start, index);\n }\n\n function scanIdentifier() {\n var start, id, type;\n\n start = index;\n\n // Backslash (U+005C) starts an escaped character.\n id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier();\n\n // There is no keyword or literal with only one character.\n // Thus, it must be an identifier.\n if (id.length === 1) {\n type = Token.Identifier;\n } else if (isKeyword(id)) {\n type = Token.Keyword;\n } else if (id === 'null') {\n type = Token.NullLiteral;\n } else if (id === 'true' || id === 'false') {\n type = Token.BooleanLiteral;\n } else {\n type = Token.Identifier;\n }\n\n return {\n type: type,\n value: id,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n\n // 7.7 Punctuators\n\n function scanPunctuator() {\n var start = index,\n code = source.charCodeAt(index),\n code2,\n ch1 = source[index],\n ch2,\n ch3,\n ch4;\n\n switch (code) {\n\n // Check for most common single-character punctuators.\n case 0x2E: // . dot\n case 0x28: // ( open bracket\n case 0x29: // ) close bracket\n case 0x3B: // ; semicolon\n case 0x2C: // , comma\n case 0x7B: // { open curly brace\n case 0x7D: // } close curly brace\n case 0x5B: // [\n case 0x5D: // ]\n case 0x3A: // :\n case 0x3F: // ?\n case 0x7E: // ~\n ++index;\n if (extra.tokenize) {\n if (code === 0x28) {\n extra.openParenToken = extra.tokens.length;\n } else if (code === 0x7B) {\n extra.openCurlyToken = extra.tokens.length;\n }\n }\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n\n default:\n code2 = source.charCodeAt(index + 1);\n\n // '=' (U+003D) marks an assignment or comparison operator.\n if (code2 === 0x3D) {\n switch (code) {\n case 0x2B: // +\n case 0x2D: // -\n case 0x2F: // /\n case 0x3C: // <\n case 0x3E: // >\n case 0x5E: // ^\n case 0x7C: // |\n case 0x25: // %\n case 0x26: // &\n case 0x2A: // *\n index += 2;\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code) + String.fromCharCode(code2),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n\n case 0x21: // !\n case 0x3D: // =\n index += 2;\n\n // !== and ===\n if (source.charCodeAt(index) === 0x3D) {\n ++index;\n }\n return {\n type: Token.Punctuator,\n value: source.slice(start, index),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n }\n }\n\n // 4-character punctuator: >>>=\n\n ch4 = source.substr(index, 4);\n\n if (ch4 === '>>>=') {\n index += 4;\n return {\n type: Token.Punctuator,\n value: ch4,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 3-character punctuators: === !== >>> <<= >>=\n\n ch3 = ch4.substr(0, 3);\n\n if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') {\n index += 3;\n return {\n type: Token.Punctuator,\n value: ch3,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // Other 2-character punctuators: ++ -- << >> && ||\n ch2 = ch3.substr(0, 2);\n\n if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') {\n index += 2;\n return {\n type: Token.Punctuator,\n value: ch2,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 1-character punctuators: < > = ! + - * % & | ^ /\n if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {\n ++index;\n return {\n type: Token.Punctuator,\n value: ch1,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n // 7.8.3 Numeric Literals\n\n function scanHexLiteral(start) {\n var number = '';\n\n while (index < length) {\n if (!isHexDigit(source[index])) {\n break;\n }\n number += source[index++];\n }\n\n if (number.length === 0) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n if (isIdentifierStart(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseInt('0x' + number, 16),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function scanOctalLiteral(start) {\n var number = '0' + source[index++];\n while (index < length) {\n if (!isOctalDigit(source[index])) {\n break;\n }\n number += source[index++];\n }\n\n if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseInt(number, 8),\n octal: true,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function scanNumericLiteral() {\n var number, start, ch;\n\n ch = source[index];\n assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),\n 'Numeric literal must start with a decimal digit or a decimal point');\n\n start = index;\n number = '';\n if (ch !== '.') {\n number = source[index++];\n ch = source[index];\n\n // Hex number starts with '0x'.\n // Octal number starts with '0'.\n if (number === '0') {\n if (ch === 'x' || ch === 'X') {\n ++index;\n return scanHexLiteral(start);\n }\n if (isOctalDigit(ch)) {\n return scanOctalLiteral(start);\n }\n\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDecimalDigit(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === '.') {\n number += source[index++];\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === 'e' || ch === 'E') {\n number += source[index++];\n\n ch = source[index];\n if (ch === '+' || ch === '-') {\n number += source[index++];\n }\n if (isDecimalDigit(source.charCodeAt(index))) {\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n } else {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n if (isIdentifierStart(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseFloat(number),\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n // 7.8.4 String Literals\n\n function scanStringLiteral() {\n var str = '', quote, start, ch, code, unescaped, restore, octal = false, startLineNumber, startLineStart;\n startLineNumber = lineNumber;\n startLineStart = lineStart;\n\n quote = source[index];\n assert((quote === '\\'' || quote === '\"'),\n 'String literal must starts with a quote');\n\n start = index;\n ++index;\n\n while (index < length) {\n ch = source[index++];\n\n if (ch === quote) {\n quote = '';\n break;\n } else if (ch === '\\\\') {\n ch = source[index++];\n if (!ch || !isLineTerminator(ch.charCodeAt(0))) {\n switch (ch) {\n case 'u':\n case 'x':\n restore = index;\n unescaped = scanHexEscape(ch);\n if (unescaped) {\n str += unescaped;\n } else {\n index = restore;\n str += ch;\n }\n break;\n case 'n':\n str += '\\n';\n break;\n case 'r':\n str += '\\r';\n break;\n case 't':\n str += '\\t';\n break;\n case 'b':\n str += '\\b';\n break;\n case 'f':\n str += '\\f';\n break;\n case 'v':\n str += '\\x0B';\n break;\n\n default:\n if (isOctalDigit(ch)) {\n code = '01234567'.indexOf(ch);\n\n // \\0 is not octal escape sequence\n if (code !== 0) {\n octal = true;\n }\n\n if (index < length && isOctalDigit(source[index])) {\n octal = true;\n code = code * 8 + '01234567'.indexOf(source[index++]);\n\n // 3 digits are only allowed when string starts\n // with 0, 1, 2, 3\n if ('0123'.indexOf(ch) >= 0 &&\n index < length &&\n isOctalDigit(source[index])) {\n code = code * 8 + '01234567'.indexOf(source[index++]);\n }\n }\n str += String.fromCharCode(code);\n } else {\n str += ch;\n }\n break;\n }\n } else {\n ++lineNumber;\n if (ch === '\\r' && source[index] === '\\n') {\n ++index;\n }\n lineStart = index;\n }\n } else if (isLineTerminator(ch.charCodeAt(0))) {\n break;\n } else {\n str += ch;\n }\n }\n\n if (quote !== '') {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.StringLiteral,\n value: str,\n octal: octal,\n startLineNumber: startLineNumber,\n startLineStart: startLineStart,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n function testRegExp(pattern, flags) {\n var value;\n try {\n value = new RegExp(pattern, flags);\n } catch (e) {\n throwError({}, Messages.InvalidRegExp);\n }\n return value;\n }\n\n function scanRegExpBody() {\n var ch, str, classMarker, terminated, body;\n\n ch = source[index];\n assert(ch === '/', 'Regular expression literal must start with a slash');\n str = source[index++];\n\n classMarker = false;\n terminated = false;\n while (index < length) {\n ch = source[index++];\n str += ch;\n if (ch === '\\\\') {\n ch = source[index++];\n // ECMA-262 7.8.5\n if (isLineTerminator(ch.charCodeAt(0))) {\n throwError({}, Messages.UnterminatedRegExp);\n }\n str += ch;\n } else if (isLineTerminator(ch.charCodeAt(0))) {\n throwError({}, Messages.UnterminatedRegExp);\n } else if (classMarker) {\n if (ch === ']') {\n classMarker = false;\n }\n } else {\n if (ch === '/') {\n terminated = true;\n break;\n } else if (ch === '[') {\n classMarker = true;\n }\n }\n }\n\n if (!terminated) {\n throwError({}, Messages.UnterminatedRegExp);\n }\n\n // Exclude leading and trailing slash.\n body = str.substr(1, str.length - 2);\n return {\n value: body,\n literal: str\n };\n }\n\n function scanRegExpFlags() {\n var ch, str, flags, restore;\n\n str = '';\n flags = '';\n while (index < length) {\n ch = source[index];\n if (!isIdentifierPart(ch.charCodeAt(0))) {\n break;\n }\n\n ++index;\n if (ch === '\\\\' && index < length) {\n ch = source[index];\n if (ch === 'u') {\n ++index;\n restore = index;\n ch = scanHexEscape('u');\n if (ch) {\n flags += ch;\n for (str += '\\\\u'; restore < index; ++restore) {\n str += source[restore];\n }\n } else {\n index = restore;\n flags += 'u';\n str += '\\\\u';\n }\n throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');\n } else {\n str += '\\\\';\n throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n } else {\n flags += ch;\n str += ch;\n }\n }\n\n return {\n value: flags,\n literal: str\n };\n }\n\n function scanRegExp() {\n var start, body, flags, pattern, value;\n\n lookahead = null;\n skipComment();\n start = index;\n\n body = scanRegExpBody();\n flags = scanRegExpFlags();\n value = testRegExp(body.value, flags.value);\n\n if (extra.tokenize) {\n return {\n type: Token.RegularExpression,\n value: value,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: start,\n end: index\n };\n }\n\n return {\n literal: body.literal + flags.literal,\n value: value,\n start: start,\n end: index\n };\n }\n\n function collectRegex() {\n var pos, loc, regex, token;\n\n skipComment();\n\n pos = index;\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart\n }\n };\n\n regex = scanRegExp();\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n\n /* istanbul ignore next */\n if (!extra.tokenize) {\n // Pop the previous token, which is likely '/' or '/='\n if (extra.tokens.length > 0) {\n token = extra.tokens[extra.tokens.length - 1];\n if (token.range[0] === pos && token.type === 'Punctuator') {\n if (token.value === '/' || token.value === '/=') {\n extra.tokens.pop();\n }\n }\n }\n\n extra.tokens.push({\n type: 'RegularExpression',\n value: regex.literal,\n range: [pos, index],\n loc: loc\n });\n }\n\n return regex;\n }\n\n function isIdentifierName(token) {\n return token.type === Token.Identifier ||\n token.type === Token.Keyword ||\n token.type === Token.BooleanLiteral ||\n token.type === Token.NullLiteral;\n }\n\n function advanceSlash() {\n var prevToken,\n checkToken;\n // Using the following algorithm:\n // https://github.com/mozilla/sweet.js/wiki/design\n prevToken = extra.tokens[extra.tokens.length - 1];\n if (!prevToken) {\n // Nothing before that: it cannot be a division.\n return collectRegex();\n }\n if (prevToken.type === 'Punctuator') {\n if (prevToken.value === ']') {\n return scanPunctuator();\n }\n if (prevToken.value === ')') {\n checkToken = extra.tokens[extra.openParenToken - 1];\n if (checkToken &&\n checkToken.type === 'Keyword' &&\n (checkToken.value === 'if' ||\n checkToken.value === 'while' ||\n checkToken.value === 'for' ||\n checkToken.value === 'with')) {\n return collectRegex();\n }\n return scanPunctuator();\n }\n if (prevToken.value === '}') {\n // Dividing a function by anything makes little sense,\n // but we have to check for that.\n if (extra.tokens[extra.openCurlyToken - 3] &&\n extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {\n // Anonymous function.\n checkToken = extra.tokens[extra.openCurlyToken - 4];\n if (!checkToken) {\n return scanPunctuator();\n }\n } else if (extra.tokens[extra.openCurlyToken - 4] &&\n extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {\n // Named function.\n checkToken = extra.tokens[extra.openCurlyToken - 5];\n if (!checkToken) {\n return collectRegex();\n }\n } else {\n return scanPunctuator();\n }\n // checkToken determines whether the function is\n // a declaration or an expression.\n if (FnExprTokens.indexOf(checkToken.value) >= 0) {\n // It is an expression.\n return scanPunctuator();\n }\n // It is a declaration.\n return collectRegex();\n }\n return collectRegex();\n }\n if (prevToken.type === 'Keyword') {\n return collectRegex();\n }\n return scanPunctuator();\n }\n\n function advance() {\n var ch;\n\n skipComment();\n\n if (index >= length) {\n return {\n type: Token.EOF,\n lineNumber: lineNumber,\n lineStart: lineStart,\n start: index,\n end: index\n };\n }\n\n ch = source.charCodeAt(index);\n\n if (isIdentifierStart(ch)) {\n return scanIdentifier();\n }\n\n // Very common: ( and ) and ;\n if (ch === 0x28 || ch === 0x29 || ch === 0x3B) {\n return scanPunctuator();\n }\n\n // String literal starts with single quote (U+0027) or double quote (U+0022).\n if (ch === 0x27 || ch === 0x22) {\n return scanStringLiteral();\n }\n\n\n // Dot (.) U+002E can also start a floating-point number, hence the need\n // to check the next character.\n if (ch === 0x2E) {\n if (isDecimalDigit(source.charCodeAt(index + 1))) {\n return scanNumericLiteral();\n }\n return scanPunctuator();\n }\n\n if (isDecimalDigit(ch)) {\n return scanNumericLiteral();\n }\n\n // Slash (/) U+002F can also start a regex.\n if (extra.tokenize && ch === 0x2F) {\n return advanceSlash();\n }\n\n return scanPunctuator();\n }\n\n function collectToken() {\n var loc, token, range, value;\n\n skipComment();\n loc = {\n start: {\n line: lineNumber,\n column: index - lineStart\n }\n };\n\n token = advance();\n loc.end = {\n line: lineNumber,\n column: index - lineStart\n };\n\n if (token.type !== Token.EOF) {\n value = source.slice(token.start, token.end);\n extra.tokens.push({\n type: TokenName[token.type],\n value: value,\n range: [token.start, token.end],\n loc: loc\n });\n }\n\n return token;\n }\n\n function lex() {\n var token;\n\n token = lookahead;\n index = token.end;\n lineNumber = token.lineNumber;\n lineStart = token.lineStart;\n\n lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();\n\n index = token.end;\n lineNumber = token.lineNumber;\n lineStart = token.lineStart;\n\n return token;\n }\n\n function peek() {\n var pos, line, start;\n\n pos = index;\n line = lineNumber;\n start = lineStart;\n lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();\n index = pos;\n lineNumber = line;\n lineStart = start;\n }\n\n function Position(line, column) {\n this.line = line;\n this.column = column;\n }\n\n function SourceLocation(startLine, startColumn, line, column) {\n this.start = new Position(startLine, startColumn);\n this.end = new Position(line, column);\n }\n\n SyntaxTreeDelegate = {\n\n name: 'SyntaxTree',\n\n processComment: function (node) {\n var lastChild, trailingComments;\n\n if (node.type === Syntax.Program) {\n if (node.body.length > 0) {\n return;\n }\n }\n\n if (extra.trailingComments.length > 0) {\n if (extra.trailingComments[0].range[0] >= node.range[1]) {\n trailingComments = extra.trailingComments;\n extra.trailingComments = [];\n } else {\n extra.trailingComments.length = 0;\n }\n } else {\n if (extra.bottomRightStack.length > 0 &&\n extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments &&\n extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments[0].range[0] >= node.range[1]) {\n trailingComments = extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments;\n delete extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments;\n }\n }\n\n // Eating the stack.\n while (extra.bottomRightStack.length > 0 && extra.bottomRightStack[extra.bottomRightStack.length - 1].range[0] >= node.range[0]) {\n lastChild = extra.bottomRightStack.pop();\n }\n\n if (lastChild) {\n if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {\n node.leadingComments = lastChild.leadingComments;\n delete lastChild.leadingComments;\n }\n } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {\n node.leadingComments = extra.leadingComments;\n extra.leadingComments = [];\n }\n\n\n if (trailingComments) {\n node.trailingComments = trailingComments;\n }\n\n extra.bottomRightStack.push(node);\n },\n\n markEnd: function (node, startToken) {\n if (extra.range) {\n node.range = [startToken.start, index];\n }\n if (extra.loc) {\n node.loc = new SourceLocation(\n startToken.startLineNumber === undefined ? startToken.lineNumber : startToken.startLineNumber,\n startToken.start - (startToken.startLineStart === undefined ? startToken.lineStart : startToken.startLineStart),\n lineNumber,\n index - lineStart\n );\n this.postProcess(node);\n }\n\n if (extra.attachComment) {\n this.processComment(node);\n }\n return node;\n },\n\n postProcess: function (node) {\n if (extra.source) {\n node.loc.source = extra.source;\n }\n return node;\n },\n\n createArrayExpression: function (elements) {\n return {\n type: Syntax.ArrayExpression,\n elements: elements\n };\n },\n\n createAssignmentExpression: function (operator, left, right) {\n return {\n type: Syntax.AssignmentExpression,\n operator: operator,\n left: left,\n right: right\n };\n },\n\n createBinaryExpression: function (operator, left, right) {\n var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :\n Syntax.BinaryExpression;\n return {\n type: type,\n operator: operator,\n left: left,\n right: right\n };\n },\n\n createBlockStatement: function (body) {\n return {\n type: Syntax.BlockStatement,\n body: body\n };\n },\n\n createBreakStatement: function (label) {\n return {\n type: Syntax.BreakStatement,\n label: label\n };\n },\n\n createCallExpression: function (callee, args) {\n return {\n type: Syntax.CallExpression,\n callee: callee,\n 'arguments': args\n };\n },\n\n createCatchClause: function (param, body) {\n return {\n type: Syntax.CatchClause,\n param: param,\n body: body\n };\n },\n\n createConditionalExpression: function (test, consequent, alternate) {\n return {\n type: Syntax.ConditionalExpression,\n test: test,\n consequent: consequent,\n alternate: alternate\n };\n },\n\n createContinueStatement: function (label) {\n return {\n type: Syntax.ContinueStatement,\n label: label\n };\n },\n\n createDebuggerStatement: function () {\n return {\n type: Syntax.DebuggerStatement\n };\n },\n\n createDoWhileStatement: function (body, test) {\n return {\n type: Syntax.DoWhileStatement,\n body: body,\n test: test\n };\n },\n\n createEmptyStatement: function () {\n return {\n type: Syntax.EmptyStatement\n };\n },\n\n createExpressionStatement: function (expression) {\n return {\n type: Syntax.ExpressionStatement,\n expression: expression\n };\n },\n\n createForStatement: function (init, test, update, body) {\n return {\n type: Syntax.ForStatement,\n init: init,\n test: test,\n update: update,\n body: body\n };\n },\n\n createForInStatement: function (left, right, body) {\n return {\n type: Syntax.ForInStatement,\n left: left,\n right: right,\n body: body,\n each: false\n };\n },\n\n createFunctionDeclaration: function (id, params, defaults, body) {\n return {\n type: Syntax.FunctionDeclaration,\n id: id,\n params: params,\n defaults: defaults,\n body: body,\n rest: null,\n generator: false,\n expression: false\n };\n },\n\n createFunctionExpression: function (id, params, defaults, body) {\n return {\n type: Syntax.FunctionExpression,\n id: id,\n params: params,\n defaults: defaults,\n body: body,\n rest: null,\n generator: false,\n expression: false\n };\n },\n\n createIdentifier: function (name) {\n return {\n type: Syntax.Identifier,\n name: name\n };\n },\n\n createIfStatement: function (test, consequent, alternate) {\n return {\n type: Syntax.IfStatement,\n test: test,\n consequent: consequent,\n alternate: alternate\n };\n },\n\n createLabeledStatement: function (label, body) {\n return {\n type: Syntax.LabeledStatement,\n label: label,\n body: body\n };\n },\n\n createLiteral: function (token) {\n return {\n type: Syntax.Literal,\n value: token.value,\n raw: source.slice(token.start, token.end)\n };\n },\n\n createMemberExpression: function (accessor, object, property) {\n return {\n type: Syntax.MemberExpression,\n computed: accessor === '[',\n object: object,\n property: property\n };\n },\n\n createNewExpression: function (callee, args) {\n return {\n type: Syntax.NewExpression,\n callee: callee,\n 'arguments': args\n };\n },\n\n createObjectExpression: function (properties) {\n return {\n type: Syntax.ObjectExpression,\n properties: properties\n };\n },\n\n createPostfixExpression: function (operator, argument) {\n return {\n type: Syntax.UpdateExpression,\n operator: operator,\n argument: argument,\n prefix: false\n };\n },\n\n createProgram: function (body) {\n return {\n type: Syntax.Program,\n body: body\n };\n },\n\n createProperty: function (kind, key, value) {\n return {\n type: Syntax.Property,\n key: key,\n value: value,\n kind: kind\n };\n },\n\n createReturnStatement: function (argument) {\n return {\n type: Syntax.ReturnStatement,\n argument: argument\n };\n },\n\n createSequenceExpression: function (expressions) {\n return {\n type: Syntax.SequenceExpression,\n expressions: expressions\n };\n },\n\n createSwitchCase: function (test, consequent) {\n return {\n type: Syntax.SwitchCase,\n test: test,\n consequent: consequent\n };\n },\n\n createSwitchStatement: function (discriminant, cases) {\n return {\n type: Syntax.SwitchStatement,\n discriminant: discriminant,\n cases: cases\n };\n },\n\n createThisExpression: function () {\n return {\n type: Syntax.ThisExpression\n };\n },\n\n createThrowStatement: function (argument) {\n return {\n type: Syntax.ThrowStatement,\n argument: argument\n };\n },\n\n createTryStatement: function (block, guardedHandlers, handlers, finalizer) {\n return {\n type: Syntax.TryStatement,\n block: block,\n guardedHandlers: guardedHandlers,\n handlers: handlers,\n finalizer: finalizer\n };\n },\n\n createUnaryExpression: function (operator, argument) {\n if (operator === '++' || operator === '--') {\n return {\n type: Syntax.UpdateExpression,\n operator: operator,\n argument: argument,\n prefix: true\n };\n }\n return {\n type: Syntax.UnaryExpression,\n operator: operator,\n argument: argument,\n prefix: true\n };\n },\n\n createVariableDeclaration: function (declarations, kind) {\n return {\n type: Syntax.VariableDeclaration,\n declarations: declarations,\n kind: kind\n };\n },\n\n createVariableDeclarator: function (id, init) {\n return {\n type: Syntax.VariableDeclarator,\n id: id,\n init: init\n };\n },\n\n createWhileStatement: function (test, body) {\n return {\n type: Syntax.WhileStatement,\n test: test,\n body: body\n };\n },\n\n createWithStatement: function (object, body) {\n return {\n type: Syntax.WithStatement,\n object: object,\n body: body\n };\n }\n };\n\n // Return true if there is a line terminator before the next token.\n\n function peekLineTerminator() {\n var pos, line, start, found;\n\n pos = index;\n line = lineNumber;\n start = lineStart;\n skipComment();\n found = lineNumber !== line;\n index = pos;\n lineNumber = line;\n lineStart = start;\n\n return found;\n }\n\n // Throw an exception\n\n function throwError(token, messageFormat) {\n var error,\n args = Array.prototype.slice.call(arguments, 2),\n msg = messageFormat.replace(\n /%(\\d)/g,\n function (whole, index) {\n assert(index < args.length, 'Message reference must be in range');\n return args[index];\n }\n );\n\n if (typeof token.lineNumber === 'number') {\n error = new Error('Line ' + token.lineNumber + ': ' + msg);\n error.index = token.start;\n error.lineNumber = token.lineNumber;\n error.column = token.start - lineStart + 1;\n } else {\n error = new Error('Line ' + lineNumber + ': ' + msg);\n error.index = index;\n error.lineNumber = lineNumber;\n error.column = index - lineStart + 1;\n }\n\n error.description = msg;\n throw error;\n }\n\n function throwErrorTolerant() {\n try {\n throwError.apply(null, arguments);\n } catch (e) {\n if (extra.errors) {\n extra.errors.push(e);\n } else {\n throw e;\n }\n }\n }\n\n\n // Throw an exception because of the token.\n\n function throwUnexpected(token) {\n if (token.type === Token.EOF) {\n throwError(token, Messages.UnexpectedEOS);\n }\n\n if (token.type === Token.NumericLiteral) {\n throwError(token, Messages.UnexpectedNumber);\n }\n\n if (token.type === Token.StringLiteral) {\n throwError(token, Messages.UnexpectedString);\n }\n\n if (token.type === Token.Identifier) {\n throwError(token, Messages.UnexpectedIdentifier);\n }\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n throwError(token, Messages.UnexpectedReserved);\n } else if (strict && isStrictModeReservedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictReservedWord);\n return;\n }\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // BooleanLiteral, NullLiteral, or Punctuator.\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // Expect the next token to match the specified punctuator.\n // If not, an exception will be thrown.\n\n function expect(value) {\n var token = lex();\n if (token.type !== Token.Punctuator || token.value !== value) {\n throwUnexpected(token);\n }\n }\n\n // Expect the next token to match the specified keyword.\n // If not, an exception will be thrown.\n\n function expectKeyword(keyword) {\n var token = lex();\n if (token.type !== Token.Keyword || token.value !== keyword) {\n throwUnexpected(token);\n }\n }\n\n // Return true if the next token matches the specified punctuator.\n\n function match(value) {\n return lookahead.type === Token.Punctuator && lookahead.value === value;\n }\n\n // Return true if the next token matches the specified keyword\n\n function matchKeyword(keyword) {\n return lookahead.type === Token.Keyword && lookahead.value === keyword;\n }\n\n // Return true if the next token is an assignment operator\n\n function matchAssign() {\n var op;\n\n if (lookahead.type !== Token.Punctuator) {\n return false;\n }\n op = lookahead.value;\n return op === '=' ||\n op === '*=' ||\n op === '/=' ||\n op === '%=' ||\n op === '+=' ||\n op === '-=' ||\n op === '<<=' ||\n op === '>>=' ||\n op === '>>>=' ||\n op === '&=' ||\n op === '^=' ||\n op === '|=';\n }\n\n function consumeSemicolon() {\n var line;\n\n // Catch the very common case first: immediately a semicolon (U+003B).\n if (source.charCodeAt(index) === 0x3B || match(';')) {\n lex();\n return;\n }\n\n line = lineNumber;\n skipComment();\n if (lineNumber !== line) {\n return;\n }\n\n if (lookahead.type !== Token.EOF && !match('}')) {\n throwUnexpected(lookahead);\n }\n }\n\n // Return true if provided expression is LeftHandSideExpression\n\n function isLeftHandSide(expr) {\n return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;\n }\n\n // 11.1.4 Array Initialiser\n\n function parseArrayInitialiser() {\n var elements = [], startToken;\n\n startToken = lookahead;\n expect('[');\n\n while (!match(']')) {\n if (match(',')) {\n lex();\n elements.push(null);\n } else {\n elements.push(parseAssignmentExpression());\n\n if (!match(']')) {\n expect(',');\n }\n }\n }\n\n lex();\n\n return delegate.markEnd(delegate.createArrayExpression(elements), startToken);\n }\n\n // 11.1.5 Object Initialiser\n\n function parsePropertyFunction(param, first) {\n var previousStrict, body, startToken;\n\n previousStrict = strict;\n startToken = lookahead;\n body = parseFunctionSourceElements();\n if (first && strict && isRestrictedWord(param[0].name)) {\n throwErrorTolerant(first, Messages.StrictParamName);\n }\n strict = previousStrict;\n return delegate.markEnd(delegate.createFunctionExpression(null, param, [], body), startToken);\n }\n\n function parseObjectPropertyKey() {\n var token, startToken;\n\n startToken = lookahead;\n token = lex();\n\n // Note: This function is called only from parseObjectProperty(), where\n // EOF and Punctuator tokens are already filtered out.\n\n if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {\n if (strict && token.octal) {\n throwErrorTolerant(token, Messages.StrictOctalLiteral);\n }\n return delegate.markEnd(delegate.createLiteral(token), startToken);\n }\n\n return delegate.markEnd(delegate.createIdentifier(token.value), startToken);\n }\n\n function parseObjectProperty() {\n var token, key, id, value, param, startToken;\n\n token = lookahead;\n startToken = lookahead;\n\n if (token.type === Token.Identifier) {\n\n id = parseObjectPropertyKey();\n\n // Property Assignment: Getter and Setter.\n\n if (token.value === 'get' && !match(':')) {\n key = parseObjectPropertyKey();\n expect('(');\n expect(')');\n value = parsePropertyFunction([]);\n return delegate.markEnd(delegate.createProperty('get', key, value), startToken);\n }\n if (token.value === 'set' && !match(':')) {\n key = parseObjectPropertyKey();\n expect('(');\n token = lookahead;\n if (token.type !== Token.Identifier) {\n expect(')');\n throwErrorTolerant(token, Messages.UnexpectedToken, token.value);\n value = parsePropertyFunction([]);\n } else {\n param = [ parseVariableIdentifier() ];\n expect(')');\n value = parsePropertyFunction(param, token);\n }\n return delegate.markEnd(delegate.createProperty('set', key, value), startToken);\n }\n expect(':');\n value = parseAssignmentExpression();\n return delegate.markEnd(delegate.createProperty('init', id, value), startToken);\n }\n if (token.type === Token.EOF || token.type === Token.Punctuator) {\n throwUnexpected(token);\n } else {\n key = parseObjectPropertyKey();\n expect(':');\n value = parseAssignmentExpression();\n return delegate.markEnd(delegate.createProperty('init', key, value), startToken);\n }\n }\n\n function parseObjectInitialiser() {\n var properties = [], property, name, key, kind, map = {}, toString = String, startToken;\n\n startToken = lookahead;\n\n expect('{');\n\n while (!match('}')) {\n property = parseObjectProperty();\n\n if (property.key.type === Syntax.Identifier) {\n name = property.key.name;\n } else {\n name = toString(property.key.value);\n }\n kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;\n\n key = '$' + name;\n if (Object.prototype.hasOwnProperty.call(map, key)) {\n if (map[key] === PropertyKind.Data) {\n if (strict && kind === PropertyKind.Data) {\n throwErrorTolerant({}, Messages.StrictDuplicateProperty);\n } else if (kind !== PropertyKind.Data) {\n throwErrorTolerant({}, Messages.AccessorDataProperty);\n }\n } else {\n if (kind === PropertyKind.Data) {\n throwErrorTolerant({}, Messages.AccessorDataProperty);\n } else if (map[key] & kind) {\n throwErrorTolerant({}, Messages.AccessorGetSet);\n }\n }\n map[key] |= kind;\n } else {\n map[key] = kind;\n }\n\n properties.push(property);\n\n if (!match('}')) {\n expect(',');\n }\n }\n\n expect('}');\n\n return delegate.markEnd(delegate.createObjectExpression(properties), startToken);\n }\n\n // 11.1.6 The Grouping Operator\n\n function parseGroupExpression() {\n var expr;\n\n expect('(');\n\n expr = parseExpression();\n\n expect(')');\n\n return expr;\n }\n\n\n // 11.1 Primary Expressions\n\n function parsePrimaryExpression() {\n var type, token, expr, startToken;\n\n if (match('(')) {\n return parseGroupExpression();\n }\n\n if (match('[')) {\n return parseArrayInitialiser();\n }\n\n if (match('{')) {\n return parseObjectInitialiser();\n }\n\n type = lookahead.type;\n startToken = lookahead;\n\n if (type === Token.Identifier) {\n expr = delegate.createIdentifier(lex().value);\n } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {\n if (strict && lookahead.octal) {\n throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);\n }\n expr = delegate.createLiteral(lex());\n } else if (type === Token.Keyword) {\n if (matchKeyword('function')) {\n return parseFunctionExpression();\n }\n if (matchKeyword('this')) {\n lex();\n expr = delegate.createThisExpression();\n } else {\n throwUnexpected(lex());\n }\n } else if (type === Token.BooleanLiteral) {\n token = lex();\n token.value = (token.value === 'true');\n expr = delegate.createLiteral(token);\n } else if (type === Token.NullLiteral) {\n token = lex();\n token.value = null;\n expr = delegate.createLiteral(token);\n } else if (match('/') || match('/=')) {\n if (typeof extra.tokens !== 'undefined') {\n expr = delegate.createLiteral(collectRegex());\n } else {\n expr = delegate.createLiteral(scanRegExp());\n }\n peek();\n } else {\n throwUnexpected(lex());\n }\n\n return delegate.markEnd(expr, startToken);\n }\n\n // 11.2 Left-Hand-Side Expressions\n\n function parseArguments() {\n var args = [];\n\n expect('(');\n\n if (!match(')')) {\n while (index < length) {\n args.push(parseAssignmentExpression());\n if (match(')')) {\n break;\n }\n expect(',');\n }\n }\n\n expect(')');\n\n return args;\n }\n\n function parseNonComputedProperty() {\n var token, startToken;\n\n startToken = lookahead;\n token = lex();\n\n if (!isIdentifierName(token)) {\n throwUnexpected(token);\n }\n\n return delegate.markEnd(delegate.createIdentifier(token.value), startToken);\n }\n\n function parseNonComputedMember() {\n expect('.');\n\n return parseNonComputedProperty();\n }\n\n function parseComputedMember() {\n var expr;\n\n expect('[');\n\n expr = parseExpression();\n\n expect(']');\n\n return expr;\n }\n\n function parseNewExpression() {\n var callee, args, startToken;\n\n startToken = lookahead;\n expectKeyword('new');\n callee = parseLeftHandSideExpression();\n args = match('(') ? parseArguments() : [];\n\n return delegate.markEnd(delegate.createNewExpression(callee, args), startToken);\n }\n\n function parseLeftHandSideExpressionAllowCall() {\n var previousAllowIn, expr, args, property, startToken;\n\n startToken = lookahead;\n\n previousAllowIn = state.allowIn;\n state.allowIn = true;\n expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();\n state.allowIn = previousAllowIn;\n\n for (;;) {\n if (match('.')) {\n property = parseNonComputedMember();\n expr = delegate.createMemberExpression('.', expr, property);\n } else if (match('(')) {\n args = parseArguments();\n expr = delegate.createCallExpression(expr, args);\n } else if (match('[')) {\n property = parseComputedMember();\n expr = delegate.createMemberExpression('[', expr, property);\n } else {\n break;\n }\n delegate.markEnd(expr, startToken);\n }\n\n return expr;\n }\n\n function parseLeftHandSideExpression() {\n var previousAllowIn, expr, property, startToken;\n\n startToken = lookahead;\n\n previousAllowIn = state.allowIn;\n expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();\n state.allowIn = previousAllowIn;\n\n while (match('.') || match('[')) {\n if (match('[')) {\n property = parseComputedMember();\n expr = delegate.createMemberExpression('[', expr, property);\n } else {\n property = parseNonComputedMember();\n expr = delegate.createMemberExpression('.', expr, property);\n }\n delegate.markEnd(expr, startToken);\n }\n\n return expr;\n }\n\n // 11.3 Postfix Expressions\n\n function parsePostfixExpression() {\n var expr, token, startToken = lookahead;\n\n expr = parseLeftHandSideExpressionAllowCall();\n\n if (lookahead.type === Token.Punctuator) {\n if ((match('++') || match('--')) && !peekLineTerminator()) {\n // 11.3.1, 11.3.2\n if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {\n throwErrorTolerant({}, Messages.StrictLHSPostfix);\n }\n\n if (!isLeftHandSide(expr)) {\n throwErrorTolerant({}, Messages.InvalidLHSInAssignment);\n }\n\n token = lex();\n expr = delegate.markEnd(delegate.createPostfixExpression(token.value, expr), startToken);\n }\n }\n\n return expr;\n }\n\n // 11.4 Unary Operators\n\n function parseUnaryExpression() {\n var token, expr, startToken;\n\n if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {\n expr = parsePostfixExpression();\n } else if (match('++') || match('--')) {\n startToken = lookahead;\n token = lex();\n expr = parseUnaryExpression();\n // 11.4.4, 11.4.5\n if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {\n throwErrorTolerant({}, Messages.StrictLHSPrefix);\n }\n\n if (!isLeftHandSide(expr)) {\n throwErrorTolerant({}, Messages.InvalidLHSInAssignment);\n }\n\n expr = delegate.createUnaryExpression(token.value, expr);\n expr = delegate.markEnd(expr, startToken);\n } else if (match('+') || match('-') || match('~') || match('!')) {\n startToken = lookahead;\n token = lex();\n expr = parseUnaryExpression();\n expr = delegate.createUnaryExpression(token.value, expr);\n expr = delegate.markEnd(expr, startToken);\n } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {\n startToken = lookahead;\n token = lex();\n expr = parseUnaryExpression();\n expr = delegate.createUnaryExpression(token.value, expr);\n expr = delegate.markEnd(expr, startToken);\n if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {\n throwErrorTolerant({}, Messages.StrictDelete);\n }\n } else {\n expr = parsePostfixExpression();\n }\n\n return expr;\n }\n\n function binaryPrecedence(token, allowIn) {\n var prec = 0;\n\n if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {\n return 0;\n }\n\n switch (token.value) {\n case '||':\n prec = 1;\n break;\n\n case '&&':\n prec = 2;\n break;\n\n case '|':\n prec = 3;\n break;\n\n case '^':\n prec = 4;\n break;\n\n case '&':\n prec = 5;\n break;\n\n case '==':\n case '!=':\n case '===':\n case '!==':\n prec = 6;\n break;\n\n case '<':\n case '>':\n case '<=':\n case '>=':\n case 'instanceof':\n prec = 7;\n break;\n\n case 'in':\n prec = allowIn ? 7 : 0;\n break;\n\n case '<<':\n case '>>':\n case '>>>':\n prec = 8;\n break;\n\n case '+':\n case '-':\n prec = 9;\n break;\n\n case '*':\n case '/':\n case '%':\n prec = 11;\n break;\n\n default:\n break;\n }\n\n return prec;\n }\n\n // 11.5 Multiplicative Operators\n // 11.6 Additive Operators\n // 11.7 Bitwise Shift Operators\n // 11.8 Relational Operators\n // 11.9 Equality Operators\n // 11.10 Binary Bitwise Operators\n // 11.11 Binary Logical Operators\n\n function parseBinaryExpression() {\n var marker, markers, expr, token, prec, stack, right, operator, left, i;\n\n marker = lookahead;\n left = parseUnaryExpression();\n\n token = lookahead;\n prec = binaryPrecedence(token, state.allowIn);\n if (prec === 0) {\n return left;\n }\n token.prec = prec;\n lex();\n\n markers = [marker, lookahead];\n right = parseUnaryExpression();\n\n stack = [left, token, right];\n\n while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) {\n\n // Reduce: make a binary expression from the three topmost entries.\n while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {\n right = stack.pop();\n operator = stack.pop().value;\n left = stack.pop();\n expr = delegate.createBinaryExpression(operator, left, right);\n markers.pop();\n marker = markers[markers.length - 1];\n delegate.markEnd(expr, marker);\n stack.push(expr);\n }\n\n // Shift.\n token = lex();\n token.prec = prec;\n stack.push(token);\n markers.push(lookahead);\n expr = parseUnaryExpression();\n stack.push(expr);\n }\n\n // Final reduce to clean-up the stack.\n i = stack.length - 1;\n expr = stack[i];\n markers.pop();\n while (i > 1) {\n expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);\n i -= 2;\n marker = markers.pop();\n delegate.markEnd(expr, marker);\n }\n\n return expr;\n }\n\n\n // 11.12 Conditional Operator\n\n function parseConditionalExpression() {\n var expr, previousAllowIn, consequent, alternate, startToken;\n\n startToken = lookahead;\n\n expr = parseBinaryExpression();\n\n if (match('?')) {\n lex();\n previousAllowIn = state.allowIn;\n state.allowIn = true;\n consequent = parseAssignmentExpression();\n state.allowIn = previousAllowIn;\n expect(':');\n alternate = parseAssignmentExpression();\n\n expr = delegate.createConditionalExpression(expr, consequent, alternate);\n delegate.markEnd(expr, startToken);\n }\n\n return expr;\n }\n\n // 11.13 Assignment Operators\n\n function parseAssignmentExpression() {\n var token, left, right, node, startToken;\n\n token = lookahead;\n startToken = lookahead;\n\n node = left = parseConditionalExpression();\n\n if (matchAssign()) {\n // LeftHandSideExpression\n if (!isLeftHandSide(left)) {\n throwErrorTolerant({}, Messages.InvalidLHSInAssignment);\n }\n\n // 11.13.1\n if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) {\n throwErrorTolerant(token, Messages.StrictLHSAssignment);\n }\n\n token = lex();\n right = parseAssignmentExpression();\n node = delegate.markEnd(delegate.createAssignmentExpression(token.value, left, right), startToken);\n }\n\n return node;\n }\n\n // 11.14 Comma Operator\n\n function parseExpression() {\n var expr, startToken = lookahead;\n\n expr = parseAssignmentExpression();\n\n if (match(',')) {\n expr = delegate.createSequenceExpression([ expr ]);\n\n while (index < length) {\n if (!match(',')) {\n break;\n }\n lex();\n expr.expressions.push(parseAssignmentExpression());\n }\n\n delegate.markEnd(expr, startToken);\n }\n\n return expr;\n }\n\n // 12.1 Block\n\n function parseStatementList() {\n var list = [],\n statement;\n\n while (index < length) {\n if (match('}')) {\n break;\n }\n statement = parseSourceElement();\n if (typeof statement === 'undefined') {\n break;\n }\n list.push(statement);\n }\n\n return list;\n }\n\n function parseBlock() {\n var block, startToken;\n\n startToken = lookahead;\n expect('{');\n\n block = parseStatementList();\n\n expect('}');\n\n return delegate.markEnd(delegate.createBlockStatement(block), startToken);\n }\n\n // 12.2 Variable Statement\n\n function parseVariableIdentifier() {\n var token, startToken;\n\n startToken = lookahead;\n token = lex();\n\n if (token.type !== Token.Identifier) {\n throwUnexpected(token);\n }\n\n return delegate.markEnd(delegate.createIdentifier(token.value), startToken);\n }\n\n function parseVariableDeclaration(kind) {\n var init = null, id, startToken;\n\n startToken = lookahead;\n id = parseVariableIdentifier();\n\n // 12.2.1\n if (strict && isRestrictedWord(id.name)) {\n throwErrorTolerant({}, Messages.StrictVarName);\n }\n\n if (kind === 'const') {\n expect('=');\n init = parseAssignmentExpression();\n } else if (match('=')) {\n lex();\n init = parseAssignmentExpression();\n }\n\n return delegate.markEnd(delegate.createVariableDeclarator(id, init), startToken);\n }\n\n function parseVariableDeclarationList(kind) {\n var list = [];\n\n do {\n list.push(parseVariableDeclaration(kind));\n if (!match(',')) {\n break;\n }\n lex();\n } while (index < length);\n\n return list;\n }\n\n function parseVariableStatement() {\n var declarations;\n\n expectKeyword('var');\n\n declarations = parseVariableDeclarationList();\n\n consumeSemicolon();\n\n return delegate.createVariableDeclaration(declarations, 'var');\n }\n\n // kind may be `const` or `let`\n // Both are experimental and not in the specification yet.\n // see http://wiki.ecmascript.org/doku.php?id=harmony:const\n // and http://wiki.ecmascript.org/doku.php?id=harmony:let\n function parseConstLetDeclaration(kind) {\n var declarations, startToken;\n\n startToken = lookahead;\n\n expectKeyword(kind);\n\n declarations = parseVariableDeclarationList(kind);\n\n consumeSemicolon();\n\n return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind), startToken);\n }\n\n // 12.3 Empty Statement\n\n function parseEmptyStatement() {\n expect(';');\n return delegate.createEmptyStatement();\n }\n\n // 12.4 Expression Statement\n\n function parseExpressionStatement() {\n var expr = parseExpression();\n consumeSemicolon();\n return delegate.createExpressionStatement(expr);\n }\n\n // 12.5 If statement\n\n function parseIfStatement() {\n var test, consequent, alternate;\n\n expectKeyword('if');\n\n expect('(');\n\n test = parseExpression();\n\n expect(')');\n\n consequent = parseStatement();\n\n if (matchKeyword('else')) {\n lex();\n alternate = parseStatement();\n } else {\n alternate = null;\n }\n\n return delegate.createIfStatement(test, consequent, alternate);\n }\n\n // 12.6 Iteration Statements\n\n function parseDoWhileStatement() {\n var body, test, oldInIteration;\n\n expectKeyword('do');\n\n oldInIteration = state.inIteration;\n state.inIteration = true;\n\n body = parseStatement();\n\n state.inIteration = oldInIteration;\n\n expectKeyword('while');\n\n expect('(');\n\n test = parseExpression();\n\n expect(')');\n\n if (match(';')) {\n lex();\n }\n\n return delegate.createDoWhileStatement(body, test);\n }\n\n function parseWhileStatement() {\n var test, body, oldInIteration;\n\n expectKeyword('while');\n\n expect('(');\n\n test = parseExpression();\n\n expect(')');\n\n oldInIteration = state.inIteration;\n state.inIteration = true;\n\n body = parseStatement();\n\n state.inIteration = oldInIteration;\n\n return delegate.createWhileStatement(test, body);\n }\n\n function parseForVariableDeclaration() {\n var token, declarations, startToken;\n\n startToken = lookahead;\n token = lex();\n declarations = parseVariableDeclarationList();\n\n return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value), startToken);\n }\n\n function parseForStatement() {\n var init, test, update, left, right, body, oldInIteration;\n\n init = test = update = null;\n\n expectKeyword('for');\n\n expect('(');\n\n if (match(';')) {\n lex();\n } else {\n if (matchKeyword('var') || matchKeyword('let')) {\n state.allowIn = false;\n init = parseForVariableDeclaration();\n state.allowIn = true;\n\n if (init.declarations.length === 1 && matchKeyword('in')) {\n lex();\n left = init;\n right = parseExpression();\n init = null;\n }\n } else {\n state.allowIn = false;\n init = parseExpression();\n state.allowIn = true;\n\n if (matchKeyword('in')) {\n // LeftHandSideExpression\n if (!isLeftHandSide(init)) {\n throwErrorTolerant({}, Messages.InvalidLHSInForIn);\n }\n\n lex();\n left = init;\n right = parseExpression();\n init = null;\n }\n }\n\n if (typeof left === 'undefined') {\n expect(';');\n }\n }\n\n if (typeof left === 'undefined') {\n\n if (!match(';')) {\n test = parseExpression();\n }\n expect(';');\n\n if (!match(')')) {\n update = parseExpression();\n }\n }\n\n expect(')');\n\n oldInIteration = state.inIteration;\n state.inIteration = true;\n\n body = parseStatement();\n\n state.inIteration = oldInIteration;\n\n return (typeof left === 'undefined') ?\n delegate.createForStatement(init, test, update, body) :\n delegate.createForInStatement(left, right, body);\n }\n\n // 12.7 The continue statement\n\n function parseContinueStatement() {\n var label = null, key;\n\n expectKeyword('continue');\n\n // Optimize the most common form: 'continue;'.\n if (source.charCodeAt(index) === 0x3B) {\n lex();\n\n if (!state.inIteration) {\n throwError({}, Messages.IllegalContinue);\n }\n\n return delegate.createContinueStatement(null);\n }\n\n if (peekLineTerminator()) {\n if (!state.inIteration) {\n throwError({}, Messages.IllegalContinue);\n }\n\n return delegate.createContinueStatement(null);\n }\n\n if (lookahead.type === Token.Identifier) {\n label = parseVariableIdentifier();\n\n key = '$' + label.name;\n if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {\n throwError({}, Messages.UnknownLabel, label.name);\n }\n }\n\n consumeSemicolon();\n\n if (label === null && !state.inIteration) {\n throwError({}, Messages.IllegalContinue);\n }\n\n return delegate.createContinueStatement(label);\n }\n\n // 12.8 The break statement\n\n function parseBreakStatement() {\n var label = null, key;\n\n expectKeyword('break');\n\n // Catch the very common case first: immediately a semicolon (U+003B).\n if (source.charCodeAt(index) === 0x3B) {\n lex();\n\n if (!(state.inIteration || state.inSwitch)) {\n throwError({}, Messages.IllegalBreak);\n }\n\n return delegate.createBreakStatement(null);\n }\n\n if (peekLineTerminator()) {\n if (!(state.inIteration || state.inSwitch)) {\n throwError({}, Messages.IllegalBreak);\n }\n\n return delegate.createBreakStatement(null);\n }\n\n if (lookahead.type === Token.Identifier) {\n label = parseVariableIdentifier();\n\n key = '$' + label.name;\n if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {\n throwError({}, Messages.UnknownLabel, label.name);\n }\n }\n\n consumeSemicolon();\n\n if (label === null && !(state.inIteration || state.inSwitch)) {\n throwError({}, Messages.IllegalBreak);\n }\n\n return delegate.createBreakStatement(label);\n }\n\n // 12.9 The return statement\n\n function parseReturnStatement() {\n var argument = null;\n\n expectKeyword('return');\n\n if (!state.inFunctionBody) {\n throwErrorTolerant({}, Messages.IllegalReturn);\n }\n\n // 'return' followed by a space and an identifier is very common.\n if (source.charCodeAt(index) === 0x20) {\n if (isIdentifierStart(source.charCodeAt(index + 1))) {\n argument = parseExpression();\n consumeSemicolon();\n return delegate.createReturnStatement(argument);\n }\n }\n\n if (peekLineTerminator()) {\n return delegate.createReturnStatement(null);\n }\n\n if (!match(';')) {\n if (!match('}') && lookahead.type !== Token.EOF) {\n argument = parseExpression();\n }\n }\n\n consumeSemicolon();\n\n return delegate.createReturnStatement(argument);\n }\n\n // 12.10 The with statement\n\n function parseWithStatement() {\n var object, body;\n\n if (strict) {\n // TODO(ikarienator): Should we update the test cases instead?\n skipComment();\n throwErrorTolerant({}, Messages.StrictModeWith);\n }\n\n expectKeyword('with');\n\n expect('(');\n\n object = parseExpression();\n\n expect(')');\n\n body = parseStatement();\n\n return delegate.createWithStatement(object, body);\n }\n\n // 12.10 The swith statement\n\n function parseSwitchCase() {\n var test, consequent = [], statement, startToken;\n\n startToken = lookahead;\n if (matchKeyword('default')) {\n lex();\n test = null;\n } else {\n expectKeyword('case');\n test = parseExpression();\n }\n expect(':');\n\n while (index < length) {\n if (match('}') || matchKeyword('default') || matchKeyword('case')) {\n break;\n }\n statement = parseStatement();\n consequent.push(statement);\n }\n\n return delegate.markEnd(delegate.createSwitchCase(test, consequent), startToken);\n }\n\n function parseSwitchStatement() {\n var discriminant, cases, clause, oldInSwitch, defaultFound;\n\n expectKeyword('switch');\n\n expect('(');\n\n discriminant = parseExpression();\n\n expect(')');\n\n expect('{');\n\n cases = [];\n\n if (match('}')) {\n lex();\n return delegate.createSwitchStatement(discriminant, cases);\n }\n\n oldInSwitch = state.inSwitch;\n state.inSwitch = true;\n defaultFound = false;\n\n while (index < length) {\n if (match('}')) {\n break;\n }\n clause = parseSwitchCase();\n if (clause.test === null) {\n if (defaultFound) {\n throwError({}, Messages.MultipleDefaultsInSwitch);\n }\n defaultFound = true;\n }\n cases.push(clause);\n }\n\n state.inSwitch = oldInSwitch;\n\n expect('}');\n\n return delegate.createSwitchStatement(discriminant, cases);\n }\n\n // 12.13 The throw statement\n\n function parseThrowStatement() {\n var argument;\n\n expectKeyword('throw');\n\n if (peekLineTerminator()) {\n throwError({}, Messages.NewlineAfterThrow);\n }\n\n argument = parseExpression();\n\n consumeSemicolon();\n\n return delegate.createThrowStatement(argument);\n }\n\n // 12.14 The try statement\n\n function parseCatchClause() {\n var param, body, startToken;\n\n startToken = lookahead;\n expectKeyword('catch');\n\n expect('(');\n if (match(')')) {\n throwUnexpected(lookahead);\n }\n\n param = parseVariableIdentifier();\n // 12.14.1\n if (strict && isRestrictedWord(param.name)) {\n throwErrorTolerant({}, Messages.StrictCatchVariable);\n }\n\n expect(')');\n body = parseBlock();\n return delegate.markEnd(delegate.createCatchClause(param, body), startToken);\n }\n\n function parseTryStatement() {\n var block, handlers = [], finalizer = null;\n\n expectKeyword('try');\n\n block = parseBlock();\n\n if (matchKeyword('catch')) {\n handlers.push(parseCatchClause());\n }\n\n if (matchKeyword('finally')) {\n lex();\n finalizer = parseBlock();\n }\n\n if (handlers.length === 0 && !finalizer) {\n throwError({}, Messages.NoCatchOrFinally);\n }\n\n return delegate.createTryStatement(block, [], handlers, finalizer);\n }\n\n // 12.15 The debugger statement\n\n function parseDebuggerStatement() {\n expectKeyword('debugger');\n\n consumeSemicolon();\n\n return delegate.createDebuggerStatement();\n }\n\n // 12 Statements\n\n function parseStatement() {\n var type = lookahead.type,\n expr,\n labeledBody,\n key,\n startToken;\n\n if (type === Token.EOF) {\n throwUnexpected(lookahead);\n }\n\n if (type === Token.Punctuator && lookahead.value === '{') {\n return parseBlock();\n }\n\n startToken = lookahead;\n\n if (type === Token.Punctuator) {\n switch (lookahead.value) {\n case ';':\n return delegate.markEnd(parseEmptyStatement(), startToken);\n case '(':\n return delegate.markEnd(parseExpressionStatement(), startToken);\n default:\n break;\n }\n }\n\n if (type === Token.Keyword) {\n switch (lookahead.value) {\n case 'break':\n return delegate.markEnd(parseBreakStatement(), startToken);\n case 'continue':\n return delegate.markEnd(parseContinueStatement(), startToken);\n case 'debugger':\n return delegate.markEnd(parseDebuggerStatement(), startToken);\n case 'do':\n return delegate.markEnd(parseDoWhileStatement(), startToken);\n case 'for':\n return delegate.markEnd(parseForStatement(), startToken);\n case 'function':\n return delegate.markEnd(parseFunctionDeclaration(), startToken);\n case 'if':\n return delegate.markEnd(parseIfStatement(), startToken);\n case 'return':\n return delegate.markEnd(parseReturnStatement(), startToken);\n case 'switch':\n return delegate.markEnd(parseSwitchStatement(), startToken);\n case 'throw':\n return delegate.markEnd(parseThrowStatement(), startToken);\n case 'try':\n return delegate.markEnd(parseTryStatement(), startToken);\n case 'var':\n return delegate.markEnd(parseVariableStatement(), startToken);\n case 'while':\n return delegate.markEnd(parseWhileStatement(), startToken);\n case 'with':\n return delegate.markEnd(parseWithStatement(), startToken);\n default:\n break;\n }\n }\n\n expr = parseExpression();\n\n // 12.12 Labelled Statements\n if ((expr.type === Syntax.Identifier) && match(':')) {\n lex();\n\n key = '$' + expr.name;\n if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {\n throwError({}, Messages.Redeclaration, 'Label', expr.name);\n }\n\n state.labelSet[key] = true;\n labeledBody = parseStatement();\n delete state.labelSet[key];\n return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody), startToken);\n }\n\n consumeSemicolon();\n\n return delegate.markEnd(delegate.createExpressionStatement(expr), startToken);\n }\n\n // 13 Function Definition\n\n function parseFunctionSourceElements() {\n var sourceElement, sourceElements = [], token, directive, firstRestricted,\n oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken;\n\n startToken = lookahead;\n expect('{');\n\n while (index < length) {\n if (lookahead.type !== Token.StringLiteral) {\n break;\n }\n token = lookahead;\n\n sourceElement = parseSourceElement();\n sourceElements.push(sourceElement);\n if (sourceElement.expression.type !== Syntax.Literal) {\n // this is not directive\n break;\n }\n directive = source.slice(token.start + 1, token.end - 1);\n if (directive === 'use strict') {\n strict = true;\n if (firstRestricted) {\n throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);\n }\n } else {\n if (!firstRestricted && token.octal) {\n firstRestricted = token;\n }\n }\n }\n\n oldLabelSet = state.labelSet;\n oldInIteration = state.inIteration;\n oldInSwitch = state.inSwitch;\n oldInFunctionBody = state.inFunctionBody;\n\n state.labelSet = {};\n state.inIteration = false;\n state.inSwitch = false;\n state.inFunctionBody = true;\n\n while (index < length) {\n if (match('}')) {\n break;\n }\n sourceElement = parseSourceElement();\n if (typeof sourceElement === 'undefined') {\n break;\n }\n sourceElements.push(sourceElement);\n }\n\n expect('}');\n\n state.labelSet = oldLabelSet;\n state.inIteration = oldInIteration;\n state.inSwitch = oldInSwitch;\n state.inFunctionBody = oldInFunctionBody;\n\n return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken);\n }\n\n function parseParams(firstRestricted) {\n var param, params = [], token, stricted, paramSet, key, message;\n expect('(');\n\n if (!match(')')) {\n paramSet = {};\n while (index < length) {\n token = lookahead;\n param = parseVariableIdentifier();\n key = '$' + token.value;\n if (strict) {\n if (isRestrictedWord(token.value)) {\n stricted = token;\n message = Messages.StrictParamName;\n }\n if (Object.prototype.hasOwnProperty.call(paramSet, key)) {\n stricted = token;\n message = Messages.StrictParamDupe;\n }\n } else if (!firstRestricted) {\n if (isRestrictedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictParamName;\n } else if (isStrictModeReservedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictReservedWord;\n } else if (Object.prototype.hasOwnProperty.call(paramSet, key)) {\n firstRestricted = token;\n message = Messages.StrictParamDupe;\n }\n }\n params.push(param);\n paramSet[key] = true;\n if (match(')')) {\n break;\n }\n expect(',');\n }\n }\n\n expect(')');\n\n return {\n params: params,\n stricted: stricted,\n firstRestricted: firstRestricted,\n message: message\n };\n }\n\n function parseFunctionDeclaration() {\n var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, startToken;\n\n startToken = lookahead;\n\n expectKeyword('function');\n token = lookahead;\n id = parseVariableIdentifier();\n if (strict) {\n if (isRestrictedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictFunctionName);\n }\n } else {\n if (isRestrictedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictFunctionName;\n } else if (isStrictModeReservedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictReservedWord;\n }\n }\n\n tmp = parseParams(firstRestricted);\n params = tmp.params;\n stricted = tmp.stricted;\n firstRestricted = tmp.firstRestricted;\n if (tmp.message) {\n message = tmp.message;\n }\n\n previousStrict = strict;\n body = parseFunctionSourceElements();\n if (strict && firstRestricted) {\n throwError(firstRestricted, message);\n }\n if (strict && stricted) {\n throwErrorTolerant(stricted, message);\n }\n strict = previousStrict;\n\n return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body), startToken);\n }\n\n function parseFunctionExpression() {\n var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict, startToken;\n\n startToken = lookahead;\n expectKeyword('function');\n\n if (!match('(')) {\n token = lookahead;\n id = parseVariableIdentifier();\n if (strict) {\n if (isRestrictedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictFunctionName);\n }\n } else {\n if (isRestrictedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictFunctionName;\n } else if (isStrictModeReservedWord(token.value)) {\n firstRestricted = token;\n message = Messages.StrictReservedWord;\n }\n }\n }\n\n tmp = parseParams(firstRestricted);\n params = tmp.params;\n stricted = tmp.stricted;\n firstRestricted = tmp.firstRestricted;\n if (tmp.message) {\n message = tmp.message;\n }\n\n previousStrict = strict;\n body = parseFunctionSourceElements();\n if (strict && firstRestricted) {\n throwError(firstRestricted, message);\n }\n if (strict && stricted) {\n throwErrorTolerant(stricted, message);\n }\n strict = previousStrict;\n\n return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body), startToken);\n }\n\n // 14 Program\n\n function parseSourceElement() {\n if (lookahead.type === Token.Keyword) {\n switch (lookahead.value) {\n case 'const':\n case 'let':\n return parseConstLetDeclaration(lookahead.value);\n case 'function':\n return parseFunctionDeclaration();\n default:\n return parseStatement();\n }\n }\n\n if (lookahead.type !== Token.EOF) {\n return parseStatement();\n }\n }\n\n function parseSourceElements() {\n var sourceElement, sourceElements = [], token, directive, firstRestricted;\n\n while (index < length) {\n token = lookahead;\n if (token.type !== Token.StringLiteral) {\n break;\n }\n\n sourceElement = parseSourceElement();\n sourceElements.push(sourceElement);\n if (sourceElement.expression.type !== Syntax.Literal) {\n // this is not directive\n break;\n }\n directive = source.slice(token.start + 1, token.end - 1);\n if (directive === 'use strict') {\n strict = true;\n if (firstRestricted) {\n throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);\n }\n } else {\n if (!firstRestricted && token.octal) {\n firstRestricted = token;\n }\n }\n }\n\n while (index < length) {\n sourceElement = parseSourceElement();\n /* istanbul ignore if */\n if (typeof sourceElement === 'undefined') {\n break;\n }\n sourceElements.push(sourceElement);\n }\n return sourceElements;\n }\n\n function parseProgram() {\n var body, startToken;\n\n skipComment();\n peek();\n startToken = lookahead;\n strict = false;\n\n body = parseSourceElements();\n return delegate.markEnd(delegate.createProgram(body), startToken);\n }\n\n function filterTokenLocation() {\n var i, entry, token, tokens = [];\n\n for (i = 0; i < extra.tokens.length; ++i) {\n entry = extra.tokens[i];\n token = {\n type: entry.type,\n value: entry.value\n };\n if (extra.range) {\n token.range = entry.range;\n }\n if (extra.loc) {\n token.loc = entry.loc;\n }\n tokens.push(token);\n }\n\n extra.tokens = tokens;\n }\n\n function tokenize(code, options) {\n var toString,\n token,\n tokens;\n\n toString = String;\n if (typeof code !== 'string' && !(code instanceof String)) {\n code = toString(code);\n }\n\n delegate = SyntaxTreeDelegate;\n source = code;\n index = 0;\n lineNumber = (source.length > 0) ? 1 : 0;\n lineStart = 0;\n length = source.length;\n lookahead = null;\n state = {\n allowIn: true,\n labelSet: {},\n inFunctionBody: false,\n inIteration: false,\n inSwitch: false,\n lastCommentStart: -1\n };\n\n extra = {};\n\n // Options matching.\n options = options || {};\n\n // Of course we collect tokens here.\n options.tokens = true;\n extra.tokens = [];\n extra.tokenize = true;\n // The following two fields are necessary to compute the Regex tokens.\n extra.openParenToken = -1;\n extra.openCurlyToken = -1;\n\n extra.range = (typeof options.range === 'boolean') && options.range;\n extra.loc = (typeof options.loc === 'boolean') && options.loc;\n\n if (typeof options.comment === 'boolean' && options.comment) {\n extra.comments = [];\n }\n if (typeof options.tolerant === 'boolean' && options.tolerant) {\n extra.errors = [];\n }\n\n try {\n peek();\n if (lookahead.type === Token.EOF) {\n return extra.tokens;\n }\n\n token = lex();\n while (lookahead.type !== Token.EOF) {\n try {\n token = lex();\n } catch (lexError) {\n token = lookahead;\n if (extra.errors) {\n extra.errors.push(lexError);\n // We have to break on the first error\n // to avoid infinite loops.\n break;\n } else {\n throw lexError;\n }\n }\n }\n\n filterTokenLocation();\n tokens = extra.tokens;\n if (typeof extra.comments !== 'undefined') {\n tokens.comments = extra.comments;\n }\n if (typeof extra.errors !== 'undefined') {\n tokens.errors = extra.errors;\n }\n } catch (e) {\n throw e;\n } finally {\n extra = {};\n }\n return tokens;\n }\n\n function parse(code, options) {\n var program, toString;\n\n toString = String;\n if (typeof code !== 'string' && !(code instanceof String)) {\n code = toString(code);\n }\n\n delegate = SyntaxTreeDelegate;\n source = code;\n index = 0;\n lineNumber = (source.length > 0) ? 1 : 0;\n lineStart = 0;\n length = source.length;\n lookahead = null;\n state = {\n allowIn: true,\n labelSet: {},\n inFunctionBody: false,\n inIteration: false,\n inSwitch: false,\n lastCommentStart: -1\n };\n\n extra = {};\n if (typeof options !== 'undefined') {\n extra.range = (typeof options.range === 'boolean') && options.range;\n extra.loc = (typeof options.loc === 'boolean') && options.loc;\n extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;\n\n if (extra.loc && options.source !== null && options.source !== undefined) {\n extra.source = toString(options.source);\n }\n\n if (typeof options.tokens === 'boolean' && options.tokens) {\n extra.tokens = [];\n }\n if (typeof options.comment === 'boolean' && options.comment) {\n extra.comments = [];\n }\n if (typeof options.tolerant === 'boolean' && options.tolerant) {\n extra.errors = [];\n }\n if (extra.attachComment) {\n extra.range = true;\n extra.comments = [];\n extra.bottomRightStack = [];\n extra.trailingComments = [];\n extra.leadingComments = [];\n }\n }\n\n try {\n program = parseProgram();\n if (typeof extra.comments !== 'undefined') {\n program.comments = extra.comments;\n }\n if (typeof extra.tokens !== 'undefined') {\n filterTokenLocation();\n program.tokens = extra.tokens;\n }\n if (typeof extra.errors !== 'undefined') {\n program.errors = extra.errors;\n }\n } catch (e) {\n throw e;\n } finally {\n extra = {};\n }\n\n return program;\n }\n\n // Sync with *.json manifests.\n exports.version = '1.2.2';\n\n exports.tokenize = tokenize;\n\n exports.parse = parse;\n\n // Deep copy.\n /* istanbul ignore next */\n exports.Syntax = (function () {\n var name, types = {};\n\n if (typeof Object.create === 'function') {\n types = Object.create(null);\n }\n\n for (name in Syntax) {\n if (Syntax.hasOwnProperty(name)) {\n types[name] = Syntax[name];\n }\n }\n\n if (typeof Object.freeze === 'function') {\n Object.freeze(types);\n }\n\n return types;\n }());\n\n}));\n/* vim: set sw=4 ts=4 et tw=80 : */\n\n},{}],1:[function(require,module,exports){\n(function (process){\n/* parser generated by jison 0.4.13 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function(){\nvar parser = {trace: function trace() { },\nyy: {},\nsymbols_: {\"error\":2,\"JSON_PATH\":3,\"DOLLAR\":4,\"PATH_COMPONENTS\":5,\"LEADING_CHILD_MEMBER_EXPRESSION\":6,\"PATH_COMPONENT\":7,\"MEMBER_COMPONENT\":8,\"SUBSCRIPT_COMPONENT\":9,\"CHILD_MEMBER_COMPONENT\":10,\"DESCENDANT_MEMBER_COMPONENT\":11,\"DOT\":12,\"MEMBER_EXPRESSION\":13,\"DOT_DOT\":14,\"STAR\":15,\"IDENTIFIER\":16,\"SCRIPT_EXPRESSION\":17,\"INTEGER\":18,\"END\":19,\"CHILD_SUBSCRIPT_COMPONENT\":20,\"DESCENDANT_SUBSCRIPT_COMPONENT\":21,\"[\":22,\"SUBSCRIPT\":23,\"]\":24,\"SUBSCRIPT_EXPRESSION\":25,\"SUBSCRIPT_EXPRESSION_LIST\":26,\"SUBSCRIPT_EXPRESSION_LISTABLE\":27,\",\":28,\"STRING_LITERAL\":29,\"ARRAY_SLICE\":30,\"FILTER_EXPRESSION\":31,\"QQ_STRING\":32,\"Q_STRING\":33,\"$accept\":0,\"$end\":1},\nterminals_: {2:\"error\",4:\"DOLLAR\",12:\"DOT\",14:\"DOT_DOT\",15:\"STAR\",16:\"IDENTIFIER\",17:\"SCRIPT_EXPRESSION\",18:\"INTEGER\",19:\"END\",22:\"[\",24:\"]\",28:\",\",30:\"ARRAY_SLICE\",31:\"FILTER_EXPRESSION\",32:\"QQ_STRING\",33:\"Q_STRING\"},\nproductions_: [0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],\nperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */\n/**/) {\n/* this == yyval */\nif (!yy.ast) {\n yy.ast = _ast;\n _ast.initialize();\n}\n\nvar $0 = $$.length - 1;\nswitch (yystate) {\ncase 1:yy.ast.set({ expression: { type: \"root\", value: $$[$0] } }); yy.ast.unshift(); return yy.ast.yield()\nbreak;\ncase 2:yy.ast.set({ expression: { type: \"root\", value: $$[$0-1] } }); yy.ast.unshift(); return yy.ast.yield()\nbreak;\ncase 3:yy.ast.unshift(); return yy.ast.yield()\nbreak;\ncase 4:yy.ast.set({ operation: \"member\", scope: \"child\", expression: { type: \"identifier\", value: $$[$0-1] }}); yy.ast.unshift(); return yy.ast.yield()\nbreak;\ncase 5:\nbreak;\ncase 6:\nbreak;\ncase 7:yy.ast.set({ operation: \"member\" }); yy.ast.push()\nbreak;\ncase 8:yy.ast.set({ operation: \"subscript\" }); yy.ast.push() \nbreak;\ncase 9:yy.ast.set({ scope: \"child\" })\nbreak;\ncase 10:yy.ast.set({ scope: \"descendant\" })\nbreak;\ncase 11:\nbreak;\ncase 12:yy.ast.set({ scope: \"child\", operation: \"member\" })\nbreak;\ncase 13:\nbreak;\ncase 14:yy.ast.set({ expression: { type: \"wildcard\", value: $$[$0] } })\nbreak;\ncase 15:yy.ast.set({ expression: { type: \"identifier\", value: $$[$0] } })\nbreak;\ncase 16:yy.ast.set({ expression: { type: \"script_expression\", value: $$[$0] } })\nbreak;\ncase 17:yy.ast.set({ expression: { type: \"numeric_literal\", value: parseInt($$[$0]) } })\nbreak;\ncase 18:\nbreak;\ncase 19:yy.ast.set({ scope: \"child\" })\nbreak;\ncase 20:yy.ast.set({ scope: \"descendant\" })\nbreak;\ncase 21:\nbreak;\ncase 22:\nbreak;\ncase 23:\nbreak;\ncase 24:$$[$0].length > 1? yy.ast.set({ expression: { type: \"union\", value: $$[$0] } }) : this.$ = $$[$0]\nbreak;\ncase 25:this.$ = [$$[$0]]\nbreak;\ncase 26:this.$ = $$[$0-2].concat($$[$0])\nbreak;\ncase 27:this.$ = { expression: { type: \"numeric_literal\", value: parseInt($$[$0]) } }; yy.ast.set(this.$)\nbreak;\ncase 28:this.$ = { expression: { type: \"string_literal\", value: $$[$0] } }; yy.ast.set(this.$)\nbreak;\ncase 29:this.$ = { expression: { type: \"slice\", value: $$[$0] } }; yy.ast.set(this.$)\nbreak;\ncase 30:this.$ = { expression: { type: \"wildcard\", value: $$[$0] } }; yy.ast.set(this.$)\nbreak;\ncase 31:this.$ = { expression: { type: \"script_expression\", value: $$[$0] } }; yy.ast.set(this.$)\nbreak;\ncase 32:this.$ = { expression: { type: \"filter_expression\", value: $$[$0] } }; yy.ast.set(this.$)\nbreak;\ncase 33:this.$ = $$[$0]\nbreak;\ncase 34:this.$ = $$[$0]\nbreak;\n}\n},\ntable: [{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],\ndefaultActions: {27:[2,23],29:[2,30],30:[2,31],31:[2,32]},\nparseError: function parseError(str, hash) {\n if (hash.recoverable) {\n this.trace(str);\n } else {\n throw new Error(str);\n }\n},\nparse: function parse(input) {\n var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;\n var args = lstack.slice.call(arguments, 1);\n this.lexer.setInput(input);\n this.lexer.yy = this.yy;\n this.yy.lexer = this.lexer;\n this.yy.parser = this;\n if (typeof this.lexer.yylloc == 'undefined') {\n this.lexer.yylloc = {};\n }\n var yyloc = this.lexer.yylloc;\n lstack.push(yyloc);\n var ranges = this.lexer.options && this.lexer.options.ranges;\n if (typeof this.yy.parseError === 'function') {\n this.parseError = this.yy.parseError;\n } else {\n this.parseError = Object.getPrototypeOf(this).parseError;\n }\n function popStack(n) {\n stack.length = stack.length - 2 * n;\n vstack.length = vstack.length - n;\n lstack.length = lstack.length - n;\n }\n function lex() {\n var token;\n token = self.lexer.lex() || EOF;\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n return token;\n }\n var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;\n while (true) {\n state = stack[stack.length - 1];\n if (this.defaultActions[state]) {\n action = this.defaultActions[state];\n } else {\n if (symbol === null || typeof symbol == 'undefined') {\n symbol = lex();\n }\n action = table[state] && table[state][symbol];\n }\n if (typeof action === 'undefined' || !action.length || !action[0]) {\n var errStr = '';\n expected = [];\n for (p in table[state]) {\n if (this.terminals_[p] && p > TERROR) {\n expected.push('\\'' + this.terminals_[p] + '\\'');\n }\n }\n if (this.lexer.showPosition) {\n errStr = 'Parse error on line ' + (yylineno + 1) + ':\\n' + this.lexer.showPosition() + '\\nExpecting ' + expected.join(', ') + ', got \\'' + (this.terminals_[symbol] || symbol) + '\\'';\n } else {\n errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\\'' + (this.terminals_[symbol] || symbol) + '\\'');\n }\n this.parseError(errStr, {\n text: this.lexer.match,\n token: this.terminals_[symbol] || symbol,\n line: this.lexer.yylineno,\n loc: yyloc,\n expected: expected\n });\n }\n if (action[0] instanceof Array && action.length > 1) {\n throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n }\n switch (action[0]) {\n case 1:\n stack.push(symbol);\n vstack.push(this.lexer.yytext);\n lstack.push(this.lexer.yylloc);\n stack.push(action[1]);\n symbol = null;\n if (!preErrorSymbol) {\n yyleng = this.lexer.yyleng;\n yytext = this.lexer.yytext;\n yylineno = this.lexer.yylineno;\n yyloc = this.lexer.yylloc;\n if (recovering > 0) {\n recovering--;\n }\n } else {\n symbol = preErrorSymbol;\n preErrorSymbol = null;\n }\n break;\n case 2:\n len = this.productions_[action[1]][1];\n yyval.$ = vstack[vstack.length - len];\n yyval._$ = {\n first_line: lstack[lstack.length - (len || 1)].first_line,\n last_line: lstack[lstack.length - 1].last_line,\n first_column: lstack[lstack.length - (len || 1)].first_column,\n last_column: lstack[lstack.length - 1].last_column\n };\n if (ranges) {\n yyval._$.range = [\n lstack[lstack.length - (len || 1)].range[0],\n lstack[lstack.length - 1].range[1]\n ];\n }\n r = this.performAction.apply(yyval, [\n yytext,\n yyleng,\n yylineno,\n this.yy,\n action[1],\n vstack,\n lstack\n ].concat(args));\n if (typeof r !== 'undefined') {\n return r;\n }\n if (len) {\n stack = stack.slice(0, -1 * len * 2);\n vstack = vstack.slice(0, -1 * len);\n lstack = lstack.slice(0, -1 * len);\n }\n stack.push(this.productions_[action[1]][0]);\n vstack.push(yyval.$);\n lstack.push(yyval._$);\n newState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n stack.push(newState);\n break;\n case 3:\n return true;\n }\n }\n return true;\n}};\nvar _ast = {\n\n initialize: function() {\n this._nodes = [];\n this._node = {};\n this._stash = [];\n },\n\n set: function(props) {\n for (var k in props) this._node[k] = props[k];\n return this._node;\n },\n\n node: function(obj) {\n if (arguments.length) this._node = obj;\n return this._node;\n },\n\n push: function() {\n this._nodes.push(this._node);\n this._node = {};\n },\n\n unshift: function() {\n this._nodes.unshift(this._node);\n this._node = {};\n },\n\n yield: function() {\n var _nodes = this._nodes;\n this.initialize();\n return _nodes;\n }\n};\n/* generated by jison-lex 0.2.1 */\nvar lexer = (function(){\nvar lexer = {\n\nEOF:1,\n\nparseError:function parseError(str, hash) {\n if (this.yy.parser) {\n this.yy.parser.parseError(str, hash);\n } else {\n throw new Error(str);\n }\n },\n\n// resets the lexer, sets new input\nsetInput:function (input) {\n this._input = input;\n this._more = this._backtrack = this.done = false;\n this.yylineno = this.yyleng = 0;\n this.yytext = this.matched = this.match = '';\n this.conditionStack = ['INITIAL'];\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0\n };\n if (this.options.ranges) {\n this.yylloc.range = [0,0];\n }\n this.offset = 0;\n return this;\n },\n\n// consumes and returns one char from the input\ninput:function () {\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n var lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n } else {\n this.yylloc.last_column++;\n }\n if (this.options.ranges) {\n this.yylloc.range[1]++;\n }\n\n this._input = this._input.slice(1);\n return ch;\n },\n\n// unshifts one char (or a string) into the input\nunput:function (ch) {\n var len = ch.length;\n var lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len - 1);\n //this.yyleng -= len;\n this.offset -= len;\n var oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n this.match = this.match.substr(0, this.match.length - 1);\n this.matched = this.matched.substr(0, this.matched.length - 1);\n\n if (lines.length - 1) {\n this.yylineno -= lines.length - 1;\n }\n var r = this.yylloc.range;\n\n this.yylloc = {\n first_line: this.yylloc.first_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.first_column,\n last_column: lines ?\n (lines.length === oldLines.length ? this.yylloc.first_column : 0)\n + oldLines[oldLines.length - lines.length].length - lines[0].length :\n this.yylloc.first_column - len\n };\n\n if (this.options.ranges) {\n this.yylloc.range = [r[0], r[0] + this.yyleng - len];\n }\n this.yyleng = this.yytext.length;\n return this;\n },\n\n// When called from action, caches matched text and appends it on next action\nmore:function () {\n this._more = true;\n return this;\n },\n\n// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\nreject:function () {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n\n }\n return this;\n },\n\n// retain first n characters of the match\nless:function (n) {\n this.unput(this.match.slice(n));\n },\n\n// displays already matched input, i.e. for error messages\npastInput:function () {\n var past = this.matched.substr(0, this.matched.length - this.match.length);\n return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\\n/g, \"\");\n },\n\n// displays upcoming input, i.e. for error messages\nupcomingInput:function () {\n var next = this.match;\n if (next.length < 20) {\n next += this._input.substr(0, 20-next.length);\n }\n return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, \"\");\n },\n\n// displays the character position where the lexing error occurred, i.e. for error messages\nshowPosition:function () {\n var pre = this.pastInput();\n var c = new Array(pre.length + 1).join(\"-\");\n return pre + this.upcomingInput() + \"\\n\" + c + \"^\";\n },\n\n// test the lexed token: return FALSE when not a match, otherwise return token\ntest_match:function (match, indexed_rule) {\n var token,\n lines,\n backup;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(0),\n done: this.done\n };\n if (this.options.ranges) {\n backup.yylloc.range = this.yylloc.range.slice(0);\n }\n }\n\n lines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno += lines.length;\n }\n this.yylloc = {\n first_line: this.yylloc.last_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.last_column,\n last_column: lines ?\n lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length :\n this.yylloc.last_column + match[0].length\n };\n this.yytext += match[0];\n this.match += match[0];\n this.matches = match;\n this.yyleng = this.yytext.length;\n if (this.options.ranges) {\n this.yylloc.range = [this.offset, this.offset += this.yyleng];\n }\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match[0].length);\n this.matched += match[0];\n token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n return false; // rule action called reject() implying the next rule should be tested instead.\n }\n return false;\n },\n\n// return next match in input\nnext:function () {\n if (this.done) {\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n this.yytext = '';\n this.match = '';\n }\n var rules = this._currentRules();\n for (var i = 0; i < rules.length; i++) {\n tempMatch = this._input.match(this.rules[rules[i]]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rules[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = false;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rules[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (this._input === \"\") {\n return this.EOF;\n } else {\n return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n }\n },\n\n// return next match that has a token\nlex:function lex() {\n var r = this.next();\n if (r) {\n return r;\n } else {\n return this.lex();\n }\n },\n\n// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\nbegin:function begin(condition) {\n this.conditionStack.push(condition);\n },\n\n// pop the previously active lexer condition state off the condition stack\npopState:function popState() {\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n// produce the lexer rule set which is active for the currently active lexer condition state\n_currentRules:function _currentRules() {\n if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n } else {\n return this.conditions[\"INITIAL\"].rules;\n }\n },\n\n// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\ntopState:function topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return \"INITIAL\";\n }\n },\n\n// alias for begin(condition)\npushState:function pushState(condition) {\n this.begin(condition);\n },\n\n// return the number of states currently on the stack\nstateStackSize:function stateStackSize() {\n return this.conditionStack.length;\n },\noptions: {},\nperformAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START\n/**/) {\n\nvar YYSTATE=YY_START;\nswitch($avoiding_name_collisions) {\ncase 0:return 4\nbreak;\ncase 1:return 14\nbreak;\ncase 2:return 12\nbreak;\ncase 3:return 15\nbreak;\ncase 4:return 16\nbreak;\ncase 5:return 22\nbreak;\ncase 6:return 24\nbreak;\ncase 7:return 28\nbreak;\ncase 8:return 30\nbreak;\ncase 9:return 18\nbreak;\ncase 10:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 32;\nbreak;\ncase 11:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 33;\nbreak;\ncase 12:return 17\nbreak;\ncase 13:return 31\nbreak;\n}\n},\nrules: [/^(?:\\$)/,/^(?:\\.\\.)/,/^(?:\\.)/,/^(?:\\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\\[)/,/^(?:\\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\\:((-?(?:0|[1-9][0-9]*)))?(\\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:\"(?:\\\\[\"bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\"\\\\])*\")/,/^(?:'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*')/,/^(?:\\(.+?\\)(?=\\]))/,/^(?:\\?\\(.+?\\)(?=\\]))/],\nconditions: {\"INITIAL\":{\"rules\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],\"inclusive\":true}}\n};\nreturn lexer;\n})();\nparser.lexer = lexer;\nfunction Parser () {\n this.yy = {};\n}\nParser.prototype = parser;parser.Parser = Parser;\nreturn new Parser;\n})();\n\n\nif (typeof require !== 'undefined' && typeof exports !== 'undefined') {\nexports.parser = parser;\nexports.Parser = parser.Parser;\nexports.parse = function () { return parser.parse.apply(parser, arguments); };\nexports.main = function commonjsMain(args) {\n if (!args[1]) {\n console.log('Usage: '+args[0]+' FILE');\n process.exit(1);\n }\n var source = require('fs').readFileSync(require('path').normalize(args[1]), \"utf8\");\n return exports.parser.parse(source);\n};\nif (typeof module !== 'undefined' && require.main === module) {\n exports.main(process.argv.slice(1));\n}\n}\n\n}).call(this,require('_process'))\n},{\"_process\":14,\"fs\":12,\"path\":13}],2:[function(require,module,exports){\nmodule.exports = {\n identifier: \"[a-zA-Z_]+[a-zA-Z0-9_]*\",\n integer: \"-?(?:0|[1-9][0-9]*)\",\n qq_string: \"\\\"(?:\\\\\\\\[\\\"bfnrt/\\\\\\\\]|\\\\\\\\u[a-fA-F0-9]{4}|[^\\\"\\\\\\\\])*\\\"\",\n q_string: \"'(?:\\\\\\\\[\\'bfnrt/\\\\\\\\]|\\\\\\\\u[a-fA-F0-9]{4}|[^\\'\\\\\\\\])*'\"\n};\n\n},{}],3:[function(require,module,exports){\nvar dict = require('./dict');\nvar fs = require('fs');\nvar grammar = {\n\n lex: {\n\n macros: {\n esc: \"\\\\\\\\\",\n int: dict.integer\n },\n\n rules: [\n [\"\\\\$\", \"return 'DOLLAR'\"],\n [\"\\\\.\\\\.\", \"return 'DOT_DOT'\"],\n [\"\\\\.\", \"return 'DOT'\"],\n [\"\\\\*\", \"return 'STAR'\"],\n [dict.identifier, \"return 'IDENTIFIER'\"],\n [\"\\\\[\", \"return '['\"],\n [\"\\\\]\", \"return ']'\"],\n [\",\", \"return ','\"],\n [\"({int})?\\\\:({int})?(\\\\:({int})?)?\", \"return 'ARRAY_SLICE'\"],\n [\"{int}\", \"return 'INTEGER'\"],\n [dict.qq_string, \"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';\"],\n [dict.q_string, \"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';\"],\n [\"\\\\(.+?\\\\)(?=\\\\])\", \"return 'SCRIPT_EXPRESSION'\"],\n [\"\\\\?\\\\(.+?\\\\)(?=\\\\])\", \"return 'FILTER_EXPRESSION'\"]\n ]\n },\n\n start: \"JSON_PATH\",\n\n bnf: {\n\n JSON_PATH: [\n [ 'DOLLAR', 'yy.ast.set({ expression: { type: \"root\", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()' ],\n [ 'DOLLAR PATH_COMPONENTS', 'yy.ast.set({ expression: { type: \"root\", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()' ],\n [ 'LEADING_CHILD_MEMBER_EXPRESSION', 'yy.ast.unshift(); return yy.ast.yield()' ],\n [ 'LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS', 'yy.ast.set({ operation: \"member\", scope: \"child\", expression: { type: \"identifier\", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()' ] ],\n\n PATH_COMPONENTS: [\n [ 'PATH_COMPONENT', '' ],\n [ 'PATH_COMPONENTS PATH_COMPONENT', '' ] ],\n\n PATH_COMPONENT: [\n [ 'MEMBER_COMPONENT', 'yy.ast.set({ operation: \"member\" }); yy.ast.push()' ],\n [ 'SUBSCRIPT_COMPONENT', 'yy.ast.set({ operation: \"subscript\" }); yy.ast.push() ' ] ],\n\n MEMBER_COMPONENT: [\n [ 'CHILD_MEMBER_COMPONENT', 'yy.ast.set({ scope: \"child\" })' ],\n [ 'DESCENDANT_MEMBER_COMPONENT', 'yy.ast.set({ scope: \"descendant\" })' ] ],\n\n CHILD_MEMBER_COMPONENT: [\n [ 'DOT MEMBER_EXPRESSION', '' ] ],\n\n LEADING_CHILD_MEMBER_EXPRESSION: [\n [ 'MEMBER_EXPRESSION', 'yy.ast.set({ scope: \"child\", operation: \"member\" })' ] ],\n\n DESCENDANT_MEMBER_COMPONENT: [\n [ 'DOT_DOT MEMBER_EXPRESSION', '' ] ],\n\n MEMBER_EXPRESSION: [\n [ 'STAR', 'yy.ast.set({ expression: { type: \"wildcard\", value: $1 } })' ],\n [ 'IDENTIFIER', 'yy.ast.set({ expression: { type: \"identifier\", value: $1 } })' ],\n [ 'SCRIPT_EXPRESSION', 'yy.ast.set({ expression: { type: \"script_expression\", value: $1 } })' ],\n [ 'INTEGER', 'yy.ast.set({ expression: { type: \"numeric_literal\", value: parseInt($1) } })' ],\n [ 'END', '' ] ],\n\n SUBSCRIPT_COMPONENT: [\n [ 'CHILD_SUBSCRIPT_COMPONENT', 'yy.ast.set({ scope: \"child\" })' ],\n [ 'DESCENDANT_SUBSCRIPT_COMPONENT', 'yy.ast.set({ scope: \"descendant\" })' ] ],\n\n CHILD_SUBSCRIPT_COMPONENT: [\n [ '[ SUBSCRIPT ]', '' ] ],\n\n DESCENDANT_SUBSCRIPT_COMPONENT: [\n [ 'DOT_DOT [ SUBSCRIPT ]', '' ] ],\n\n SUBSCRIPT: [\n [ 'SUBSCRIPT_EXPRESSION', '' ],\n [ 'SUBSCRIPT_EXPRESSION_LIST', '$1.length > 1? yy.ast.set({ expression: { type: \"union\", value: $1 } }) : $$ = $1' ] ],\n\n SUBSCRIPT_EXPRESSION_LIST: [\n [ 'SUBSCRIPT_EXPRESSION_LISTABLE', '$$ = [$1]'],\n [ 'SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE', '$$ = $1.concat($3)' ] ],\n\n SUBSCRIPT_EXPRESSION_LISTABLE: [\n [ 'INTEGER', '$$ = { expression: { type: \"numeric_literal\", value: parseInt($1) } }; yy.ast.set($$)' ],\n [ 'STRING_LITERAL', '$$ = { expression: { type: \"string_literal\", value: $1 } }; yy.ast.set($$)' ],\n [ 'ARRAY_SLICE', '$$ = { expression: { type: \"slice\", value: $1 } }; yy.ast.set($$)' ] ],\n\n SUBSCRIPT_EXPRESSION: [\n [ 'STAR', '$$ = { expression: { type: \"wildcard\", value: $1 } }; yy.ast.set($$)' ],\n [ 'SCRIPT_EXPRESSION', '$$ = { expression: { type: \"script_expression\", value: $1 } }; yy.ast.set($$)' ],\n [ 'FILTER_EXPRESSION', '$$ = { expression: { type: \"filter_expression\", value: $1 } }; yy.ast.set($$)' ] ],\n\n STRING_LITERAL: [\n [ 'QQ_STRING', \"$$ = $1\" ],\n [ 'Q_STRING', \"$$ = $1\" ] ]\n }\n};\nif (fs.readFileSync) {\n grammar.moduleInclude = fs.readFileSync(require.resolve(\"../include/module.js\"));\n grammar.actionInclude = fs.readFileSync(require.resolve(\"../include/action.js\"));\n}\n\nmodule.exports = grammar;\n\n},{\"./dict\":2,\"fs\":12}],4:[function(require,module,exports){\nvar aesprim = require('./aesprim');\nvar slice = require('./slice');\nvar _evaluate = require('static-eval');\nvar _uniq = require('underscore').uniq;\n\nvar Handlers = function() {\n return this.initialize.apply(this, arguments);\n}\n\nHandlers.prototype.initialize = function() {\n this.traverse = traverser(true);\n this.descend = traverser();\n}\n\nHandlers.prototype.keys = Object.keys;\n\nHandlers.prototype.resolve = function(component) {\n\n var key = [ component.operation, component.scope, component.expression.type ].join('-');\n var method = this._fns[key];\n\n if (!method) throw new Error(\"couldn't resolve key: \" + key);\n return method.bind(this);\n};\n\nHandlers.prototype.register = function(key, handler) {\n\n if (!handler instanceof Function) {\n throw new Error(\"handler must be a function\");\n }\n\n this._fns[key] = handler;\n};\n\nHandlers.prototype._fns = {\n\n 'member-child-identifier': function(component, partial) {\n var key = component.expression.value;\n var value = partial.value;\n if (value instanceof Object && key in value) {\n return [ { value: value[key], path: partial.path.concat(key) } ]\n }\n },\n\n 'member-descendant-identifier':\n _traverse(function(key, value, ref) { return key == ref }),\n\n 'subscript-child-numeric_literal':\n _descend(function(key, value, ref) { return key === ref }),\n\n 'member-child-numeric_literal':\n _descend(function(key, value, ref) { return String(key) === String(ref) }),\n\n 'subscript-descendant-numeric_literal':\n _traverse(function(key, value, ref) { return key === ref }),\n\n 'member-child-wildcard':\n _descend(function() { return true }),\n\n 'member-descendant-wildcard':\n _traverse(function() { return true }),\n\n 'subscript-descendant-wildcard':\n _traverse(function() { return true }),\n\n 'subscript-child-wildcard':\n _descend(function() { return true }),\n\n 'subscript-child-slice': function(component, partial) {\n if (is_array(partial.value)) {\n var args = component.expression.value.split(':').map(_parse_nullable_int);\n var values = partial.value.map(function(v, i) { return { value: v, path: partial.path.concat(i) } });\n return slice.apply(null, [values].concat(args));\n }\n },\n\n 'subscript-child-union': function(component, partial) {\n var results = [];\n component.expression.value.forEach(function(component) {\n var _component = { operation: 'subscript', scope: 'child', expression: component.expression };\n var handler = this.resolve(_component);\n var _results = handler(_component, partial);\n if (_results) {\n results = results.concat(_results);\n }\n }, this);\n\n return unique(results);\n },\n\n 'subscript-descendant-union': function(component, partial, count) {\n\n var jp = require('..');\n var self = this;\n\n var results = [];\n var nodes = jp.nodes(partial, '$..*').slice(1);\n\n nodes.forEach(function(node) {\n if (results.length >= count) return;\n component.expression.value.forEach(function(component) {\n var _component = { operation: 'subscript', scope: 'child', expression: component.expression };\n var handler = self.resolve(_component);\n var _results = handler(_component, node);\n results = results.concat(_results);\n });\n });\n\n return unique(results);\n },\n\n 'subscript-child-filter_expression': function(component, partial, count) {\n\n // slice out the expression from ?(expression)\n var src = component.expression.value.slice(2, -1);\n var ast = aesprim.parse(src).body[0].expression;\n\n var passable = function(key, value) {\n return evaluate(ast, { '@': value });\n }\n\n return this.descend(partial, null, passable, count);\n\n },\n\n 'subscript-descendant-filter_expression': function(component, partial, count) {\n\n // slice out the expression from ?(expression)\n var src = component.expression.value.slice(2, -1);\n var ast = aesprim.parse(src).body[0].expression;\n\n var passable = function(key, value) {\n return evaluate(ast, { '@': value });\n }\n\n return this.traverse(partial, null, passable, count);\n },\n\n 'subscript-child-script_expression': function(component, partial) {\n var exp = component.expression.value.slice(1, -1);\n return eval_recurse(partial, exp, '$[{{value}}]');\n },\n\n 'member-child-script_expression': function(component, partial) {\n var exp = component.expression.value.slice(1, -1);\n return eval_recurse(partial, exp, '$.{{value}}');\n },\n\n 'member-descendant-script_expression': function(component, partial) {\n var exp = component.expression.value.slice(1, -1);\n return eval_recurse(partial, exp, '$..value');\n }\n};\n\nHandlers.prototype._fns['subscript-child-string_literal'] =\n\tHandlers.prototype._fns['member-child-identifier'];\n\nHandlers.prototype._fns['member-descendant-numeric_literal'] =\n Handlers.prototype._fns['subscript-descendant-string_literal'] =\n Handlers.prototype._fns['member-descendant-identifier'];\n\nfunction eval_recurse(partial, src, template) {\n\n var jp = require('./index');\n var ast = aesprim.parse(src).body[0].expression;\n var value = evaluate(ast, { '@': partial.value });\n var path = template.replace(/\\{\\{\\s*value\\s*\\}\\}/g, value);\n\n var results = jp.nodes(partial.value, path);\n results.forEach(function(r) {\n r.path = partial.path.concat(r.path.slice(1));\n });\n\n return results;\n}\n\nfunction is_array(val) {\n return Array.isArray(val);\n}\n\nfunction is_object(val) {\n // is this a non-array, non-null object?\n return val && !(val instanceof Array) && val instanceof Object;\n}\n\nfunction traverser(recurse) {\n\n return function(partial, ref, passable, count) {\n\n var value = partial.value;\n var path = partial.path;\n\n var results = [];\n\n var descend = function(value, path) {\n\n if (is_array(value)) {\n value.forEach(function(element, index) {\n if (results.length >= count) { return }\n if (passable(index, element, ref)) {\n results.push({ path: path.concat(index), value: element });\n }\n });\n value.forEach(function(element, index) {\n if (results.length >= count) { return }\n if (recurse) {\n descend(element, path.concat(index));\n }\n });\n } else if (is_object(value)) {\n this.keys(value).forEach(function(k) {\n if (results.length >= count) { return }\n if (passable(k, value[k], ref)) {\n results.push({ path: path.concat(k), value: value[k] });\n }\n })\n this.keys(value).forEach(function(k) {\n if (results.length >= count) { return }\n if (recurse) {\n descend(value[k], path.concat(k));\n }\n });\n }\n }.bind(this);\n descend(value, path);\n return results;\n }\n}\n\nfunction _descend(passable) {\n return function(component, partial, count) {\n return this.descend(partial, component.expression.value, passable, count);\n }\n}\n\nfunction _traverse(passable) {\n return function(component, partial, count) {\n return this.traverse(partial, component.expression.value, passable, count);\n }\n}\n\nfunction evaluate() {\n try { return _evaluate.apply(this, arguments) }\n catch (e) { }\n}\n\nfunction unique(results) {\n results = results.filter(function(d) { return d })\n return _uniq(\n results,\n function(r) { return r.path.map(function(c) { return String(c).replace('-', '--') }).join('-') }\n );\n}\n\nfunction _parse_nullable_int(val) {\n var sval = String(val);\n return sval.match(/^-?[0-9]+$/) ? parseInt(sval) : null;\n}\n\nmodule.exports = Handlers;\n\n},{\"..\":\"jsonpath\",\"./aesprim\":\"./aesprim\",\"./index\":5,\"./slice\":7,\"static-eval\":15,\"underscore\":12}],5:[function(require,module,exports){\nvar assert = require('assert');\nvar dict = require('./dict');\nvar Parser = require('./parser');\nvar Handlers = require('./handlers');\n\nvar JSONPath = function() {\n this.initialize.apply(this, arguments);\n};\n\nJSONPath.prototype.initialize = function() {\n this.parser = new Parser();\n this.handlers = new Handlers();\n};\n\nJSONPath.prototype.parse = function(string) {\n assert.ok(_is_string(string), \"we need a path\");\n return this.parser.parse(string);\n};\n\nJSONPath.prototype.parent = function(obj, string) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(string, \"we need a path\");\n\n var node = this.nodes(obj, string)[0];\n var key = node.path.pop(); /* jshint unused:false */\n return this.value(obj, node.path);\n}\n\nJSONPath.prototype.apply = function(obj, string, fn) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(string, \"we need a path\");\n assert.equal(typeof fn, \"function\", \"fn needs to be function\")\n\n var nodes = this.nodes(obj, string).sort(function(a, b) {\n // sort nodes so we apply from the bottom up\n return b.path.length - a.path.length;\n });\n\n nodes.forEach(function(node) {\n var key = node.path.pop();\n var parent = this.value(obj, this.stringify(node.path));\n var val = node.value = fn.call(obj, parent[key]);\n parent[key] = val;\n }, this);\n\n return nodes;\n}\n\nJSONPath.prototype.value = function(obj, path, value) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(path, \"we need a path\");\n\n if (arguments.length >= 3) {\n var node = this.nodes(obj, path).shift();\n if (!node) return this._vivify(obj, path, value);\n var key = node.path.slice(-1).shift();\n var parent = this.parent(obj, this.stringify(node.path));\n parent[key] = value;\n }\n return this.query(obj, this.stringify(path), 1).shift();\n}\n\nJSONPath.prototype._vivify = function(obj, string, value) {\n\n var self = this;\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(string, \"we need a path\");\n\n var path = this.parser.parse(string)\n .map(function(component) { return component.expression.value });\n\n var setValue = function(path, value) {\n var key = path.pop();\n var node = self.value(obj, path);\n if (!node) {\n setValue(path.concat(), typeof key === 'string' ? {} : []);\n node = self.value(obj, path);\n }\n node[key] = value;\n }\n setValue(path, value);\n return this.query(obj, string)[0];\n}\n\nJSONPath.prototype.query = function(obj, string, count) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(_is_string(string), \"we need a path\");\n\n var results = this.nodes(obj, string, count)\n .map(function(r) { return r.value });\n\n return results;\n};\n\nJSONPath.prototype.paths = function(obj, string, count) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(string, \"we need a path\");\n\n var results = this.nodes(obj, string, count)\n .map(function(r) { return r.path });\n\n return results;\n};\n\nJSONPath.prototype.nodes = function(obj, string, count) {\n\n assert.ok(obj instanceof Object, \"obj needs to be an object\");\n assert.ok(string, \"we need a path\");\n\n if (count === 0) return [];\n\n var path = this.parser.parse(string);\n var handlers = this.handlers;\n\n var partials = [ { path: ['$'], value: obj } ];\n var matches = [];\n\n if (path.length && path[0].expression.type == 'root') path.shift();\n\n if (!path.length) return partials;\n\n path.forEach(function(component, index) {\n\n if (matches.length >= count) return;\n var handler = handlers.resolve(component);\n var _partials = [];\n\n partials.forEach(function(p) {\n\n if (matches.length >= count) return;\n var results = handler(component, p, count);\n\n if (index == path.length - 1) {\n // if we're through the components we're done\n matches = matches.concat(results || []);\n } else {\n // otherwise accumulate and carry on through\n _partials = _partials.concat(results || []);\n }\n });\n\n partials = _partials;\n\n });\n\n return count ? matches.slice(0, count) : matches;\n};\n\nJSONPath.prototype.stringify = function(path) {\n\n assert.ok(path, \"we need a path\");\n\n var string = '$';\n\n var templates = {\n 'descendant-member': '..{{value}}',\n 'child-member': '.{{value}}',\n 'descendant-subscript': '..[{{value}}]',\n 'child-subscript': '[{{value}}]'\n };\n\n path = this._normalize(path);\n\n path.forEach(function(component) {\n\n if (component.expression.type == 'root') return;\n\n var key = [component.scope, component.operation].join('-');\n var template = templates[key];\n var value;\n\n if (component.expression.type == 'string_literal') {\n value = JSON.stringify(component.expression.value)\n } else {\n value = component.expression.value;\n }\n\n if (!template) throw new Error(\"couldn't find template \" + key);\n\n string += template.replace(/{{value}}/, value);\n });\n\n return string;\n}\n\nJSONPath.prototype._normalize = function(path) {\n\n assert.ok(path, \"we need a path\");\n\n if (typeof path == \"string\") {\n\n return this.parser.parse(path);\n\n } else if (Array.isArray(path) && typeof path[0] == \"string\") {\n\n var _path = [ { expression: { type: \"root\", value: \"$\" } } ];\n\n path.forEach(function(component, index) {\n\n if (component == '$' && index === 0) return;\n\n if (typeof component == \"string\" && component.match(\"^\" + dict.identifier + \"$\")) {\n\n _path.push({\n operation: 'member',\n scope: 'child',\n expression: { value: component, type: 'identifier' }\n });\n\n } else {\n\n var type = typeof component == \"number\" ?\n 'numeric_literal' : 'string_literal';\n\n _path.push({\n operation: 'subscript',\n scope: 'child',\n expression: { value: component, type: type }\n });\n }\n });\n\n return _path;\n\n } else if (Array.isArray(path) && typeof path[0] == \"object\") {\n\n return path\n }\n\n throw new Error(\"couldn't understand path \" + path);\n}\n\nfunction _is_string(obj) {\n return Object.prototype.toString.call(obj) == '[object String]';\n}\n\nJSONPath.Handlers = Handlers;\nJSONPath.Parser = Parser;\n\nvar instance = new JSONPath;\ninstance.JSONPath = JSONPath;\n\nmodule.exports = instance;\n\n},{\"./dict\":2,\"./handlers\":4,\"./parser\":6,\"assert\":8}],6:[function(require,module,exports){\nvar grammar = require('./grammar');\nvar gparser = require('../generated/parser');\n\nvar Parser = function() {\n\n var parser = new gparser.Parser();\n\n var _parseError = parser.parseError;\n parser.yy.parseError = function() {\n if (parser.yy.ast) {\n parser.yy.ast.initialize();\n }\n _parseError.apply(parser, arguments);\n }\n\n return parser;\n\n};\n\nParser.grammar = grammar;\nmodule.exports = Parser;\n\n},{\"../generated/parser\":1,\"./grammar\":3}],7:[function(require,module,exports){\nmodule.exports = function(arr, start, end, step) {\n\n if (typeof start == 'string') throw new Error(\"start cannot be a string\");\n if (typeof end == 'string') throw new Error(\"end cannot be a string\");\n if (typeof step == 'string') throw new Error(\"step cannot be a string\");\n\n var len = arr.length;\n\n if (step === 0) throw new Error(\"step cannot be zero\");\n step = step ? integer(step) : 1;\n\n // normalize negative values\n start = start < 0 ? len + start : start;\n end = end < 0 ? len + end : end;\n\n // default extents to extents\n start = integer(start === 0 ? 0 : !start ? (step > 0 ? 0 : len - 1) : start);\n end = integer(end === 0 ? 0 : !end ? (step > 0 ? len : -1) : end);\n\n // clamp extents\n start = step > 0 ? Math.max(0, start) : Math.min(len, start);\n end = step > 0 ? Math.min(end, len) : Math.max(-1, end);\n\n // return empty if extents are backwards\n if (step > 0 && end <= start) return [];\n if (step < 0 && start <= end) return [];\n\n var result = [];\n\n for (var i = start; i != end; i += step) {\n if ((step < 0 && i <= end) || (step > 0 && i >= end)) break;\n result.push(arr[i]);\n }\n\n return result;\n}\n\nfunction integer(val) {\n return String(val).match(/^[0-9]+$/) ? parseInt(val) :\n Number.isFinite(val) ? parseInt(val, 10) : 0;\n}\n\n},{}],8:[function(require,module,exports){\n// http://wiki.commonjs.org/wiki/Unit_Testing/1.0\n//\n// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!\n//\n// Originally from narwhal.js (http://narwhaljs.org)\n// Copyright (c) 2009 Thomas Robinson <280north.com>\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the 'Software'), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// when used in node, this will actually load the util module we depend on\n// versus loading the builtin util module as happens otherwise\n// this is a bug in node module loading as far as I am concerned\nvar util = require('util/');\n\nvar pSlice = Array.prototype.slice;\nvar hasOwn = Object.prototype.hasOwnProperty;\n\n// 1. The assert module provides functions that throw\n// AssertionError's when particular conditions are not met. The\n// assert module must conform to the following interface.\n\nvar assert = module.exports = ok;\n\n// 2. The AssertionError is defined in assert.\n// new assert.AssertionError({ message: message,\n// actual: actual,\n// expected: expected })\n\nassert.AssertionError = function AssertionError(options) {\n this.name = 'AssertionError';\n this.actual = options.actual;\n this.expected = options.expected;\n this.operator = options.operator;\n if (options.message) {\n this.message = options.message;\n this.generatedMessage = false;\n } else {\n this.message = getMessage(this);\n this.generatedMessage = true;\n }\n var stackStartFunction = options.stackStartFunction || fail;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, stackStartFunction);\n }\n else {\n // non v8 browsers so we can have a stacktrace\n var err = new Error();\n if (err.stack) {\n var out = err.stack;\n\n // try to strip useless frames\n var fn_name = stackStartFunction.name;\n var idx = out.indexOf('\\n' + fn_name);\n if (idx >= 0) {\n // once we have located the function frame\n // we need to strip out everything before it (and its line)\n var next_line = out.indexOf('\\n', idx + 1);\n out = out.substring(next_line + 1);\n }\n\n this.stack = out;\n }\n }\n};\n\n// assert.AssertionError instanceof Error\nutil.inherits(assert.AssertionError, Error);\n\nfunction replacer(key, value) {\n if (util.isUndefined(value)) {\n return '' + value;\n }\n if (util.isNumber(value) && !isFinite(value)) {\n return value.toString();\n }\n if (util.isFunction(value) || util.isRegExp(value)) {\n return value.toString();\n }\n return value;\n}\n\nfunction truncate(s, n) {\n if (util.isString(s)) {\n return s.length < n ? s : s.slice(0, n);\n } else {\n return s;\n }\n}\n\nfunction getMessage(self) {\n return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +\n self.operator + ' ' +\n truncate(JSON.stringify(self.expected, replacer), 128);\n}\n\n// At present only the three keys mentioned above are used and\n// understood by the spec. Implementations or sub modules can pass\n// other keys to the AssertionError's constructor - they will be\n// ignored.\n\n// 3. All of the following functions must throw an AssertionError\n// when a corresponding condition is not met, with a message that\n// may be undefined if not provided. All assertion methods provide\n// both the actual and expected values to the assertion error for\n// display purposes.\n\nfunction fail(actual, expected, message, operator, stackStartFunction) {\n throw new assert.AssertionError({\n message: message,\n actual: actual,\n expected: expected,\n operator: operator,\n stackStartFunction: stackStartFunction\n });\n}\n\n// EXTENSION! allows for well behaved errors defined elsewhere.\nassert.fail = fail;\n\n// 4. Pure assertion tests whether a value is truthy, as determined\n// by !!guard.\n// assert.ok(guard, message_opt);\n// This statement is equivalent to assert.equal(true, !!guard,\n// message_opt);. To test strictly for the value true, use\n// assert.strictEqual(true, guard, message_opt);.\n\nfunction ok(value, message) {\n if (!value) fail(value, true, message, '==', assert.ok);\n}\nassert.ok = ok;\n\n// 5. The equality assertion tests shallow, coercive equality with\n// ==.\n// assert.equal(actual, expected, message_opt);\n\nassert.equal = function equal(actual, expected, message) {\n if (actual != expected) fail(actual, expected, message, '==', assert.equal);\n};\n\n// 6. The non-equality assertion tests for whether two objects are not equal\n// with != assert.notEqual(actual, expected, message_opt);\n\nassert.notEqual = function notEqual(actual, expected, message) {\n if (actual == expected) {\n fail(actual, expected, message, '!=', assert.notEqual);\n }\n};\n\n// 7. The equivalence assertion tests a deep equality relation.\n// assert.deepEqual(actual, expected, message_opt);\n\nassert.deepEqual = function deepEqual(actual, expected, message) {\n if (!_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'deepEqual', assert.deepEqual);\n }\n};\n\nfunction _deepEqual(actual, expected) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n\n } else if (util.isBuffer(actual) && util.isBuffer(expected)) {\n if (actual.length != expected.length) return false;\n\n for (var i = 0; i < actual.length; i++) {\n if (actual[i] !== expected[i]) return false;\n }\n\n return true;\n\n // 7.2. If the expected value is a Date object, the actual value is\n // equivalent if it is also a Date object that refers to the same time.\n } else if (util.isDate(actual) && util.isDate(expected)) {\n return actual.getTime() === expected.getTime();\n\n // 7.3 If the expected value is a RegExp object, the actual value is\n // equivalent if it is also a RegExp object with the same source and\n // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).\n } else if (util.isRegExp(actual) && util.isRegExp(expected)) {\n return actual.source === expected.source &&\n actual.global === expected.global &&\n actual.multiline === expected.multiline &&\n actual.lastIndex === expected.lastIndex &&\n actual.ignoreCase === expected.ignoreCase;\n\n // 7.4. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (!util.isObject(actual) && !util.isObject(expected)) {\n return actual == expected;\n\n // 7.5 For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else {\n return objEquiv(actual, expected);\n }\n}\n\nfunction isArguments(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\nfunction objEquiv(a, b) {\n if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))\n return false;\n // an identical 'prototype' property.\n if (a.prototype !== b.prototype) return false;\n // if one is a primitive, the other must be same\n if (util.isPrimitive(a) || util.isPrimitive(b)) {\n return a === b;\n }\n var aIsArgs = isArguments(a),\n bIsArgs = isArguments(b);\n if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))\n return false;\n if (aIsArgs) {\n a = pSlice.call(a);\n b = pSlice.call(b);\n return _deepEqual(a, b);\n }\n var ka = objectKeys(a),\n kb = objectKeys(b),\n key, i;\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length != kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] != kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!_deepEqual(a[key], b[key])) return false;\n }\n return true;\n}\n\n// 8. The non-equivalence assertion tests for any deep inequality.\n// assert.notDeepEqual(actual, expected, message_opt);\n\nassert.notDeepEqual = function notDeepEqual(actual, expected, message) {\n if (_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);\n }\n};\n\n// 9. The strict equality assertion tests strict equality, as determined by ===.\n// assert.strictEqual(actual, expected, message_opt);\n\nassert.strictEqual = function strictEqual(actual, expected, message) {\n if (actual !== expected) {\n fail(actual, expected, message, '===', assert.strictEqual);\n }\n};\n\n// 10. The strict non-equality assertion tests for strict inequality, as\n// determined by !==. assert.notStrictEqual(actual, expected, message_opt);\n\nassert.notStrictEqual = function notStrictEqual(actual, expected, message) {\n if (actual === expected) {\n fail(actual, expected, message, '!==', assert.notStrictEqual);\n }\n};\n\nfunction expectedException(actual, expected) {\n if (!actual || !expected) {\n return false;\n }\n\n if (Object.prototype.toString.call(expected) == '[object RegExp]') {\n return expected.test(actual);\n } else if (actual instanceof expected) {\n return true;\n } else if (expected.call({}, actual) === true) {\n return true;\n }\n\n return false;\n}\n\nfunction _throws(shouldThrow, block, expected, message) {\n var actual;\n\n if (util.isString(expected)) {\n message = expected;\n expected = null;\n }\n\n try {\n block();\n } catch (e) {\n actual = e;\n }\n\n message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +\n (message ? ' ' + message : '.');\n\n if (shouldThrow && !actual) {\n fail(actual, expected, 'Missing expected exception' + message);\n }\n\n if (!shouldThrow && expectedException(actual, expected)) {\n fail(actual, expected, 'Got unwanted exception' + message);\n }\n\n if ((shouldThrow && actual && expected &&\n !expectedException(actual, expected)) || (!shouldThrow && actual)) {\n throw actual;\n }\n}\n\n// 11. Expected to throw an error:\n// assert.throws(block, Error_opt, message_opt);\n\nassert.throws = function(block, /*optional*/error, /*optional*/message) {\n _throws.apply(this, [true].concat(pSlice.call(arguments)));\n};\n\n// EXTENSION! This is annoying to write outside this module.\nassert.doesNotThrow = function(block, /*optional*/message) {\n _throws.apply(this, [false].concat(pSlice.call(arguments)));\n};\n\nassert.ifError = function(err) { if (err) {throw err;}};\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n if (hasOwn.call(obj, key)) keys.push(key);\n }\n return keys;\n};\n\n},{\"util/\":11}],9:[function(require,module,exports){\nif (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n\n},{}],10:[function(require,module,exports){\nmodule.exports = function isBuffer(arg) {\n return arg && typeof arg === 'object'\n && typeof arg.copy === 'function'\n && typeof arg.fill === 'function'\n && typeof arg.readUInt8 === 'function';\n}\n},{}],11:[function(require,module,exports){\n(function (process,global){\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n // Allow for deprecating things in the process of starting up.\n if (isUndefined(global.process)) {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n if (process.noDeprecation === true) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\n}).call(this,require('_process'),typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"./support/isBuffer\":10,\"_process\":14,\"inherits\":9}],12:[function(require,module,exports){\n\n},{}],13:[function(require,module,exports){\n(function (process){\n// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,\n// backported and transplited with Babel, with backwards-compat fixes\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function (path) {\n if (typeof path !== 'string') path = path + '';\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) {\n // return '//';\n // Backwards-compat fix:\n return '/';\n }\n return path.slice(0, end);\n};\n\nfunction basename(path) {\n if (typeof path !== 'string') path = path + '';\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n}\n\n// Uses a mixed approach for backwards-compatibility, as ext behavior changed\n// in new Node.js versions, so only basename() above is backported here\nexports.basename = function (path, ext) {\n var f = basename(path);\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\nexports.extname = function (path) {\n if (typeof path !== 'string') path = path + '';\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n\n}).call(this,require('_process'))\n},{\"_process\":14}],14:[function(require,module,exports){\n// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],15:[function(require,module,exports){\nvar unparse = require('escodegen').generate;\n\nmodule.exports = function (ast, vars) {\n if (!vars) vars = {};\n var FAIL = {};\n \n var result = (function walk (node, scopeVars) {\n if (node.type === 'Literal') {\n return node.value;\n }\n else if (node.type === 'UnaryExpression'){\n var val = walk(node.argument)\n if (node.operator === '+') return +val\n if (node.operator === '-') return -val\n if (node.operator === '~') return ~val\n if (node.operator === '!') return !val\n return FAIL\n }\n else if (node.type === 'ArrayExpression') {\n var xs = [];\n for (var i = 0, l = node.elements.length; i < l; i++) {\n var x = walk(node.elements[i]);\n if (x === FAIL) return FAIL;\n xs.push(x);\n }\n return xs;\n }\n else if (node.type === 'ObjectExpression') {\n var obj = {};\n for (var i = 0; i < node.properties.length; i++) {\n var prop = node.properties[i];\n var value = prop.value === null\n ? prop.value\n : walk(prop.value)\n ;\n if (value === FAIL) return FAIL;\n obj[prop.key.value || prop.key.name] = value;\n }\n return obj;\n }\n else if (node.type === 'BinaryExpression' ||\n node.type === 'LogicalExpression') {\n var l = walk(node.left);\n if (l === FAIL) return FAIL;\n var r = walk(node.right);\n if (r === FAIL) return FAIL;\n \n var op = node.operator;\n if (op === '==') return l == r;\n if (op === '===') return l === r;\n if (op === '!=') return l != r;\n if (op === '!==') return l !== r;\n if (op === '+') return l + r;\n if (op === '-') return l - r;\n if (op === '*') return l * r;\n if (op === '/') return l / r;\n if (op === '%') return l % r;\n if (op === '<') return l < r;\n if (op === '<=') return l <= r;\n if (op === '>') return l > r;\n if (op === '>=') return l >= r;\n if (op === '|') return l | r;\n if (op === '&') return l & r;\n if (op === '^') return l ^ r;\n if (op === '&&') return l && r;\n if (op === '||') return l || r;\n \n return FAIL;\n }\n else if (node.type === 'Identifier') {\n if ({}.hasOwnProperty.call(vars, node.name)) {\n return vars[node.name];\n }\n else return FAIL;\n }\n else if (node.type === 'ThisExpression') {\n if ({}.hasOwnProperty.call(vars, 'this')) {\n return vars['this'];\n }\n else return FAIL;\n }\n else if (node.type === 'CallExpression') {\n var callee = walk(node.callee);\n if (callee === FAIL) return FAIL;\n if (typeof callee !== 'function') return FAIL;\n \n var ctx = node.callee.object ? walk(node.callee.object) : FAIL;\n if (ctx === FAIL) ctx = null;\n\n var args = [];\n for (var i = 0, l = node.arguments.length; i < l; i++) {\n var x = walk(node.arguments[i]);\n if (x === FAIL) return FAIL;\n args.push(x);\n }\n return callee.apply(ctx, args);\n }\n else if (node.type === 'MemberExpression') {\n var obj = walk(node.object);\n // do not allow access to methods on Function \n if((obj === FAIL) || (typeof obj == 'function')){\n return FAIL;\n }\n if (node.property.type === 'Identifier') {\n return obj[node.property.name];\n }\n var prop = walk(node.property);\n if (prop === FAIL) return FAIL;\n return obj[prop];\n }\n else if (node.type === 'ConditionalExpression') {\n var val = walk(node.test)\n if (val === FAIL) return FAIL;\n return val ? walk(node.consequent) : walk(node.alternate)\n }\n else if (node.type === 'ExpressionStatement') {\n var val = walk(node.expression)\n if (val === FAIL) return FAIL;\n return val;\n }\n else if (node.type === 'ReturnStatement') {\n return walk(node.argument)\n }\n else if (node.type === 'FunctionExpression') {\n \n var bodies = node.body.body;\n \n // Create a \"scope\" for our arguments\n var oldVars = {};\n Object.keys(vars).forEach(function(element){\n oldVars[element] = vars[element];\n })\n\n for(var i=0; i\r\n *\r\n * This work is licensed under the MIT License.\r\n *\r\n * Revision 20: April 26, 2011\r\n * Fixed a typo resulting in FIRST_ORDERED_NODE_TYPE results being wrong,\r\n * thanks to .\r\n *\r\n * Revision 19: November 29, 2005\r\n * Nodesets now store their nodes in a height balanced tree, increasing\r\n * performance for the common case of selecting nodes in document order,\r\n * thanks to Sébastien Cramatte .\r\n * AVL tree code adapted from Raimund Neumann .\r\n *\r\n * Revision 18: October 27, 2005\r\n * DOM 3 XPath support. Caveats:\r\n * - namespace prefixes aren't resolved in XPathEvaluator.createExpression,\r\n * but in XPathExpression.evaluate.\r\n * - XPathResult.invalidIteratorState is not implemented.\r\n *\r\n * Revision 17: October 25, 2005\r\n * Some core XPath function fixes and a patch to avoid crashing certain\r\n * versions of MSXML in PathExpr.prototype.getOwnerElement, thanks to\r\n * Sébastien Cramatte .\r\n *\r\n * Revision 16: September 22, 2005\r\n * Workarounds for some IE 5.5 deficiencies.\r\n * Fixed problem with prefix node tests on attribute nodes.\r\n *\r\n * Revision 15: May 21, 2005\r\n * Fixed problem with QName node tests on elements with an xmlns=\"...\".\r\n *\r\n * Revision 14: May 19, 2005\r\n * Fixed QName node tests on attribute node regression.\r\n *\r\n * Revision 13: May 3, 2005\r\n * Node tests are case insensitive now if working in an HTML DOM.\r\n *\r\n * Revision 12: April 26, 2005\r\n * Updated licence. Slight code changes to enable use of Dean\r\n * Edwards' script compression, http://dean.edwards.name/packer/ .\r\n *\r\n * Revision 11: April 23, 2005\r\n * Fixed bug with 'and' and 'or' operators, fix thanks to\r\n * Sandy McArthur .\r\n *\r\n * Revision 10: April 15, 2005\r\n * Added support for a virtual root node, supposedly helpful for\r\n * implementing XForms. Fixed problem with QName node tests and\r\n * the parent axis.\r\n *\r\n * Revision 9: March 17, 2005\r\n * Namespace resolver tweaked so using the document node as the context\r\n * for namespace lookups is equivalent to using the document element.\r\n *\r\n * Revision 8: February 13, 2005\r\n * Handle implicit declaration of 'xmlns' namespace prefix.\r\n * Fixed bug when comparing nodesets.\r\n * Instance data can now be associated with a FunctionResolver, and\r\n * workaround for MSXML not supporting 'localName' and 'getElementById',\r\n * thanks to Grant Gongaware.\r\n * Fix a few problems when the context node is the root node.\r\n *\r\n * Revision 7: February 11, 2005\r\n * Default namespace resolver fix from Grant Gongaware\r\n * .\r\n *\r\n * Revision 6: February 10, 2005\r\n * Fixed bug in 'number' function.\r\n *\r\n * Revision 5: February 9, 2005\r\n * Fixed bug where text nodes not getting converted to string values.\r\n *\r\n * Revision 4: January 21, 2005\r\n * Bug in 'name' function, fix thanks to Bill Edney.\r\n * Fixed incorrect processing of namespace nodes.\r\n * Fixed NamespaceResolver to resolve 'xml' namespace.\r\n * Implemented union '|' operator.\r\n *\r\n * Revision 3: January 14, 2005\r\n * Fixed bug with nodeset comparisons, bug lexing < and >.\r\n *\r\n * Revision 2: October 26, 2004\r\n * QName node test namespace handling fixed. Few other bug fixes.\r\n *\r\n * Revision 1: August 13, 2004\r\n * Bug fixes from William J. Edney .\r\n * Added minimal licence.\r\n *\r\n * Initial version: June 14, 2004\r\n */\r\n\r\n// non-node wrapper\r\nvar xpath = (typeof exports === 'undefined') ? {} : exports;\r\n\r\n(function (exports) {\r\n \"use strict\";\r\n\r\n // namespace nodes are not part of the DOM spec, so we use a custom nodetype for them.\r\n // should NOT be used externally\r\n var NAMESPACE_NODE_NODETYPE = '__namespace';\r\n\r\n var isNil = function (x) {\r\n return x === null || x === undefined;\r\n };\r\n\r\n var isValidNodeType = function (nodeType) {\r\n return nodeType === NAMESPACE_NODE_NODETYPE ||\r\n (Number.isInteger(nodeType)\r\n && nodeType >= 1\r\n && nodeType <= 11\r\n );\r\n };\r\n\r\n var isNodeLike = function (value) {\r\n return value\r\n && isValidNodeType(value.nodeType)\r\n && typeof value.nodeName === \"string\";\r\n };\r\n\r\n // functional helpers\r\n function curry(func) {\r\n var slice = Array.prototype.slice,\r\n totalargs = func.length,\r\n partial = function (args, fn) {\r\n return function () {\r\n return fn.apply(this, args.concat(slice.call(arguments)));\r\n }\r\n },\r\n fn = function () {\r\n var args = slice.call(arguments);\r\n return (args.length < totalargs) ?\r\n partial(args, fn) :\r\n func.apply(this, slice.apply(arguments, [0, totalargs]));\r\n };\r\n return fn;\r\n }\r\n\r\n var forEach = function (f, xs) {\r\n for (var i = 0; i < xs.length; i += 1) {\r\n f(xs[i], i, xs);\r\n }\r\n };\r\n\r\n var reduce = function (f, seed, xs) {\r\n var acc = seed;\r\n\r\n forEach(function (x, i) { acc = f(acc, x, i); }, xs);\r\n\r\n return acc;\r\n };\r\n\r\n var map = function (f, xs) {\r\n var mapped = new Array(xs.length);\r\n\r\n forEach(function (x, i) { mapped[i] = f(x); }, xs);\r\n\r\n return mapped;\r\n };\r\n\r\n var filter = function (f, xs) {\r\n var filtered = [];\r\n\r\n forEach(function (x, i) { if (f(x, i)) { filtered.push(x); } }, xs);\r\n\r\n return filtered;\r\n };\r\n\r\n var includes = function (values, value) {\r\n for (var i = 0; i < values.length; i += 1) {\r\n if (values[i] === value) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n };\r\n\r\n function always(value) { return function () { return value; } }\r\n\r\n function toString(x) { return x.toString(); }\r\n var join = function (s, xs) { return xs.join(s); };\r\n var wrap = function (pref, suf, str) { return pref + str + suf; };\r\n\r\n var prototypeConcat = Array.prototype.concat;\r\n\r\n var sortNodes = function (nodes, reverse) {\r\n var ns = new XNodeSet();\r\n\r\n ns.addArray(nodes);\r\n\r\n var sorted = ns.toArray();\r\n\r\n return reverse ? sorted.reverse() : sorted;\r\n }\r\n\r\n // .apply() fails above a certain number of arguments - https://github.com/goto100/xpath/pull/98\r\n var MAX_ARGUMENT_LENGTH = 32767;\r\n\r\n function flatten(arr) {\r\n var result = [];\r\n\r\n for (var start = 0; start < arr.length; start += MAX_ARGUMENT_LENGTH) {\r\n var chunk = arr.slice(start, start + MAX_ARGUMENT_LENGTH);\r\n\r\n result = prototypeConcat.apply(result, chunk);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n function assign(target, varArgs) { // .length of function is 2\r\n var to = Object(target);\r\n\r\n for (var index = 1; index < arguments.length; index++) {\r\n var nextSource = arguments[index];\r\n\r\n if (nextSource != null) { // Skip over if undefined or null\r\n for (var nextKey in nextSource) {\r\n // Avoid bugs when hasOwnProperty is shadowed\r\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\r\n to[nextKey] = nextSource[nextKey];\r\n }\r\n }\r\n }\r\n }\r\n\r\n return to;\r\n }\r\n\r\n var NodeTypes = {\r\n ELEMENT_NODE: 1,\r\n ATTRIBUTE_NODE: 2,\r\n TEXT_NODE: 3,\r\n CDATA_SECTION_NODE: 4,\r\n PROCESSING_INSTRUCTION_NODE: 7,\r\n COMMENT_NODE: 8,\r\n DOCUMENT_NODE: 9,\r\n DOCUMENT_TYPE_NODE: 10,\r\n DOCUMENT_FRAGMENT_NODE: 11,\r\n NAMESPACE_NODE: NAMESPACE_NODE_NODETYPE,\r\n };\r\n\r\n // XPathParser ///////////////////////////////////////////////////////////////\r\n\r\n XPathParser.prototype = new Object();\r\n XPathParser.prototype.constructor = XPathParser;\r\n XPathParser.superclass = Object.prototype;\r\n\r\n function XPathParser() {\r\n this.init();\r\n }\r\n\r\n XPathParser.prototype.init = function () {\r\n this.reduceActions = [];\r\n\r\n this.reduceActions[3] = function (rhs) {\r\n return new OrOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[5] = function (rhs) {\r\n return new AndOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[7] = function (rhs) {\r\n return new EqualsOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[8] = function (rhs) {\r\n return new NotEqualOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[10] = function (rhs) {\r\n return new LessThanOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[11] = function (rhs) {\r\n return new GreaterThanOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[12] = function (rhs) {\r\n return new LessThanOrEqualOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[13] = function (rhs) {\r\n return new GreaterThanOrEqualOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[15] = function (rhs) {\r\n return new PlusOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[16] = function (rhs) {\r\n return new MinusOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[18] = function (rhs) {\r\n return new MultiplyOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[19] = function (rhs) {\r\n return new DivOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[20] = function (rhs) {\r\n return new ModOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[22] = function (rhs) {\r\n return new UnaryMinusOperation(rhs[1]);\r\n };\r\n this.reduceActions[24] = function (rhs) {\r\n return new BarOperation(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[25] = function (rhs) {\r\n return new PathExpr(undefined, undefined, rhs[0]);\r\n };\r\n this.reduceActions[27] = function (rhs) {\r\n rhs[0].locationPath = rhs[2];\r\n return rhs[0];\r\n };\r\n this.reduceActions[28] = function (rhs) {\r\n rhs[0].locationPath = rhs[2];\r\n rhs[0].locationPath.steps.unshift(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));\r\n return rhs[0];\r\n };\r\n this.reduceActions[29] = function (rhs) {\r\n return new PathExpr(rhs[0], [], undefined);\r\n };\r\n this.reduceActions[30] = function (rhs) {\r\n if (Utilities.instance_of(rhs[0], PathExpr)) {\r\n if (rhs[0].filterPredicates == undefined) {\r\n rhs[0].filterPredicates = [];\r\n }\r\n rhs[0].filterPredicates.push(rhs[1]);\r\n return rhs[0];\r\n } else {\r\n return new PathExpr(rhs[0], [rhs[1]], undefined);\r\n }\r\n };\r\n this.reduceActions[32] = function (rhs) {\r\n return rhs[1];\r\n };\r\n this.reduceActions[33] = function (rhs) {\r\n return new XString(rhs[0]);\r\n };\r\n this.reduceActions[34] = function (rhs) {\r\n return new XNumber(rhs[0]);\r\n };\r\n this.reduceActions[36] = function (rhs) {\r\n return new FunctionCall(rhs[0], []);\r\n };\r\n this.reduceActions[37] = function (rhs) {\r\n return new FunctionCall(rhs[0], rhs[2]);\r\n };\r\n this.reduceActions[38] = function (rhs) {\r\n return [rhs[0]];\r\n };\r\n this.reduceActions[39] = function (rhs) {\r\n rhs[2].unshift(rhs[0]);\r\n return rhs[2];\r\n };\r\n this.reduceActions[43] = function (rhs) {\r\n return new LocationPath(true, []);\r\n };\r\n this.reduceActions[44] = function (rhs) {\r\n rhs[1].absolute = true;\r\n return rhs[1];\r\n };\r\n this.reduceActions[46] = function (rhs) {\r\n return new LocationPath(false, [rhs[0]]);\r\n };\r\n this.reduceActions[47] = function (rhs) {\r\n rhs[0].steps.push(rhs[2]);\r\n return rhs[0];\r\n };\r\n this.reduceActions[49] = function (rhs) {\r\n return new Step(rhs[0], rhs[1], []);\r\n };\r\n this.reduceActions[50] = function (rhs) {\r\n return new Step(Step.CHILD, rhs[0], []);\r\n };\r\n this.reduceActions[51] = function (rhs) {\r\n return new Step(rhs[0], rhs[1], rhs[2]);\r\n };\r\n this.reduceActions[52] = function (rhs) {\r\n return new Step(Step.CHILD, rhs[0], rhs[1]);\r\n };\r\n this.reduceActions[54] = function (rhs) {\r\n return [rhs[0]];\r\n };\r\n this.reduceActions[55] = function (rhs) {\r\n rhs[1].unshift(rhs[0]);\r\n return rhs[1];\r\n };\r\n this.reduceActions[56] = function (rhs) {\r\n if (rhs[0] == \"ancestor\") {\r\n return Step.ANCESTOR;\r\n } else if (rhs[0] == \"ancestor-or-self\") {\r\n return Step.ANCESTORORSELF;\r\n } else if (rhs[0] == \"attribute\") {\r\n return Step.ATTRIBUTE;\r\n } else if (rhs[0] == \"child\") {\r\n return Step.CHILD;\r\n } else if (rhs[0] == \"descendant\") {\r\n return Step.DESCENDANT;\r\n } else if (rhs[0] == \"descendant-or-self\") {\r\n return Step.DESCENDANTORSELF;\r\n } else if (rhs[0] == \"following\") {\r\n return Step.FOLLOWING;\r\n } else if (rhs[0] == \"following-sibling\") {\r\n return Step.FOLLOWINGSIBLING;\r\n } else if (rhs[0] == \"namespace\") {\r\n return Step.NAMESPACE;\r\n } else if (rhs[0] == \"parent\") {\r\n return Step.PARENT;\r\n } else if (rhs[0] == \"preceding\") {\r\n return Step.PRECEDING;\r\n } else if (rhs[0] == \"preceding-sibling\") {\r\n return Step.PRECEDINGSIBLING;\r\n } else if (rhs[0] == \"self\") {\r\n return Step.SELF;\r\n }\r\n return -1;\r\n };\r\n this.reduceActions[57] = function (rhs) {\r\n return Step.ATTRIBUTE;\r\n };\r\n this.reduceActions[59] = function (rhs) {\r\n if (rhs[0] == \"comment\") {\r\n return NodeTest.commentTest;\r\n } else if (rhs[0] == \"text\") {\r\n return NodeTest.textTest;\r\n } else if (rhs[0] == \"processing-instruction\") {\r\n return NodeTest.anyPiTest;\r\n } else if (rhs[0] == \"node\") {\r\n return NodeTest.nodeTest;\r\n }\r\n return new NodeTest(-1, undefined);\r\n };\r\n this.reduceActions[60] = function (rhs) {\r\n return new NodeTest.PITest(rhs[2]);\r\n };\r\n this.reduceActions[61] = function (rhs) {\r\n return rhs[1];\r\n };\r\n this.reduceActions[63] = function (rhs) {\r\n rhs[1].absolute = true;\r\n rhs[1].steps.unshift(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));\r\n return rhs[1];\r\n };\r\n this.reduceActions[64] = function (rhs) {\r\n rhs[0].steps.push(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));\r\n rhs[0].steps.push(rhs[2]);\r\n return rhs[0];\r\n };\r\n this.reduceActions[65] = function (rhs) {\r\n return new Step(Step.SELF, NodeTest.nodeTest, []);\r\n };\r\n this.reduceActions[66] = function (rhs) {\r\n return new Step(Step.PARENT, NodeTest.nodeTest, []);\r\n };\r\n this.reduceActions[67] = function (rhs) {\r\n return new VariableReference(rhs[1]);\r\n };\r\n this.reduceActions[68] = function (rhs) {\r\n return NodeTest.nameTestAny;\r\n };\r\n this.reduceActions[69] = function (rhs) {\r\n return new NodeTest.NameTestPrefixAny(rhs[0].split(':')[0]);\r\n };\r\n this.reduceActions[70] = function (rhs) {\r\n return new NodeTest.NameTestQName(rhs[0]);\r\n };\r\n };\r\n\r\n XPathParser.actionTable = [\r\n \" s s sssssssss s ss s ss\",\r\n \" s \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \" rrrrr \",\r\n \" s s sssssssss s ss s ss\",\r\n \"rs rrrrrrrr s sssssrrrrrr rrs rs \",\r\n \" s s sssssssss s ss s ss\",\r\n \" s \",\r\n \" s \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" s \",\r\n \" s \",\r\n \" s s sssss s s \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"a \",\r\n \"r s rr r \",\r\n \"r sr rr r \",\r\n \"r s rr s rr r \",\r\n \"r rssrr rss rr r \",\r\n \"r rrrrr rrrss rr r \",\r\n \"r rrrrrsss rrrrr rr r \",\r\n \"r rrrrrrrr rrrrr rr r \",\r\n \"r rrrrrrrr rrrrrs rr r \",\r\n \"r rrrrrrrr rrrrrr rr r \",\r\n \"r rrrrrrrr rrrrrr rr r \",\r\n \"r srrrrrrrr rrrrrrs rr sr \",\r\n \"r srrrrrrrr rrrrrrs rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrr rrrrrr rr r \",\r\n \"r rrrrrrrr rrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \" sssss \",\r\n \"r rrrrrrrrr rrrrrrr rr sr \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" s \",\r\n \"r srrrrrrrr rrrrrrs rr r \",\r\n \"r rrrrrrrr rrrrr rr r \",\r\n \" s \",\r\n \" s \",\r\n \" rrrrr \",\r\n \" s s sssssssss s sss s ss\",\r\n \"r srrrrrrrr rrrrrrs rr r \",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssssssss ss s ss\",\r\n \" s s sssssssss s ss s ss\",\r\n \" s s sssss s s \",\r\n \" s s sssss s s \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" s s sssss s s \",\r\n \" s s sssss s s \",\r\n \"r rrrrrrrrr rrrrrrr rr sr \",\r\n \"r rrrrrrrrr rrrrrrr rr sr \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" s \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" rr \",\r\n \" s \",\r\n \" rs \",\r\n \"r sr rr r \",\r\n \"r s rr s rr r \",\r\n \"r rssrr rss rr r \",\r\n \"r rssrr rss rr r \",\r\n \"r rrrrr rrrss rr r \",\r\n \"r rrrrr rrrss rr r \",\r\n \"r rrrrr rrrss rr r \",\r\n \"r rrrrr rrrss rr r \",\r\n \"r rrrrrsss rrrrr rr r \",\r\n \"r rrrrrsss rrrrr rr r \",\r\n \"r rrrrrrrr rrrrr rr r \",\r\n \"r rrrrrrrr rrrrr rr r \",\r\n \"r rrrrrrrr rrrrr rr r \",\r\n \"r rrrrrrrr rrrrrr rr r \",\r\n \" r \",\r\n \" s \",\r\n \"r srrrrrrrr rrrrrrs rr r \",\r\n \"r srrrrrrrr rrrrrrs rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr r \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" s s sssssssss s ss s ss\",\r\n \"r rrrrrrrrr rrrrrrr rr rr \",\r\n \" r \"\r\n ];\r\n\r\n XPathParser.actionTableNumber = [\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" J \",\r\n \"a aaaaaaaaa aaaaaaa aa a \",\r\n \" YYYYY \",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \"K1 KKKKKKKK . +*)('KKKKKK KK# K\\\" \",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" N \",\r\n \" O \",\r\n \"e eeeeeeeee eeeeeee ee ee \",\r\n \"f fffffffff fffffff ff ff \",\r\n \"d ddddddddd ddddddd dd dd \",\r\n \"B BBBBBBBBB BBBBBBB BB BB \",\r\n \"A AAAAAAAAA AAAAAAA AA AA \",\r\n \" P \",\r\n \" Q \",\r\n \" 1 . +*)(' # \\\" \",\r\n \"b bbbbbbbbb bbbbbbb bb b \",\r\n \" \",\r\n \"! S !! ! \",\r\n \"\\\" T\\\" \\\"\\\" \\\" \",\r\n \"$ V $$ U $$ $ \",\r\n \"& &ZY&& &XW && & \",\r\n \") ))))) )))\\\\[ )) ) \",\r\n \". ....._^] ..... .. . \",\r\n \"1 11111111 11111 11 1 \",\r\n \"5 55555555 55555` 55 5 \",\r\n \"7 77777777 777777 77 7 \",\r\n \"9 99999999 999999 99 9 \",\r\n \": c:::::::: ::::::b :: a: \",\r\n \"I fIIIIIIII IIIIIIe II I \",\r\n \"= ========= ======= == == \",\r\n \"? ????????? ??????? ?? ?? \",\r\n \"C CCCCCCCCC CCCCCCC CC CC \",\r\n \"J JJJJJJJJ JJJJJJ JJ J \",\r\n \"M MMMMMMMM MMMMMM MM M \",\r\n \"N NNNNNNNNN NNNNNNN NN N \",\r\n \"P PPPPPPPPP PPPPPPP PP P \",\r\n \" +*)(' \",\r\n \"R RRRRRRRRR RRRRRRR RR aR \",\r\n \"U UUUUUUUUU UUUUUUU UU U \",\r\n \"Z ZZZZZZZZZ ZZZZZZZ ZZ ZZ \",\r\n \"c ccccccccc ccccccc cc cc \",\r\n \" j \",\r\n \"L fLLLLLLLL LLLLLLe LL L \",\r\n \"6 66666666 66666 66 6 \",\r\n \" k \",\r\n \" l \",\r\n \" XXXXX \",\r\n \" 1 0 /.-,+*)(' & %$m # \\\"!\",\r\n \"_ f________ ______e __ _ \",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' %$ # \\\"!\",\r\n \" 1 0 /.-,+*)(' & %$ # \\\"!\",\r\n \" 1 . +*)(' # \\\" \",\r\n \" 1 . +*)(' # \\\" \",\r\n \"> >>>>>>>>> >>>>>>> >> >> \",\r\n \" 1 . +*)(' # \\\" \",\r\n \" 1 . +*)(' # \\\" \",\r\n \"Q QQQQQQQQQ QQQQQQQ QQ aQ \",\r\n \"V VVVVVVVVV VVVVVVV VV aV \",\r\n \"T TTTTTTTTT TTTTTTT TT T \",\r\n \"@ @@@@@@@@@ @@@@@@@ @@ @@ \",\r\n \" \\x87 \",\r\n \"[ [[[[[[[[[ [[[[[[[ [[ [[ \",\r\n \"D DDDDDDDDD DDDDDDD DD DD \",\r\n \" HH \",\r\n \" \\x88 \",\r\n \" F\\x89 \",\r\n \"# T# ## # \",\r\n \"% V %% U %% % \",\r\n \"' 'ZY'' 'XW '' ' \",\r\n \"( (ZY(( (XW (( ( \",\r\n \"+ +++++ +++\\\\[ ++ + \",\r\n \"* ***** ***\\\\[ ** * \",\r\n \"- ----- ---\\\\[ -- - \",\r\n \", ,,,,, ,,,\\\\[ ,, , \",\r\n \"0 00000_^] 00000 00 0 \",\r\n \"/ /////_^] ///// // / \",\r\n \"2 22222222 22222 22 2 \",\r\n \"3 33333333 33333 33 3 \",\r\n \"4 44444444 44444 44 4 \",\r\n \"8 88888888 888888 88 8 \",\r\n \" ^ \",\r\n \" \\x8a \",\r\n \"; f;;;;;;;; ;;;;;;e ;; ; \",\r\n \"< f<<<<<<<< <<<<<?@ AB CDEFGH IJ \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \"L456789:;<=>?@ AB CDEFGH IJ \",\r\n \" M EFGH IJ \",\r\n \" N;<=>?@ AB CDEFGH IJ \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" S EFGH IJ \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" e \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" h J \",\r\n \" i j \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \"o456789:;<=>?@ ABpqCDEFGH IJ \",\r\n \" \",\r\n \" r6789:;<=>?@ AB CDEFGH IJ \",\r\n \" s789:;<=>?@ AB CDEFGH IJ \",\r\n \" t89:;<=>?@ AB CDEFGH IJ \",\r\n \" u89:;<=>?@ AB CDEFGH IJ \",\r\n \" v9:;<=>?@ AB CDEFGH IJ \",\r\n \" w9:;<=>?@ AB CDEFGH IJ \",\r\n \" x9:;<=>?@ AB CDEFGH IJ \",\r\n \" y9:;<=>?@ AB CDEFGH IJ \",\r\n \" z:;<=>?@ AB CDEFGH IJ \",\r\n \" {:;<=>?@ AB CDEFGH IJ \",\r\n \" |;<=>?@ AB CDEFGH IJ \",\r\n \" };<=>?@ AB CDEFGH IJ \",\r\n \" ~;<=>?@ AB CDEFGH IJ \",\r\n \" \\x7f=>?@ AB CDEFGH IJ \",\r\n \"\\x80456789:;<=>?@ AB CDEFGH IJ\\x81\",\r\n \" \\x82 EFGH IJ \",\r\n \" \\x83 EFGH IJ \",\r\n \" \",\r\n \" \\x84 GH IJ \",\r\n \" \\x85 GH IJ \",\r\n \" i \\x86 \",\r\n \" i \\x87 \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \" \",\r\n \"o456789:;<=>?@ AB\\x8cqCDEFGH IJ \",\r\n \" \",\r\n \" \"\r\n ];\r\n\r\n XPathParser.productions = [\r\n [1, 1, 2],\r\n [2, 1, 3],\r\n [3, 1, 4],\r\n [3, 3, 3, -9, 4],\r\n [4, 1, 5],\r\n [4, 3, 4, -8, 5],\r\n [5, 1, 6],\r\n [5, 3, 5, -22, 6],\r\n [5, 3, 5, -5, 6],\r\n [6, 1, 7],\r\n [6, 3, 6, -23, 7],\r\n [6, 3, 6, -24, 7],\r\n [6, 3, 6, -6, 7],\r\n [6, 3, 6, -7, 7],\r\n [7, 1, 8],\r\n [7, 3, 7, -25, 8],\r\n [7, 3, 7, -26, 8],\r\n [8, 1, 9],\r\n [8, 3, 8, -12, 9],\r\n [8, 3, 8, -11, 9],\r\n [8, 3, 8, -10, 9],\r\n [9, 1, 10],\r\n [9, 2, -26, 9],\r\n [10, 1, 11],\r\n [10, 3, 10, -27, 11],\r\n [11, 1, 12],\r\n [11, 1, 13],\r\n [11, 3, 13, -28, 14],\r\n [11, 3, 13, -4, 14],\r\n [13, 1, 15],\r\n [13, 2, 13, 16],\r\n [15, 1, 17],\r\n [15, 3, -29, 2, -30],\r\n [15, 1, -15],\r\n [15, 1, -16],\r\n [15, 1, 18],\r\n [18, 3, -13, -29, -30],\r\n [18, 4, -13, -29, 19, -30],\r\n [19, 1, 20],\r\n [19, 3, 20, -31, 19],\r\n [20, 1, 2],\r\n [12, 1, 14],\r\n [12, 1, 21],\r\n [21, 1, -28],\r\n [21, 2, -28, 14],\r\n [21, 1, 22],\r\n [14, 1, 23],\r\n [14, 3, 14, -28, 23],\r\n [14, 1, 24],\r\n [23, 2, 25, 26],\r\n [23, 1, 26],\r\n [23, 3, 25, 26, 27],\r\n [23, 2, 26, 27],\r\n [23, 1, 28],\r\n [27, 1, 16],\r\n [27, 2, 16, 27],\r\n [25, 2, -14, -3],\r\n [25, 1, -32],\r\n [26, 1, 29],\r\n [26, 3, -20, -29, -30],\r\n [26, 4, -21, -29, -15, -30],\r\n [16, 3, -33, 30, -34],\r\n [30, 1, 2],\r\n [22, 2, -4, 14],\r\n [24, 3, 14, -4, 23],\r\n [28, 1, -35],\r\n [28, 1, -2],\r\n [17, 2, -36, -18],\r\n [29, 1, -17],\r\n [29, 1, -19],\r\n [29, 1, -18]\r\n ];\r\n\r\n XPathParser.DOUBLEDOT = 2;\r\n XPathParser.DOUBLECOLON = 3;\r\n XPathParser.DOUBLESLASH = 4;\r\n XPathParser.NOTEQUAL = 5;\r\n XPathParser.LESSTHANOREQUAL = 6;\r\n XPathParser.GREATERTHANOREQUAL = 7;\r\n XPathParser.AND = 8;\r\n XPathParser.OR = 9;\r\n XPathParser.MOD = 10;\r\n XPathParser.DIV = 11;\r\n XPathParser.MULTIPLYOPERATOR = 12;\r\n XPathParser.FUNCTIONNAME = 13;\r\n XPathParser.AXISNAME = 14;\r\n XPathParser.LITERAL = 15;\r\n XPathParser.NUMBER = 16;\r\n XPathParser.ASTERISKNAMETEST = 17;\r\n XPathParser.QNAME = 18;\r\n XPathParser.NCNAMECOLONASTERISK = 19;\r\n XPathParser.NODETYPE = 20;\r\n XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL = 21;\r\n XPathParser.EQUALS = 22;\r\n XPathParser.LESSTHAN = 23;\r\n XPathParser.GREATERTHAN = 24;\r\n XPathParser.PLUS = 25;\r\n XPathParser.MINUS = 26;\r\n XPathParser.BAR = 27;\r\n XPathParser.SLASH = 28;\r\n XPathParser.LEFTPARENTHESIS = 29;\r\n XPathParser.RIGHTPARENTHESIS = 30;\r\n XPathParser.COMMA = 31;\r\n XPathParser.AT = 32;\r\n XPathParser.LEFTBRACKET = 33;\r\n XPathParser.RIGHTBRACKET = 34;\r\n XPathParser.DOT = 35;\r\n XPathParser.DOLLAR = 36;\r\n\r\n XPathParser.prototype.tokenize = function (s1) {\r\n var types = [];\r\n var values = [];\r\n var s = s1 + '\\0';\r\n\r\n var pos = 0;\r\n var c = s.charAt(pos++);\r\n while (1) {\r\n while (c == ' ' || c == '\\t' || c == '\\r' || c == '\\n') {\r\n c = s.charAt(pos++);\r\n }\r\n if (c == '\\0' || pos >= s.length) {\r\n break;\r\n }\r\n\r\n if (c == '(') {\r\n types.push(XPathParser.LEFTPARENTHESIS);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == ')') {\r\n types.push(XPathParser.RIGHTPARENTHESIS);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '[') {\r\n types.push(XPathParser.LEFTBRACKET);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == ']') {\r\n types.push(XPathParser.RIGHTBRACKET);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '@') {\r\n types.push(XPathParser.AT);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == ',') {\r\n types.push(XPathParser.COMMA);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '|') {\r\n types.push(XPathParser.BAR);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '+') {\r\n types.push(XPathParser.PLUS);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '-') {\r\n types.push(XPathParser.MINUS);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '=') {\r\n types.push(XPathParser.EQUALS);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c == '$') {\r\n types.push(XPathParser.DOLLAR);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n\r\n if (c == '.') {\r\n c = s.charAt(pos++);\r\n if (c == '.') {\r\n types.push(XPathParser.DOUBLEDOT);\r\n values.push(\"..\");\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (c >= '0' && c <= '9') {\r\n var number = \".\" + c;\r\n c = s.charAt(pos++);\r\n while (c >= '0' && c <= '9') {\r\n number += c;\r\n c = s.charAt(pos++);\r\n }\r\n types.push(XPathParser.NUMBER);\r\n values.push(number);\r\n continue;\r\n }\r\n types.push(XPathParser.DOT);\r\n values.push('.');\r\n continue;\r\n }\r\n\r\n if (c == '\\'' || c == '\"') {\r\n var delimiter = c;\r\n var literal = \"\";\r\n while (pos < s.length && (c = s.charAt(pos)) !== delimiter) {\r\n literal += c;\r\n pos += 1;\r\n }\r\n if (c !== delimiter) {\r\n throw XPathException.fromMessage(\"Unterminated string literal: \" + delimiter + literal);\r\n }\r\n pos += 1;\r\n types.push(XPathParser.LITERAL);\r\n values.push(literal);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n\r\n if (c >= '0' && c <= '9') {\r\n var number = c;\r\n c = s.charAt(pos++);\r\n while (c >= '0' && c <= '9') {\r\n number += c;\r\n c = s.charAt(pos++);\r\n }\r\n if (c == '.') {\r\n if (s.charAt(pos) >= '0' && s.charAt(pos) <= '9') {\r\n number += c;\r\n number += s.charAt(pos++);\r\n c = s.charAt(pos++);\r\n while (c >= '0' && c <= '9') {\r\n number += c;\r\n c = s.charAt(pos++);\r\n }\r\n }\r\n }\r\n types.push(XPathParser.NUMBER);\r\n values.push(number);\r\n continue;\r\n }\r\n\r\n if (c == '*') {\r\n if (types.length > 0) {\r\n var last = types[types.length - 1];\r\n if (last != XPathParser.AT\r\n && last != XPathParser.DOUBLECOLON\r\n && last != XPathParser.LEFTPARENTHESIS\r\n && last != XPathParser.LEFTBRACKET\r\n && last != XPathParser.AND\r\n && last != XPathParser.OR\r\n && last != XPathParser.MOD\r\n && last != XPathParser.DIV\r\n && last != XPathParser.MULTIPLYOPERATOR\r\n && last != XPathParser.SLASH\r\n && last != XPathParser.DOUBLESLASH\r\n && last != XPathParser.BAR\r\n && last != XPathParser.PLUS\r\n && last != XPathParser.MINUS\r\n && last != XPathParser.EQUALS\r\n && last != XPathParser.NOTEQUAL\r\n && last != XPathParser.LESSTHAN\r\n && last != XPathParser.LESSTHANOREQUAL\r\n && last != XPathParser.GREATERTHAN\r\n && last != XPathParser.GREATERTHANOREQUAL) {\r\n types.push(XPathParser.MULTIPLYOPERATOR);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n }\r\n types.push(XPathParser.ASTERISKNAMETEST);\r\n values.push(c);\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n\r\n if (c == ':') {\r\n if (s.charAt(pos) == ':') {\r\n types.push(XPathParser.DOUBLECOLON);\r\n values.push(\"::\");\r\n pos++;\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n }\r\n\r\n if (c == '/') {\r\n c = s.charAt(pos++);\r\n if (c == '/') {\r\n types.push(XPathParser.DOUBLESLASH);\r\n values.push(\"//\");\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n types.push(XPathParser.SLASH);\r\n values.push('/');\r\n continue;\r\n }\r\n\r\n if (c == '!') {\r\n if (s.charAt(pos) == '=') {\r\n types.push(XPathParser.NOTEQUAL);\r\n values.push(\"!=\");\r\n pos++;\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n }\r\n\r\n if (c == '<') {\r\n if (s.charAt(pos) == '=') {\r\n types.push(XPathParser.LESSTHANOREQUAL);\r\n values.push(\"<=\");\r\n pos++;\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n types.push(XPathParser.LESSTHAN);\r\n values.push('<');\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n\r\n if (c == '>') {\r\n if (s.charAt(pos) == '=') {\r\n types.push(XPathParser.GREATERTHANOREQUAL);\r\n values.push(\">=\");\r\n pos++;\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n types.push(XPathParser.GREATERTHAN);\r\n values.push('>');\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n\r\n if (c == '_' || Utilities.isLetter(c.charCodeAt(0))) {\r\n var name = c;\r\n c = s.charAt(pos++);\r\n while (Utilities.isNCNameChar(c.charCodeAt(0))) {\r\n name += c;\r\n c = s.charAt(pos++);\r\n }\r\n if (types.length > 0) {\r\n var last = types[types.length - 1];\r\n if (last != XPathParser.AT\r\n && last != XPathParser.DOUBLECOLON\r\n && last != XPathParser.LEFTPARENTHESIS\r\n && last != XPathParser.LEFTBRACKET\r\n && last != XPathParser.AND\r\n && last != XPathParser.OR\r\n && last != XPathParser.MOD\r\n && last != XPathParser.DIV\r\n && last != XPathParser.MULTIPLYOPERATOR\r\n && last != XPathParser.SLASH\r\n && last != XPathParser.DOUBLESLASH\r\n && last != XPathParser.BAR\r\n && last != XPathParser.PLUS\r\n && last != XPathParser.MINUS\r\n && last != XPathParser.EQUALS\r\n && last != XPathParser.NOTEQUAL\r\n && last != XPathParser.LESSTHAN\r\n && last != XPathParser.LESSTHANOREQUAL\r\n && last != XPathParser.GREATERTHAN\r\n && last != XPathParser.GREATERTHANOREQUAL) {\r\n if (name == \"and\") {\r\n types.push(XPathParser.AND);\r\n values.push(name);\r\n continue;\r\n }\r\n if (name == \"or\") {\r\n types.push(XPathParser.OR);\r\n values.push(name);\r\n continue;\r\n }\r\n if (name == \"mod\") {\r\n types.push(XPathParser.MOD);\r\n values.push(name);\r\n continue;\r\n }\r\n if (name == \"div\") {\r\n types.push(XPathParser.DIV);\r\n values.push(name);\r\n continue;\r\n }\r\n }\r\n }\r\n if (c == ':') {\r\n if (s.charAt(pos) == '*') {\r\n types.push(XPathParser.NCNAMECOLONASTERISK);\r\n values.push(name + \":*\");\r\n pos++;\r\n c = s.charAt(pos++);\r\n continue;\r\n }\r\n if (s.charAt(pos) == '_' || Utilities.isLetter(s.charCodeAt(pos))) {\r\n name += ':';\r\n c = s.charAt(pos++);\r\n while (Utilities.isNCNameChar(c.charCodeAt(0))) {\r\n name += c;\r\n c = s.charAt(pos++);\r\n }\r\n if (c == '(') {\r\n types.push(XPathParser.FUNCTIONNAME);\r\n values.push(name);\r\n continue;\r\n }\r\n types.push(XPathParser.QNAME);\r\n values.push(name);\r\n continue;\r\n }\r\n if (s.charAt(pos) == ':') {\r\n types.push(XPathParser.AXISNAME);\r\n values.push(name);\r\n continue;\r\n }\r\n }\r\n if (c == '(') {\r\n if (name == \"comment\" || name == \"text\" || name == \"node\") {\r\n types.push(XPathParser.NODETYPE);\r\n values.push(name);\r\n continue;\r\n }\r\n if (name == \"processing-instruction\") {\r\n if (s.charAt(pos) == ')') {\r\n types.push(XPathParser.NODETYPE);\r\n } else {\r\n types.push(XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL);\r\n }\r\n values.push(name);\r\n continue;\r\n }\r\n types.push(XPathParser.FUNCTIONNAME);\r\n values.push(name);\r\n continue;\r\n }\r\n types.push(XPathParser.QNAME);\r\n values.push(name);\r\n continue;\r\n }\r\n\r\n throw new Error(\"Unexpected character \" + c);\r\n }\r\n types.push(1);\r\n values.push(\"[EOF]\");\r\n return [types, values];\r\n };\r\n\r\n XPathParser.SHIFT = 's';\r\n XPathParser.REDUCE = 'r';\r\n XPathParser.ACCEPT = 'a';\r\n\r\n XPathParser.prototype.parse = function (s) {\r\n if (!s) {\r\n throw new Error('XPath expression unspecified.');\r\n }\r\n if (typeof s !== 'string'){\r\n throw new Error('XPath expression must be a string.');\r\n }\r\n\r\n var types;\r\n var values;\r\n var res = this.tokenize(s);\r\n if (res == undefined) {\r\n return undefined;\r\n }\r\n types = res[0];\r\n values = res[1];\r\n var tokenPos = 0;\r\n var state = [];\r\n var tokenType = [];\r\n var tokenValue = [];\r\n var s;\r\n var a;\r\n var t;\r\n\r\n state.push(0);\r\n tokenType.push(1);\r\n tokenValue.push(\"_S\");\r\n\r\n a = types[tokenPos];\r\n t = values[tokenPos++];\r\n while (1) {\r\n s = state[state.length - 1];\r\n switch (XPathParser.actionTable[s].charAt(a - 1)) {\r\n case XPathParser.SHIFT:\r\n tokenType.push(-a);\r\n tokenValue.push(t);\r\n state.push(XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32);\r\n a = types[tokenPos];\r\n t = values[tokenPos++];\r\n break;\r\n case XPathParser.REDUCE:\r\n var num = XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][1];\r\n var rhs = [];\r\n for (var i = 0; i < num; i++) {\r\n tokenType.pop();\r\n rhs.unshift(tokenValue.pop());\r\n state.pop();\r\n }\r\n var s_ = state[state.length - 1];\r\n tokenType.push(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0]);\r\n if (this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32] == undefined) {\r\n tokenValue.push(rhs[0]);\r\n } else {\r\n tokenValue.push(this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32](rhs));\r\n }\r\n state.push(XPathParser.gotoTable[s_].charCodeAt(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0] - 2) - 33);\r\n break;\r\n case XPathParser.ACCEPT:\r\n return new XPath(tokenValue.pop());\r\n default:\r\n throw new Error(\"XPath parse error\");\r\n }\r\n }\r\n };\r\n\r\n // XPath /////////////////////////////////////////////////////////////////////\r\n\r\n XPath.prototype = new Object();\r\n XPath.prototype.constructor = XPath;\r\n XPath.superclass = Object.prototype;\r\n\r\n function XPath(e) {\r\n this.expression = e;\r\n }\r\n\r\n XPath.prototype.toString = function () {\r\n return this.expression.toString();\r\n };\r\n\r\n function setIfUnset(obj, prop, value) {\r\n if (!(prop in obj)) {\r\n obj[prop] = value;\r\n }\r\n }\r\n\r\n XPath.prototype.evaluate = function (c) {\r\n var node = c.expressionContextNode;\r\n\r\n if (!(isNil(node) || isNodeLike(node))) {\r\n throw new Error(\"Context node does not appear to be a valid DOM node.\");\r\n }\r\n\r\n c.contextNode = c.expressionContextNode;\r\n c.contextSize = 1;\r\n c.contextPosition = 1;\r\n\r\n // [2017-11-25] Removed usage of .implementation.hasFeature() since it does\r\n // not reliably detect HTML DOMs (always returns false in xmldom and true in browsers)\r\n if (c.isHtml) {\r\n setIfUnset(c, 'caseInsensitive', true);\r\n setIfUnset(c, 'allowAnyNamespaceForNoPrefix', true);\r\n }\r\n\r\n setIfUnset(c, 'caseInsensitive', false);\r\n\r\n return this.expression.evaluate(c);\r\n };\r\n\r\n XPath.XML_NAMESPACE_URI = \"http://www.w3.org/XML/1998/namespace\";\r\n XPath.XMLNS_NAMESPACE_URI = \"http://www.w3.org/2000/xmlns/\";\r\n\r\n // Expression ////////////////////////////////////////////////////////////////\r\n\r\n Expression.prototype = new Object();\r\n Expression.prototype.constructor = Expression;\r\n Expression.superclass = Object.prototype;\r\n\r\n function Expression() {\r\n }\r\n\r\n Expression.prototype.init = function () {\r\n };\r\n\r\n Expression.prototype.toString = function () {\r\n return \"\";\r\n };\r\n\r\n Expression.prototype.evaluate = function (c) {\r\n throw new Error(\"Could not evaluate expression.\");\r\n };\r\n\r\n // UnaryOperation ////////////////////////////////////////////////////////////\r\n\r\n UnaryOperation.prototype = new Expression();\r\n UnaryOperation.prototype.constructor = UnaryOperation;\r\n UnaryOperation.superclass = Expression.prototype;\r\n\r\n function UnaryOperation(rhs) {\r\n if (arguments.length > 0) {\r\n this.init(rhs);\r\n }\r\n }\r\n\r\n UnaryOperation.prototype.init = function (rhs) {\r\n this.rhs = rhs;\r\n };\r\n\r\n // UnaryMinusOperation ///////////////////////////////////////////////////////\r\n\r\n UnaryMinusOperation.prototype = new UnaryOperation();\r\n UnaryMinusOperation.prototype.constructor = UnaryMinusOperation;\r\n UnaryMinusOperation.superclass = UnaryOperation.prototype;\r\n\r\n function UnaryMinusOperation(rhs) {\r\n if (arguments.length > 0) {\r\n this.init(rhs);\r\n }\r\n }\r\n\r\n UnaryMinusOperation.prototype.init = function (rhs) {\r\n UnaryMinusOperation.superclass.init.call(this, rhs);\r\n };\r\n\r\n UnaryMinusOperation.prototype.evaluate = function (c) {\r\n return this.rhs.evaluate(c).number().negate();\r\n };\r\n\r\n UnaryMinusOperation.prototype.toString = function () {\r\n return \"-\" + this.rhs.toString();\r\n };\r\n\r\n // BinaryOperation ///////////////////////////////////////////////////////////\r\n\r\n BinaryOperation.prototype = new Expression();\r\n BinaryOperation.prototype.constructor = BinaryOperation;\r\n BinaryOperation.superclass = Expression.prototype;\r\n\r\n function BinaryOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n BinaryOperation.prototype.init = function (lhs, rhs) {\r\n this.lhs = lhs;\r\n this.rhs = rhs;\r\n };\r\n\r\n // OrOperation ///////////////////////////////////////////////////////////////\r\n\r\n OrOperation.prototype = new BinaryOperation();\r\n OrOperation.prototype.constructor = OrOperation;\r\n OrOperation.superclass = BinaryOperation.prototype;\r\n\r\n function OrOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n OrOperation.prototype.init = function (lhs, rhs) {\r\n OrOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n OrOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" or \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n OrOperation.prototype.evaluate = function (c) {\r\n var b = this.lhs.evaluate(c).bool();\r\n if (b.booleanValue()) {\r\n return b;\r\n }\r\n return this.rhs.evaluate(c).bool();\r\n };\r\n\r\n // AndOperation //////////////////////////////////////////////////////////////\r\n\r\n AndOperation.prototype = new BinaryOperation();\r\n AndOperation.prototype.constructor = AndOperation;\r\n AndOperation.superclass = BinaryOperation.prototype;\r\n\r\n function AndOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n AndOperation.prototype.init = function (lhs, rhs) {\r\n AndOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n AndOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" and \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n AndOperation.prototype.evaluate = function (c) {\r\n var b = this.lhs.evaluate(c).bool();\r\n if (!b.booleanValue()) {\r\n return b;\r\n }\r\n return this.rhs.evaluate(c).bool();\r\n };\r\n\r\n // EqualsOperation ///////////////////////////////////////////////////////////\r\n\r\n EqualsOperation.prototype = new BinaryOperation();\r\n EqualsOperation.prototype.constructor = EqualsOperation;\r\n EqualsOperation.superclass = BinaryOperation.prototype;\r\n\r\n function EqualsOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n EqualsOperation.prototype.init = function (lhs, rhs) {\r\n EqualsOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n EqualsOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" = \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n EqualsOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).equals(this.rhs.evaluate(c));\r\n };\r\n\r\n // NotEqualOperation /////////////////////////////////////////////////////////\r\n\r\n NotEqualOperation.prototype = new BinaryOperation();\r\n NotEqualOperation.prototype.constructor = NotEqualOperation;\r\n NotEqualOperation.superclass = BinaryOperation.prototype;\r\n\r\n function NotEqualOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n NotEqualOperation.prototype.init = function (lhs, rhs) {\r\n NotEqualOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n NotEqualOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" != \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n NotEqualOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).notequal(this.rhs.evaluate(c));\r\n };\r\n\r\n // LessThanOperation /////////////////////////////////////////////////////////\r\n\r\n LessThanOperation.prototype = new BinaryOperation();\r\n LessThanOperation.prototype.constructor = LessThanOperation;\r\n LessThanOperation.superclass = BinaryOperation.prototype;\r\n\r\n function LessThanOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n LessThanOperation.prototype.init = function (lhs, rhs) {\r\n LessThanOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n LessThanOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).lessthan(this.rhs.evaluate(c));\r\n };\r\n\r\n LessThanOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" < \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // GreaterThanOperation //////////////////////////////////////////////////////\r\n\r\n GreaterThanOperation.prototype = new BinaryOperation();\r\n GreaterThanOperation.prototype.constructor = GreaterThanOperation;\r\n GreaterThanOperation.superclass = BinaryOperation.prototype;\r\n\r\n function GreaterThanOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n GreaterThanOperation.prototype.init = function (lhs, rhs) {\r\n GreaterThanOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n GreaterThanOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).greaterthan(this.rhs.evaluate(c));\r\n };\r\n\r\n GreaterThanOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" > \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // LessThanOrEqualOperation //////////////////////////////////////////////////\r\n\r\n LessThanOrEqualOperation.prototype = new BinaryOperation();\r\n LessThanOrEqualOperation.prototype.constructor = LessThanOrEqualOperation;\r\n LessThanOrEqualOperation.superclass = BinaryOperation.prototype;\r\n\r\n function LessThanOrEqualOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n LessThanOrEqualOperation.prototype.init = function (lhs, rhs) {\r\n LessThanOrEqualOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n LessThanOrEqualOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).lessthanorequal(this.rhs.evaluate(c));\r\n };\r\n\r\n LessThanOrEqualOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" <= \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // GreaterThanOrEqualOperation ///////////////////////////////////////////////\r\n\r\n GreaterThanOrEqualOperation.prototype = new BinaryOperation();\r\n GreaterThanOrEqualOperation.prototype.constructor = GreaterThanOrEqualOperation;\r\n GreaterThanOrEqualOperation.superclass = BinaryOperation.prototype;\r\n\r\n function GreaterThanOrEqualOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n GreaterThanOrEqualOperation.prototype.init = function (lhs, rhs) {\r\n GreaterThanOrEqualOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n GreaterThanOrEqualOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).greaterthanorequal(this.rhs.evaluate(c));\r\n };\r\n\r\n GreaterThanOrEqualOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" >= \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // PlusOperation /////////////////////////////////////////////////////////////\r\n\r\n PlusOperation.prototype = new BinaryOperation();\r\n PlusOperation.prototype.constructor = PlusOperation;\r\n PlusOperation.superclass = BinaryOperation.prototype;\r\n\r\n function PlusOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n PlusOperation.prototype.init = function (lhs, rhs) {\r\n PlusOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n PlusOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).number().plus(this.rhs.evaluate(c).number());\r\n };\r\n\r\n PlusOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" + \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // MinusOperation ////////////////////////////////////////////////////////////\r\n\r\n MinusOperation.prototype = new BinaryOperation();\r\n MinusOperation.prototype.constructor = MinusOperation;\r\n MinusOperation.superclass = BinaryOperation.prototype;\r\n\r\n function MinusOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n MinusOperation.prototype.init = function (lhs, rhs) {\r\n MinusOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n MinusOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).number().minus(this.rhs.evaluate(c).number());\r\n };\r\n\r\n MinusOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" - \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // MultiplyOperation /////////////////////////////////////////////////////////\r\n\r\n MultiplyOperation.prototype = new BinaryOperation();\r\n MultiplyOperation.prototype.constructor = MultiplyOperation;\r\n MultiplyOperation.superclass = BinaryOperation.prototype;\r\n\r\n function MultiplyOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n MultiplyOperation.prototype.init = function (lhs, rhs) {\r\n MultiplyOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n MultiplyOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).number().multiply(this.rhs.evaluate(c).number());\r\n };\r\n\r\n MultiplyOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" * \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // DivOperation //////////////////////////////////////////////////////////////\r\n\r\n DivOperation.prototype = new BinaryOperation();\r\n DivOperation.prototype.constructor = DivOperation;\r\n DivOperation.superclass = BinaryOperation.prototype;\r\n\r\n function DivOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n DivOperation.prototype.init = function (lhs, rhs) {\r\n DivOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n DivOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).number().div(this.rhs.evaluate(c).number());\r\n };\r\n\r\n DivOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" div \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // ModOperation //////////////////////////////////////////////////////////////\r\n\r\n ModOperation.prototype = new BinaryOperation();\r\n ModOperation.prototype.constructor = ModOperation;\r\n ModOperation.superclass = BinaryOperation.prototype;\r\n\r\n function ModOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n ModOperation.prototype.init = function (lhs, rhs) {\r\n ModOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n ModOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).number().mod(this.rhs.evaluate(c).number());\r\n };\r\n\r\n ModOperation.prototype.toString = function () {\r\n return \"(\" + this.lhs.toString() + \" mod \" + this.rhs.toString() + \")\";\r\n };\r\n\r\n // BarOperation //////////////////////////////////////////////////////////////\r\n\r\n BarOperation.prototype = new BinaryOperation();\r\n BarOperation.prototype.constructor = BarOperation;\r\n BarOperation.superclass = BinaryOperation.prototype;\r\n\r\n function BarOperation(lhs, rhs) {\r\n if (arguments.length > 0) {\r\n this.init(lhs, rhs);\r\n }\r\n }\r\n\r\n BarOperation.prototype.init = function (lhs, rhs) {\r\n BarOperation.superclass.init.call(this, lhs, rhs);\r\n };\r\n\r\n BarOperation.prototype.evaluate = function (c) {\r\n return this.lhs.evaluate(c).nodeset().union(this.rhs.evaluate(c).nodeset());\r\n };\r\n\r\n BarOperation.prototype.toString = function () {\r\n return map(toString, [this.lhs, this.rhs]).join(' | ');\r\n };\r\n\r\n // PathExpr //////////////////////////////////////////////////////////////////\r\n\r\n PathExpr.prototype = new Expression();\r\n PathExpr.prototype.constructor = PathExpr;\r\n PathExpr.superclass = Expression.prototype;\r\n\r\n function PathExpr(filter, filterPreds, locpath) {\r\n if (arguments.length > 0) {\r\n this.init(filter, filterPreds, locpath);\r\n }\r\n }\r\n\r\n PathExpr.prototype.init = function (filter, filterPreds, locpath) {\r\n PathExpr.superclass.init.call(this);\r\n this.filter = filter;\r\n this.filterPredicates = filterPreds;\r\n this.locationPath = locpath;\r\n };\r\n\r\n /**\r\n * Returns the topmost node of the tree containing node\r\n */\r\n function findRoot(node) {\r\n while (node && node.parentNode) {\r\n node = node.parentNode;\r\n }\r\n\r\n return node;\r\n }\r\n\r\n var applyPredicates = function (predicates, c, nodes, reverse) {\r\n if (predicates.length === 0) {\r\n return nodes;\r\n }\r\n\r\n var ctx = c.extend({});\r\n\r\n return reduce(\r\n function (inNodes, pred) {\r\n ctx.contextSize = inNodes.length;\r\n\r\n return filter(\r\n function (node, i) {\r\n ctx.contextNode = node;\r\n ctx.contextPosition = i + 1;\r\n\r\n return PathExpr.predicateMatches(pred, ctx);\r\n },\r\n inNodes\r\n );\r\n },\r\n sortNodes(nodes, reverse),\r\n predicates\r\n );\r\n };\r\n\r\n PathExpr.getRoot = function (xpc, nodes) {\r\n var firstNode = nodes[0];\r\n\r\n // xpc.virtualRoot could possibly provide a root even if firstNode is null,\r\n // so using a guard here instead of throwing.\r\n if (firstNode && firstNode.nodeType === NodeTypes.DOCUMENT_NODE) {\r\n return firstNode;\r\n }\r\n\r\n if (xpc.virtualRoot) {\r\n return xpc.virtualRoot;\r\n }\r\n\r\n if (!firstNode) {\r\n throw new Error('Context node not found when determining document root.');\r\n }\r\n\r\n var ownerDoc = firstNode.ownerDocument;\r\n\r\n if (ownerDoc) {\r\n return ownerDoc;\r\n }\r\n\r\n // IE 5.5 doesn't have ownerDocument?\r\n var n = firstNode;\r\n while (n.parentNode != null) {\r\n n = n.parentNode;\r\n }\r\n return n;\r\n }\r\n\r\n var getPrefixForNamespaceNode = function (attrNode) {\r\n var nm = String(attrNode.name);\r\n\r\n if (nm === \"xmlns\") {\r\n return \"\";\r\n }\r\n\r\n if (nm.substring(0, 6) === \"xmlns:\") {\r\n return nm.substring(6, nm.length);\r\n }\r\n\r\n return null;\r\n };\r\n\r\n PathExpr.applyStep = function (step, xpc, node) {\r\n if (!node) {\r\n throw new Error('Context node not found when evaluating XPath step: ' + step);\r\n }\r\n\r\n var newNodes = [];\r\n xpc.contextNode = node;\r\n\r\n switch (step.axis) {\r\n case Step.ANCESTOR:\r\n // look at all the ancestor nodes\r\n if (xpc.contextNode === xpc.virtualRoot) {\r\n break;\r\n }\r\n var m;\r\n if (xpc.contextNode.nodeType == NodeTypes.ATTRIBUTE_NODE) {\r\n m = PathExpr.getOwnerElement(xpc.contextNode);\r\n } else {\r\n m = xpc.contextNode.parentNode;\r\n }\r\n while (m != null) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n if (m === xpc.virtualRoot) {\r\n break;\r\n }\r\n m = m.parentNode;\r\n }\r\n break;\r\n\r\n case Step.ANCESTORORSELF:\r\n // look at all the ancestor nodes and the current node\r\n for (var m = xpc.contextNode; m != null; m = m.nodeType == NodeTypes.ATTRIBUTE_NODE ? PathExpr.getOwnerElement(m) : m.parentNode) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n if (m === xpc.virtualRoot) {\r\n break;\r\n }\r\n }\r\n break;\r\n\r\n case Step.ATTRIBUTE:\r\n // look at the attributes\r\n var nnm = xpc.contextNode.attributes;\r\n if (nnm != null) {\r\n for (var k = 0; k < nnm.length; k++) {\r\n var m = nnm.item(k);\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case Step.CHILD:\r\n // look at all child elements\r\n for (var m = xpc.contextNode.firstChild; m != null; m = m.nextSibling) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n }\r\n break;\r\n\r\n case Step.DESCENDANT:\r\n // look at all descendant nodes\r\n var st = [xpc.contextNode.firstChild];\r\n while (st.length > 0) {\r\n for (var m = st.pop(); m != null;) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n if (m.firstChild != null) {\r\n st.push(m.nextSibling);\r\n m = m.firstChild;\r\n } else {\r\n m = m.nextSibling;\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case Step.DESCENDANTORSELF:\r\n // look at self\r\n if (step.nodeTest.matches(xpc.contextNode, xpc)) {\r\n newNodes.push(xpc.contextNode);\r\n }\r\n // look at all descendant nodes\r\n var st = [xpc.contextNode.firstChild];\r\n while (st.length > 0) {\r\n for (var m = st.pop(); m != null;) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n if (m.firstChild != null) {\r\n st.push(m.nextSibling);\r\n m = m.firstChild;\r\n } else {\r\n m = m.nextSibling;\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case Step.FOLLOWING:\r\n if (xpc.contextNode === xpc.virtualRoot) {\r\n break;\r\n }\r\n var st = [];\r\n if (xpc.contextNode.firstChild != null) {\r\n st.unshift(xpc.contextNode.firstChild);\r\n } else {\r\n st.unshift(xpc.contextNode.nextSibling);\r\n }\r\n for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != NodeTypes.DOCUMENT_NODE && m !== xpc.virtualRoot; m = m.parentNode) {\r\n st.unshift(m.nextSibling);\r\n }\r\n do {\r\n for (var m = st.pop(); m != null;) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n if (m.firstChild != null) {\r\n st.push(m.nextSibling);\r\n m = m.firstChild;\r\n } else {\r\n m = m.nextSibling;\r\n }\r\n }\r\n } while (st.length > 0);\r\n break;\r\n\r\n case Step.FOLLOWINGSIBLING:\r\n if (xpc.contextNode === xpc.virtualRoot) {\r\n break;\r\n }\r\n for (var m = xpc.contextNode.nextSibling; m != null; m = m.nextSibling) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n }\r\n break;\r\n\r\n case Step.NAMESPACE:\r\n var nodes = {};\r\n\r\n if (xpc.contextNode.nodeType == NodeTypes.ELEMENT_NODE) {\r\n // BUG: This only collects the namespaces on the current node, but seemingly\r\n // it should collect all those in scope\r\n nodes[\"xml\"] = new XPathNamespace(\"xml\", null, XPath.XML_NAMESPACE_URI, xpc.contextNode);\r\n\r\n for (var m = xpc.contextNode; m != null && m.nodeType == NodeTypes.ELEMENT_NODE; m = m.parentNode) {\r\n for (var k = 0; k < m.attributes.length; k++) {\r\n var attr = m.attributes.item(k);\r\n\r\n var pre = getPrefixForNamespaceNode(attr);\r\n\r\n if (pre != null && nodes[pre] == undefined) {\r\n nodes[pre] = new XPathNamespace(pre, attr, attr.value, xpc.contextNode);\r\n }\r\n }\r\n }\r\n\r\n for (var pre in nodes) {\r\n var node = nodes[pre];\r\n\r\n if (step.nodeTest.matches(node, xpc)) {\r\n newNodes.push(node);\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case Step.PARENT:\r\n m = null;\r\n if (xpc.contextNode !== xpc.virtualRoot) {\r\n if (xpc.contextNode.nodeType == NodeTypes.ATTRIBUTE_NODE) {\r\n m = PathExpr.getOwnerElement(xpc.contextNode);\r\n } else {\r\n m = xpc.contextNode.parentNode;\r\n }\r\n }\r\n if (m != null && step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n break;\r\n\r\n case Step.PRECEDING:\r\n var st;\r\n if (xpc.virtualRoot != null) {\r\n st = [xpc.virtualRoot];\r\n } else {\r\n // cannot rely on .ownerDocument because the node may be in a document fragment\r\n st = [findRoot(xpc.contextNode)];\r\n }\r\n outer: while (st.length > 0) {\r\n for (var m = st.pop(); m != null;) {\r\n if (m == xpc.contextNode) {\r\n break outer;\r\n }\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.unshift(m);\r\n }\r\n if (m.firstChild != null) {\r\n st.push(m.nextSibling);\r\n m = m.firstChild;\r\n } else {\r\n m = m.nextSibling;\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case Step.PRECEDINGSIBLING:\r\n if (xpc.contextNode === xpc.virtualRoot) {\r\n break;\r\n }\r\n for (var m = xpc.contextNode.previousSibling; m != null; m = m.previousSibling) {\r\n if (step.nodeTest.matches(m, xpc)) {\r\n newNodes.push(m);\r\n }\r\n }\r\n break;\r\n\r\n case Step.SELF:\r\n if (step.nodeTest.matches(xpc.contextNode, xpc)) {\r\n newNodes.push(xpc.contextNode);\r\n }\r\n break;\r\n\r\n default:\r\n }\r\n\r\n return newNodes;\r\n };\r\n\r\n function applyStepWithPredicates(step, xpc, node) {\r\n return applyPredicates(\r\n step.predicates,\r\n xpc,\r\n PathExpr.applyStep(step, xpc, node),\r\n includes(REVERSE_AXES, step.axis)\r\n );\r\n }\r\n\r\n function applyStepToNodes(context, nodes, step) {\r\n return flatten(\r\n map(\r\n applyStepWithPredicates.bind(null, step, context),\r\n nodes\r\n )\r\n );\r\n }\r\n\r\n PathExpr.applySteps = function (steps, xpc, nodes) {\r\n return reduce(\r\n applyStepToNodes.bind(null, xpc),\r\n nodes,\r\n steps\r\n );\r\n }\r\n\r\n PathExpr.prototype.applyFilter = function (c, xpc) {\r\n if (!this.filter) {\r\n return { nodes: [c.contextNode] };\r\n }\r\n\r\n var ns = this.filter.evaluate(c);\r\n\r\n if (!Utilities.instance_of(ns, XNodeSet)) {\r\n if (this.filterPredicates != null && this.filterPredicates.length > 0 || this.locationPath != null) {\r\n throw new Error(\"Path expression filter must evaluate to a nodeset if predicates or location path are used\");\r\n }\r\n\r\n return { nonNodes: ns };\r\n }\r\n\r\n return {\r\n nodes: applyPredicates(\r\n this.filterPredicates || [],\r\n xpc,\r\n ns.toUnsortedArray(),\r\n false // reverse\r\n )\r\n };\r\n };\r\n\r\n PathExpr.applyLocationPath = function (locationPath, xpc, nodes) {\r\n if (!locationPath) {\r\n return nodes;\r\n }\r\n\r\n var startNodes = locationPath.absolute ? [PathExpr.getRoot(xpc, nodes)] : nodes;\r\n\r\n return PathExpr.applySteps(locationPath.steps, xpc, startNodes);\r\n };\r\n\r\n PathExpr.prototype.evaluate = function (c) {\r\n var xpc = assign(new XPathContext(), c);\r\n\r\n var filterResult = this.applyFilter(c, xpc);\r\n\r\n if ('nonNodes' in filterResult) {\r\n return filterResult.nonNodes;\r\n }\r\n\r\n var ns = new XNodeSet();\r\n ns.addArray(PathExpr.applyLocationPath(this.locationPath, xpc, filterResult.nodes));\r\n return ns;\r\n };\r\n\r\n PathExpr.predicateMatches = function (pred, c) {\r\n var res = pred.evaluate(c);\r\n\r\n return Utilities.instance_of(res, XNumber)\r\n ? c.contextPosition === res.numberValue()\r\n : res.booleanValue();\r\n };\r\n\r\n PathExpr.predicateString = function (predicate) {\r\n return wrap('[', ']', predicate.toString());\r\n }\r\n\r\n PathExpr.predicatesString = function (predicates) {\r\n return join(\r\n '',\r\n map(PathExpr.predicateString, predicates)\r\n );\r\n }\r\n\r\n PathExpr.prototype.toString = function () {\r\n if (this.filter != undefined) {\r\n var filterStr = toString(this.filter);\r\n\r\n if (Utilities.instance_of(this.filter, XString)) {\r\n return wrap(\"'\", \"'\", filterStr);\r\n }\r\n if (this.filterPredicates != undefined && this.filterPredicates.length) {\r\n return wrap('(', ')', filterStr) +\r\n PathExpr.predicatesString(this.filterPredicates);\r\n }\r\n if (this.locationPath != undefined) {\r\n return filterStr +\r\n (this.locationPath.absolute ? '' : '/') +\r\n toString(this.locationPath);\r\n }\r\n\r\n return filterStr;\r\n }\r\n\r\n return toString(this.locationPath);\r\n };\r\n\r\n PathExpr.getOwnerElement = function (n) {\r\n // DOM 2 has ownerElement\r\n if (n.ownerElement) {\r\n return n.ownerElement;\r\n }\r\n // DOM 1 Internet Explorer can use selectSingleNode (ironically)\r\n try {\r\n if (n.selectSingleNode) {\r\n return n.selectSingleNode(\"..\");\r\n }\r\n } catch (e) {\r\n }\r\n // Other DOM 1 implementations must use this egregious search\r\n var doc = n.nodeType == NodeTypes.DOCUMENT_NODE\r\n ? n\r\n : n.ownerDocument;\r\n var elts = doc.getElementsByTagName(\"*\");\r\n for (var i = 0; i < elts.length; i++) {\r\n var elt = elts.item(i);\r\n var nnm = elt.attributes;\r\n for (var j = 0; j < nnm.length; j++) {\r\n var an = nnm.item(j);\r\n if (an === n) {\r\n return elt;\r\n }\r\n }\r\n }\r\n return null;\r\n };\r\n\r\n // LocationPath //////////////////////////////////////////////////////////////\r\n\r\n LocationPath.prototype = new Object();\r\n LocationPath.prototype.constructor = LocationPath;\r\n LocationPath.superclass = Object.prototype;\r\n\r\n function LocationPath(abs, steps) {\r\n if (arguments.length > 0) {\r\n this.init(abs, steps);\r\n }\r\n }\r\n\r\n LocationPath.prototype.init = function (abs, steps) {\r\n this.absolute = abs;\r\n this.steps = steps;\r\n };\r\n\r\n LocationPath.prototype.toString = function () {\r\n return (\r\n (this.absolute ? '/' : '') +\r\n map(toString, this.steps).join('/')\r\n );\r\n };\r\n\r\n // Step //////////////////////////////////////////////////////////////////////\r\n\r\n Step.prototype = new Object();\r\n Step.prototype.constructor = Step;\r\n Step.superclass = Object.prototype;\r\n\r\n function Step(axis, nodetest, preds) {\r\n if (arguments.length > 0) {\r\n this.init(axis, nodetest, preds);\r\n }\r\n }\r\n\r\n Step.prototype.init = function (axis, nodetest, preds) {\r\n this.axis = axis;\r\n this.nodeTest = nodetest;\r\n this.predicates = preds;\r\n };\r\n\r\n Step.prototype.toString = function () {\r\n return Step.STEPNAMES[this.axis] +\r\n \"::\" +\r\n this.nodeTest.toString() +\r\n PathExpr.predicatesString(this.predicates);\r\n };\r\n\r\n\r\n Step.ANCESTOR = 0;\r\n Step.ANCESTORORSELF = 1;\r\n Step.ATTRIBUTE = 2;\r\n Step.CHILD = 3;\r\n Step.DESCENDANT = 4;\r\n Step.DESCENDANTORSELF = 5;\r\n Step.FOLLOWING = 6;\r\n Step.FOLLOWINGSIBLING = 7;\r\n Step.NAMESPACE = 8;\r\n Step.PARENT = 9;\r\n Step.PRECEDING = 10;\r\n Step.PRECEDINGSIBLING = 11;\r\n Step.SELF = 12;\r\n\r\n Step.STEPNAMES = reduce(function (acc, x) { return acc[x[0]] = x[1], acc; }, {}, [\r\n [Step.ANCESTOR, 'ancestor'],\r\n [Step.ANCESTORORSELF, 'ancestor-or-self'],\r\n [Step.ATTRIBUTE, 'attribute'],\r\n [Step.CHILD, 'child'],\r\n [Step.DESCENDANT, 'descendant'],\r\n [Step.DESCENDANTORSELF, 'descendant-or-self'],\r\n [Step.FOLLOWING, 'following'],\r\n [Step.FOLLOWINGSIBLING, 'following-sibling'],\r\n [Step.NAMESPACE, 'namespace'],\r\n [Step.PARENT, 'parent'],\r\n [Step.PRECEDING, 'preceding'],\r\n [Step.PRECEDINGSIBLING, 'preceding-sibling'],\r\n [Step.SELF, 'self']\r\n ]);\r\n\r\n var REVERSE_AXES = [\r\n Step.ANCESTOR,\r\n Step.ANCESTORORSELF,\r\n Step.PARENT,\r\n Step.PRECEDING,\r\n Step.PRECEDINGSIBLING\r\n ];\r\n\r\n // NodeTest //////////////////////////////////////////////////////////////////\r\n\r\n NodeTest.prototype = new Object();\r\n NodeTest.prototype.constructor = NodeTest;\r\n NodeTest.superclass = Object.prototype;\r\n\r\n function NodeTest(type, value) {\r\n if (arguments.length > 0) {\r\n this.init(type, value);\r\n }\r\n }\r\n\r\n NodeTest.prototype.init = function (type, value) {\r\n this.type = type;\r\n this.value = value;\r\n };\r\n\r\n NodeTest.prototype.toString = function () {\r\n return \"\";\r\n };\r\n\r\n NodeTest.prototype.matches = function (n, xpc) {\r\n console.warn('unknown node test type');\r\n };\r\n\r\n NodeTest.NAMETESTANY = 0;\r\n NodeTest.NAMETESTPREFIXANY = 1;\r\n NodeTest.NAMETESTQNAME = 2;\r\n NodeTest.COMMENT = 3;\r\n NodeTest.TEXT = 4;\r\n NodeTest.PI = 5;\r\n NodeTest.NODE = 6;\r\n\r\n NodeTest.isNodeType = function (types) {\r\n return function (node) {\r\n return includes(types, node.nodeType);\r\n };\r\n };\r\n\r\n NodeTest.makeNodeTestType = function (type, members, ctor) {\r\n var newType = ctor || function () { };\r\n\r\n newType.prototype = new NodeTest(type);\r\n newType.prototype.constructor = newType;\r\n\r\n assign(newType.prototype, members);\r\n\r\n return newType;\r\n };\r\n // create invariant node test for certain node types\r\n NodeTest.makeNodeTypeTest = function (type, nodeTypes, stringVal) {\r\n return new (NodeTest.makeNodeTestType(type, {\r\n matches: NodeTest.isNodeType(nodeTypes),\r\n toString: always(stringVal)\r\n }))();\r\n };\r\n\r\n NodeTest.hasPrefix = function (node) {\r\n return node.prefix || (node.nodeName || node.tagName).indexOf(':') !== -1;\r\n };\r\n\r\n NodeTest.isElementOrAttribute = NodeTest.isNodeType([1, 2]);\r\n NodeTest.nameSpaceMatches = function (prefix, xpc, n) {\r\n var nNamespace = (n.namespaceURI || '');\r\n\r\n if (!prefix) {\r\n return !nNamespace || (xpc.allowAnyNamespaceForNoPrefix && !NodeTest.hasPrefix(n));\r\n }\r\n\r\n var ns = xpc.namespaceResolver.getNamespace(prefix, xpc.expressionContextNode);\r\n\r\n if (ns == null) {\r\n throw new Error(\"Cannot resolve QName \" + prefix);\r\n }\r\n\r\n return ns === nNamespace;\r\n };\r\n NodeTest.localNameMatches = function (localName, xpc, n) {\r\n var nLocalName = (n.localName || n.nodeName);\r\n\r\n return xpc.caseInsensitive\r\n ? localName.toLowerCase() === nLocalName.toLowerCase()\r\n : localName === nLocalName;\r\n };\r\n\r\n NodeTest.NameTestPrefixAny = NodeTest.makeNodeTestType(\r\n NodeTest.NAMETESTPREFIXANY,\r\n {\r\n matches: function (n, xpc) {\r\n return NodeTest.isElementOrAttribute(n) &&\r\n NodeTest.nameSpaceMatches(this.prefix, xpc, n);\r\n },\r\n toString: function () {\r\n return this.prefix + \":*\";\r\n }\r\n },\r\n function NameTestPrefixAny(prefix) { this.prefix = prefix; }\r\n );\r\n\r\n NodeTest.NameTestQName = NodeTest.makeNodeTestType(\r\n NodeTest.NAMETESTQNAME,\r\n {\r\n matches: function (n, xpc) {\r\n return NodeTest.isNodeType(\r\n [\r\n NodeTypes.ELEMENT_NODE,\r\n NodeTypes.ATTRIBUTE_NODE,\r\n NodeTypes.NAMESPACE_NODE,\r\n ]\r\n )(n) &&\r\n NodeTest.nameSpaceMatches(this.prefix, xpc, n) &&\r\n NodeTest.localNameMatches(this.localName, xpc, n);\r\n },\r\n toString: function () {\r\n return this.name;\r\n }\r\n },\r\n function NameTestQName(name) {\r\n var nameParts = name.split(':');\r\n\r\n this.name = name;\r\n this.prefix = nameParts.length > 1 ? nameParts[0] : null;\r\n this.localName = nameParts[nameParts.length > 1 ? 1 : 0];\r\n }\r\n );\r\n\r\n NodeTest.PITest = NodeTest.makeNodeTestType(NodeTest.PI, {\r\n matches: function (n, xpc) {\r\n return NodeTest.isNodeType(\r\n [NodeTypes.PROCESSING_INSTRUCTION_NODE]\r\n )(n) &&\r\n (n.target || n.nodeName) === this.name;\r\n },\r\n toString: function () {\r\n return wrap('processing-instruction(\"', '\")', this.name);\r\n }\r\n }, function (name) { this.name = name; })\r\n\r\n // singletons\r\n\r\n // elements, attributes, namespaces\r\n NodeTest.nameTestAny = NodeTest.makeNodeTypeTest(\r\n NodeTest.NAMETESTANY,\r\n [\r\n NodeTypes.ELEMENT_NODE,\r\n NodeTypes.ATTRIBUTE_NODE,\r\n NodeTypes.NAMESPACE_NODE,\r\n ],\r\n '*'\r\n );\r\n // text, cdata\r\n NodeTest.textTest = NodeTest.makeNodeTypeTest(\r\n NodeTest.TEXT,\r\n [\r\n NodeTypes.TEXT_NODE,\r\n NodeTypes.CDATA_SECTION_NODE,\r\n ],\r\n 'text()'\r\n );\r\n NodeTest.commentTest = NodeTest.makeNodeTypeTest(\r\n NodeTest.COMMENT,\r\n [NodeTypes.COMMENT_NODE],\r\n 'comment()'\r\n );\r\n // elements, attributes, text, cdata, PIs, comments, document nodes\r\n NodeTest.nodeTest = NodeTest.makeNodeTypeTest(\r\n NodeTest.NODE,\r\n [\r\n NodeTypes.ELEMENT_NODE,\r\n NodeTypes.ATTRIBUTE_NODE,\r\n NodeTypes.TEXT_NODE,\r\n NodeTypes.CDATA_SECTION_NODE,\r\n NodeTypes.PROCESSING_INSTRUCTION_NODE,\r\n NodeTypes.COMMENT_NODE,\r\n NodeTypes.DOCUMENT_NODE,\r\n ],\r\n 'node()'\r\n );\r\n NodeTest.anyPiTest = NodeTest.makeNodeTypeTest(\r\n NodeTest.PI,\r\n [NodeTypes.PROCESSING_INSTRUCTION_NODE],\r\n 'processing-instruction()'\r\n );\r\n\r\n // VariableReference /////////////////////////////////////////////////////////\r\n\r\n VariableReference.prototype = new Expression();\r\n VariableReference.prototype.constructor = VariableReference;\r\n VariableReference.superclass = Expression.prototype;\r\n\r\n function VariableReference(v) {\r\n if (arguments.length > 0) {\r\n this.init(v);\r\n }\r\n }\r\n\r\n VariableReference.prototype.init = function (v) {\r\n this.variable = v;\r\n };\r\n\r\n VariableReference.prototype.toString = function () {\r\n return \"$\" + this.variable;\r\n };\r\n\r\n VariableReference.prototype.evaluate = function (c) {\r\n var parts = Utilities.resolveQName(this.variable, c.namespaceResolver, c.contextNode, false);\r\n\r\n if (parts[0] == null) {\r\n throw new Error(\"Cannot resolve QName \" + fn);\r\n }\r\n var result = c.variableResolver.getVariable(parts[1], parts[0]);\r\n if (!result) {\r\n throw XPathException.fromMessage(\"Undeclared variable: \" + this.toString());\r\n }\r\n return result;\r\n };\r\n\r\n // FunctionCall //////////////////////////////////////////////////////////////\r\n\r\n FunctionCall.prototype = new Expression();\r\n FunctionCall.prototype.constructor = FunctionCall;\r\n FunctionCall.superclass = Expression.prototype;\r\n\r\n function FunctionCall(fn, args) {\r\n if (arguments.length > 0) {\r\n this.init(fn, args);\r\n }\r\n }\r\n\r\n FunctionCall.prototype.init = function (fn, args) {\r\n this.functionName = fn;\r\n this.arguments = args;\r\n };\r\n\r\n FunctionCall.prototype.toString = function () {\r\n var s = this.functionName + \"(\";\r\n for (var i = 0; i < this.arguments.length; i++) {\r\n if (i > 0) {\r\n s += \", \";\r\n }\r\n s += this.arguments[i].toString();\r\n }\r\n return s + \")\";\r\n };\r\n\r\n FunctionCall.prototype.evaluate = function (c) {\r\n var f = FunctionResolver.getFunctionFromContext(this.functionName, c);\r\n\r\n if (!f) {\r\n throw new Error(\"Unknown function \" + this.functionName);\r\n }\r\n\r\n var a = [c].concat(this.arguments);\r\n return f.apply(c.functionResolver.thisArg, a);\r\n };\r\n\r\n // Operators /////////////////////////////////////////////////////////////////\r\n\r\n var Operators = new Object();\r\n\r\n Operators.equals = function (l, r) {\r\n return l.equals(r);\r\n };\r\n\r\n Operators.notequal = function (l, r) {\r\n return l.notequal(r);\r\n };\r\n\r\n Operators.lessthan = function (l, r) {\r\n return l.lessthan(r);\r\n };\r\n\r\n Operators.greaterthan = function (l, r) {\r\n return l.greaterthan(r);\r\n };\r\n\r\n Operators.lessthanorequal = function (l, r) {\r\n return l.lessthanorequal(r);\r\n };\r\n\r\n Operators.greaterthanorequal = function (l, r) {\r\n return l.greaterthanorequal(r);\r\n };\r\n\r\n // XString ///////////////////////////////////////////////////////////////////\r\n\r\n XString.prototype = new Expression();\r\n XString.prototype.constructor = XString;\r\n XString.superclass = Expression.prototype;\r\n\r\n function XString(s) {\r\n if (arguments.length > 0) {\r\n this.init(s);\r\n }\r\n }\r\n\r\n XString.prototype.init = function (s) {\r\n this.str = String(s);\r\n };\r\n\r\n XString.prototype.toString = function () {\r\n return this.str;\r\n };\r\n\r\n XString.prototype.evaluate = function (c) {\r\n return this;\r\n };\r\n\r\n XString.prototype.string = function () {\r\n return this;\r\n };\r\n\r\n XString.prototype.number = function () {\r\n return new XNumber(this.str);\r\n };\r\n\r\n XString.prototype.bool = function () {\r\n return new XBoolean(this.str);\r\n };\r\n\r\n XString.prototype.nodeset = function () {\r\n throw new Error(\"Cannot convert string to nodeset\");\r\n };\r\n\r\n XString.prototype.stringValue = function () {\r\n return this.str;\r\n };\r\n\r\n XString.prototype.numberValue = function () {\r\n return this.number().numberValue();\r\n };\r\n\r\n XString.prototype.booleanValue = function () {\r\n return this.bool().booleanValue();\r\n };\r\n\r\n XString.prototype.equals = function (r) {\r\n if (Utilities.instance_of(r, XBoolean)) {\r\n return this.bool().equals(r);\r\n }\r\n if (Utilities.instance_of(r, XNumber)) {\r\n return this.number().equals(r);\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithString(this, Operators.equals);\r\n }\r\n return new XBoolean(this.str == r.str);\r\n };\r\n\r\n XString.prototype.notequal = function (r) {\r\n if (Utilities.instance_of(r, XBoolean)) {\r\n return this.bool().notequal(r);\r\n }\r\n if (Utilities.instance_of(r, XNumber)) {\r\n return this.number().notequal(r);\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithString(this, Operators.notequal);\r\n }\r\n return new XBoolean(this.str != r.str);\r\n };\r\n\r\n XString.prototype.lessthan = function (r) {\r\n return this.number().lessthan(r);\r\n };\r\n\r\n XString.prototype.greaterthan = function (r) {\r\n return this.number().greaterthan(r);\r\n };\r\n\r\n XString.prototype.lessthanorequal = function (r) {\r\n return this.number().lessthanorequal(r);\r\n };\r\n\r\n XString.prototype.greaterthanorequal = function (r) {\r\n return this.number().greaterthanorequal(r);\r\n };\r\n\r\n // XNumber ///////////////////////////////////////////////////////////////////\r\n\r\n XNumber.prototype = new Expression();\r\n XNumber.prototype.constructor = XNumber;\r\n XNumber.superclass = Expression.prototype;\r\n\r\n function XNumber(n) {\r\n if (arguments.length > 0) {\r\n this.init(n);\r\n }\r\n }\r\n\r\n XNumber.prototype.init = function (n) {\r\n this.num = typeof n === \"string\" ? this.parse(n) : Number(n);\r\n };\r\n\r\n XNumber.prototype.numberFormat = /^\\s*-?[0-9]*\\.?[0-9]+\\s*$/;\r\n\r\n XNumber.prototype.parse = function (s) {\r\n // XPath representation of numbers is more restrictive than what Number() or parseFloat() allow\r\n return this.numberFormat.test(s) ? parseFloat(s) : Number.NaN;\r\n };\r\n\r\n function padSmallNumber(numberStr) {\r\n var parts = numberStr.split('e-');\r\n var base = parts[0].replace('.', '');\r\n var exponent = Number(parts[1]);\r\n\r\n for (var i = 0; i < exponent - 1; i += 1) {\r\n base = '0' + base;\r\n }\r\n\r\n return '0.' + base;\r\n }\r\n\r\n function padLargeNumber(numberStr) {\r\n var parts = numberStr.split('e');\r\n var base = parts[0].replace('.', '');\r\n var exponent = Number(parts[1]);\r\n var zerosToAppend = exponent + 1 - base.length;\r\n\r\n for (var i = 0; i < zerosToAppend; i += 1) {\r\n base += '0';\r\n }\r\n\r\n return base;\r\n }\r\n\r\n XNumber.prototype.toString = function () {\r\n var strValue = this.num.toString();\r\n\r\n if (strValue.indexOf('e-') !== -1) {\r\n return padSmallNumber(strValue);\r\n }\r\n\r\n if (strValue.indexOf('e') !== -1) {\r\n return padLargeNumber(strValue);\r\n }\r\n\r\n return strValue;\r\n };\r\n\r\n XNumber.prototype.evaluate = function (c) {\r\n return this;\r\n };\r\n\r\n XNumber.prototype.string = function () {\r\n\r\n\r\n return new XString(this.toString());\r\n };\r\n\r\n XNumber.prototype.number = function () {\r\n return this;\r\n };\r\n\r\n XNumber.prototype.bool = function () {\r\n return new XBoolean(this.num);\r\n };\r\n\r\n XNumber.prototype.nodeset = function () {\r\n throw new Error(\"Cannot convert number to nodeset\");\r\n };\r\n\r\n XNumber.prototype.stringValue = function () {\r\n return this.string().stringValue();\r\n };\r\n\r\n XNumber.prototype.numberValue = function () {\r\n return this.num;\r\n };\r\n\r\n XNumber.prototype.booleanValue = function () {\r\n return this.bool().booleanValue();\r\n };\r\n\r\n XNumber.prototype.negate = function () {\r\n return new XNumber(-this.num);\r\n };\r\n\r\n XNumber.prototype.equals = function (r) {\r\n if (Utilities.instance_of(r, XBoolean)) {\r\n return this.bool().equals(r);\r\n }\r\n if (Utilities.instance_of(r, XString)) {\r\n return this.equals(r.number());\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.equals);\r\n }\r\n return new XBoolean(this.num == r.num);\r\n };\r\n\r\n XNumber.prototype.notequal = function (r) {\r\n if (Utilities.instance_of(r, XBoolean)) {\r\n return this.bool().notequal(r);\r\n }\r\n if (Utilities.instance_of(r, XString)) {\r\n return this.notequal(r.number());\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.notequal);\r\n }\r\n return new XBoolean(this.num != r.num);\r\n };\r\n\r\n XNumber.prototype.lessthan = function (r) {\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.greaterthan);\r\n }\r\n if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {\r\n return this.lessthan(r.number());\r\n }\r\n return new XBoolean(this.num < r.num);\r\n };\r\n\r\n XNumber.prototype.greaterthan = function (r) {\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.lessthan);\r\n }\r\n if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {\r\n return this.greaterthan(r.number());\r\n }\r\n return new XBoolean(this.num > r.num);\r\n };\r\n\r\n XNumber.prototype.lessthanorequal = function (r) {\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.greaterthanorequal);\r\n }\r\n if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {\r\n return this.lessthanorequal(r.number());\r\n }\r\n return new XBoolean(this.num <= r.num);\r\n };\r\n\r\n XNumber.prototype.greaterthanorequal = function (r) {\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithNumber(this, Operators.lessthanorequal);\r\n }\r\n if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {\r\n return this.greaterthanorequal(r.number());\r\n }\r\n return new XBoolean(this.num >= r.num);\r\n };\r\n\r\n XNumber.prototype.plus = function (r) {\r\n return new XNumber(this.num + r.num);\r\n };\r\n\r\n XNumber.prototype.minus = function (r) {\r\n return new XNumber(this.num - r.num);\r\n };\r\n\r\n XNumber.prototype.multiply = function (r) {\r\n return new XNumber(this.num * r.num);\r\n };\r\n\r\n XNumber.prototype.div = function (r) {\r\n return new XNumber(this.num / r.num);\r\n };\r\n\r\n XNumber.prototype.mod = function (r) {\r\n return new XNumber(this.num % r.num);\r\n };\r\n\r\n // XBoolean //////////////////////////////////////////////////////////////////\r\n\r\n XBoolean.prototype = new Expression();\r\n XBoolean.prototype.constructor = XBoolean;\r\n XBoolean.superclass = Expression.prototype;\r\n\r\n function XBoolean(b) {\r\n if (arguments.length > 0) {\r\n this.init(b);\r\n }\r\n }\r\n\r\n XBoolean.prototype.init = function (b) {\r\n this.b = Boolean(b);\r\n };\r\n\r\n XBoolean.prototype.toString = function () {\r\n return this.b.toString();\r\n };\r\n\r\n XBoolean.prototype.evaluate = function (c) {\r\n return this;\r\n };\r\n\r\n XBoolean.prototype.string = function () {\r\n return new XString(this.b);\r\n };\r\n\r\n XBoolean.prototype.number = function () {\r\n return new XNumber(this.b);\r\n };\r\n\r\n XBoolean.prototype.bool = function () {\r\n return this;\r\n };\r\n\r\n XBoolean.prototype.nodeset = function () {\r\n throw new Error(\"Cannot convert boolean to nodeset\");\r\n };\r\n\r\n XBoolean.prototype.stringValue = function () {\r\n return this.string().stringValue();\r\n };\r\n\r\n XBoolean.prototype.numberValue = function () {\r\n return this.number().numberValue();\r\n };\r\n\r\n XBoolean.prototype.booleanValue = function () {\r\n return this.b;\r\n };\r\n\r\n XBoolean.prototype.not = function () {\r\n return new XBoolean(!this.b);\r\n };\r\n\r\n XBoolean.prototype.equals = function (r) {\r\n if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {\r\n return this.equals(r.bool());\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithBoolean(this, Operators.equals);\r\n }\r\n return new XBoolean(this.b == r.b);\r\n };\r\n\r\n XBoolean.prototype.notequal = function (r) {\r\n if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {\r\n return this.notequal(r.bool());\r\n }\r\n if (Utilities.instance_of(r, XNodeSet)) {\r\n return r.compareWithBoolean(this, Operators.notequal);\r\n }\r\n return new XBoolean(this.b != r.b);\r\n };\r\n\r\n XBoolean.prototype.lessthan = function (r) {\r\n return this.number().lessthan(r);\r\n };\r\n\r\n XBoolean.prototype.greaterthan = function (r) {\r\n return this.number().greaterthan(r);\r\n };\r\n\r\n XBoolean.prototype.lessthanorequal = function (r) {\r\n return this.number().lessthanorequal(r);\r\n };\r\n\r\n XBoolean.prototype.greaterthanorequal = function (r) {\r\n return this.number().greaterthanorequal(r);\r\n };\r\n\r\n XBoolean.true_ = new XBoolean(true);\r\n XBoolean.false_ = new XBoolean(false);\r\n\r\n // AVLTree ///////////////////////////////////////////////////////////////////\r\n\r\n AVLTree.prototype = new Object();\r\n AVLTree.prototype.constructor = AVLTree;\r\n AVLTree.superclass = Object.prototype;\r\n\r\n function AVLTree(n) {\r\n this.init(n);\r\n }\r\n\r\n AVLTree.prototype.init = function (n) {\r\n this.left = null;\r\n this.right = null;\r\n this.node = n;\r\n this.depth = 1;\r\n };\r\n\r\n AVLTree.prototype.balance = function () {\r\n var ldepth = this.left == null ? 0 : this.left.depth;\r\n var rdepth = this.right == null ? 0 : this.right.depth;\r\n\r\n if (ldepth > rdepth + 1) {\r\n // LR or LL rotation\r\n var lldepth = this.left.left == null ? 0 : this.left.left.depth;\r\n var lrdepth = this.left.right == null ? 0 : this.left.right.depth;\r\n\r\n if (lldepth < lrdepth) {\r\n // LR rotation consists of a RR rotation of the left child\r\n this.left.rotateRR();\r\n // plus a LL rotation of this node, which happens anyway\r\n }\r\n this.rotateLL();\r\n } else if (ldepth + 1 < rdepth) {\r\n // RR or RL rorarion\r\n var rrdepth = this.right.right == null ? 0 : this.right.right.depth;\r\n var rldepth = this.right.left == null ? 0 : this.right.left.depth;\r\n\r\n if (rldepth > rrdepth) {\r\n // RR rotation consists of a LL rotation of the right child\r\n this.right.rotateLL();\r\n // plus a RR rotation of this node, which happens anyway\r\n }\r\n this.rotateRR();\r\n }\r\n };\r\n\r\n AVLTree.prototype.rotateLL = function () {\r\n // the left side is too long => rotate from the left (_not_ leftwards)\r\n var nodeBefore = this.node;\r\n var rightBefore = this.right;\r\n this.node = this.left.node;\r\n this.right = this.left;\r\n this.left = this.left.left;\r\n this.right.left = this.right.right;\r\n this.right.right = rightBefore;\r\n this.right.node = nodeBefore;\r\n this.right.updateInNewLocation();\r\n this.updateInNewLocation();\r\n };\r\n\r\n AVLTree.prototype.rotateRR = function () {\r\n // the right side is too long => rotate from the right (_not_ rightwards)\r\n var nodeBefore = this.node;\r\n var leftBefore = this.left;\r\n this.node = this.right.node;\r\n this.left = this.right;\r\n this.right = this.right.right;\r\n this.left.right = this.left.left;\r\n this.left.left = leftBefore;\r\n this.left.node = nodeBefore;\r\n this.left.updateInNewLocation();\r\n this.updateInNewLocation();\r\n };\r\n\r\n AVLTree.prototype.updateInNewLocation = function () {\r\n this.getDepthFromChildren();\r\n };\r\n\r\n AVLTree.prototype.getDepthFromChildren = function () {\r\n this.depth = this.node == null ? 0 : 1;\r\n if (this.left != null) {\r\n this.depth = this.left.depth + 1;\r\n }\r\n if (this.right != null && this.depth <= this.right.depth) {\r\n this.depth = this.right.depth + 1;\r\n }\r\n };\r\n\r\n function nodeOrder(n1, n2) {\r\n if (n1 === n2) {\r\n return 0;\r\n }\r\n\r\n if (n1.compareDocumentPosition) {\r\n var cpos = n1.compareDocumentPosition(n2);\r\n\r\n if (cpos & 0x01) {\r\n // not in the same document; return an arbitrary result (is there a better way to do this)\r\n return 1;\r\n }\r\n if (cpos & 0x0A) {\r\n // n2 precedes or contains n1\r\n return 1;\r\n }\r\n if (cpos & 0x14) {\r\n // n2 follows or is contained by n1\r\n return -1;\r\n }\r\n\r\n return 0;\r\n }\r\n\r\n var d1 = 0,\r\n d2 = 0;\r\n for (var m1 = n1; m1 != null; m1 = m1.parentNode || m1.ownerElement) {\r\n d1++;\r\n }\r\n for (var m2 = n2; m2 != null; m2 = m2.parentNode || m2.ownerElement) {\r\n d2++;\r\n }\r\n\r\n // step up to same depth\r\n if (d1 > d2) {\r\n while (d1 > d2) {\r\n n1 = n1.parentNode || n1.ownerElement;\r\n d1--;\r\n }\r\n if (n1 === n2) {\r\n return 1;\r\n }\r\n } else if (d2 > d1) {\r\n while (d2 > d1) {\r\n n2 = n2.parentNode || n2.ownerElement;\r\n d2--;\r\n }\r\n if (n1 === n2) {\r\n return -1;\r\n }\r\n }\r\n\r\n var n1Par = n1.parentNode || n1.ownerElement,\r\n n2Par = n2.parentNode || n2.ownerElement;\r\n\r\n // find common parent\r\n while (n1Par !== n2Par) {\r\n n1 = n1Par;\r\n n2 = n2Par;\r\n n1Par = n1.parentNode || n1.ownerElement;\r\n n2Par = n2.parentNode || n2.ownerElement;\r\n }\r\n\r\n var n1isAttr = isAttributeLike(n1);\r\n var n2isAttr = isAttributeLike(n2);\r\n\r\n if (n1isAttr && !n2isAttr) {\r\n return -1;\r\n }\r\n if (!n1isAttr && n2isAttr) {\r\n return 1;\r\n }\r\n\r\n // xml namespace node comes before others. namespace nodes before non-namespace nodes\r\n if (n1.isXPathNamespace) {\r\n if (n1.nodeValue === XPath.XML_NAMESPACE_URI) {\r\n return -1;\r\n }\r\n\r\n if (!n2.isXPathNamespace) {\r\n return -1;\r\n }\r\n\r\n if (n2.nodeValue === XPath.XML_NAMESPACE_URI) {\r\n return 1;\r\n }\r\n } else if (n2.isXPathNamespace) {\r\n return 1;\r\n }\r\n\r\n if (n1Par) {\r\n var cn = n1isAttr ? n1Par.attributes : n1Par.childNodes;\r\n var len = cn.length;\r\n var n1Compare = n1.baseNode || n1;\r\n var n2Compare = n2.baseNode || n2;\r\n\r\n for (var i = 0; i < len; i += 1) {\r\n var n = cn[i];\r\n if (n === n1Compare) {\r\n return -1;\r\n }\r\n if (n === n2Compare) {\r\n return 1;\r\n }\r\n }\r\n }\r\n\r\n throw new Error('Unexpected: could not determine node order');\r\n }\r\n\r\n AVLTree.prototype.add = function (n) {\r\n if (n === this.node) {\r\n return false;\r\n }\r\n\r\n var o = nodeOrder(n, this.node);\r\n\r\n var ret = false;\r\n if (o == -1) {\r\n if (this.left == null) {\r\n this.left = new AVLTree(n);\r\n ret = true;\r\n } else {\r\n ret = this.left.add(n);\r\n if (ret) {\r\n this.balance();\r\n }\r\n }\r\n } else if (o == 1) {\r\n if (this.right == null) {\r\n this.right = new AVLTree(n);\r\n ret = true;\r\n } else {\r\n ret = this.right.add(n);\r\n if (ret) {\r\n this.balance();\r\n }\r\n }\r\n }\r\n\r\n if (ret) {\r\n this.getDepthFromChildren();\r\n }\r\n return ret;\r\n };\r\n\r\n // XNodeSet //////////////////////////////////////////////////////////////////\r\n\r\n XNodeSet.prototype = new Expression();\r\n XNodeSet.prototype.constructor = XNodeSet;\r\n XNodeSet.superclass = Expression.prototype;\r\n\r\n function XNodeSet() {\r\n this.init();\r\n }\r\n\r\n XNodeSet.prototype.init = function () {\r\n this.tree = null;\r\n this.nodes = [];\r\n this.size = 0;\r\n };\r\n\r\n XNodeSet.prototype.toString = function () {\r\n var p = this.first();\r\n if (p == null) {\r\n return \"\";\r\n }\r\n return this.stringForNode(p);\r\n };\r\n\r\n XNodeSet.prototype.evaluate = function (c) {\r\n return this;\r\n };\r\n\r\n XNodeSet.prototype.string = function () {\r\n return new XString(this.toString());\r\n };\r\n\r\n XNodeSet.prototype.stringValue = function () {\r\n return this.toString();\r\n };\r\n\r\n XNodeSet.prototype.number = function () {\r\n return new XNumber(this.string());\r\n };\r\n\r\n XNodeSet.prototype.numberValue = function () {\r\n return Number(this.string());\r\n };\r\n\r\n XNodeSet.prototype.bool = function () {\r\n return new XBoolean(this.booleanValue());\r\n };\r\n\r\n XNodeSet.prototype.booleanValue = function () {\r\n return !!this.size;\r\n };\r\n\r\n XNodeSet.prototype.nodeset = function () {\r\n return this;\r\n };\r\n\r\n XNodeSet.prototype.stringForNode = function (n) {\r\n if (n.nodeType == NodeTypes.DOCUMENT_NODE ||\r\n n.nodeType == NodeTypes.ELEMENT_NODE ||\r\n n.nodeType === NodeTypes.DOCUMENT_FRAGMENT_NODE) {\r\n return this.stringForContainerNode(n);\r\n }\r\n if (n.nodeType === NodeTypes.ATTRIBUTE_NODE) {\r\n return n.value || n.nodeValue;\r\n }\r\n if (n.isNamespaceNode) {\r\n return n.namespace;\r\n }\r\n return n.nodeValue;\r\n };\r\n\r\n XNodeSet.prototype.stringForContainerNode = function (n) {\r\n var s = \"\";\r\n for (var n2 = n.firstChild; n2 != null; n2 = n2.nextSibling) {\r\n var nt = n2.nodeType;\r\n // Element, Text, CDATA, Document, Document Fragment\r\n if (nt === 1 || nt === 3 || nt === 4 || nt === 9 || nt === 11) {\r\n s += this.stringForNode(n2);\r\n }\r\n }\r\n return s;\r\n };\r\n\r\n XNodeSet.prototype.buildTree = function () {\r\n if (!this.tree && this.nodes.length) {\r\n this.tree = new AVLTree(this.nodes[0]);\r\n for (var i = 1; i < this.nodes.length; i += 1) {\r\n this.tree.add(this.nodes[i]);\r\n }\r\n }\r\n\r\n return this.tree;\r\n };\r\n\r\n XNodeSet.prototype.first = function () {\r\n var p = this.buildTree();\r\n if (p == null) {\r\n return null;\r\n }\r\n while (p.left != null) {\r\n p = p.left;\r\n }\r\n return p.node;\r\n };\r\n\r\n XNodeSet.prototype.add = function (n) {\r\n for (var i = 0; i < this.nodes.length; i += 1) {\r\n if (n === this.nodes[i]) {\r\n return;\r\n }\r\n }\r\n\r\n this.tree = null;\r\n this.nodes.push(n);\r\n this.size += 1;\r\n };\r\n\r\n XNodeSet.prototype.addArray = function (ns) {\r\n var self = this;\r\n\r\n forEach(function (x) { self.add(x); }, ns);\r\n };\r\n\r\n /**\r\n * Returns an array of the node set's contents in document order\r\n */\r\n XNodeSet.prototype.toArray = function () {\r\n var a = [];\r\n this.toArrayRec(this.buildTree(), a);\r\n return a;\r\n };\r\n\r\n XNodeSet.prototype.toArrayRec = function (t, a) {\r\n if (t != null) {\r\n this.toArrayRec(t.left, a);\r\n a.push(t.node);\r\n this.toArrayRec(t.right, a);\r\n }\r\n };\r\n\r\n /**\r\n * Returns an array of the node set's contents in arbitrary order\r\n */\r\n XNodeSet.prototype.toUnsortedArray = function () {\r\n return this.nodes.slice();\r\n };\r\n\r\n XNodeSet.prototype.compareWithString = function (r, o) {\r\n var a = this.toUnsortedArray();\r\n for (var i = 0; i < a.length; i++) {\r\n var n = a[i];\r\n var l = new XString(this.stringForNode(n));\r\n var res = o(l, r);\r\n if (res.booleanValue()) {\r\n return res;\r\n }\r\n }\r\n return new XBoolean(false);\r\n };\r\n\r\n XNodeSet.prototype.compareWithNumber = function (r, o) {\r\n var a = this.toUnsortedArray();\r\n for (var i = 0; i < a.length; i++) {\r\n var n = a[i];\r\n var l = new XNumber(this.stringForNode(n));\r\n var res = o(l, r);\r\n if (res.booleanValue()) {\r\n return res;\r\n }\r\n }\r\n return new XBoolean(false);\r\n };\r\n\r\n XNodeSet.prototype.compareWithBoolean = function (r, o) {\r\n return o(this.bool(), r);\r\n };\r\n\r\n XNodeSet.prototype.compareWithNodeSet = function (r, o) {\r\n var arr = this.toUnsortedArray();\r\n var oInvert = function (lop, rop) { return o(rop, lop); };\r\n\r\n for (var i = 0; i < arr.length; i++) {\r\n var l = new XString(this.stringForNode(arr[i]));\r\n\r\n var res = r.compareWithString(l, oInvert);\r\n if (res.booleanValue()) {\r\n return res;\r\n }\r\n }\r\n\r\n return new XBoolean(false);\r\n };\r\n\r\n XNodeSet.compareWith = curry(function (o, r) {\r\n if (Utilities.instance_of(r, XString)) {\r\n return this.compareWithString(r, o);\r\n }\r\n if (Utilities.instance_of(r, XNumber)) {\r\n return this.compareWithNumber(r, o);\r\n }\r\n if (Utilities.instance_of(r, XBoolean)) {\r\n return this.compareWithBoolean(r, o);\r\n }\r\n return this.compareWithNodeSet(r, o);\r\n });\r\n\r\n XNodeSet.prototype.equals = XNodeSet.compareWith(Operators.equals);\r\n XNodeSet.prototype.notequal = XNodeSet.compareWith(Operators.notequal);\r\n XNodeSet.prototype.lessthan = XNodeSet.compareWith(Operators.lessthan);\r\n XNodeSet.prototype.greaterthan = XNodeSet.compareWith(Operators.greaterthan);\r\n XNodeSet.prototype.lessthanorequal = XNodeSet.compareWith(Operators.lessthanorequal);\r\n XNodeSet.prototype.greaterthanorequal = XNodeSet.compareWith(Operators.greaterthanorequal);\r\n\r\n XNodeSet.prototype.union = function (r) {\r\n var ns = new XNodeSet();\r\n ns.addArray(this.toUnsortedArray());\r\n ns.addArray(r.toUnsortedArray());\r\n return ns;\r\n };\r\n\r\n // XPathNamespace ////////////////////////////////////////////////////////////\r\n\r\n XPathNamespace.prototype = new Object();\r\n XPathNamespace.prototype.constructor = XPathNamespace;\r\n XPathNamespace.superclass = Object.prototype;\r\n\r\n function XPathNamespace(pre, node, uri, p) {\r\n this.isXPathNamespace = true;\r\n this.baseNode = node;\r\n this.ownerDocument = p.ownerDocument;\r\n this.nodeName = pre;\r\n this.prefix = pre;\r\n this.localName = pre;\r\n this.namespaceURI = null;\r\n this.nodeValue = uri;\r\n this.ownerElement = p;\r\n this.nodeType = NodeTypes.NAMESPACE_NODE;\r\n }\r\n\r\n XPathNamespace.prototype.toString = function () {\r\n return \"{ \\\"\" + this.prefix + \"\\\", \\\"\" + this.namespaceURI + \"\\\" }\";\r\n };\r\n\r\n // XPathContext //////////////////////////////////////////////////////////////\r\n\r\n XPathContext.prototype = new Object();\r\n XPathContext.prototype.constructor = XPathContext;\r\n XPathContext.superclass = Object.prototype;\r\n\r\n function XPathContext(vr, nr, fr) {\r\n this.variableResolver = vr != null ? vr : new VariableResolver();\r\n this.namespaceResolver = nr != null ? nr : new NamespaceResolver();\r\n this.functionResolver = fr != null ? fr : new FunctionResolver();\r\n }\r\n\r\n XPathContext.prototype.extend = function (newProps) {\r\n return assign(new XPathContext(), this, newProps);\r\n };\r\n\r\n // VariableResolver //////////////////////////////////////////////////////////\r\n\r\n VariableResolver.prototype = new Object();\r\n VariableResolver.prototype.constructor = VariableResolver;\r\n VariableResolver.superclass = Object.prototype;\r\n\r\n function VariableResolver() {\r\n }\r\n\r\n VariableResolver.prototype.getVariable = function (ln, ns) {\r\n return null;\r\n };\r\n\r\n // FunctionResolver //////////////////////////////////////////////////////////\r\n\r\n FunctionResolver.prototype = new Object();\r\n FunctionResolver.prototype.constructor = FunctionResolver;\r\n FunctionResolver.superclass = Object.prototype;\r\n\r\n function FunctionResolver(thisArg) {\r\n this.thisArg = thisArg != null ? thisArg : Functions;\r\n this.functions = new Object();\r\n this.addStandardFunctions();\r\n }\r\n\r\n FunctionResolver.prototype.addStandardFunctions = function () {\r\n this.functions[\"{}last\"] = Functions.last;\r\n this.functions[\"{}position\"] = Functions.position;\r\n this.functions[\"{}count\"] = Functions.count;\r\n this.functions[\"{}id\"] = Functions.id;\r\n this.functions[\"{}local-name\"] = Functions.localName;\r\n this.functions[\"{}namespace-uri\"] = Functions.namespaceURI;\r\n this.functions[\"{}name\"] = Functions.name;\r\n this.functions[\"{}string\"] = Functions.string;\r\n this.functions[\"{}concat\"] = Functions.concat;\r\n this.functions[\"{}starts-with\"] = Functions.startsWith;\r\n this.functions[\"{}contains\"] = Functions.contains;\r\n this.functions[\"{}substring-before\"] = Functions.substringBefore;\r\n this.functions[\"{}substring-after\"] = Functions.substringAfter;\r\n this.functions[\"{}substring\"] = Functions.substring;\r\n this.functions[\"{}string-length\"] = Functions.stringLength;\r\n this.functions[\"{}normalize-space\"] = Functions.normalizeSpace;\r\n this.functions[\"{}translate\"] = Functions.translate;\r\n this.functions[\"{}boolean\"] = Functions.boolean_;\r\n this.functions[\"{}not\"] = Functions.not;\r\n this.functions[\"{}true\"] = Functions.true_;\r\n this.functions[\"{}false\"] = Functions.false_;\r\n this.functions[\"{}lang\"] = Functions.lang;\r\n this.functions[\"{}number\"] = Functions.number;\r\n this.functions[\"{}sum\"] = Functions.sum;\r\n this.functions[\"{}floor\"] = Functions.floor;\r\n this.functions[\"{}ceiling\"] = Functions.ceiling;\r\n this.functions[\"{}round\"] = Functions.round;\r\n };\r\n\r\n FunctionResolver.prototype.addFunction = function (ns, ln, f) {\r\n this.functions[\"{\" + ns + \"}\" + ln] = f;\r\n };\r\n\r\n FunctionResolver.getFunctionFromContext = function (qName, context) {\r\n var parts = Utilities.resolveQName(qName, context.namespaceResolver, context.contextNode, false);\r\n\r\n if (parts[0] === null) {\r\n throw new Error(\"Cannot resolve QName \" + name);\r\n }\r\n\r\n return context.functionResolver.getFunction(parts[1], parts[0]);\r\n };\r\n\r\n FunctionResolver.prototype.getFunction = function (localName, namespace) {\r\n return this.functions[\"{\" + namespace + \"}\" + localName];\r\n };\r\n\r\n // NamespaceResolver /////////////////////////////////////////////////////////\r\n\r\n NamespaceResolver.prototype = new Object();\r\n NamespaceResolver.prototype.constructor = NamespaceResolver;\r\n NamespaceResolver.superclass = Object.prototype;\r\n\r\n function NamespaceResolver() {\r\n }\r\n\r\n NamespaceResolver.prototype.getNamespace = function (prefix, n) {\r\n if (prefix == \"xml\") {\r\n return XPath.XML_NAMESPACE_URI;\r\n } else if (prefix == \"xmlns\") {\r\n return XPath.XMLNS_NAMESPACE_URI;\r\n }\r\n if (n.nodeType == NodeTypes.DOCUMENT_NODE) {\r\n n = n.documentElement;\r\n } else if (n.nodeType == NodeTypes.ATTRIBUTE_NODE) {\r\n n = PathExpr.getOwnerElement(n);\r\n } else if (n.nodeType != NodeTypes.ELEMENT_NODE) {\r\n n = n.parentNode;\r\n }\r\n while (n != null && n.nodeType == NodeTypes.ELEMENT_NODE) {\r\n var nnm = n.attributes;\r\n for (var i = 0; i < nnm.length; i++) {\r\n var a = nnm.item(i);\r\n var aname = a.name || a.nodeName;\r\n if ((aname === \"xmlns\" && prefix === \"\")\r\n || aname === \"xmlns:\" + prefix) {\r\n return String(a.value || a.nodeValue);\r\n }\r\n }\r\n n = n.parentNode;\r\n }\r\n return null;\r\n };\r\n\r\n // Functions /////////////////////////////////////////////////////////////////\r\n\r\n var Functions = new Object();\r\n\r\n Functions.last = function (c) {\r\n if (arguments.length != 1) {\r\n throw new Error(\"Function last expects ()\");\r\n }\r\n\r\n return new XNumber(c.contextSize);\r\n };\r\n\r\n Functions.position = function (c) {\r\n if (arguments.length != 1) {\r\n throw new Error(\"Function position expects ()\");\r\n }\r\n\r\n return new XNumber(c.contextPosition);\r\n };\r\n\r\n Functions.count = function () {\r\n var c = arguments[0];\r\n var ns;\r\n if (arguments.length != 2 || !Utilities.instance_of(ns = arguments[1].evaluate(c), XNodeSet)) {\r\n throw new Error(\"Function count expects (node-set)\");\r\n }\r\n return new XNumber(ns.size);\r\n };\r\n\r\n Functions.id = function () {\r\n var c = arguments[0];\r\n var id;\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function id expects (object)\");\r\n }\r\n id = arguments[1].evaluate(c);\r\n if (Utilities.instance_of(id, XNodeSet)) {\r\n id = id.toArray().join(\" \");\r\n } else {\r\n id = id.stringValue();\r\n }\r\n var ids = id.split(/[\\x0d\\x0a\\x09\\x20]+/);\r\n var count = 0;\r\n var ns = new XNodeSet();\r\n var doc = c.contextNode.nodeType == NodeTypes.DOCUMENT_NODE\r\n ? c.contextNode\r\n : c.contextNode.ownerDocument;\r\n for (var i = 0; i < ids.length; i++) {\r\n var n;\r\n if (doc.getElementById) {\r\n n = doc.getElementById(ids[i]);\r\n } else {\r\n n = Utilities.getElementById(doc, ids[i]);\r\n }\r\n if (n != null) {\r\n ns.add(n);\r\n count++;\r\n }\r\n }\r\n return ns;\r\n };\r\n\r\n Functions.localName = function (c, eNode) {\r\n var n;\r\n\r\n if (arguments.length == 1) {\r\n n = c.contextNode;\r\n } else if (arguments.length == 2) {\r\n n = eNode.evaluate(c).first();\r\n } else {\r\n throw new Error(\"Function local-name expects (node-set?)\");\r\n }\r\n\r\n if (n == null) {\r\n return new XString(\"\");\r\n }\r\n\r\n return new XString(\r\n n.localName || // standard elements and attributes\r\n n.baseName || // IE\r\n n.target || // processing instructions\r\n n.nodeName || // DOM1 elements\r\n \"\" // fallback\r\n );\r\n };\r\n\r\n Functions.namespaceURI = function () {\r\n var c = arguments[0];\r\n var n;\r\n\r\n if (arguments.length == 1) {\r\n n = c.contextNode;\r\n } else if (arguments.length == 2) {\r\n n = arguments[1].evaluate(c).first();\r\n } else {\r\n throw new Error(\"Function namespace-uri expects (node-set?)\");\r\n }\r\n\r\n if (n == null) {\r\n return new XString(\"\");\r\n }\r\n return new XString(n.namespaceURI || '');\r\n };\r\n\r\n Functions.name = function () {\r\n var c = arguments[0];\r\n var n;\r\n if (arguments.length == 1) {\r\n n = c.contextNode;\r\n } else if (arguments.length == 2) {\r\n n = arguments[1].evaluate(c).first();\r\n } else {\r\n throw new Error(\"Function name expects (node-set?)\");\r\n }\r\n if (n == null) {\r\n return new XString(\"\");\r\n }\r\n if (n.nodeType == NodeTypes.ELEMENT_NODE) {\r\n return new XString(n.nodeName);\r\n } else if (n.nodeType == NodeTypes.ATTRIBUTE_NODE) {\r\n return new XString(n.name || n.nodeName);\r\n } else if (n.nodeType === NodeTypes.PROCESSING_INSTRUCTION_NODE) {\r\n return new XString(n.target || n.nodeName);\r\n } else if (n.localName == null) {\r\n return new XString(\"\");\r\n } else {\r\n return new XString(n.localName);\r\n }\r\n };\r\n\r\n Functions.string = function () {\r\n var c = arguments[0];\r\n if (arguments.length == 1) {\r\n return new XString(XNodeSet.prototype.stringForNode(c.contextNode));\r\n } else if (arguments.length == 2) {\r\n return arguments[1].evaluate(c).string();\r\n }\r\n throw new Error(\"Function string expects (object?)\");\r\n };\r\n\r\n Functions.concat = function (c) {\r\n if (arguments.length < 3) {\r\n throw new Error(\"Function concat expects (string, string[, string]*)\");\r\n }\r\n var s = \"\";\r\n for (var i = 1; i < arguments.length; i++) {\r\n s += arguments[i].evaluate(c).stringValue();\r\n }\r\n return new XString(s);\r\n };\r\n\r\n Functions.startsWith = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 3) {\r\n throw new Error(\"Function startsWith expects (string, string)\");\r\n }\r\n var s1 = arguments[1].evaluate(c).stringValue();\r\n var s2 = arguments[2].evaluate(c).stringValue();\r\n return new XBoolean(s1.substring(0, s2.length) == s2);\r\n };\r\n\r\n Functions.contains = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 3) {\r\n throw new Error(\"Function contains expects (string, string)\");\r\n }\r\n var s1 = arguments[1].evaluate(c).stringValue();\r\n var s2 = arguments[2].evaluate(c).stringValue();\r\n return new XBoolean(s1.indexOf(s2) !== -1);\r\n };\r\n\r\n Functions.substringBefore = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 3) {\r\n throw new Error(\"Function substring-before expects (string, string)\");\r\n }\r\n var s1 = arguments[1].evaluate(c).stringValue();\r\n var s2 = arguments[2].evaluate(c).stringValue();\r\n return new XString(s1.substring(0, s1.indexOf(s2)));\r\n };\r\n\r\n Functions.substringAfter = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 3) {\r\n throw new Error(\"Function substring-after expects (string, string)\");\r\n }\r\n var s1 = arguments[1].evaluate(c).stringValue();\r\n var s2 = arguments[2].evaluate(c).stringValue();\r\n if (s2.length == 0) {\r\n return new XString(s1);\r\n }\r\n var i = s1.indexOf(s2);\r\n if (i == -1) {\r\n return new XString(\"\");\r\n }\r\n return new XString(s1.substring(i + s2.length));\r\n };\r\n\r\n Functions.substring = function () {\r\n var c = arguments[0];\r\n if (!(arguments.length == 3 || arguments.length == 4)) {\r\n throw new Error(\"Function substring expects (string, number, number?)\");\r\n }\r\n var s = arguments[1].evaluate(c).stringValue();\r\n var n1 = Math.round(arguments[2].evaluate(c).numberValue()) - 1;\r\n var n2 = arguments.length == 4 ? n1 + Math.round(arguments[3].evaluate(c).numberValue()) : undefined;\r\n return new XString(s.substring(n1, n2));\r\n };\r\n\r\n Functions.stringLength = function () {\r\n var c = arguments[0];\r\n var s;\r\n if (arguments.length == 1) {\r\n s = XNodeSet.prototype.stringForNode(c.contextNode);\r\n } else if (arguments.length == 2) {\r\n s = arguments[1].evaluate(c).stringValue();\r\n } else {\r\n throw new Error(\"Function string-length expects (string?)\");\r\n }\r\n return new XNumber(s.length);\r\n };\r\n\r\n Functions.normalizeSpace = function () {\r\n var c = arguments[0];\r\n var s;\r\n if (arguments.length == 1) {\r\n s = XNodeSet.prototype.stringForNode(c.contextNode);\r\n } else if (arguments.length == 2) {\r\n s = arguments[1].evaluate(c).stringValue();\r\n } else {\r\n throw new Error(\"Function normalize-space expects (string?)\");\r\n }\r\n var i = 0;\r\n var j = s.length - 1;\r\n while (Utilities.isSpace(s.charCodeAt(j))) {\r\n j--;\r\n }\r\n var t = \"\";\r\n while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {\r\n i++;\r\n }\r\n while (i <= j) {\r\n if (Utilities.isSpace(s.charCodeAt(i))) {\r\n t += \" \";\r\n while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {\r\n i++;\r\n }\r\n } else {\r\n t += s.charAt(i);\r\n i++;\r\n }\r\n }\r\n return new XString(t);\r\n };\r\n\r\n Functions.translate = function (c, eValue, eFrom, eTo) {\r\n if (arguments.length != 4) {\r\n throw new Error(\"Function translate expects (string, string, string)\");\r\n }\r\n\r\n var value = eValue.evaluate(c).stringValue();\r\n var from = eFrom.evaluate(c).stringValue();\r\n var to = eTo.evaluate(c).stringValue();\r\n\r\n var cMap = reduce(function (acc, ch, i) {\r\n if (!(ch in acc)) {\r\n acc[ch] = i > to.length ? '' : to[i];\r\n }\r\n return acc;\r\n }, {}, from);\r\n\r\n var t = join(\r\n '',\r\n map(function (ch) {\r\n return ch in cMap ? cMap[ch] : ch;\r\n }, value)\r\n );\r\n\r\n return new XString(t);\r\n };\r\n\r\n Functions.boolean_ = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function boolean expects (object)\");\r\n }\r\n return arguments[1].evaluate(c).bool();\r\n };\r\n\r\n Functions.not = function (c, eValue) {\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function not expects (object)\");\r\n }\r\n return eValue.evaluate(c).bool().not();\r\n };\r\n\r\n Functions.true_ = function () {\r\n if (arguments.length != 1) {\r\n throw new Error(\"Function true expects ()\");\r\n }\r\n return XBoolean.true_;\r\n };\r\n\r\n Functions.false_ = function () {\r\n if (arguments.length != 1) {\r\n throw new Error(\"Function false expects ()\");\r\n }\r\n return XBoolean.false_;\r\n };\r\n\r\n Functions.lang = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function lang expects (string)\");\r\n }\r\n var lang;\r\n for (var n = c.contextNode; n != null && n.nodeType != NodeTypes.DOCUMENT_NODE; n = n.parentNode) {\r\n var a = n.getAttributeNS(XPath.XML_NAMESPACE_URI, \"lang\");\r\n if (a != null) {\r\n lang = String(a);\r\n break;\r\n }\r\n }\r\n if (lang == null) {\r\n return XBoolean.false_;\r\n }\r\n var s = arguments[1].evaluate(c).stringValue();\r\n return new XBoolean(lang.substring(0, s.length) == s\r\n && (lang.length == s.length || lang.charAt(s.length) == '-'));\r\n };\r\n\r\n Functions.number = function () {\r\n var c = arguments[0];\r\n if (!(arguments.length == 1 || arguments.length == 2)) {\r\n throw new Error(\"Function number expects (object?)\");\r\n }\r\n if (arguments.length == 1) {\r\n return new XNumber(XNodeSet.prototype.stringForNode(c.contextNode));\r\n }\r\n return arguments[1].evaluate(c).number();\r\n };\r\n\r\n Functions.sum = function () {\r\n var c = arguments[0];\r\n var ns;\r\n if (arguments.length != 2 || !Utilities.instance_of((ns = arguments[1].evaluate(c)), XNodeSet)) {\r\n throw new Error(\"Function sum expects (node-set)\");\r\n }\r\n ns = ns.toUnsortedArray();\r\n var n = 0;\r\n for (var i = 0; i < ns.length; i++) {\r\n n += new XNumber(XNodeSet.prototype.stringForNode(ns[i])).numberValue();\r\n }\r\n return new XNumber(n);\r\n };\r\n\r\n Functions.floor = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function floor expects (number)\");\r\n }\r\n return new XNumber(Math.floor(arguments[1].evaluate(c).numberValue()));\r\n };\r\n\r\n Functions.ceiling = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function ceiling expects (number)\");\r\n }\r\n return new XNumber(Math.ceil(arguments[1].evaluate(c).numberValue()));\r\n };\r\n\r\n Functions.round = function () {\r\n var c = arguments[0];\r\n if (arguments.length != 2) {\r\n throw new Error(\"Function round expects (number)\");\r\n }\r\n return new XNumber(Math.round(arguments[1].evaluate(c).numberValue()));\r\n };\r\n\r\n // Utilities /////////////////////////////////////////////////////////////////\r\n\r\n var Utilities = new Object();\r\n\r\n // Returns true if the node is an attribute node or namespace node\r\n var isAttributeLike = function (val) {\r\n return val && (\r\n val.nodeType === NodeTypes.ATTRIBUTE_NODE ||\r\n val.ownerElement ||\r\n val.isXPathNamespace\r\n );\r\n }\r\n\r\n Utilities.splitQName = function (qn) {\r\n var i = qn.indexOf(\":\");\r\n if (i == -1) {\r\n return [null, qn];\r\n }\r\n return [qn.substring(0, i), qn.substring(i + 1)];\r\n };\r\n\r\n Utilities.resolveQName = function (qn, nr, n, useDefault) {\r\n var parts = Utilities.splitQName(qn);\r\n if (parts[0] != null) {\r\n parts[0] = nr.getNamespace(parts[0], n);\r\n } else {\r\n if (useDefault) {\r\n parts[0] = nr.getNamespace(\"\", n);\r\n if (parts[0] == null) {\r\n parts[0] = \"\";\r\n }\r\n } else {\r\n parts[0] = \"\";\r\n }\r\n }\r\n return parts;\r\n };\r\n\r\n Utilities.isSpace = function (c) {\r\n return c == 0x9 || c == 0xd || c == 0xa || c == 0x20;\r\n };\r\n\r\n Utilities.isLetter = function (c) {\r\n return c >= 0x0041 && c <= 0x005A ||\r\n c >= 0x0061 && c <= 0x007A ||\r\n c >= 0x00C0 && c <= 0x00D6 ||\r\n c >= 0x00D8 && c <= 0x00F6 ||\r\n c >= 0x00F8 && c <= 0x00FF ||\r\n c >= 0x0100 && c <= 0x0131 ||\r\n c >= 0x0134 && c <= 0x013E ||\r\n c >= 0x0141 && c <= 0x0148 ||\r\n c >= 0x014A && c <= 0x017E ||\r\n c >= 0x0180 && c <= 0x01C3 ||\r\n c >= 0x01CD && c <= 0x01F0 ||\r\n c >= 0x01F4 && c <= 0x01F5 ||\r\n c >= 0x01FA && c <= 0x0217 ||\r\n c >= 0x0250 && c <= 0x02A8 ||\r\n c >= 0x02BB && c <= 0x02C1 ||\r\n c == 0x0386 ||\r\n c >= 0x0388 && c <= 0x038A ||\r\n c == 0x038C ||\r\n c >= 0x038E && c <= 0x03A1 ||\r\n c >= 0x03A3 && c <= 0x03CE ||\r\n c >= 0x03D0 && c <= 0x03D6 ||\r\n c == 0x03DA ||\r\n c == 0x03DC ||\r\n c == 0x03DE ||\r\n c == 0x03E0 ||\r\n c >= 0x03E2 && c <= 0x03F3 ||\r\n c >= 0x0401 && c <= 0x040C ||\r\n c >= 0x040E && c <= 0x044F ||\r\n c >= 0x0451 && c <= 0x045C ||\r\n c >= 0x045E && c <= 0x0481 ||\r\n c >= 0x0490 && c <= 0x04C4 ||\r\n c >= 0x04C7 && c <= 0x04C8 ||\r\n c >= 0x04CB && c <= 0x04CC ||\r\n c >= 0x04D0 && c <= 0x04EB ||\r\n c >= 0x04EE && c <= 0x04F5 ||\r\n c >= 0x04F8 && c <= 0x04F9 ||\r\n c >= 0x0531 && c <= 0x0556 ||\r\n c == 0x0559 ||\r\n c >= 0x0561 && c <= 0x0586 ||\r\n c >= 0x05D0 && c <= 0x05EA ||\r\n c >= 0x05F0 && c <= 0x05F2 ||\r\n c >= 0x0621 && c <= 0x063A ||\r\n c >= 0x0641 && c <= 0x064A ||\r\n c >= 0x0671 && c <= 0x06B7 ||\r\n c >= 0x06BA && c <= 0x06BE ||\r\n c >= 0x06C0 && c <= 0x06CE ||\r\n c >= 0x06D0 && c <= 0x06D3 ||\r\n c == 0x06D5 ||\r\n c >= 0x06E5 && c <= 0x06E6 ||\r\n c >= 0x0905 && c <= 0x0939 ||\r\n c == 0x093D ||\r\n c >= 0x0958 && c <= 0x0961 ||\r\n c >= 0x0985 && c <= 0x098C ||\r\n c >= 0x098F && c <= 0x0990 ||\r\n c >= 0x0993 && c <= 0x09A8 ||\r\n c >= 0x09AA && c <= 0x09B0 ||\r\n c == 0x09B2 ||\r\n c >= 0x09B6 && c <= 0x09B9 ||\r\n c >= 0x09DC && c <= 0x09DD ||\r\n c >= 0x09DF && c <= 0x09E1 ||\r\n c >= 0x09F0 && c <= 0x09F1 ||\r\n c >= 0x0A05 && c <= 0x0A0A ||\r\n c >= 0x0A0F && c <= 0x0A10 ||\r\n c >= 0x0A13 && c <= 0x0A28 ||\r\n c >= 0x0A2A && c <= 0x0A30 ||\r\n c >= 0x0A32 && c <= 0x0A33 ||\r\n c >= 0x0A35 && c <= 0x0A36 ||\r\n c >= 0x0A38 && c <= 0x0A39 ||\r\n c >= 0x0A59 && c <= 0x0A5C ||\r\n c == 0x0A5E ||\r\n c >= 0x0A72 && c <= 0x0A74 ||\r\n c >= 0x0A85 && c <= 0x0A8B ||\r\n c == 0x0A8D ||\r\n c >= 0x0A8F && c <= 0x0A91 ||\r\n c >= 0x0A93 && c <= 0x0AA8 ||\r\n c >= 0x0AAA && c <= 0x0AB0 ||\r\n c >= 0x0AB2 && c <= 0x0AB3 ||\r\n c >= 0x0AB5 && c <= 0x0AB9 ||\r\n c == 0x0ABD ||\r\n c == 0x0AE0 ||\r\n c >= 0x0B05 && c <= 0x0B0C ||\r\n c >= 0x0B0F && c <= 0x0B10 ||\r\n c >= 0x0B13 && c <= 0x0B28 ||\r\n c >= 0x0B2A && c <= 0x0B30 ||\r\n c >= 0x0B32 && c <= 0x0B33 ||\r\n c >= 0x0B36 && c <= 0x0B39 ||\r\n c == 0x0B3D ||\r\n c >= 0x0B5C && c <= 0x0B5D ||\r\n c >= 0x0B5F && c <= 0x0B61 ||\r\n c >= 0x0B85 && c <= 0x0B8A ||\r\n c >= 0x0B8E && c <= 0x0B90 ||\r\n c >= 0x0B92 && c <= 0x0B95 ||\r\n c >= 0x0B99 && c <= 0x0B9A ||\r\n c == 0x0B9C ||\r\n c >= 0x0B9E && c <= 0x0B9F ||\r\n c >= 0x0BA3 && c <= 0x0BA4 ||\r\n c >= 0x0BA8 && c <= 0x0BAA ||\r\n c >= 0x0BAE && c <= 0x0BB5 ||\r\n c >= 0x0BB7 && c <= 0x0BB9 ||\r\n c >= 0x0C05 && c <= 0x0C0C ||\r\n c >= 0x0C0E && c <= 0x0C10 ||\r\n c >= 0x0C12 && c <= 0x0C28 ||\r\n c >= 0x0C2A && c <= 0x0C33 ||\r\n c >= 0x0C35 && c <= 0x0C39 ||\r\n c >= 0x0C60 && c <= 0x0C61 ||\r\n c >= 0x0C85 && c <= 0x0C8C ||\r\n c >= 0x0C8E && c <= 0x0C90 ||\r\n c >= 0x0C92 && c <= 0x0CA8 ||\r\n c >= 0x0CAA && c <= 0x0CB3 ||\r\n c >= 0x0CB5 && c <= 0x0CB9 ||\r\n c == 0x0CDE ||\r\n c >= 0x0CE0 && c <= 0x0CE1 ||\r\n c >= 0x0D05 && c <= 0x0D0C ||\r\n c >= 0x0D0E && c <= 0x0D10 ||\r\n c >= 0x0D12 && c <= 0x0D28 ||\r\n c >= 0x0D2A && c <= 0x0D39 ||\r\n c >= 0x0D60 && c <= 0x0D61 ||\r\n c >= 0x0E01 && c <= 0x0E2E ||\r\n c == 0x0E30 ||\r\n c >= 0x0E32 && c <= 0x0E33 ||\r\n c >= 0x0E40 && c <= 0x0E45 ||\r\n c >= 0x0E81 && c <= 0x0E82 ||\r\n c == 0x0E84 ||\r\n c >= 0x0E87 && c <= 0x0E88 ||\r\n c == 0x0E8A ||\r\n c == 0x0E8D ||\r\n c >= 0x0E94 && c <= 0x0E97 ||\r\n c >= 0x0E99 && c <= 0x0E9F ||\r\n c >= 0x0EA1 && c <= 0x0EA3 ||\r\n c == 0x0EA5 ||\r\n c == 0x0EA7 ||\r\n c >= 0x0EAA && c <= 0x0EAB ||\r\n c >= 0x0EAD && c <= 0x0EAE ||\r\n c == 0x0EB0 ||\r\n c >= 0x0EB2 && c <= 0x0EB3 ||\r\n c == 0x0EBD ||\r\n c >= 0x0EC0 && c <= 0x0EC4 ||\r\n c >= 0x0F40 && c <= 0x0F47 ||\r\n c >= 0x0F49 && c <= 0x0F69 ||\r\n c >= 0x10A0 && c <= 0x10C5 ||\r\n c >= 0x10D0 && c <= 0x10F6 ||\r\n c == 0x1100 ||\r\n c >= 0x1102 && c <= 0x1103 ||\r\n c >= 0x1105 && c <= 0x1107 ||\r\n c == 0x1109 ||\r\n c >= 0x110B && c <= 0x110C ||\r\n c >= 0x110E && c <= 0x1112 ||\r\n c == 0x113C ||\r\n c == 0x113E ||\r\n c == 0x1140 ||\r\n c == 0x114C ||\r\n c == 0x114E ||\r\n c == 0x1150 ||\r\n c >= 0x1154 && c <= 0x1155 ||\r\n c == 0x1159 ||\r\n c >= 0x115F && c <= 0x1161 ||\r\n c == 0x1163 ||\r\n c == 0x1165 ||\r\n c == 0x1167 ||\r\n c == 0x1169 ||\r\n c >= 0x116D && c <= 0x116E ||\r\n c >= 0x1172 && c <= 0x1173 ||\r\n c == 0x1175 ||\r\n c == 0x119E ||\r\n c == 0x11A8 ||\r\n c == 0x11AB ||\r\n c >= 0x11AE && c <= 0x11AF ||\r\n c >= 0x11B7 && c <= 0x11B8 ||\r\n c == 0x11BA ||\r\n c >= 0x11BC && c <= 0x11C2 ||\r\n c == 0x11EB ||\r\n c == 0x11F0 ||\r\n c == 0x11F9 ||\r\n c >= 0x1E00 && c <= 0x1E9B ||\r\n c >= 0x1EA0 && c <= 0x1EF9 ||\r\n c >= 0x1F00 && c <= 0x1F15 ||\r\n c >= 0x1F18 && c <= 0x1F1D ||\r\n c >= 0x1F20 && c <= 0x1F45 ||\r\n c >= 0x1F48 && c <= 0x1F4D ||\r\n c >= 0x1F50 && c <= 0x1F57 ||\r\n c == 0x1F59 ||\r\n c == 0x1F5B ||\r\n c == 0x1F5D ||\r\n c >= 0x1F5F && c <= 0x1F7D ||\r\n c >= 0x1F80 && c <= 0x1FB4 ||\r\n c >= 0x1FB6 && c <= 0x1FBC ||\r\n c == 0x1FBE ||\r\n c >= 0x1FC2 && c <= 0x1FC4 ||\r\n c >= 0x1FC6 && c <= 0x1FCC ||\r\n c >= 0x1FD0 && c <= 0x1FD3 ||\r\n c >= 0x1FD6 && c <= 0x1FDB ||\r\n c >= 0x1FE0 && c <= 0x1FEC ||\r\n c >= 0x1FF2 && c <= 0x1FF4 ||\r\n c >= 0x1FF6 && c <= 0x1FFC ||\r\n c == 0x2126 ||\r\n c >= 0x212A && c <= 0x212B ||\r\n c == 0x212E ||\r\n c >= 0x2180 && c <= 0x2182 ||\r\n c >= 0x3041 && c <= 0x3094 ||\r\n c >= 0x30A1 && c <= 0x30FA ||\r\n c >= 0x3105 && c <= 0x312C ||\r\n c >= 0xAC00 && c <= 0xD7A3 ||\r\n c >= 0x4E00 && c <= 0x9FA5 ||\r\n c == 0x3007 ||\r\n c >= 0x3021 && c <= 0x3029;\r\n };\r\n\r\n Utilities.isNCNameChar = function (c) {\r\n return c >= 0x0030 && c <= 0x0039\r\n || c >= 0x0660 && c <= 0x0669\r\n || c >= 0x06F0 && c <= 0x06F9\r\n || c >= 0x0966 && c <= 0x096F\r\n || c >= 0x09E6 && c <= 0x09EF\r\n || c >= 0x0A66 && c <= 0x0A6F\r\n || c >= 0x0AE6 && c <= 0x0AEF\r\n || c >= 0x0B66 && c <= 0x0B6F\r\n || c >= 0x0BE7 && c <= 0x0BEF\r\n || c >= 0x0C66 && c <= 0x0C6F\r\n || c >= 0x0CE6 && c <= 0x0CEF\r\n || c >= 0x0D66 && c <= 0x0D6F\r\n || c >= 0x0E50 && c <= 0x0E59\r\n || c >= 0x0ED0 && c <= 0x0ED9\r\n || c >= 0x0F20 && c <= 0x0F29\r\n || c == 0x002E\r\n || c == 0x002D\r\n || c == 0x005F\r\n || Utilities.isLetter(c)\r\n || c >= 0x0300 && c <= 0x0345\r\n || c >= 0x0360 && c <= 0x0361\r\n || c >= 0x0483 && c <= 0x0486\r\n || c >= 0x0591 && c <= 0x05A1\r\n || c >= 0x05A3 && c <= 0x05B9\r\n || c >= 0x05BB && c <= 0x05BD\r\n || c == 0x05BF\r\n || c >= 0x05C1 && c <= 0x05C2\r\n || c == 0x05C4\r\n || c >= 0x064B && c <= 0x0652\r\n || c == 0x0670\r\n || c >= 0x06D6 && c <= 0x06DC\r\n || c >= 0x06DD && c <= 0x06DF\r\n || c >= 0x06E0 && c <= 0x06E4\r\n || c >= 0x06E7 && c <= 0x06E8\r\n || c >= 0x06EA && c <= 0x06ED\r\n || c >= 0x0901 && c <= 0x0903\r\n || c == 0x093C\r\n || c >= 0x093E && c <= 0x094C\r\n || c == 0x094D\r\n || c >= 0x0951 && c <= 0x0954\r\n || c >= 0x0962 && c <= 0x0963\r\n || c >= 0x0981 && c <= 0x0983\r\n || c == 0x09BC\r\n || c == 0x09BE\r\n || c == 0x09BF\r\n || c >= 0x09C0 && c <= 0x09C4\r\n || c >= 0x09C7 && c <= 0x09C8\r\n || c >= 0x09CB && c <= 0x09CD\r\n || c == 0x09D7\r\n || c >= 0x09E2 && c <= 0x09E3\r\n || c == 0x0A02\r\n || c == 0x0A3C\r\n || c == 0x0A3E\r\n || c == 0x0A3F\r\n || c >= 0x0A40 && c <= 0x0A42\r\n || c >= 0x0A47 && c <= 0x0A48\r\n || c >= 0x0A4B && c <= 0x0A4D\r\n || c >= 0x0A70 && c <= 0x0A71\r\n || c >= 0x0A81 && c <= 0x0A83\r\n || c == 0x0ABC\r\n || c >= 0x0ABE && c <= 0x0AC5\r\n || c >= 0x0AC7 && c <= 0x0AC9\r\n || c >= 0x0ACB && c <= 0x0ACD\r\n || c >= 0x0B01 && c <= 0x0B03\r\n || c == 0x0B3C\r\n || c >= 0x0B3E && c <= 0x0B43\r\n || c >= 0x0B47 && c <= 0x0B48\r\n || c >= 0x0B4B && c <= 0x0B4D\r\n || c >= 0x0B56 && c <= 0x0B57\r\n || c >= 0x0B82 && c <= 0x0B83\r\n || c >= 0x0BBE && c <= 0x0BC2\r\n || c >= 0x0BC6 && c <= 0x0BC8\r\n || c >= 0x0BCA && c <= 0x0BCD\r\n || c == 0x0BD7\r\n || c >= 0x0C01 && c <= 0x0C03\r\n || c >= 0x0C3E && c <= 0x0C44\r\n || c >= 0x0C46 && c <= 0x0C48\r\n || c >= 0x0C4A && c <= 0x0C4D\r\n || c >= 0x0C55 && c <= 0x0C56\r\n || c >= 0x0C82 && c <= 0x0C83\r\n || c >= 0x0CBE && c <= 0x0CC4\r\n || c >= 0x0CC6 && c <= 0x0CC8\r\n || c >= 0x0CCA && c <= 0x0CCD\r\n || c >= 0x0CD5 && c <= 0x0CD6\r\n || c >= 0x0D02 && c <= 0x0D03\r\n || c >= 0x0D3E && c <= 0x0D43\r\n || c >= 0x0D46 && c <= 0x0D48\r\n || c >= 0x0D4A && c <= 0x0D4D\r\n || c == 0x0D57\r\n || c == 0x0E31\r\n || c >= 0x0E34 && c <= 0x0E3A\r\n || c >= 0x0E47 && c <= 0x0E4E\r\n || c == 0x0EB1\r\n || c >= 0x0EB4 && c <= 0x0EB9\r\n || c >= 0x0EBB && c <= 0x0EBC\r\n || c >= 0x0EC8 && c <= 0x0ECD\r\n || c >= 0x0F18 && c <= 0x0F19\r\n || c == 0x0F35\r\n || c == 0x0F37\r\n || c == 0x0F39\r\n || c == 0x0F3E\r\n || c == 0x0F3F\r\n || c >= 0x0F71 && c <= 0x0F84\r\n || c >= 0x0F86 && c <= 0x0F8B\r\n || c >= 0x0F90 && c <= 0x0F95\r\n || c == 0x0F97\r\n || c >= 0x0F99 && c <= 0x0FAD\r\n || c >= 0x0FB1 && c <= 0x0FB7\r\n || c == 0x0FB9\r\n || c >= 0x20D0 && c <= 0x20DC\r\n || c == 0x20E1\r\n || c >= 0x302A && c <= 0x302F\r\n || c == 0x3099\r\n || c == 0x309A\r\n || c == 0x00B7\r\n || c == 0x02D0\r\n || c == 0x02D1\r\n || c == 0x0387\r\n || c == 0x0640\r\n || c == 0x0E46\r\n || c == 0x0EC6\r\n || c == 0x3005\r\n || c >= 0x3031 && c <= 0x3035\r\n || c >= 0x309D && c <= 0x309E\r\n || c >= 0x30FC && c <= 0x30FE;\r\n };\r\n\r\n Utilities.coalesceText = function (n) {\r\n for (var m = n.firstChild; m != null; m = m.nextSibling) {\r\n if (m.nodeType == NodeTypes.TEXT_NODE || m.nodeType == NodeTypes.CDATA_SECTION_NODE) {\r\n var s = m.nodeValue;\r\n var first = m;\r\n m = m.nextSibling;\r\n while (m != null && (m.nodeType == NodeTypes.TEXT_NODE || m.nodeType == NodeTypes.CDATA_SECTION_NODE)) {\r\n s += m.nodeValue;\r\n var del = m;\r\n m = m.nextSibling;\r\n del.parentNode.removeChild(del);\r\n }\r\n if (first.nodeType == NodeTypes.CDATA_SECTION_NODE) {\r\n var p = first.parentNode;\r\n if (first.nextSibling == null) {\r\n p.removeChild(first);\r\n p.appendChild(p.ownerDocument.createTextNode(s));\r\n } else {\r\n var next = first.nextSibling;\r\n p.removeChild(first);\r\n p.insertBefore(p.ownerDocument.createTextNode(s), next);\r\n }\r\n } else {\r\n first.nodeValue = s;\r\n }\r\n if (m == null) {\r\n break;\r\n }\r\n } else if (m.nodeType == NodeTypes.ELEMENT_NODE) {\r\n Utilities.coalesceText(m);\r\n }\r\n }\r\n };\r\n\r\n Utilities.instance_of = function (o, c) {\r\n while (o != null) {\r\n if (o.constructor === c) {\r\n return true;\r\n }\r\n if (o === Object) {\r\n return false;\r\n }\r\n o = o.constructor.superclass;\r\n }\r\n return false;\r\n };\r\n\r\n Utilities.getElementById = function (n, id) {\r\n // Note that this does not check the DTD to check for actual\r\n // attributes of type ID, so this may be a bit wrong.\r\n if (n.nodeType == NodeTypes.ELEMENT_NODE) {\r\n if (n.getAttribute(\"id\") == id\r\n || n.getAttributeNS(null, \"id\") == id) {\r\n return n;\r\n }\r\n }\r\n for (var m = n.firstChild; m != null; m = m.nextSibling) {\r\n var res = Utilities.getElementById(m, id);\r\n if (res != null) {\r\n return res;\r\n }\r\n }\r\n return null;\r\n };\r\n\r\n // XPathException ////////////////////////////////////////////////////////////\r\n\r\n var XPathException = (function () {\r\n function getMessage(code, exception) {\r\n var msg = exception ? \": \" + exception.toString() : \"\";\r\n switch (code) {\r\n case XPathException.INVALID_EXPRESSION_ERR:\r\n return \"Invalid expression\" + msg;\r\n case XPathException.TYPE_ERR:\r\n return \"Type error\" + msg;\r\n }\r\n return null;\r\n }\r\n\r\n function XPathException(code, error, message) {\r\n var err = Error.call(this, getMessage(code, error) || message);\r\n\r\n err.code = code;\r\n err.exception = error;\r\n\r\n return err;\r\n }\r\n\r\n XPathException.prototype = Object.create(Error.prototype);\r\n XPathException.prototype.constructor = XPathException;\r\n XPathException.superclass = Error;\r\n\r\n XPathException.prototype.toString = function () {\r\n return this.message;\r\n };\r\n\r\n XPathException.fromMessage = function (message, error) {\r\n return new XPathException(null, error, message);\r\n };\r\n\r\n XPathException.INVALID_EXPRESSION_ERR = 51;\r\n XPathException.TYPE_ERR = 52;\r\n\r\n return XPathException;\r\n })();\r\n\r\n // XPathExpression ///////////////////////////////////////////////////////////\r\n\r\n XPathExpression.prototype = {};\r\n XPathExpression.prototype.constructor = XPathExpression;\r\n XPathExpression.superclass = Object.prototype;\r\n\r\n function XPathExpression(e, r, p) {\r\n this.xpath = p.parse(e);\r\n this.context = new XPathContext();\r\n this.context.namespaceResolver = new XPathNSResolverWrapper(r);\r\n }\r\n\r\n XPathExpression.getOwnerDocument = function (n) {\r\n return n.nodeType === NodeTypes.DOCUMENT_NODE ? n : n.ownerDocument;\r\n }\r\n\r\n XPathExpression.detectHtmlDom = function (n) {\r\n if (!n) { return false; }\r\n\r\n var doc = XPathExpression.getOwnerDocument(n);\r\n\r\n try {\r\n return doc.implementation.hasFeature(\"HTML\", \"2.0\");\r\n } catch (e) {\r\n return true;\r\n }\r\n }\r\n\r\n XPathExpression.prototype.evaluate = function (n, t, res) {\r\n this.context.expressionContextNode = n;\r\n // backward compatibility - no reliable way to detect whether the DOM is HTML, but\r\n // this library has been using this method up until now, so we will continue to use it\r\n // ONLY when using an XPathExpression\r\n this.context.caseInsensitive = XPathExpression.detectHtmlDom(n);\r\n\r\n var result = this.xpath.evaluate(this.context);\r\n\r\n return new XPathResult(result, t);\r\n }\r\n\r\n // XPathNSResolverWrapper ////////////////////////////////////////////////////\r\n\r\n XPathNSResolverWrapper.prototype = {};\r\n XPathNSResolverWrapper.prototype.constructor = XPathNSResolverWrapper;\r\n XPathNSResolverWrapper.superclass = Object.prototype;\r\n\r\n function XPathNSResolverWrapper(r) {\r\n this.xpathNSResolver = r;\r\n }\r\n\r\n XPathNSResolverWrapper.prototype.getNamespace = function (prefix, n) {\r\n if (this.xpathNSResolver == null) {\r\n return null;\r\n }\r\n return this.xpathNSResolver.lookupNamespaceURI(prefix);\r\n };\r\n\r\n // NodeXPathNSResolver ///////////////////////////////////////////////////////\r\n\r\n NodeXPathNSResolver.prototype = {};\r\n NodeXPathNSResolver.prototype.constructor = NodeXPathNSResolver;\r\n NodeXPathNSResolver.superclass = Object.prototype;\r\n\r\n function NodeXPathNSResolver(n) {\r\n this.node = n;\r\n this.namespaceResolver = new NamespaceResolver();\r\n }\r\n\r\n NodeXPathNSResolver.prototype.lookupNamespaceURI = function (prefix) {\r\n return this.namespaceResolver.getNamespace(prefix, this.node);\r\n };\r\n\r\n // XPathResult ///////////////////////////////////////////////////////////////\r\n\r\n XPathResult.prototype = {};\r\n XPathResult.prototype.constructor = XPathResult;\r\n XPathResult.superclass = Object.prototype;\r\n\r\n function XPathResult(v, t) {\r\n if (t == XPathResult.ANY_TYPE) {\r\n if (v.constructor === XString) {\r\n t = XPathResult.STRING_TYPE;\r\n } else if (v.constructor === XNumber) {\r\n t = XPathResult.NUMBER_TYPE;\r\n } else if (v.constructor === XBoolean) {\r\n t = XPathResult.BOOLEAN_TYPE;\r\n } else if (v.constructor === XNodeSet) {\r\n t = XPathResult.UNORDERED_NODE_ITERATOR_TYPE;\r\n }\r\n }\r\n this.resultType = t;\r\n switch (t) {\r\n case XPathResult.NUMBER_TYPE:\r\n this.numberValue = v.numberValue();\r\n return;\r\n case XPathResult.STRING_TYPE:\r\n this.stringValue = v.stringValue();\r\n return;\r\n case XPathResult.BOOLEAN_TYPE:\r\n this.booleanValue = v.booleanValue();\r\n return;\r\n case XPathResult.ANY_UNORDERED_NODE_TYPE:\r\n case XPathResult.FIRST_ORDERED_NODE_TYPE:\r\n if (v.constructor === XNodeSet) {\r\n this.singleNodeValue = v.first();\r\n return;\r\n }\r\n break;\r\n case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:\r\n case XPathResult.ORDERED_NODE_ITERATOR_TYPE:\r\n if (v.constructor === XNodeSet) {\r\n this.invalidIteratorState = false;\r\n this.nodes = v.toArray();\r\n this.iteratorIndex = 0;\r\n return;\r\n }\r\n break;\r\n case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:\r\n case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:\r\n if (v.constructor === XNodeSet) {\r\n this.nodes = v.toArray();\r\n this.snapshotLength = this.nodes.length;\r\n return;\r\n }\r\n break;\r\n }\r\n throw new XPathException(XPathException.TYPE_ERR);\r\n };\r\n\r\n XPathResult.prototype.iterateNext = function () {\r\n if (this.resultType != XPathResult.UNORDERED_NODE_ITERATOR_TYPE\r\n && this.resultType != XPathResult.ORDERED_NODE_ITERATOR_TYPE) {\r\n throw new XPathException(XPathException.TYPE_ERR);\r\n }\r\n return this.nodes[this.iteratorIndex++];\r\n };\r\n\r\n XPathResult.prototype.snapshotItem = function (i) {\r\n if (this.resultType != XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE\r\n && this.resultType != XPathResult.ORDERED_NODE_SNAPSHOT_TYPE) {\r\n throw new XPathException(XPathException.TYPE_ERR);\r\n }\r\n return this.nodes[i];\r\n };\r\n\r\n XPathResult.ANY_TYPE = 0;\r\n XPathResult.NUMBER_TYPE = 1;\r\n XPathResult.STRING_TYPE = 2;\r\n XPathResult.BOOLEAN_TYPE = 3;\r\n XPathResult.UNORDERED_NODE_ITERATOR_TYPE = 4;\r\n XPathResult.ORDERED_NODE_ITERATOR_TYPE = 5;\r\n XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE = 6;\r\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE = 7;\r\n XPathResult.ANY_UNORDERED_NODE_TYPE = 8;\r\n XPathResult.FIRST_ORDERED_NODE_TYPE = 9;\r\n\r\n // DOM 3 XPath support ///////////////////////////////////////////////////////\r\n\r\n function installDOM3XPathSupport(doc, p) {\r\n doc.createExpression = function (e, r) {\r\n try {\r\n return new XPathExpression(e, r, p);\r\n } catch (e) {\r\n throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, e);\r\n }\r\n };\r\n doc.createNSResolver = function (n) {\r\n return new NodeXPathNSResolver(n);\r\n };\r\n doc.evaluate = function (e, cn, r, t, res) {\r\n if (t < 0 || t > 9) {\r\n throw { code: 0, toString: function () { return \"Request type not supported\"; } };\r\n }\r\n return doc.createExpression(e, r, p).evaluate(cn, t, res);\r\n };\r\n };\r\n\r\n // ---------------------------------------------------------------------------\r\n\r\n // Install DOM 3 XPath support for the current document.\r\n try {\r\n var shouldInstall = true;\r\n try {\r\n if (document.implementation\r\n && document.implementation.hasFeature\r\n && document.implementation.hasFeature(\"XPath\", null)) {\r\n shouldInstall = false;\r\n }\r\n } catch (e) {\r\n }\r\n if (shouldInstall) {\r\n installDOM3XPathSupport(document, new XPathParser());\r\n }\r\n } catch (e) {\r\n }\r\n\r\n // ---------------------------------------------------------------------------\r\n // exports for node.js\r\n\r\n installDOM3XPathSupport(exports, new XPathParser());\r\n\r\n (function () {\r\n var parser = new XPathParser();\r\n\r\n var defaultNSResolver = new NamespaceResolver();\r\n var defaultFunctionResolver = new FunctionResolver();\r\n var defaultVariableResolver = new VariableResolver();\r\n\r\n function makeNSResolverFromFunction(func) {\r\n return {\r\n getNamespace: function (prefix, node) {\r\n var ns = func(prefix, node);\r\n\r\n return ns || defaultNSResolver.getNamespace(prefix, node);\r\n }\r\n };\r\n }\r\n\r\n function makeNSResolverFromObject(obj) {\r\n return makeNSResolverFromFunction(obj.getNamespace.bind(obj));\r\n }\r\n\r\n function makeNSResolverFromMap(map) {\r\n return makeNSResolverFromFunction(function (prefix) {\r\n return map[prefix];\r\n });\r\n }\r\n\r\n function makeNSResolver(resolver) {\r\n if (resolver && typeof resolver.getNamespace === \"function\") {\r\n return makeNSResolverFromObject(resolver);\r\n }\r\n\r\n if (typeof resolver === \"function\") {\r\n return makeNSResolverFromFunction(resolver);\r\n }\r\n\r\n // assume prefix -> uri mapping\r\n if (typeof resolver === \"object\") {\r\n return makeNSResolverFromMap(resolver);\r\n }\r\n\r\n return defaultNSResolver;\r\n }\r\n\r\n /** Converts native JavaScript types to their XPath library equivalent */\r\n function convertValue(value) {\r\n if (value === null ||\r\n typeof value === \"undefined\" ||\r\n value instanceof XString ||\r\n value instanceof XBoolean ||\r\n value instanceof XNumber ||\r\n value instanceof XNodeSet) {\r\n return value;\r\n }\r\n\r\n switch (typeof value) {\r\n case \"string\": return new XString(value);\r\n case \"boolean\": return new XBoolean(value);\r\n case \"number\": return new XNumber(value);\r\n }\r\n\r\n // assume node(s)\r\n var ns = new XNodeSet();\r\n ns.addArray([].concat(value));\r\n return ns;\r\n }\r\n\r\n function makeEvaluator(func) {\r\n return function (context) {\r\n var args = Array.prototype.slice.call(arguments, 1).map(function (arg) {\r\n return arg.evaluate(context);\r\n });\r\n var result = func.apply(this, [].concat(context, args));\r\n return convertValue(result);\r\n };\r\n }\r\n\r\n function makeFunctionResolverFromFunction(func) {\r\n return {\r\n getFunction: function (name, namespace) {\r\n var found = func(name, namespace);\r\n if (found) {\r\n return makeEvaluator(found);\r\n }\r\n return defaultFunctionResolver.getFunction(name, namespace);\r\n }\r\n };\r\n }\r\n\r\n function makeFunctionResolverFromObject(obj) {\r\n return makeFunctionResolverFromFunction(obj.getFunction.bind(obj));\r\n }\r\n\r\n function makeFunctionResolverFromMap(map) {\r\n return makeFunctionResolverFromFunction(function (name) {\r\n return map[name];\r\n });\r\n }\r\n\r\n function makeFunctionResolver(resolver) {\r\n if (resolver && typeof resolver.getFunction === \"function\") {\r\n return makeFunctionResolverFromObject(resolver);\r\n }\r\n\r\n if (typeof resolver === \"function\") {\r\n return makeFunctionResolverFromFunction(resolver);\r\n }\r\n\r\n // assume map\r\n if (typeof resolver === \"object\") {\r\n return makeFunctionResolverFromMap(resolver);\r\n }\r\n\r\n return defaultFunctionResolver;\r\n }\r\n\r\n function makeVariableResolverFromFunction(func) {\r\n return {\r\n getVariable: function (name, namespace) {\r\n var value = func(name, namespace);\r\n return convertValue(value);\r\n }\r\n };\r\n }\r\n\r\n function makeVariableResolver(resolver) {\r\n if (resolver) {\r\n if (typeof resolver.getVariable === \"function\") {\r\n return makeVariableResolverFromFunction(resolver.getVariable.bind(resolver));\r\n }\r\n\r\n if (typeof resolver === \"function\") {\r\n return makeVariableResolverFromFunction(resolver);\r\n }\r\n\r\n // assume map\r\n if (typeof resolver === \"object\") {\r\n return makeVariableResolverFromFunction(function (name) {\r\n return resolver[name];\r\n });\r\n }\r\n }\r\n\r\n return defaultVariableResolver;\r\n }\r\n\r\n function copyIfPresent(prop, dest, source) {\r\n if (prop in source) { dest[prop] = source[prop]; }\r\n }\r\n\r\n function makeContext(options) {\r\n var context = new XPathContext();\r\n\r\n if (options) {\r\n context.namespaceResolver = makeNSResolver(options.namespaces);\r\n context.functionResolver = makeFunctionResolver(options.functions);\r\n context.variableResolver = makeVariableResolver(options.variables);\r\n context.expressionContextNode = options.node;\r\n copyIfPresent('allowAnyNamespaceForNoPrefix', context, options);\r\n copyIfPresent('isHtml', context, options);\r\n } else {\r\n context.namespaceResolver = defaultNSResolver;\r\n }\r\n\r\n return context;\r\n }\r\n\r\n function evaluate(parsedExpression, options) {\r\n var context = makeContext(options);\r\n\r\n return parsedExpression.evaluate(context);\r\n }\r\n\r\n var evaluatorPrototype = {\r\n evaluate: function (options) {\r\n return evaluate(this.expression, options);\r\n }\r\n\r\n , evaluateNumber: function (options) {\r\n return this.evaluate(options).numberValue();\r\n }\r\n\r\n , evaluateString: function (options) {\r\n return this.evaluate(options).stringValue();\r\n }\r\n\r\n , evaluateBoolean: function (options) {\r\n return this.evaluate(options).booleanValue();\r\n }\r\n\r\n , evaluateNodeSet: function (options) {\r\n return this.evaluate(options).nodeset();\r\n }\r\n\r\n , select: function (options) {\r\n return this.evaluateNodeSet(options).toArray()\r\n }\r\n\r\n , select1: function (options) {\r\n return this.select(options)[0];\r\n }\r\n };\r\n\r\n function parse(xpath) {\r\n var parsed = parser.parse(xpath);\r\n\r\n return Object.create(evaluatorPrototype, {\r\n expression: {\r\n value: parsed\r\n }\r\n });\r\n }\r\n\r\n exports.parse = parse;\r\n })();\r\n\r\n assign(\r\n exports,\r\n {\r\n XPath: XPath,\r\n XPathParser: XPathParser,\r\n XPathResult: XPathResult,\r\n\r\n Step: Step,\r\n PathExpr: PathExpr,\r\n NodeTest: NodeTest,\r\n LocationPath: LocationPath,\r\n\r\n OrOperation: OrOperation,\r\n AndOperation: AndOperation,\r\n\r\n BarOperation: BarOperation,\r\n\r\n EqualsOperation: EqualsOperation,\r\n NotEqualOperation: NotEqualOperation,\r\n LessThanOperation: LessThanOperation,\r\n GreaterThanOperation: GreaterThanOperation,\r\n LessThanOrEqualOperation: LessThanOrEqualOperation,\r\n GreaterThanOrEqualOperation: GreaterThanOrEqualOperation,\r\n\r\n PlusOperation: PlusOperation,\r\n MinusOperation: MinusOperation,\r\n MultiplyOperation: MultiplyOperation,\r\n DivOperation: DivOperation,\r\n ModOperation: ModOperation,\r\n UnaryMinusOperation: UnaryMinusOperation,\r\n\r\n FunctionCall: FunctionCall,\r\n VariableReference: VariableReference,\r\n\r\n XPathContext: XPathContext,\r\n\r\n XNodeSet: XNodeSet,\r\n XBoolean: XBoolean,\r\n XString: XString,\r\n XNumber: XNumber,\r\n\r\n NamespaceResolver: NamespaceResolver,\r\n FunctionResolver: FunctionResolver,\r\n VariableResolver: VariableResolver,\r\n\r\n Utilities: Utilities,\r\n }\r\n );\r\n\r\n // helper\r\n exports.select = function (e, doc, single) {\r\n return exports.selectWithResolver(e, doc, null, single);\r\n };\r\n\r\n exports.useNamespaces = function (mappings) {\r\n var resolver = {\r\n mappings: mappings || {},\r\n lookupNamespaceURI: function (prefix) {\r\n return this.mappings[prefix];\r\n }\r\n };\r\n\r\n return function (e, doc, single) {\r\n return exports.selectWithResolver(e, doc, resolver, single);\r\n };\r\n };\r\n\r\n exports.selectWithResolver = function (e, doc, resolver, single) {\r\n var expression = new XPathExpression(e, resolver, new XPathParser());\r\n var type = XPathResult.ANY_TYPE;\r\n\r\n var result = expression.evaluate(doc, type, null);\r\n\r\n if (result.resultType == XPathResult.STRING_TYPE) {\r\n result = result.stringValue;\r\n }\r\n else if (result.resultType == XPathResult.NUMBER_TYPE) {\r\n result = result.numberValue;\r\n }\r\n else if (result.resultType == XPathResult.BOOLEAN_TYPE) {\r\n result = result.booleanValue;\r\n }\r\n else {\r\n result = result.nodes;\r\n if (single) {\r\n result = result[0];\r\n }\r\n }\r\n\r\n return result;\r\n };\r\n\r\n exports.select1 = function (e, doc) {\r\n return exports.select(e, doc, true);\r\n };\r\n\r\n var isArrayOfNodes = function (value) {\r\n return Array.isArray(value) && value.every(isNodeLike);\r\n };\r\n\r\n var isNodeOfType = function (type) {\r\n return function (value) {\r\n return isNodeLike(value) && value.nodeType === type;\r\n };\r\n };\r\n\r\n assign(\r\n exports,\r\n {\r\n isNodeLike: isNodeLike,\r\n isArrayOfNodes: isArrayOfNodes,\r\n isElement: isNodeOfType(NodeTypes.ELEMENT_NODE),\r\n isAttribute: isNodeOfType(NodeTypes.ATTRIBUTE_NODE),\r\n isTextNode: isNodeOfType(NodeTypes.TEXT_NODE),\r\n isCDATASection: isNodeOfType(NodeTypes.CDATA_SECTION_NODE),\r\n isProcessingInstruction: isNodeOfType(NodeTypes.PROCESSING_INSTRUCTION_NODE),\r\n isComment: isNodeOfType(NodeTypes.COMMENT_NODE),\r\n isDocumentNode: isNodeOfType(NodeTypes.DOCUMENT_NODE),\r\n isDocumentTypeNode: isNodeOfType(NodeTypes.DOCUMENT_TYPE_NODE),\r\n isDocumentFragment: isNodeOfType(NodeTypes.DOCUMENT_FRAGMENT_NODE),\r\n }\r\n );\r\n // end non-node wrapper\r\n})(xpath);\r\n","'use strict'\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties, including NodeList.\n *\n * @template {unknown} T\n * @param {Array | ({length:number, [number]: T})} list\n * @param {function (item: T, index: number, list:Array | ({length:number, [number]: T})):boolean} predicate\n * @param {Partial>?} ac `Array.prototype` by default,\n * \t\t\t\tallows injecting a custom implementation in tests\n * @returns {T | undefined}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (Object.prototype.hasOwnProperty.call(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * @template T\n * @param {T} object the object to freeze\n * @param {Pick = Object} oc `Object` by default,\n * \t\t\t\tallows to inject custom object constructor for tests\n * @returns {Readonly}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object\n}\n\n/**\n * Since we can not rely on `Object.assign` we provide a simplified version\n * that is sufficient for our needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n *\n * @returns {Object} target\n * @throws TypeError if target is not an object\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object')\n\t}\n\tfor (var key in source) {\n\t\tif (Object.prototype.hasOwnProperty.call(source, key)) {\n\t\t\ttarget[key] = source[key]\n\t\t}\n\t}\n\treturn target\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec\n * @see DOMParser.prototype.parseFromString\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see DOMParser.SupportedType.isHTML\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * Helper method to check a mime type if it indicates an HTML document\n\t *\n\t * @param {string} [value]\n\t * @returns {boolean}\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring \t */\n\tisHTML: function (value) {\n\t\treturn value === MIME_TYPE.HTML\n\t},\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/html`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n})\n\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * Checks if `uri` equals `NAMESPACE.HTML`.\n\t *\n\t * @param {string} [uri]\n\t *\n\t * @see NAMESPACE.HTML\n\t */\n\tisHTML: function (uri) {\n\t\treturn uri === NAMESPACE.HTML\n\t},\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n})\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","var conventions = require(\"./conventions\");\n\nvar find = conventions.find;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty\n * @param {string} input\n * @returns {boolean}\n */\nfunction notEmptyString (input) {\n\treturn input !== ''\n}\n/**\n * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace\n * @see https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * @param {string} input\n * @returns {string[]} (can be empty)\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : []\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * @param {string} element\n * @returns {Record}\n */\nfunction orderedSetReducer (current, element) {\n\tif (!current.hasOwnProperty(element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * @see https://infra.spec.whatwg.org/#ordered-set\n * @param {string} input\n * @returns {string[]}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}))\n}\n\n/**\n * Uses `list.indexOf` to implement something like `Array.prototype.includes`,\n * which we can not rely on being available.\n *\n * @param {any[]} list\n * @returns {function(any): boolean}\n */\nfunction arrayIncludes (list) {\n\treturn function(element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t}\n}\n\nfunction copy(src,dest){\n\tfor(var p in src){\n\t\tif (Object.prototype.hasOwnProperty.call(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*((?:.*\\{\\s*?[\\r\\n][\\s\\S]*?^})|\\S.*?(?=[;\\r\\n]));?\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*(\\S.*?(?=[;\\r\\n]));?\n */\nfunction _extends(Class,Super){\n\tvar pt = Class.prototype;\n\tif(!(pt instanceof Super)){\n\t\tfunction t(){};\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt,t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif(pt.constructor != Class){\n\t\tif(typeof Class != 'function'){\n\t\t\tconsole.error(\"unknown Class:\"+Class)\n\t\t}\n\t\tpt.constructor = Class\n\t}\n}\n\n// Node Types\nvar NodeType = {}\nvar ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;\nvar ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;\nvar TEXT_NODE = NodeType.TEXT_NODE = 3;\nvar CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;\nvar ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;\nvar ENTITY_NODE = NodeType.ENTITY_NODE = 6;\nvar PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;\nvar COMMENT_NODE = NodeType.COMMENT_NODE = 8;\nvar DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;\nvar DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;\nvar DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;\nvar NOTATION_NODE = NodeType.NOTATION_NODE = 12;\n\n// ExceptionCode\nvar ExceptionCode = {}\nvar ExceptionMessage = {};\nvar INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]=\"Index size error\"),1);\nvar DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]=\"DOMString size error\"),2);\nvar HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]=\"Hierarchy request error\"),3);\nvar WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]=\"Wrong document\"),4);\nvar INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]=\"Invalid character\"),5);\nvar NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]=\"No data allowed\"),6);\nvar NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]=\"No modification allowed\"),7);\nvar NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]=\"Not found\"),8);\nvar NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]=\"Not supported\"),9);\nvar INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]=\"Attribute in use\"),10);\n//level2\nvar INVALID_STATE_ERR \t= ExceptionCode.INVALID_STATE_ERR \t= ((ExceptionMessage[11]=\"Invalid state\"),11);\nvar SYNTAX_ERR \t= ExceptionCode.SYNTAX_ERR \t= ((ExceptionMessage[12]=\"Syntax error\"),12);\nvar INVALID_MODIFICATION_ERR \t= ExceptionCode.INVALID_MODIFICATION_ERR \t= ((ExceptionMessage[13]=\"Invalid modification\"),13);\nvar NAMESPACE_ERR \t= ExceptionCode.NAMESPACE_ERR \t= ((ExceptionMessage[14]=\"Invalid namespace\"),14);\nvar INVALID_ACCESS_ERR \t= ExceptionCode.INVALID_ACCESS_ERR \t= ((ExceptionMessage[15]=\"Invalid access\"),15);\n\n/**\n * DOM Level 2\n * Object DOMException\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(code, message) {\n\tif(message instanceof Error){\n\t\tvar error = message;\n\t}else{\n\t\terror = this;\n\t\tError.call(this, ExceptionMessage[code]);\n\t\tthis.message = ExceptionMessage[code];\n\t\tif(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n\t}\n\terror.code = code;\n\tif(message) this.message = this.message + \": \" + message;\n\treturn error;\n};\nDOMException.prototype = Error.prototype;\ncopy(ExceptionCode,DOMException)\n\n/**\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n */\nfunction NodeList() {\n};\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.\n\t * @standard level1\n\t */\n\tlength:0,\n\t/**\n\t * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.\n\t * @standard level1\n\t * @param index unsigned long\n\t * Index into the collection.\n\t * @return Node\n\t * \tThe node at the indexth position in the NodeList, or null if that is not a valid index.\n\t */\n\titem: function(index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\ttoString:function(isHTML,nodeFilter){\n\t\tfor(var buf = [], i = 0;i=0){\n\t\tvar lastIndex = list.length-1\n\t\twhile(i0 || key == 'xmlns'){\n//\t\t\treturn null;\n//\t\t}\n\t\t//console.log()\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar attr = this[i];\n\t\t\t//console.log(attr.nodeName,key)\n\t\t\tif(attr.nodeName == key){\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t}\n\t},\n\tsetNamedItem: function(attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItem(attr.nodeName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\t/* returns Node */\n\tsetNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR\n\t\tvar el = attr.ownerElement, oldAttr;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\toldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/* returns Node */\n\tremoveNamedItem: function(key) {\n\t\tvar attr = this.getNamedItem(key);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\n\n\t},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR\n\n\t//for level2\n\tremoveNamedItemNS:function(namespaceURI,localName){\n\t\tvar attr = this.getNamedItemNS(namespaceURI,localName);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\t},\n\tgetNamedItemNS: function(namespaceURI, localName) {\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar node = this[i];\n\t\t\tif(node.localName == localName && node.namespaceURI == namespaceURI){\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n};\n\n/**\n * The DOMImplementation interface represents an object providing methods\n * which are not dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * __The individual methods describe the differences compared to the specs.__\n *\n * @constructor\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n */\nfunction DOMImplementation() {\n}\n\nDOMImplementation.prototype = {\n\t/**\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.\n\t * The different implementations fairly diverged in what kind of features were reported.\n\t * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated It is deprecated and modern browsers return true in all cases.\n\t *\n\t * @param {string} feature\n\t * @param {string} [version]\n\t * @returns {boolean} always true\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t */\n\thasFeature: function(feature, version) {\n\t\t\treturn true;\n\t},\n\t/**\n\t * Creates an XML Document object of the specified type with its document element.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document` instance.\n\t * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string|null} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {DocumentType=null} doctype\n\t * @returns {Document}\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocument: function(namespaceURI, qualifiedName, doctype){\n\t\tvar doc = new Document();\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype){\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName){\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.\n\t *\n\t * __This behavior is slightly different from the in the specs__:\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string} qualifiedName\n\t * @param {string} [publicId]\n\t * @param {string} [systemId]\n\t * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation\n\t * \t\t\t\t or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocumentType: function(qualifiedName, publicId, systemId){\n\t\tvar node = new DocumentType();\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\n\t\treturn node;\n\t}\n};\n\n\n/**\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n */\n\nfunction Node() {\n};\n\nNode.prototype = {\n\tfirstChild : null,\n\tlastChild : null,\n\tpreviousSibling : null,\n\tnextSibling : null,\n\tattributes : null,\n\tparentNode : null,\n\tchildNodes : null,\n\townerDocument : null,\n\tnodeValue : null,\n\tnamespaceURI : null,\n\tprefix : null,\n\tlocalName : null,\n\t// Modified in DOM Level 2:\n\tinsertBefore:function(newChild, refChild){//raises\n\t\treturn _insertBefore(this,newChild,refChild);\n\t},\n\treplaceChild:function(newChild, oldChild){//raises\n\t\t_insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);\n\t\tif(oldChild){\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\tremoveChild:function(oldChild){\n\t\treturn _removeChild(this,oldChild);\n\t},\n\tappendChild:function(newChild){\n\t\treturn this.insertBefore(newChild,null);\n\t},\n\thasChildNodes:function(){\n\t\treturn this.firstChild != null;\n\t},\n\tcloneNode:function(deep){\n\t\treturn cloneNode(this.ownerDocument||this,this,deep);\n\t},\n\t// Modified in DOM Level 2:\n\tnormalize:function(){\n\t\tvar child = this.firstChild;\n\t\twhile(child){\n\t\t\tvar next = child.nextSibling;\n\t\t\tif(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t}else{\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n \t// Introduced in DOM Level 2:\n\tisSupported:function(feature, version){\n\t\treturn this.ownerDocument.implementation.hasFeature(feature,version);\n\t},\n // Introduced in DOM Level 2:\n hasAttributes:function(){\n \treturn this.attributes.length>0;\n },\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._\n\t *\n\t * @param {string | null} namespaceURI\n\t * @returns {string | null}\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t */\n lookupPrefix:function(namespaceURI){\n \tvar el = this;\n \twhile(el){\n \t\tvar map = el._nsMap;\n \t\t//console.dir(map)\n \t\tif(map){\n \t\t\tfor(var n in map){\n\t\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\t\treturn n;\n\t\t\t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tel = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;\n \t}\n \treturn null;\n },\n // Introduced in DOM Level 3:\n lookupNamespaceURI:function(prefix){\n \tvar el = this;\n \twhile(el){\n \t\tvar map = el._nsMap;\n \t\t//console.dir(map)\n \t\tif(map){\n \t\t\tif(Object.prototype.hasOwnProperty.call(map, prefix)){\n \t\t\t\treturn map[prefix] ;\n \t\t\t}\n \t\t}\n \t\tel = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;\n \t}\n \treturn null;\n },\n // Introduced in DOM Level 3:\n isDefaultNamespace:function(namespaceURI){\n \tvar prefix = this.lookupPrefix(namespaceURI);\n \treturn prefix == null;\n }\n};\n\n\nfunction _xmlEncoder(c){\n\treturn c == '<' && '<' ||\n c == '>' && '>' ||\n c == '&' && '&' ||\n c == '\"' && '"' ||\n '&#'+c.charCodeAt()+';'\n}\n\n\ncopy(NodeType,Node);\ncopy(NodeType,Node.prototype);\n\n/**\n * @param callback return true for continue,false for break\n * @return boolean true: break visit;\n */\nfunction _visitNode(node,callback){\n\tif(callback(node)){\n\t\treturn true;\n\t}\n\tif(node = node.firstChild){\n\t\tdo{\n\t\t\tif(_visitNode(node,callback)){return true}\n }while(node=node.nextSibling)\n }\n}\n\n\n\nfunction Document(){\n\tthis.ownerDocument = this;\n}\n\nfunction _onAddAttribute(doc,el,newAttr){\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI ;\n\tif(ns === NAMESPACE.XMLNS){\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value\n\t}\n}\n\nfunction _onRemoveAttribute(doc,el,newAttr,remove){\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI ;\n\tif(ns === NAMESPACE.XMLNS){\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix?newAttr.localName:'']\n\t}\n}\n\n/**\n * Updates `el.childNodes`, updating the indexed items and it's `length`.\n * Passing `newChild` means it will be appended.\n * Otherwise it's assumed that an item has been removed,\n * and `el.firstNode` and it's `.nextSibling` are used\n * to walk the current list of child nodes.\n *\n * @param {Document} doc\n * @param {Node} el\n * @param {Node} [newChild]\n * @private\n */\nfunction _onUpdateChild (doc, el, newChild) {\n\tif(doc && doc._inc){\n\t\tdoc._inc++;\n\t\t//update childNodes\n\t\tvar cs = el.childNodes;\n\t\tif (newChild) {\n\t\t\tcs[cs.length++] = newChild;\n\t\t} else {\n\t\t\tvar child = el.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile (child) {\n\t\t\t\tcs[i++] = child;\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\tcs.length = i;\n\t\t\tdelete cs[cs.length];\n\t\t}\n\t}\n}\n\n/**\n * Removes the connections between `parentNode` and `child`\n * and any existing `child.previousSibling` or `child.nextSibling`.\n *\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n *\n * @param {Node} parentNode\n * @param {Node} child\n * @returns {Node} the child that was removed.\n * @private\n */\nfunction _removeChild (parentNode, child) {\n\tvar previous = child.previousSibling;\n\tvar next = child.nextSibling;\n\tif (previous) {\n\t\tprevious.nextSibling = next;\n\t} else {\n\t\tparentNode.firstChild = next;\n\t}\n\tif (next) {\n\t\tnext.previousSibling = previous;\n\t} else {\n\t\tparentNode.lastChild = previous;\n\t}\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\t_onUpdateChild(parentNode.ownerDocument, parentNode);\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(isElementNode(node) ||\n\t\t\tisTextNode(node) ||\n\t\t\tisDocTypeNode(node) ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc The document node\n * @param {Node} child the node that would become the nextSibling if the element would be inserted\n * @returns {boolean} `true` if an element can be inserted before child\n * @private\n * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc The document node\n * @param {Node} child the node that would become the nextSibling if the element would be inserted\n * @returns {boolean} `true` if an element can be inserted before child\n * @private\n * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * @private\n * Steps 1-5 of the checks before inserting and before replacing a child are the same.\n *\n * @param {Node} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node=} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tHIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * @private\n * Step 6 of the checks before inserting and before replacing a child are different.\n *\n * @param {Document} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node | undefined} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @private\n * Step 6 of the checks before inserting and before replacing a child are different.\n *\n * @param {Document} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node | undefined} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * @private\n * @param {Node} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node=} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif(cp){\n\t\tcp.removeChild(node);//remove and update\n\t}\n\tif(node.nodeType === DOCUMENT_FRAGMENT_NODE){\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t}else{\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\n\tif(pre){\n\t\tpre.nextSibling = newFirst;\n\t}else{\n\t\tparent.firstChild = newFirst;\n\t}\n\tif(child == null){\n\t\tparent.lastChild = newLast;\n\t}else{\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo{\n\t\tnewFirst.parentNode = parent;\n\t}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))\n\t_onUpdateChild(parent.ownerDocument||parent, parent);\n\t//console.log(parent.lastChild.nextSibling == null)\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\treturn node;\n}\n\n/**\n * Appends `newChild` to `parentNode`.\n * If `newChild` is already connected to a `parentNode` it is first removed from it.\n *\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n * @param {Node} parentNode\n * @param {Node} newChild\n * @returns {Node}\n * @private\n */\nfunction _appendSingleChild (parentNode, newChild) {\n\tif (newChild.parentNode) {\n\t\tnewChild.parentNode.removeChild(newChild);\n\t}\n\tnewChild.parentNode = parentNode;\n\tnewChild.previousSibling = parentNode.lastChild;\n\tnewChild.nextSibling = null;\n\tif (newChild.previousSibling) {\n\t\tnewChild.previousSibling.nextSibling = newChild;\n\t} else {\n\t\tparentNode.firstChild = newChild;\n\t}\n\tparentNode.lastChild = newChild;\n\t_onUpdateChild(parentNode.ownerDocument, parentNode, newChild);\n\treturn newChild;\n}\n\nDocument.prototype = {\n\t//implementation : null,\n\tnodeName : '#document',\n\tnodeType : DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @readonly\n\t * @type DocumentType\n\t */\n\tdoctype : null,\n\tdocumentElement : null,\n\t_inc : 1,\n\n\tinsertBefore : function(newChild, refChild){//raises\n\t\tif(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile(child){\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child,refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild : function(oldChild){\n\t\tif(this.documentElement == oldChild){\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn _removeChild(this,oldChild);\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode : function(importedNode,deep){\n\t\treturn importNode(this,importedNode,deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById :\tfunction(id){\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement,function(node){\n\t\t\tif(node.nodeType == ELEMENT_NODE){\n\t\t\t\tif(node.getAttribute('id') == id){\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * The `getElementsByClassName` method of `Document` interface returns an array-like object\n\t * of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.\n\t *\n\t *\n\t * Warning: This is a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function(classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames)\n\t\treturn new LiveNodeList(this, function(base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base.documentElement, function(node) {\n\t\t\t\t\tif(node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class')\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames)\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t//document factory method:\n\tcreateElement :\tfunction(tagName){\n\t\tvar node = new Element();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs\t= node.attributes = new NamedNodeMap();\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\tcreateDocumentFragment :\tfunction(){\n\t\tvar node = new DocumentFragment();\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\tcreateTextNode :\tfunction(data){\n\t\tvar node = new Text();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateComment :\tfunction(data){\n\t\tvar node = new Comment();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateCDATASection :\tfunction(data){\n\t\tvar node = new CDATASection();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateProcessingInstruction :\tfunction(target,data){\n\t\tvar node = new ProcessingInstruction();\n\t\tnode.ownerDocument = this;\n\t\tnode.tagName = node.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\tcreateAttribute :\tfunction(name){\n\t\tvar node = new Attr();\n\t\tnode.ownerDocument\t= this;\n\t\tnode.name = name;\n\t\tnode.nodeName\t= name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\tcreateEntityReference :\tfunction(name){\n\t\tvar node = new EntityReference();\n\t\tnode.ownerDocument\t= this;\n\t\tnode.nodeName\t= name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\tcreateElementNS :\tfunction(namespaceURI,qualifiedName){\n\t\tvar node = new Element();\n\t\tvar pl = qualifiedName.split(':');\n\t\tvar attrs\t= node.attributes = new NamedNodeMap();\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = namespaceURI;\n\t\tif(pl.length == 2){\n\t\t\tnode.prefix = pl[0];\n\t\t\tnode.localName = pl[1];\n\t\t}else{\n\t\t\t//el.prefix = null;\n\t\t\tnode.localName = qualifiedName;\n\t\t}\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\tcreateAttributeNS :\tfunction(namespaceURI,qualifiedName){\n\t\tvar node = new Attr();\n\t\tvar pl = qualifiedName.split(':');\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.namespaceURI = namespaceURI;\n\t\tnode.specified = true;\n\t\tif(pl.length == 2){\n\t\t\tnode.prefix = pl[0];\n\t\t\tnode.localName = pl[1];\n\t\t}else{\n\t\t\t//el.prefix = null;\n\t\t\tnode.localName = qualifiedName;\n\t\t}\n\t\treturn node;\n\t}\n};\n_extends(Document,Node);\n\n\nfunction Element() {\n\tthis._nsMap = {};\n};\nElement.prototype = {\n\tnodeType : ELEMENT_NODE,\n\thasAttribute : function(name){\n\t\treturn this.getAttributeNode(name)!=null;\n\t},\n\tgetAttribute : function(name){\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr && attr.value || '';\n\t},\n\tgetAttributeNode : function(name){\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\tsetAttribute : function(name, value){\n\t\tvar attr = this.ownerDocument.createAttribute(name);\n\t\tattr.value = attr.nodeValue = \"\" + value;\n\t\tthis.setAttributeNode(attr)\n\t},\n\tremoveAttribute : function(name){\n\t\tvar attr = this.getAttributeNode(name)\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\n\t//four real opeartion method\n\tappendChild:function(newChild){\n\t\tif(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){\n\t\t\treturn this.insertBefore(newChild,null);\n\t\t}else{\n\t\t\treturn _appendSingleChild(this,newChild);\n\t\t}\n\t},\n\tsetAttributeNode : function(newAttr){\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS : function(newAttr){\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode : function(oldAttr){\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS : function(namespaceURI, localName){\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS : function(namespaceURI, localName){\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName)!=null;\n\t},\n\tgetAttributeNS : function(namespaceURI, localName){\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr && attr.value || '';\n\t},\n\tsetAttributeNS : function(namespaceURI, qualifiedName, value){\n\t\tvar attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\tattr.value = attr.nodeValue = \"\" + value;\n\t\tthis.setAttributeNode(attr)\n\t},\n\tgetAttributeNodeNS : function(namespaceURI, localName){\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\tgetElementsByTagName : function(tagName){\n\t\treturn new LiveNodeList(this,function(base){\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base,function(node){\n\t\t\t\tif(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS : function(namespaceURI, localName){\n\t\treturn new LiveNodeList(this,function(base){\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base,function(node){\n\t\t\t\tif(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\n\t\t});\n\t}\n};\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n\n_extends(Element,Node);\nfunction Attr() {\n};\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr,Node);\n\n\nfunction CharacterData() {\n};\nCharacterData.prototype = {\n\tdata : '',\n\tsubstringData : function(offset, count) {\n\t\treturn this.data.substring(offset, offset+count);\n\t},\n\tappendData: function(text) {\n\t\ttext = this.data+text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function(offset,text) {\n\t\tthis.replaceData(offset,0,text);\n\n\t},\n\tappendChild:function(newChild){\n\t\tthrow new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])\n\t},\n\tdeleteData: function(offset, count) {\n\t\tthis.replaceData(offset,count,\"\");\n\t},\n\treplaceData: function(offset, count, text) {\n\t\tvar start = this.data.substring(0,offset);\n\t\tvar end = this.data.substring(offset+count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t}\n}\n_extends(CharacterData,Node);\nfunction Text() {\n};\nText.prototype = {\n\tnodeName : \"#text\",\n\tnodeType : TEXT_NODE,\n\tsplitText : function(offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif(this.parentNode){\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t}\n}\n_extends(Text,CharacterData);\nfunction Comment() {\n};\nComment.prototype = {\n\tnodeName : \"#comment\",\n\tnodeType : COMMENT_NODE\n}\n_extends(Comment,CharacterData);\n\nfunction CDATASection() {\n};\nCDATASection.prototype = {\n\tnodeName : \"#cdata-section\",\n\tnodeType : CDATA_SECTION_NODE\n}\n_extends(CDATASection,CharacterData);\n\n\nfunction DocumentType() {\n};\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType,Node);\n\nfunction Notation() {\n};\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation,Node);\n\nfunction Entity() {\n};\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity,Node);\n\nfunction EntityReference() {\n};\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference,Node);\n\nfunction DocumentFragment() {\n};\nDocumentFragment.prototype.nodeName =\t\"#document-fragment\";\nDocumentFragment.prototype.nodeType =\tDOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment,Node);\n\n\nfunction ProcessingInstruction() {\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction,Node);\nfunction XMLSerializer(){}\nXMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){\n\treturn nodeSerializeToString.call(node,isHtml,nodeFilter);\n}\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(isHtml,nodeFilter){\n\tvar buf = [];\n\tvar refNode = this.nodeType == 9 && this.documentElement || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif(uri && prefix == null){\n\t\t//console.log(prefix)\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif(prefix == null){\n\t\t\t//isHTML = true;\n\t\t\tvar visibleNamespaces=[\n\t\t\t{namespace:uri,prefix:null}\n\t\t\t//{namespace:uri,prefix:''}\n\t\t\t]\n\t\t}\n\t}\n\tserializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);\n\t//console.log('###',this.nodeType,uri,prefix,buf.join(''))\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif (prefix === \"xml\" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Well-formed constraint: No < in Attribute Values\n * > The replacement text of any entity referred to directly or indirectly\n * > in an attribute value must not contain a <.\n * @see https://www.w3.org/TR/xml11/#CleanAttrVals\n * @see https://www.w3.org/TR/xml11/#NT-AttValue\n *\n * Literal whitespace other than space that appear in attribute values\n * are serialized as their entity references, so they will be preserved.\n * (In contrast to whitespace literals in the input which are normalized to spaces)\n * @see https://www.w3.org/TR/xml11/#AVNormalize\n * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<>&\"\\t\\n\\r]/g, _xmlEncoder), '\"')\n}\n\nfunction serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\n\tif(nodeFilter){\n\t\tnode = nodeFilter(node);\n\t\tif(node){\n\t\t\tif(typeof node == 'string'){\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}else{\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch(node.nodeType){\n\tcase ELEMENT_NODE:\n\t\tvar attrs = node.attributes;\n\t\tvar len = attrs.length;\n\t\tvar child = node.firstChild;\n\t\tvar nodeName = node.tagName;\n\n\t\tisHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML\n\n\t\tvar prefixedNodeName = nodeName\n\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\tvar defaultNS\n\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\tdefaultNS = attrs.item(ai).value\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!defaultNS) {\n\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\tvar namespace = visibleNamespaces[nsi]\n\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\tdefaultNS = namespace.namespace\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\tvar namespace = visibleNamespaces[nsi]\n\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tbuf.push('<', prefixedNodeName);\n\n\t\tfor(var i=0;i');\n\t\t\t//if is cdata child node\n\t\t\tif(isHTML && /^script$/i.test(nodeName)){\n\t\t\t\twhile(child){\n\t\t\t\t\tif(child.data){\n\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t}\n\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t}\n\t\t\t}else\n\t\t\t{\n\t\t\t\twhile(child){\n\t\t\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbuf.push('');\n\t\t}else{\n\t\t\tbuf.push('/>');\n\t\t}\n\t\t// remove added visible namespaces\n\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\treturn;\n\tcase DOCUMENT_NODE:\n\tcase DOCUMENT_FRAGMENT_NODE:\n\t\tvar child = node.firstChild;\n\t\twhile(child){\n\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\tchild = child.nextSibling;\n\t\t}\n\t\treturn;\n\tcase ATTRIBUTE_NODE:\n\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\tcase TEXT_NODE:\n\t\t/**\n\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.\n\t\t * If they are needed elsewhere, they must be escaped using either numeric character references or the strings\n\t\t * `&` and `<` respectively.\n\t\t * The right angle bracket (>) may be represented using the string \" > \", and must, for compatibility,\n\t\t * be escaped using either `>` or a character reference when it appears in the string `]]>` in content,\n\t\t * when that string is not marking the end of a CDATA section.\n\t\t *\n\t\t * In the content of elements, character data is any string of characters\n\t\t * which does not contain the start-delimiter of any markup\n\t\t * and does not include the CDATA-section-close delimiter, `]]>`.\n\t\t *\n\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node\n\t\t */\n\t\treturn buf.push(node.data\n\t\t\t.replace(/[<&>]/g,_xmlEncoder)\n\t\t);\n\tcase CDATA_SECTION_NODE:\n\t\treturn buf.push( '');\n\tcase COMMENT_NODE:\n\t\treturn buf.push( \"\");\n\tcase DOCUMENT_TYPE_NODE:\n\t\tvar pubid = node.publicId;\n\t\tvar sysid = node.systemId;\n\t\tbuf.push('');\n\t\t}else if(sysid && sysid!='.'){\n\t\t\tbuf.push(' SYSTEM ', sysid, '>');\n\t\t}else{\n\t\t\tvar sub = node.internalSubset;\n\t\t\tif(sub){\n\t\t\t\tbuf.push(\" [\",sub,\"]\");\n\t\t\t}\n\t\t\tbuf.push(\">\");\n\t\t}\n\t\treturn;\n\tcase PROCESSING_INSTRUCTION_NODE:\n\t\treturn buf.push( \"\");\n\tcase ENTITY_REFERENCE_NODE:\n\t\treturn buf.push( '&',node.nodeName,';');\n\t//case ENTITY_NODE:\n\t//case NOTATION_NODE:\n\tdefault:\n\t\tbuf.push('??',node.nodeName);\n\t}\n}\nfunction importNode(doc,node,deep){\n\tvar node2;\n\tswitch (node.nodeType) {\n\tcase ELEMENT_NODE:\n\t\tnode2 = node.cloneNode(false);\n\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see XML_ENTITIES\n * @see DOMParser.parseFromString\n * @see DOMImplementation.prototype.createHTMLDocument\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated use `HTML_ENTITIES` instead\n * @see HTML_ENTITIES\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","var NAMESPACE = require(\"./conventions\").NAMESPACE;\n\n//[4] \tNameStartChar\t ::= \t\":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]\n//[4a] \tNameChar\t ::= \tNameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]\n//[5] \tName\t ::= \tNameStartChar (NameChar)*\nvar nameStartChar = /[A-Z_a-z\\xC0-\\xD6\\xD8-\\xF6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]///\\u10000-\\uEFFFF\nvar nameChar = new RegExp(\"[\\\\-\\\\.0-9\"+nameStartChar.source.slice(1,-1)+\"\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040]\");\nvar tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\\:'+nameStartChar.source+nameChar.source+'*)?$');\n//var tagNamePattern = /^[a-zA-Z_][\\w\\-\\.]*(?:\\:[a-zA-Z_][\\w\\-\\.]*)?$/\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0;//tag name offerring\nvar S_ATTR = 1;//attr name offerring\nvar S_ATTR_SPACE=2;//attr name end and space offer\nvar S_EQ = 3;//=space?\nvar S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)\nvar S_ATTR_END = 5;//attr value end and no space(quot end)\nvar S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7;//closed el\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @param {string} message\n * @param {any?} locator Optional, can provide details about the location in the source\n * @constructor\n */\nfunction ParseError(message, locator) {\n\tthis.message = message\n\tthis.locator = locator\n\tif(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nParseError.prototype = new Error();\nParseError.prototype.name = ParseError.name\n\nfunction XMLReader(){\n\n}\n\nXMLReader.prototype = {\n\tparse:function(source,defaultNSMap,entityMap){\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap ,defaultNSMap = {})\n\t\tparse(source,defaultNSMap,entityMap,\n\t\t\t\tdomBuilder,this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t}\n}\nfunction parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10)\n\t\t\t\t, surrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\tfunction entityReplacer(a){\n\t\tvar k = a.slice(1,-1);\n\t\tif (Object.hasOwnProperty.call(entityMap, k)) {\n\t\t\treturn entityMap[k];\n\t\t}else if(k.charAt(0) === '#'){\n\t\t\treturn fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))\n\t\t}else{\n\t\t\terrorHandler.error('entity not found:'+a);\n\t\t\treturn a;\n\t\t}\n\t}\n\tfunction appendText(end){//has some bugs\n\t\tif(end>start){\n\t\t\tvar xt = source.substring(start,end).replace(/&#?\\w+;/g,entityReplacer);\n\t\t\tlocator&&position(start);\n\t\t\tdomBuilder.characters(xt,0,end-start);\n\t\t\tstart = end\n\t\t}\n\t}\n\tfunction position(p,m){\n\t\twhile(p>=lineEnd && (m = linePattern.exec(source))){\n\t\t\tlineStart = m.index;\n\t\t\tlineEnd = lineStart + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t\t//console.log('line++:',locator,startPos,endPos)\n\t\t}\n\t\tlocator.columnNumber = p-lineStart+1;\n\t}\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /.*(?:\\r\\n?|\\n)|.*$/g\n\tvar locator = domBuilder.locator;\n\n\tvar parseStack = [{currentNSMap:defaultNSMapCopy}]\n\tvar closeMap = {};\n\tvar start = 0;\n\twhile(true){\n\t\ttry{\n\t\t\tvar tagStart = source.indexOf('<',start);\n\t\t\tif(tagStart<0){\n\t\t\t\tif(!source.substr(start).match(/^\\s*$/)){\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t \t\t\tvar text = doc.createTextNode(source.substr(start));\n\t \t\t\tdoc.appendChild(text);\n\t \t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(tagStart>start){\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch(source.charAt(tagStart+1)){\n\t\t\tcase '/':\n\t\t\t\tvar end = source.indexOf('>',tagStart+3);\n\t\t\t\tvar tagName = source.substring(tagStart + 2, end).replace(/[ \\t\\n\\r]+$/g, '');\n\t\t\t\tvar config = parseStack.pop();\n\t\t\t\tif(end<0){\n\n\t \t\ttagName = source.substring(tagStart+2).replace(/[\\s<].*/,'');\n\t \t\terrorHandler.error(\"end tag name: \"+tagName+' is not complete:'+config.tagName);\n\t \t\tend = tagStart+1+tagName.length;\n\t \t}else if(tagName.match(/\\s\n\t\t\t\tlocator&&position(tagStart);\n\t\t\t\tend = parseInstruction(source,tagStart,domBuilder);\n\t\t\t\tbreak;\n\t\t\tcase '!':// start){\n\t\t\tstart = end;\n\t\t}else{\n\t\t\t//TODO: 这里有可能sax回退,有位置错误风险\n\t\t\tappendText(Math.max(tagStart,start)+1);\n\t\t}\n\t}\n}\nfunction copyLocator(f,t){\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);\n * @return end of the elementStartPart(end of elementEndPart for selfClosed el)\n */\nfunction parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){\n\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (el.attributeNames.hasOwnProperty(qname)) {\n\t\t\terrorHandler.fatalError('Attribute ' + qname + ' redefined')\n\t\t}\n\t\tel.addValue(\n\t\t\tqname,\n\t\t\t// @see https://www.w3.org/TR/xml/#AVNormalize\n\t\t\t// since the xmldom sax parser does not \"interpret\" DTD the following is not implemented:\n\t\t\t// - recursive replacement of (DTD) entity references\n\t\t\t// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA\n\t\t\tvalue.replace(/[\\t\\n\\r]/g, ' ').replace(/&#?\\w+;/g, entityReplacer),\n\t\t\tstartIndex\n\t\t)\n\t}\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG;//status\n\twhile(true){\n\t\tvar c = source.charAt(p);\n\t\tswitch(c){\n\t\tcase '=':\n\t\t\tif(s === S_ATTR){//attrName\n\t\t\t\tattrName = source.slice(start,p);\n\t\t\t\ts = S_EQ;\n\t\t\t}else if(s === S_ATTR_SPACE){\n\t\t\t\ts = S_EQ;\n\t\t\t}else{\n\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '\\'':\n\t\tcase '\"':\n\t\t\tif(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t){//equal\n\t\t\t\tif(s === S_ATTR){\n\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"')\n\t\t\t\t\tattrName = source.slice(start,p)\n\t\t\t\t}\n\t\t\t\tstart = p+1;\n\t\t\t\tp = source.indexOf(c,start)\n\t\t\t\tif(p>0){\n\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\taddAttribute(attrName, value, start-1);\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t}else{\n\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\tthrow new Error('attribute value no end \\''+c+'\\' match');\n\t\t\t\t}\n\t\t\t}else if(s == S_ATTR_NOQUOT_VALUE){\n\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\terrorHandler.warning('attribute \"'+attrName+'\" missed start quot('+c+')!!');\n\t\t\t\tstart = p+1;\n\t\t\t\ts = S_ATTR_END\n\t\t\t}else{\n\t\t\t\t//fatalError: no equal before\n\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '/':\n\t\t\tswitch(s){\n\t\t\tcase S_TAG:\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\tcase S_ATTR_END:\n\t\t\tcase S_TAG_SPACE:\n\t\t\tcase S_TAG_CLOSE:\n\t\t\t\ts =S_TAG_CLOSE;\n\t\t\t\tel.closed = true;\n\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\tcase S_ATTR:\n\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\tel.closed = true;\n\t\t\t\tbreak;\n\t\t\t//case S_EQ:\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"attribute invalid close char('/')\") // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase ''://end document\n\t\t\terrorHandler.error('unexpected end of input');\n\t\t\tif(s == S_TAG){\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\t}\n\t\t\treturn p;\n\t\tcase '>':\n\t\t\tswitch(s){\n\t\t\tcase S_TAG:\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\tcase S_ATTR_END:\n\t\t\tcase S_TAG_SPACE:\n\t\t\tcase S_TAG_CLOSE:\n\t\t\t\tbreak;//normal\n\t\t\tcase S_ATTR_NOQUOT_VALUE://Compatible state\n\t\t\tcase S_ATTR:\n\t\t\t\tvalue = source.slice(start,p);\n\t\t\t\tif(value.slice(-1) === '/'){\n\t\t\t\t\tel.closed = true;\n\t\t\t\t\tvalue = value.slice(0,-1)\n\t\t\t\t}\n\t\t\tcase S_ATTR_SPACE:\n\t\t\t\tif(s === S_ATTR_SPACE){\n\t\t\t\t\tvalue = attrName;\n\t\t\t\t}\n\t\t\t\tif(s == S_ATTR_NOQUOT_VALUE){\n\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed quot(\")!');\n\t\t\t\t\taddAttribute(attrName, value, start)\n\t\t\t\t}else{\n\t\t\t\t\tif(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){\n\t\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed value!! \"'+value+'\" instead!!')\n\t\t\t\t\t}\n\t\t\t\t\taddAttribute(value, value, start)\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase S_EQ:\n\t\t\t\tthrow new Error('attribute value missed!!');\n\t\t\t}\n//\t\t\tconsole.log(tagName,tagNamePattern,tagNamePattern.test(tagName))\n\t\t\treturn p;\n\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\tcase '\\u0080':\n\t\t\tc = ' ';\n\t\tdefault:\n\t\t\tif(c<= ' '){//space\n\t\t\t\tswitch(s){\n\t\t\t\tcase S_TAG:\n\t\t\t\t\tel.setTagName(source.slice(start,p));//tagName\n\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR:\n\t\t\t\t\tattrName = source.slice(start,p)\n\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tvar value = source.slice(start, p);\n\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed quot(\")!!');\n\t\t\t\t\taddAttribute(attrName, value, start)\n\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t//case S_EQ:\n\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t//\tvoid();break;\n\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t//ignore warning\n\t\t\t\t}\n\t\t\t}else{//not space\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\tswitch(s){\n\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\tvar tagName = el.tagName;\n\t\t\t\t\tif (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {\n\t\t\t\t\t\terrorHandler.warning('attribute \"'+attrName+'\" missed value!! \"'+attrName+'\" instead2!!')\n\t\t\t\t\t}\n\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\tstart = p;\n\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\terrorHandler.warning('attribute space is required\"'+attrName+'\"!!')\n\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\tstart = p;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_EQ:\n\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\tstart = p;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t}\n\t\t\t}\n\t\t}//end outer switch\n\t\t//console.log('p++',p)\n\t\tp++;\n\t}\n}\n/**\n * @return true if has new namespace define\n */\nfunction appendElement(el,domBuilder,currentNSMap){\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\t//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;\n\tvar i = el.length;\n\twhile(i--){\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif(nsp>0){\n\t\t\tvar prefix = a.prefix = qName.slice(0,nsp);\n\t\t\tvar localName = qName.slice(nsp+1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName\n\t\t}else{\n\t\t\tlocalName = qName;\n\t\t\tprefix = null\n\t\t\tnsPrefix = qName === 'xmlns' && ''\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName ;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif(nsPrefix !== false){//hack!!\n\t\t\tif(localNSMap == null){\n\t\t\t\tlocalNSMap = {}\n\t\t\t\t//console.log(currentNSMap,0)\n\t\t\t\t_copy(currentNSMap,currentNSMap={})\n\t\t\t\t//console.log(currentNSMap,1)\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value)\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile(i--){\n\t\ta = el[i];\n\t\tvar prefix = a.prefix;\n\t\tif(prefix){//no prefix attribute has no namespace\n\t\t\tif(prefix === 'xml'){\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}if(prefix !== 'xmlns'){\n\t\t\t\ta.uri = currentNSMap[prefix || '']\n\n\t\t\t\t//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif(nsp>0){\n\t\tprefix = el.prefix = tagName.slice(0,nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp+1);\n\t}else{\n\t\tprefix = null;//important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = el.uri = currentNSMap[prefix || ''];\n\tdomBuilder.startElement(ns,localName,tagName,el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif(el.closed){\n\t\tdomBuilder.endElement(ns,localName,tagName);\n\t\tif(localNSMap){\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}else{\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\nfunction parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){\n\tif(/^(?:script|textarea)$/i.test(tagName)){\n\t\tvar elEndStart = source.indexOf('',elStartEnd);\n\t\tvar text = source.substring(elStartEnd+1,elEndStart);\n\t\tif(/[&<]/.test(text)){\n\t\t\tif(/^script$/i.test(tagName)){\n\t\t\t\t//if(!/\\]\\]>/.test(text)){\n\t\t\t\t\t//lexHandler.startCDATA();\n\t\t\t\t\tdomBuilder.characters(text,0,text.length);\n\t\t\t\t\t//lexHandler.endCDATA();\n\t\t\t\t\treturn elEndStart;\n\t\t\t\t//}\n\t\t\t}//}else{//text area\n\t\t\t\ttext = text.replace(/&#?\\w+;/g,entityReplacer);\n\t\t\t\tdomBuilder.characters(text,0,text.length);\n\t\t\t\treturn elEndStart;\n\t\t\t//}\n\n\t\t}\n\t}\n\treturn elStartEnd+1;\n}\nfunction fixSelfClosed(source,elStartEnd,tagName,closeMap){\n\t//if(tagName in closeMap){\n\tvar pos = closeMap[tagName];\n\tif(pos == null){\n\t\t//console.log(tagName)\n\t\tpos = source.lastIndexOf('')\n\t\tif(pos',start+4);\n\t\t\t//append comment source.substring(4,end)//