Files
2022-11-04 13:24:24 +02:00

243 lines
360 KiB
JavaScript
Executable File

!function (a) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = a(); else if ("function" == typeof define && define.amd) define([], a); else { var b; b = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this, b.Everlive = a() } }(function () {
var define, module, exports; return function a(b, c, d) { function e(g, h) { if (!c[g]) { if (!b[g]) { var i = "function" == typeof require && require; if (!h && i) return i(g, !0); if (f) return f(g, !0); var j = new Error("Cannot find module '" + g + "'"); throw j.code = "MODULE_NOT_FOUND", j } var k = c[g] = { exports: {} }; b[g][0].call(k.exports, function (a) { var c = b[g][1][a]; return e(c ? c : a) }, k, k.exports, a, b, c, d) } return c[g].exports } for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]); return e }({
1: [function (a, b) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function c() { this._events = this._events || {}, this._maxListeners = this._maxListeners || void 0 } function d(a) { return "function" == typeof a } function e(a) { return "number" == typeof a } function f(a) { return "object" == typeof a && null !== a } function g(a) { return void 0 === a } b.exports = c, c.EventEmitter = c, c.prototype._events = void 0, c.prototype._maxListeners = void 0, c.defaultMaxListeners = 10, c.prototype.setMaxListeners = function (a) { if (!e(a) || 0 > a || isNaN(a)) throw TypeError("n must be a positive number"); return this._maxListeners = a, this }, c.prototype.emit = function (a) { var b, c, e, h, i, j; if (this._events || (this._events = {}), "error" === a && (!this._events.error || f(this._events.error) && !this._events.error.length)) { if (b = arguments[1], b instanceof Error) throw b; throw TypeError('Uncaught, unspecified "error" event.') } if (c = this._events[a], g(c)) return !1; if (d(c)) switch (arguments.length) { case 1: c.call(this); break; case 2: c.call(this, arguments[1]); break; case 3: c.call(this, arguments[1], arguments[2]); break; default: for (e = arguments.length, h = new Array(e - 1), i = 1; e > i; i++) h[i - 1] = arguments[i]; c.apply(this, h) } else if (f(c)) { for (e = arguments.length, h = new Array(e - 1), i = 1; e > i; i++) h[i - 1] = arguments[i]; for (j = c.slice(), e = j.length, i = 0; e > i; i++) j[i].apply(this, h) } return !0 }, c.prototype.addListener = function (a, b) { var e; if (!d(b)) throw TypeError("listener must be a function"); if (this._events || (this._events = {}), this._events.newListener && this.emit("newListener", a, d(b.listener) ? b.listener : b), this._events[a] ? f(this._events[a]) ? this._events[a].push(b) : this._events[a] = [this._events[a], b] : this._events[a] = b, f(this._events[a]) && !this._events[a].warned) { var e; e = g(this._maxListeners) ? c.defaultMaxListeners : this._maxListeners, e && e > 0 && this._events[a].length > e && (this._events[a].warned = !0, console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", this._events[a].length), "function" == typeof console.trace && console.trace()) } return this }, c.prototype.on = c.prototype.addListener, c.prototype.once = function (a, b) { function c() { this.removeListener(a, c), e || (e = !0, b.apply(this, arguments)) } if (!d(b)) throw TypeError("listener must be a function"); var e = !1; return c.listener = b, this.on(a, c), this }, c.prototype.removeListener = function (a, b) { var c, e, g, h; if (!d(b)) throw TypeError("listener must be a function"); if (!this._events || !this._events[a]) return this; if (c = this._events[a], g = c.length, e = -1, c === b || d(c.listener) && c.listener === b) delete this._events[a], this._events.removeListener && this.emit("removeListener", a, b); else if (f(c)) { for (h = g; h-- > 0;) if (c[h] === b || c[h].listener && c[h].listener === b) { e = h; break } if (0 > e) return this; 1 === c.length ? (c.length = 0, delete this._events[a]) : c.splice(e, 1), this._events.removeListener && this.emit("removeListener", a, b) } return this }, c.prototype.removeAllListeners = function (a) { var b, c; if (!this._events) return this; if (!this._events.removeListener) return 0 === arguments.length ? this._events = {} : this._events[a] && delete this._events[a], this; if (0 === arguments.length) { for (b in this._events) "removeListener" !== b && this.removeAllListeners(b); return this.removeAllListeners("removeListener"), this._events = {}, this } if (c = this._events[a], d(c)) this.removeListener(a, c); else for (; c.length;) this.removeListener(a, c[c.length - 1]); return delete this._events[a], this }, c.prototype.listeners = function (a) { var b; return b = this._events && this._events[a] ? d(this._events[a]) ? [this._events[a]] : this._events[a].slice() : [] }, c.listenerCount = function (a, b) { var c; return c = a._events && a._events[b] ? d(a._events[b]) ? 1 : a._events[b].length : 0 }
}, {}], 2: [function (a, b) { b.exports = "function" == typeof Object.create ? function (a, b) { a.super_ = b, a.prototype = Object.create(b.prototype, { constructor: { value: a, enumerable: !1, writable: !0, configurable: !0 } }) } : function (a, b) { a.super_ = b; var c = function () { }; c.prototype = b.prototype, a.prototype = new c, a.prototype.constructor = a } }, {}], 3: [function (a, b, c) {
(function (a) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function b(a, b) { for (var c = 0, d = a.length - 1; d >= 0; d--) { var e = a[d]; "." === e ? a.splice(d, 1) : ".." === e ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--) } if (b) for (; c--; c) a.unshift(".."); return a } function d(a, b) { if (a.filter) return a.filter(b); for (var c = [], d = 0; d < a.length; d++) b(a[d], d, a) && c.push(a[d]); return c } var e = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/, f = function (a) { return e.exec(a).slice(1) }; c.resolve = function () { for (var c = "", e = !1, f = arguments.length - 1; f >= -1 && !e; f--) { var g = f >= 0 ? arguments[f] : a.cwd(); if ("string" != typeof g) throw new TypeError("Arguments to path.resolve must be strings"); g && (c = g + "/" + c, e = "/" === g.charAt(0)) } return c = b(d(c.split("/"), function (a) { return !!a }), !e).join("/"), (e ? "/" : "") + c || "." }, c.normalize = function (a) { var e = c.isAbsolute(a), f = "/" === g(a, -1); return a = b(d(a.split("/"), function (a) { return !!a }), !e).join("/"), a || e || (a = "."), a && f && (a += "/"), (e ? "/" : "") + a }, c.isAbsolute = function (a) { return "/" === a.charAt(0) }, c.join = function () { var a = Array.prototype.slice.call(arguments, 0); return c.normalize(d(a, function (a) { if ("string" != typeof a) throw new TypeError("Arguments to path.join must be strings"); return a }).join("/")) }, c.relative = function (a, b) { function d(a) { for (var b = 0; b < a.length && "" === a[b]; b++); for (var c = a.length - 1; c >= 0 && "" === a[c]; c--); return b > c ? [] : a.slice(b, c - b + 1) } a = c.resolve(a).substr(1), b = c.resolve(b).substr(1); for (var e = d(a.split("/")), f = d(b.split("/")), g = Math.min(e.length, f.length), h = g, i = 0; g > i; i++) if (e[i] !== f[i]) { h = i; break } for (var j = [], i = h; i < e.length; i++) j.push(".."); return j = j.concat(f.slice(h)), j.join("/") }, c.sep = "/", c.delimiter = ":", c.dirname = function (a) { var b = f(a), c = b[0], d = b[1]; return c || d ? (d && (d = d.substr(0, d.length - 1)), c + d) : "." }, c.basename = function (a, b) { var c = f(a)[2]; return b && c.substr(-1 * b.length) === b && (c = c.substr(0, c.length - b.length)), c }, c.extname = function (a) { return f(a)[3] }; var g = "b" === "ab".substr(-1) ? function (a, b, c) { return a.substr(b, c) } : function (a, b, c) { return 0 > b && (b = a.length + b), a.substr(b, c) }
}).call(this, a("_process"))
}, { _process: 4 }], 4: [function (a, b) { function c() { j = !1, g.length ? i = g.concat(i) : k = -1, i.length && d() } function d() { if (!j) { var a = setTimeout(c); j = !0; for (var b = i.length; b;) { for (g = i, i = []; ++k < b;) g && g[k].run(); k = -1, b = i.length } g = null, j = !1, clearTimeout(a) } } function e(a, b) { this.fun = a, this.array = b } function f() { } var g, h = b.exports = {}, i = [], j = !1, k = -1; h.nextTick = function (a) { var b = new Array(arguments.length - 1); if (arguments.length > 1) for (var c = 1; c < arguments.length; c++) b[c - 1] = arguments[c]; i.push(new e(a, b)), 1 !== i.length || j || setTimeout(d, 0) }, e.prototype.run = function () { this.fun.apply(null, this.array) }, h.title = "browser", h.browser = !0, h.env = {}, h.argv = [], h.version = "", h.versions = {}, h.on = f, h.addListener = f, h.once = f, h.off = f, h.removeListener = f, h.removeAllListeners = f, h.emit = f, h.binding = function () { throw new Error("process.binding is not supported") }, h.cwd = function () { return "/" }, h.chdir = function () { throw new Error("process.chdir is not supported") }, h.umask = function () { return 0 } }, {}], 5: [function (a, b) { b.exports = function (a) { return a && "object" == typeof a && "function" == typeof a.copy && "function" == typeof a.fill && "function" == typeof a.readUInt8 } }, {}], 6: [function (a, b, c) {
(function (b, d) {
function e(a, b) { var d = { seen: [], stylize: g }; return arguments.length >= 3 && (d.depth = arguments[2]), arguments.length >= 4 && (d.colors = arguments[3]), p(b) ? d.showHidden = b : b && c._extend(d, b), v(d.showHidden) && (d.showHidden = !1), v(d.depth) && (d.depth = 2), v(d.colors) && (d.colors = !1), v(d.customInspect) && (d.customInspect = !0), d.colors && (d.stylize = f), i(d, a, d.depth) } function f(a, b) { var c = e.styles[b]; return c ? "[" + e.colors[c][0] + "m" + a + "[" + e.colors[c][1] + "m" : a } function g(a) { return a } function h(a) { var b = {}; return a.forEach(function (a) { b[a] = !0 }), b } function i(a, b, d) { if (a.customInspect && b && A(b.inspect) && b.inspect !== c.inspect && (!b.constructor || b.constructor.prototype !== b)) { var e = b.inspect(d, a); return t(e) || (e = i(a, e, d)), e } var f = j(a, b); if (f) return f; var g = Object.keys(b), p = h(g); if (a.showHidden && (g = Object.getOwnPropertyNames(b)), z(b) && (g.indexOf("message") >= 0 || g.indexOf("description") >= 0)) return k(b); if (0 === g.length) { if (A(b)) { var q = b.name ? ": " + b.name : ""; return a.stylize("[Function" + q + "]", "special") } if (w(b)) return a.stylize(RegExp.prototype.toString.call(b), "regexp"); if (y(b)) return a.stylize(Date.prototype.toString.call(b), "date"); if (z(b)) return k(b) } var r = "", s = !1, u = ["{", "}"]; if (o(b) && (s = !0, u = ["[", "]"]), A(b)) { var v = b.name ? ": " + b.name : ""; r = " [Function" + v + "]" } if (w(b) && (r = " " + RegExp.prototype.toString.call(b)), y(b) && (r = " " + Date.prototype.toUTCString.call(b)), z(b) && (r = " " + k(b)), 0 === g.length && (!s || 0 == b.length)) return u[0] + r + u[1]; if (0 > d) return w(b) ? a.stylize(RegExp.prototype.toString.call(b), "regexp") : a.stylize("[Object]", "special"); a.seen.push(b); var x; return x = s ? l(a, b, d, p, g) : g.map(function (c) { return m(a, b, d, p, c, s) }), a.seen.pop(), n(x, r, u) } function j(a, b) { if (v(b)) return a.stylize("undefined", "undefined"); if (t(b)) { var c = "'" + JSON.stringify(b).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; return a.stylize(c, "string") } return s(b) ? a.stylize("" + b, "number") : p(b) ? a.stylize("" + b, "boolean") : q(b) ? a.stylize("null", "null") : void 0 } function k(a) { return "[" + Error.prototype.toString.call(a) + "]" } function l(a, b, c, d, e) { for (var f = [], g = 0, h = b.length; h > g; ++g) f.push(F(b, String(g)) ? m(a, b, c, d, String(g), !0) : ""); return e.forEach(function (e) { e.match(/^\d+$/) || f.push(m(a, b, c, d, e, !0)) }), f } function m(a, b, c, d, e, f) { var g, h, j; if (j = Object.getOwnPropertyDescriptor(b, e) || { value: b[e] }, j.get ? h = j.set ? a.stylize("[Getter/Setter]", "special") : a.stylize("[Getter]", "special") : j.set && (h = a.stylize("[Setter]", "special")), F(d, e) || (g = "[" + e + "]"), h || (a.seen.indexOf(j.value) < 0 ? (h = q(c) ? i(a, j.value, null) : i(a, j.value, c - 1), h.indexOf("\n") > -1 && (h = f ? h.split("\n").map(function (a) { return " " + a }).join("\n").substr(2) : "\n" + h.split("\n").map(function (a) { return " " + a }).join("\n"))) : h = a.stylize("[Circular]", "special")), v(g)) { if (f && e.match(/^\d+$/)) return h; g = JSON.stringify("" + e), g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (g = g.substr(1, g.length - 2), g = a.stylize(g, "name")) : (g = g.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), g = a.stylize(g, "string")) } return g + ": " + h } function n(a, b, c) { var d = 0, e = a.reduce(function (a, b) { return d++, b.indexOf("\n") >= 0 && d++, a + b.replace(/\u001b\[\d\d?m/g, "").length + 1 }, 0); return e > 60 ? c[0] + ("" === b ? "" : b + "\n ") + " " + a.join(",\n ") + " " + c[1] : c[0] + b + " " + a.join(", ") + " " + c[1] } function o(a) { return Array.isArray(a) } function p(a) { return "boolean" == typeof a } function q(a) { return null === a } function r(a) { return null == a } function s(a) { return "number" == typeof a } function t(a) { return "string" == typeof a } function u(a) { return "symbol" == typeof a } function v(a) { return void 0 === a } function w(a) { return x(a) && "[object RegExp]" === C(a) } function x(a) { return "object" == typeof a && null !== a } function y(a) { return x(a) && "[object Date]" === C(a) } function z(a) { return x(a) && ("[object Error]" === C(a) || a instanceof Error) } function A(a) { return "function" == typeof a } function B(a) { return null === a || "boolean" == typeof a || "number" == typeof a || "string" == typeof a || "symbol" == typeof a || "undefined" == typeof a } function C(a) { return Object.prototype.toString.call(a) } function D(a) { return 10 > a ? "0" + a.toString(10) : a.toString(10) } function E() { var a = new Date, b = [D(a.getHours()), D(a.getMinutes()), D(a.getSeconds())].join(":"); return [a.getDate(), J[a.getMonth()], b].join(" ") } function F(a, b) { return Object.prototype.hasOwnProperty.call(a, b) }
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var G = /%[sdj%]/g; c.format = function (a) { if (!t(a)) { for (var b = [], c = 0; c < arguments.length; c++) b.push(e(arguments[c])); return b.join(" ") } for (var c = 1, d = arguments, f = d.length, g = String(a).replace(G, function (a) { if ("%%" === a) return "%"; if (c >= f) return a; switch (a) { case "%s": return String(d[c++]); case "%d": return Number(d[c++]); case "%j": try { return JSON.stringify(d[c++]) } catch (b) { return "[Circular]" } default: return a } }), h = d[c]; f > c; h = d[++c]) g += q(h) || !x(h) ? " " + h : " " + e(h); return g }, c.deprecate = function (a, e) { function f() { if (!g) { if (b.throwDeprecation) throw new Error(e); b.traceDeprecation ? console.trace(e) : console.error(e), g = !0 } return a.apply(this, arguments) } if (v(d.process)) return function () { return c.deprecate(a, e).apply(this, arguments) }; if (b.noDeprecation === !0) return a; var g = !1; return f }; var H, I = {}; c.debuglog = function (a) { if (v(H) && (H = b.env.NODE_DEBUG || ""), a = a.toUpperCase(), !I[a]) if (new RegExp("\\b" + a + "\\b", "i").test(H)) { var d = b.pid; I[a] = function () { var b = c.format.apply(c, arguments); console.error("%s %d: %s", a, d, b) } } else I[a] = function () { }; return I[a] }, c.inspect = e, e.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, e.styles = { special: "cyan", number: "yellow", "boolean": "yellow", undefined: "grey", "null": "bold", string: "green", date: "magenta", regexp: "red" }, c.isArray = o, c.isBoolean = p, c.isNull = q, c.isNullOrUndefined = r, c.isNumber = s, c.isString = t, c.isSymbol = u, c.isUndefined = v, c.isRegExp = w, c.isObject = x, c.isDate = y, c.isError = z, c.isFunction = A, c.isPrimitive = B, c.isBuffer = a("./support/isBuffer"); var J = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; c.log = function () { console.log("%s - %s", E(), c.format.apply(c, arguments)) }, c.inherits = a("inherits"), c._extend = function (a, b) { if (!b || !x(b)) return a; for (var c = Object.keys(b), d = c.length; d--;) a[c[d]] = b[c[d]]; return a }
}).call(this, a("_process"), "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {})
}, { "./support/isBuffer": 5, _process: 4, inherits: 2 }], 7: [function (a, b) { var c = "undefined" != typeof JSON ? JSON : a("jsonify"); b.exports = function (a, b) { b || (b = {}), "function" == typeof b && (b = { cmp: b }); var f = b.space || ""; "number" == typeof f && (f = Array(f + 1).join(" ")); var g = "boolean" == typeof b.cycles ? b.cycles : !1, h = b.replacer || function (a, b) { return b }, i = b.cmp && function (a) { return function (b) { return function (c, d) { var e = { key: c, value: b[c] }, f = { key: d, value: b[d] }; return a(e, f) } } }(b.cmp), j = []; return function k(a, b, l, m) { var n = f ? "\n" + new Array(m + 1).join(f) : "", o = f ? ": " : ":"; if (l && l.toJSON && "function" == typeof l.toJSON && (l = l.toJSON()), l = h.call(a, b, l), void 0 !== l) { if ("object" != typeof l || null === l) return c.stringify(l); if (d(l)) { for (var p = [], q = 0; q < l.length; q++) { var r = k(l, q, l[q], m + 1) || c.stringify(null); p.push(n + f + r) } return "[" + p.join(",") + n + "]" } if (-1 !== j.indexOf(l)) { if (g) return c.stringify("__cycle__"); throw new TypeError("Converting circular structure to JSON") } j.push(l); for (var s = e(l).sort(i && i(l)), p = [], q = 0; q < s.length; q++) { var b = s[q], t = k(l, b, l[b], m + 1); if (t) { var u = c.stringify(b) + o + t; p.push(n + f + u) } } return "{" + p.join(",") + n + "}" } }({ "": a }, "", a, 0) }; var d = Array.isArray || function (a) { return "[object Array]" === {}.toString.call(a) }, e = Object.keys || function (a) { var b = Object.prototype.hasOwnProperty || function () { return !0 }, c = []; for (var d in a) b.call(a, d) && c.push(d); return c } }, { jsonify: 8 }], 8: [function (a, b, c) { c.parse = a("./lib/parse"), c.stringify = a("./lib/stringify") }, { "./lib/parse": 9, "./lib/stringify": 10 }], 9: [function (a, b) { var c, d, e, f, g = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: " " }, h = function (a) { throw { name: "SyntaxError", message: a, at: c, text: e } }, i = function (a) { return a && a !== d && h("Expected '" + a + "' instead of '" + d + "'"), d = e.charAt(c), c += 1, d }, j = function () { var a, b = ""; for ("-" === d && (b = "-", i("-")) ; d >= "0" && "9" >= d;) b += d, i(); if ("." === d) for (b += "."; i() && d >= "0" && "9" >= d;) b += d; if ("e" === d || "E" === d) for (b += d, i(), ("-" === d || "+" === d) && (b += d, i()) ; d >= "0" && "9" >= d;) b += d, i(); return a = +b, isFinite(a) ? a : void h("Bad number") }, k = function () { var a, b, c, e = ""; if ('"' === d) for (; i() ;) { if ('"' === d) return i(), e; if ("\\" === d) if (i(), "u" === d) { for (c = 0, b = 0; 4 > b && (a = parseInt(i(), 16), isFinite(a)) ; b += 1) c = 16 * c + a; e += String.fromCharCode(c) } else { if ("string" != typeof g[d]) break; e += g[d] } else e += d } h("Bad string") }, l = function () { for (; d && " " >= d;) i() }, m = function () { switch (d) { case "t": return i("t"), i("r"), i("u"), i("e"), !0; case "f": return i("f"), i("a"), i("l"), i("s"), i("e"), !1; case "n": return i("n"), i("u"), i("l"), i("l"), null } h("Unexpected '" + d + "'") }, n = function () { var a = []; if ("[" === d) { if (i("["), l(), "]" === d) return i("]"), a; for (; d;) { if (a.push(f()), l(), "]" === d) return i("]"), a; i(","), l() } } h("Bad array") }, o = function () { var a, b = {}; if ("{" === d) { if (i("{"), l(), "}" === d) return i("}"), b; for (; d;) { if (a = k(), l(), i(":"), Object.hasOwnProperty.call(b, a) && h('Duplicate key "' + a + '"'), b[a] = f(), l(), "}" === d) return i("}"), b; i(","), l() } } h("Bad object") }; f = function () { switch (l(), d) { case "{": return o(); case "[": return n(); case '"': return k(); case "-": return j(); default: return d >= "0" && "9" >= d ? j() : m() } }, b.exports = function (a, b) { var g; return e = a, c = 0, d = " ", g = f(), l(), d && h("Syntax error"), "function" == typeof b ? function i(a, c) { var d, e, f = a[c]; if (f && "object" == typeof f) for (d in f) Object.prototype.hasOwnProperty.call(f, d) && (e = i(f, d), void 0 !== e ? f[d] = e : delete f[d]); return b.call(a, c, f) }({ "": g }, "") : g } }, {}], 10: [function (a, b) { function c(a) { return h.lastIndex = 0, h.test(a) ? '"' + a.replace(h, function (a) { var b = i[a]; return "string" == typeof b ? b : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + a + '"' } function d(a, b) { var h, i, j, k, l, m = e, n = b[a]; switch (n && "object" == typeof n && "function" == typeof n.toJSON && (n = n.toJSON(a)), "function" == typeof g && (n = g.call(b, a, n)), typeof n) { case "string": return c(n); case "number": return isFinite(n) ? String(n) : "null"; case "boolean": case "null": return String(n); case "object": if (!n) return "null"; if (e += f, l = [], "[object Array]" === Object.prototype.toString.apply(n)) { for (k = n.length, h = 0; k > h; h += 1) l[h] = d(h, n) || "null"; return j = 0 === l.length ? "[]" : e ? "[\n" + e + l.join(",\n" + e) + "\n" + m + "]" : "[" + l.join(",") + "]", e = m, j } if (g && "object" == typeof g) for (k = g.length, h = 0; k > h; h += 1) i = g[h], "string" == typeof i && (j = d(i, n), j && l.push(c(i) + (e ? ": " : ":") + j)); else for (i in n) Object.prototype.hasOwnProperty.call(n, i) && (j = d(i, n), j && l.push(c(i) + (e ? ": " : ":") + j)); return j = 0 === l.length ? "{}" : e ? "{\n" + e + l.join(",\n" + e) + "\n" + m + "}" : "{" + l.join(",") + "}", e = m, j } } var e, f, g, h = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, i = { "\b": "\\b", " ": "\\t", "\n": "\\n", "\f": "\\f", "\r": "\\r", '"': '\\"', "\\": "\\\\" }; b.exports = function (a, b, c) { var h; if (e = "", f = "", "number" == typeof c) for (h = 0; c > h; h += 1) f += " "; else "string" == typeof c && (f = c); if (g = b, b && "function" != typeof b && ("object" != typeof b || "number" != typeof b.length)) throw new Error("JSON.stringify"); return d("", { "": a }) } }, {}], 11: [function (a, b, c) {/**
* This script gives you the zone info key representing your device's time zone setting.
*
* @name jsTimezoneDetect
* @version 1.0.5
* @author Jon Nylander
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
*
* For usage and examples, visit:
* http://pellepim.bitbucket.org/jstz/
*
* Copyright (c) Jon Nylander
*/
!function (a) { var b = function () { "use strict"; var a = "s", c = function (a) { var b = -a.getTimezoneOffset(); return null !== b ? b : 0 }, d = function (a, b, c) { var d = new Date; return void 0 !== a && d.setFullYear(a), d.setMonth(b), d.setDate(c), d }, e = function (a) { return c(d(a, 0, 2)) }, f = function (a) { return c(d(a, 5, 2)) }, g = function (a) { var b = a.getMonth() > 7, d = b ? f(a.getFullYear()) : e(a.getFullYear()), g = c(a), h = 0 > d, i = d - g; return h || b ? 0 !== i : 0 > i }, h = function () { var b = e(), c = f(), d = b - c; return 0 > d ? b + ",1" : d > 0 ? c + ",1," + a : b + ",0" }, i = function () { var a = h(); return new b.TimeZone(b.olson.timezones[a]) }, j = function (a) { var b = new Date(2010, 6, 15, 1, 0, 0, 0), c = { "America/Denver": new Date(2011, 2, 13, 3, 0, 0, 0), "America/Mazatlan": new Date(2011, 3, 3, 3, 0, 0, 0), "America/Chicago": new Date(2011, 2, 13, 3, 0, 0, 0), "America/Mexico_City": new Date(2011, 3, 3, 3, 0, 0, 0), "America/Asuncion": new Date(2012, 9, 7, 3, 0, 0, 0), "America/Santiago": new Date(2012, 9, 3, 3, 0, 0, 0), "America/Campo_Grande": new Date(2012, 9, 21, 5, 0, 0, 0), "America/Montevideo": new Date(2011, 9, 2, 3, 0, 0, 0), "America/Sao_Paulo": new Date(2011, 9, 16, 5, 0, 0, 0), "America/Los_Angeles": new Date(2011, 2, 13, 8, 0, 0, 0), "America/Santa_Isabel": new Date(2011, 3, 5, 8, 0, 0, 0), "America/Havana": new Date(2012, 2, 10, 2, 0, 0, 0), "America/New_York": new Date(2012, 2, 10, 7, 0, 0, 0), "Europe/Helsinki": new Date(2013, 2, 31, 5, 0, 0, 0), "Pacific/Auckland": new Date(2011, 8, 26, 7, 0, 0, 0), "America/Halifax": new Date(2011, 2, 13, 6, 0, 0, 0), "America/Goose_Bay": new Date(2011, 2, 13, 2, 1, 0, 0), "America/Miquelon": new Date(2011, 2, 13, 5, 0, 0, 0), "America/Godthab": new Date(2011, 2, 27, 1, 0, 0, 0), "Europe/Moscow": b, "Asia/Amman": new Date(2013, 2, 29, 1, 0, 0, 0), "Asia/Beirut": new Date(2013, 2, 31, 2, 0, 0, 0), "Asia/Damascus": new Date(2013, 3, 6, 2, 0, 0, 0), "Asia/Jerusalem": new Date(2013, 2, 29, 5, 0, 0, 0), "Asia/Yekaterinburg": b, "Asia/Omsk": b, "Asia/Krasnoyarsk": b, "Asia/Irkutsk": b, "Asia/Yakutsk": b, "Asia/Vladivostok": b, "Asia/Baku": new Date(2013, 2, 31, 4, 0, 0), "Asia/Yerevan": new Date(2013, 2, 31, 3, 0, 0), "Asia/Kamchatka": b, "Asia/Gaza": new Date(2010, 2, 27, 4, 0, 0), "Africa/Cairo": new Date(2010, 4, 1, 3, 0, 0), "Europe/Minsk": b, "Pacific/Apia": new Date(2010, 10, 1, 1, 0, 0, 0), "Pacific/Fiji": new Date(2010, 11, 1, 0, 0, 0), "Australia/Perth": new Date(2008, 10, 1, 1, 0, 0, 0) }; return c[a] }; return { determine: i, date_is_dst: g, dst_start_for: j } }(); b.TimeZone = function (a) { "use strict"; var c = { "America/Denver": ["America/Denver", "America/Mazatlan"], "America/Chicago": ["America/Chicago", "America/Mexico_City"], "America/Santiago": ["America/Santiago", "America/Asuncion", "America/Campo_Grande"], "America/Montevideo": ["America/Montevideo", "America/Sao_Paulo"], "Asia/Beirut": ["Asia/Amman", "Asia/Jerusalem", "Asia/Beirut", "Europe/Helsinki", "Asia/Damascus"], "Pacific/Auckland": ["Pacific/Auckland", "Pacific/Fiji"], "America/Los_Angeles": ["America/Los_Angeles", "America/Santa_Isabel"], "America/New_York": ["America/Havana", "America/New_York"], "America/Halifax": ["America/Goose_Bay", "America/Halifax"], "America/Godthab": ["America/Miquelon", "America/Godthab"], "Asia/Dubai": ["Europe/Moscow"], "Asia/Dhaka": ["Asia/Yekaterinburg"], "Asia/Jakarta": ["Asia/Omsk"], "Asia/Shanghai": ["Asia/Krasnoyarsk", "Australia/Perth"], "Asia/Tokyo": ["Asia/Irkutsk"], "Australia/Brisbane": ["Asia/Yakutsk"], "Pacific/Noumea": ["Asia/Vladivostok"], "Pacific/Tarawa": ["Asia/Kamchatka", "Pacific/Fiji"], "Pacific/Tongatapu": ["Pacific/Apia"], "Asia/Baghdad": ["Europe/Minsk"], "Asia/Baku": ["Asia/Yerevan", "Asia/Baku"], "Africa/Johannesburg": ["Asia/Gaza", "Africa/Cairo"] }, d = a, e = function () { for (var a = c[d], e = a.length, f = 0, g = a[0]; e > f; f += 1) if (g = a[f], b.date_is_dst(b.dst_start_for(g))) return void (d = g) }, f = function () { return "undefined" != typeof c[d] }; return f() && e(), { name: function () { return d } } }, b.olson = {}, b.olson.timezones = { "-720,0": "Pacific/Majuro", "-660,0": "Pacific/Pago_Pago", "-600,1": "America/Adak", "-600,0": "Pacific/Honolulu", "-570,0": "Pacific/Marquesas", "-540,0": "Pacific/Gambier", "-540,1": "America/Anchorage", "-480,1": "America/Los_Angeles", "-480,0": "Pacific/Pitcairn", "-420,0": "America/Phoenix", "-420,1": "America/Denver", "-360,0": "America/Guatemala", "-360,1": "America/Chicago", "-360,1,s": "Pacific/Easter", "-300,0": "America/Bogota", "-300,1": "America/New_York", "-270,0": "America/Caracas", "-240,1": "America/Halifax", "-240,0": "America/Santo_Domingo", "-240,1,s": "America/Santiago", "-210,1": "America/St_Johns", "-180,1": "America/Godthab", "-180,0": "America/Argentina/Buenos_Aires", "-180,1,s": "America/Montevideo", "-120,0": "America/Noronha", "-120,1": "America/Noronha", "-60,1": "Atlantic/Azores", "-60,0": "Atlantic/Cape_Verde", "0,0": "UTC", "0,1": "Europe/London", "60,1": "Europe/Berlin", "60,0": "Africa/Lagos", "60,1,s": "Africa/Windhoek", "120,1": "Asia/Beirut", "120,0": "Africa/Johannesburg", "180,0": "Asia/Baghdad", "180,1": "Europe/Moscow", "210,1": "Asia/Tehran", "240,0": "Asia/Dubai", "240,1": "Asia/Baku", "270,0": "Asia/Kabul", "300,1": "Asia/Yekaterinburg", "300,0": "Asia/Karachi", "330,0": "Asia/Kolkata", "345,0": "Asia/Kathmandu", "360,0": "Asia/Dhaka", "360,1": "Asia/Omsk", "390,0": "Asia/Rangoon", "420,1": "Asia/Krasnoyarsk", "420,0": "Asia/Jakarta", "480,0": "Asia/Shanghai", "480,1": "Asia/Irkutsk", "525,0": "Australia/Eucla", "525,1,s": "Australia/Eucla", "540,1": "Asia/Yakutsk", "540,0": "Asia/Tokyo", "570,0": "Australia/Darwin", "570,1,s": "Australia/Adelaide", "600,0": "Australia/Brisbane", "600,1": "Asia/Vladivostok", "600,1,s": "Australia/Sydney", "630,1,s": "Australia/Lord_Howe", "660,1": "Asia/Kamchatka", "660,0": "Pacific/Noumea", "690,0": "Pacific/Norfolk", "720,1,s": "Pacific/Auckland", "720,0": "Pacific/Tarawa", "765,1,s": "Pacific/Chatham", "780,0": "Pacific/Tongatapu", "780,1,s": "Pacific/Apia", "840,0": "Pacific/Kiritimati" }, "undefined" != typeof c ? c.jstz = b : a.jstz = b }(this)
}, {}], 12: [function (a, b, c) { !function (d, e) { "use strict"; function f(a) { for (var b = 0; b < u.length; b++) if (u[b](a)) return !0; return !1 } function g(a) { if (f(a)) return p.isRegExp(a) ? { $regex: a } : { $eq: a }; if (p.isObject(a)) { var b = p.keys(a), c = 0 === p.intersection(k(P), b).length; if (c) return { $eq: a }; if (p.contains(b, "$regex")) { var d = a.$regex, e = a.$options || "", g = ""; p.isString(d) && (g += d.ignoreCase || e.indexOf("i") >= 0 ? "i" : "", g += d.multiline || e.indexOf("m") >= 0 ? "m" : "", g += d.global || e.indexOf("g") >= 0 ? "g" : "", d = new RegExp(d, g)), a.$regex = d, delete a.$options } } return a } function h(a, b) { return p.result(a, b) } function i(a, b) { if (!b) return e; for (var c, d = b.split("."), f = a, g = 0; g < d.length; g++) { if (c = null === d[g].match(/^\d+$/), c && p.isArray(f)) { var j = []; p.each(f, function (a) { j.push(i(a, d[g])) }), f = j } else f = h(f, d[g]); if (f === e) break } return f } function j(a, b) { return new Array(Math.max(b - String(a).length + 1, 0)).join("0") + a } function k(a) { return p.keys(U[a]) } function l(a, b) { var c = { keys: [], groups: [] }; if (p.each(a, function (a) { var d = b(a), e = -1; if (p.isObject(d)) { for (var f = 0; f < c.keys.length; f++) if (p.isEqual(d, c.keys[f])) { e = f; break } } else e = p.indexOf(c.keys, d); e > -1 ? c.groups[e].push(a) : (c.keys.push(d), c.groups.push([a])) }), c.keys.length !== c.groups.length) throw new Error("assert groupBy(): keys.length !== groups.length"); return c } function m(a, b, c) { if (p.contains(k(Q), b)) return D[b](a, c); if (p.isObject(c)) { var d = {}; for (var f in c) if (c.hasOwnProperty(f) && (d[f] = m(a, f, c[f]), p.contains(k(Q), f))) { if (d = d[f], p.keys(c).length > 1) throw new Error("Invalid $group expression '" + JSON.stringify(c) + "'"); break } return d } return e } function n(a, b, c) { if (p.contains(k(R), c)) return O[c](a, b); if (p.isString(b) && b.length > 0 && "$" === b[0]) return i(a, b.slice(1)); var d; if (f(b)) return b; if (p.isArray(b)) d = p.map(b, function (b) { return n(a, b, null) }); else if (p.isObject(b)) { d = {}; for (var e in b) if (b.hasOwnProperty(e) && (d[e] = n(a, b[e], e), p.contains(k(R), e))) { if (d = d[e], p.keys(b).length > 1) throw new Error("Invalid aggregation expression '" + JSON.stringify(b) + "'"); break } } return d } var o, p, q = {}; q.VERSION = "0.6.2", null != d && (o = d.Mingo), q.noConflict = function () { return d.Mingo = o, q }; var r = Boolean("undefined" != typeof android && android && android.widget && android.widget.Button || "undefined" != typeof UIButton && UIButton), s = "undefined" != typeof c && "undefined" != typeof a && "undefined" == typeof window && !r, t = "undefined" != typeof c && "undefined" != typeof a; s || r || t ? ("undefined" != typeof b && (b.exports = q), p = a("underscore")) : (d.Mingo = q, p = d._); var u = [p.isString, p.isBoolean, p.isNumber, p.isDate, p.isNull, p.isRegExp], v = { key: "_id" }; if (q.setup = function (a) { p.extend(v, a || {}) }, q.Query = function (a, b) { return this instanceof q.Query ? (this._criteria = a, this._projection = b, this._compiled = [], void this._compile()) : new q.Query(a, b) }, q.Query.prototype = { _compile: function () { if (!p.isEmpty(this._criteria)) { if (p.isArray(this._criteria) || p.isFunction(this._criteria) || !p.isObject(this._criteria)) throw new Error("Invalid type for criteria"); for (var a in this._criteria) if (this._criteria.hasOwnProperty(a)) { var b = this._criteria[a]; if (p.contains(["$and", "$or", "$nor", "$where"], a)) this._processOperator(a, a, b); else { b = g(b); for (var c in b) b.hasOwnProperty(c) && this._processOperator(a, c, b[c]) } } } }, _processOperator: function (a, b, c) { if (!p.contains(k(P), b)) throw new Error("Invalid query operator '" + b + "' detected"); this._compiled.push(z[b](a, c)) }, test: function (a) { for (var b = 0; b < this._compiled.length; b++) if (!this._compiled[b].test(a)) return !1; return !0 }, find: function (a, b) { return new q.Cursor(a, this, b) }, remove: function (a) { for (var b = [], c = 0; c < a.length; c++) this.test(a[c]) || b.push(a[c]); return b } }, s) { var w = a("stream").Transform, x = a("util"); q.Query.prototype.stream = function (a) { return new q.Stream(this, a) }, q.Stream = function (a, b) { return this instanceof q.Stream ? (b = b || {}, p.extend(b, { objectMode: !0 }), w.call(this, b), void (this._query = a)) : new q.Stream(a, b) }, x.inherits(q.Stream, w), q.Stream.prototype._transform = function (a, b, c) { if (p.isObject(a) && this._query.test(a)) if (p.isEmpty(this._query._projection)) this.push(a); else { var d = new q.Cursor([a], this._query); d.hasNext() && this.push(d.next()) } c() } } q.Cursor = function (a, b, c) { return this instanceof q.Cursor ? (this._query = b, this._collection = a, this._projection = c || b._projection, this._operators = {}, this._result = !1, void (this._position = 0)) : new q.Cursor(a, b, c) }, q.Cursor.prototype = { _fetch: function () { var a = this; if (this._result !== !1) return this._result; p.isObject(this._projection) && p.extend(this._operators, { $project: this._projection }), this._result = p.filter(this._collection, this._query.test, this._query); var b = []; if (p.each(["$sort", "$skip", "$limit", "$project"], function (c) { p.has(a._operators, c) && b.push(p.pick(a._operators, c)) }), b.length > 0) { var c = new q.Aggregator(b); this._result = c.run(this._result, this._query) } return this._result }, all: function () { return this._fetch() }, first: function () { return this.count() > 0 ? this._fetch()[0] : null }, last: function () { return this.count() > 0 ? this._fetch()[this.count() - 1] : null }, count: function () { return this._fetch().length }, skip: function (a) { return p.extend(this._operators, { $skip: a }), this }, limit: function (a) { return p.extend(this._operators, { $limit: a }), this }, sort: function (a) { return p.extend(this._operators, { $sort: a }), this }, next: function () { return this.hasNext() ? this._fetch()[this._position++] : null }, hasNext: function () { return this.count() > this._position }, max: function (a) { return D.$max(this._fetch(), a) }, min: function (a) { return D.$min(this._fetch(), a) }, map: function (a) { return p.map(this._fetch(), a) }, forEach: function (a) { p.each(this._fetch(), a) } }, q.Aggregator = function (a) { return this instanceof q.Aggregator ? void (this._operators = a) : new q.Aggregator(a) }, q.Aggregator.prototype = { run: function (a, b) { if (!p.isEmpty(this._operators)) for (var c = 0; c < this._operators.length; c++) { var d = this._operators[c], e = p.keys(d); if (1 != e.length || !p.contains(k(S), e[0])) throw new Error("Invalid aggregation operator '" + e + "'"); e = e[0], a = b instanceof q.Query ? y[e].call(b, a, d[e]) : y[e](a, d[e]) } return a } }, q.find = function (a, b, c) { return new q.Query(b).find(a, c) }, q.remove = function (a, b) { return new q.Query(b).remove(a) }, q.aggregate = function (a, b) { if (!p.isArray(b)) throw new Error("Aggregation pipeline must be an array"); return new q.Aggregator(b).run(a) }, q.addOperators = function (a, b) { var c = b({ resolve: i, computeValue: n, ops: k, key: function () { return v.key } }); if (!p.contains([R, Q, S, T, P], a)) throw new Error("Could not identify type '" + a + "'"); var d = k(a); p.each(p.keys(c), function (b) { if (!/^\$\w+$/.test(b)) throw new Error("Invalid operator name '" + b + "'"); if (p.contains(d, b)) throw new Error("Operator " + b + " is already defined for " + a + " operators") }); var e = {}; switch (a) { case P: p.each(p.keys(c), function (a) { e[a] = function (b, c) { return function (d, e) { return { test: function (f) { var g = i(f, d), h = b.call(c, d, g, e); if (p.isBoolean(h)) return h; if (h instanceof q.Query) return h.test(f); throw new Error("Invalid return type for '" + a + "'. Must return a Boolean or Mingo.Query") } } } }(c[a], c) }); break; case T: p.each(p.keys(c), function (a) { e[a] = function (a, b) { return function (c, d, e) { var f = i(c, e); return a.call(b, e, f, d) } }(c[a], c) }); break; default: p.each(p.keys(c), function (a) { e[a] = function (a, b) { return function () { var c = Array.prototype.slice.call(arguments); return a.apply(b, c) } }(c[a], c) }) } p.extend(U[a], e) }, q.CollectionMixin = { query: function (a, b) { return q.find(this.toJSON(), a, b) }, aggregate: function (a) { var b = [this.toJSON(), a]; return q.aggregate.apply(null, b) } }; var y = { $group: function (a, b) { var c = b[v.key], d = l(a, function (a) { return n(a, c, c) }), e = []; return b = p.omit(b, v.key), p.each(d.keys, function (a, c) { var f = {}; p.isUndefined(a) || (f[v.key] = a); for (var g in b) b.hasOwnProperty(g) && (f[g] = m(d.groups[c], g, b[g])); e.push(f) }), e }, $match: function (a, b) { return new q.Query(b).find(a).all() }, $project: function (a, b) { if (p.isEmpty(b)) return a; var c = !1; p.each(b, function (a, b) { if (0 === a && b !== v.key && (c = !0), 0 !== a && c) throw new Error("You cannot mix including and excluding fields.") }); var d = [], e = p.keys(b), f = !1; if (p.contains(e, v.key)) { var g = b[v.key]; (0 === g || g === !1) && (e = p.without(e, v.key), p.isEmpty(e) && (f = !0)) } else e.push(v.key); for (var h = 0; h < a.length; h++) { var i = a[h], j = {}, l = !1, m = !1, o = []; f && o.push(v.key), p.each(e, function (a) { var c, d = b[a]; if (a !== v.key && 0 === d && (m = !0), a === v.key && p.isEmpty(d)) c = i[a]; else if (p.isString(d)) c = n(i, d, a); else if (1 === d || d === !0) c = p.result(i, a); else if (p.isObject(d)) { var e = p.keys(d); if (e = e.length > 1 ? !1 : e[0], e !== !1 && p.contains(k(T), e)) { var f = C[e](i, d[e], a); p.isUndefined(f) || (c = f), "$slice" == e && (l = !0) } else c = n(i, d, a) } else o.push(a); p.isUndefined(c) || (j[a] = c) }), (l || m || f) && (j = p.defaults(j, p.omit(i, o))), d.push(j) } return d }, $limit: function (a, b) { return p.first(a, b) }, $skip: function (a, b) { return p.rest(a, b) }, $unwind: function (a, b) { for (var c = [], d = b.substr(1), e = 0; e < a.length; e++) { var f = a[e], g = h(f, d); if (!p.isArray(g)) throw new Error("Target field '" + d + "' is not of type Array."); p.each(g, function (a) { var b = p.clone(f); b[d] = a, c.push(b) }) } return c }, $sort: function (a, b) { if (!p.isEmpty(b) && p.isObject(b)) { var c = p.keys(b); c.reverse().forEach(function (c) { var d = [], e = p.groupBy(a, function (a) { var b = i(a, c); return d.push(b), b }); d = p.sortBy(p.uniq(d), function (a) { return a }), -1 === b[c] && d.reverse(), a = [], p.each(d, function (b) { Array.prototype.push.apply(a, e[b]) }) }) } return a } }, z = {}, A = { $and: function (a, b) { if (!p.isArray(b)) throw new Error("Invalid expression for $and criteria"); var c = []; return p.each(b, function (a) { c.push(new q.Query(a)) }), { test: function (a) { for (var b = 0; b < c.length; b++) if (!c[b].test(a)) return !1; return !0 } } }, $or: function (a, b) { if (!p.isArray(b)) throw new Error("Invalid expression for $or criteria"); var c = []; return p.each(b, function (a) { c.push(new q.Query(a)) }), { test: function (a) { for (var b = 0; b < c.length; b++) if (c[b].test(a)) return !0; return !1 } } }, $nor: function (a, b) { if (!p.isArray(b)) throw new Error("Invalid expression for $nor criteria"); var c = this.$or("$or", b); return { test: function (a) { return !c.test(a) } } }, $not: function (a, b) { var c = {}; c[a] = g(b); var d = new q.Query(c); return { test: function (a) { return !d.test(a) } } }, $where: function (a, b) { return p.isFunction(b) || (b = new Function("return " + b + ";")), { test: function (a) { return b.call(a) === !0 } } } }; p.extend(z, A); var B = { $eq: function (a, b) { return a = p.flatten(p.isArray(a) ? a : [a]), a = p.find(a, function (a) { return p.isEqual(a, b) }), a !== e }, $ne: function (a, b) { return !this.$eq(a, b) }, $in: function (a, b) { return a = p.isArray(a) ? a : [a], p.intersection(a, b).length > 0 }, $nin: function (a, b) { return p.isUndefined(a) || !this.$in(a, b) }, $lt: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return b > a }), a !== e }, $lte: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return b >= a }), a !== e }, $gt: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return a > b }), a !== e }, $gte: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return a >= b }), a !== e }, $mod: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return p.isNumber(a) && p.isArray(b) && 2 === b.length && a % b[0] === b[1] }), a !== e }, $regex: function (a, b) { return a = p.isArray(a) ? a : [a], a = p.find(a, function (a) { return p.isString(a) && p.isRegExp(b) && !!a.match(b) }), a !== e }, $exists: function (a, b) { return b === !1 && p.isUndefined(a) || b === !0 && !p.isUndefined(a) }, $all: function (a, b) { var c = this, d = !1; if (p.isArray(a) && p.isArray(b)) for (var e = 0; e < b.length; e++) { if (!p.isObject(b[e]) || !p.contains(p.keys(b[e]), "$elemMatch")) return p.intersection(b, a).length === b.length; d = d || c.$elemMatch(a, b[e].$elemMatch) } return d }, $size: function (a, b) { return p.isArray(a) && p.isNumber(b) && a.length === b }, $elemMatch: function (a, b) { if (p.isArray(a) && !p.isEmpty(a)) for (var c = new q.Query(b), d = 0; d < a.length; d++) if (c.test(a[d])) return !0; return !1 }, $type: function (a, b) { switch (b) { case 1: return p.isNumeric(a) && -1 !== (a + "").indexOf("."); case 2: case 5: return p.isString(a); case 3: return p.isObject(a); case 4: return p.isArray(a); case 8: return p.isBoolean(a); case 9: return p.isDate(a); case 10: return p.isNull(a); case 11: return p.isRegExp(a); case 16: return p.isNumeric(a) && 2147483647 >= a && -1 === (a + "").indexOf("."); case 18: return p.isNumeric(a) && a > 2147483647 && 0x8000000000000000 >= a && -1 === (a + "").indexOf("."); default: return !1 } } }; p.each(p.keys(B), function (a) { z[a] = function (a, b) { return function (c, d) { return { test: function (e) { var f = i(e, c); return a.call(b, f, d) } } } }(B[a], B) }); var C = { $: function () { throw new Error("$ not implemented") }, $elemMatch: function (a, b, c) { var d = i(a, c), f = new q.Query(b); if (p.isUndefined(d) || !p.isArray(d)) return e; for (var g = 0; g < d.length; g++) if (f.test(d[g])) return [d[g]]; return e }, $slice: function (a, b, c) { var d = i(a, c); if (!p.isArray(d)) return d; if (p.isArray(b)) { var e = b[0] < 0 ? d.length + b[0] : b, f = e + b[1]; b = [e, f] } else { if (!p.isNumber(b)) throw new Error("Invalid type for $slice operator"); b = 0 > b ? [b] : [0, b] } return Array.prototype.slice.apply(d, b) } }, D = { $addToSet: function (a, b) { var c = p.map(a, function (a) { return n(a, b, null) }); return p.uniq(c) }, $sum: function (a, b) { return p.isArray(a) ? p.isNumber(b) ? a.length * b : p.reduce(a, function (a, c) { return a + n(c, b, null) }, 0) : 0 }, $max: function (a, b) { var c = p.max(a, function (a) { return n(a, b, null) }); return n(c, b, null) }, $min: function (a, b) { var c = p.min(a, function (a) { return n(a, b, null) }); return n(c, b, null) }, $avg: function (a, b) { return this.$sum(a, b) / (a.length || 1) }, $push: function (a, b) { return p.map(a, function (a) { return n(a, b, null) }) }, $first: function (a, b) { return a.length > 0 ? n(a[0], b) : e }, $last: function (a, b) { return a.length > 0 ? n(a[a.length - 1], b) : e } }, E = { $add: function (a, b) { var c = n(a, b, null); return p.reduce(c, function (a, b) { return a + b }, 0) }, $subtract: function (a, b) { var c = n(a, b, null); return c[0] - c[1] }, $divide: function (a, b) { var c = n(a, b, null); return c[0] / c[1] }, $multiply: function (a, b) { var c = n(a, b, null); return p.reduce(c, function (a, b) { return a * b }, 1) }, $mod: function (a, b) { var c = n(a, b, null); return c[0] % c[1] } }, F = { $concat: function (a, b) { var c = n(a, b, null); return p.contains(c, null) || p.contains(c, e) ? null : c.join("") }, $strcasecmp: function (a, b) { var c = n(a, b, null); return c[0] = p.isEmpty(c[0]) ? "" : c[0].toUpperCase(), c[1] = p.isEmpty(c[1]) ? "" : c[1].toUpperCase(), c[0] > c[1] ? 1 : c[0] < c[1] ? -1 : 0 }, $substr: function (a, b) { var c = n(a, b, null); return p.isString(c[0]) ? c[1] < 0 ? "" : c[2] < 0 ? c[0].substr(c[1]) : c[0].substr(c[1], c[2]) : "" }, $toLower: function (a, b) { var c = n(a, b, null); return p.isEmpty(c) ? "" : c.toLowerCase() }, $toUpper: function (a, b) { var c = n(a, b, null); return p.isEmpty(c) ? "" : c.toUpperCase() } }, G = { $dayOfYear: function (a, b) { var c = n(a, b, null); if (p.isDate(c)) { var d = new Date(c.getFullYear(), 0, 0), f = c - d, g = 864e5; return Math.round(f / g) } return e }, $dayOfMonth: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getDate() : e }, $dayOfWeek: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getDay() + 1 : e }, $year: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getFullYear() : e }, $month: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getMonth() + 1 : e }, $week: function (a, b) { var c = n(a, b, null); c = new Date(+c), c.setHours(0, 0, 0), c.setDate(c.getDate() + 4 - (c.getDay() || 7)); var d = new Date(c.getFullYear(), 0, 1); return Math.floor(((c - d) / 864e5 + 1) / 7) }, $hour: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getHours() : e }, $minute: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getMinutes() : e }, $second: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getSeconds() : e }, $millisecond: function (a, b) { var c = n(a, b, null); return p.isDate(c) ? c.getMilliseconds() : e }, $dateToString: function (a, b) { for (var c = b.format, d = n(a, b.date, null), e = c.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g), f = 0, g = e.length; g > f; f++) { var h = V[e[f]], i = h; if (p.isArray(h)) { var k = this[h[0]], l = h[1]; i = j(k.call(this, a, d), l) } c = c.replace(e[f], i) } return c } }, H = { $setEquals: function (a, b) { var c = n(a, b, null), d = p.uniq(c[0]), e = p.uniq(c[1]); return d.length !== e.length ? !1 : 0 == p.difference(d, e).length }, $setIntersection: function (a, b) { var c = n(a, b, null); return p.intersection(c[0], c[1]) }, $setDifference: function (a, b) { var c = n(a, b, null); return p.difference(c[0], c[1]) }, $setUnion: function (a, b) { var c = n(a, b, null); return p.union(c[0], c[1]) }, $setIsSubset: function (a, b) { var c = n(a, b, null); return p.intersection(c[0], c[1]).length === c[0].length }, $anyElementTrue: function (a, b) { for (var c = n(a, b, null)[0], d = 0; d < c.length; d++) if (c[d]) return !0; return !1 }, $allElementsTrue: function (a, b) { for (var c = n(a, b, null)[0], d = 0; d < c.length; d++) if (!c[d]) return !1; return !0 } }, I = { $cond: function (a, b) { var c, d, e; if (p.isArray(b)) { if (3 != b.length) throw new Error("Invalid arguments for $cond operator"); c = b[0], d = b[1], e = b[2] } else p.isObject(b) && (c = b["if"], d = b.then, e = b["else"]); var f = n(a, c, null); return f ? n(a, d, null) : n(a, e, null) }, $ifNull: function (a, b) { if (!p.isArray(b) || 2 != b.length) throw new Error("Invalid arguments for $ifNull operator"); var c = n(a, b, null); return null === c[0] || c[0] === e ? c[1] : c[0] } }, J = { $cmp: function (a, b) { var c = n(a, b, null); return c[0] > c[1] ? 1 : c[0] < c[1] ? -1 : 0 } }; p.each(["$eq", "$ne", "$gt", "$gte", "$lt", "$lte"], function (a) { J[a] = function (b, c) { var d = n(b, c, null); return B[a](d[0], d[1]) } }); var K = { $size: function (a, b) { var c = n(a, b, null); return p.isArray(c) ? c.length : e } }, L = { $literal: function (a, b) { return b } }, M = { $map: function (a, b) { var c = n(a, b.input, null); if (!p.isArray(c)) throw new Error("Input expression for $map must resolve to an array"); var d = b.as, e = b["in"], f = "$" + d, g = a[f]; return p.map(c, function (b) { a[f] = b; var c = n(a, e, null); return p.isUndefined(g) ? delete a[f] : a[f] = g, c }) }, $let: function (a, b) { var c = b.vars, d = b["in"], e = {}, f = p.keys(c); p.each(f, function (b) { var d = n(a, c[b], null), f = "$" + b; e[f] = a[f], a[f] = d }); var g = n(a, d, null); return p.each(f, function (b) { var c = "$" + b; p.isUndefined(e[c]) ? delete a[c] : a[c] = e[c] }), g } }, N = { $and: function (a, b) { var c = n(a, b, null); return p.every(c) }, $or: function (a, b) { var c = n(a, b, null); return p.some(c) }, $not: function (a, b) { return !n(a, b[0], null) } }, O = p.extend({}, K, E, N, J, I, G, L, H, F, M), P = q.OP_QUERY = "query", Q = q.OP_GROUP = "group", R = q.OP_AGGREGATE = "aggregate", S = q.OP_PIPELINE = "pipeline", T = q.OP_PROJECTION = "projection", U = { aggregate: O, group: D, pipeline: y, projection: C, query: z }, V = { "%Y": ["$year", 4], "%m": ["$month", 2], "%d": ["$dayOfMonth", 2], "%H": ["$hour", 2], "%M": ["$minute", 2], "%S": ["$second", 2], "%L": ["$millisecond", 3], "%j": ["$dayOfYear", 3], "%w": ["$dayOfWeek", 1], "%U": ["$week", 2], "%%": "%" } }(this) }, { stream: "stream", underscore: 35, util: 6 }], 13: [function (a, b, c) { function d(a, b) { a = a || {}; var c = {}; for (var f in b) if (b.hasOwnProperty(f)) { var g, i, k = b[f], l = f.split("."), m = a, n = []; a: for (var o = 0; o < l.length; o++) switch (m = m[l[o]], h(m)) { case "array": if (g = l.slice(0, o + 1).join("."), i = l.slice(o + 1).join("."), j('searching array "%s"', g), k.$size && !i.length) return e(k, m); for (var p = c[g] || m, q = 0; q < p.length; q++) if (i.length) { var r = {}; r[i] = k, "object" == h(p[q]) && (j("attempting subdoc search with query %j", r), d(p[q], r) && (c[g] && ~c[g].indexOf(p[q]) || n.push(p[q]))) } else j("performing simple array item search"), e(k, p[q]) && (c[g] && ~c[g].indexOf(p[q]) || n.push(p[q])); n.length && (c[g] = c[g] || [], c[g].push.apply(c[g], n)); break a; case "undefined": return !1; case "object": if (null != l[o + 1]) continue; if (!e(k, m)) return !1; break; default: if (!e(k, m)) return !1 } } return c } function e(a, b) { if ("object" != h(a)) return g(a, b); var c = i.keys(a); if ("$" == c[0][0]) { for (var e = 0; e < c.length; e++) { if ("$elemMatch" == c[e]) return !1 !== d(b, a.$elemMatch); if (!f[c[e]](a[c[e]], b)) return !1 } return !0 } return g(a, b) } var f = a("./ops"), g = a("mongo-eql"), h = (a("dot-component"), a("component-type")), i = a("object-component"), j = a("debug")("mongo-query"); b.exports = c = d, c.ops = f }, { "./ops": 24, "component-type": 16, debug: 17, "dot-component": 20, "mongo-eql": 22, "object-component": 23 }], 14: [function (a, b, c) { function d(a, b, c, d) { a = a || {}, d = d || {}, b = b || {}, c = c || {}; var j, k = !!d.strict, l = []; if (h.length(b) && (j = f(a, b)), k && !1 === j) i("no matches for query %j", b); else { for (var m = h.keys(c), n = [], o = 0, p = m.length; p > o; o++) if (e[m[o]]) { i('found modifier "%s"', m[o]); for (var q in c[m[o]]) { var r = q.indexOf(".$."); if (~r) { var s = q.substr(0, r), t = q.substr(r + 3); if (j[s]) { i('executing "%s" %s on first match within "%s"', q, m[o], s); var u = e[m[o]](j[s][0], t, c[m[o]][q]); if (u) { var v = g.get(a, s).indexOf(j[s][0]); u.key = s + "." + v + "." + t, u.op = m[o], n.push(u) } } else i('ignoring "%s" %s - no matches within "%s"', q, m[o], s) } else { var u = e[m[o]](a, q, c[m[o]][q]); u && (u.key = q, u.op = m[o], n.push(u)) } } } else i('skipping unknown modifier "%s"', m[o]); if (n.length) for (var o = 0; o < n.length; o++) { var u = n[o], w = u(); l.push({ op: u.op, key: u.key, value: w }) } } return l } var e = a("./mods"), f = a("./filter"), g = a("dot-component"), h = (a("component-type"), a("object-component")), i = a("debug")("mongo-query"); b.exports = c = d, c.filter = f, c.mods = e }, { "./filter": 13, "./mods": 15, "component-type": 16, debug: 17, "dot-component": 20, "object-component": 23 }], 15: [function (a, b, c) { function d(a, b) { for (var c = 0, d = a.length; d > c; c++) if (g(b, a[c])) return !0; return !1 } function e(a, b, c) { for (var d = [], e = 0; e < a.length; e++) for (var f = a[e], h = 0; h < b.length; h++) { var l = b[h]; if ("object" == i(l)) if ("object" == i(f)) { var m = !1; if (j(l).length) { for (var h in l) if (l.hasOwnProperty(h)) { if (!g(l[h], f[h])) { m = !1; break } m = !0 } } else j(f).length || (m = !0); if (m) { d.push(e), c.push(f); continue } } else k("ignoring pull match against object"); else if (g(l, f)) { d.push(e), c.push(f); continue } } return function () { for (var b = 0; b < d.length; b++) { var c = d[b]; a.splice(c - b, 1) } } } function f(a) { return "number" == i(a) || Number(a) == a } var g = a("mongo-eql"), h = a("dot-component"), i = a("component-type"), j = a("object-component").keys, k = a("debug")("mongo-query"); c.$set = function (a, b, c) { var d = b.split(".").pop(); switch (a = h.parent(a, b, !0), i(a)) { case "object": if (!g(a[d], c)) return function () { return a[d] = c, c }; break; case "array": if (!f(d)) throw new Error("can't append to array using string field name [" + d + "]"); if (!g(a[d], c)) return function () { return a[d] = c, c }; break; default: throw new Error("$set only supports object not " + i(a)) } }, c.$unset = function (a, b) { var c = b.split(".").pop(); switch (a = h.parent(a, b), i(a)) { case "array": case "object": if (a.hasOwnProperty(c)) return function () { delete a[c] }; k("ignoring unset of inexisting key") } }, c.$rename = function (a, b, c) { if (b == c) throw new Error("$rename source must differ from target"); if (0 === b.indexOf(c + ".")) throw new Error("$rename target may not be a parent of source"); var d = h.parent(a, b), e = i(d); if ("object" == e) { var f = b.split(".").pop(); if (d.hasOwnProperty(f)) return function () { var b = d[f]; delete d[f]; var e = h.parent(a, c, !0); return "object" == i(e) ? e[c.split(".").pop()] = b : k("invalid $rename target path type"), c }; k("ignoring rename from inexisting source") } else if ("undefined" != e) throw new Error("$rename source field invalid") }, c.$inc = function (a, b, c) { if ("number" != i(c)) throw new Error("Modifier $inc allowed for numbers only"); a = h.parent(a, b, !0); var d = b.split(".").pop(); switch (i(a)) { case "array": case "object": if (a.hasOwnProperty(d)) { if ("number" != i(a[d])) throw new Error("Cannot apply $inc modifier to non-number"); return function () { return a[d] += c, c } } if ("object" == i(a) || f(d)) return function () { return a[d] = c, c }; throw new Error("can't append to array using string field name [" + d + "]"); default: throw new Error("Cannot apply $inc modifier to non-number") } }, c.$pop = function (a, b, c) { a = h.parent(a, b); var d = b.split(".").pop(); switch (i(a)) { case "array": case "object": if (a.hasOwnProperty(d)) switch (i(a[d])) { case "array": if (a[d].length) return function () { return -1 == c ? a[d].shift() : a[d].pop() }; break; case "undefined": k("ignoring pop to inexisting key"); break; default: throw new Error("Cannot apply $pop modifier to non-array") } else k("ignoring pop to inexisting key"); break; case "undefined": k("ignoring pop to inexisting key") } }, c.$push = function (a, b, c) { a = h.parent(a, b, !0); var d = b.split(".").pop(); switch (i(a)) { case "object": if (a.hasOwnProperty(d)) { if ("array" == i(a[d])) return function () { return a[d].push(c), c }; throw new Error("Cannot apply $push/$pushAll modifier to non-array") } return function () { return a[d] = [c], c }; case "array": if (a.hasOwnProperty(d)) { if ("array" == i(a[d])) return function () { return a[d].push(c), c }; throw new Error("Cannot apply $push/$pushAll modifier to non-array") } if (f(d)) return function () { return a[d] = [c], c }; throw new Error("can't append to array using string field name [" + d + "]") } }, c.$pushAll = function (a, b, c) { if ("array" != i(c)) throw new Error("Modifier $pushAll/pullAll allowed for arrays only"); a = h.parent(a, b, !0); var d = b.split(".").pop(); switch (i(a)) { case "object": if (a.hasOwnProperty(d)) { if ("array" == i(a[d])) return function () { return a[d].push.apply(a[d], c), c }; throw new Error("Cannot apply $push/$pushAll modifier to non-array") } return function () { return a[d] = c, c }; case "array": if (a.hasOwnProperty(d)) { if ("array" == i(a[d])) return function () { return a[d].push.apply(a[d], c), c }; throw new Error("Cannot apply $push/$pushAll modifier to non-array") } if (f(d)) return function () { return a[d] = c, c }; throw new Error("can't append to array using string field name [" + d + "]") } }, c.$pull = function (a, b, c) { a = h.parent(a, b, !0); var d = b.split(".").pop(), f = i(a); switch (f) { case "object": if (a.hasOwnProperty(d)) { if ("array" != i(a[d])) throw new Error("Cannot apply $pull/$pullAll modifier to non-array"); var g = [], j = e(a[d], [c], g); if (g.length) return function () { return j(), g } } break; case "array": if (a.hasOwnProperty(d)) { if ("array" != i(a[d])) throw new Error("Cannot apply $pull/$pullAll modifier to non-array"); var g = [], j = e(a[d], [c], g); if (g.length) return function () { return j(), g } } else k("ignoring pull to non array"); break; default: if ("undefined" != f) throw new Error("LEFT_SUBFIELD only supports Object: hello not: " + f) } }, c.$pullAll = function (a, b, c) { if ("array" != i(c)) throw new Error("Modifier $pushAll/pullAll allowed for arrays only"); a = h.parent(a, b, !0); var d = b.split(".").pop(), f = i(a); switch (f) { case "object": if (a.hasOwnProperty(d)) { if ("array" != i(a[d])) throw new Error("Cannot apply $pull/$pullAll modifier to non-array"); var g = [], j = e(a[d], c, g); if (g.length) return function () { return j(), g } } break; case "array": if (a.hasOwnProperty(d)) { if ("array" != i(a[d])) throw new Error("Cannot apply $pull/$pullAll modifier to non-array"); var g = [], j = e(a[d], c, g); if (g.length) return function () { return j(), g } } else k("ignoring pull to non array"); break; default: if ("undefined" != f) throw new Error("LEFT_SUBFIELD only supports Object: hello not: " + f) } }, c.$addToSet = function l(a, b, c, e) { if (!e && "array" == i(c.$each)) { for (var g = [], j = 0, k = c.$each.length; k > j; j++) { var m = l(a, b, c.$each[j], !0); m && g.push(m) } return g.length ? function () { for (var a = [], b = 0; b < g.length; b++) a.push(g[b]()); return a } : void 0 } a = h.parent(a, b, !0); var n = b.split(".").pop(); switch (i(a)) { case "object": if (!a.hasOwnProperty(n)) return function () { return a[n] = [c], c }; if ("array" != i(a[n])) throw new Error("Cannot apply $addToSet modifier to non-array"); if (!d(a[n], c)) return function () { return a[n].push(c), c }; break; case "array": if (!a.hasOwnProperty(n)) { if (f(n)) return function () { return a[n] = [c], c }; throw new Error("can't append to array using string field name [" + n + "]") } if ("array" != i(a[n])) throw new Error("Cannot apply $addToSet modifier to non-array"); if (!d(a[n], c)) return function () { return a[n].push(c), c } } } }, { "component-type": 16, debug: 17, "dot-component": 20, "mongo-eql": 22, "object-component": 23 }], 16: [function (a, b) {
var c = Object.prototype.toString; b.exports = function (a) {
switch (c.call(a)) {
case "[object Date]": return "date";
case "[object RegExp]": return "regexp"; case "[object Arguments]": return "arguments"; case "[object Array]": return "array"; case "[object Error]": return "error"
} return null === a ? "null" : void 0 === a ? "undefined" : a !== a ? "nan" : a && 1 === a.nodeType ? "element" : (a = a.valueOf ? a.valueOf() : Object.prototype.valueOf.apply(a), typeof a)
}
}, {}], 17: [function (a, b, c) { function d() { return "WebkitAppearance" in document.documentElement.style || window.console && (console.firebug || console.exception && console.table) || navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 } function e() { var a = arguments, b = this.useColors; if (a[0] = (b ? "%c" : "") + this.namespace + (b ? " %c" : " ") + a[0] + (b ? "%c " : " ") + "+" + c.humanize(this.diff), !b) return a; var d = "color: " + this.color; a = [a[0], d, "color: inherit"].concat(Array.prototype.slice.call(a, 1)); var e = 0, f = 0; return a[0].replace(/%[a-z%]/g, function (a) { "%%" !== a && (e++, "%c" === a && (f = e)) }), a.splice(f, 0, d), a } function f() { return "object" == typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments) } function g(a) { try { null == a ? c.storage.removeItem("debug") : c.storage.debug = a } catch (b) { } } function h() { var a; try { a = c.storage.debug } catch (b) { } return a } function i() { try { return window.localStorage } catch (a) { } } c = b.exports = a("./debug"), c.log = f, c.formatArgs = e, c.save = g, c.load = h, c.useColors = d, c.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local : i(), c.colors = ["lightseagreen", "forestgreen", "goldenrod", "dodgerblue", "darkorchid", "crimson"], c.formatters.j = function (a) { return JSON.stringify(a) }, c.enable(h()) }, { "./debug": 18 }], 18: [function (a, b, c) { function d() { return c.colors[k++ % c.colors.length] } function e(a) { function b() { } function e() { var a = e, b = +new Date, f = b - (j || b); a.diff = f, a.prev = j, a.curr = b, j = b, null == a.useColors && (a.useColors = c.useColors()), null == a.color && a.useColors && (a.color = d()); var g = Array.prototype.slice.call(arguments); g[0] = c.coerce(g[0]), "string" != typeof g[0] && (g = ["%o"].concat(g)); var h = 0; g[0] = g[0].replace(/%([a-z%])/g, function (b, d) { if ("%%" === b) return b; h++; var e = c.formatters[d]; if ("function" == typeof e) { var f = g[h]; b = e.call(a, f), g.splice(h, 1), h-- } return b }), "function" == typeof c.formatArgs && (g = c.formatArgs.apply(a, g)); var i = e.log || c.log || console.log.bind(console); i.apply(a, g) } b.enabled = !1, e.enabled = !0; var f = c.enabled(a) ? e : b; return f.namespace = a, f } function f(a) { c.save(a); for (var b = (a || "").split(/[\s,]+/), d = b.length, e = 0; d > e; e++) b[e] && (a = b[e].replace(/\*/g, ".*?"), "-" === a[0] ? c.skips.push(new RegExp("^" + a.substr(1) + "$")) : c.names.push(new RegExp("^" + a + "$"))) } function g() { c.enable("") } function h(a) { var b, d; for (b = 0, d = c.skips.length; d > b; b++) if (c.skips[b].test(a)) return !1; for (b = 0, d = c.names.length; d > b; b++) if (c.names[b].test(a)) return !0; return !1 } function i(a) { return a instanceof Error ? a.stack || a.message : a } c = b.exports = e, c.coerce = i, c.disable = g, c.enable = f, c.enabled = h, c.humanize = a("ms"), c.names = [], c.skips = [], c.formatters = {}; var j, k = 0 }, { ms: 19 }], 19: [function (a, b) { function c(a) { if (a = "" + a, !(a.length > 1e4)) { var b = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a); if (b) { var c = parseFloat(b[1]), d = (b[2] || "ms").toLowerCase(); switch (d) { case "years": case "year": case "yrs": case "yr": case "y": return c * k; case "days": case "day": case "d": return c * j; case "hours": case "hour": case "hrs": case "hr": case "h": return c * i; case "minutes": case "minute": case "mins": case "min": case "m": return c * h; case "seconds": case "second": case "secs": case "sec": case "s": return c * g; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return c } } } } function d(a) { return a >= j ? Math.round(a / j) + "d" : a >= i ? Math.round(a / i) + "h" : a >= h ? Math.round(a / h) + "m" : a >= g ? Math.round(a / g) + "s" : a + "ms" } function e(a) { return f(a, j, "day") || f(a, i, "hour") || f(a, h, "minute") || f(a, g, "second") || a + " ms" } function f(a, b, c) { return b > a ? void 0 : 1.5 * b > a ? Math.floor(a / b) + " " + c : Math.ceil(a / b) + " " + c + "s" } var g = 1e3, h = 60 * g, i = 60 * h, j = 24 * i, k = 365.25 * j; b.exports = function (a, b) { return b = b || {}, "string" == typeof a ? c(a) : b["long"] ? e(a) : d(a) } }, {}], 20: [function (a, b, c) { function d(a, b, c) { if (~b.indexOf(".")) { for (var d = b.split("."), f = a, g = 0; g < d.length - 1; g++) Number(d[g]) == d[g] && "array" == e(f) ? f = f[d[g]] : "object" == e(f) && (c && !f.hasOwnProperty(d[g]) && (f[d[g]] = {}), f && (f = f[d[g]])); return f } return a } var e = a("type-component"); c.get = function (a, b) { if (!~b.indexOf(".")) return a[b]; var c = d(a, b), f = b.split(".").pop(), g = e(c); return "object" == g || "array" == g ? c[f] : void 0 }, c.set = function (a, b, c) { if (~b.indexOf(".")) { var f = d(a, b, !0), g = b.split(".").pop(); f && "object" == e(f) && (f[g] = c) } else a[b] = c }, c.parent = d }, { "type-component": 21 }], 21: [function (a, b) { var c = Object.prototype.toString; b.exports = function (a) { switch (c.call(a)) { case "[object Function]": return "function"; case "[object Date]": return "date"; case "[object RegExp]": return "regexp"; case "[object Arguments]": return "arguments"; case "[object Array]": return "array" } return null === a ? "null" : void 0 === a ? "undefined" : a === Object(a) ? "object" : typeof a } }, {}], 22: [function (a, b) { function c(a, b) { switch (d(a)) { case "null": case "undefined": return null == b; case "regexp": return a.test(b); case "array": if ("array" == d(b) && a.length == b.length) { for (var e = 0; e < a.length; e++) if (!c(b[e], a[e])) return !1; return !0 } return !1; case "object": var f = {}; for (var e in a) { if (a.hasOwnProperty(e) && (!b.hasOwnProperty(e) || !c(a[e], b[e]))) return !1; f[e] = !0 } for (var e in b) if (b.hasOwnProperty(e) && !f.hasOwnProperty(e)) return !1; return !0; default: return a === b } } var d = a("component-type"); b.exports = c }, { "component-type": 16 }], 23: [function (a, b, c) { var d = Object.prototype.hasOwnProperty; c.keys = Object.keys || function (a) { var b = []; for (var c in a) d.call(a, c) && b.push(c); return b }, c.values = function (a) { var b = []; for (var c in a) d.call(a, c) && b.push(a[c]); return b }, c.merge = function (a, b) { for (var c in b) d.call(b, c) && (a[c] = b[c]); return a }, c.length = function (a) { return c.keys(a).length }, c.isEmpty = function (a) { return 0 == c.length(a) } }, {}], 24: [function (a, b, c) { var d = a("mongo-eql"), e = a("component-type"); c.$ne = function (a, b) { return !d(a, b) }, c.$gt = function (a, b) { return "number" === e(a) && b > a }, c.$gte = function (a, b) { return "number" === e(a) && b >= a }, c.$lt = function (a, b) { return "number" === e(a) && a > b }, c.$lte = function (a, b) { return "number" === e(a) && a >= b }, c.$regex = function (a, b) { return "regexp" != e("matcher") && (a = new RegExp(a)), a.test(b) }, c.$exists = function (a, b) { return a ? void 0 !== b : void 0 === b }, c.$in = function (a, b) { if ("array" != e(a)) return !1; for (var c = 0; c < a.length; c++) if (d(a[c], b)) return !0; return !1 }, c.$nin = function (a, b) { return !c.$in(a, b) }, c.$size = function (a, b) { return Array.isArray(b) && a == b.length } }, { "component-type": 16, "mongo-eql": 22 }], 25: [function (a, b, c) { var d = a("./lib/core").CryptoJS; a("./lib/enc-base64"), a("./lib/md5"), a("./lib/evpkdf"), a("./lib/cipher-core"), a("./lib/aes"); var e = a("./lib/jsonformatter").JsonFormatter; c.CryptoJS = d, c.JsonFormatter = e }, { "./lib/aes": 26, "./lib/cipher-core": 27, "./lib/core": 28, "./lib/enc-base64": 29, "./lib/evpkdf": 30, "./lib/jsonformatter": 31, "./lib/md5": 32 }], 26: [function (a) {
var b = a("./core").CryptoJS;/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
!function () { var a = b, c = a.lib, d = c.BlockCipher, e = a.algo, f = [], g = [], h = [], i = [], j = [], k = [], l = [], m = [], n = [], o = []; !function () { for (var a = [], b = 0; 256 > b; b++) a[b] = 128 > b ? b << 1 : b << 1 ^ 283; for (var c = 0, d = 0, b = 0; 256 > b; b++) { var e = d ^ d << 1 ^ d << 2 ^ d << 3 ^ d << 4; e = e >>> 8 ^ 255 & e ^ 99, f[c] = e, g[e] = c; var p = a[c], q = a[p], r = a[q], s = 257 * a[e] ^ 16843008 * e; h[c] = s << 24 | s >>> 8, i[c] = s << 16 | s >>> 16, j[c] = s << 8 | s >>> 24, k[c] = s; var s = 16843009 * r ^ 65537 * q ^ 257 * p ^ 16843008 * c; l[e] = s << 24 | s >>> 8, m[e] = s << 16 | s >>> 16, n[e] = s << 8 | s >>> 24, o[e] = s, c ? (c = p ^ a[a[a[r ^ p]]], d ^= a[a[d]]) : c = d = 1 } }(); var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], q = e.AES = d.extend({ _doReset: function () { for (var a = this._key, b = a.words, c = a.sigBytes / 4, d = this._nRounds = c + 6, e = 4 * (d + 1), g = this._keySchedule = [], h = 0; e > h; h++) if (c > h) g[h] = b[h]; else { var i = g[h - 1]; h % c ? c > 6 && h % c == 4 && (i = f[i >>> 24] << 24 | f[i >>> 16 & 255] << 16 | f[i >>> 8 & 255] << 8 | f[255 & i]) : (i = i << 8 | i >>> 24, i = f[i >>> 24] << 24 | f[i >>> 16 & 255] << 16 | f[i >>> 8 & 255] << 8 | f[255 & i], i ^= p[h / c | 0] << 24), g[h] = g[h - c] ^ i } for (var j = this._invKeySchedule = [], k = 0; e > k; k++) { var h = e - k; if (k % 4) var i = g[h]; else var i = g[h - 4]; j[k] = 4 > k || 4 >= h ? i : l[f[i >>> 24]] ^ m[f[i >>> 16 & 255]] ^ n[f[i >>> 8 & 255]] ^ o[f[255 & i]] } }, encryptBlock: function (a, b) { this._doCryptBlock(a, b, this._keySchedule, h, i, j, k, f) }, decryptBlock: function (a, b) { var c = a[b + 1]; a[b + 1] = a[b + 3], a[b + 3] = c, this._doCryptBlock(a, b, this._invKeySchedule, l, m, n, o, g); var c = a[b + 1]; a[b + 1] = a[b + 3], a[b + 3] = c }, _doCryptBlock: function (a, b, c, d, e, f, g, h) { for (var i = this._nRounds, j = a[b] ^ c[0], k = a[b + 1] ^ c[1], l = a[b + 2] ^ c[2], m = a[b + 3] ^ c[3], n = 4, o = 1; i > o; o++) { var p = d[j >>> 24] ^ e[k >>> 16 & 255] ^ f[l >>> 8 & 255] ^ g[255 & m] ^ c[n++], q = d[k >>> 24] ^ e[l >>> 16 & 255] ^ f[m >>> 8 & 255] ^ g[255 & j] ^ c[n++], r = d[l >>> 24] ^ e[m >>> 16 & 255] ^ f[j >>> 8 & 255] ^ g[255 & k] ^ c[n++], s = d[m >>> 24] ^ e[j >>> 16 & 255] ^ f[k >>> 8 & 255] ^ g[255 & l] ^ c[n++]; j = p, k = q, l = r, m = s } var p = (h[j >>> 24] << 24 | h[k >>> 16 & 255] << 16 | h[l >>> 8 & 255] << 8 | h[255 & m]) ^ c[n++], q = (h[k >>> 24] << 24 | h[l >>> 16 & 255] << 16 | h[m >>> 8 & 255] << 8 | h[255 & j]) ^ c[n++], r = (h[l >>> 24] << 24 | h[m >>> 16 & 255] << 16 | h[j >>> 8 & 255] << 8 | h[255 & k]) ^ c[n++], s = (h[m >>> 24] << 24 | h[j >>> 16 & 255] << 16 | h[k >>> 8 & 255] << 8 | h[255 & l]) ^ c[n++]; a[b] = p, a[b + 1] = q, a[b + 2] = r, a[b + 3] = s }, keySize: 8 }); a.AES = d._createHelper(q) }()
}, { "./core": 28 }], 27: [function (a) {
var b = a("./core").CryptoJS;/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
b.lib.Cipher || function (a) { var c = b, d = c.lib, e = d.Base, f = d.WordArray, g = d.BufferedBlockAlgorithm, h = c.enc, i = (h.Utf8, h.Base64), j = c.algo, k = j.EvpKDF, l = d.Cipher = g.extend({ cfg: e.extend(), createEncryptor: function (a, b) { return this.create(this._ENC_XFORM_MODE, a, b) }, createDecryptor: function (a, b) { return this.create(this._DEC_XFORM_MODE, a, b) }, init: function (a, b, c) { this.cfg = this.cfg.extend(c), this._xformMode = a, this._key = b, this.reset() }, reset: function () { g.reset.call(this), this._doReset() }, process: function (a) { return this._append(a), this._process() }, finalize: function (a) { a && this._append(a); var b = this._doFinalize(); return b }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { function a(a) { return "string" == typeof a ? x : u } return function (b) { return { encrypt: function (c, d, e) { return a(d).encrypt(b, c, d, e) }, decrypt: function (c, d, e) { return a(d).decrypt(b, c, d, e) } } } }() }), m = (d.StreamCipher = l.extend({ _doFinalize: function () { var a = this._process(!0); return a }, blockSize: 1 }), c.mode = {}), n = d.BlockCipherMode = e.extend({ createEncryptor: function (a, b) { return this.Encryptor.create(a, b) }, createDecryptor: function (a, b) { return this.Decryptor.create(a, b) }, init: function (a, b) { this._cipher = a, this._iv = b } }), o = m.CBC = function () { function b(b, c, d) { var e = this._iv; if (e) { var f = e; this._iv = a } else var f = this._prevBlock; for (var g = 0; d > g; g++) b[c + g] ^= f[g] } var c = n.extend(); return c.Encryptor = c.extend({ processBlock: function (a, c) { var d = this._cipher, e = d.blockSize; b.call(this, a, c, e), d.encryptBlock(a, c), this._prevBlock = a.slice(c, c + e) } }), c.Decryptor = c.extend({ processBlock: function (a, c) { var d = this._cipher, e = d.blockSize, f = a.slice(c, c + e); d.decryptBlock(a, c), b.call(this, a, c, e), this._prevBlock = f } }), c }(), p = c.pad = {}, q = p.Pkcs7 = { pad: function (a, b) { for (var c = 4 * b, d = c - a.sigBytes % c, e = d << 24 | d << 16 | d << 8 | d, g = [], h = 0; d > h; h += 4) g.push(e); var i = f.create(g, d); a.concat(i) }, unpad: function (a) { var b = 255 & a.words[a.sigBytes - 1 >>> 2]; a.sigBytes -= b } }, r = (d.BlockCipher = l.extend({ cfg: l.cfg.extend({ mode: o, padding: q }), reset: function () { l.reset.call(this); var a = this.cfg, b = a.iv, c = a.mode; if (this._xformMode == this._ENC_XFORM_MODE) var d = c.createEncryptor; else { var d = c.createDecryptor; this._minBufferSize = 1 } this._mode = d.call(c, this, b && b.words) }, _doProcessBlock: function (a, b) { this._mode.processBlock(a, b) }, _doFinalize: function () { var a = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { a.pad(this._data, this.blockSize); var b = this._process(!0) } else { var b = this._process(!0); a.unpad(b) } return b }, blockSize: 4 }), d.CipherParams = e.extend({ init: function (a) { this.mixIn(a) }, toString: function (a) { return (a || this.formatter).stringify(this) } })), s = c.format = {}, t = s.OpenSSL = { stringify: function (a) { var b = a.ciphertext, c = a.salt; if (c) var d = f.create([1398893684, 1701076831]).concat(c).concat(b); else var d = b; return d.toString(i) }, parse: function (a) { var b = i.parse(a), c = b.words; if (1398893684 == c[0] && 1701076831 == c[1]) { var d = f.create(c.slice(2, 4)); c.splice(0, 4), b.sigBytes -= 16 } return r.create({ ciphertext: b, salt: d }) } }, u = d.SerializableCipher = e.extend({ cfg: e.extend({ format: t }), encrypt: function (a, b, c, d) { d = this.cfg.extend(d); var e = a.createEncryptor(c, d), f = e.finalize(b), g = e.cfg; return r.create({ ciphertext: f, key: c, iv: g.iv, algorithm: a, mode: g.mode, padding: g.padding, blockSize: a.blockSize, formatter: d.format }) }, decrypt: function (a, b, c, d) { d = this.cfg.extend(d), b = this._parse(b, d.format); var e = a.createDecryptor(c, d).finalize(b.ciphertext); return e }, _parse: function (a, b) { return "string" == typeof a ? b.parse(a, this) : a } }), v = c.kdf = {}, w = v.OpenSSL = { execute: function (a, b, c, d) { d || (d = f.random(8)); var e = k.create({ keySize: b + c }).compute(a, d), g = f.create(e.words.slice(b), 4 * c); return e.sigBytes = 4 * b, r.create({ key: e, iv: g, salt: d }) } }, x = d.PasswordBasedCipher = u.extend({ cfg: u.cfg.extend({ kdf: w }), encrypt: function (a, b, c, d) { d = this.cfg.extend(d); var e = d.kdf.execute(c, a.keySize, a.ivSize); d.iv = e.iv; var f = u.encrypt.call(this, a, b, e.key, d); return f.mixIn(e), f }, decrypt: function (a, b, c, d) { d = this.cfg.extend(d), b = this._parse(b, d.format); var e = d.kdf.execute(c, a.keySize, a.ivSize, b.salt); d.iv = e.iv; var f = u.decrypt.call(this, a, b, e.key, d); return f } }) }()
}, { "./core": 28 }], 28: [function (a, b, c) {/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var d = d || function (a, b) { var c = {}, d = c.lib = {}, e = d.Base = function () { function a() { } return { extend: function (b) { a.prototype = this; var c = new a; return b && c.mixIn(b), c.hasOwnProperty("init") || (c.init = function () { c.$super.init.apply(this, arguments) }), c.init.prototype = c, c.$super = this, c }, create: function () { var a = this.extend(); return a.init.apply(a, arguments), a }, init: function () { }, mixIn: function (a) { for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } } }(), f = d.WordArray = e.extend({ init: function (a, c) { a = this.words = a || [], this.sigBytes = c != b ? c : 4 * a.length }, toString: function (a) { return (a || h).stringify(this) }, concat: function (a) { var b = this.words, c = a.words, d = this.sigBytes, e = a.sigBytes; if (this.clamp(), d % 4) for (var f = 0; e > f; f++) { var g = c[f >>> 2] >>> 24 - f % 4 * 8 & 255; b[d + f >>> 2] |= g << 24 - (d + f) % 4 * 8 } else if (c.length > 65535) for (var f = 0; e > f; f += 4) b[d + f >>> 2] = c[f >>> 2]; else b.push.apply(b, c); return this.sigBytes += e, this }, clamp: function () { var b = this.words, c = this.sigBytes; b[c >>> 2] &= 4294967295 << 32 - c % 4 * 8, b.length = a.ceil(c / 4) }, clone: function () { var a = e.clone.call(this); return a.words = this.words.slice(0), a }, random: function (b) { for (var c = [], d = 0; b > d; d += 4) c.push(4294967296 * a.random() | 0); return new f.init(c, b) } }), g = c.enc = {}, h = g.Hex = { stringify: function (a) { for (var b = a.words, c = a.sigBytes, d = [], e = 0; c > e; e++) { var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; d.push((f >>> 4).toString(16)), d.push((15 & f).toString(16)) } return d.join("") }, parse: function (a) { for (var b = a.length, c = [], d = 0; b > d; d += 2) c[d >>> 3] |= parseInt(a.substr(d, 2), 16) << 24 - d % 8 * 4; return new f.init(c, b / 2) } }, i = g.Latin1 = { stringify: function (a) { for (var b = a.words, c = a.sigBytes, d = [], e = 0; c > e; e++) { var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; d.push(String.fromCharCode(f)) } return d.join("") }, parse: function (a) { for (var b = a.length, c = [], d = 0; b > d; d++) c[d >>> 2] |= (255 & a.charCodeAt(d)) << 24 - d % 4 * 8; return new f.init(c, b) } }, j = g.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(i.stringify(a))) } catch (b) { throw new Error("Malformed UTF-8 data") } }, parse: function (a) { return i.parse(unescape(encodeURIComponent(a))) } }, k = d.BufferedBlockAlgorithm = e.extend({ reset: function () { this._data = new f.init, this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = j.parse(a)), this._data.concat(a), this._nDataBytes += a.sigBytes }, _process: function (b) { var c = this._data, d = c.words, e = c.sigBytes, g = this.blockSize, h = 4 * g, i = e / h; i = b ? a.ceil(i) : a.max((0 | i) - this._minBufferSize, 0); var j = i * g, k = a.min(4 * j, e); if (j) { for (var l = 0; j > l; l += g) this._doProcessBlock(d, l); var m = d.splice(0, j); c.sigBytes -= k } return new f.init(m, k) }, clone: function () { var a = e.clone.call(this); return a._data = this._data.clone(), a }, _minBufferSize: 0 }), l = (d.Hasher = k.extend({ cfg: e.extend(), init: function (a) { this.cfg = this.cfg.extend(a), this.reset() }, reset: function () { k.reset.call(this), this._doReset() }, update: function (a) { return this._append(a), this._process(), this }, finalize: function (a) { a && this._append(a); var b = this._doFinalize(); return b }, blockSize: 16, _createHelper: function (a) { return function (b, c) { return new a.init(c).finalize(b) } }, _createHmacHelper: function (a) { return function (b, c) { return new l.HMAC.init(a, c).finalize(b) } } }), c.algo = {}); return c }(Math); c.CryptoJS = d
}, {}], 29: [function (a) {
var b = a("./core").CryptoJS;/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
!function () { { var a = b, c = a.lib, d = c.WordArray, e = a.enc; e.Base64 = { stringify: function (a) { var b = a.words, c = a.sigBytes, d = this._map; a.clamp(); for (var e = [], f = 0; c > f; f += 3) for (var g = b[f >>> 2] >>> 24 - f % 4 * 8 & 255, h = b[f + 1 >>> 2] >>> 24 - (f + 1) % 4 * 8 & 255, i = b[f + 2 >>> 2] >>> 24 - (f + 2) % 4 * 8 & 255, j = g << 16 | h << 8 | i, k = 0; 4 > k && c > f + .75 * k; k++) e.push(d.charAt(j >>> 6 * (3 - k) & 63)); var l = d.charAt(64); if (l) for (; e.length % 4;) e.push(l); return e.join("") }, parse: function (a) { var b = a.length, c = this._map, e = c.charAt(64); if (e) { var f = a.indexOf(e); -1 != f && (b = f) } for (var g = [], h = 0, i = 0; b > i; i++) if (i % 4) { var j = c.indexOf(a.charAt(i - 1)) << i % 4 * 2, k = c.indexOf(a.charAt(i)) >>> 6 - i % 4 * 2; g[h >>> 2] |= (j | k) << 24 - h % 4 * 8, h++ } return d.create(g, h) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } } }()
}, { "./core": 28 }], 30: [function (a) {
var b = a("./core").CryptoJS;/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
!function () { var a = b, c = a.lib, d = c.Base, e = c.WordArray, f = a.algo, g = f.MD5, h = f.EvpKDF = d.extend({ cfg: d.extend({ keySize: 4, hasher: g, iterations: 1 }), init: function (a) { this.cfg = this.cfg.extend(a) }, compute: function (a, b) { for (var c = this.cfg, d = c.hasher.create(), f = e.create(), g = f.words, h = c.keySize, i = c.iterations; g.length < h;) { j && d.update(j); var j = d.update(a).finalize(b); d.reset(); for (var k = 1; i > k; k++) j = d.finalize(j), d.reset(); f.concat(j) } return f.sigBytes = 4 * h, f } }); a.EvpKDF = function (a, b, c) { return h.create(c).compute(a, b) } }()
}, { "./core": 28 }], 31: [function (a, b, c) { var d = a("./core").CryptoJS, e = { stringify: function (a) { var b = { ct: a.ciphertext.toString(d.enc.Base64) }; return a.iv && (b.iv = a.iv.toString()), a.salt && (b.s = a.salt.toString()), JSON.stringify(b) }, parse: function (a) { var b = JSON.parse(a), c = d.lib.CipherParams.create({ ciphertext: d.enc.Base64.parse(b.ct) }); return b.iv && (c.iv = d.enc.Hex.parse(b.iv)), b.s && (c.salt = d.enc.Hex.parse(b.s)), c } }; c.JsonFormatter = e }, { "./core": 28 }], 32: [function (a) {
var b = a("./core").CryptoJS;/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
!function (a) { function c(a, b, c, d, e, f, g) { var h = a + (b & c | ~b & d) + e + g; return (h << f | h >>> 32 - f) + b } function d(a, b, c, d, e, f, g) { var h = a + (b & d | c & ~d) + e + g; return (h << f | h >>> 32 - f) + b } function e(a, b, c, d, e, f, g) { var h = a + (b ^ c ^ d) + e + g; return (h << f | h >>> 32 - f) + b } function f(a, b, c, d, e, f, g) { var h = a + (c ^ (b | ~d)) + e + g; return (h << f | h >>> 32 - f) + b } var g = b, h = g.lib, i = h.WordArray, j = h.Hasher, k = g.algo, l = []; !function () { for (var b = 0; 64 > b; b++) l[b] = 4294967296 * a.abs(a.sin(b + 1)) | 0 }(); var m = k.MD5 = j.extend({ _doReset: function () { this._hash = new i.init([1732584193, 4023233417, 2562383102, 271733878]) }, _doProcessBlock: function (a, b) { for (var g = 0; 16 > g; g++) { var h = b + g, i = a[h]; a[h] = 16711935 & (i << 8 | i >>> 24) | 4278255360 & (i << 24 | i >>> 8) } var j = this._hash.words, k = a[b + 0], m = a[b + 1], n = a[b + 2], o = a[b + 3], p = a[b + 4], q = a[b + 5], r = a[b + 6], s = a[b + 7], t = a[b + 8], u = a[b + 9], v = a[b + 10], w = a[b + 11], x = a[b + 12], y = a[b + 13], z = a[b + 14], A = a[b + 15], B = j[0], C = j[1], D = j[2], E = j[3]; B = c(B, C, D, E, k, 7, l[0]), E = c(E, B, C, D, m, 12, l[1]), D = c(D, E, B, C, n, 17, l[2]), C = c(C, D, E, B, o, 22, l[3]), B = c(B, C, D, E, p, 7, l[4]), E = c(E, B, C, D, q, 12, l[5]), D = c(D, E, B, C, r, 17, l[6]), C = c(C, D, E, B, s, 22, l[7]), B = c(B, C, D, E, t, 7, l[8]), E = c(E, B, C, D, u, 12, l[9]), D = c(D, E, B, C, v, 17, l[10]), C = c(C, D, E, B, w, 22, l[11]), B = c(B, C, D, E, x, 7, l[12]), E = c(E, B, C, D, y, 12, l[13]), D = c(D, E, B, C, z, 17, l[14]), C = c(C, D, E, B, A, 22, l[15]), B = d(B, C, D, E, m, 5, l[16]), E = d(E, B, C, D, r, 9, l[17]), D = d(D, E, B, C, w, 14, l[18]), C = d(C, D, E, B, k, 20, l[19]), B = d(B, C, D, E, q, 5, l[20]), E = d(E, B, C, D, v, 9, l[21]), D = d(D, E, B, C, A, 14, l[22]), C = d(C, D, E, B, p, 20, l[23]), B = d(B, C, D, E, u, 5, l[24]), E = d(E, B, C, D, z, 9, l[25]), D = d(D, E, B, C, o, 14, l[26]), C = d(C, D, E, B, t, 20, l[27]), B = d(B, C, D, E, y, 5, l[28]), E = d(E, B, C, D, n, 9, l[29]), D = d(D, E, B, C, s, 14, l[30]), C = d(C, D, E, B, x, 20, l[31]), B = e(B, C, D, E, q, 4, l[32]), E = e(E, B, C, D, t, 11, l[33]), D = e(D, E, B, C, w, 16, l[34]), C = e(C, D, E, B, z, 23, l[35]), B = e(B, C, D, E, m, 4, l[36]), E = e(E, B, C, D, p, 11, l[37]), D = e(D, E, B, C, s, 16, l[38]), C = e(C, D, E, B, v, 23, l[39]), B = e(B, C, D, E, y, 4, l[40]), E = e(E, B, C, D, k, 11, l[41]), D = e(D, E, B, C, o, 16, l[42]), C = e(C, D, E, B, r, 23, l[43]), B = e(B, C, D, E, u, 4, l[44]), E = e(E, B, C, D, x, 11, l[45]), D = e(D, E, B, C, A, 16, l[46]), C = e(C, D, E, B, n, 23, l[47]), B = f(B, C, D, E, k, 6, l[48]), E = f(E, B, C, D, s, 10, l[49]), D = f(D, E, B, C, z, 15, l[50]), C = f(C, D, E, B, q, 21, l[51]), B = f(B, C, D, E, x, 6, l[52]), E = f(E, B, C, D, o, 10, l[53]), D = f(D, E, B, C, v, 15, l[54]), C = f(C, D, E, B, m, 21, l[55]), B = f(B, C, D, E, t, 6, l[56]), E = f(E, B, C, D, A, 10, l[57]), D = f(D, E, B, C, r, 15, l[58]), C = f(C, D, E, B, y, 21, l[59]), B = f(B, C, D, E, p, 6, l[60]), E = f(E, B, C, D, w, 10, l[61]), D = f(D, E, B, C, n, 15, l[62]), C = f(C, D, E, B, u, 21, l[63]), j[0] = j[0] + B | 0, j[1] = j[1] + C | 0, j[2] = j[2] + D | 0, j[3] = j[3] + E | 0 }, _doFinalize: function () { var b = this._data, c = b.words, d = 8 * this._nDataBytes, e = 8 * b.sigBytes; c[e >>> 5] |= 128 << 24 - e % 32; var f = a.floor(d / 4294967296), g = d; c[(e + 64 >>> 9 << 4) + 15] = 16711935 & (f << 8 | f >>> 24) | 4278255360 & (f << 24 | f >>> 8), c[(e + 64 >>> 9 << 4) + 14] = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), b.sigBytes = 4 * (c.length + 1), this._process(); for (var h = this._hash, i = h.words, j = 0; 4 > j; j++) { var k = i[j]; i[j] = 16711935 & (k << 8 | k >>> 24) | 4278255360 & (k << 24 | k >>> 8) } return h }, clone: function () { var a = j.clone.call(this); return a._hash = this._hash.clone(), a } }); g.MD5 = j._createHelper(m), g.HmacMD5 = j._createHmacHelper(m) }(Math)
}, { "./core": 28 }], 33: [function (require, module, exports) {/*!
* Reqwest! A general purpose XHR connection manager
* license MIT (c) Dustin Diaz 2014
* https://github.com/ded/reqwest
*/
!function (a, b, c) { "undefined" != typeof module && module.exports ? module.exports = c() : "function" == typeof define && define.amd ? define(c) : b[a] = c() }("reqwest", this, function () { function succeed(a) { var b = protocolRe.exec(a.url); return b = b && b[1] || window.location.protocol, httpsRe.test(b) ? twoHundo.test(a.request.status) : !!a.request.response } function handleReadyState(a, b, c) { return function () { return a._aborted ? c(a.request) : a._timedOut ? c(a.request, "Request is aborted: timeout") : void (a.request && 4 == a.request[readyState] && (a.request.onreadystatechange = noop, succeed(a) ? b(a.request) : c(a.request))) } } function setHeaders(a, b) { var c, d = b.headers || {}; d.Accept = d.Accept || defaultHeaders.accept[b.type] || defaultHeaders.accept["*"]; var e = "function" == typeof FormData && b.data instanceof FormData; b.crossOrigin || d[requestedWith] || (d[requestedWith] = defaultHeaders.requestedWith), d[contentType] || e || (d[contentType] = b.contentType || defaultHeaders.contentType); for (c in d) d.hasOwnProperty(c) && "setRequestHeader" in a && a.setRequestHeader(c, d[c]) } function setCredentials(a, b) { "undefined" != typeof b.withCredentials && "undefined" != typeof a.withCredentials && (a.withCredentials = !!b.withCredentials) } function generalCallback(a) { lastValue = a } function urlappend(a, b) { return a + (/\?/.test(a) ? "&" : "?") + b } function handleJsonp(a, b, c, d) { var e = uniqid++, f = a.jsonpCallback || "callback", g = a.jsonpCallbackName || reqwest.getcallbackPrefix(e), h = new RegExp("((^|\\?|&)" + f + ")=([^&]+)"), i = d.match(h), j = doc.createElement("script"), k = 0, l = -1 !== navigator.userAgent.indexOf("MSIE 10.0"); return i ? "?" === i[3] ? d = d.replace(h, "$1=" + g) : g = i[3] : d = urlappend(d, f + "=" + g), win[g] = generalCallback, j.type = "text/javascript", j.src = d, j.async = !0, "undefined" == typeof j.onreadystatechange || l || (j.htmlFor = j.id = "_reqwest_" + e), j.onload = j.onreadystatechange = function () { return j[readyState] && "complete" !== j[readyState] && "loaded" !== j[readyState] || k ? !1 : (j.onload = j.onreadystatechange = null, j.onclick && j.onclick(), b(lastValue), lastValue = void 0, head.removeChild(j), void (k = 1)) }, head.appendChild(j), { abort: function () { j.onload = j.onreadystatechange = null, c({}, "Request is aborted: timeout", {}), lastValue = void 0, head.removeChild(j), k = 1 } } } function getRequest(a, b) { var c, d = this.o, e = (d.method || "GET").toUpperCase(), f = "string" == typeof d ? d : d.url, g = d.processData !== !1 && d.data && "string" != typeof d.data ? reqwest.toQueryString(d.data) : d.data || null, h = !1; return "jsonp" != d.type && "GET" != e || !g || (f = urlappend(f, g), g = null), "jsonp" == d.type ? handleJsonp(d, a, b, f) : (c = d.xhr && d.xhr(d) || xhr(d), c.open(e, f, d.async === !1 ? !1 : !0), setHeaders(c, d), setCredentials(c, d), win[xDomainRequest] && c instanceof win[xDomainRequest] ? (c.onload = a, c.onerror = b, c.onprogress = function () { }, h = !0) : c.onreadystatechange = handleReadyState(this, a, b), d.before && d.before(c), h ? setTimeout(function () { c.send(g) }, 200) : c.send(g), c) } function Reqwest(a, b) { this.o = a, this.fn = b, init.apply(this, arguments) } function setType(a) { return a.match("json") ? "json" : a.match("javascript") ? "js" : a.match("text") ? "html" : a.match("xml") ? "xml" : void 0 } function init(o, fn) { function complete(a) { for (o.timeout && clearTimeout(self.timeout), self.timeout = null; self._completeHandlers.length > 0;) self._completeHandlers.shift()(a) } function success(resp) { var type = o.type || resp && setType(resp.getResponseHeader("Content-Type")); resp = "jsonp" !== type ? self.request : resp; var filteredResponse = globalSetupOptions.dataFilter(resp.responseText, type), r = filteredResponse; try { resp.responseText = r } catch (e) { } if (r) switch (type) { case "json": try { resp = win.JSON ? win.JSON.parse(r) : eval("(" + r + ")") } catch (err) { return error(resp, "Could not parse JSON in response", err) } break; case "js": resp = eval(r); break; case "html": resp = r; break; case "xml": resp = resp.responseXML && resp.responseXML.parseError && resp.responseXML.parseError.errorCode && resp.responseXML.parseError.reason ? null : resp.responseXML } for (self._responseArgs.resp = resp, self._fulfilled = !0, fn(resp), self._successHandler(resp) ; self._fulfillmentHandlers.length > 0;) resp = self._fulfillmentHandlers.shift()(resp); complete(resp) } function timedOut() { self._timedOut = !0, self.request.abort() } function error(a, b, c) { for (a = self.request, self._responseArgs.resp = a, self._responseArgs.msg = b, self._responseArgs.t = c, self._erred = !0; self._errorHandlers.length > 0;) self._errorHandlers.shift()(a, b, c); complete(a) } this.url = "string" == typeof o ? o : o.url, this.timeout = null, this._fulfilled = !1, this._successHandler = function () { }, this._fulfillmentHandlers = [], this._errorHandlers = [], this._completeHandlers = [], this._erred = !1, this._responseArgs = {}; var self = this; fn = fn || function () { }, o.timeout && (this.timeout = setTimeout(function () { timedOut() }, o.timeout)), o.success && (this._successHandler = function () { o.success.apply(o, arguments) }), o.error && this._errorHandlers.push(function () { o.error.apply(o, arguments) }), o.complete && this._completeHandlers.push(function () { o.complete.apply(o, arguments) }), this.request = getRequest.call(this, success, error) } function reqwest(a, b) { return new Reqwest(a, b) } function normalize(a) { return a ? a.replace(/\r?\n/g, "\r\n") : "" } function serial(a, b) { var c, d, e, f, g = a.name, h = a.tagName.toLowerCase(), i = function (a) { a && !a.disabled && b(g, normalize(a.attributes.value && a.attributes.value.specified ? a.value : a.text)) }; if (!a.disabled && g) switch (h) { case "input": /reset|button|image|file/i.test(a.type) || (c = /checkbox/i.test(a.type), d = /radio/i.test(a.type), e = a.value, (!(c || d) || a.checked) && b(g, normalize(c && "" === e ? "on" : e))); break; case "textarea": b(g, normalize(a.value)); break; case "select": if ("select-one" === a.type.toLowerCase()) i(a.selectedIndex >= 0 ? a.options[a.selectedIndex] : null); else for (f = 0; a.length && f < a.length; f++) a.options[f].selected && i(a.options[f]) } } function eachFormElement() { var a, b, c = this, d = function (a, b) { var d, e, f; for (d = 0; d < b.length; d++) for (f = a[byTag](b[d]), e = 0; e < f.length; e++) serial(f[e], c) }; for (b = 0; b < arguments.length; b++) a = arguments[b], /input|select|textarea/i.test(a.tagName) && serial(a, c), d(a, ["input", "select", "textarea"]) } function serializeQueryString() { return reqwest.toQueryString(reqwest.serializeArray.apply(null, arguments)) } function serializeHash() { var a = {}; return eachFormElement.apply(function (b, c) { b in a ? (a[b] && !isArray(a[b]) && (a[b] = [a[b]]), a[b].push(c)) : a[b] = c }, arguments), a } function buildParams(a, b, c, d) { var e, f, g, h = /\[\]$/; if (isArray(b)) for (f = 0; b && f < b.length; f++) g = b[f], c || h.test(a) ? d(a, g) : buildParams(a + "[" + ("object" == typeof g ? f : "") + "]", g, c, d); else if (b && "[object Object]" === b.toString()) for (e in b) buildParams(a + "[" + e + "]", b[e], c, d); else d(a, b) } var win = window, doc = document, httpsRe = /^http/, protocolRe = /(^\w+):\/\//, twoHundo = /^(20\d|1223)$/, byTag = "getElementsByTagName", readyState = "readyState", contentType = "Content-Type", requestedWith = "X-Requested-With", head = doc[byTag]("head")[0], uniqid = 0, callbackPrefix = "reqwest_" + +new Date, lastValue, xmlHttpRequest = "XMLHttpRequest", xDomainRequest = "XDomainRequest", noop = function () { }, isArray = "function" == typeof Array.isArray ? Array.isArray : function (a) { return a instanceof Array }, defaultHeaders = { contentType: "application/x-www-form-urlencoded", requestedWith: xmlHttpRequest, accept: { "*": "text/javascript, text/html, application/xml, text/xml, */*", xml: "application/xml, text/xml", html: "text/html", text: "text/plain", json: "application/json, text/javascript", js: "application/javascript, text/javascript" } }, xhr = function (a) { if (a.crossOrigin === !0) { var b = win[xmlHttpRequest] ? new XMLHttpRequest : null; if (b && "withCredentials" in b) return b; if (win[xDomainRequest]) return new XDomainRequest; throw new Error("Browser does not support cross-origin requests") } return win[xmlHttpRequest] ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP") }, globalSetupOptions = { dataFilter: function (a) { return a } }; return Reqwest.prototype = { abort: function () { this._aborted = !0, this.request.abort() }, retry: function () { init.call(this, this.o, this.fn) }, then: function (a, b) { return a = a || function () { }, b = b || function () { }, this._fulfilled ? this._responseArgs.resp = a(this._responseArgs.resp) : this._erred ? b(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) : (this._fulfillmentHandlers.push(a), this._errorHandlers.push(b)), this }, always: function (a) { return this._fulfilled || this._erred ? a(this._responseArgs.resp) : this._completeHandlers.push(a), this }, fail: function (a) { return this._erred ? a(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) : this._errorHandlers.push(a), this }, "catch": function (a) { return this.fail(a) } }, reqwest.serializeArray = function () { var a = []; return eachFormElement.apply(function (b, c) { a.push({ name: b, value: c }) }, arguments), a }, reqwest.serialize = function () { if (0 === arguments.length) return ""; var a, b, c = Array.prototype.slice.call(arguments, 0); return a = c.pop(), a && a.nodeType && c.push(a) && (a = null), a && (a = a.type), b = "map" == a ? serializeHash : "array" == a ? reqwest.serializeArray : serializeQueryString, b.apply(null, c) }, reqwest.toQueryString = function (a, b) { var c, d, e = b || !1, f = [], g = encodeURIComponent, h = function (a, b) { b = "function" == typeof b ? b() : null == b ? "" : b, f[f.length] = g(a) + "=" + g(b) }; if (isArray(a)) for (d = 0; a && d < a.length; d++) h(a[d].name, a[d].value); else for (c in a) a.hasOwnProperty(c) && buildParams(c, a[c], e, h); return f.join("&").replace(/%20/g, "+") }, reqwest.getcallbackPrefix = function () { return callbackPrefix }, reqwest.compat = function (a, b) { return a && (a.type && (a.method = a.type) && delete a.type, a.dataType && (a.type = a.dataType), a.jsonpCallback && (a.jsonpCallbackName = a.jsonpCallback) && delete a.jsonpCallback, a.jsonp && (a.jsonpCallback = a.jsonp)), new Reqwest(a, b) }, reqwest.ajaxSetup = function (a) { a = a || {}; for (var b in a) globalSetupOptions[b] = a[b] }, reqwest })
}, {}], 34: [function (a, b) {
(function (c) {/*!
* @overview RSVP - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE
* @version 3.0.17
*/
(function () { "use strict"; function d(a) { return "function" == typeof a || "object" == typeof a && null !== a } function e(a) { return "function" == typeof a } function f(a) { return "object" == typeof a && null !== a } function g() { } function h(a, b) { for (var c = 0, d = a.length; d > c; c++) if (a[c] === b) return c; return -1 } function i(a) { var b = a._promiseCallbacks; return b || (b = a._promiseCallbacks = {}), b } function j(a, b) { return "onerror" === a ? void ya.on("error", b) : 2 !== arguments.length ? ya[a] : void (ya[a] = b) } function k() { setTimeout(function () { for (var a, b = 0; b < za.length; b++) { a = za[b]; var c = a.payload; c.guid = c.key + c.id, c.childGuid = c.key + c.childId, c.error && (c.stack = c.error.stack), ya.trigger(a.name, a.payload) } za.length = 0 }, 50) } function l(a, b, c) { 1 === za.push({ name: a, payload: { key: b._guidKey, id: b._id, eventName: a, detail: b._result, childId: c && c._id, label: b._label, timeStamp: va(), error: ya["instrument-with-stack"] ? new Error(b._label) : null } }) && k() } function m() { return new TypeError("A promises callback cannot return that same promise.") } function n() { } function o(a) { try { return a.then } catch (b) { return Ea.error = b, Ea } } function p(a, b, c, d) { try { a.call(b, c, d) } catch (e) { return e } } function q(a, b, c) { ya.async(function (a) { var d = !1, e = p(c, b, function (c) { d || (d = !0, b !== c ? t(a, c) : v(a, c)) }, function (b) { d || (d = !0, w(a, b)) }, "Settle: " + (a._label || " unknown promise")); !d && e && (d = !0, w(a, e)) }, a) } function r(a, b) { b._state === Ca ? v(a, b._result) : b._state === Da ? (b._onError = null, w(a, b._result)) : x(b, void 0, function (c) { b !== c ? t(a, c) : v(a, c) }, function (b) { w(a, b) }) } function s(a, b) { if (b.constructor === a.constructor) r(a, b); else { var c = o(b); c === Ea ? w(a, Ea.error) : void 0 === c ? v(a, b) : e(c) ? q(a, b, c) : v(a, b) } } function t(a, b) { a === b ? v(a, b) : d(b) ? s(a, b) : v(a, b) } function u(a) { a._onError && a._onError(a._result), y(a) } function v(a, b) { a._state === Ba && (a._result = b, a._state = Ca, 0 === a._subscribers.length ? ya.instrument && Aa("fulfilled", a) : ya.async(y, a)) } function w(a, b) { a._state === Ba && (a._state = Da, a._result = b, ya.async(u, a)) } function x(a, b, c, d) { var e = a._subscribers, f = e.length; a._onError = null, e[f] = b, e[f + Ca] = c, e[f + Da] = d, 0 === f && a._state && ya.async(y, a) } function y(a) { var b = a._subscribers, c = a._state; if (ya.instrument && Aa(c === Ca ? "fulfilled" : "rejected", a), 0 !== b.length) { for (var d, e, f = a._result, g = 0; g < b.length; g += 3) d = b[g], e = b[g + c], d ? B(c, d, e, f) : e(f); a._subscribers.length = 0 } } function z() { this.error = null } function A(a, b) { try { return a(b) } catch (c) { return Fa.error = c, Fa } } function B(a, b, c, d) { var f, g, h, i, j = e(c); if (j) { if (f = A(c, d), f === Fa ? (i = !0, g = f.error, f = null) : h = !0, b === f) return void w(b, m()) } else f = d, h = !0; b._state !== Ba || (j && h ? t(b, f) : i ? w(b, g) : a === Ca ? v(b, f) : a === Da && w(b, f)) } function C(a, b) { var c = !1; try { b(function (b) { c || (c = !0, t(a, b)) }, function (b) { c || (c = !0, w(a, b)) }) } catch (d) { w(a, d) } } function D(a, b, c) { return a === Ca ? { state: "fulfilled", value: c } : { state: "rejected", reason: c } } function E(a, b, c, d) { this._instanceConstructor = a, this.promise = new a(n, d), this._abortOnReject = c, this._validateInput(b) ? (this._input = b, this.length = b.length, this._remaining = b.length, this._init(), 0 === this.length ? v(this.promise, this._result) : (this.length = this.length || 0, this._enumerate(), 0 === this._remaining && v(this.promise, this._result))) : w(this.promise, this._validationError()) } function F(a, b) { return new Ga(this, a, !0, b).promise } function G(a, b) { function c(a) { t(f, a) } function d(a) { w(f, a) } var e = this, f = new e(n, b); if (!ua(a)) return w(f, new TypeError("You must pass an array to race.")), f; for (var g = a.length, h = 0; f._state === Ba && g > h; h++) x(e.resolve(a[h]), void 0, c, d); return f } function H(a, b) { var c = this; if (a && "object" == typeof a && a.constructor === c) return a; var d = new c(n, b); return t(d, a), d } function I(a, b) { var c = this, d = new c(n, b); return w(d, a), d } function J() { throw new TypeError("You must pass a resolver function as the first argument to the promise constructor") } function K() { throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.") } function L(a, b) { this._id = Ma++, this._label = b, this._state = void 0, this._result = void 0, this._subscribers = [], ya.instrument && Aa("created", this), n !== a && (e(a) || J(), this instanceof L || K(), C(this, a)) } function M(a, b, c) { this._superConstructor(a, b, !1, c) } function N(a, b) { return new M(Na, a, b).promise } function O(a, b) { return Na.all(a, b) } function P(a, b) { Za[Sa] = a, Za[Sa + 1] = b, Sa += 2, 2 === Sa && Pa() } function Q() { var a = c.nextTick, b = c.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); return Array.isArray(b) && "0" === b[1] && "10" === b[2] && (a = setImmediate), function () { a(V) } } function R() { return function () { Oa(V) } } function S() { var a = 0, b = new Wa(V), c = document.createTextNode(""); return b.observe(c, { characterData: !0 }), function () { c.data = a = ++a % 2 } } function T() { var a = new MessageChannel; return a.port1.onmessage = V, function () { a.port2.postMessage(0) } } function U() { return function () { setTimeout(V, 1) } } function V() { for (var a = 0; Sa > a; a += 2) { var b = Za[a], c = Za[a + 1]; b(c), Za[a] = void 0, Za[a + 1] = void 0 } Sa = 0 } function W() { try { var b = a, c = b("vertx"); return Oa = c.runOnLoop || c.runOnContext, R() } catch (d) { return U() } } function X(a) { var b = {}; return b.promise = new Na(function (a, c) { b.resolve = a, b.reject = c }, a), b } function Y(a, b, c) { return Na.all(a, c).then(function (a) { if (!e(b)) throw new TypeError("You must pass a function as filter's second argument."); for (var d = a.length, f = new Array(d), g = 0; d > g; g++) f[g] = b(a[g]); return Na.all(f, c).then(function (b) { for (var c = new Array(d), e = 0, f = 0; d > f; f++) b[f] && (c[e] = a[f], e++); return c.length = e, c }) }) } function Z(a, b, c) { this._superConstructor(a, b, !0, c) } function $(a, b, c) { this._superConstructor(a, b, !1, c) } function _(a, b) { return new $(Na, a, b).promise } function aa(a, b) { return new ab(Na, a, b).promise } function ba(a, b, c) { return Na.all(a, c).then(function (a) { if (!e(b)) throw new TypeError("You must pass a function as map's second argument."); for (var d = a.length, f = new Array(d), g = 0; d > g; g++) f[g] = b(a[g]); return Na.all(f, c) }) } function ca() { this.value = void 0 } function da(a) { try { return a.then } catch (b) { return eb.value = b, eb } } function ea(a, b, c) { try { a.apply(b, c) } catch (d) { return eb.value = d, eb } } function fa(a, b) { for (var c, d, e = {}, f = a.length, g = new Array(f), h = 0; f > h; h++) g[h] = a[h]; for (d = 0; d < b.length; d++) c = b[d], e[c] = g[d + 1]; return e } function ga(a) { for (var b = a.length, c = new Array(b - 1), d = 1; b > d; d++) c[d - 1] = a[d]; return c } function ha(a, b) { return { then: function (c, d) { return a.call(b, c, d) } } } function ia(a, b) { var c = function () { for (var c, d = this, e = arguments.length, f = new Array(e + 1), g = !1, h = 0; e > h; ++h) { if (c = arguments[h], !g) { if (g = la(c), g === fb) { var i = new Na(n); return w(i, fb.value), i } g && g !== !0 && (c = ha(g, c)) } f[h] = c } var j = new Na(n); return f[e] = function (a, c) { a ? w(j, a) : void 0 === b ? t(j, c) : b === !0 ? t(j, ga(arguments)) : ua(b) ? t(j, fa(arguments, b)) : t(j, c) }, g ? ka(j, f, a, d) : ja(j, f, a, d) }; return c.__proto__ = a, c } function ja(a, b, c, d) { var e = ea(c, d, b); return e === eb && w(a, e.value), a } function ka(a, b, c, d) { return Na.all(b).then(function (b) { var e = ea(c, d, b); return e === eb && w(a, e.value), a }) } function la(a) { return a && "object" == typeof a ? a.constructor === Na ? !0 : da(a) : !1 } function ma(a, b) { return Na.race(a, b) } function na(a, b) { return Na.reject(a, b) } function oa(a, b) { return Na.resolve(a, b) } function pa(a) { throw setTimeout(function () { throw a }), a } function qa(a, b) { ya.async(a, b) } function ra() { ya.on.apply(ya, arguments) } function sa() { ya.off.apply(ya, arguments) } var ta; ta = Array.isArray ? Array.isArray : function (a) { return "[object Array]" === Object.prototype.toString.call(a) }; var ua = ta, va = Date.now || function () { return (new Date).getTime() }, wa = Object.create || function (a) { if (arguments.length > 1) throw new Error("Second argument not supported"); if ("object" != typeof a) throw new TypeError("Argument must be an object"); return g.prototype = a, new g }, xa = { mixin: function (a) { return a.on = this.on, a.off = this.off, a.trigger = this.trigger, a._promiseCallbacks = void 0, a }, on: function (a, b) { var c, d = i(this); c = d[a], c || (c = d[a] = []), -1 === h(c, b) && c.push(b) }, off: function (a, b) { var c, d, e = i(this); return b ? (c = e[a], d = h(c, b), void (-1 !== d && c.splice(d, 1))) : void (e[a] = []) }, trigger: function (a, b) { var c, d, e = i(this); if (c = e[a]) for (var f = 0; f < c.length; f++) (d = c[f])(b) } }, ya = { instrument: !1 }; xa.mixin(ya); var za = [], Aa = l, Ba = void 0, Ca = 1, Da = 2, Ea = new z, Fa = new z, Ga = E; E.prototype._validateInput = function (a) { return ua(a) }, E.prototype._validationError = function () { return new Error("Array Methods must be provided an Array") }, E.prototype._init = function () { this._result = new Array(this.length) }, E.prototype._enumerate = function () { for (var a = this.length, b = this.promise, c = this._input, d = 0; b._state === Ba && a > d; d++) this._eachEntry(c[d], d) }, E.prototype._eachEntry = function (a, b) { var c = this._instanceConstructor; f(a) ? a.constructor === c && a._state !== Ba ? (a._onError = null, this._settledAt(a._state, b, a._result)) : this._willSettleAt(c.resolve(a), b) : (this._remaining--, this._result[b] = this._makeResult(Ca, b, a)) }, E.prototype._settledAt = function (a, b, c) { var d = this.promise; d._state === Ba && (this._remaining--, this._abortOnReject && a === Da ? w(d, c) : this._result[b] = this._makeResult(a, b, c)), 0 === this._remaining && v(d, this._result) }, E.prototype._makeResult = function (a, b, c) { return c }, E.prototype._willSettleAt = function (a, b) { var c = this; x(a, void 0, function (a) { c._settledAt(Ca, b, a) }, function (a) { c._settledAt(Da, b, a) }) }; var Ha = F, Ia = G, Ja = H, Ka = I, La = "rsvp_" + va() + "-", Ma = 0, Na = L; L.cast = Ja, L.all = Ha, L.race = Ia, L.resolve = Ja, L.reject = Ka, L.prototype = { constructor: L, _guidKey: La, _onError: function (a) { ya.async(function (b) { setTimeout(function () { b._onError && ya.trigger("error", a) }, 0) }, this) }, then: function (a, b, c) { var d = this, e = d._state; if (e === Ca && !a || e === Da && !b) return ya.instrument && Aa("chained", this, this), this; d._onError = null; var f = new this.constructor(n, c), g = d._result; if (ya.instrument && Aa("chained", d, f), e) { var h = arguments[e - 1]; ya.async(function () { B(e, f, h, g) }) } else x(d, f, a, b); return f }, "catch": function (a, b) { return this.then(null, a, b) }, "finally": function (a, b) { var c = this.constructor; return this.then(function (b) { return c.resolve(a()).then(function () { return b }) }, function (b) { return c.resolve(a()).then(function () { throw b }) }, b) } }, M.prototype = wa(Ga.prototype), M.prototype._superConstructor = Ga, M.prototype._makeResult = D, M.prototype._validationError = function () { return new Error("allSettled must be called with an array") }; var Oa, Pa, Qa = N, Ra = O, Sa = 0, Ta = ({}.toString, P), Ua = "undefined" != typeof window ? window : void 0, Va = Ua || {}, Wa = Va.MutationObserver || Va.WebKitMutationObserver, Xa = "undefined" != typeof c && "[object process]" === {}.toString.call(c), Ya = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel, Za = new Array(1e3); Pa = Xa ? Q() : Wa ? S() : Ya ? T() : void 0 === Ua && "function" == typeof a ? W() : U(); var $a = X, _a = Y, ab = Z; Z.prototype = wa(Ga.prototype), Z.prototype._superConstructor = Ga, Z.prototype._init = function () { this._result = {} }, Z.prototype._validateInput = function (a) { return a && "object" == typeof a }, Z.prototype._validationError = function () { return new Error("Promise.hash must be called with an object") }, Z.prototype._enumerate = function () { var a = this.promise, b = this._input, c = []; for (var d in b) a._state === Ba && b.hasOwnProperty(d) && c.push({ position: d, entry: b[d] }); var e = c.length; this._remaining = e; for (var f, g = 0; a._state === Ba && e > g; g++) f = c[g], this._eachEntry(f.entry, f.position) }, $.prototype = wa(ab.prototype), $.prototype._superConstructor = Ga, $.prototype._makeResult = D, $.prototype._validationError = function () { return new Error("hashSettled must be called with an object") }; var bb = _, cb = aa, db = ba, eb = new ca, fb = new ca, gb = ia, hb = ma, ib = na, jb = oa, kb = pa; ya.async = Ta; if ("undefined" != typeof window && "object" == typeof window.__PROMISE_INSTRUMENTATION__) { var lb = window.__PROMISE_INSTRUMENTATION__; j("instrument", !0); for (var mb in lb) lb.hasOwnProperty(mb) && ra(mb, lb[mb]) } var nb = { race: hb, Promise: Na, allSettled: Qa, hash: cb, hashSettled: bb, denodeify: gb, on: ra, off: sa, map: db, filter: _a, resolve: jb, reject: ib, all: Ra, rethrow: kb, defer: $a, EventTarget: xa, configure: j, async: qa }; "function" == typeof define && define.amd ? define(function () { return nb }) : "undefined" != typeof b && b.exports ? b.exports = nb : "undefined" != typeof this && (this.RSVP = nb) }).call(this)
}).call(this, a("_process"))
}, { _process: 4 }], 35: [function (a, b, c) {
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(function () { function a(a) { function b(b, c, d, e, f, g) { for (; f >= 0 && g > f; f += a) { var h = e ? e[f] : f; d = c(d, b[h], h, b) } return d } return function (c, d, e, f) { d = u(d, f, 4); var g = !z(c) && t.keys(c), h = (g || c).length, i = a > 0 ? 0 : h - 1; return arguments.length < 3 && (e = c[g ? g[i] : i], i += a), b(c, d, e, g, i, h) } } function d(a) { return function (b, c, d) { c = v(c, d); for (var e = null != b && b.length, f = a > 0 ? 0 : e - 1; f >= 0 && e > f; f += a) if (c(b[f], f, b)) return f; return -1 } } function e(a, b) { var c = E.length, d = a.constructor, e = t.isFunction(d) && d.prototype || i, f = "constructor"; for (t.has(a, f) && !t.contains(b, f) && b.push(f) ; c--;) f = E[c], f in a && a[f] !== e[f] && !t.contains(b, f) && b.push(f) } var f = this, g = f._, h = Array.prototype, i = Object.prototype, j = Function.prototype, k = h.push, l = h.slice, m = i.toString, n = i.hasOwnProperty, o = Array.isArray, p = Object.keys, q = j.bind, r = Object.create, s = function () { }, t = function (a) { return a instanceof t ? a : this instanceof t ? void (this._wrapped = a) : new t(a) }; "undefined" != typeof c ? ("undefined" != typeof b && b.exports && (c = b.exports = t), c._ = t) : f._ = t, t.VERSION = "1.8.2"; var u = function (a, b, c) { if (void 0 === b) return a; switch (null == c ? 3 : c) { case 1: return function (c) { return a.call(b, c) }; case 2: return function (c, d) { return a.call(b, c, d) }; case 3: return function (c, d, e) { return a.call(b, c, d, e) }; case 4: return function (c, d, e, f) { return a.call(b, c, d, e, f) } } return function () { return a.apply(b, arguments) } }, v = function (a, b, c) { return null == a ? t.identity : t.isFunction(a) ? u(a, b, c) : t.isObject(a) ? t.matcher(a) : t.property(a) }; t.iteratee = function (a, b) { return v(a, b, 1 / 0) }; var w = function (a, b) { return function (c) { var d = arguments.length; if (2 > d || null == c) return c; for (var e = 1; d > e; e++) for (var f = arguments[e], g = a(f), h = g.length, i = 0; h > i; i++) { var j = g[i]; b && void 0 !== c[j] || (c[j] = f[j]) } return c } }, x = function (a) { if (!t.isObject(a)) return {}; if (r) return r(a); s.prototype = a; var b = new s; return s.prototype = null, b }, y = Math.pow(2, 53) - 1, z = function (a) { var b = a && a.length; return "number" == typeof b && b >= 0 && y >= b }; t.each = t.forEach = function (a, b, c) { b = u(b, c); var d, e; if (z(a)) for (d = 0, e = a.length; e > d; d++) b(a[d], d, a); else { var f = t.keys(a); for (d = 0, e = f.length; e > d; d++) b(a[f[d]], f[d], a) } return a }, t.map = t.collect = function (a, b, c) { b = v(b, c); for (var d = !z(a) && t.keys(a), e = (d || a).length, f = Array(e), g = 0; e > g; g++) { var h = d ? d[g] : g; f[g] = b(a[h], h, a) } return f }, t.reduce = t.foldl = t.inject = a(1), t.reduceRight = t.foldr = a(-1), t.find = t.detect = function (a, b, c) { var d; return d = z(a) ? t.findIndex(a, b, c) : t.findKey(a, b, c), void 0 !== d && -1 !== d ? a[d] : void 0 }, t.filter = t.select = function (a, b, c) { var d = []; return b = v(b, c), t.each(a, function (a, c, e) { b(a, c, e) && d.push(a) }), d }, t.reject = function (a, b, c) { return t.filter(a, t.negate(v(b)), c) }, t.every = t.all = function (a, b, c) { b = v(b, c); for (var d = !z(a) && t.keys(a), e = (d || a).length, f = 0; e > f; f++) { var g = d ? d[f] : f; if (!b(a[g], g, a)) return !1 } return !0 }, t.some = t.any = function (a, b, c) { b = v(b, c); for (var d = !z(a) && t.keys(a), e = (d || a).length, f = 0; e > f; f++) { var g = d ? d[f] : f; if (b(a[g], g, a)) return !0 } return !1 }, t.contains = t.includes = t.include = function (a, b, c) { return z(a) || (a = t.values(a)), t.indexOf(a, b, "number" == typeof c && c) >= 0 }, t.invoke = function (a, b) { var c = l.call(arguments, 2), d = t.isFunction(b); return t.map(a, function (a) { var e = d ? b : a[b]; return null == e ? e : e.apply(a, c) }) }, t.pluck = function (a, b) { return t.map(a, t.property(b)) }, t.where = function (a, b) { return t.filter(a, t.matcher(b)) }, t.findWhere = function (a, b) { return t.find(a, t.matcher(b)) }, t.max = function (a, b, c) { var d, e, f = -(1 / 0), g = -(1 / 0); if (null == b && null != a) { a = z(a) ? a : t.values(a); for (var h = 0, i = a.length; i > h; h++) d = a[h], d > f && (f = d) } else b = v(b, c), t.each(a, function (a, c, d) { e = b(a, c, d), (e > g || e === -(1 / 0) && f === -(1 / 0)) && (f = a, g = e) }); return f }, t.min = function (a, b, c) { var d, e, f = 1 / 0, g = 1 / 0; if (null == b && null != a) { a = z(a) ? a : t.values(a); for (var h = 0, i = a.length; i > h; h++) d = a[h], f > d && (f = d) } else b = v(b, c), t.each(a, function (a, c, d) { e = b(a, c, d), (g > e || e === 1 / 0 && f === 1 / 0) && (f = a, g = e) }); return f }, t.shuffle = function (a) { for (var b, c = z(a) ? a : t.values(a), d = c.length, e = Array(d), f = 0; d > f; f++) b = t.random(0, f), b !== f && (e[f] = e[b]), e[b] = c[f]; return e }, t.sample = function (a, b, c) { return null == b || c ? (z(a) || (a = t.values(a)), a[t.random(a.length - 1)]) : t.shuffle(a).slice(0, Math.max(0, b)) }, t.sortBy = function (a, b, c) { return b = v(b, c), t.pluck(t.map(a, function (a, c, d) { return { value: a, index: c, criteria: b(a, c, d) } }).sort(function (a, b) { var c = a.criteria, d = b.criteria; if (c !== d) { if (c > d || void 0 === c) return 1; if (d > c || void 0 === d) return -1 } return a.index - b.index }), "value") }; var A = function (a) { return function (b, c, d) { var e = {}; return c = v(c, d), t.each(b, function (d, f) { var g = c(d, f, b); a(e, d, g) }), e } }; t.groupBy = A(function (a, b, c) { t.has(a, c) ? a[c].push(b) : a[c] = [b] }), t.indexBy = A(function (a, b, c) { a[c] = b }), t.countBy = A(function (a, b, c) { t.has(a, c) ? a[c]++ : a[c] = 1 }), t.toArray = function (a) { return a ? t.isArray(a) ? l.call(a) : z(a) ? t.map(a, t.identity) : t.values(a) : [] }, t.size = function (a) { return null == a ? 0 : z(a) ? a.length : t.keys(a).length }, t.partition = function (a, b, c) { b = v(b, c); var d = [], e = []; return t.each(a, function (a, c, f) { (b(a, c, f) ? d : e).push(a) }), [d, e] }, t.first = t.head = t.take = function (a, b, c) { return null == a ? void 0 : null == b || c ? a[0] : t.initial(a, a.length - b) }, t.initial = function (a, b, c) { return l.call(a, 0, Math.max(0, a.length - (null == b || c ? 1 : b))) }, t.last = function (a, b, c) { return null == a ? void 0 : null == b || c ? a[a.length - 1] : t.rest(a, Math.max(0, a.length - b)) }, t.rest = t.tail = t.drop = function (a, b, c) { return l.call(a, null == b || c ? 1 : b) }, t.compact = function (a) { return t.filter(a, t.identity) }; var B = function (a, b, c, d) { for (var e = [], f = 0, g = d || 0, h = a && a.length; h > g; g++) { var i = a[g]; if (z(i) && (t.isArray(i) || t.isArguments(i))) { b || (i = B(i, b, c)); var j = 0, k = i.length; for (e.length += k; k > j;) e[f++] = i[j++] } else c || (e[f++] = i) } return e }; t.flatten = function (a, b) { return B(a, b, !1) }, t.without = function (a) { return t.difference(a, l.call(arguments, 1)) }, t.uniq = t.unique = function (a, b, c, d) { if (null == a) return []; t.isBoolean(b) || (d = c, c = b, b = !1), null != c && (c = v(c, d)); for (var e = [], f = [], g = 0, h = a.length; h > g; g++) { var i = a[g], j = c ? c(i, g, a) : i; b ? (g && f === j || e.push(i), f = j) : c ? t.contains(f, j) || (f.push(j), e.push(i)) : t.contains(e, i) || e.push(i) } return e }, t.union = function () { return t.uniq(B(arguments, !0, !0)) }, t.intersection = function (a) { if (null == a) return []; for (var b = [], c = arguments.length, d = 0, e = a.length; e > d; d++) { var f = a[d]; if (!t.contains(b, f)) { for (var g = 1; c > g && t.contains(arguments[g], f) ; g++); g === c && b.push(f) } } return b }, t.difference = function (a) { var b = B(arguments, !0, !0, 1); return t.filter(a, function (a) { return !t.contains(b, a) }) }, t.zip = function () { return t.unzip(arguments) }, t.unzip = function (a) { for (var b = a && t.max(a, "length").length || 0, c = Array(b), d = 0; b > d; d++) c[d] = t.pluck(a, d); return c }, t.object = function (a, b) { for (var c = {}, d = 0, e = a && a.length; e > d; d++) b ? c[a[d]] = b[d] : c[a[d][0]] = a[d][1]; return c }, t.indexOf = function (a, b, c) { var d = 0, e = a && a.length; if ("number" == typeof c) d = 0 > c ? Math.max(0, e + c) : c; else if (c && e) return d = t.sortedIndex(a, b), a[d] === b ? d : -1; if (b !== b) return t.findIndex(l.call(a, d), t.isNaN); for (; e > d; d++) if (a[d] === b) return d; return -1 }, t.lastIndexOf = function (a, b, c) { var d = a ? a.length : 0; if ("number" == typeof c && (d = 0 > c ? d + c + 1 : Math.min(d, c + 1)), b !== b) return t.findLastIndex(l.call(a, 0, d), t.isNaN); for (; --d >= 0;) if (a[d] === b) return d; return -1 }, t.findIndex = d(1), t.findLastIndex = d(-1), t.sortedIndex = function (a, b, c, d) { c = v(c, d, 1); for (var e = c(b), f = 0, g = a.length; g > f;) { var h = Math.floor((f + g) / 2); c(a[h]) < e ? f = h + 1 : g = h } return f }, t.range = function (a, b, c) { arguments.length <= 1 && (b = a || 0, a = 0), c = c || 1; for (var d = Math.max(Math.ceil((b - a) / c), 0), e = Array(d), f = 0; d > f; f++, a += c) e[f] = a; return e }; var C = function (a, b, c, d, e) { if (!(d instanceof b)) return a.apply(c, e); var f = x(a.prototype), g = a.apply(f, e); return t.isObject(g) ? g : f }; t.bind = function (a, b) { if (q && a.bind === q) return q.apply(a, l.call(arguments, 1)); if (!t.isFunction(a)) throw new TypeError("Bind must be called on a function"); var c = l.call(arguments, 2), d = function () { return C(a, d, b, this, c.concat(l.call(arguments))) }; return d }, t.partial = function (a) { var b = l.call(arguments, 1), c = function () { for (var d = 0, e = b.length, f = Array(e), g = 0; e > g; g++) f[g] = b[g] === t ? arguments[d++] : b[g]; for (; d < arguments.length;) f.push(arguments[d++]); return C(a, c, this, this, f) }; return c }, t.bindAll = function (a) { var b, c, d = arguments.length; if (1 >= d) throw new Error("bindAll must be passed function names"); for (b = 1; d > b; b++) c = arguments[b], a[c] = t.bind(a[c], a); return a }, t.memoize = function (a, b) { var c = function (d) { var e = c.cache, f = "" + (b ? b.apply(this, arguments) : d); return t.has(e, f) || (e[f] = a.apply(this, arguments)), e[f] }; return c.cache = {}, c }, t.delay = function (a, b) { var c = l.call(arguments, 2); return setTimeout(function () { return a.apply(null, c) }, b) }, t.defer = t.partial(t.delay, t, 1), t.throttle = function (a, b, c) { var d, e, f, g = null, h = 0; c || (c = {}); var i = function () { h = c.leading === !1 ? 0 : t.now(), g = null, f = a.apply(d, e), g || (d = e = null) }; return function () { var j = t.now(); h || c.leading !== !1 || (h = j); var k = b - (j - h); return d = this, e = arguments, 0 >= k || k > b ? (g && (clearTimeout(g), g = null), h = j, f = a.apply(d, e), g || (d = e = null)) : g || c.trailing === !1 || (g = setTimeout(i, k)), f } }, t.debounce = function (a, b, c) { var d, e, f, g, h, i = function () { var j = t.now() - g; b > j && j >= 0 ? d = setTimeout(i, b - j) : (d = null, c || (h = a.apply(f, e), d || (f = e = null))) }; return function () { f = this, e = arguments, g = t.now(); var j = c && !d; return d || (d = setTimeout(i, b)), j && (h = a.apply(f, e), f = e = null), h } }, t.wrap = function (a, b) { return t.partial(b, a) }, t.negate = function (a) { return function () { return !a.apply(this, arguments) } }, t.compose = function () { var a = arguments, b = a.length - 1; return function () { for (var c = b, d = a[b].apply(this, arguments) ; c--;) d = a[c].call(this, d); return d } }, t.after = function (a, b) { return function () { return --a < 1 ? b.apply(this, arguments) : void 0 } }, t.before = function (a, b) { var c; return function () { return --a > 0 && (c = b.apply(this, arguments)), 1 >= a && (b = null), c } }, t.once = t.partial(t.before, 2); var D = !{ toString: null }.propertyIsEnumerable("toString"), E = ["valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"]; t.keys = function (a) { if (!t.isObject(a)) return []; if (p) return p(a); var b = []; for (var c in a) t.has(a, c) && b.push(c); return D && e(a, b), b }, t.allKeys = function (a) { if (!t.isObject(a)) return []; var b = []; for (var c in a) b.push(c); return D && e(a, b), b }, t.values = function (a) { for (var b = t.keys(a), c = b.length, d = Array(c), e = 0; c > e; e++) d[e] = a[b[e]]; return d }, t.mapObject = function (a, b, c) { b = v(b, c); for (var d, e = t.keys(a), f = e.length, g = {}, h = 0; f > h; h++) d = e[h], g[d] = b(a[d], d, a); return g }, t.pairs = function (a) { for (var b = t.keys(a), c = b.length, d = Array(c), e = 0; c > e; e++) d[e] = [b[e], a[b[e]]]; return d }, t.invert = function (a) { for (var b = {}, c = t.keys(a), d = 0, e = c.length; e > d; d++) b[a[c[d]]] = c[d]; return b }, t.functions = t.methods = function (a) { var b = []; for (var c in a) t.isFunction(a[c]) && b.push(c); return b.sort() }, t.extend = w(t.allKeys), t.extendOwn = t.assign = w(t.keys), t.findKey = function (a, b, c) { b = v(b, c); for (var d, e = t.keys(a), f = 0, g = e.length; g > f; f++) if (d = e[f], b(a[d], d, a)) return d }, t.pick = function (a, b, c) { var d, e, f = {}, g = a; if (null == g) return f; t.isFunction(b) ? (e = t.allKeys(g), d = u(b, c)) : (e = B(arguments, !1, !1, 1), d = function (a, b, c) { return b in c }, g = Object(g)); for (var h = 0, i = e.length; i > h; h++) { var j = e[h], k = g[j]; d(k, j, g) && (f[j] = k) } return f }, t.omit = function (a, b, c) { if (t.isFunction(b)) b = t.negate(b); else { var d = t.map(B(arguments, !1, !1, 1), String); b = function (a, b) { return !t.contains(d, b) } } return t.pick(a, b, c) }, t.defaults = w(t.allKeys, !0), t.clone = function (a) { return t.isObject(a) ? t.isArray(a) ? a.slice() : t.extend({}, a) : a }, t.tap = function (a, b) { return b(a), a }, t.isMatch = function (a, b) { var c = t.keys(b), d = c.length; if (null == a) return !d; for (var e = Object(a), f = 0; d > f; f++) { var g = c[f]; if (b[g] !== e[g] || !(g in e)) return !1 } return !0 }; var F = function (a, b, c, d) { if (a === b) return 0 !== a || 1 / a === 1 / b; if (null == a || null == b) return a === b; a instanceof t && (a = a._wrapped), b instanceof t && (b = b._wrapped); var e = m.call(a); if (e !== m.call(b)) return !1; switch (e) { case "[object RegExp]": case "[object String]": return "" + a == "" + b; case "[object Number]": return +a !== +a ? +b !== +b : 0 === +a ? 1 / +a === 1 / b : +a === +b; case "[object Date]": case "[object Boolean]": return +a === +b } var f = "[object Array]" === e; if (!f) { if ("object" != typeof a || "object" != typeof b) return !1; var g = a.constructor, h = b.constructor; if (g !== h && !(t.isFunction(g) && g instanceof g && t.isFunction(h) && h instanceof h) && "constructor" in a && "constructor" in b) return !1 } c = c || [], d = d || []; for (var i = c.length; i--;) if (c[i] === a) return d[i] === b; if (c.push(a), d.push(b), f) { if (i = a.length, i !== b.length) return !1; for (; i--;) if (!F(a[i], b[i], c, d)) return !1 } else { var j, k = t.keys(a); if (i = k.length, t.keys(b).length !== i) return !1; for (; i--;) if (j = k[i], !t.has(b, j) || !F(a[j], b[j], c, d)) return !1 } return c.pop(), d.pop(), !0 }; t.isEqual = function (a, b) { return F(a, b) }, t.isEmpty = function (a) { return null == a ? !0 : z(a) && (t.isArray(a) || t.isString(a) || t.isArguments(a)) ? 0 === a.length : 0 === t.keys(a).length }, t.isElement = function (a) { return !(!a || 1 !== a.nodeType) }, t.isArray = o || function (a) { return "[object Array]" === m.call(a) }, t.isObject = function (a) { var b = typeof a; return "function" === b || "object" === b && !!a }, t.each(["Arguments", "Function", "String", "Number", "Date", "RegExp", "Error"], function (a) { t["is" + a] = function (b) { return m.call(b) === "[object " + a + "]" } }), t.isArguments(arguments) || (t.isArguments = function (a) { return t.has(a, "callee") }), "function" != typeof /./ && "object" != typeof Int8Array && (t.isFunction = function (a) { return "function" == typeof a || !1 }), t.isFinite = function (a) { return isFinite(a) && !isNaN(parseFloat(a)) }, t.isNaN = function (a) { return t.isNumber(a) && a !== +a }, t.isBoolean = function (a) { return a === !0 || a === !1 || "[object Boolean]" === m.call(a) }, t.isNull = function (a) { return null === a }, t.isUndefined = function (a) { return void 0 === a }, t.has = function (a, b) { return null != a && n.call(a, b) }, t.noConflict = function () { return f._ = g, this }, t.identity = function (a) { return a }, t.constant = function (a) { return function () { return a } }, t.noop = function () { }, t.property = function (a) { return function (b) { return null == b ? void 0 : b[a] } }, t.propertyOf = function (a) { return null == a ? function () { } : function (b) { return a[b] } }, t.matcher = t.matches = function (a) { return a = t.extendOwn({}, a), function (b) { return t.isMatch(b, a) } }, t.times = function (a, b, c) { var d = Array(Math.max(0, a)); b = u(b, c, 1); for (var e = 0; a > e; e++) d[e] = b(e); return d }, t.random = function (a, b) { return null == b && (b = a, a = 0), a + Math.floor(Math.random() * (b - a + 1)) }, t.now = Date.now || function () { return (new Date).getTime() }; var G = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#x27;", "`": "&#x60;" }, H = t.invert(G), I = function (a) { var b = function (b) { return a[b] }, c = "(?:" + t.keys(a).join("|") + ")", d = RegExp(c), e = RegExp(c, "g"); return function (a) { return a = null == a ? "" : "" + a, d.test(a) ? a.replace(e, b) : a } }; t.escape = I(G), t.unescape = I(H), t.result = function (a, b, c) { var d = null == a ? void 0 : a[b]; return void 0 === d && (d = c), t.isFunction(d) ? d.call(a) : d }; var J = 0; t.uniqueId = function (a) { var b = ++J + ""; return a ? a + b : b }, t.templateSettings = { evaluate: /<%([\s\S]+?)%>/g, interpolate: /<%=([\s\S]+?)%>/g, escape: /<%-([\s\S]+?)%>/g }; var K = /(.)^/, L = { "'": "'", "\\": "\\", "\r": "r", "\n": "n", "\u2028": "u2028", "\u2029": "u2029" }, M = /\\|'|\r|\n|\u2028|\u2029/g, N = function (a) { return "\\" + L[a] }; t.template = function (a, b, c) { !b && c && (b = c), b = t.defaults({}, b, t.templateSettings); var d = RegExp([(b.escape || K).source, (b.interpolate || K).source, (b.evaluate || K).source].join("|") + "|$", "g"), e = 0, f = "__p+='"; a.replace(d, function (b, c, d, g, h) { return f += a.slice(e, h).replace(M, N), e = h + b.length, c ? f += "'+\n((__t=(" + c + "))==null?'':_.escape(__t))+\n'" : d ? f += "'+\n((__t=(" + d + "))==null?'':__t)+\n'" : g && (f += "';\n" + g + "\n__p+='"), b }), f += "';\n", b.variable || (f = "with(obj||{}){\n" + f + "}\n"), f = "var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n" + f + "return __p;\n"; try { var g = new Function(b.variable || "obj", "_", f) } catch (h) { throw h.source = f, h } var i = function (a) { return g.call(this, a, t) }, j = b.variable || "obj"; return i.source = "function(" + j + "){\n" + f + "}", i }, t.chain = function (a) { var b = t(a); return b._chain = !0, b }; var O = function (a, b) { return a._chain ? t(b).chain() : b }; t.mixin = function (a) { t.each(t.functions(a), function (b) { var c = t[b] = a[b]; t.prototype[b] = function () { var a = [this._wrapped]; return k.apply(a, arguments), O(this, c.apply(t, a)) } }) }, t.mixin(t), t.each(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function (a) { var b = h[a]; t.prototype[a] = function () { var c = this._wrapped; return b.apply(c, arguments), "shift" !== a && "splice" !== a || 0 !== c.length || delete c[0], O(this, c) } }), t.each(["concat", "join", "slice"], function (a) { var b = h[a]; t.prototype[a] = function () { return O(this, b.apply(this._wrapped, arguments)) } }), t.prototype.value = function () { return this._wrapped }, t.prototype.valueOf = t.prototype.toJSON = t.prototype.value, t.prototype.toString = function () { return "" + this._wrapped }, "function" == typeof define && define.amd && define("underscore", [], function () { return t }) }).call(this)
}, {}], 36: [function (a, b) { "use strict"; function c(a) { var b; if (a.hasOwnProperty("count")) b = { $sum: 1 }; else if (a.min) b = { $min: "$" + a.min }; else if (a.max) b = { $max: "$" + a.max }; else if (a.avg) b = { $avg: "$" + a.avg }; else { if (!a.sum) throw new Error("The aggregating function was not recognized or is not supported: " + JSON.stringify(a)); b = { $sum: "$" + a.sum } } return b } function d(a, b, c) { b[a] = "$" + a, c[a] = "$_id." + a } var e = {}; e.translate = function (a, b) { var e, f, g; b = b || {}, a.Filter && (e = a.Filter); var h, i = a.GroupBy; if (i) if (g = { _id: 0 }, h = {}, Array.isArray(i)) for (var j = i, k = 0; k < j.length; k++) { var l = j[k]; d(l, h, g) } else { var l = i; d(l, h, g) } else h = null, g = { _id: 0 }; f = { _id: h }; var a = a.Aggregate; if (a) for (var m in a) if (a.hasOwnProperty(m)) { var n = a[m]; f[m] = c(n), g[m] = 1 } var o = []; return e && o.push({ $match: e }), b.maxDocumentsCount && o.push({ $limit: b.maxDocumentsCount }), f && o.push({ $group: f }), g && o.push({ $project: g }), o }, b.exports = e }, {}], 37: [function (a, b) { "use strict"; var c = {}; c.DefaultTakeItemsCount = 50, c.ExpandExpressionName = "Expand", c.ReturnAsFieldName = "ReturnAs", c.FieldsExpressionName = "Fields", c.SingleFieldExpressionName = "SingleField", c.SortExpressionName = "Sort", c.FilterExpressionName = "Filter", c.SkipExpressionName = "Skip", c.TakeExpressionName = "Take", c.ParentRelationFieldName = "ParentRelationField", c.IdFieldNameClient = "Id", c.TargetTypeNameFieldName = "TargetTypeName", c.ReturnItemsCountFieldName = "ReturnItemsCount", c.AggregateExpressionFieldName = "Aggregate", b.exports = c }, {}], 38: [function (a, b) { "use strict"; var c = a("./Constants"), d = function (a, b) { var c = ""; a && (c = a.path), this.parent = c, this.relations = [b.path], this.name = b.path, this.targetTypeName = b.targetTypeName, this.canAddOtherRelations = !(b.filterExpression || b.sortExpression || b.aggregateExpression || b.take || b.skip), this.children = []; var d = ""; c && (d += c + "."), d += b.targetTypeName, this.path = d }; d.prototype._insertRelationNode = function (a) { this.relations.push(a.path) }, d.prototype._insertChildNode = function (a) { this.children.push(a.name) }, d.prototype.canCombineWithRelation = function (a) { return this.canAddOtherRelations ? !(this.targetTypeName !== a.targetTypeName || a.filterExpression || a.sortExpression || a.aggregateExpression || a.take || a.skip) : !1 }; var e = function (a) { this._relationTree = a, this._map = {} }; e.prototype.addExecutionNode = function (a) { this._map[a.name] = a }, e.prototype.getExecutionNodeOfRelation = function (a) { for (var b in this._map) if (this._map.hasOwnProperty(b) && this._map[b].relations.indexOf(a) > -1) return this._map[b]; return null }, e.prototype.getRelationTree = function () { return this._relationTree }, e.prototype.getRelationNode = function (a) { return a ? this._relationTree.map[a] || null : null }, e.prototype.getRootRelationNode = function () { return this._relationTree.map[this._relationTree.map.$root] || null }, e.prototype.getRootNode = function () { var a = this._map, b = null; for (var c in a) if (a.hasOwnProperty(c) && "" === a[c].parent) { b = a[c]; break } return b }, e.prototype.getNode = function (a) { return this._map[a] }, e.prototype.build = function () { var a = this.getRelationNode(this._relationTree.map.$root), b = new d(null, a); this.addExecutionNode(b), this.buildInternal(a) }, e.prototype.buildInternal = function (a) { a.children.forEach(function (a) { var b = this.getRelationNode(a); this.insertRelationNodeInExecutionTree(b), this.buildInternal(b) }, this) }, e.prototype.insertRelationNodeInExecutionTree = function (a) { var b = this.getExecutionNodeOfRelation(a.parentPath), c = this.tryGetChildNodeToCombine(b, a); if (c) c._insertRelationNode(a); else { var e = new d(b, a); b._insertChildNode(e), this.addExecutionNode(e) } }, e.prototype.tryGetChildNodeToCombine = function (a, b) { if (a.canCombineWithRelation(b)) return a; for (var c = a.children, d = 0; d < c.length; d++) { var e = this._map[c[d]], f = this.tryGetChildNodeToCombine(e, b); if (f) return f } return null }, e.prototype.getFilterFromExecutionNode = function (a, b) { for (var c = {}, d = [], e = 0; e < a.relations.length; e++) { var f = this.getFilterFromSingleRelation(this._relationTree.map[a.relations[e]], b); f && d.push(f) } return d.length > 1 ? c.$or = d : c = d.length > 0 ? d[0] : null, c }, e.prototype.getFilterFromSingleRelation = function (a, b) { var d = a.filterExpression, e = {}, f = this.getRelationFieldValues(a, b), g = a.isInvertedRelation ? a.relationField : c.IdFieldNameClient; if (!(f.length > 0)) return null; if (e[g] = { $in: f }, void 0 !== d) { var h = []; return h.push(e), h.push(d), { $and: h } } return e }, e.prototype.getRelationFieldValues = function (a, b) { var c = [], d = this._relationTree.map[a.parentPath], e = Array.isArray(d.result) ? d.result : [d.result]; if (a.isInvertedRelation) for (var f = 0; f < e.length; f++) c.push(e[f][a.parentRelationField]); else if (d && d.result) { a.parentRelationIds = a.parentRelationIds || {}; for (var g = 0; g < e.length; g++) { var h = e[g], i = h[a.relationField]; if (Array.isArray(i)) { if (a.hasArrayValues = !0, b) for (var j = 0; j < i.length; j++) { var k = i[j]; void 0 !== k && null !== k && (c.push(k), a.parentRelationIds[k] = 1) } } else void 0 !== i && null !== i && (c.push(i), a.parentRelationIds[i] = 1) } } return c }, b.exports = e }, { "./Constants": 37 }], 39: [function (a, b) { "use strict"; function c(a) { this.name = "ExpandError", this.message = a, this.stack = (new Error).stack } c.prototype = new Error, b.exports = c }, {}], 40: [function (a, b) { "use strict"; function c(a) { this._executionNodeFunction = a.executionNodeFunction, this._metadataProviderFunction = a.metadataProviderFunction } var d = a("async"), e = a("./RelationTreeBuilder"), f = a("./ExecutionTree"), g = a("./Constants"), h = a("./ExpandError"); c.prototype._createExecuteNodeExecutor = function (a, b, c, f) { var g = this; return function (i) { var j = b.getRelationNode(c.relations[0]), k = b.getRelationNode(j.parentPath), l = !(k.parentPath && k.hasArrayValues), m = b.getFilterFromExecutionNode(c, l), n = e.validateSingleRelation(j); if (n) return i(new h(n)); var o = {}; o.select = j.fieldsExpression, o.sort = j.sortExpression, o.skip = j.skip, o.take = j.take, o.filter = m, o.targetTypeName = j.targetTypeName, o.returnItemsCount = j.returnItemsCount, o.aggregate = j.aggregateExpression, g._executionNodeFunction.call(null, o, f, function (e, h) { if (e) return i(e); for (var j, k = 0; k < c.relations.length; k++) j = b.getRelationNode(c.relations[k]), j.result = g._extractResultForRelation(j, h); c.result = j.result; for (var l = [], m = 0; m < c.children.length; m++) { var n = b._map; l.push(g._createExecuteNodeExecutor(a, b, n[c.children[m]], f)) } d.parallel(l, i) }) } }, c.prototype._getSingleResult = function (a, b, c, d) { if (!c) return null; var e, f; if (b.singleFieldName) return b.children && b.children.length > 0 ? (e = a[b.children[0]], f = this._getObjectByIdFromArray(e.result, c[b.singleFieldName]), this._getSingleResult(a, e, f, 0)) : c[b.singleFieldName]; var g = {}, h = {}; if (b.children && b.children.length > 0) for (var i = 0; i < b.children.length; i++) { e = a[b.children[i]]; var j = e.relationField, k = e.userDefinedName; e.isInvertedRelation || j !== k || (h[j] = 1); var l = e.result; if (e.isInvertedRelation) if (e.aggregateExpression) g[k] = l[d]; else if (e.returnItemsCount) g[k] = l; else for (var m = 0; m < l.length; m++) { var n = this._getSingleResult(a, e, l[m], m); n && (g[k] = g[k] || [], Array.isArray(b.result) ? n[e.relationField] === c.Id && g[k].push(n) : g[k].push(n)) } else if (g[k] = e.isArray() ? [] : null, c[j]) if (Array.isArray(c[j])) if (e.aggregateExpression) g[k] = l[d]; else if (e.sortExpression) for (var o = 0; o < l.length; o++) c[j].indexOf(l[o].Id) > -1 && (f = l[o], this._addSingleResultToParentArray(a, e, f, g, k)); else for (var p = 0; p < c[j].length; p++) f = this._getObjectByIdFromArray(l, c[j][p]), this._addSingleResultToParentArray(a, e, f, g, k); else f = this._getObjectByIdFromArray(l, c[j]), g[k] = this._getSingleResult(a, e, f, 0) } for (var q in c) if (c.hasOwnProperty(q)) { var r = !h[q] && this._fieldExistInFieldsExpression(q, b.originalFieldsExpression); r && (g[q] = c[q]) } return g }, c.prototype._addSingleResultToParentArray = function (a, b, c, d, e) { var f = this._getSingleResult(a, b, c, 0); d[e] = d[e] || [], f && d[e].push(f) }, c.prototype._fieldExistInFieldsExpression = function (a, b) { if (void 0 === b || 0 === Object.keys(b).length) return !0; if (a === g.IdFieldNameClient) return void 0 === b[a] ? !0 : b[a]; var c = e.getIsFieldsExpressionExclusive(b); return void 0 === c ? !0 : c ? !b.hasOwnProperty(a) : b.hasOwnProperty(a) }, c.prototype._extractResultForRelation = function (a, b) { if (a.returnItemsCount || a.aggregateExpression) return b; for (var c = [], d = 0; d < b.length; d++) a.parentRelationIds && a.parentRelationIds.hasOwnProperty(b[d].Id) && c.push(b[d]), a.isInvertedRelation && c.push(b[d]); return c }, c.prototype._getObjectByIdFromArray = function (a, b) { if (a) for (var c = 0; c < a.length; c++) if (a[c].Id === b) return a[c]; return null }, c.prototype.prepare = function (a, b, c, d, f, g, h) { var i = new e(a, b, c, d, f, this._metadataProviderFunction, g); i.build(function (a, b) { var c; if (b) { c = b[b.$root].fieldsExpression; var d = { relationsTree: i, mainQueryFieldsExpression: c } } h(a, d) }) }, c.prototype.expand = function (a, b, c, g) { var i = a.map, j = this, k = new f(a); k.build(), i[i.$root].result = b; var l = (k._map, k.getRootNode()); if (l) { var m = this._getExecutionList(k, l, c), n = 25; m.length > n && g(new h("Expand expression results in more than " + n + " inner queries!")), d.forEachSeries(m, function (b, d) { var f = b.executeOptions, g = b.relationNode; j._adjustFilterForExecuteDefinition(k, b); var i = e.validateSingleRelation(g, a); return i ? d(new h(i)) : void j._executionNodeFunction.call(null, f, c, function (a, c) { if (a) return d(a); var e; if (b.dataItem) e = j._extractResultForRelation(g, c), g.result || (g.result = []), g.result.push(e); else { for (var f, h = b.executionNode, i = 0; i < h.relations.length; i++) f = k.getRelationNode(h.relations[i]), f.result = j._extractResultForRelation(f, c); h.result = f.result } d() }) }, function (a) { if (a) g(a); else { var c, d = i[i.$root]; if (Array.isArray(b)) { c = []; for (var e = 0; e < b.length; e++) { var f = j._getSingleResult(i, d, b[e], e); f && c.push(f) } } else c = j._getSingleResult(i, d, b, 0); g(null, c) } }) } }, c.prototype._getExecutionList = function (a, b, c) { for (var d = a.getRelationTree(), e = a.getRelationNode(b.name), f = e.result, g = [], h = 0; h < b.children.length; h++) { var i, j = b.children[h], k = a.getNode(j), l = a.getRelationNode(j); if (l.aggregateExpression) { var f = f; Array.isArray(f) || (f = [f]); for (var m = 0; m < f.length; m++) i = this._getExecuteDefinitionForItem(f[m], l, d, c), g.push(i) } else i = this._getExecuteDefinitionForNode(a, k, c), g.push(i); var n = this._getExecutionList(a, k, c); g = g.concat(n) } return g }, c.prototype._adjustFilterForExecuteDefinition = function (a, b) { var c, d = b.relationNode; if (b.dataItem) c = this._getFilterFromSingleItem(b.dataItem, d); else { var e = b.executionNode, f = a.getRelationNode(d.parentPath), g = !(f.parentPath && f.hasArrayValues); c = a.getFilterFromExecutionNode(e, g) } b.executeOptions.filter = c }, c.prototype._getExecuteDefinitionForItem = function (a, b) { var c = {}; return c.select = b.fieldsExpression, c.sort = b.sortExpression, c.skip = b.skip, c.take = b.take, c.targetTypeName = b.targetTypeName, c.returnItemsCount = b.returnItemsCount, c.aggregate = b.aggregateExpression, { executeOptions: c, relationNode: b, dataItem: a } }, c.prototype._getExecuteDefinitionForNode = function (a, b) { var c = a.getRelationNode(b.relations[0]), d = {}; return d.select = c.fieldsExpression, d.sort = c.sortExpression, d.skip = c.skip, d.take = c.take, d.targetTypeName = c.targetTypeName, d.returnItemsCount = c.returnItemsCount, d.aggregate = c.aggregateExpression, { executeOptions: d, relationNode: c, executionNode: b } }, c.prototype._getFilterFromSingleItem = function (a, b) { var c, d = b.filterExpression, e = b.relationField; if (b.isInvertedRelation) c = {}, c[b.relationField] = a.Id; else { var f = a[e]; f && (c = Array.isArray(f) ? { Id: { $in: f } } : { Id: f }) } return c && d ? { $and: [c, d] } : c ? c : d ? d : null }, c.Constants = g, b.exports = c }, { "./Constants": 37, "./ExecutionTree": 38, "./ExpandError": 39, "./RelationTreeBuilder": 42, async: 43 }], 41: [function (a, b) { "use strict"; function c(a) { this.parentPath = a.parent, this.relationField = a.relationField, this.path = a.path || a.parent + "." + a.relationField, this.fieldsExpression = a.fieldsExpression || {}, this.targetTypeName = a.targetTypeName, this.children = [], this.isInvertedRelation = a.isInvertedRelation, this.isArrayRoot = a.isArrayRoot, this.hasArrayValues = !1; var b = a.expandExpression || {}; this.parentRelationField = b[d.ParentRelationFieldName] || d.IdFieldNameClient; var c = this.isInvertedRelation ? this.path : this.relationField; this.userDefinedName = b[d.ReturnAsFieldName] || c, e.extend(this.fieldsExpression, b[d.FieldsExpressionName]), this.originalFieldsExpression = {}, e.extend(this.originalFieldsExpression, this.fieldsExpression), this.singleFieldName = b[d.SingleFieldExpressionName], this.filterExpression = b[d.FilterExpressionName], this.sortExpression = b[d.SortExpressionName], this.skip = b[d.SkipExpressionName], this.take = this._getTakeLimit(b[d.TakeExpressionName], a.maxTakeValue), this.returnItemsCount = b[d.ReturnItemsCountFieldName], this.aggregateExpression = b[d.AggregateExpressionFieldName] } var d = a("./Constants"), e = a("underscore"), f = a("./ExpandError"); c.prototype._getTakeLimit = function (a, b) { if (b = b || d.DefaultTakeItemsCount, a) { if (a > b) throw new f("The maximum allowed take value when expanding relations is " + b + "!"); return a } return b }, c.prototype.setIsArrayFromMetadata = function () { this.isArrayFromMetadata = !0 }, c.prototype.isArray = function () { return this.isArrayFromMetadata || this.isInvertedRelation || this.hasArrayValues }, c.createInverted = function (a, b, d, e) { var f = a.split("."), g = f[0], h = f[1]; return c._create(a, g, h, d, e, b, !0) }, c.createRegular = function (a, b, e, f) { var g = e + "." + a, h = b[d.TargetTypeNameFieldName]; return c._create(g, h, a, e, f, b, !1) }, c._create = function (a, b, d, e, f, g, h) { var i = {}; return i.parent = e, i.path = a, i.maxTakeValue = f, i.validated = !1, i.expandExpression = g, i.relationField = d, i.targetTypeName = b, i.isInvertedRelation = h, new c(i) }, b.exports = c }, { "./Constants": 37, "./ExpandError": 39, underscore: 44 }], 42: [function (a, b) {
"use strict"; var c = a("./RelationNode"), d = a("underscore"), e = a("./Constants"), f = a("./ExpandError"), g = [e.ExpandExpressionName, e.ReturnAsFieldName, e.FieldsExpressionName, e.SingleFieldExpressionName, e.SortExpressionName, e.FilterExpressionName, e.SkipExpressionName, e.TakeExpressionName, e.ParentRelationFieldName, e.TargetTypeNameFieldName, e.ReturnItemsCountFieldName, e.AggregateExpressionFieldName], h = function (a, b, e, f, g, h, i) { this.maxTakeValue = g, this._metadataProviderFunction = h, this.context = i, this.expandExpression = this._processExpandExpression(a), this.map = {}, this.map[b] = new c({ targetTypeName: b, isArrayRoot: e, fieldsExpression: f, validated: !0, path: b, maxTakeValue: g }), this.map[b].originalFieldsExpression = {}, d.extend(this.map[b].originalFieldsExpression, f), this.map.$root = b }; h.prototype._processExpandExpression = function (a) { for (var b in a) if (a.hasOwnProperty(b) && ("boolean" == typeof a[b] && (a[b] = {}, a[b][e.ReturnAsFieldName] = b), "string" == typeof a[b])) { var c = a[b]; a[b] = {}, a[b][e.ReturnAsFieldName] = c } return a }, h.prototype.build = function (b) { try { this.buildMapInternal(this.expandExpression, this.map.$root) } catch (c) { return b(c) } var d = this; a("async").series([this.configureRelationTree.bind(this), this.validateRelationTree.bind(this)], function (a) { b(a, d.map) }) }, h.prototype.buildMapInternal = function (a, b) { for (var d in a) if (a.hasOwnProperty(d)) { var i = a[d]; for (var j in i) if (i.hasOwnProperty(j) && -1 === g.indexOf(j)) throw new f('"' + j + '" is not a valid option for Expand expression'); if (d.indexOf(".") > -1) { var k = c.createInverted(d, i, b, this.maxTakeValue); if (this.map[k.path] = k, this.map[b].children.push(k.path), h.addFieldToFieldsExpression(this.map[k.parentPath].originalFieldsExpression, k.userDefinedName), a[d][e.ExpandExpressionName]) { var l = this._processExpandExpression(a[d][e.ExpandExpressionName]); this.buildMapInternal(l, k.path) } } else { var m = c.createRegular(d, i, b, this.maxTakeValue); if (this.map[m.path] = m, this.map[b].children.push(m.path), i.hasOwnProperty(e.ExpandExpressionName)) { if ("object" != typeof i[e.ExpandExpressionName]) throw new f(m.path + ".Expand must be a valid expand expression!"); this.buildMapInternal(this._processExpandExpression(i.Expand), m.path) } } } }, h.prototype.configureRelationTree = function (a) { if (!this._metadataProviderFunction) return a(); var b = []; for (var c in this.map) this.map.hasOwnProperty(c) && null !== this.map[c].parentPath && b.push(this.map[c].relationField); this._metadataProviderFunction(b, this.map, this.context, function (b) { a(b) }) }, h.prototype.validateRelationTree = function (a) {
var b = "", c = "\r\n"; for (var d in this.map) if ("$root" !== d && this.map.hasOwnProperty(d)) {
var e = this.map[d]; b += h.validateSingleRelation(e, this), this.configureFieldsExpressionsForRelation(e);
} if ("" !== b) { var g = b.substr(0, b.lastIndexOf(c)), i = new f(g); return a(i) } a()
}, h.prototype.configureFieldsExpressionsForRelation = function (a) { if (a.parentPath) { var b = this.map[a.parentPath].fieldsExpression; a.isInvertedRelation ? h.addFieldToFieldsExpression(b, a.parentRelationField) : h.addFieldToFieldsExpression(b, a.relationField) } a.isInvertedRelation ? h.addFieldToFieldsExpression(a.fieldsExpression, a.relationField) : h.addFieldToFieldsExpression(a.fieldsExpression, e.IdFieldNameClient), h.adjustParentRelationFieldsExpression(this.map[a.parentPath], a) }, h.validateSingleRelation = function (a, b) { var c = "", d = b.map, e = d[d.$root], f = "\r\n", g = e.isArrayRoot; if (a.path === a.parentPath) return c += a.path + " has same parent which will cause an infinite loop." + f; if (a.isArray()) { var i = h._getParentMultipleRelationsCount(a, b); i > 0 && (c += 'Expand expression has multiple relation "' + a.path + '" inside a multiple relation.', c += f), d[a.parentPath] === e && g && (a.filterExpression || a.sortExpression) && (c += "Filter and Sort are not allowed when expanding multiple items.", c += f), d[a.parentPath] === e && g && a.isInvertedRelation && a.skip && (c += "Skip and Take are not supported when expanding multiple items with external relation.", c += f) } return a.targetTypeName || (c += 'Expanding relation "' + a.relationField + '" has no target type name specified. You should use "TargetTypeName" to specify it.', c += f), a.fieldsExpression && Object.keys(a.fieldsExpression).length && a.singleFieldName && (c += a.path + " ", c += 'expand expression contains both "Fields" and "SingleField" expressions.', c += f), a.singleFieldName && a.children && (a.children.length > 1 && (c += a.path + " has multiple expand expressions with a single field option." + f), 1 === a.children.length && d[a.children[0]].relationField !== a.singleFieldName && (c += "Expand expression " + a.path, c += ' single field "' + a.singleFieldName + '"', c += ' does not match child relation field "' + d[a.children[0]].relationField + '".', c += f)), c }, h._getParentMultipleRelationsCount = function (a, b) { for (var c = 0, d = a; d.parentPath;) { var e = b.map[d.parentPath]; e.isArray() && e.parentPath && (c += 1), d = e } return c }, h.adjustParentRelationFieldsExpression = function (a, b) { if (!b.isInvertedRelation && b.take && "number" == typeof b.take) { var c = b.isArray() && !b.filterExpression && !b.sortExpression && a; c && (void 0 === a.fieldsExpression && (a.fieldsExpression = {}), a.fieldsExpression[b.relationField] = b.skip && "number" == typeof b.skip ? { $slice: [b.skip, b.take] } : { $slice: b.take }, b.take = null, b.skip = null, b.movedSkipTakeAsSlice = !0) } }, h.addFieldToFieldsExpression = function (a, b) { if (void 0 !== a && 0 !== Object.keys(a).length) { var c = h.getIsFieldsExpressionExclusive(a); void 0 !== c && (c ? delete a[b] : a[b] = 1) } }, h.getIsFieldsExpressionExclusive = function (a) { var b; for (var c in a) if (c !== e.IdFieldNameClient && a.hasOwnProperty(c) && void 0 === b) { if (0 === a[c]) { b = !0; break } if ("object" == typeof a[c]) continue; b = !1; break } return b }, b.exports = h
}, { "./Constants": 37, "./ExpandError": 39, "./RelationNode": 41, async: 43, underscore: 44 }], 43: [function (a, b) {
(function (a) {/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/
!function () { function c(a) { var b = !1; return function () { if (b) throw new Error("Callback was already called."); b = !0, a.apply(d, arguments) } } var d, e, f = {}; d = this, null != d && (e = d.async), f.noConflict = function () { return d.async = e, f }; var g = Object.prototype.toString, h = Array.isArray || function (a) { return "[object Array]" === g.call(a) }, i = function (a, b) { if (a.forEach) return a.forEach(b); for (var c = 0; c < a.length; c += 1) b(a[c], c, a) }, j = function (a, b) { if (a.map) return a.map(b); var c = []; return i(a, function (a, d, e) { c.push(b(a, d, e)) }), c }, k = function (a, b, c) { return a.reduce ? a.reduce(b, c) : (i(a, function (a, d, e) { c = b(c, a, d, e) }), c) }, l = function (a) { if (Object.keys) return Object.keys(a); var b = []; for (var c in a) a.hasOwnProperty(c) && b.push(c); return b }; "undefined" != typeof a && a.nextTick ? (f.nextTick = a.nextTick, f.setImmediate = "undefined" != typeof setImmediate ? function (a) { setImmediate(a) } : f.nextTick) : "function" == typeof setImmediate ? (f.nextTick = function (a) { setImmediate(a) }, f.setImmediate = f.nextTick) : (f.nextTick = function (a) { setTimeout(a, 0) }, f.setImmediate = f.nextTick), f.each = function (a, b, d) { function e(b) { b ? (d(b), d = function () { }) : (f += 1, f >= a.length && d()) } if (d = d || function () { }, !a.length) return d(); var f = 0; i(a, function (a) { b(a, c(e)) }) }, f.forEach = f.each, f.eachSeries = function (a, b, c) { if (c = c || function () { }, !a.length) return c(); var d = 0, e = function () { b(a[d], function (b) { b ? (c(b), c = function () { }) : (d += 1, d >= a.length ? c() : e()) }) }; e() }, f.forEachSeries = f.eachSeries, f.eachLimit = function (a, b, c, d) { var e = m(b); e.apply(null, [a, c, d]) }, f.forEachLimit = f.eachLimit; var m = function (a) { return function (b, c, d) { if (d = d || function () { }, !b.length || 0 >= a) return d(); var e = 0, f = 0, g = 0; !function h() { if (e >= b.length) return d(); for (; a > g && f < b.length;) f += 1, g += 1, c(b[f - 1], function (a) { a ? (d(a), d = function () { }) : (e += 1, g -= 1, e >= b.length ? d() : h()) }) }() } }, n = function (a) { return function () { var b = Array.prototype.slice.call(arguments); return a.apply(null, [f.each].concat(b)) } }, o = function (a, b) { return function () { var c = Array.prototype.slice.call(arguments); return b.apply(null, [m(a)].concat(c)) } }, p = function (a) { return function () { var b = Array.prototype.slice.call(arguments); return a.apply(null, [f.eachSeries].concat(b)) } }, q = function (a, b, c, d) { if (b = j(b, function (a, b) { return { index: b, value: a } }), d) { var e = []; a(b, function (a, b) { c(a.value, function (c, d) { e[a.index] = d, b(c) }) }, function (a) { d(a, e) }) } else a(b, function (a, b) { c(a.value, function (a) { b(a) }) }) }; f.map = n(q), f.mapSeries = p(q), f.mapLimit = function (a, b, c, d) { return r(b)(a, c, d) }; var r = function (a) { return o(a, q) }; f.reduce = function (a, b, c, d) { f.eachSeries(a, function (a, d) { c(b, a, function (a, c) { b = c, d(a) }) }, function (a) { d(a, b) }) }, f.inject = f.reduce, f.foldl = f.reduce, f.reduceRight = function (a, b, c, d) { var e = j(a, function (a) { return a }).reverse(); f.reduce(e, b, c, d) }, f.foldr = f.reduceRight; var s = function (a, b, c, d) { var e = []; b = j(b, function (a, b) { return { index: b, value: a } }), a(b, function (a, b) { c(a.value, function (c) { c && e.push(a), b() }) }, function () { d(j(e.sort(function (a, b) { return a.index - b.index }), function (a) { return a.value })) }) }; f.filter = n(s), f.filterSeries = p(s), f.select = f.filter, f.selectSeries = f.filterSeries; var t = function (a, b, c, d) { var e = []; b = j(b, function (a, b) { return { index: b, value: a } }), a(b, function (a, b) { c(a.value, function (c) { c || e.push(a), b() }) }, function () { d(j(e.sort(function (a, b) { return a.index - b.index }), function (a) { return a.value })) }) }; f.reject = n(t), f.rejectSeries = p(t); var u = function (a, b, c, d) { a(b, function (a, b) { c(a, function (c) { c ? (d(a), d = function () { }) : b() }) }, function () { d() }) }; f.detect = n(u), f.detectSeries = p(u), f.some = function (a, b, c) { f.each(a, function (a, d) { b(a, function (a) { a && (c(!0), c = function () { }), d() }) }, function () { c(!1) }) }, f.any = f.some, f.every = function (a, b, c) { f.each(a, function (a, d) { b(a, function (a) { a || (c(!1), c = function () { }), d() }) }, function () { c(!0) }) }, f.all = f.every, f.sortBy = function (a, b, c) { f.map(a, function (a, c) { b(a, function (b, d) { b ? c(b) : c(null, { value: a, criteria: d }) }) }, function (a, b) { if (a) return c(a); var d = function (a, b) { var c = a.criteria, d = b.criteria; return d > c ? -1 : c > d ? 1 : 0 }; c(null, j(b.sort(d), function (a) { return a.value })) }) }, f.auto = function (a, b) { b = b || function () { }; var c = l(a), d = c.length; if (!d) return b(); var e = {}, g = [], j = function (a) { g.unshift(a) }, m = function (a) { for (var b = 0; b < g.length; b += 1) if (g[b] === a) return void g.splice(b, 1) }, n = function () { d--, i(g.slice(0), function (a) { a() }) }; j(function () { if (!d) { var a = b; b = function () { }, a(null, e) } }), i(c, function (c) { var d = h(a[c]) ? a[c] : [a[c]], g = function (a) { var d = Array.prototype.slice.call(arguments, 1); if (d.length <= 1 && (d = d[0]), a) { var g = {}; i(l(e), function (a) { g[a] = e[a] }), g[c] = d, b(a, g), b = function () { } } else e[c] = d, f.setImmediate(n) }, o = d.slice(0, Math.abs(d.length - 1)) || [], p = function () { return k(o, function (a, b) { return a && e.hasOwnProperty(b) }, !0) && !e.hasOwnProperty(c) }; if (p()) d[d.length - 1](g, e); else { var q = function () { p() && (m(q), d[d.length - 1](g, e)) }; j(q) } }) }, f.retry = function (a, b, c) { var d = 5, e = []; "function" == typeof a && (c = b, b = a, a = d), a = parseInt(a, 10) || d; var g = function (d, g) { for (var h = function (a, b) { return function (c) { a(function (a, d) { c(!a || b, { err: a, result: d }) }, g) } }; a;) e.push(h(b, !(a -= 1))); f.series(e, function (a, b) { b = b[b.length - 1], (d || c)(b.err, b.result) }) }; return c ? g() : g }, f.waterfall = function (a, b) { if (b = b || function () { }, !h(a)) { var c = new Error("First argument to waterfall must be an array of functions"); return b(c) } if (!a.length) return b(); var d = function (a) { return function (c) { if (c) b.apply(null, arguments), b = function () { }; else { var e = Array.prototype.slice.call(arguments, 1), g = a.next(); e.push(g ? d(g) : b), f.setImmediate(function () { a.apply(null, e) }) } } }; d(f.iterator(a))() }; var v = function (a, b, c) { if (c = c || function () { }, h(b)) a.map(b, function (a, b) { a && a(function (a) { var c = Array.prototype.slice.call(arguments, 1); c.length <= 1 && (c = c[0]), b.call(null, a, c) }) }, c); else { var d = {}; a.each(l(b), function (a, c) { b[a](function (b) { var e = Array.prototype.slice.call(arguments, 1); e.length <= 1 && (e = e[0]), d[a] = e, c(b) }) }, function (a) { c(a, d) }) } }; f.parallel = function (a, b) { v({ map: f.map, each: f.each }, a, b) }, f.parallelLimit = function (a, b, c) { v({ map: r(b), each: m(b) }, a, c) }, f.series = function (a, b) { if (b = b || function () { }, h(a)) f.mapSeries(a, function (a, b) { a && a(function (a) { var c = Array.prototype.slice.call(arguments, 1); c.length <= 1 && (c = c[0]), b.call(null, a, c) }) }, b); else { var c = {}; f.eachSeries(l(a), function (b, d) { a[b](function (a) { var e = Array.prototype.slice.call(arguments, 1); e.length <= 1 && (e = e[0]), c[b] = e, d(a) }) }, function (a) { b(a, c) }) } }, f.iterator = function (a) { var b = function (c) { var d = function () { return a.length && a[c].apply(null, arguments), d.next() }; return d.next = function () { return c < a.length - 1 ? b(c + 1) : null }, d }; return b(0) }, f.apply = function (a) { var b = Array.prototype.slice.call(arguments, 1); return function () { return a.apply(null, b.concat(Array.prototype.slice.call(arguments))) } }; var w = function (a, b, c, d) { var e = []; a(b, function (a, b) { c(a, function (a, c) { e = e.concat(c || []), b(a) }) }, function (a) { d(a, e) }) }; f.concat = n(w), f.concatSeries = p(w), f.whilst = function (a, b, c) { a() ? b(function (d) { return d ? c(d) : void f.whilst(a, b, c) }) : c() }, f.doWhilst = function (a, b, c) { a(function (d) { if (d) return c(d); var e = Array.prototype.slice.call(arguments, 1); b.apply(null, e) ? f.doWhilst(a, b, c) : c() }) }, f.until = function (a, b, c) { a() ? c() : b(function (d) { return d ? c(d) : void f.until(a, b, c) }) }, f.doUntil = function (a, b, c) { a(function (d) { if (d) return c(d); var e = Array.prototype.slice.call(arguments, 1); b.apply(null, e) ? c() : f.doUntil(a, b, c) }) }, f.queue = function (a, b) { function d(a, b, c, d) { return a.started || (a.started = !0), h(b) || (b = [b]), 0 == b.length ? f.setImmediate(function () { a.drain && a.drain() }) : void i(b, function (b) { var e = { data: b, callback: "function" == typeof d ? d : null }; c ? a.tasks.unshift(e) : a.tasks.push(e), a.saturated && a.tasks.length === a.concurrency && a.saturated(), f.setImmediate(a.process) }) } void 0 === b && (b = 1); var e = 0, g = { tasks: [], concurrency: b, saturated: null, empty: null, drain: null, started: !1, paused: !1, push: function (a, b) { d(g, a, !1, b) }, kill: function () { g.drain = null, g.tasks = [] }, unshift: function (a, b) { d(g, a, !0, b) }, process: function () { if (!g.paused && e < g.concurrency && g.tasks.length) { var b = g.tasks.shift(); g.empty && 0 === g.tasks.length && g.empty(), e += 1; var d = function () { e -= 1, b.callback && b.callback.apply(b, arguments), g.drain && g.tasks.length + e === 0 && g.drain(), g.process() }, f = c(d); a(b.data, f) } }, length: function () { return g.tasks.length }, running: function () { return e }, idle: function () { return g.tasks.length + e === 0 }, pause: function () { g.paused !== !0 && (g.paused = !0, g.process()) }, resume: function () { g.paused !== !1 && (g.paused = !1, g.process()) } }; return g }, f.priorityQueue = function (a, b) { function c(a, b) { return a.priority - b.priority } function d(a, b, c) { for (var d = -1, e = a.length - 1; e > d;) { var f = d + (e - d + 1 >>> 1); c(b, a[f]) >= 0 ? d = f : e = f - 1 } return d } function e(a, b, e, g) { return a.started || (a.started = !0), h(b) || (b = [b]), 0 == b.length ? f.setImmediate(function () { a.drain && a.drain() }) : void i(b, function (b) { var h = { data: b, priority: e, callback: "function" == typeof g ? g : null }; a.tasks.splice(d(a.tasks, h, c) + 1, 0, h), a.saturated && a.tasks.length === a.concurrency && a.saturated(), f.setImmediate(a.process) }) } var g = f.queue(a, b); return g.push = function (a, b, c) { e(g, a, b, c) }, delete g.unshift, g }, f.cargo = function (a, b) { var c = !1, d = [], e = { tasks: d, payload: b, saturated: null, empty: null, drain: null, drained: !0, push: function (a, c) { h(a) || (a = [a]), i(a, function (a) { d.push({ data: a, callback: "function" == typeof c ? c : null }), e.drained = !1, e.saturated && d.length === b && e.saturated() }), f.setImmediate(e.process) }, process: function g() { if (!c) { if (0 === d.length) return e.drain && !e.drained && e.drain(), void (e.drained = !0); var f = "number" == typeof b ? d.splice(0, b) : d.splice(0, d.length), h = j(f, function (a) { return a.data }); e.empty && e.empty(), c = !0, a(h, function () { c = !1; var a = arguments; i(f, function (b) { b.callback && b.callback.apply(null, a) }), g() }) } }, length: function () { return d.length }, running: function () { return c } }; return e }; var x = function (a) { return function (b) { var c = Array.prototype.slice.call(arguments, 1); b.apply(null, c.concat([function (b) { var c = Array.prototype.slice.call(arguments, 1); "undefined" != typeof console && (b ? console.error && console.error(b) : console[a] && i(c, function (b) { console[a](b) })) }])) } }; f.log = x("log"), f.dir = x("dir"), f.memoize = function (a, b) { var c = {}, d = {}; b = b || function (a) { return a }; var e = function () { var e = Array.prototype.slice.call(arguments), g = e.pop(), h = b.apply(null, e); h in c ? f.nextTick(function () { g.apply(null, c[h]) }) : h in d ? d[h].push(g) : (d[h] = [g], a.apply(null, e.concat([function () { c[h] = arguments; var a = d[h]; delete d[h]; for (var b = 0, e = a.length; e > b; b++) a[b].apply(null, arguments) }]))) }; return e.memo = c, e.unmemoized = a, e }, f.unmemoize = function (a) { return function () { return (a.unmemoized || a).apply(null, arguments) } }, f.times = function (a, b, c) { for (var d = [], e = 0; a > e; e++) d.push(e); return f.map(d, b, c) }, f.timesSeries = function (a, b, c) { for (var d = [], e = 0; a > e; e++) d.push(e); return f.mapSeries(d, b, c) }, f.seq = function () { var a = arguments; return function () { var b = this, c = Array.prototype.slice.call(arguments), d = c.pop(); f.reduce(a, c, function (a, c, d) { c.apply(b, a.concat([function () { var a = arguments[0], b = Array.prototype.slice.call(arguments, 1); d(a, b) }])) }, function (a, c) { d.apply(b, [a].concat(c)) }) } }, f.compose = function () { return f.seq.apply(null, Array.prototype.reverse.call(arguments)) }; var y = function (a, b) { var c = function () { var c = this, d = Array.prototype.slice.call(arguments), e = d.pop(); return a(b, function (a, b) { a.apply(c, d.concat([b])) }, e) }; if (arguments.length > 2) { var d = Array.prototype.slice.call(arguments, 2); return c.apply(this, d) } return c }; f.applyEach = n(y), f.applyEachSeries = p(y), f.forever = function (a, b) { function c(d) { if (d) { if (b) return b(d); throw d } a(c) } c() }, "undefined" != typeof b && b.exports ? b.exports = f : "undefined" != typeof define && define.amd ? define([], function () { return f }) : d.async = f }()
}).call(this, a("_process"))
}, { _process: 4 }], 44: [function (a, b, c) { arguments[4][35][0].apply(c, arguments) }, { dup: 35 }], 45: [function (a, b) { var c = a("./EverliveError").EverliveError, d = a("./constants"), e = a("underscore"); b.exports = function () { function a(a) { if (a = parseInt(a || d.MaxConcurrentDownloadTasks), isNaN(a) || 0 >= a) throw new c("The maxConcurrentTasks must be a number larger than 0"); this.maxConcurrentTasks = a, this.runningTasksCount = 0, this.tasks = [] } return a.prototype = { enqueue: function (a, b, d) { if (!e.isFunction(b) || !e.isFunction(d)) throw new c("taskSuccess and taskError functions must be provided"); var f = [].splice.call(arguments, 3); this.tasks.push({ task: a, args: f, success: b, error: d }), this._runNext() }, _runNext: function () { var a = this; if (a.runningTasksCount !== a.maxConcurrentTasks && a.tasks.length) { a.runningTasksCount++; var b = this.tasks.shift(), c = b.task, d = b.args, e = b.success, f = b.error; d.unshift(function (b) { a.runningTasksCount--, b ? f(b) : e.apply(null, [].splice.call(arguments, 1)), a._runNext() }), c.apply(null, d) } } }, a }() }, { "./EverliveError": 48, "./constants": 60, underscore: 35 }], 46: [function (a, b) { "use strict"; var c = a("events").EventEmitter, d = function (a) { a._emitter = new c, a._emitterProxy = function (b, c) { a._emitter[b].apply(a._emitter, c) }, a.addListener = function () { a._emitterProxy("addListener", arguments) }, a.on = a.addListener, a.removeListener = function () { a._emitterProxy("removeListener", arguments) }, a.off = a.removeListener, a.once = function () { a._emitterProxy("once", arguments) }, a.removeAllListeners = function () { a._emitterProxy("removeAllListeners", arguments) } }; b.exports = { apply: d } }, { events: 1 }], 47: [function (a, b) { { var c = a("./Setup"), d = a("./types/Data"), e = a("./types/Users"), f = a("./types/Files"), g = a("./constants"), h = a("./utils"), i = h.buildAuthHeader, j = a("./Push"), k = a("./auth/Authentication"), l = a("./offline/offline"), m = a("./caching/caching"), n = a("./Request"), o = a("./common"), p = (o.rsvp, o._), q = a("./EverliveError").EverliveError, r = a("./EverliveError").EverliveErrors, s = a("./helpers/helpers"), t = a("./EventEmitterProxy"); a("./mixins/mixins") } b.exports = function () { function a(b) { var d = this; this.setup = new c(b); var e = p.pick(this.setup, ["appId", "apiKey"]), f = p.extend({}, b, e); p.each(o, function (a) { a.func.call(d, f) }), null === a.$ && (a.$ = d), t.apply(this) } function b() { if (!this._isOfflineStorageEnabled()) throw new q("You have instantiated the SDK without support for offline storage") } a.$ = null, a.idField = g.idField; var o = []; a.initializations = o, a.init = function (b) { return a.$ = null, new a(b) }, a.prototype.data = function (a) { return new d(this.setup, a, this.offlineStorage, this) }, a.prototype.buildUrl = function () { return h.buildUrl(this.setup) }, a.prototype.buildAuthHeader = function () { return i(this.setup) }, a.disableRequestCache = h.disableRequestCache, a.AuthStatus = g.AuthStatus, a.prototype.authInfo = function (b, c) { var d = this; return h.buildPromise(function (b, c) { var e = d.setup; return e.masterKey ? b({ status: a.AuthStatus.masterKey }) : e.token ? d.authentication && d.authentication.isAuthenticationInProgress() ? b({ status: a.AuthStatus.authenticating }) : void d.Users.skipAuth(!0).currentUser().then(function (c) { return b({ status: a.AuthStatus.authenticated, user: c.result }) }, function (e) { return d.authentication && d.authentication.isAuthenticationInProgress() ? b({ status: a.AuthStatus.authenticating }) : e.code === r.invalidRequest.code || e.code === r.expiredToken.code ? b({ status: a.AuthStatus.invalidAuthentication }) : c(e) }) : b({ status: a.AuthStatus.unauthenticated }) }, b, c) }, a.prototype.request = function (a) { return new n(this.setup, a) }, a.prototype._isOfflineStorageEnabled = function () { var a = this.setup.offlineStorage || this.setup.offline; return a && a.enabled !== !1 }, a.prototype.offline = function () { b.call(this); var a; a = 0 === arguments.length ? !0 : 1 == arguments[0], this.offlineStorage._setOffline(a) }, a.prototype.online = function () { b.call(this); var a; a = 0 === arguments.length ? !0 : 1 == arguments[0], this.offlineStorage._setOffline(!a) }, a.prototype.isOffline = function () { return b.call(this), !this.isOnline() }, a.prototype.isOnline = function () { return this.offlineStorage.isOnline() }, a.prototype.sync = function () { return b.call(this), this.offlineStorage.sync.apply(this.offlineStorage, arguments) }; var u = function () { var a = this.data("Users"); e.addUsersFunctions(a, this), this.Users = a, this.users = a; var b = this.data("Files"); f.addFilesFunctions(b), this.Files = b, this.files = b, this.push = new j(this) }, v = function () { this.authentication = this.Authentication = new k(this, this.setup.authentication) }, w = function (a) { var b = this; b.helpers = {}, p.each(s, function (c) { var d = a.helpers ? a.helpers[c.name] : null; b.helpers[c.name] = new c.ctor(b, d) }) }; return o.push({ name: "caching", func: m.initCaching }), o.push({ name: "offlineStorage", func: l.initOfflineStorage }), o.push({ name: "cacheStore", func: m._initStore }), o.push({ name: "default", func: u }), o.push({ name: "authentication", func: v }), o.push({ name: "helpers", func: w }), a }() }, { "./EventEmitterProxy": 46, "./EverliveError": 48, "./Push": 52, "./Request": 53, "./Setup": 54, "./auth/Authentication": 55, "./caching/caching": 58, "./common": 59, "./constants": 60, "./helpers/helpers": 63, "./mixins/mixins": 69, "./offline/offline": 77, "./types/Data": 99, "./types/Files": 100, "./types/Users": 101, "./utils": 102 }], 48: [function (a, b) { var c = { itemNotFound: { code: 801, message: "Item not found." }, syncConflict: { code: 10001, message: "A conflict occurred while syncing data." }, syncError: { code: 10002, message: "Synchronization failed for item." }, syncInProgress: { code: 10003, message: "Cannot perform operation while synchronization is in progress." }, syncCancelledByUser: { code: 10004, message: "Synchronization cancelled by user." }, operationNotSupportedOffline: { code: 2e4 }, invalidId: { code: 20001, message: "Invalid or missing Id in model." }, generalDatabaseError: { code: 107, message: "General database error." }, invalidToken: { code: 301, message: "Invalid access token." }, expiredToken: { code: 302, message: "Expired access token." }, invalidExpandExpression: { code: 618, message: "Invalid expand expression." }, invalidRequest: { code: 601, message: "Invalid request." }, missingContentType: { code: 701, message: "ContentType not specified." }, missingOrInvalidFileContent: { code: 702, message: "Missing or invalid file content." }, customFileSyncNotSupported: { code: 703, message: "Custom ConflictResolution for files is not allowed." }, cannotDownloadOffline: { code: 704, message: "Cannot download a file while offline." }, cannotForceCacheWhenDisabled: { code: 705, message: "Cannot use forceCache while the caching is disabled." }, filesNotSupportedInBrowser: { code: 706, message: "Create and Update operations are not supported for Files in browsers while in offline mode." }, pushNotSupportedOffline: { code: 707, message: "Push is not supported in offline mode." } }, d = function () { function a(a, b) { var c = Error.apply(this); if ("object" == typeof a) { var d = a; a = d.message, b = d.code } return c.message = a, c.code = b || 0, c.name = this.name = "EverliveError", this.message = c.message, this.code = b, Object.defineProperty(this, "stack", { get: function () { return c.stack } }), this } return a.prototype = Object.create(Error.prototype), a.prototype.toJSON = function () { return { name: this.name, message: this.message, code: this.code, stack: this.stack } }, a }(), e = function () { var a = function (a, b, c) { d.call(this, b), this.errorType = a, this.message = b, void 0 !== c && (this.additionalInformation = c) }; a.prototype = Object.create(d.prototype), a.fromEverliveError = function (c) { var d = new a(b.EverliveError, c.message, c); return d }, a.fromPluginError = function (c) { var d = "A plugin error occurred"; c && ("string" == typeof c.error ? d = c.error : "string" == typeof c.message && (d = c.message)); var e = new a(b.PluginError, d, c); return e }; var b = { EverliveError: 1, PluginError: 2 }; return a }(); b.exports = { EverliveError: d, EverliveErrors: c, DeviceRegistrationError: e } }, {}], 49: [function (a, b) { var c = a("./common").Processor, d = a("./query/DataQuery"), e = a("./query/Query"), f = a("./query/AggregateQuery"), g = (a("./EverliveError").EverliveError, a("./constants")); b.exports = function () { return new c({ executionNodeFunction: function (a, b, c) { var h, i = a.targetTypeName.toLowerCase() === g.FilesTypeNameLegacy ? g.FilesTypeName : a.targetTypeName; h = new d(a.aggregate ? { operation: d.operations.Aggregate, collectionName: i, query: new f(a.filter, a.select, a.sort, a.skip, a.take, null, a.aggregate) } : { operation: d.operations.Read, collectionName: i, query: new e(a.filter, a.select, a.sort, a.skip, a.take) }), b.offlineModule.processQuery(h).then(function (a) { c(null, a.result) }, c) } }) }() }, { "./EverliveError": 48, "./common": 59, "./constants": 60, "./query/AggregateQuery": 86, "./query/DataQuery": 87, "./query/Query": 89 }], 50: [function (a, b) { b.exports = function () { function a(a, b) { this.operator = a, this.operands = b || [] } return a.prototype = { addOperand: function (a) { this.operands.push(a) } }, a }() }, {}], 51: [function (a, b) { b.exports = function () { function a(a, b) { this.longitude = a || 0, this.latitude = b || 0 } return a }() }, {}], 52: [function (a, b) { var c = a("./utils"), d = (a("./everlive.platform"), c.buildPromise), e = c.DeviceRegistrationResult, f = a("./EverliveError"), g = f.DeviceRegistrationError, h = f.EverliveError, i = a("./push/CurrentDevice"), j = a("./constants"), k = j.Platform; b.exports = function () { function a(a) { this._el = a, this.notifications = a.data(j.Push.NotificationsType), this.devices = a.data(j.Push.DevicesType) } return a.prototype = { ensurePushIsAvailable: function () { i.ensurePushIsAvailable() }, currentDevice: function (a) { return this.ensurePushIsAvailable(), 0 === arguments.length && (a = this._el.setup._emulatorMode), this._currentDevice || (this._currentDevice = new i(this)), this._currentDevice.emulatorMode = a || c._inAppBuilderSimulator(), this._currentDevice }, register: function (a, b, c) { this.ensurePushIsAvailable(); var f = this.currentDevice(), h = this; a = a || {}, a.android && (a.android.senderID = a.android.projectNumber || a.android.senderID); var i = function (a, b) { var c = new e(a); b(c) }, j = function (a, b) { var c = g.fromEverliveError(a); b(c) }, l = function (b, c, d) { var e = f._getPlatformType(), g = e === k.iOS; g && a.iOS && (g = a.iOS.clearBadge !== !1), g ? h.clearBadgeNumber().then(function () { i(b, c) }, function (a) { j(a, d) }) : i(b, c) }; return d(function (b, c) { f.enableNotifications(a, function (d) { var e = d.token, g = a.customParameters; f.getRegistration().then(function () { f.updateRegistration(g, function () { l(e, b, c) }, function (a) { j(a, c) }) }, function (a) { 801 === a.code ? f.register(g, function () { l(e, b, c) }, c) : j(a, c) }) }, function (a) { var b = g.fromPluginError(a); c(b) }) }, b, c) }, unregister: function () { this.ensurePushIsAvailable(); var a = this.currentDevice(); return a.disableNotifications.apply(a, arguments) }, updateRegistration: function () { this.ensurePushIsAvailable(); var a = this.currentDevice(); return a.updateRegistration.apply(a, arguments) }, setBadgeNumber: function (a, b, e) { if (this.ensurePushIsAvailable(), a = parseInt(a), isNaN(a)) return d(function (a, b) { b(new h("The badge must have a numeric value")) }, b, e); var f = {}, g = this.currentDevice(), i = g._getDeviceId(); return f.Id = "HardwareId/" + encodeURIComponent(i), f.BadgeCounter = a, d(function (b, d) { g._pushHandler.devices.updateSingle(f).then(function () { return window.plugins && window.plugins.pushNotification && !c._inAppBuilderSimulator() ? window.plugins.pushNotification.setApplicationIconBadgeNumber(b, d, a) : b() }, d) }, b, e) }, clearBadgeNumber: function (a, b) { return this.ensurePushIsAvailable(), this.setBadgeNumber(0, a, b) }, getRegistration: function () { this.ensurePushIsAvailable(); var a = this.currentDevice(); return a.getRegistration.apply(a, arguments) }, send: function () { return this.notifications.create.apply(this.notifications, arguments) }, areNotificationsEnabled: function (a, b, c) { this.ensurePushIsAvailable(); var d = this.currentDevice(); return d.areNotificationsEnabled(a, b, c) }, notificationProcessed: function () { this.ensurePushIsAvailable(); var a = this.currentDevice(); a.notificationProcessed() } }, a }() }, { "./EverliveError": 48, "./constants": 60, "./everlive.platform": 62, "./push/CurrentDevice": 84, "./utils": 102 }], 53: [function (a, b) { { var c = a("./utils"), d = (a("./common").rsvp, c.buildAuthHeader), e = c.parseUtilities, f = c.guardUnset, g = a("./common"), h = g.reqwest, i = g._, j = a("./constants").Headers, k = a("./everlive.platform").isNodejs, l = a("./query/Query"); a("./query/AggregateQuery") } b.exports = function () { function a(d, e) { f(d, "setup"), f(e, "options"), this.setup = d, this.method = null, this.endpoint = null, this.data = null, this.success = null, this.error = null, this.parse = a.parsers.simple; var g = {}; Object.defineProperty(this, "headers", { get: function () { return g }, set: function (a) { g = c.normalizeKeys(a) } }), i.extend(this, e), b = this, this._init(e) } var b; a.prototype = { send: function () { a.sendRequest(this) }, buildAuthHeader: d, buildUrl: function (a) { return c.buildUrl(a) }, buildQueryHeaders: function (b) { return b ? b instanceof l ? a.prototype._buildQueryHeaders(b) : a.prototype._buildFilterHeader(b) : {} }, _init: function (a) { i.extend(this.headers, this.buildAuthHeader(this.setup, a), this.buildQueryHeaders(a.query), a.headers) }, _buildQueryHeaders: function (a) { a = a.build(); var b = {}; return null !== a.$where && (b[j.filter] = JSON.stringify(a.$where)), null !== a.$select && (b[j.select] = JSON.stringify(a.$select)), null !== a.$sort && (b[j.sort] = JSON.stringify(a.$sort)), null !== a.$skip && (b[j.skip] = a.$skip), null !== a.$take && (b[j.take] = a.$take), null !== a.$expand && (b[j.expand] = JSON.stringify(a.$expand)), null !== a.$aggregate && (b[j.aggregate] = JSON.stringify(a.$aggregate)), b }, _buildFilterHeader: function (a) { var b = {}; return b[j.filter] = JSON.stringify(a), b } }; var g = b && b.setup && b.setup.parseOnlyCompleteDateTimeObjects, m = e.getReviver(g); return a.parsers = { simple: { result: e.parseResult.bind(null, m), error: e.parseError.bind(null, m) }, single: { result: e.parseSingleResult.bind(null, m), error: e.parseError.bind(null, m) }, update: { result: e.parseUpdateResult.bind(null, m), error: e.parseError.bind(null, m) } }, "undefined" == typeof a.sendRequest && (a.sendRequest = function (a) { var b = a.buildUrl(a.setup) + a.endpoint; b = c.disableRequestCache(b, a.method), a.method = a.method || "GET"; var d = "GET" === a.method ? a.data : JSON.stringify(a.data), e = { url: b, method: a.method, data: d, headers: a.headers, contentType: "application/json" }; k ? (e.success = function (b, c) { a.success.call(a, a.parse.result(b), c) }, e.error = function (b) { a.error.call(a, a.parse.error(b.responseText || b.statusText)) }) : (e.type = "json", e.crossOrigin = !0, e.success = function (b) { var c = a.parse.result(b); a.success.call(a, c) }, e.error = function (b) { var c = a.parse.error(b.responseText || b.statusText); a.error.call(a, c) }), h(e) }), a }() }, { "./common": 59, "./constants": 60, "./everlive.platform": 62, "./query/AggregateQuery": 86, "./query/Query": 89, "./utils": 102 }], 54: [function (a, b) { var c = a("./common")._, d = a("./constants"), e = a("./auth/AuthenticationSetup"); b.exports = function () { function a(a) { this.url = b, this.appId = null, this.masterKey = null, this.token = null, this.tokenType = null, this.principalId = null, this.scheme = "http", this.parseOnlyCompleteDateTimeObjects = !1, "string" == typeof a ? this.appId = a : (this._emulatorMode = a.emulatorMode, c.extend(this, a), a.apiKey && (this.appId = a.apiKey)), this.apiKey = this.appId, this.authentication = new e(this, a.authentication) } var b = d.everliveUrl; return a.prototype.setAuthorizationProperties = function (a, b, c) { this.token = a, this.tokenType = b, this.principalId = c }, a.prototype.getAuthorizationProperties = function () { return { token: this.token, tokenType: this.tokenType, principalId: this.principalId } }, a }() }, { "./auth/AuthenticationSetup": 56, "./common": 59, "./constants": 60 }], 55: [function (a, b) { "use strict"; var c = a("../utils"), d = a("../query/DataQuery"), e = a("../Request"), f = (a("../Everlive"), a("../constants")), g = "Users", h = c.buildPromise, i = a("../storages/LocalStore"), j = a("../EverliveError").EverliveErrors; b.exports = function () { var a = function (a, b) { if (this.authSetup = b || {}, this._el = a, this._authenticationCallbacks = null, this.authSetup.persist) { this._localStore = new i(a); var c, d = this._getLocalStoreKey(), e = this._localStore.getItem(d); e && (c = JSON.parse(this._localStore.getItem(d))), c && this._el.setup.setAuthorizationProperties(c.token, c.tokenType, c.principalId) } }; return a.prototype.login = function (a, b, c, e) { var f = this; return h(function (c, e) { var h = function () { f._loginSuccess.apply(f, arguments), c.apply(null, arguments) }, i = new d({ operation: d.operations.UserLogin, collectionName: g, data: { username: a, password: b, grant_type: "password" }, skipAuth: !0, onSuccess: h, onError: e }); return f._el.Users.processDataQuery(i) }, c, e) }, a.prototype.logout = function (a, b) { var c = this; return h(function (a, b) { var e = function () { c._logoutSuccess.apply(c, arguments), a.apply(null, arguments) }, f = function (a) { 301 === a.code && c.clearAuthorization(), b.apply(null, arguments) }, h = new d({ operation: d.operations.UserLogout, collectionName: g, skipAuth: !0, onSuccess: e, onError: f }); return c._el.Users.processDataQuery(h) }, a, b) }, a.prototype._getLocalStoreKey = function () { return f.AuthStoreKey + this._el.setup.apiKey + "$authentication" }, a.prototype.loginWithFacebook = function (a, b, c) { var d = { Provider: "Facebook", Token: a }; return this._loginWithProvider(d, b, c) }, a.prototype.loginWithADFS = function (a, b, c) { var d = { Provider: "ADFS", Token: a }; return this._loginWithProvider(d, b, c) }, a.prototype.loginWithLiveID = function (a, b, c) { var d = { Provider: "LiveID", Token: a }; return this._loginWithProvider(d, b, c) }, a.prototype.loginWithGoogle = function (a, b, c) { var d = { Provider: "Google", Token: a }; return this._loginWithProvider(d, b, c) }, a.prototype.loginWithTwitter = function (a, b, c, d) { var e = { Provider: "Twitter", Token: a, TokenSecret: b }; return this._loginWithProvider(e, c, d) }, a.prototype.setAuthorization = function (a, b, c) { if (this._el.setup.setAuthorizationProperties(a, b, c), this.authSetup.persist) { var d = this._getLocalStoreKey(), e = this._el.setup.getAuthorizationProperties(); this._localStore.setItem(d, JSON.stringify(e)) } this._authenticationCallbacks && (this._authenticationCallbacks.success(), this._authenticationCallbacks = null) }, a.prototype.clearAuthorization = function () { this.setAuthorization(null, null, null), this.clearPersistedAuthentication() }, a.prototype.clearPersistedAuthentication = function () { if (this._localStore) { var a = this._getLocalStoreKey(); this._localStore.removeItem(a), this._el.setup.setAuthorizationProperties(null, null, null) } }, a.prototype.isAuthenticationInProgress = function () { return "function" == typeof this.authSetup.onAuthenticationRequired }, a.prototype._ensureAuthentication = function () { if (!this.isAuthenticationInProgress()) throw new Error("onAuthenticationRequired option of Everlive.Setup.Authentication is required."); return this.isAuthenticating() ? this._authenticationCallbacks.promise : (this.clearAuthorization(), this.authSetup.onAuthenticationRequired.call(this), this._authenticationCallbacks = c.getCallbacks(), this._authenticationCallbacks.promise) }, a.prototype.completeAuthentication = function (a) { this._el.setAuthorization(a.access_token, a.token_type, a.principal_id) }, a.prototype.getAuthenticationStatus = function (a, b) { var d = this; return c.buildPromise(function (a, b) { var c = d._el.setup; return c.masterKey ? a({ status: f.AuthStatus.masterKey }) : c.token ? d.isAuthenticationInProgress() ? a({ status: f.AuthStatus.authenticating }) : void d._el.Users.skipAuth(!0).currentUser().then(function (b) { return a({ status: f.AuthStatus.authenticated, user: b.result }) }, function (c) { return d.isAuthenticationInProgress() ? a({ status: f.AuthStatus.authenticating }) : c.code === j.invalidRequest.code || c.code === j.invalidToken.code ? a({ status: f.AuthStatus.invalidAuthentication }) : c.code === j.expiredToken.code ? a({ status: f.AuthStatus.expiredAuthentication }) : b(c) }) : a({ status: f.AuthStatus.unauthenticated }) }, a, b) }, a.prototype.isAuthenticating = function () { return !!this._authenticationCallbacks }, a.prototype._loginSuccess = function (a) { var b = a.result; this.setAuthorization(b.access_token, b.token_type, b.principal_id) }, a.prototype._logoutSuccess = function () { this.clearAuthorization() }, a.prototype._loginWithProvider = function (a, b, c) { var f = { Identity: a }, i = this; return h(function (a, b) { var c = function () { i._loginSuccess.apply(i, arguments), a.apply(null, arguments) }, h = new d({ operation: d.operations.UserLoginWithProvider, collectionName: g, data: f, authHeaders: !1, skipAuth: !0, parse: e.parsers.single, onSuccess: c, onError: b }); i._el.Users.processDataQuery(h) }, b, c) }, a }() }, { "../Everlive": 47, "../EverliveError": 48, "../Request": 53, "../constants": 60, "../query/DataQuery": 87, "../storages/LocalStore": 96, "../utils": 102 }], 56: [function (a, b) { "use strict"; b.exports = function () { var a = function (a, b) { b = b || {}, this.onAuthenticationRequired = b.onAuthenticationRequired, this.persist = b.persist }; return a }() }, {}], 57: [function (a, b) {
"use strict"; var c = a("../constants"), d = a("../common"), e = a("../utils"), f = e.buildPromise, g = d.jsonStringify, h = d.rsvp, i = a("underscore"), j = a("../offline/offlinePersisters"), k = (a("../EverliveError").EverliveError, a("../query/Query"), a("../query/DataQuery")), l = a("../offline/offline").buildOfflineStorageOptions, m = function (a, b) { this.options = a, this.typeSettings = this.options.typeSettings, this.maxAgeInMs = 60 * this.options.maxAge * 1e3, this._everlive = b }, n = [k.operations.Read, k.operations.ReadById, k.operations.Count]; m.prototype = {
_hash: function (a) { return g(a) }, _initStore: function (a) { if (!this.persister) { var b = l(a), c = this.options.storage.storagePath + "_" + a.apiKey; this.persister = j.getPersister(c, b) } }, _getCacheData: function () {
var a = this; return this.cacheData ? e.successfulPromise(this.cacheData) : this._persisterGetAllDataWrap().then(function (b) {
return a.cacheData = b, a.cacheData
})
}, _persisterGetAllDataWrap: function () { var a = this; return new h.Promise(function (b, c) { return a.persister.getAllData(b, c) }) }, _persisterSaveDataWrap: function (a, b) { var c = this; return new h.Promise(function (d, e) { return c.persister.saveData(a, JSON.stringify(b), d, e) }) }, _getCacheDataForContentType: function (a) { return this._getCacheData().then(function (b) { return b[a] = "string" == typeof b[a] ? JSON.parse(b[a]) : b[a] || {}, i.clone(b[a]) }) }, _persistCacheData: function (a, b) { var c = this; return this._getCacheDataForContentType(a).then(function () { var d = i.extend({}, c.cacheData[a], b); return c.cacheData[a] = i.compactObject(d), c._persisterSaveDataWrap(a, c.cacheData[a]) }) }, isQueryUnsupportedOffline: function (a) { var b = !!a.getHeader(c.Headers.powerFields), d = a.getQueryParameters(), f = d.filter, g = e.getUnsupportedOperators(f), h = 0 !== g.length; return b || h }, _shouldSkipCache: function (a) { var b = -1 === n.indexOf(a.operation), c = a.collectionName, d = this.typeSettings, e = d && d && d[c] && d[c].enabled === !1, f = a.ignoreCache, g = this.isQueryUnsupportedOffline(a); return b || e || f || g }, _cacheDataQuery: function (a) { if (this._shouldSkipCache(a)) if (a.ignoreCache && !this.isQueryUnsupportedOffline(a)) { var b = this._getHashForQuery(a); this._cacheQuery(a, b) } else this._everlive.data(a.collectionName)._sendRequest(a); else a.useCache = !1, this._processCacheItem(a) }, _processCacheItem: function (a) { var b = this, c = a.collectionName, d = this._getHashForQuery(a); return this._getCacheDataForContentType(c).then(function (e) { return e[d] ? b._isHashExpired(c, d, a.maxAge).then(function (e) { return e && !a.forceCache ? b._purgeForHash(c, d).then(function () { return b._cacheQuery(a, d) }) : (a.operation === k.operations.ReadById && "me" === a.additionalOptions.id && (a.additionalOptions.id = b._everlive.setup.principalId), b._everlive.offlineStorage.processQuery(a).then(function (b) { a.onSuccess(b) })["catch"](a.onError)) }) : b._cacheQuery(a, d) }) }, _addObjectToCache: function (a, b, c) { var d = a.Id; return this._cacheResultFromDataQuery(b, d, c) }, _cacheQuery: function (a, b) { var c = this, d = a.collectionName, e = a.onSuccess; a.onSuccess = function (f) { var g = arguments; return c._getCacheData().then(function () { var j = [], l = f.result; if (a.operation !== k.operations.Count) if (Array.isArray(l)) i.each(l, function (b) { var d = c._addObjectToCache(b, a.collectionName); j.push(d) }); else if (i.isObject(l)) { var m = c._addObjectToCache(l, a.collectionName); j.push(m) } return h.all(j).then(function () { return a.operation !== k.operations.Count ? c._cacheResultFromDataQuery(d, b) : void 0 }).then(function () { return e.apply(this, g) }) }) }, this._everlive.data(a.collectionName)._sendRequest(a) }, _cacheResultFromDataQuery: function (a, b) { var c = {}; return c[b] = { cachedAt: Date.now() }, this._persistCacheData(a, c) }, _getExpirationForHash: function (a, b) { return this._getCacheDataForContentType(a).then(function (a) { return a[b].cachedAt }) }, _isHashExpired: function (a, b, c) { var d = this; return this._getExpirationForHash(a, b).then(function (b) { var e, f = d.typeSettings && d.typeSettings[a] ? 60 * d.typeSettings[a].maxAge * 1e3 : null; return e = c || 0 === c ? c : f || 0 === f ? f : d.maxAgeInMs, b + e < Date.now() }) }, _purgeForHash: function (a, b) { var c = {}; return c[b] = null, this._persistCacheData(a, c) }, _getHashForQuery: function (a) { if (a.operation === k.operations.ReadById) return a.additionalOptions.id; var b = a.getQueryParameters(); return this._hash(b) }, clear: function (a, b, c) { var d = this; return f(function (b, c) { return d.persister.purge(a, function () { delete d.cacheData[a], d._everlive.offlineStorage.setup.enabled ? b() : d._everlive.offlineStorage._queryProcessor._persister.purge(a, b, c) }, c) }, b, c) }, clearAll: function (a, b) { var c = this; return c.cacheData = null, f(function (a, b) { return c.persister.purgeAll(function () { c._everlive.offlineStorage.setup.enabled ? a() : c._everlive.offlineStorage._queryProcessor._persister.purgeAll(a, b) }, b) }, a, b) }
}, b.exports = m
}, { "../EverliveError": 48, "../common": 59, "../constants": 60, "../offline/offline": 77, "../offline/offlinePersisters": 78, "../query/DataQuery": 87, "../query/Query": 89, "../utils": 102, underscore: 35 }], 58: [function (a, b) { "use strict"; var c = a("./CacheModule"), d = a("../common")._, e = function () { return { maxAge: 60, enabled: !1, storage: { storagePath: "el_cache" } } }; b.exports = { initCaching: function (a) { var b, f = e(); a.caching === !0 ? (b = d.deepExtend({}, f), b.enabled = !0) : b = d.deepExtend(f, a.caching), a.caching !== !1 && (this.setup.caching = b), this.cache = new c(b, this) }, _initStore: function (a) { this.cache._initStore(a) } } }, { "../common": 59, "./CacheModule": 57 }], 59: [function (a, b) { (function (c) { b.exports = function () { var b = {}, d = {}, e = a("./everlive.platform"), f = e.isNativeScript, g = e.isNodejs; g || f ? f ? (b.root = c, d.reqwest = a("./reqwest.nativescript")) : g && (b.root = c, d.reqwest = a("./reqwest.nodejs")) : d.reqwest = a("reqwest"), b.root || (b.root = window); var h = function (a, c) { c || (c = a), d[c] && "object" == typeof d[c] && !Object.keys(d[c]).length && (d[c] = void 0), Object.defineProperty(b, c, { get: function () { return d[c] || this.root[a] } }) }; return d._ = a("underscore"), h("_"), d.jstz = a("jstimezonedetect").jstz, h("jstz"), d.mongoQuery = a("mongo-query"), h("mongoQuery"), d.Mingo = a("mingo"), h("Mingo"), d.Processor = a("../scripts/bs-expand-processor"), h("Processor"), d.AggregationTranslator = a("../scripts/bs-aggregation-translator"), h("AggregationTranslator"), d.rsvp = a("rsvp"), h("RSVP", "rsvp"), h("reqwest"), d.jsonStringify = a("json-stable-stringify"), h("json-stable-stringify", "jsonStringify"), b }() }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}) }, { "../scripts/bs-aggregation-translator": 36, "../scripts/bs-expand-processor": 40, "./everlive.platform": 62, "./reqwest.nativescript": 93, "./reqwest.nodejs": 94, "json-stable-stringify": 7, jstimezonedetect: 11, mingo: 12, "mongo-query": 14, reqwest: 33, rsvp: 34, underscore: 35 }], 60: [function (a, b) { var c = { idField: "Id", guidEmpty: "00000000-0000-0000-0000-000000000000", everliveUrl: "//api.everlive.com/v1/", ConflictResolutionStrategy: { ClientWins: "clientWins", ServerWins: "serverWins", Custom: "custom" }, ConflictResolution: { KeepServer: "keepServer", KeepClient: "keepClient", Custom: "custom", Skip: "skip" }, StorageProvider: { LocalStorage: "localStorage", FileSystem: "fileSystem", Custom: "custom" }, DefaultStoragePath: "el_store", DefaultFilesStoragePath: "el_file_store", DefaultFilesMetadataPath: "el_file_mapping", EncryptionProvider: { Default: "default", Custom: "custom" }, Headers: { filter: "x-everlive-filter", select: "x-everlive-fields", sort: "x-everlive-sort", skip: "x-everlive-skip", take: "x-everlive-take", expand: "x-everlive-expand", singleField: "x-everlive-single-field", includeCount: "x-everlive-include-count", powerFields: "x-everlive-power-fields", debug: "x-everlive-debug", overrideSystemFields: "x-everlive-override-system-fields", sdk: "x-everlive-sdk", sync: "x-everlive-sync", aggregate: "x-everlive-aggregate" }, Platform: { WindowsPhone: 1, Windows: 2, Android: 3, iOS: 4, OSX: 5, Blackberry: 6, Nokia: 7, Unknown: 100 }, OperatorType: { query: 1, where: 100, filter: 101, and: 110, or: 111, not: 112, equal: 120, not_equal: 121, lt: 122, lte: 123, gt: 124, gte: 125, isin: 126, notin: 127, all: 128, size: 129, regex: 130, contains: 131, startsWith: 132, endsWith: 133, nearShpere: 140, withinBox: 141, withinPolygon: 142, withinShpere: 143, select: 200, exclude: 201, order: 300, order_desc: 301, skip: 400, take: 401, expand: 402 }, AuthStatus: { unauthenticated: "unauthenticated", masterKey: "masterKey", invalidAuthentication: "invalidAuthentication", authenticated: "authenticated", expiredAuthentication: "expiredAuthentication", authenticating: "authenticating" }, offlineItemStates: { created: "create", modified: "update", deleted: "delete" }, HttpMethod: { GET: "GET", POST: "POST", PUT: "PUT", DELETE: "DELETE" }, maxDistanceConsts: { radians: "$maxDistance", km: "$maxDistanceInKilometers", miles: "$maxDistanceInMiles" }, radiusConsts: { radians: "radius", km: "radiusInKilometers", miles: "radiusInMiles" } }; c.offlineItemsStateMarker = "__everlive_offline_state", c.SyncErrors = { generalError: "generalError", itemSyncError: "itemSyncError" }, c.syncBatchSize = 10, c.AuthStoreKey = "__everlive_auth_key", c.CachingStoreKey = "__everlive_cache", c.defaultSyncInterval = 6e5, c.fileUploadKey = "fileUpload", c.fileUploadDelimiter = "_", c.FilesTypeNameLegacy = "system.files", c.FilesTypeName = "Files", c.MaxConcurrentDownloadTasks = 3, c.DefaultFilesystemStorageQuota = 10485760, c.Events = { SyncStart: "syncStart", SyncEnd: "syncEnd", Processed: "processed", ItemProcessed: "itemProcessed", BeforeExecute: "beforeExecute" }, c.DataQueryOperations = { Read: "read", Create: "create", Update: "update", Delete: "destroy", DeleteById: "destroySingle", ReadById: "readById", Count: "count", RawUpdate: "rawUpdate", SetAcl: "setAcl", SetOwner: "setOwner", UpdateById: "updateSingle", UserLogin: "login", UserLogout: "logout", UserChangePassword: "changePassword", UserLoginWithProvider: "loginWith", UserLinkWithProvider: "linkWith", UserUnlinkFromProvider: "unlinkFrom", UserResetPassword: "resetPassword", UserSetPassword: "setPassword", FilesUpdateContent: "updateContent", FilesGetDownloadUrlById: "downloadUrlById", Aggregate: "aggregate" }, c.Aggregation = { MaxDocumentsCount: 1e5 }, c.Push = { NotificationsType: "Push/Notifications", DevicesType: "Push/Devices" }, b.exports = c }, {}], 61: [function (a, b) { var c = a("node-cryptojs-aes").CryptoJS, d = c.AES; b.exports = function () { function a(a) { this.options = a } return a.prototype = { _getKey: function () { return this.options.encryption.key }, _canEncryptDecrypt: function (a) { return this._getKey() && null !== a && void 0 !== a }, encrypt: function (a) { return this._canEncryptDecrypt(a) ? d.encrypt(a, this._getKey()).toString() : a }, decrypt: function (a) { return this._canEncryptDecrypt(a) ? d.decrypt(a, this._getKey()).toString(c.enc.Utf8) : a } }, a }() }, { "node-cryptojs-aes": 25 }], 62: [function (a, b, c) { var d, e = Boolean("undefined" != typeof android && android && android.widget && android.widget.Button || "undefined" != typeof UIButton && UIButton), f = !1, g = !1, h = !1; "undefined" == typeof window || e || (f = /^file:\/{3}[^\/]|x-wmapp/i.test(window.location.href) && /ios|iphone|ipod|ipad|android|iemobile/i.test(navigator.userAgent), g = f && /iemobile/i.test(navigator.userAgent), h = f && "android" === cordova.platformId); var i = "object" == typeof c && "undefined" == typeof window, j = "function" == typeof define && define.amd, k = !e && !f && !i; e ? d = "ns" : i ? d = "nodejs" : k ? d = "desktop" : f && (d = "cordova"); var l = function () { return void 0 !== typeof window && window.navigator && window.navigator.simulator }; b.exports = { isCordova: f, isNativeScript: e, isDesktop: k, isWindowsPhone: g, isAndroid: h, isNodejs: i, isRequirejs: j, platform: d, isInAppBuilderSimulator: l } }, {}], 63: [function (a, b) { "use strict"; var c = a("../everlive.platform"), d = [], e = a("./html/htmlHelper"); (c.isCordova || c.isDesktop) && d.push({ name: "html", ctor: e }), b.exports = d }, { "../everlive.platform": 62, "./html/htmlHelper": 64 }], 64: [function (a, b) { "use strict"; var c = (a("../../everlive.platform"), a("../../common")), d = c._, e = a("../../utils"), f = c.rsvp, g = a("./htmlHelperResponsiveModule"), h = a("./htmlHelperOfflineModule"), i = a("../../constants"), j = a("../../EverliveError").EverliveError, k = a("../../EventEmitterProxy"); b.exports = function () { function a(a, c) { k.apply(this), this._everlive = a, this._settings = { urlTemplate: "[protocol][hostname][appid]/[operations][url]", server: "bs1.cdn.telerik.com/image/v1/" }, c = c || {}, this.options = d.extend({}, b, c), this.options.attributes = d.extend({}, b.attributes, c.attributes), this._responsive = new g(this), this._offline = new h(this), this._init() } var b = { processOnLoad: !1, processOnResize: !1, loadingImageUrl: "", errorImageUrl: "", attributes: { loadingImage: "data-loading-image", errorImage: "data-error-image", dpi: "data-dpi", imageSource: "data-src", fileSource: "data-href", enableOffline: "data-offline", enableResponsive: "data-responsive" } }; return a.prototype = { _init: function () { var a = this; a.options.processOnLoad && window.addEventListener("load", this.processAll.bind(this), !1), this.options.processOnResize && window.addEventListener("resize", d.debounce(this.processAll.bind(this), 300), !1) }, _triggerOnProcessed: function (a) { this._emitter.emit(i.Events.Processed, a) }, _defaultProcessSettings: function (a) { return d.defaults({}, a, { responsive: !0, offline: !0 }) }, _setLoadingUrl: function (a) { var b = a.getAttribute(this.options.attributes.loadingImage) || this.options.loadingImageUrl; return !b || e.isElement.anchor(a) ? e.successfulPromise() : this._setUrl(a, b, !0) }, _getBackgroundSrc: function (a) { var b = window.getComputedStyle(a, null), c = b.getPropertyValue("background-image"), d = "none" !== c ? c : !1; return d && (d = d.replace(/url\(('?"?)(.*?)\1\)/gi, "$2")), d }, _setErrorUrl: function (a) { var b = a.getAttribute(this.options.attributes.errorImage) || this.options.errorImageUrl; return !b || e.isElement.anchor(a) ? e.successfulPromise() : this._setUrl(a, b, !0) }, _setUrl: function (a, b, c) { var g = this; return new f.Promise(function (f, h) { var i = g._getAttr(a); if (e.isElement.image(a) && i === g.options.attributes.imageSource) if (c) a.src = b, a.style.visibility = "visible"; else { var k = new Image; k.onerror = function () { k = null, h(new j("Can't be loaded: " + b)) }, k.onload = function () { k = null, g._setUrl(a, b, !0).then(f)["catch"](h) }, k.src = b } else if (c = !0, i) { var l; l = i === g.options.attributes.imageSource ? "src" : i === g.options.attributes.fileSource ? "href" : d.last(i.split("-")), a.setAttribute(l, b) } else a.style.backgroundImage = "url(" + b + ")"; c && f() }) }, _getAttr: function (a) { return a.getAttribute(this.options.attributes.imageSource) ? this.options.attributes.imageSource : a.getAttribute(this.options.attributes.fileSource) ? this.options.attributes.fileSource : void 0 }, _getUrl: function (a) { var b = a.getAttribute(this.options.attributes.imageSource) || a.getAttribute(this.options.attributes.fileSource) || this._getBackgroundSrc(a); return b }, _wrapElements: function (a) { var b = this, c = d.map(a, function (a) { var c = a.tagName.toLowerCase(), d = function (b) { var c, d = (a.attributes[b] || { value: null }).value; if ("" === d) c = !0; else if (d) try { c = JSON.parse(d) } catch (e) { c = !0 } else c = !1; return c }, e = d(b.options.attributes.enableResponsive), f = d(b.options.attributes.enableOffline); return { item: a, tag: c, operations: { responsive: e, offline: f } } }); return c }, process: function (a, b, c, g) { var h = this; return e.buildPromise(function (c) { b = h._defaultProcessSettings(b), a = d.isArray(a) || a instanceof NodeList || a.length ? d.flatten(a) : [a]; var g = h._wrapElements(a), i = []; d.each(g, function (a) { var c = { element: a.item, responsive: !1, offline: !1 }, d = h._getUrl(c.element); if (!d) return i.push(e.successfulPromise(c)); var f = b.responsive ? a.operations.responsive : !1, g = b.offline ? a.operations.offline : !1; if (!f && !g) return i.push(h._setUrl(c.element, d, !0).then(function () { return c })); var j = h._setLoadingUrl(c.element), k = function (a, b) { return b ? (c[a] = !0, b) : void 0 }; f && (j = j.then(function () { return h._responsive.responsiveImage(a, d).then(k.bind(this, "responsive")) })), g && (j = j.then(function (a) { return h._offline.processOffline(a || d).then(k.bind(this, "offline")) })), j = j.then(function (a) { return h._setUrl(c.element, a).then(function () { return c }) })["catch"](function (a) { return h._setErrorUrl(c.element).then(function () { throw { element: c.element, error: a } }) }), i.push(j) }), f.allSettled(i).then(function (a) { var b = [], e = []; d.each(a, function (a) { "fulfilled" === a.state ? b.push(a.value) : e.push(a.reason) }); var f = { processed: b, failed: e }; h._triggerOnProcessed(f), c(f) }) }, c, g) }, processAll: function (a, b, c) { a = this._defaultProcessSettings(a); var e = "[" + this.options.attributes.enableResponsive + "]", f = "[" + this.options.attributes.enableOffline + "]", g = []; a.responsive && (g = document.querySelectorAll(e)); var h = []; a.offline && (h = document.querySelectorAll(f)); var i = [].slice, j = d.unique(i.call(g).concat(i.call(h))); return this.process(j, a, b, c) } }, a }() }, { "../../EventEmitterProxy": 46, "../../EverliveError": 48, "../../common": 59, "../../constants": 60, "../../everlive.platform": 62, "../../utils": 102, "./htmlHelperOfflineModule": 65, "./htmlHelperResponsiveModule": 66 }], 65: [function (a, b) { "use strict"; var c = a("../../utils"), d = a("../../EverliveError"), e = d.EverliveErrors, f = d.EverliveError, g = (a("../../constants"), a("path")), h = a("../../common"), i = h._; b.exports = function () { function a(a) { this.htmlHelper = a } return a.prototype = { processOffline: function (a) { var b = this; return b.htmlHelper._everlive.offlineStorage.files ? b.htmlHelper._everlive.offlineStorage.files.downloadOffline(a).then(function (a) { return a })["catch"](function (c) { if (c.code !== e.cannotDownloadOffline.code) throw c; return b.htmlHelper._everlive.offlineStorage._offlineFilesProcessor.getOfflineFilesData().then(function (b) { var c = g.basename(a), d = i.find(b, function (a) { if (a.onlineLocation && a.offlineLocation) { var b = a.onlineLocation, d = b.lastIndexOf(c); return -1 !== d } }); if (d) return d.offlineLocation; throw new f("Cannot find offline image " + a, e.missingOrInvalidFileContent.code) }) }) : c.rejectedPromise(new f("Offline storage must be enabled in order to use the offline features of the images component.")) } }, a }() }, { "../../EverliveError": 48, "../../common": 59, "../../constants": 60, "../../utils": 102, path: 3 }], 66: [function (a, b) { "use strict"; var c = a("../../common"), d = c._, e = c.rsvp, f = (a("../../EverliveError").EverliveError, a("../../constants"), a("../../utils")); b.exports = function () { function a(a) { this.htmlHelper = a } return a.prototype = { getBackgroundWidth: function (a) { return Math.ceil(a.offsetWidth) }, parseParamsString: function (a) { if (!a || "undefined" == typeof a || a.length <= 1) return !1; for (var b = !1, c = [], d = a.split("/"), e = d.length, f = 0; e > f; f++) { var g = d[f].split("="), h = {}; g[1] = "undefined" == typeof g[1] ? !1 : unescape(g[1].replace(/\+/g, " ")), h[g[0]] = g[1], c.push(h), "resize" === g[0] && (b = !0) } return { params: c, isUserResize: b } }, getImgParams: function (a) { var b, c = a.replace(/.*?resize=[^//]*\//gi, ""), d = new RegExp("https?://", "gi"), e = new RegExp(this.htmlHelper._settings.server, "gi"), f = new RegExp(this.htmlHelper._everlive.appId + "/", "gi"); return b = a.replace(c, "").replace(d, "").replace(e, "").replace(f, "").toLowerCase(), b = "" !== b ? b.indexOf("/") ? b.substring(0, b.length - 1) : b : !1, b = this.parseParamsString(b), b.isUserResize && (c = a), { imgUrl: c, operations: b.params, isUserResize: b.isUserResize } }, hasClass: function (a, b) { var c = new RegExp("(?:\\s|^)" + b + "(?:\\s|$)"); return !!a.className.match(c) }, getImageWidth: function (a) { var b = a.parentNode, c = b.offsetWidth, d = window.getComputedStyle(b, null), e = parseFloat(d.getPropertyValue("padding-left")), f = parseFloat(d.getPropertyValue("padding-right")), g = parseFloat(d.getPropertyValue("border-left-width")), h = parseFloat(d.getPropertyValue("border-right-width")); return Math.abs(c - Math.ceil(e + f + g + h)) }, getDevicePixelRatio: function () { return window.devicePixelRatio ? window.devicePixelRatio : 1 }, getPixelRatio: function (a) { var b = a.getAttribute(this.htmlHelper.options.attributes.dpi) || ""; return "" !== b ? d.isNumber(b) ? parseFloat(b) : !1 : this.getDevicePixelRatio() }, getImgParamsString: function (a, b) { for (var c = "", e = 0, g = b.length; g > e; e++) { var h, i = b[e], j = d.keys(i)[0]; if (f.isElement.image(a) || "resize" !== j) { var k = this.getPixelRatio(a.item); k = k ? ",pd:" + k : ""; for (var l in i) h = "resize" === j ? i[l] + k : i[l]; c += j + "=" + h + "/" } } return c }, responsiveImage: function (a, b) { var c, g = this, h = d.extend({}, a), i = h.item, j = h.tag, k = f.isElement.image(j); h = d.extend({}, h, g.getImgParams(b)), h.isUserResize || (c = k ? g.getImageWidth(i) : g.getBackgroundWidth(i)), c = c ? c : !1; var l = h.isUserResize ? h.imgUrl : g.getImgSrc(h, c); return new e.Promise(function (a) { return c || h.isUserResize ? a(l) : a() }) }, getImgSrc: function (a, b) { var c = this.htmlHelper._everlive.setup.scheme + "://", d = this.htmlHelper._everlive.setup.appId, e = this.htmlHelper._settings.server, g = this.htmlHelper._settings.urlTemplate, h = this.getPixelRatio(a.item); h = h ? ",pd:" + h : "", g = g.replace("[protocol]", c), g = g.replace("[appid]", d ? d : ""), g = g.replace("[hostname]", e); var i = a.operations || !1; if (i) { var j = ""; i = this.getImgParamsString(a, i), j = f.isElement.image(a.tag) ? b ? "resize=w:" + b + h + "/" + i : i : "resize=w:" + b + h + "/" + i, g = g.replace("[operations]", j) } else g = g.replace("[operations]", "resize=w:" + b + h + "/"); return g = g.replace("[url]", a.imgUrl) } }, a }() }, { "../../EverliveError": 48, "../../common": 59, "../../constants": 60, "../../utils": 102 }], 67: [function (a, b) {/*!
The MIT License (MIT)
Copyright (c) 2013 Telerik AD
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.y distributed under the MIT license.
*/
/*!
Everlive SDK
Version 1.6.5
*/
!function () { var c = a("./Everlive"), d = a("./everlive.platform"); if (!d.isNativeScript && !d.isNodejs) { var e = a("./kendo/kendo.everlive"); c.createDataSource = e.createDataSource, c.createHierarchicalDataSource = e.createHierarchicalDataSource } c.PushCallbacks = {}, c.Offline = {}, c.Query = a("./query/Query"), c.AggregateQuery = a("./query/AggregateQuery"), c.QueryBuilder = a("./query/QueryBuilder"), c.GeoPoint = a("./GeoPoint"), c.Constants = a("./constants"), c.Request = a("./Request"), c.Data = a("./types/Data"), c._utils = a("./utils"), c._traverseAndRevive = c._utils.parseUtilities.traverseAndRevive, c._common = a("./common"); var f = a("./offline/offlinePersisters"); c.persister = { LocalStorage: f.LocalStoragePersister, FileSystem: f.FileSystemPersister }, b.exports = c }()
}, { "./Everlive": 47, "./GeoPoint": 51, "./Request": 53, "./common": 59, "./constants": 60, "./everlive.platform": 62, "./kendo/kendo.everlive": 68, "./offline/offlinePersisters": 78, "./query/AggregateQuery": 86, "./query/Query": 89, "./query/QueryBuilder": 90, "./types/Data": 99, "./utils": 102 }], 68: [function (a, b) { var c = a("../query/QueryBuilder"), d = a("../query/Query"), e = a("../query/AggregateQuery"), f = (a("../Request"), a("../constants")), g = a("../common"), h = g._, i = (g.rsvp, a("../Everlive")), j = (a("../EverliveError").EverliveError, { read: "read", update: "update", destroy: "destroy", create: "create" }); !function () { "use strict"; function a(a) { var b = {}; if (a) { if (a.skip && (b.$skip = a.skip, delete a.skip), a.take && (b.$take = a.take, delete a.take), a.sort) { var c = a.sort, d = {}; g.isArray(c) || (c = [c]), g.each(c, function (a, b) { d[b.field] = "asc" === b.dir ? 1 : -1 }), b.$sort = d, delete a.sort } a.filter && (b.$where = p.build(a.filter), delete a.filter) } return b } if (!("undefined" != typeof window && "undefined" == typeof window.jQuery || "undefined" == typeof window.kendo || h.isEmpty(window.kendo.data))) { var g = window.jQuery, k = window.kendo, l = g.extend, m = "_", n = k.data.RemoteTransport.extend({ init: function (a) { if (this.everlive$ = a.dataProvider || i.$, this._subscribeToSdkEvents(a), !this.everlive$) throw new Error("An instance of the Backend services sdk must be provided."); if (!a.typeName) throw new Error("A type name must be provided."); this.headers = a.headers, this.dataCollection = this.everlive$.data(a.typeName), k.data.RemoteTransport.fn.init.call(this, a) }, read: function (b) { var c = this.options.read, e = this; if (c && c.url) return k.data.RemoteTransport.fn.read.call(this, b); var f; c && c.headers && (f = c.headers); var g = a(b.data), h = new d(g.$where, null, g.$sort, g.$skip, g.$take), i = b.data.Id; i ? this.dataCollection.withHeaders(this.headers).withHeaders(f).getById(i).then(b.success, b.error) : this.dataCollection.withHeaders(this.headers).withHeaders(f).get(h).then(function (a) { return e._readServAggregates(a, g, b, f) }).then(b.success)["catch"](b.error) }, update: function (a) { var b = this.options.update; if (b && b.url) return k.data.RemoteTransport.fn.read.call(this, a); var c; b && b.headers && (c = b.headers); var d = h.isArray(a.data.models); if (d) throw new Error("Batch update is not supported."); var e = a.data; return this.dataCollection.withHeaders(this.headers).withHeaders(c).updateSingle(e).then(a.success.bind(this, e), a.error)["catch"](a.error) }, create: function (a) { var b = this.options.create; if (b && b.url) return k.data.RemoteTransport.fn.read.call(this, a); var c; b && b.headers && (c = b.headers); var d = h.isArray(a.data.models), e = d ? a.data.models : a.data; return this.dataCollection.withHeaders(this.headers).withHeaders(c).create(e).then(a.success.bind(this, e), a.error)["catch"](a.error) }, destroy: function (a) { var b = this.options.destroy; if (b && b.url) return k.data.RemoteTransport.fn.read.call(this, a); var c; b && b.headers && (c = b.headers); var d = h.isArray(a.data.models); if (d) throw new Error("Batch destroy is not supported."); var e = { Id: a.data.Id }; return this.dataCollection.withHeaders(this.headers).withHeaders(c).destroySingle(e).then(a.success, a.error)["catch"](a.error) }, _subscribeToSdkEvents: function (a) { var b = this; h.map(j, function (c) { if (a && a[c] && "function" == typeof a[c].beforeSend) { var d = a[c].beforeSend; b.everlive$.on(i.Constants.Events.BeforeExecute, d) } }) }, _readServAggregates: function (a, b, c, d) { if (c.data.aggregate) { if (!c.data.hasOwnProperty("filter") && !b.$where) throw new Error("The serverFiltering option must be enabled, when using serverAggregates."); var f = new e(b.$where, null, b.$sort, b.$skip, b.$take); return v(c.data.aggregate, f), this.dataCollection.withHeaders(this.headers).withHeaders(d).aggregate(f).then(function (b) { var d = w(c.data.aggregate, b.result[0]); return g.extend(!0, a, { aggregates: d }), a })["catch"](c.error) } return a } }); g.extend(!0, k.data, { transports: { everlive: n }, schemas: { everlive: { type: "json", total: function (a) { return a.hasOwnProperty("count") ? a.count : a.Count }, data: function (a) { return a.result || i._traverseAndRevive(a.Result) || a }, model: { id: f.idField }, aggregates: "aggregates" } } }); var o = ["startswith", "startsWith", "endswith", "endsWith", "contains"], p = { build: function (a) { return p._build(a) }, _build: function (a) { return p._isRaw(a) ? p._raw(a) : p._isSimple(a) ? p._simple(a) : p._isRegex(a) ? p._regex(a) : p._isAnd(a) ? p._and(a) : p._isOr(a) ? p._or(a) : void 0 }, _isRaw: function (a) { return "_raw" === a.operator }, _raw: function (a) { var b = {}; return b[a.field] = a.value, b }, _isSimple: function (a) { return "undefined" == typeof a.logic && !p._isRegex(a) }, _simple: function (a) { var b = {}, c = {}, d = p._translateoperator(a.operator); return d ? b[d] = a.value : b = a.value, c[a.field] = b, c }, _isRegex: function (a) { return -1 !== g.inArray(a.operator, o) }, _regex: function (a) { var b = {}, c = p._getRegex(a); return b[a.field] = p._getRegexValue(c), b }, _getRegex: function (a) { var b = a.value, c = a.operator; switch (c) { case "contains": return new RegExp(".*" + b + ".*", "i"); case "startsWith": case "startswith": return new RegExp("^" + b, "i"); case "endsWith": case "endswith": return new RegExp(b + "$", "i") } throw new Error("Unknown operator type.") }, _getRegexValue: function (a) { return c.prototype._getRegexValue.call(this, a) }, _isAnd: function (a) { return "and" === a.logic }, _and: function (a) { var b, c, d, e = {}, f = a.filters; for (b = 0, c = f.length; c > b; b++) d = p._build(f[b]), e = p._andAppend(e, d); return e }, _andAppend: function (a, b) { return c.prototype._andAppend.call(this, a, b) }, _isOr: function (a) { return "or" === a.logic }, _or: function (a) { var b, c, d, e = [], f = a.filters; for (b = 0, c = f.length; c > b; b++) d = p._build(f[b]), e.push(d); return { $or: e } }, _translateoperator: function (a) { switch (a) { case "eq": return null; case "neq": return "$ne"; case "gt": return "$gt"; case "lt": return "$lt"; case "gte": return "$gte"; case "lte": return "$lte" } throw new Error("Unknown operator type.") } }, q = function (a) { return a = a || {}, everlive$.getKendoDataSource(a.typeName, a) }, r = function (a) { var b = a.typeName, c = a.dataProvider || i.$; if (!c) throw new Error("You need to instantiate an Everlive instance in order to create a Kendo UI DataSource."); if (!b) throw new Error("You need to specify a 'typeName' in order to create a Kendo UI DataSource."); return c.getHierarchicalDataSource(b, a) }; i.prototype.getKendoDataSource = function (a, b) { b = b || {}; var c = b.dataProvider || i.$; if (!c) throw new Error("You need to instantiate an Everlive instance in order to create a Kendo UI DataSource."); if (!a) throw new Error("You need to specify a 'typeName' in order to create a Kendo UI DataSource."); if (b.serverGrouping) throw new Error("serverGrouping is not supported."); if (b.serverAggregates && !b.serverFiltering) throw new Error("The serverFiltering option must be enabled, when using serverAggregates."); var d = { type: "everlive", transport: { typeName: a, dataProvider: this } }, b = h.defaults(d, b); return new k.data.DataSource(b) }, i.prototype.getHierarchicalDataSource = function (a, b) { b = b || {}; var c = b.expand || b; if (delete b.expand, !a) throw new Error("You need to specify a 'typeName' in order to create a Kendo UI HierarchicalDataSource."); if (!g.isArray(c)) throw new Error("You need to set 'expand' array option in order to create a Kendo UI HierarchicalDataSource"); for (var d, e = this.buildUrl() + a, f = this._isOfflineStorageEnabled(), h = c.length - 1; h >= 0; h--) { var i = c[h]; if (f) { if (!g.isPlainObject(i)) throw new Error("When offline is enabled, each member of the expand array option must be an object. (Expand node index: " + h + ")"); if (!i.relation) throw new Error("When offline is enabled, each member of the expand array option must have a `relation` option set. (Expand node index: " + h + ")"); if (!i.typeName) throw new Error("When offline is enabled, each member of the expand array option must have a `typeName` option set. (Expand node index: " + h + ")"); var j, m = {}; m[i.relation] = { TargetTypeName: i.typeName, Filter: i.filter, Sort: i.sort, Take: i.take, Skip: i.skip, Fields: i.fields, SingleField: i.singleField }, j = { "X-Everlive-Expand": JSON.stringify(m), "X-Everlive-Single-Field": i.relation }; var n; n = 0 === h ? a : c[h - 1].typeName, d = { model: { hasChildren: i.relation, children: { type: "everlive", transport: { typeName: n, read: { headers: j } }, schema: d } } } } else d = { model: { hasChildren: u(i), children: { type: "everlive", transport: { read: { url: s(e, c.slice(0, h + 1)), headers: t(i) } }, schema: d } } } } var o = {}; return o.type = "everlive", o.transport = { typeName: a, dataProvider: this }, o.schema = d, g.isPlainObject(b) && l(!0, o, b), new k.data.HierarchicalDataSource(o) }; var s = function (a, b) { for (var c = u(b[b.length - 1]), d = b.slice(0, b.length - 1), e = "/_expand", f = 0; f < d.length; f++) e += "/" + u(d[f]); return function (b, c) { return function (d) { var e = a + ""; return d.Id && c && (e += b + "/" + d.Id + "/" + c), e } }(e, c) }, t = function (a) { return "string" == typeof a ? {} : { "X-Everlive-Filter": JSON.stringify(a.filter), "X-Everlive-Sort": JSON.stringify(a.sort), "X-Everlive-Single-Field": a.singleField, "X-Everlive-Skip": a.skip, "X-Everlive-Take": a.take, "X-Everlive-Fields": JSON.stringify(a.fields) } }, u = function (a) { if ("string" == typeof a) return a; if (a.relation) return a.relation; throw new Error("You need to specify a 'relation' for an expand node when using the object notation") }, v = function (a, b) { h.each(a, function (a) { "count" === a.aggregate ? b[a.aggregate](a.aggregate + m + a.field) : b[a.aggregate](a.field, a.aggregate + m + a.field) }) }, w = function (a, b) { var c = {}; return h.each(a, function (a) { c[a.field] || (c[a.field] = {}), c[a.field][a.aggregate] = b[a.aggregate + m + a.field] }), h.isEmpty(c) ? null : c }; b.exports = { createDataSource: q, createHierarchicalDataSource: r } } }() }, { "../Everlive": 47, "../EverliveError": 48, "../Request": 53, "../common": 59, "../constants": 60, "../query/AggregateQuery": 86, "../query/Query": 89, "../query/QueryBuilder": 90 }], 69: [function (a) { var b = a("../common")._, c = a("./underscoreDeepExtend"), d = a("./underscoreCompactObject"), e = a("./underscoreIsObjectEmpty"); b.mixin({ deepExtend: c }), b.mixin({ compactObject: d }), b.mixin({ isEmptyObject: e }) }, { "../common": 59, "./underscoreCompactObject": 70, "./underscoreDeepExtend": 71, "./underscoreIsObjectEmpty": 72 }], 70: [function (a, b) { var c = a("underscore"); b.exports = function (a) { var b = {}; return c.each(a, function (a, c) { null !== a && void 0 !== a && (b[c] = a) }), b } }, { underscore: 35 }], 71: [function (a, b) {/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
var c = a("../common")._; b.exports = function (a) { var b = /#{\s*?_\s*?}/, d = Array.prototype.slice; return c.each(d.call(arguments, 1), function (d) { for (var e in d) if (c.isUndefined(a[e]) || c.isFunction(a[e]) || c.isNull(d[e]) || c.isDate(d[e])) a[e] = d[e]; else if (c.isString(d[e]) && b.test(d[e])) c.isString(a[e]) && (a[e] = d[e].replace(b, a[e])); else if (c.isArray(a[e]) || c.isArray(d[e])) { if (!c.isArray(a[e]) || !c.isArray(d[e])) throw new Error("Trying to combine an array with a non-array (" + e + ")"); a[e] = c.reject(c.deepExtend(c.clone(a[e]), d[e]), function (a) { return c.isNull(a) }) } else if (c.isObject(a[e]) || c.isObject(d[e])) { if (!c.isObject(a[e]) || !c.isObject(d[e])) throw new Error("Trying to combine an object with a non-object (" + e + ")"); a[e] = c.deepExtend(c.clone(a[e]), d[e]) } else a[e] = d[e] }), a }
}, { "../common": 59 }], 72: [function (a, b) { "use strict"; function c(a) { if (null == a) return !0; if (a.length > 0) return !1; if (0 === a.length) return !0; for (var b in a) if (d.call(a, b)) return !1; return !0 } var d = Object.prototype.hasOwnProperty; b.exports = c }, {}], 73: [function (a, b) { "use strict"; var c = a("../utils"), d = c.buildPromise, e = (a("../Request"), a("../common")), f = e.rsvp, g = e._, h = e.reqwest, i = (e.uuid, a("path")), j = a("node-cryptojs-aes").CryptoJS, k = a("../EverliveError"), l = k.EverliveErrors, m = k.EverliveError, n = a("../AutoQueue"), o = function (a, b, c) { this._offlineFilesProcessor = a, this._everlive = b, this._downloadsQueue = new n(c) }; o.prototype = { _getFilenameMetadata: function (a, b) { return new f.Promise(function (c, d) { h({ url: a, method: "HEAD", async: !0, crossDomain: !0 }).then(function (a) { var d = a.getResponseHeader("Content-Disposition"); if (d) { var e = /filename="?([^"\\]*(?:\\.[^"\\]*)*)"?/i.exec(d); g.isArray(e) && (b.filename = e[1]) } else b.filename = i.basename(a.responseURL); c(a.responseURL) })["catch"](d) }) }, downloadOffline: function (a, b, e, f) { var g = this; return d(function (d, e) { g._downloadsQueue.enqueue(function (d) { var f; return g._getOfflineFileInfo(a).then(function (c) { return f = c, b ? !1 : g.existsOffline(a) }).then(function (b) { return b ? g._getOfflineFileInfo(a).then(function (a) { return g._getOfflineLocation(a) }) : g._everlive.isOnline() ? c.successfulPromise().then(function () { return f.filename ? void 0 : g._getFilenameMetadata(a, f) }).then(function (a) { var b = a || f.location; return g._saveFile(b, f.filename, null, f.location) }) : void e(new m(l.cannotDownloadOffline)) }).then(function (a) { d(null, a) })["catch"](d) }, d, e) }, e, f) }, _saveFile: function (a, b, c, d) { var e, f = this; return f._downloadFile(a, b).then(function (a) { return e = a, f._offlineFilesProcessor.getOfflineFilesData() }).then(function (b) { return b.push({ offlineLocation: e, onlineLocation: d || a, id: c }), f._offlineFilesProcessor.saveOfflineFilesData() }).then(function () { return e }) }, purgeAll: function (a, b) { var d = this; return c.buildPromise(function (a, b) { d._offlineFilesProcessor.fileStore.removeFilesDirectory().then(function () { return d._offlineFilesProcessor.filesMetaStore.removeFilesDirectory() }).then(function () { d._offlineFilesProcessor._offlineFilesData = null }).then(a)["catch"](b) }, a, b) }, _getOfflineLocation: function (a) { var b = this, c = a.location, d = a.filename, e = a.Id; return b._offlineFilesProcessor.getOfflineLocation(c, e).then(function (a) { return a ? a : e && !c ? b._getFileUrlForId(e, d) : null }) }, _downloadFile: function (a, b) { var d = this; return new f.Promise(function (e, f) { var g = new FileTransfer, h = d._sanitizeUrl(a), k = i.basename(h), l = i.extname(b), m = k; i.extname(h) !== l && (m += l); var n = ""; if (!c.isGuid(a)) { var o = a.lastIndexOf(k), p = a.substr(0, o); n = j.MD5(p).toString() } return d._offlineFilesProcessor.fileStore.getDataDirectory().then(function (a) { return c.joinPath(a.nativeURL, d._offlineFilesProcessor.fileStore.filesDirectoryPath, n, m) }).then(function (b) { g.download(a, b, function () { e(b) }, f, !0, { headers: d._everlive.buildAuthHeader() }) })["catch"](f) }) }, _sanitizeUrl: function (a) { if (!a) return a; var b = encodeURI(a), c = b.lastIndexOf("?"); return -1 !== c && (b = b.substr(0, c)), b }, _getFileUrlForId: function (a, b) { var d = this; return this._offlineFilesProcessor.fileStore.getDataDirectory().then(function (e) { var f = i.extname(b); return c.joinPath(e.nativeURL, d._offlineFilesProcessor.fileStore.filesDirectoryPath, a + f) }) }, existsOffline: function (a, b, c) { var e = this; return d(function (b, c) { e._getOfflineFileInfo(a).then(function (a) { return e._getOfflineLocation(a) }).then(function (a) { return a ? e._offlineFilesProcessor.fileStore.getFileByAbsolutePath(a) : void 0 }).then(function (a) { return !!a }).then(b)["catch"](function (a) { return a.code === l.itemNotFound.code ? b(!1) : c.apply(this, arguments) }) }, b, c) }, purge: function (a, b, c) { var e = this; return d(function (b, c) { e._getOfflineFileInfo(a).then(function (a) { return e._getOfflineLocation(a) }).then(function (a) { return a ? e._offlineFilesProcessor.purge(a) : void 0 }).then(b)["catch"](c) }, b, c) }, getOfflineLocation: function (a, b, c) { var e = this; return d(function (b, c) { e._getOfflineFileInfo(a).then(e._getOfflineLocation.bind(e)).then(function (a) { return a ? e.existsOffline(a).then(function (b) { return b ? a : null }) : null }).then(b)["catch"](c) }, b, c) }, _getOfflineFileInfo: function (a) { var b = this, c = this._sanitizeUrl(a); return new f.Promise(function (d, e) { b._everlive.Files.isSync(!0).useOffline(!0).getById(c).then(function (a) { var b = a.result; d({ location: b.Uri, filename: b.Filename, Id: c }) })["catch"](function (b) { b && b.code === l.itemNotFound.code ? d({ location: a }) : e(b) }) }) }, changeFileExtensionById: function (a, b) { var c = this; return "string" != typeof b ? new f.Promise(function (a) { a() }) : c._changeExtension(a, b) }, _changeExtension: function (a, b) { var c, d = this, e = d._offlineFilesProcessor.fileStore, f = a + b; return e.getFilesDirectory().then(function (b) { return c = b, d.getOfflineLocation(a) }).then(function (a) { var h = i.basename(a); return h !== f ? e.getFileByAbsolutePath(a).then(function (a) { return e.renameFile(c, a, f) }).then(function () { return d._offlineFilesProcessor.getOfflineFilesData() }).then(function (c) { var e = g.findWhere(c, { offlineLocation: a }); if (!e) throw new m("Could not find a cached location for the specified file."); var f = e.offlineLocation, h = i.extname(f), j = f.slice(0, f.length - h.length) + b; return e.offlineLocation = j, d._offlineFilesProcessor.saveOfflineFilesData() }) : void 0 }) } }, b.exports = o }, { "../AutoQueue": 45, "../EverliveError": 48, "../Request": 53, "../common": 59, "../utils": 102, "node-cryptojs-aes": 25, path: 3 }], 74: [function (a, b) { "use strict"; var c = a("../EverliveError"), d = c.EverliveError, e = c.EverliveErrors, f = a("../storages/FileStore"), g = a("../everlive.platform"), h = (a("../constants"), a("../common")), i = h.rsvp, j = a("../utils"), k = h._, l = a("path"), m = "filesMetadataMap", n = function (a, b) { this.fileStore = new f(a.files.storagePath, a), this.filesMetaStore = new f(a.files.metaPath, a), this._everlive = b }; n.prototype = { validateFileCreateObject: function (a, b) { return new i.Promise(function (c, f) { return a.base64 || b ? a.ContentType ? a.Filename ? void c() : f(new d(e.invalidRequest)) : f(new d(e.missingContentType)) : f(new d(e.missingOrInvalidFileContent)) }) }, getOfflineFilesData: function () { var a = this; return new i.Promise(function (b, c) { return a._offlineFilesData ? void b(a._offlineFilesData) : a.filesMetaStore.getFile(m).then(function (b) { return a.filesMetaStore.readFileAsText(b) }).then(function (c) { c || (c = "[]"), a._offlineFilesData = JSON.parse(c), b(a._offlineFilesData) })["catch"](c) }) }, saveOfflineFilesData: function () { var a = this; return a.getOfflineFilesData().then(function (b) { return a.filesMetaStore.writeText(m, JSON.stringify(b)) }) }, upsertFileFromObject: function (a, b, c) { if (g.isDesktop || g.isNativeScript) return j.successfulPromise(); var f = this; if (!c) if (b) { if (!a.base64) return j.rejectedPromise(new d(e.missingOrInvalidFileContent)); if (!a.ContentType) return j.rejectedPromise(new d(e.missingContentType)) } else if (!a.base64) return j.successfulPromise(); if (!a.base64) { var h, i = j.getId(a), k = a.Uri ? j.successfulPromise(a.Uri) : f._everlive.files.isSync(c).applyOffline(!1).getDownloadUrlById(i); return k.then(function (a) { return h = a, f._everlive.offlineStorage.files.existsOffline(i) }).then(function (b) { return b ? void 0 : f._everlive.offlineStorage.files._saveFile(h, a.Filename) }) } return a.Storage = "internal", j.successfulPromise().then(function () { return c ? void 0 : f.validateFileCreateObject(a, c) }).then(function () { var b, c = a.Uri, d = f.getFilenameForObject(a), e = a.base64; delete a.base64; var g = j.b64toBlob(e, a.ContentType); return f.writeFile(d, g).then(function (a) { return b = a, f.getOfflineFilesData() }).then(function (d) { return d.push({ offlineLocation: b.offlineLocation, onlineLocation: c, id: a._id }), a.Length = b.size, f.saveOfflineFilesData() }) }) }, purge: function (a) { var b = this; return this.getOfflineFilesData().then(function (c) { var d = k.where(c, { offlineLocation: a }), e = c.indexOf(d[0]); return -1 !== e && c.splice(e, 1), b.saveOfflineFilesData() }).then(function () { return b.fileStore.getFileByAbsolutePath(a) }).then(function (a) { return a ? b.fileStore.removeFile(a) : void 0 }) }, writeFile: function (a, b, c) { var d, e = this; return e.fileStore.writeText(a, b, c).then(function (a) { return d = a, e.saveOfflineFilesData() }).then(function () { return e.fileStore.getFileSize(a, c) }).then(function (a) { return { size: a, offlineLocation: d } }) }, getFilenameForObject: function (a) { var b = l.extname(a.Filename); return a._id + b }, getOfflineLocation: function (a, b) { return this.getOfflineFilesData().then(function (c) { if (a || b) for (var d = 0; d < c.length; d++) { var e = c[d], f = a && (e.offlineLocation === a || e.onlineLocation === a), g = b && e.id === b; if (f || g) return e.offlineLocation } }) } }, b.exports = n }, { "../EverliveError": 48, "../common": 59, "../constants": 60, "../everlive.platform": 62, "../storages/FileStore": 95, "../utils": 102, path: 3 }], 75: [function (a, b) { "use strict"; function c(a) { var b = [f.operations.UserLoginWithProvider, f.operations.UserLinkWithProvider, f.operations.UserUnlinkFromProvider], c = a.operation; return -1 !== b.indexOf(c) && (c += a.data.Provider || a.data.Identity.Provider), "The Users operation " + c + " is not supported in offline mode" } function d(a) { return "The Files operation " + a.operation + " is not supported in offline mode" } function e(a, b, c, d, e) { this._collectionCache = {}, this.offlineFilesProcessor = c, this._persister = a, this._encryptionProvider = b, this.everlive = d, this.setup = e } var f = a("../query/DataQuery"), g = a("../utils"), h = a("./offlineTransformations"), i = a("../ExpandProcessor"), j = a("../everlive.platform"), k = a("../EverliveError"), l = k.EverliveError, m = k.EverliveErrors, n = a("../utils").buildPromise, o = a("../common"), p = o._, q = o.rsvp, r = o.Mingo, s = o.mongoQuery, t = o.AggregationTranslator, u = (a("../query/Query"), a("path")), v = a("../constants"), w = v.Headers, x = v.offlineItemStates, y = [w.powerFields], z = {}; z[f.operations.Create] = !0, z[f.operations.Update] = !0, z[f.operations.Delete] = !0, z[f.operations.DeleteById] = !0, z[f.operations.RawUpdate] = !0, z[f.operations.SetAcl] = !0, z[f.operations.SetOwner] = !0, z[f.operations.UserLoginWithProvider] = !0, z[f.operations.UserLinkWithProvider] = !0, z[f.operations.UserUnlinkFromProvider] = !0, z[f.operations.UserLogin] = !0, z[f.operations.UserLogout] = !0, z[f.operations.UserChangePassword] = !0, z[f.operations.UserResetPassword] = !0, e.prototype = { processQuery: function (a) { var b = a.collectionName; if (g.isContentType.pushDevices(b) || g.isContentType.pushNotifications(b)) return this.everlive.isOnline() ? g.successfulPromise() : g.rejectedPromise(new l(m.pushNotSupportedOffline)); var c = this.checkSupportedQuery(a); if (c && !a.isSync) return new q.Promise(function (a, b) { b(new l(c)) }); var d = a.getQueryParameters(), e = g.getUnsupportedOperators(d.filter), i = e.length; if (i) return new q.Promise(function (a, b) { var c; c = 1 === i ? "The operator " + e[0] + " is not supported in offline mode." : "The operators " + e.join(",") + "are not supported in offline mode.", b(new l(c, m.operationNotSupportedOffline.code)) }); switch (h.traverseAndTransformFilterId(d.filter), a.operation) { case f.operations.Read: return this.read(a, d.filter, d.sort, d.skip, d.limit, d.select, d.expand); case f.operations.ReadById: return this.readById(a, d.expand); case f.operations.FilesGetDownloadUrlById: return this.getDownloadUrlById(a); case f.operations.Count: return this.count(a, d.filter); case f.operations.Create: return this.create(a); case f.operations.RawUpdate: case f.operations.Update: return this.update(a, d.filter); case f.operations.FilesUpdateContent: return this.updateFileContent(a, d.filter); case f.operations.Delete: return this.remove(a, d.filter); case f.operations.DeleteById: return d.filter._id = a.additionalOptions.id, this.remove(a, d.filter); case f.operations.Aggregate: return this.aggregate(a, d); default: return new q.Promise(function (b, c) { a.isSync ? b() : c(new l(a.operation + " is not supported in offline mode.")) }) } }, getDownloadUrlById: function (a) { var b, c, d = this, e = a.additionalOptions.id; return d.everlive.files.useOffline(!0).isSync(a.isSync).getById(e).then(function (a) { var b = a.result; return c = b.Uri, d.everlive.offlineStorage.files._getFileUrlForId(b.Id, b.Filename) }).then(function (a) { return b = a, d.everlive.offlineStorage._offlineFilesProcessor.fileStore.getFileByAbsolutePath(a) }).then(function (a) { return { result: { Uri: a ? b : c } } }) }, checkSupportedQuery: function (a) { for (var b = 0; b < y.length; b++) { var e = y[b]; if (a.getHeader(e)) return "The header " + e + " is not supported in offline mode" } if (g.isContentType.users(a.collectionName) && z[a.operation]) return c(a); if (g.isContentType.files(a.collectionName) && (a.operation === f.operations.create && Array.isArray(a.data) || a.operation === f.operations.rawUpdate || a.operation === f.operations.update)) return m.invalidRequest; var h = a.additionalOptions && a.additionalOptions.id, i = a.operation === f.operations.Update && !h, j = a.operation === f.operations.RawUpdate; return g.isContentType.files(a.collectionName) && (j || i) ? d(a) : void 0 }, _getCreateResult: function (a, b) { if (1 === a.length) { var c; if (b) { var d = p.extend({}, a[0]); c = h.idTransform(d) } else c = { CreatedAt: g.cloneDate(a[0].CreatedAt), Id: a[0]._id }; return { result: c } } var e = []; return p.each(a, function (a) { var c; if (b) { var d = p.extend({}, a); c = h.idTransform(d) } else c = { CreatedAt: g.cloneDate(a.CreatedAt), Id: a._id }; e.push(c) }), { result: e } }, create: function (a) { var b = this; return b._createItems(a.collectionName, a.data, a.isSync, a.preserveState).then(function (c) { var d = g.isContentType.files(a.collectionName); return b._getCreateResult(c, d) }) }, read: function (a, b, c, d, e, f, g) { var i, j = this; return new q.Promise(function (k, l) { var m; j._prepareExpand(g, a, !0).then(function (b) { return i = b, b && (f = b.mainQueryFieldsExpression), j._getCollection(a.collectionName) }).then(function (g) { var k = j._readInternal(g, b, c, d, e, f); if (d || e) { var l = j._readInternal(g); m = l.length } return k = j._shouldAutogenerateIdForContentType(a.collectionName) ? h.idTransform(k) : h.removeIdTransform(k, !0), j._expandResult(i, k) }).then(function (b) { var c = j._transformOfflineResult(b, m, a); k(c) })["catch"](l) }) }, _readInternal: function (a, b, c, d, e, f) { var g = p.extend({}, b), i = this._getWithoutDeletedFilter(g); h.traverseAndTransformFilterId(i); var j = r.Query(i), k = r.Cursor(a, j, f); return c && (k = k.sort(c)), d && k.skip(d), e && k.limit(e), p.map(k.all(), function (a) { return p.extend({}, a) }) }, readById: function (a, b) { var c, d = this; return d._prepareExpand(b, a, !1).then(function (b) { return c = b, d._getCollection(a.collectionName) }).then(function (b) { return new q.Promise(function (e, f) { var g = d._getById(b, a.additionalOptions.id); return g ? (g = h.idTransform(g), d._expandResult(c, g).then(e)["catch"](f)) : f(new l(m.itemNotFound)) }) }).then(function (b) { return d._transformOfflineResult(b, null, a) }) }, _getById: function (a, b) { if (!b) throw new l("Id field is mandatory when using offline storage"); if (a[b]) { var c = p.extend({}, a[b]), d = c && c[v.offlineItemsStateMarker] === x.deleted; return d ? void 0 : c } }, _prepareExpand: function (a, b, c) { return new q.Promise(function (d, e) { a ? i.prepare(a, b.collectionName, c, b.fields, null, null, function (a, b) { return a ? ("ExpandError" === a.name && (a.code = m.invalidExpandExpression.code), e(a)) : void d(b) }) : d() }) }, _expandResult: function (a, b) { var c = this; return new q.Promise(function (d, e) { a ? i.expand(a.relationsTree, b, { offlineModule: c }, function (a, b) { return a ? ("ExpandError" === a.name && (a.code = m.invalidExpandExpression.code), e(a)) : void d(b) }) : d(b) }) }, _getWithoutDeletedFilter: function (a) { var b = { $and: [] }; b.$and.push(a); var c = {}; return c[v.offlineItemsStateMarker] = { $ne: x.deleted }, b.$and.push(c), b }, _getUpdateItemsResult: function (a) { var b = a.length, c = b ? a[0].ModifiedAt : new Date; return { ModifiedAt: c, result: b } }, update: function (a, b) { var c = this; return this._updateItems(a, a.data, b, a.isSync).then(function (a) { return c._getUpdateItemsResult(a) }) }, remove: function (a, b) { return this._removeItems(a, b, a.isSync) }, count: function (a, b) { var c = this; return new q.Promise(function (d, e) { c._getCollection(a.collectionName).then(function (a) { var e = c._readInternal(a, b); d({ result: e.length }) })["catch"](e) }) }, _setItemDates: function (a, b, c) { b.CreatedAt = a.CreatedAt && a.CreatedAt instanceof Date ? g.cloneDate(a.CreatedAt) : new Date, b.ModifiedAt = g.cloneDate(a.ModifiedAt && a.ModifiedAt instanceof Date ? a.ModifiedAt : b.CreatedAt), b.CreatedBy = b.CreatedBy || this.everlive.setup.principalId || v.guidEmpty, b.ModifiedBy = b.ModifiedBy || b.CreatedBy, b.Owner = "Users" === c ? b._id : b.CreatedBy || v.guidEmpty }, _mapCreateItem: function (a, b, c, d, e) { function f() { return h._setItemDates(a, i, e), h._setItem(b, p.extend({}, i), j), i } var h = this, i = p.extend({}, a); i._id = i.Id || g.uuid(), delete i.Id; var j, k = h._getById(b, i._id), m = !!k; if (m && !c && !d) throw new l("An item with the specified id already exists"); return j = c && d && m ? k[v.offlineItemsStateMarker] : c ? void 0 : x.created, g.isContentType.files(e) ? h.offlineFilesProcessor.upsertFileFromObject(i, !0, c).then(f) : f() }, _createItems: function (a, b, c, d) { var e = this; return this._getCollection(a).then(function (f) { var g = p.isArray(b) ? b : [b], i = p.map(g, function (b) { return e._mapCreateItem(b, f, c, d, a) }); return q.all(i).then(function (b) { return e._persistData(a).then(function () { return e._shouldAutogenerateIdForContentType(a) || c || (i = h.removeIdTransform(b)), b }) }) }) }, _applyUpdateOperation: function (a, b, c, d, e) { var f, h = g.getDbOperators(a, !0), i = 0 !== h.length; f = i ? a : { $set: a }; var j = { ModifiedBy: this.everlive.setup.principalId || v.guidEmpty }; f.$set = p.extend(j, f.$set), d && (f.$set.ModifiedAt = g.cloneDate(a.ModifiedAt || e)), s(b, {}, f, { strict: !0 }), b._id = b._id || f._id || f.Id, delete b.Id; var k; k = d ? void 0 : b[v.offlineItemsStateMarker] === x.created ? x.created : x.modified, this._setItem(c, b, k) }, updateFileContent: function (a) { if (j.isDesktop) return g.successfulPromise(); var b, c = a.isSync, d = a.data, e = this, f = a.additionalOptions.id, h = a.collectionName; return this._getCollection(h).then(function (a) { var g = e._getById(a, f); return b = [g], g.base64 = d.base64, g.Filename = d.Filename, g.ContentType = d.ContentType, delete g.Uri, e._overwriteFile(f, g, c).then(function () { return e._applyUpdateOperation(d, g, a), e._setItem(a, g, v.offlineItemStates.modified), e._persistData(h) }).then(function () { return e._getUpdateItemsResult(b) }) }) }, _overwriteFile: function (a, b, c) { var d = this; return d.everlive.offlineStorage.files.purge(a).then(function () { return d.offlineFilesProcessor.upsertFileFromObject(b, !0, c) }) }, _updateItems: function (a, b, c, d) { var e = this, f = a.collectionName; return e._getCollection(f).then(function (h) { var i; if (a.additionalOptions && a.additionalOptions.id) { var j = a.additionalOptions.id, k = e._getById(h, j); if (!k) throw new l(m.itemNotFound, "Item with id :" + j + " does not exist offline in the collection :" + f); if (i = [k], g.isContentType.files(f) && b.$set && b.$set.Filename || b.Filename) { var n = b.Filename || b.$set.Filename, o = u.extname(n); return e.everlive.offlineStorage.files.changeFileExtensionById(j, o).then(function () { return e._applyUpdateOperation(b, k, h, d, a.ModifiedAt), e._persistData(f) }).then(function () { return i }) } e._applyUpdateOperation(b, k, h, d, a.ModifiedAt) } else { i = e._readInternal(h, c); for (var p = 0; p < i.length; p++) { var q = i[p], r = !!e._getById(h, q._id.toString()); if (!r && !d) throw new l(m.itemNotFound); e._applyUpdateOperation(b, q, h, d, a.ModifiedAt) } } return e._persistData(f).then(function () { return i }) }) }, _getAllCollections: function () { var a = this; return new q.Promise(function (b, c) { a._persister.getAllData(function (c) { p.each(c, function (b, d) { var e = a._encryptionProvider.decrypt(b); c[d] = JSON.parse(e || "{}", g.parseUtilities.getReviver()) }), b(c) }, c) }) }, _getCollection: function (a) { var b = this; return new q.Promise(function (c, d) { b._collectionCache[a] ? c(b._collectionCache[a]) : b._persister.getData(a, function (d) { var e = b._encryptionProvider.decrypt(d), f = JSON.parse(e || "{}", g.parseUtilities.getReviver()); b._collectionCache[a] = f, c(b._collectionCache[a]) }, d) }) }, _setItem: function (a, b, c) { c ? b[v.offlineItemsStateMarker] = c : delete b[v.offlineItemsStateMarker], a[b._id] = b }, _getDirtyItems: function (a) { var b = {}; b[v.offlineItemsStateMarker] = { $exists: !0 }; var c = r.Query(b), d = r.Cursor(a, c); return d.all() }, _persistData: function (a) { var b = this; return new q.Promise(function (c, d) { var e = b._collectionCache[a] || {}; b._transformPersistedData(a, e); var f = JSON.stringify(e), g = b._encryptionProvider.encrypt(f); b._persister.saveData(a, g, c, d) }) }, _shouldAutogenerateIdForContentType: function (a) { return !(this.setup && this.setup.typeSettings && this.setup.typeSettings[a] && this.setup.typeSettings[a].autoGenerateId === !1) }, _clearItem: function (a, b) { delete a[b._id] }, _mapRemoveItem: function (a, b, c, d) { var e = this; return new q.Promise(function (b, c) { return g.isContentType.files(d) && !j.isDesktop ? e.everlive.offlineStorage.files.purge(a._id).then(b, c) : b() }).then(function () { a._id = a._id || a.Id; var d = !!e._getById(b, a._id.toString()); if (!d && !c) throw new l("Cannot delete item - item with id " + a._id + " does not exist."); var f = a[v.offlineItemsStateMarker] === x.created || c; f ? e._clearItem(b, a) : e._setItem(b, a, x.deleted) }) }, _removeItems: function (a, b, c) { var d = this, e = a.collectionName; return d._getCollection(e).then(function (a) { var f = d._readInternal(a, b), g = p.map(f, function (b) { return d._mapRemoveItem(b, a, c, e) }); return q.all(g) }).then(function (a) { return d._persistData(e).then(function () { return a }) }).then(function (a) { return d._transformOfflineResult(a.length) }) }, _applyTransformations: function (a, b) { Array.isArray(a.result) ? p.each(b, function (b) { a.result.map(function (c, d) { a.result[d] = b(c) }) }) : p.each(b, function (b) { a.result = b(a.result) }) }, _transformOfflineResult: function (a, b, c, d) { var e = { result: a, count: b || (a || []).length }; (void 0 !== b && null !== b || Array.isArray(a)) && (e.count = b || a.length); var f = []; if (f.push(h.idTransform), f.push(h.removeMarkersTransform), c) { var g = c.getHeader(w.includeCount); g === !1 && delete e.count; var i = c.getHeader(w.singleField); "string" == typeof i && f.push(h.singleFieldTransform.bind(this, i)) } return d && (f = f.concat(d)), this._applyTransformations(e, f), void 0 === e.count && delete e.count, e }, _transformPersistedData: function (a, b) { var c = []; "Users" === a && (c = c.concat(["Password", "SecretQuestionId", "SecretAnswer"])), c.length && p.each(b, function (a) { h.removeFieldsTransform(a, c) }) }, aggregate: function (a, b) { var c = this; return this._getCollection(a.collectionName).then(function (d) { if (!b || !b.aggregate || p.isEmpty(b.aggregate)) throw new l("You must specify a valid aggregation definition. Either GroupBy or Aggregate is required."); var e = p.extend({}, b.aggregate); e.Filter = b.filter; var f = t.translate(e, { maxDocumentsCount: v.Aggregation.MaxDocumentsCount }), g = p.filter(d, function (a) { return a[v.offlineItemsStateMarker] !== v.offlineItemStates.deleted }), h = r.aggregate(g, f); return c._transformOfflineResult(h, null, a) }) }, purgeAll: function (a, b) { var c = this; return this._collectionCache = {}, n(function (a, b) { c._collectionCache = {}, c._persister.purgeAll(function () { c.everlive.setup.caching ? c.everlive.cache.clearAll(a, b) : a() }, b) }, a, b) }, purge: function (a, b, c) { var d = this; return n(function (b, c) { delete d._collectionCache[a], d._persister.purge(a, function () { d.everlive.setup.caching ? d.everlive.cache.clear(a, b, c) : b() }, c) }, b, c) } }, b.exports = e }, { "../EverliveError": 48, "../ExpandProcessor": 49, "../common": 59, "../constants": 60, "../everlive.platform": 62, "../query/DataQuery": 87, "../query/Query": 89, "../utils": 102, "./offlineTransformations": 79, path: 3 }], 76: [function (a, b) {
var c = a("../query/DataQuery"), d = a("../EverliveError"), e = d.EverliveError, f = d.EverliveErrors, g = a("../constants"), h = g.offlineItemStates, i = a("../query/RequestOptionsBuilder"), j = a("../common"), k = j._, l = j.rsvp, m = a("../utils"), n = a("../Request"), o = a("./offlineTransformations"), p = a("../utils").buildPromise, q = a("./OfflineQueryProcessor"), r = a("./OfflineFilesProcessor"), s = a("./OfflineFilesModule"), t = (a("path"), a("../query/Query")), u = { server: "server", client: "client" }; b.exports = function () {
function a(a, b, c, d) { this._everlive = a, this.setup = b, this._isSynchronizing = !1, this._encryptionProvider = d, this._offlineFilesProcessor = new r(this.setup, this._everlive), this._queryProcessor = new q(c, d, this._offlineFilesProcessor, this._everlive, this.setup), this.files = new s(this._offlineFilesProcessor, this._everlive, this.setup.files.maxConcurrentDownloads) } var b = function (a) { var b = d(a); return b.ModifiedAt = a.ModifiedAt, b }, d = function (a) { return { Id: a.Id } }; return a.prototype = {
purgeAll: function (a, b) { return this._queryProcessor.purgeAll(a, b) }, purge: function (a, b, c) { return this._queryProcessor.purge(a, b, c) }, processQuery: function (a) { return this._queryProcessor.processQuery(a) }, _setOffline: function (a) { this.setup.offline = a }, isOnline: function () { return !this.setup.offline }, _prepareSyncData: function (a) { var b = this, c = {}, d = []; return k.each(a, function (a, e) { var f = o.idTransform(a.offlineItemsToSync), g = b._getSyncItemStates(e, f, a.serverItems); d.push(g.conflicts), c[e] = g.itemsForSync }), { conflicts: d, contentTypesSyncData: c } }, _resolveConflicts: function (a) { var b = this; return this._applyResolutionStrategy(a.conflicts).then(function () { return b._mergeResolvedConflicts(a.conflicts, a.contentTypesSyncData) }).then(function () { return a.contentTypesSyncData }) }, isSynchronizing: function () { return this._isSynchronizing }, _fireSyncStart: function () { var a = this; return new l.Promise(function (b) { a._isSynchronizing ? b() : (a._isSynchronizing = !0, a._everlive._emitter.emit(g.Events.SyncStart), b()) }) }, _fireSyncEnd: function () { this._isSynchronizing = !1, this._everlive._emitter.emit(g.Events.SyncEnd, this._syncResultInfo), delete this._syncResultInfo }, _eachSyncItem: function (a, b, c, d) { var e = this; k.each(a, function (a) { var f = b(a.remoteItem), g = a.resultingItem, h = a.isCustom, i = a.resolutionType; k.some(e._syncResultInfo.failedItems[c], { itemId: g.Id }) || d(g, f, h, i) }) }, _shouldAutogenerateIdForContentType: function (a) { return this._queryProcessor._shouldAutogenerateIdForContentType(a) }, _addCreatedFileToSyncPromises: function (a, b, c) { var d = this; k.each(a, function (a) { var e = d._everlive.files; b[a.Id] = new l.Promise(function (b, f) { d.files.getOfflineLocation(a.Id).then(function (b) { return b ? d._transferFile(!1, a, b) : void 0 }, function (b) { f({ type: h.created, items: a, contentType: c, error: b, storage: u.server }) }).then(function (b) { var f = k.extend({}, a, b.result); return d._onItemProcessed(f, c, u.server, h.created), e.isSync(!0).useOffline(!0).updateSingle(f) }, function (b) { f({ type: h.created, items: a, contentType: c, error: b, storage: u.server }) }).then(b, function (b) { f({ type: h.modified, items: a, contentType: c, error: b, storage: u.client }) }) }) }) }, _transferFile: function (a, b, c) { var d = this._everlive; return new l.Promise(function (e, f) { var h = this, i = d.files.getUploadUrl(), j = m.successfulPromise(); a && (j = new l.Promise(function (a) { d.files.isSync(!0).applyOffline(!1).getById(b.Id).then(function () { a(!0) })["catch"](function () { a(!1) }) })), j.then(function (j) { var l = a && j; l && (i += "/" + b.Id + "/Content"); var n = new FileTransfer, o = g.fileUploadKey, p = { fileKey: o, httpMethod: l ? "PUT" : "POST", mimeType: b.ContentType, fileName: b.Filename, headers: d.buildAuthHeader() }; p.params = {}, k.each(b, function (a, b) { if ("base64" !== b.toLowerCase()) { var c = g.fileUploadKey + g.fileUploadDelimiter + b; p.params[c] = a } }), n.upload(c, i, function (a) { var b = m.parseUtilities.parseJSON(a.response); b.Result === !1 ? f.apply(h, arguments) : e(k.isArray(b.Result) ? { result: b.Result[0] } : b) }, f, p, !0) }) }) }, _addCreatedObjectToSyncPromises: function (a, b, c, d, e, f) { var g = this, i = new l.Promise(function (a, i) { b.isSync(!0).applyOffline(!1).create(c).then(function (a) { c = k.map(c, function (b, c) { b.Id = a.result[c].Id, b.CreatedAt = b.ModifiedAt = a.result[c].CreatedAt; var f = k.find(d.createdItems, function (a) { return a.resultingItem.Id === b.Id }); return f.isCustom && g._onItemProcessed(b, e, u.client, h.modified), b }) }, function (a) { throw { type: h.created, items: c, contentType: e, error: a, storage: u.server } }).then(function () { return b.isSync(!0).useOffline(!0).create(c).then(function () { k.each(c, function (a) { g._onItemProcessed(a, e, u.server, h.created) }) }, function (a) { throw { type: h.created, items: c, contentType: e, error: a, storage: u.client } }) }).then(function () { if (f && f.length) { var a = { Id: { $in: f } }; return b.isSync(!0).useOffline(!0).destroy(a)["catch"](function (a) { throw { type: h.created, items: c, contentType: e, error: a, storage: u.client } }) } }).then(a)["catch"](function (a) { i(a) }) }); return k.each(c, function (b) { a[b.Id] = i }), c }, _addCreatedItemsForSync: function (a, b, c) { var d, e = c.collectionName, f = k.pluck(a.createdItems, "resultingItem"); return this._shouldAutogenerateIdForContentType(e) || (d = k.pluck(f, "Id"), f = o.removeIdTransform(f)), m.isContentType.files(e) ? this._addCreatedFileToSyncPromises(f, b, e) : this._addCreatedObjectToSyncPromises(b, c, f, a, e, d) }, _addUpdatedItemsForSync: function (a, b, c, d, e) { var f = this, g = d.collectionName; f._eachSyncItem(a.modifiedItems, b, g, e) }, _addDeletedItemsForSync: function (a, b, c, d, e) { var f = this, g = d.collectionName; f._eachSyncItem(a.deletedItems, b, g, e) }, _onSyncResponse: function (a, b, d, e, g) { var i = this; if (1 !== a.result) return new l.Promise(function (a, b) { b(k.extend({}, f.syncConflict, { contentType: d })) }); if (e === c.operations.Update) { i._onItemProcessed(b, d, u.server, h.modified); var j = k.extend({}, b, { ModifiedAt: a.ModifiedAt }), m = new c({ operation: e, data: j, additionalOptions: { id: b.Id }, collectionName: d, isSync: !0 }); return this.processQuery(m).then(function () { if (g) { var a = k.find(i._syncResultInfo.syncedItems[d], function (a) { return a.itemId === b.Id }); a || i._onItemProcessed(b, d, u.client, h.modified) } }) } return e === c.operations.Delete ? (i._onItemProcessed(b, d, u.server, h.deleted), this._purgeById(d, b.Id).then(function () { g && i._onItemProcessed(b, d, u.client, h.deleted) })) : void 0 }, _purgeById: function (a, b) { var c = this; return this._queryProcessor._getCollection(a).then(function (d) { return delete d[b], c._queryProcessor._persistData(a) }) }, sync: function () { var a = this; if (a._syncResultInfo = a._syncResultInfo || { syncedItems: {}, syncedToServer: 0, syncedToClient: 0, failedItems: {}, error: void 0 }, !this.isOnline()) throw new e("Cannot synchronize while offline"); a._fireSyncStart().then(function () { return a._applySync() }).then(function (b) { var c = []; return k.each(b, function (b, d) { b && "rejected" === b.state && (b.reason && b.reason.code === f.syncConflict.code ? c.push(b) : a._onItemFailed(b, d)) }), c.length ? a.sync() : void a._fireSyncEnd() })["catch"](function (b) { a._syncResultInfo.error = b, a._fireSyncEnd() }) }, _handleKeepServer: function (a, b, d, f) { var i, j = this, k = b.serverItem, n = b.clientItem; if (k && n) i = new c({ collectionName: a, operation: c.operations.Update, additionalOptions: { id: k.Id }, data: k }); else if (k && !n) i = new c({ collectionName: a, operation: c.operations.Create, data: k }); else { if (k || !n) throw new e('Both serverItem and clientItem are not set when syncing data with "KeepServer" resolution strategy.'); i = new c({ collectionName: a, operation: c.operations.DeleteById, additionalOptions: { id: n.Id } }) } i.isSync = !0, d.push(new l.Promise(function (d, e) { j.processQuery(i).then(function () { switch (i.operation) { case c.operations.Update: j._onItemProcessed(k, a, u.client, h.modified), m.isContentType.files(a) && f.modifiedItems.push({ remoteItem: b.serverItem, resultingItem: k, resolutionType: g.ConflictResolution.KeepServer }); break; case c.operations.Create: j._onItemProcessed(k, a, u.client, h.created); break; case c.operations.DeleteById: j._onItemProcessed(n, a, u.client, h.deleted) } d() }, function (a) { var b, d; switch (i.operation) { case c.operations.Update: b = k.Id, d = h.modified; break; case c.operations.Create: b = k.Id, d = h.created; break; case c.operations.DeleteById: b = n.Id, d = h.deleted } e({ itemId: b, type: d, contentType: i.collectionName, error: a, storage: u.client }) }) })) }, _handleKeepClient: function (a, b) { var c, d, f = a.serverItem, h = a.clientItem; if (f && h) c = k.extend(h, { ModifiedAt: new Date(f.ModifiedAt) }), d = b.modifiedItems; else if (f && !h) c = f, d = b.deletedItems; else { if (f || !h) throw new e('Both serverItem and clientItem are not set when syncing data with "KeepClient" resolution strategy.'); c = h, d = b.createdItems } d.push({ remoteItem: a.serverItem, resultingItem: c, resolutionType: g.ConflictResolution.KeepClient }) }, _handleCustom: function (a, b, d, e) {
var f = a.serverItem, g = a.clientItem, i = k.omit(a.result.item, "CreatedAt", "ModifiedAt"); if (f && i) {
var j = new c({ collectionName: b, operation: c.operations.Create, data: f }); j.preserveState = !0, j.isSync = !0, d.push(this.processQuery(j)),
this._onItemProcessed(f, b, u.client, h.created)
} if (f && i && !g) i.Id = f.Id, e.modifiedItems.push({ remoteItem: f, resultingItem: i, isCustom: !0 }); else if (f && !i) e.deletedItems.push({ remoteItem: a.serverItem, resultingItem: f, isCustom: !0 }); else if (!f && i && g) { var l = new c({ collectionName: b, operation: c.operations.Update, data: i, additionalOptions: { id: g.Id } }); d.push(this.processQuery(l)), i.Id = g.Id, e.createdItems.push({ remoteItem: f, resultingItem: i, isCustom: !0 }) } else i.Id = f.Id, e.modifiedItems.push({ remoteItem: f, resultingItem: i, isCustom: !0 })
}, _mergeResolvedConflicts: function (a, b) { var c = this, d = []; return k.each(a, function (a) { var h = a.contentTypeName; k.each(a.conflictingItems, function (a) { var i = b[h]; switch (a.result.resolutionType) { case g.ConflictResolution.KeepServer: c._handleKeepServer(h, a, d, i); break; case g.ConflictResolution.KeepClient: c._handleKeepClient(a, i); break; case g.ConflictResolution.Custom: if (m.isContentType.files(h)) { var j = f.customFileSyncNotSupported; throw new e(j.message, j.code) } c._handleCustom(a, h, d, i); break; case g.ConflictResolution.Skip: } }) }), l.all(d) }, _getSyncItemStates: function (a, b, c) { var d = this, i = { itemsForSync: { createdItems: [], modifiedItems: [], modifiedItemsOnServer: [], deletedItems: [], deletedItemsOnServer: [] }, conflicts: { contentTypeName: a, conflictingItems: [] } }; return k.each(b, function (b) { var j = k.findWhere(c, { Id: b.Id }); if (j) { if (j.Id === b.Id && b[g.offlineItemsStateMarker] === h.created) return d.setup.conflicts.strategy === g.ConflictResolutionStrategy.Custom ? (d._onItemFailed({ type: h.modified, storage: u.client, error: new e(f.syncError), contentType: a }, b.Id), d._onItemFailed({ type: h.modified, storage: u.server, error: new e(f.syncError), contentType: a }, j.Id)) : d._onItemFailed({ type: h.created, storage: u.client, error: new e(f.syncError), contentType: a }, j.Id); var l = !!b[g.offlineItemsStateMarker], m = !1; l && (m = j.ModifiedAt.getTime() !== b.ModifiedAt.getTime() || b[g.offlineItemsStateMarker] === h.deleted), m ? i.conflicts.conflictingItems.push({ clientItem: b[g.offlineItemsStateMarker] === h.deleted ? null : b, serverItem: j, result: {} }) : b[g.offlineItemsStateMarker] === h.deleted ? i.itemsForSync.deletedItems.push({ remoteItem: j, resultingItem: b }) : b[g.offlineItemsStateMarker] === h.modified ? i.itemsForSync.modifiedItems.push({ remoteItem: j, resultingItem: b }) : void 0 === b[g.offlineItemsStateMarker] ? i.itemsForSync.modifiedItemsOnServer.push(j) : i.itemsForSync.modifiedItems.push({ remoteItem: j, resultingItem: j }) } else b[g.offlineItemsStateMarker] === h.modified ? i.conflicts.conflictingItems.push({ clientItem: b, serverItem: null, result: {} }) : b[g.offlineItemsStateMarker] === h.created ? i.itemsForSync.createdItems.push({ remoteItem: j, resultingItem: b }) : i.itemsForSync.deletedItemsOnServer.push(b); delete b[g.offlineItemsStateMarker] }), i }, _setResolutionTypeForItem: function (a, b) { b.result = { resolutionType: a } }, _applyResolutionStrategy: function (a) { var b = this, c = b.setup.conflicts.strategy; return new l.Promise(function (d, f) { for (var h = [], i = 0; i < a.length; i++) { var j = a[i]; if (j.conflictingItems.length) switch (c) { case g.ConflictResolutionStrategy.ServerWins: k.each(j.conflictingItems, b._setResolutionTypeForItem.bind(b, g.ConflictResolution.KeepServer)); break; case g.ConflictResolutionStrategy.Custom: var m = b.setup.conflicts.implementation; if (!m) return f(new e("Implementation of the conflict resolution strategy must be provided when set to Custom")); h.push(new l.Promise(function (b) { m(a, b) })); break; default: return f(new e("Invalid resolution strategy provided")) } } l.all(h).then(function () { d() }) }) }, _getSyncPromiseBatch: function (a, b) { var d = this; return new l.Promise(function (e, f) { var g = new c({ collectionName: a, query: new t({ Id: { $in: b } }), operation: c.operations.Read, onSuccess: function (a) { e(a.result) }, applyOffline: !1, onError: f }), h = i[g.operation], j = h(g), k = new n(d._everlive.setup, j); k.send() }) }, _getPlainItemsForSync: function (a, b) { return this.setup.syncUnmodified && !b ? k.values(a) : this._queryProcessor._getDirtyItems(a) }, _getIdsForSync: function (a, b) { return this._shouldAutogenerateIdForContentType(a) ? k.pluck(b, "_id") : k.pluck(k.reject(b, function (a) { return a[g.offlineItemsStateMarker] === h.created }), "_id") }, _getSyncPromiseForCollection: function (a, b) { for (var c = [], d = g.syncBatchSize, e = this._getPlainItemsForSync(a), f = this._getIdsForSync(b, e), h = Math.ceil(f.length / d), i = 0; h > i; i++) { var j = i * d, m = f.slice(j, j + d), n = this._getSyncPromiseBatch(b, m); c.push(n) } return l.all(c).then(function (a) { var b = { serverItems: [] }; return k.each(a, function (a) { b.serverItems = k.union(b.serverItems, a) }), b.offlineItemsToSync = e, b }) }, _onItemFailed: function (a, b) { var c = this, d = a.reason ? a.reason : a, e = d.contentType, f = function (a) { var b = k.pick(d, "storage", "type", "error"); return k.extend({ itemId: a, contentType: e }, b) }, g = []; d.type === h.created && d.items ? g = k.map(d.items, function (a) { return f(a.Id) }) : g.push(f(b)), c._syncResultInfo.failedItems[e] = c._syncResultInfo.failedItems[e] || [], k.each(g, function (a) { c._syncResultInfo.failedItems[e].push(a), c._fireItemProcessed(a) }) }, _onItemProcessed: function (a, b, c, d) { var e = { itemId: a.Id, type: d, storage: c, contentType: b }; this._syncResultInfo.syncedItems[b] = this._syncResultInfo.syncedItems[b] || [], this._syncResultInfo.syncedItems[b].push(e), e.storage == u.server ? this._syncResultInfo.syncedToServer++ : this._syncResultInfo.syncedToClient++, this._fireItemProcessed(e) }, _fireItemProcessed: function (a) { this._everlive._emitter.emit(g.Events.ItemProcessed, a) }, _getClientWinsSyncData: function (a, b) { var c = this, d = {}; return k.each(a, function (a, e) { d[e] || (d[e] = { createdItems: [], modifiedItems: [], deletedItems: [], deletedItemsOnServer: [], modifiedItemsOnServer: [] }); var f = c._getPlainItemsForSync(a, b), i = o.idTransform(f); k.each(i, function (a) { switch (a[g.offlineItemsStateMarker]) { case h.created: d[e].createdItems.push({ remoteItem: a, resultingItem: a }); break; case h.modified: d[e].modifiedItems.push({ remoteItem: a, resultingItem: a }); break; case h.deleted: d[e].deletedItems.push({ remoteItem: a, resultingItem: a }) } delete a[g.offlineItemsStateMarker] }) }), d }, _getModifiedFilesForSyncClientWins: function (a, b, c) { var d = this, e = d._everlive; return new l.Promise(function (f, g) { var i = d.files; i.getOfflineLocation(a).then(function (a) { return a ? d._transferFile(!0, b, a).then(function (a) { return a.Result !== !1 ? { result: a } : void g({ type: h.modified, itemId: b.Id, contentType: c, error: a, storage: u.server }) }, function (a) { g({ type: h.modified, itemId: b.Id, contentType: c, error: a, storage: u.server }) }) : e.files.isSync(!0).applyOffline(!1).updateSingle(b).then(function (a) { return a }, function (a) { g({ type: h.modified, itemId: b.Id, contentType: c, error: a, storage: u.server }) }) }).then(function (a) { var f = a.result; return b.ModifiedAt = f.ModifiedAt, d._onItemProcessed(b, c, u.server, h.modified), e.files.isSync(!0).useOffline(!0).updateSingle(b) }).then(f)["catch"](function (a) { g({ type: h.modified, itemId: b.Id, contentType: c, error: a, storage: u.server }) }) }) }, _getModifiedItemForSyncClientWins: function (a, b, d) { var e = this; return new l.Promise(function (f, g) { return a.isSync(!0).applyOffline(!1).updateSingle(b).then(function (a) { e._onItemProcessed(b, d, u.server, h.modified); var f = k.extend({}, b, { ModifiedAt: a.ModifiedAt }), g = new c({ operation: c.operations.Update, data: f, additionalOptions: { id: b.Id }, collectionName: d, isSync: !0 }); return e.processQuery(g) }, function (a) { g({ storage: u.server, type: h.modified, itemId: b.Id, contentType: d, error: a }) }).then(f, function (a) { g({ storage: u.client, type: h.modified, itemId: b.Id, contentType: d, error: a }) }) }) }, _addModifiedItemsForSyncClientWins: function (a, b, c) { var f = this; this._addUpdatedItemsForSync(a, d, b, c, function (a) { var d = a.Id; if (!d) throw new e("When updating an item it must have an Id field."); var g = c.collectionName; b[d] = m.isContentType.files(g) ? f._getModifiedFilesForSyncClientWins(d, a, g) : f._getModifiedItemForSyncClientWins(c, a, g) }) }, _addDeletedItemsForSyncClientWins: function (a, b, c) { var f = this; this._addDeletedItemsForSync(a, d, b, c, function (a, d) { var g = c.collectionName; b[a.Id] = new l.Promise(function (b, i) { var j = a.Id; if (!j) throw new e("When deleting an item it must have an Id field."); return c.isSync(!0).applyOffline(!1).destroySingle(d).then(function () { return f._onItemProcessed(a, g, u.server, h.deleted), f._purgeById(g, a.Id).then(function () { b() }, function (a) { i(k.extend({}, { storage: u.client, type: h.deleted, contentType: g, itemId: j, error: a })) }) }, function (a) { i(k.extend({}, { storage: u.server, type: h.deleted, contentType: g, error: a, itemId: j })) }) }) }) }, _applyClientWins: function (a) { var b = this, c = this._getClientWinsSyncData(a, !0), d = {}; k.each(c, function (a, c) { var e = b._everlive.data(c); a.createdItems.length && b._addCreatedItemsForSync(a, d, e), a.modifiedItems.length && b._addModifiedItemsForSyncClientWins(a, d, e), a.deletedItems.length && b._addDeletedItemsForSyncClientWins(a, d, e) }); var e; return l.hashSettled(d).then(function (c) { if (e = c, b.setup.syncUnmodified) { var d = []; return k.each(a, function (a, c) { var e = b._getPlainItemsForSync(a), f = k.where(e, function (a) { return void 0 !== a[g.offlineItemsStateMarker] }), h = b._everlive.data(c), i = k.pluck(f, "_id"), j = h.isSync(!0).useOffline(!1).get({ Id: { $in: i } }).then(function (a) { var d = a.result, e = k.pluck(d, "Id"); return b._unmodifiedClientWinsItemsDeletedOnServer(c, e, f).then(function () { return b._unmodifiedClientWinsItemsUpdatedOnServer(c, d, f) }) }); d.push(j) }), l.all(d) } }).then(function () { return e }) }, _unmodifiedClientWinsItemsDeletedOnServer: function (a, b, d) { var e = this, f = [], g = k.pluck(d, "_id"); return k.each(g, function (a) { -1 === b.indexOf(a) && f.push(a) }), m.successfulPromise().then(function () { if (0 !== f.length) { var b = new c({ operation: c.operations.Delete, filter: { Id: { $in: f } }, collectionName: a, isSync: !0 }); return e.processQuery(b).then(function () { k.each(f, function (b) { e._onItemProcessed({ Id: b }, a, u.client, h.deleted) }) }) } }) }, _unmodifiedClientWinsItemsUpdatedOnServer: function (a, b, d) { var e = this, f = []; return k.each(b, function (b) { var g = k.find(d, function (a) { return a._id === b.Id }); if (g) { var i = new c({ operation: c.operations.Update, data: b, additionalOptions: { id: g._id }, collectionName: a, isSync: !0 }), j = e.processQuery(i).then(function () { e._onItemProcessed(b, a, u.client, h.modified) }); f.push(j) } }), l.all(f) }, _modifyFileStandardSync: function (a, b, c, d, h) { var i = this, j = i._everlive.files; a[b] = new l.Promise(function (a, l) { var m; i.files.getOfflineLocation(b).then(function (a) { m = a }).then(function () { return j.isSync(!0).applyOffline(!1).getById(b) }).then(function (a) { var b = a.result; if (b.ModifiedAt.getTime() !== c.ModifiedAt.getTime()) l(k.extend({}, new e(f.syncConflict), { contentType: d })); else if (m) { if (h === g.ConflictResolution.KeepServer) return i.files._saveFile(c.Uri, c.Filename, c.Id).then(function () { return i._offlineFilesProcessor.purge(m) }).then(function () { return a }); if (h === g.ConflictResolution.KeepClient) return i._transferFile(!0, c, m) } }).then(function () { return i._everlive.files.isSync(!0).useOffline(!0).updateSingle(c) }).then(a)["catch"](l) }) }, _modifyContentTypeStandardSync: function (a, b, d, e, f, g, i) { var j = this; a[b] = d.isSync(!0).applyOffline(!1).update(e, f).then(function (a) { return j._onSyncResponse(a, e, g, c.operations.Update, i) }, function (a) { return new l.Promise(function (b, c) { c({ type: h.modified, itemId: e.Id, contentType: g, error: a, storage: u.server }) }) }) }, _applyStandardSync: function (a) { var d = this, e = {}; return k.each(a, function (a, b) { e[b] = d._getSyncPromiseForCollection(a, b) }), l.hash(e).then(function (a) { return d._prepareSyncData(a) }).then(function (a) { return d._resolveConflicts(a) }).then(function (a) { var e = {}; return k.each(a, function (a, f) { var g = d._everlive.data(f); a.createdItems.length && d._addCreatedItemsForSync(a, e, g), a.modifiedItems.length && d._addUpdatedItemsForSync(a, b, e, g, function (a, b, c, h) { var i = a.Id; m.isContentType.files(f) ? d._modifyFileStandardSync(e, i, a, f, h, c) : d._modifyContentTypeStandardSync(e, i, g, a, b, f, c) }), a.deletedItems.length && d._addDeletedItemsForSync(a, b, e, g, function (a, b, i) { e[a.Id] = g.isSync(!0).applyOffline(!1).destroy(b).then(function (b) { return d._onSyncResponse(b, a, f, c.operations.Delete, i) }, function (b) { return new l.Promise(function (c, d) { d({ type: h.deleted, itemId: a.Id, contentType: f, error: b, storage: u.server }) }) }) }), k.each(a.deletedItemsOnServer, function (a) { e[a.Id] = g.isSync(!0).useOffline(!0).destroySingle({ Id: a.Id }).then(function () { return d._onItemProcessed(a, f, u.client, h.deleted) }, function (b) { return new l.Promise(function (c, d) { d({ type: h.deleted, itemId: a.Id, contentType: f, error: b, storage: u.client }) }) }) }), k.each(a.modifiedItemsOnServer, function (a) { e[a.Id] = g.isSync(!0).useOffline(!0).update(a, { Id: a.Id }).then(function () { return d._onItemProcessed(a, f, u.client, h.modified) }, function (b) { return m.rejectedPromise({ type: h.modified, itemId: a.Id, contentType: f, error: b, storage: u.client }) }) }) }), l.hashSettled(e) }) }, _applySync: function () { var a = this; return this._queryProcessor._getAllCollections().then(function (b) { return a.setup.conflicts.strategy === g.ConflictResolutionStrategy.ClientWins ? a._applyClientWins(b) : a._applyStandardSync(b) }) }, getItemsForSync: function (a, b) { var c = this, d = {}; return p(function (a, b) { c._queryProcessor._getAllCollections().then(function (b) { k.each(b, function (a, b) { var e = c._getPlainItemsForSync(a); d[b] = k.map(e, function (a) { var b = { item: k.extend({}, a), action: a[g.offlineItemsStateMarker] }; return delete b.item[g.offlineItemsStateMarker], b }) }), a(d) })["catch"](b) }, a, b) }
}, a
}()
}, { "../EverliveError": 48, "../Request": 53, "../common": 59, "../constants": 60, "../query/DataQuery": 87, "../query/Query": 89, "../query/RequestOptionsBuilder": 91, "../utils": 102, "./OfflineFilesModule": 73, "./OfflineFilesProcessor": 74, "./OfflineQueryProcessor": 75, "./offlineTransformations": 79, path: 3 }], 77: [function (a, b) { var c = a("../constants"), d = a("./offlinePersisters"), e = (d.LocalStoragePersister, d.FileSystemPersister, a("./OfflineStorageModule")), f = a("../EverliveError").EverliveError, g = a("../everlive.platform").isNativeScript, h = a("../common"), i = h._, j = h.rsvp, k = a("../encryption/CryptographicProvider"), l = { autoSync: !0, enabled: !0, conflicts: { strategy: c.ConflictResolutionStrategy.ClientWins, implementation: null }, offline: !1, storage: { name: "", provider: g ? c.StorageProvider.FileSystem : c.StorageProvider.LocalStorage, implementation: null, storagePath: c.DefaultStoragePath, requestedQuota: c.DefaultFilesystemStorageQuota }, typeSettings: {}, encryption: { provider: c.EncryptionProvider.Default, implementation: null, key: "" }, files: { storagePath: c.DefaultFilesStoragePath, metaPath: c.DefaultFilesMetadataPath, maxConcurrentDownloads: c.MaxConcurrentDownloadTasks } }; b.exports = function () { function a(a) { var b, c = a.offline || a.offlineStorage; return c === !0 ? b = i.defaults({}, l) : i.isObject(c) ? (b = i.defaults(c, l), b.storage = i.defaults(c.storage, l.storage), b.encryption = i.defaults(c.encryption, l.encryption), b.conflicts = i.defaults(c.conflicts, l.conflicts), b.files = i.defaults(c.files, l.files)) : (b = i.defaults({}, l), b.enabled = !1, c || (a.offlineStorage = b)), b.cacheEnabled = a.caching && a.caching.enabled, b } var b = {}; b[c.ConflictResolutionStrategy.ClientWins] = function (a, b) { return new j.Promise(function (a) { a(b) }) }, b[c.ConflictResolutionStrategy.ServerWins] = function (a, b, c) { return new j.Promise(function (a) { a(c) }) }; var g = function (a) { var b = a.storage.name || "everliveOfflineStorage_" + this.setup.appId, c = d.getPersister(b, a); return a.storage.implementation = c, c }, h = function (a) { var b, d = a.encryption.provider, e = a.encryption.implementation; if (i.isObject(e) && d === c.EncryptionProvider.Custom) b = e; else switch (d) { case c.EncryptionProvider.Default: b = new k(a); break; case c.EncryptionProvider.Custom: throw new f("Custom encryption provider requires an implementation object"); default: throw new f("Unsupported encryption provider " + d) } return a.encryption.implementation = b, b }, m = function (b) { var c = a(b), d = g.call(this, c), f = h.call(this, c); return new e(this, c, d, f) }, n = function (a) { this.offlineStorage = m.call(this, a) }; return { initOfflineStorage: n, buildOfflineStorageOptions: a } }() }, { "../EverliveError": 48, "../common": 59, "../constants": 60, "../encryption/CryptographicProvider": 61, "../everlive.platform": 62, "./OfflineStorageModule": 76, "./offlinePersisters": 78 }], 78: [function (a, b) { var c = a("./persisters/BasePersister"), d = a("./persisters/LocalStoragePersister"), e = a("./persisters/FileSystemPersister"), f = a("../constants"), g = a("../EverliveError").EverliveError, h = a("../common")._; b.exports = { BasePersister: c, LocalStoragePersister: d, FileSystemPersister: e, getPersister: function (a, b) { var c, i = b.storage.provider, j = b.storage.implementation; if (h.isObject(j) && i === f.StorageProvider.Custom) c = j; else switch (i) { case f.StorageProvider.LocalStorage: c = new d(a, b); break; case f.StorageProvider.FileSystem: c = new e(a, b); break; case f.StorageProvider.Custom: throw new g("Custom storage provider requires an implementation object"); default: throw new g("Unsupported storage type " + i) } return c } } }, { "../EverliveError": 48, "../common": 59, "../constants": 60, "./persisters/BasePersister": 80, "./persisters/FileSystemPersister": 81, "./persisters/LocalStoragePersister": 82 }], 79: [function (a, b) { "use strict"; var c = a("../constants"), d = a("../common")._, e = c.offlineItemsStateMarker, f = function (a, b, c) { return d.isArray(a) ? d.map(a, function (a) { return b(a, c) }) : b(a, c) }, g = function (a) { return "object" == typeof a && a._id && !a.Id && (a.Id = a._id, delete a._id), a }, h = function (a, b) { var d = b.verifyStateCreated, e = d ? a[c.offlineItemsStateMarker] === c.offlineItemStates.created : !0; return "object" == typeof a && (a._id || a.Id) && e && (delete a._id, delete a.Id), a }, i = function (a) { return delete a[e], a }, j = { removeIdTransform: function (a, b) { return f(a, h, { verifyStateCreated: b }) }, idTransform: function (a) { return f(a, g) }, singleFieldTransform: function (a, b) { return "undefined" == typeof b || null === b ? null : b[a] }, traverseAndTransformFilterId: function (a) { a && a.Id && (a._id = a.Id, delete a.Id); for (var b in a) if (a.hasOwnProperty(b)) { var c = a[b]; "object" == typeof c && j.traverseAndTransformFilterId(c) } }, removeMarkersTransform: function (a) { return f(a, i) }, removeFieldsTransform: function (a, b) { return d.each(b, function (b) { delete a[b] }), a } }; b.exports = j }, { "../common": 59, "../constants": 60 }], 80: [function (a, b) { "use strict"; var c = a("../../EverliveError").EverliveError, d = (a("../../utils"), a("../../common")), e = d._, f = d.rsvp, g = function () { function a(a, b) { this.key = a, this.options = b, this.contentTypesStoreKey = this.key + "@ContentTypes" } return a.prototype = { getAllData: function (a, b) { var c = this, d = {}; this._getContentTypes(function (g) { e.each(g, function (a) { d[a] = new f.Promise(function (b, d) { c.getData(a, b, d) }) }), f.hash(d).then(a)["catch"](b) }, b) }, getData: function () { throw new c("The method getData is not implemented") }, saveData: function () { throw new c("The method saveData is not implemented") }, purge: function () { throw new c("The method clear is not implemented") }, purgeAll: function () { throw new c("The method clearAll is not implemented") }, _getKey: function (a) { return this.key + "_" + a }, _getContentTypes: function () { throw new c("The method _getContentTypes is not implemented") } }, a }(); b.exports = g }, { "../../EverliveError": 48, "../../common": 59, "../../utils": 102 }], 81: [function (a, b) { "use strict"; var c = a("../../storages/FileStore"), d = a("./BasePersister"), e = (a("../../EverliveError").EverliveError, a("../../common")), f = e._, g = (a("../../everlive.platform"), e.rsvp, a("util")), h = (a("path"), a("../../utils"), function () { function a(a, b) { d.apply(this, arguments), this.fileStore = new c(b.storage.storagePath, b) } return g.inherits(a, d), a.prototype.getAllData = function (b, c) { var d = this._fileSystemErrorHandler(c); a.super_.prototype.getAllData.call(this, b, d) }, a.prototype.getData = function (a, b, c) { var d = this, e = this._fileSystemErrorHandler(c); this.getFileHandle(a, function (a) { d._readFileContent(a, b, e) }, c) }, a.prototype.saveData = function (a, b, c, d) { var e = this, f = this._fileSystemErrorHandler(d); this.getFileHandle(a, function (d) { e._writeFileContent(d, b, function () { e._saveContentTypes(a, c, f) }, f) }, f) }, a.prototype.purge = function (a, b, c) { var d = this, e = this._fileSystemErrorHandler(c); this.getFileHandle(a, function (a) { d.fileStore.removeFile(a).then(function () { b() })["catch"](c) }, e) }, a.prototype.purgeAll = function (a, b) { var c = this._fileSystemErrorHandler(b); this.fileStore.removeFilesDirectory().then(function () { a() })["catch"](c) }, a.prototype._getContentTypes = function (a, b) { this.getData(this.contentTypesStoreKey, function (b) { var c = JSON.parse(b || "[]"); a(c) }, b) }, a.prototype._saveContentTypes = function (a, b, c) { var d = this; this._getContentTypes(function (e) { f.contains(e, a) || e.push(a), d.getFileHandle(d.contentTypesStoreKey, function (a) { d._writeFileContent(a, JSON.stringify(e), b, c) }, c) }) }, a.prototype.getFileHandle = function (a, b, c) { var d = this, e = d._getFilePath(a); this.fileStore.getFilesDirectory().then(function () { return d.fileStore.getFile(e) }).then(function (a) { b(a) })["catch"](c) }, a.prototype._readFileContent = function (a, b, c) { this.fileStore.readFileAsText(a).then(function (a) { b(a) })["catch"](c) }, a.prototype._writeFileContent = function (a, b, c, d) { this.fileStore.writeTextToFile(a, b).then(c)["catch"](d) }, a.prototype._getFilePath = function (a) { return this._getKey(a) }, a.prototype._fileSystemErrorHandler = function (a) { return this.fileStore.getErrorHandler(a) }, a }()); b.exports = h }, { "../../EverliveError": 48, "../../common": 59, "../../everlive.platform": 62, "../../storages/FileStore": 95, "../../utils": 102, "./BasePersister": 80, path: 3, util: 6 }], 82: [function (a, b) { "use strict"; var c = a("../../common"), d = c._, e = (c.rsvp, a("util")), f = a("../../storages/LocalStore"), g = a("./BasePersister"), h = function () { function a(a, b) { g.apply(this, arguments), this._localStore = new f(b) } return e.inherits(a, g), a.prototype.getData = function (a, b, c) { try { var d = this._getKey(a), e = this._getItem(d); b(e) } catch (f) { c(f) } }, a.prototype.saveData = function (a, b, c, d) { try { var e = this._getKey(a); this._setItem(e, b), c() } catch (f) { d(f) } }, a.prototype.purge = function (a, b, c) { var e = this; try { var f = this._getKey(a); this._removeItem(f), this._getContentTypes(function (c) { c = d.without(c, a), e._setContentTypesCollection(c), b() }, c) } catch (g) { c(g) } }, a.prototype.purgeAll = function (a, b) { try { var c = this; this._getContentTypes(function (b) { d.each(b, function (a) { var b = c._getKey(a); c._removeItem(b) }), c._removeItem(c.contentTypesStoreKey), a() }, b) } catch (e) { b(e) } }, a.prototype._getItem = function (a) { return this._localStore.getItem(a) }, a.prototype._setItem = function (a, b) { return this._localStore.setItem(a, b) }, a.prototype._removeItem = function (a) { return this._localStore.removeItem(a) }, a.prototype._getKey = function (b) { return this._addTypeToCollectionsCache(b), a.super_.prototype._getKey.apply(this, arguments) }, a.prototype._getContentTypes = function (a, b) { try { var c = this._getItem(this.contentTypesStoreKey), d = []; c && (d = JSON.parse(c)), a(d) } catch (e) { b(e) } }, a.prototype._setContentTypesCollection = function (a) { this._setItem(this.contentTypesStoreKey, JSON.stringify(a)) }, a.prototype._addTypeToCollectionsCache = function (a) { var b = this; this._getContentTypes(function (c) { d.contains(c, a) || (c.push(a), b._setContentTypesCollection(c)) }) }, a }(); b.exports = h }, { "../../common": 59, "../../storages/LocalStore": 96, "./BasePersister": 80, util: 6 }], 83: [function (a, b) { var c = a("../utils").buildPromise, d = a("../EverliveError").EverliveError, e = a("../constants").Platform, f = a("../common"), g = f.jstz, h = f._, i = a("../utils"); b.exports = function () { var a = function (a) { if (!window.cordova) throw new d("Error: currentDevice() can only be called from within a hybrid mobile app, after 'deviceready' event has been fired."); this._pushHandler = a, this._initSuccessCallback = null, this._initErrorCallback = null, this._globalFunctionSuffix = null, this.pushSettings = null, this.pushToken = null, this.isInitialized = !1, this.isInitializing = !1, this.emulatorMode = !1 }; return a.ensurePushIsAvailable = function () { var a = "undefined" != typeof window && window.plugins && window.plugins.pushNotification; if (!a && !i._inAppBuilderSimulator()) throw new d("The push notification plugin is not available. Ensure that the pushNotification plugin is included and use after `deviceready` event has been fired.") }, a.prototype = { enableNotifications: function (a, b, d) { return this.pushSettings = this._cleanPlatformsPushSettings(a), c(h.bind(this._initialize, this), b, d) }, disableNotifications: function (a, b) { var d = this; return this.unregister().then(function () { return c(function (a, b) { if (d.emulatorMode) a(); else { var c, f = window.plugins.pushNotification, g = d._getPlatformType(); g === e.WindowsPhone && (c = { channelName: d.pushSettings.wp8.channelName }), f.unregister(function () { d.isInitialized = !1, a() }, b, c) } }, a, b) }, b) }, getRegistration: function (a, b) { var c = encodeURIComponent(this._getDeviceId()); return this._pushHandler.devices.getById("HardwareId/" + c, a, b) }, register: function (a, b, c) { var d = this, e = {}; return void 0 !== a && (e.Parameters = a), this._populateRegistrationObject(e).then(function () { return d._pushHandler.devices.create(e, b, c) }, c) }, unregister: function (a, b) { var c = encodeURIComponent(device.uuid); return this._pushHandler.devices.destroySingle({ Id: "HardwareId/" + c }, a, b) }, updateRegistration: function (a, b, c) { var d = this, e = {}; return void 0 !== a && (e.Parameters = a), this._populateRegistrationObject(e).then(function () { return e.Id = "HardwareId/" + encodeURIComponent(e.HardwareId), d._pushHandler.devices.updateSingle(e, b, c) }, c) }, areNotificationsEnabled: function (a, b, d) { a = a || {}; var e = window.plugins.pushNotification; return c(function (b, c) { e.areNotificationsEnabled(b, c, a) }, b, d) }, notificationProcessed: function () { var a = window.plugins.pushNotification; a.notificationProcessed() }, _initializeInteractivePush: function (a, b, c) { var d = window.plugins.pushNotification, e = a.interactiveSettings, f = []; a.alert && f.push(d.UserNotificationTypes.Alert), a.badge && f.push(d.UserNotificationTypes.Badge), a.sound && f.push(d.UserNotificationTypes.Sound); var g = function (a) { var b = h.find(e.actions, function (b) { return b.identifier === a }); return b }, i = h.map(e.categories, function (a) { return { identifier: a.identifier, actionsForDefaultContext: h.map(a.actionsForDefaultContext, g), actionsForMinimalContext: h.map(a.actionsForMinimalContext, g) } }); d.registerUserNotificationSettings(b, c, { types: f, categories: i }) }, _initialize: function (a, b) { var c = this; if (this.isInitializing) return void b(new d("Push notifications are currently initializing.")); if (!(this.emulatorMode || window.navigator && window.navigator.globalization)) return void b(new d("The globalization plugin is not initialized.")); if (!(this.emulatorMode || window.plugins && window.plugins.pushNotification)) return void b(new d("The push notifications plugin is not initialized.")); if (this._initSuccessCallback = a, this._initErrorCallback = b, this.isInitialized) return void this._deviceRegistrationSuccess(this.pushToken); if (this.emulatorMode) return void setTimeout(function () { c._deviceRegistrationSuccess("fake_push_token") }, 1e3); this.isInitializing = !0; var f = this._globalFunctionSuffix; f || (f = Date.now().toString(), this._globalFunctionSuffix = f); var g = window.plugins.pushNotification, i = this._getPlatformType(); if (i === e.iOS) { var j = "apnCallback_" + f; Everlive.PushCallbacks[j] = h.bind(this._onNotificationAPN, this); var k = this.pushSettings.iOS; k.ecb = "Everlive.PushCallbacks." + j, g.register(h.bind(this._successfulRegistrationAPN, this), h.bind(this._failedRegistrationAPN, this), k) } else if (i === e.Android) { var l = "gcmCallback_" + f; Everlive.PushCallbacks[l] = h.bind(this._onNotificationGCM, this); var m = this.pushSettings.android; this._validateAndroidSettings(m), m.ecb = "Everlive.PushCallbacks." + l, g.register(h.bind(this._successSentRegistrationGCM, this), h.bind(this._errorSentRegistrationGCM, this), m) } else { if (i !== e.WindowsPhone) throw new d("The current platform is not supported: " + device.platform); var n = "wp8Callback_" + f, o = "wp8RegistrationSuccessCallback_" + f, p = "wp8RegistrationErrorCallback_" + f; Everlive.PushCallbacks[n] = h.bind(this._onNotificationWP8, this), Everlive.PushCallbacks[o] = h.bind(this._deviceRegistrationSuccessWP, this), Everlive.PushCallbacks[p] = h.bind(this._deviceRegistrationFailed, this); var q = this.pushSettings.wp8; this._validateWP8Settings(q), q.ecb = "Everlive.PushCallbacks." + n, q.uccb = "Everlive.PushCallbacks." + o, q.errcb = "Everlive.PushCallbacks." + p, g.register(h.bind(this._successSentRegistrationWP8, this), h.bind(this._errorSentRegistrationWP8, this), q) } }, _deviceRegistrationSuccessWP: function (a) { this._deviceRegistrationSuccess(a.uri) }, _validateAndroidSettings: function (a) { if (!a.senderID) throw new d("Sender ID (project number) is not set in the android settings.") }, _validateWP8Settings: function (a) { if (!a.channelName) throw new d("channelName is not set in the WP8 settings.") }, _cleanPlatformsPushSettings: function (a) { var b = {}; a = a || {}; var c = function (b, c, d) { if (a[c]) { b[c] = b[c] || {}; var e = a[c], f = b[c]; h.each(d, function (a) { e.hasOwnProperty(a) && (f[a] = e[a]) }) } }; c(b, "iOS", ["badge", "sound", "alert", "interactiveSettings"]), c(b, "android", ["senderID", "projectNumber"]), c(b, "wp8", ["channelName"]); var e = ["notificationCallbackAndroid", "notificationCallbackIOS", "notificationCallbackWP8"]; return h.each(e, function (c) { var e = a[c]; if (e) { if ("function" != typeof e) throw new d('The "' + c + '" of the push settings should be a function'); b[c] = a[c] } }), a.customParameters && (b.customParameters = a.customParameters), b }, _populateRegistrationObject: function (a, b, e) { var f = this; return c(function (b, c) { if (!f.pushToken) throw new d("Push token is not available."); f._getLocaleName(function (c) { var d = f._getDeviceId(), e = device.model, h = f._getPlatformType(), i = g.determine().name(), j = f.pushToken, k = c.value, l = device.version; a.HardwareId = d, a.HardwareModel = e, a.PlatformType = h, a.PlatformVersion = l, a.TimeZone = i, a.PushToken = j, a.Locale = k, b() }, c) }, b, e) }, _getLocaleName: function (a, b) { this.emulatorMode ? a({ value: "en_US" }) : (navigator.globalization.getLocaleName(function (b) { a(b) }, b), navigator.globalization.getLocaleName(function () { }, b)) }, _getDeviceId: function () { return device.uuid }, _getPlatformType: function () { var a = device.platform.toLowerCase(); switch (a) { case "ios": case "iphone": case "ipad": return e.iOS; case "android": return e.Android; case "wince": return e.WindowsPhone; case "win32nt": return e.WindowsPhone; default: return e.Unknown } }, _deviceRegistrationFailed: function (a) { this.pushToken = null, this.isInitializing = !1, this.isInitialized = !1, this._initErrorCallback && this._initErrorCallback({ error: a }) }, _deviceRegistrationSuccess: function (a) { this.pushToken = a, this.isInitializing = !1, this.isInitialized = !0, this._initSuccessCallback && this._initSuccessCallback({ token: a }) }, _successfulRegistrationAPN: function (a) { var b = this; this.pushSettings.iOS && this.pushSettings.iOS.interactiveSettings ? this._initializeInteractivePush(this.pushSettings.iOS, function () { b._deviceRegistrationSuccess(a) }, function (a) { throw new d("The interactive push configuration is incorrect: " + a) }) : this._deviceRegistrationSuccess(a) }, _failedRegistrationAPN: function (a) { this._deviceRegistrationFailed(a) }, _successSentRegistrationGCM: function () { }, _successSentRegistrationWP8: function () { }, _errorSentRegistrationWP8: function (a) { this._deviceRegistrationFailed(a) }, _errorSentRegistrationGCM: function (a) { this._deviceRegistrationFailed(a) }, _onNotificationAPN: function (a) { this._raiseNotificationEventIOS(a) }, _onNotificationWP8: function (a) { this._raiseNotificationEventWP8(a) }, _onNotificationGCM: function (a) { switch (a.event) { case "registered": a.regid.length > 0 && this._deviceRegistrationSuccess(a.regid); break; case "message": this._raiseNotificationEventAndroid(a); break; case "error": this.pushToken ? this._raiseNotificationEventAndroid(a) : this._deviceRegistrationFailed(a); break; default: this._raiseNotificationEventAndroid(a) } }, _raiseNotificationEventAndroid: function (a) { this.pushSettings.notificationCallbackAndroid && this.pushSettings.notificationCallbackAndroid(a) }, _raiseNotificationEventIOS: function (a) { this.pushSettings.notificationCallbackIOS && this.pushSettings.notificationCallbackIOS(a) }, _raiseNotificationEventWP8: function (a) { this.pushSettings.notificationCallbackWP8 && this.pushSettings.notificationCallbackWP8(a) } }, a }() }, { "../EverliveError": 48, "../common": 59, "../constants": 60, "../utils": 102 }], 84: [function (a, b) { var c = a("../everlive.platform"), d = a("../common")._; if (c.isNativeScript) { var e = a("./NativeScriptCurrentDevice"); b.exports = e } else if (c.isCordova || c.isDesktop) { var f = a("./CordovaCurrentDevice"); b.exports = f } else b.exports = d.noop }, { "../common": 59, "../everlive.platform": 62, "./CordovaCurrentDevice": 83, "./NativeScriptCurrentDevice": 85 }], 85: [function (a, b) {
var c = a("../utils").buildPromise, d = a("../EverliveError").EverliveError, e = a("../constants").Platform, f = a("../common"), g = a("../utils"), h = f.jstz, i = f._, j = g.lazyRequire("nativescript-push-notifications", "tnsPushPlugin"), k = a("platform"); b.exports = function () {
var a = function (a) {
this._pushHandler = a, this._initSuccessCallback = null, this._initErrorCallback = null, this._globalFunctionSuffix = null, this.pushSettings = null, this.pushToken = null, this.isInitialized = !1, this.isInitializing = !1,
this.emulatorMode = !1
}; return a.ensurePushIsAvailable = function () { }, a.prototype = { enableNotifications: function (a, b, d) { return this.pushSettings = this._cleanPlatformsPushSettings(a), c(i.bind(this._initialize, this), b, d) }, disableNotifications: function (a, b) { var d = this; return this.unregister().then(function () { return c(function (a, b) { var c = function () { d.isInitialized = !1, a() }, f = d._getPlatformType(); return f === e.Android ? j.tnsPushPlugin.unregister(c, b, d.pushSettings.android) : void j.tnsPushPlugin.unregister(c, b) }, a, b) }, b) }, getRegistration: function (a, b) { var c = encodeURIComponent(this._getDeviceId()); return this._pushHandler.devices.getById("HardwareId/" + c, a, b) }, register: function (a, b, c) { var d = this, e = {}; return void 0 !== a && (e.Parameters = a), this._populateRegistrationObject(e).then(function () { return d._pushHandler.devices.create(e, b, c) }, c) }, unregister: function (a, b) { var c = encodeURIComponent(this._getDeviceId()); return this._pushHandler.devices.destroySingle({ Id: "HardwareId/" + c }, a, b) }, updateRegistration: function (a, b, c) { var d = this, e = {}; return void 0 !== a && (e.Parameters = a), this._populateRegistrationObject(e).then(function () { return e.Id = "HardwareId/" + encodeURIComponent(e.HardwareId), d._pushHandler.devices.updateSingle(e, b, c) }, c) }, areNotificationsEnabled: function (a, b, d) { return a = a || {}, c(function (b, c) { j.tnsPushPlugin.areNotificationsEnabled(b, c, a) }, b, d) }, _initializeInteractivePush: function (a, b, c) { j.tnsPushPlugin.registerUserNotificationSettings(b, c) }, _initialize: function (a, b) { if (this.isInitializing) return void b(new d("Push notifications are currently initializing.")); if (this._initSuccessCallback = a, this._initErrorCallback = b, this.isInitialized) return void this._deviceRegistrationSuccess(this.pushToken); this.isInitializing = !0; var c = this._globalFunctionSuffix; c || (c = Date.now().toString(), this._globalFunctionSuffix = c); var f = this._getPlatformType(); if (f === e.iOS) { var g = this.pushSettings.iOS; g.notificationCallbackIOS = this.pushSettings.notificationCallbackIOS, j.tnsPushPlugin.register(g, i.bind(this._successfulRegistrationAPN, this), i.bind(this._failedRegistrationAPN, this)) } else { if (f !== e.Android) throw new d("The current platform is not supported: " + k.device.os); var h = this.pushSettings.android; this._validateAndroidSettings(h), h.notificationCallbackAndroid = this.pushSettings.notificationCallbackAndroid, j.tnsPushPlugin.register(h, i.bind(this._successSentRegistrationGCM, this), i.bind(this._errorSentRegistrationGCM, this)) } }, _validateAndroidSettings: function (a) { if (!a.senderID) throw new d("Sender ID (project number) is not set in the android settings.") }, _cleanPlatformsPushSettings: function (a) { var b = {}; a = a || {}; var c = function (b, c, d) { if (a[c]) { b[c] = b[c] || {}; var e = a[c], f = b[c]; i.each(d, function (a) { e.hasOwnProperty(a) && (f[a] = e[a]) }) } }; c(b, "iOS", ["badge", "sound", "alert", "interactiveSettings"]), c(b, "android", ["senderID", "projectNumber"]); var e = ["notificationCallbackAndroid", "notificationCallbackIOS"]; return i.each(e, function (c) { var e = a[c]; if (e) { if ("function" != typeof e) throw new d('The "' + c + '" of the push settings should be a function'); b[c] = a[c] } }), a.customParameters && (b.customParameters = a.customParameters), b }, _populateRegistrationObject: function (a, b, e) { var f = this; return c(function (b, c) { if (!f.pushToken) throw new d("Push token is not available."); f._getLocaleName(function () { var c = f._getDeviceId(), d = k.device.model, e = f._getPlatformType(), g = h.determine().name(), i = f.pushToken, j = "en_US", l = k.device.osVersion; a.HardwareId = c, a.HardwareModel = d, a.PlatformType = e, a.PlatformVersion = l, a.TimeZone = g, a.PushToken = i, a.Locale = j, b() }, c) }, b, e) }, _getLocaleName: function (a) { return a() }, _getDeviceId: function () { return k.device.uuid }, _getPlatformType: function () { var a = k.device.os.toLowerCase(); switch (a) { case "ios": case "iphone": case "ipad": return e.iOS; case "android": return e.Android; default: return e.Unknown } }, _deviceRegistrationFailed: function (a) { this.pushToken = null, this.isInitializing = !1, this.isInitialized = !1, this._initErrorCallback && this._initErrorCallback({ error: a }) }, _deviceRegistrationSuccess: function (a) { this.pushToken = a, this.isInitializing = !1, this.isInitialized = !0, this._initSuccessCallback && this._initSuccessCallback({ token: a }) }, _successfulRegistrationAPN: function (a) { var b = this; this.pushSettings.iOS && this.pushSettings.iOS.interactiveSettings ? this._initializeInteractivePush(this.pushSettings.iOS, function () { b._deviceRegistrationSuccess(a) }, function (a) { throw new d("The interactive push configuration is incorrect: " + a) }) : this._deviceRegistrationSuccess(a) }, _failedRegistrationAPN: function (a) { this._deviceRegistrationFailed(a) }, _successSentRegistrationGCM: function (a) { j.tnsPushPlugin.onMessageReceived(this.pushSettings.notificationCallbackAndroid), this._deviceRegistrationSuccess(a) }, _errorSentRegistrationGCM: function (a) { this._deviceRegistrationFailed(a) }, notificationProcessed: function () { throw new Error("Not implemented") }, _onNotificationAPN: function (a) { this._raiseNotificationEventIOS(a) }, _onNotificationGCM: function (a) { switch (a.event) { case "registered": a.regid.length > 0 && this._deviceRegistrationSuccess(a.regid); break; case "message": this._raiseNotificationEventAndroid(a); break; case "error": this.pushToken ? this._raiseNotificationEventAndroid(a) : this._deviceRegistrationFailed(a); break; default: this._raiseNotificationEventAndroid(a) } }, _raiseNotificationEventAndroid: function (a) { this.pushSettings.notificationCallbackAndroid && this.pushSettings.notificationCallbackAndroid(a) }, _raiseNotificationEventIOS: function (a) { this.pushSettings.notificationCallbackIOS && this.pushSettings.notificationCallbackIOS(a) } }, a
}()
}, { "../EverliveError": 48, "../common": 59, "../constants": 60, "../utils": 102, platform: "platform" }], 86: [function (a, b) { var c = a("../common")._, d = a("./Query"), e = a("util"), f = a("../EverliveError").EverliveError, g = function () { d.apply(this, arguments), this.aggregateExpression = { GroupBy: [], Aggregate: {} }; var a, b, c = arguments[6]; c && (a = c.GroupBy, b = c.Aggregate), this.aggregateExpression = { GroupBy: a || [], Aggregate: b || {} } }; e.inherits(g, d), g.prototype._aggregateFunc = function (a, b, c) { if ("string" != typeof b && "count" !== a) throw new f(a + "() accepts only string as parameter."); var d = {}; return d[a] = b, this.aggregateExpression.Aggregate[c || b] = d, this }, g.prototype.groupBy = function (a) { if (c.isArray(a)) Array.prototype.push.apply(this.aggregateExpression.GroupBy, a); else { if ("string" != typeof a) throw new f("groupBy() accepts only array or string as parameter."); this.aggregateExpression.GroupBy.push(a) } return this }, g.prototype.avg = function () { return Array.prototype.unshift.call(arguments, "avg"), this._aggregateFunc.apply(this, arguments) }, g.prototype.count = function (a) { return this._aggregateFunc("count", null, a || "Count") }, g.prototype.max = function () { return Array.prototype.unshift.call(arguments, "max"), this._aggregateFunc.apply(this, arguments) }, g.prototype.min = function () { return Array.prototype.unshift.call(arguments, "min"), this._aggregateFunc.apply(this, arguments) }, g.prototype.sum = function () { return Array.prototype.unshift.call(arguments, "sum"), this._aggregateFunc.apply(this, arguments) }, g.prototype.select = function () { throw new f("select() is not supported for aggregations.") }, g.prototype.skip = function () { throw new f("skip() is not supported for aggregations.") }, g.prototype.take = function () { throw new f("take() is not supported for aggregations.") }, g.prototype.order = function () { throw new f("order() is not supported for aggregations.") }, g.prototype.average = g.prototype.avg, b.exports = g }, { "../EverliveError": 48, "../common": 59, "./Query": 89, util: 6 }], 87: [function (a, b) { var c = a("../common")._, d = a("../constants"), e = a("../query/Query"), f = d.Headers, g = a("../utils"); b.exports = function () { var a = function (a) { this.collectionName = a.collectionName, this.headers = a.headers || {}, this.query = a.query, this.onSuccess = a.onSuccess, this.onError = a.onError, this.operation = a.operation, this.parse = a.parse, this.additionalOptions = a.additionalOptions, this.data = a.data, this.useOffline = a.useOffline, this.applyOffline = a.applyOffline, this.noRetry = a.noRetry, this.skipAuth = a.skipAuth, this._normalizedHeaders = null, this.isSync = a.isSync, a.query || !a.filter || c.isEmpty(a.filter) || (this.query = a.filter instanceof e ? a.filter : new e(a.filter)) }; return a.prototype = { _normalizeHeaders: function () { this._normalizedHeaders = g.normalizeKeys(this.headers) }, getHeader: function (a) { this._normalizeHeaders(); var b = a.toLowerCase(); return this._normalizedHeaders[b] }, getHeaderAsJSON: function (a) { this._normalizeHeaders(); var b; if (a && (b = this._normalizedHeaders[a.toLowerCase()]), c.isObject(b)) return b; if (!c.isString(b)) return b; try { return JSON.parse(b) } catch (d) { return b } }, getHeaders: function () { this._normalizeHeaders(); var a = c.deepExtend(this._normalizedHeaders); return a }, getQueryParameters: function () { var b = {}; if (this.operation === a.operations.ReadById) b.filter = this.additionalOptions.id, b.expand = this.getHeaderAsJSON(f.expand); else { var c = this.getHeaderAsJSON(f.sort), d = this.getHeaderAsJSON(f.take), g = this.getHeaderAsJSON(f.skip), h = this.getHeaderAsJSON(f.select), i = this.getHeaderAsJSON(f.filter), j = this.getHeaderAsJSON(f.expand), k = this.getHeaderAsJSON(f.aggregate); if (this.query instanceof e) { var l = this.query.build(); b.filter = l.$where || i || {}, b.sort = l.$sort || c, b.limit = l.$take || d, b.skip = l.$skip || g, b.select = l.$select || h, b.expand = l.$expand || j, b.aggregate = l.$aggregate || k } else b.filter = this.filter || i || {}, b.sort = c, b.limit = d, b.skip = g, b.select = h, b.expand = j, b.aggregate = k } return b }, applyEventQuery: function (a) { this._applyCustomHeaders(a), this._applyEventQueryHeaders(a), this._applyEventQueryParams(a), this.additionalOptions = this.additionalOptions || {}, this.additionalOptions.id = a.itemId, this.data = a.data, this._applyEventQuerySettings(a) }, _applyCustomHeaders: function (a) { this.headers = a.headers, this._normalizeHeaders() }, _applyEventQueryHeaders: function (a) { this._applyEventHeader(f.filter, a.filter), this._applyEventHeader(f.select, a.fields), this._applyEventHeader(f.sort, a.sort), this._applyEventHeader(f.skip, a.skip), this._applyEventHeader(f.take, a.take), this._applyEventHeader(f.expand, a.expand), this._applyEventHeader(f.aggregate, a.aggregate), this._applyEventHeader(f.powerFields, a.powerfields) }, _applyEventQueryParams: function (a) { a.filter && !this.query && (this.query = {}), this.query.filter = a.filter, this.fields = a.select, this.sort = a.sort, this.skip = a.skip, this.take = a.take, this.expand = a.expand, this.aggregate = a.aggregate }, _applyEventQuerySettings: function (a) { this.useOffline = a.settings.useOffline, this.forceCache = a.settings.forceCache, this.ignoreCache = a.settings.ignoreCache, this.applyOffline = a.settings.applyOffline }, _applyEventHeader: function (a, b) { if (b && "string" != typeof b) { var c = a.toLowerCase(); this.headers[c] = JSON.stringify(b) } } }, a.operations = d.DataQueryOperations, a }() }, { "../common": 59, "../constants": 60, "../query/Query": 89, "../utils": 102 }], 88: [function (a, b) { "use strict"; function c(a, b) { var c = b.getQueryParameters(); return a.filter = c.filter, a.fields = c.select, a.sort = c.sort, a.skip = c.skip, a.take = c.limit || c.take, a.expand = c.expand, a.aggregate = c.aggregate, c } function d(a, b) { a.settings = { useOffline: b.useOffline, applyOffline: b.applyOffline, ignoreCache: b.ignoreCache, forceCache: b.forceCache } } var e = a("../constants"), f = function () { }; f.fromDataQuery = function (a) { var b = new f; if (b.contentTypeName = a.collectionName, a.additionalOptions && a.additionalOptions.id) switch (a.operation) { case e.DataQueryOperations.Update: b.operation = e.DataQueryOperations.UpdateById; break; case e.DataQueryOperations.Delete: b.operation = e.DataQueryOperations.DeleteById; break; default: b.operation = a.operation } else b.operation = a.operation; b.itemId = a.additionalOptions ? a.additionalOptions.id : void 0, b.data = a.data, d(b, a), c(b, a), b.headers = a.getHeaders(); var g = b.headers[e.Headers.powerFields]; return "string" == typeof g && (b.powerfields = JSON.parse(g)), b.isSync = a.isSync, b }, f.prototype = { cancel: function () { this._cancelled = !0 }, isCancelled: function () { return this._cancelled } }, b.exports = f }, { "../constants": 60 }], 89: [function (a, b) { var c = a("../Expression"), d = a("../constants").OperatorType, e = a("./WhereQuery"), f = a("./QueryBuilder"); b.exports = function () { function a(a, b, e, f, g, h) { this.filter = a, this.fields = b, this.sort = e, this.toskip = f, this.totake = g, this.expandExpression = h, this.expr = new c(d.query) } return a.prototype = { where: function (a) { return a ? this._simple(d.filter, [a]) : new e(this) }, select: function () { return this._simple(d.select, arguments) }, order: function (a) { return this._simple(d.order, [a]) }, orderDesc: function (a) { return this._simple(d.order_desc, [a]) }, skip: function (a) { return this._simple(d.skip, [a]) }, take: function (a) { return this._simple(d.take, [a]) }, expand: function (a) { return this._simple(d.expand, [a]) }, build: function () { return new f(this).build() }, _simple: function (a, b) { var d = [].slice.call(b); return this.expr.addOperand(new c(a, d)), this } }, a }() }, { "../Expression": 50, "../constants": 60, "./QueryBuilder": 90, "./WhereQuery": 92 }], 90: [function (a, b) { var c = a("../constants"), d = c.OperatorType, e = a("../common")._, f = a("../GeoPoint"), g = a("../EverliveError").EverliveError, h = a("../Expression"), i = c.maxDistanceConsts, j = c.radiusConsts; b.exports = function () { function a(a) { this.query = a, this.expr = a.expr } return a.prototype = { build: function () { var a = this.query; return a.filter || a.fields || a.sort || a.toskip || a.totake || a.expandExpression ? { $where: a.filter || null, $select: a.fields || null, $sort: a.sort || null, $skip: a.toskip || null, $take: a.totake || null, $expand: a.expandExpression || null, $aggregate: a.aggregateExpression || null } : { $where: this._buildWhere(), $select: this._buildSelect(), $sort: this._buildSort(), $skip: this._getSkip(), $take: this._getTake(), $expand: this._getExpand(), $aggregate: this._getAggregate() } }, _getSkip: function () { var a = e.find(this.expr.operands, function (a) { return a.operator === d.skip }); return a ? a.operands[0] : null }, _getTake: function () { var a = e.find(this.expr.operands, function (a) { return a.operator === d.take }); return a ? a.operands[0] : null }, _getExpand: function () { var a = e.chain(this.expr.operands).filter(function (a) { return a.operator === d.expand }).reduce(function (a, b) { return e.extend(a, b.operands[0]) }, {}).value(); return e.isEmpty(a) ? null : a }, _getAggregate: function () { if (!this.query.aggregateExpression) return null; var a = e.extend({}, this.query.aggregateExpression); return e.isEmpty(a.GroupBy) && delete a.GroupBy, e.isEmpty(a.Aggregate) && delete a.Aggregate, a }, _buildSelect: function () { var a = e.find(this.expr.operands, function (a) { return a.operator === d.select }), b = {}; return a ? (e.reduce(a.operands, function (a, b) { return a[b] = 1, a }, b), b) : null }, _buildSort: function () { var a = e.filter(this.expr.operands, function (a) { return a.operator === d.order || a.operator === d.order_desc }), b = {}; return a.length > 0 ? (e.reduce(a, function (a, b) { return a[b.operands[0]] = b.operator === d.order ? 1 : -1, a }, b), b) : null }, _buildWhere: function () { var a = e.find(this.expr.operands, function (a) { return a.operator === d.where }); if (a) return this._build(new h(d.and, a.operands)); var b = e.find(this.expr.operands, function (a) { return a.operator === d.filter }); return b ? b.operands[0] : null }, _build: function (a) { return this._isSimple(a) ? this._simple(a) : this._isRegex(a) ? this._regex(a) : this._isGeo(a) ? this._geo(a) : this._isAnd(a) ? this._and(a) : this._isOr(a) ? this._or(a) : this._isNot(a) ? this._not(a) : void 0 }, _isSimple: function (a) { return a.operator >= d.equal && a.operator <= d.size }, _simple: function (a) { var b = {}, c = {}, d = a.operands, e = this._translateoperator(a.operator); return e ? b[e] = d[1] : b = d[1], c[d[0]] = b, c }, _isRegex: function (a) { return a.operator >= d.regex && a.operator <= d.endsWith }, _regex: function (a) { var b = {}, c = this._getRegex(a), d = this._getRegexValue(c), e = a.operands; return b[e[0]] = d, b }, _getRegex: function (a) { var b = a.operands[1], c = a.operands[2] ? a.operands[2] : ""; switch (a.operator) { case d.regex: return b instanceof RegExp ? b : new RegExp(b, c); case d.startsWith: return new RegExp("^" + b, c); case d.endsWith: return new RegExp(b + "$", c); default: throw new g("Unknown operator type.") } }, _getRegexValue: function (a) { var b = ""; return a.global && (b += "g"), a.multiline && (b += "m"), a.ignoreCase && (b += "i"), { $regex: a.source, $options: b } }, _isGeo: function (a) { return a.operator >= d.nearShpere && a.operator <= d.withinShpere }, _geo: function (a) { var b = {}, c = a.operands; return b[c[0]] = this._getGeoTerm(a), b }, _getGeoTerm: function (a) { switch (a.operator) { case d.nearShpere: return this._getNearSphereTerm(a); case d.withinBox: return this._getWithinBox(a); case d.withinPolygon: return this._getWithinPolygon(a); case d.withinShpere: return this._getWithinCenterSphere(a); default: throw new g("Unknown operator type.") } }, _getNearSphereTerm: function (a) { var b, c = a.operands, d = this._getGeoPoint(c[1]), e = c[2], f = c[3], g = { $nearSphere: d }; return "undefined" != typeof e && (b = i[f] || i.radians, g[b] = e), g }, _getWithinBox: function (a) { var b = a.operands, c = this._getGeoPoint(b[1]), d = this._getGeoPoint(b[2]); return { $within: { $box: [c, d] } } }, _getWithinPolygon: function (a) { var b = a.operands, c = this._getGeoPoints(b[1]); return { $within: { $polygon: c } } }, _getWithinCenterSphere: function (a) { var b = a.operands, c = this._getGeoPoint(b[1]), d = b[2], e = b[3], f = j[e] || j.radians, g = { center: c }; return g[f] = d, { $within: { $centerSphere: g } } }, _getGeoPoint: function (a) { return e.isArray(a) ? new f(a[0], a[1]) : a }, _getGeoPoints: function (a) { var b = this; return e.map(a, function (a) { return b._getGeoPoint(a) }) }, _isAnd: function (a) { return a.operator === d.and }, _and: function (a) { var b, c, d, e = {}, f = a.operands; for (b = 0, c = f.length; c > b; b++) d = this._build(f[b]), e = this._andAppend(e, d); return e }, _andAppend: function (a, b) { var c, d, f, g, h, i = e.keys(b); for (c = 0, d = i.length; d > c; c++) f = i[c], g = a[f], "undefined" == typeof g ? a[f] = b[f] : (h = b[f], g = "object" == typeof g && "object" == typeof h ? e.extend(g, h) : h, a[f] = g); return a }, _isOr: function (a) { return a.operator === d.or }, _or: function (a) { var b, c, d, e = [], f = a.operands; for (b = 0, c = f.length; c > b; b++) d = this._build(f[b]), e.push(d); return { $or: e } }, _isNot: function (a) { return a.operator === d.not }, _not: function (a) { return { $not: this._build(a.operands[0]) } }, _translateoperator: function (a) { switch (a) { case d.equal: return null; case d.not_equal: return "$ne"; case d.gt: return "$gt"; case d.lt: return "$lt"; case d.gte: return "$gte"; case d.lte: return "$lte"; case d.isin: return "$in"; case d.notin: return "$nin"; case d.all: return "$all"; case d.size: return "$size" } throw new g("Unknown operator type.") } }, a }() }, { "../EverliveError": 48, "../Expression": 50, "../GeoPoint": 51, "../common": 59, "../constants": 60 }], 91: [function (a, b) { var c = a("./DataQuery"), d = a("../Request"), e = a("../common")._, f = a("../constants"); b.exports = function () { var a = {}; return a._buildEndpointUrl = function (a) { var b = a.collectionName; return a.additionalOptions && a.additionalOptions.id && (b += "/" + a.additionalOptions.id), b }, a._buildBaseObject = function (b) { var c = { endpoint: a._buildEndpointUrl(b), query: b.query, success: b.onSuccess, error: b.onError, data: b.data, headers: b.headers }; return b.parse && (c.parse = b.parse), c }, a._build = function (b, c) { return e.extend(a._buildBaseObject(b), c) }, a[c.operations.Read] = function (b) { return a._build(b, { method: "GET" }) }, a[c.operations.ReadById] = function (b) { return a._build(b, { method: "GET" }) }, a[c.operations.Count] = function (b) { return a._build(b, { method: "GET", endpoint: b.collectionName + "/_count" }) }, a[c.operations.Create] = function (b) { return a._build(b, { method: "POST" }) }, a[c.operations.RawUpdate] = function (b) { var c = b.collectionName, d = b.query, e = null; return "string" == typeof d ? c += "/" + d : "object" == typeof d && (e = d), a._build(b, { method: "PUT", endpoint: c, query: e }) }, a[c.operations.Update] = function (b) { return a._build(b, { method: "PUT" }) }, a[c.operations.Delete] = function (b) { return e.extend(a._buildBaseObject(b), { method: "DELETE" }) }, a[c.operations.DeleteById] = a[c.operations.Delete], a[c.operations.SetAcl] = function (b) { var c = b.collectionName, d = b.query; "string" == typeof d ? c += "/" + d : "object" == typeof d && (c += "/" + d[f.idField]), c += "/_acl"; var e, g; return null === b.additionalOptions.acl ? e = "DELETE" : (e = "PUT", g = b.additionalOptions.acl), a._build(b, { method: e, endpoint: c, data: g }) }, a[c.operations.SetOwner] = function (b) { var c = b.collectionName, d = b.query; return "string" == typeof d ? c += "/" + d : "object" == typeof d && (c += "/" + d[f.idField]), c += "/_owner", a._build(b, { method: "PUT", endpoint: c }) }, a[c.operations.UserLogin] = function (b) { return a._build(b, { method: "POST", endpoint: "oauth/token", authHeaders: !1, parse: d.parsers.single }) }, a[c.operations.UserLogout] = function (b) { return a._build(b, { method: "GET", endpoint: "oauth/logout" }) }, a[c.operations.UserChangePassword] = function (b) { var c = b.additionalOptions.keepTokens, e = "Users/changepassword"; return c && (e += "?keepTokens=true"), a._build(b, { method: "POST", endpoint: e, authHeaders: !1, parse: d.parsers.single }) }, a[c.operations.UserLoginWithProvider] = function (b) { return a._build(b, { method: "POST", authHeaders: !1 }) }, a[c.operations.UserLinkWithProvider] = function (b) { return a._build(b, { method: "POST", endpoint: a._buildEndpointUrl(b) + "/link" }) }, a[c.operations.UserUnlinkFromProvider] = function (b) { return a._build(b, { method: "POST", endpoint: a._buildEndpointUrl(b) + "/unlink" }) }, a[c.operations.UserResetPassword] = function (b) { return a._build(b, { method: "POST", endpoint: a._buildEndpointUrl(b) + "/resetpassword" }) }, a[c.operations.UserSetPassword] = function (b) { return a._build(b, { method: "POST", endpoint: a._buildEndpointUrl(b) + "/setpassword" }) }, a[c.operations.FilesUpdateContent] = function (b) { return a._build(b, { method: "PUT", endpoint: a._buildEndpointUrl(b) + "/Content" }) }, a[c.operations.FilesGetDownloadUrlById] = function (b) { return a._build(b, { method: "GET" }) }, a[c.operations.Aggregate] = function (b) { return a._build(b, { method: "GET", endpoint: b.collectionName + "/_aggregate" }) }, a }() }, { "../Request": 53, "../common": 59, "../constants": 60, "./DataQuery": 87 }], 92: [function (a, b) { var c = a("../Expression"), d = a("../constants").OperatorType; b.exports = function () { function a(a, b, e) { this.parent = a, this.single = e, this.expr = new c(b || d.where), this.parent.expr.addOperand(this.expr) } return a.prototype = { and: function () { return new a(this, d.and) }, or: function () { return new a(this, d.or) }, not: function () { return new a(this, d.not, !0) }, _simple: function (a) { var b = [].slice.call(arguments, 1); return this.expr.addOperand(new c(a, b)), this._done() }, eq: function (a, b) { return this._simple(d.equal, a, b) }, ne: function (a, b) { return this._simple(d.not_equal, a, b) }, gt: function (a, b) { return this._simple(d.gt, a, b) }, gte: function (a, b) { return this._simple(d.gte, a, b) }, lt: function (a, b) { return this._simple(d.lt, a, b) }, lte: function (a, b) { return this._simple(d.lte, a, b) }, isin: function (a, b) { return this._simple(d.isin, a, b) }, notin: function (a, b) { return this._simple(d.notin, a, b) }, all: function (a, b) { return this._simple(d.all, a, b) }, size: function (a, b) { return this._simple(d.size, a, b) }, regex: function (a, b, c) { return this._simple(d.regex, a, b, c) }, startsWith: function (a, b, c) { return this._simple(d.startsWith, a, b, c) }, endsWith: function (a, b, c) { return this._simple(d.endsWith, a, b, c) }, nearSphere: function (a, b, c, e) { return this._simple(d.nearShpere, a, b, c, e) }, withinBox: function (a, b, c) { return this._simple(d.withinBox, a, b, c) }, withinPolygon: function (a, b) { return this._simple(d.withinPolygon, a, b) }, withinCenterSphere: function (a, b, c, e) { return this._simple(d.withinShpere, a, b, c, e) }, done: function () { return this.parent instanceof a ? this.parent._done() : this.parent }, _done: function () { return this.single ? this.parent : this } }, a.prototype.equal = a.prototype.eq, a.prototype.notEqual = a.prototype.ne, a.prototype.greaterThan = a.prototype.gt, a.prototype.greaterThanEqual = a.prototype.gte, a.prototype.lessThan = a.prototype.lt, a.prototype.lessThanEqual = a.prototype.lte, a }() }, { "../Expression": 50, "../constants": 60 }], 93: [function (a, b) { var c = a("http"); b.exports = function () { "use strict"; function a(a) { var b = { url: a.url, method: a.method, headers: a.headers || {} }; a.data && (b.content = a.data), b.headers.Accept = "application/json", b.headers["Content-Type"] = "application/json"; var d = function () { }, e = a.success || d, f = a.error || d, g = function (a) { var b = a.content.toString(); a.statusCode < 400 ? e(b) : f({ responseText: b }) }, h = function (a) { f({ responseText: a }) }; c.request(b).then(g, h) } return a }() }, { http: "http" }], 94: [function (a, b) { (function (c) { var d = a("url"), e = a("http"), f = a("https"), g = (a("rsvp"), a("zlib")), h = a("underscore"); b.exports = function () { "use strict"; function a(a) { var b, i = d.parse(a.url); b = "https:" === i.protocol ? f.request : e.request; var j = a.headers || {}; a.success = a.success || h.noop, a.error = a.error || h.noop, j["Content-Type"] = a.contentType; var k = b({ method: a.method, hostname: i.hostname, port: i.port, path: i.path, headers: j }, function (b) { var c, d = "", e = b.headers["content-encoding"]; switch (e) { case "gzip": c = g.createGunzip(), b.pipe(c); break; default: c = b, c.setEncoding("utf8") } c.on("data", function (a) { d += a.toString() }), c.on("end", function () { if (b.statusCode >= 200 && b.statusCode < 400) a.success(d, b); else if (d) a.error({ responseText: d }); else { var c = new Error("Response error."); c.statusCode = b.statusCode, a.error({ responseText: c }) } }) }); if (k.on("error", function (b) { a.error({ responseText: b }) }), a.data) { var l = j["content-encoding"]; switch (l) { case "gzip": var m = new c(a.data, "utf-8"); g.gzip(m, function (a, b) { k.end(b) }); break; default: k.end(a.data) } } else k.end() } return a }() }).call(this, a("buffer").Buffer) }, { buffer: "buffer", http: "http", https: "https", rsvp: 34, underscore: 35, url: "url", zlib: "zlib" }], 95: [function (a, b) { var c = a("../everlive.platform"), d = a("./WebFileStore"), e = a("./NativeScriptFileStore"), f = a("../common")._; b.exports = c.isNativeScript ? e : c.isCordova || c.isDesktop ? d : f.noop }, { "../common": 59, "../everlive.platform": 62, "./NativeScriptFileStore": 97, "./WebFileStore": 98 }], 96: [function (a, b) { { var c = a("./../everlive.platform.js"), d = c.isNativeScript, e = c.isNodejs; a("./../constants") } b.exports = function () { "use strict"; function b(b) { if (d) { var c; try { c = a("application-settings") } catch (f) { c = a("local-settings") } return { getItem: function (a) { return c.getString(a) }, removeItem: function (a) { return c.remove(a) }, setItem: function (a, b) { return c.setString(a, b) } } } var g; if (e) { var h = a("node-localstorage").LocalStorage; g = new h(b.storage.storagePath) } else g = window.localStorage; return { getItem: function (a) { return g.getItem(a) }, removeItem: function (a) { return g.removeItem(a) }, setItem: function (a, b) { return g.setItem(a, b) } } } function c(a) { this.options = a, this._localStorage = b(this.options) } return c.prototype = { getItem: function (a) { return this._localStorage.getItem(a) }, removeItem: function (a) { return this._localStorage.removeItem(a) }, setItem: function (a, b) { return this._localStorage.setItem(a, b) } }, c }() }, { "./../constants": 60, "./../everlive.platform.js": 62, "application-settings": "application-settings", "local-settings": "local-settings", "node-localstorage": "node-localstorage" }], 97: [function (a, b) { "use strict"; function c(b, c) { this.options = c, this.fs = a("file-system"), this.dataDirectoryPath = this.fs.knownFolders.documents().path, this.filesDirectoryPath = this.fs.path.join(this.dataDirectoryPath, b) } { var d = a("../common"), e = d.rsvp; a("../utils") } c.prototype = { getErrorHandler: function (a) { return function (b) { a && a(b) } }, removeFilesDirectory: function () { var a = this; return a.getFilesDirectory().then(function (a) { return a.remove() }) }, removeFile: function (a) { return a.remove() }, readFileAsText: function (a) { return a.readText() }, writeTextToFile: function (a, b) { return a.writeText(b) }, getFile: function (a) { var b = this; return new e.Promise(function (c, d) { b.resolveDataDirectory().then(function (d) { var e = b.fs.path.join(d.path, a), f = b.fs.File.fromPath(e); c(f) })["catch"](d) }) }, getFilesDirectory: function () { var a = this; return new e.Promise(function (b) { var c = a.fs.Folder.fromPath(a.filesDirectoryPath); b(c) }) }, resolveDataDirectory: function () { var a = this; return new e.Promise(function (b) { var c = a.fs.Folder.fromPath(a.dataDirectoryPath); b(c) }) }, ensureFilesDirectory: function () { var a = this; return new e.Promise(function (b, c) { a.resolveDataDirectory().then(function (c) { var d = a.fs.path.join(c.path, a.filesDirectoryPath); a.fs.Folder.fromPath(d), b() })["catch"](c) }) }, getFilesDirectoryPath: function () { return this.filesDirectoryPath }, writeText: function () { throw new Error("Not implemented") }, createDirectory: function () { throw new Error("Not implemented") }, getFileSize: function () { throw new Error("Not implemented") }, getFileByAbsolutePath: function () { throw new Error("Not implemented") }, readFileAsBase64: function () { throw new Error("Not implemented") }, renameFile: function () { throw new Error("Not implemented") } }, b.exports = c }, { "../common": 59, "../utils": 102, "file-system": "file-system" }], 98: [function (a, b) { "use strict"; function c(a, b) { this.options = b; var c; i.isWindowsPhone || i.isInAppBuilderSimulator() ? c = a.replace(new RegExp("/", "g"), "") : -1 === a.lastIndexOf("/") && (c = a + "/"), c = c || a; var d = this; j().then(function () { d.filesDirectoryPath = c, d._requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem, d._resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL, d._PERSISTENT_FILE_SYSTEM = window.LocalFileSystem ? window.LocalFileSystem.PERSISTENT : window.PERSISTENT }) } var d = a("../EverliveError").EverliveError, e = a("../common"), f = e.rsvp, g = e._, h = a("../utils"), i = a("../everlive.platform"), j = (a("path"), function () { return new f.Promise(function (a) { document.addEventListener("deviceready", a) }) }); c.prototype = { getErrorHandler: function (a) { var b = { 1000: "NOT_FOUND" }; return g.each(Object.keys(FileError), function (a) { b[FileError[a]] = a }), function (c) { c.message || (c.message = b[c.code]), a && a(c) } }, getDataDirectory: function () { var a; return function () { var b = this; return j().then(function () { var c = function (c, d, e) { b._requestFileSystem.call(window, b._PERSISTENT_FILE_SYSTEM, c, function (b) { a = b.root, a.nativeURL = a.nativeURL || a.toURL(), d(a) }, e) }; return new f.Promise(function (e, f) { if (a) return e(a); if (i.isDesktop) { if (navigator && !navigator.webkitPersistentStorage) return f(new d("FileSystemStorage can be used only with browsers supporting it. Consider using localStorage.")); navigator.webkitPersistentStorage.requestQuota(b.options.storage.requestedQuota, function (a) { c(a, e, f) }, f) } else c(0, e, f) }) }) } }(), getFilesDirectory: function () { var a = this; return new f.Promise(function (b, c) { a.getDataDirectory().then(function (d) { d.getDirectory(a.filesDirectoryPath, { create: !0, exclusive: !1 }, b, c) })["catch"](c) }) }, removeFilesDirectory: function () { var a = this; return this.getFilesDirectory().then(function (b) { return a._removeFolderWrap(b) }) }, removeFile: function (a) { return new f.Promise(function (b, c) { a.remove(function () { b() }, c) }) }, readFileAsText: function (a) { var b = this; return new f.Promise(function (c, d) { b.getFilesDirectory().then(function () { a.file(function (a) { var b = new FileReader; b.onloadend = function () { var a = this.result; "object" == typeof this.result && (a = JSON.stringify(this.result)), c(a) }, b.onerror = d, b.readAsText(a) }, d) })["catch"](d) }) }, writeTextToFile: function (a, b) { var c = this; return c.getFilesDirectory().then(function () { return c._getWriterWrap(a, b) }) }, getFileSize: function (a, b) { var c = this; return new f.Promise(function (d, e) { var f = h.joinPath(b, a); return c.getFile(f).then(function (a) { a.file(function (a) { d(a.size) }, e) }) }) }, getFile: function (a, b) { return this.getFilesDirectory().then(function (c) { var d; return d = b ? b : c, new f.Promise(function (b, c) { d.getFile(a, { create: !0, exclusive: !1 }, b, c) }) }) }, getFileByAbsolutePath: function (a) { var b = this; return a = h.transformPlatformPath(a), new f.Promise(function (c, d) { b._resolveLocalFileSystemURL.call(window, a, c, function (a) { return a && a.code === FileError.NOT_FOUND_ERR ? c() : d(a) }) }) }, createDirectory: function (a) { var b = this; return this.getFilesDirectory().then(function (c) { return b._getDirectoryWrap(a, c, { create: !0, exclusive: !1 }) }) }, renameFile: function (a, b, c) { return new f.Promise(function (d, e) { b.moveTo(a, c, d, e) }) }, _getDirectoryWrap: function (a, b, c) { return new f.Promise(function (d, e) { b.getDirectory(a, c, d, e) }) }, _removeFolderWrap: function (a) { return new f.Promise(function (b, c) { a.removeRecursively(function () { b() }, c) }) }, _getWriterWrap: function (a, b) { return new f.Promise(function (c, d) { a.createWriter(function (a) { a.onwriteend = function () { c() }, a.onerror = d; var e = new Blob([b]); a.write(e) }, d) }) }, writeText: function (a, b, c) { var d, e = this; return this.getFilesDirectory().then(function (a) { return c ? e.createDirectory(c) : a }).then(function (b) { return e.getFile(a, b) }).then(function (a) { return d = a, e.writeTextToFile(a, b) }).then(function () { return d.nativeURL || d.toURL() }) }, readFileAsBase64: function (a) { return new f.Promise(function (b, c) { a.file(function (a) { var c = new FileReader; c.onloadend = function (a) { b(h.arrayBufferToBase64(a.target.result)) }, c.readAsArrayBuffer(a) }, c) }) } }, b.exports = c }, { "../EverliveError": 48, "../common": 59, "../everlive.platform": 62, "../utils": 102, path: 3 }], 99: [function (a, b) {
var c = a("../utils").buildPromise, d = a("../constants"), e = d.idField, f = a("../query/DataQuery"), g = a("../query/RequestOptionsBuilder"), h = a("../common").rsvp, i = a("../Request"), j = (a("../Everlive"),
a("../EverliveError").EverliveError), k = a("../EverliveError").EverliveErrors, l = a("../query/EventQuery"), m = a("../everlive.platform"), n = m.platform, o = a("../common")._, p = a("../utils"), q = a("../query/Query"), r = [d.DataQueryOperations.Count, d.DataQueryOperations.Read, d.DataQueryOperations.Create, d.DataQueryOperations.Update, d.DataQueryOperations.UpdateById, d.DataQueryOperations.Delete, d.DataQueryOperations.DeleteById, d.DataQueryOperations.ReadById, d.DataQueryOperations.Aggregate, d.DataQueryOperations.RawUpdate]; b.exports = function () { function a(a, b) { return function (c, d) { var e = c.result; o.isArray(a) || "number" == typeof a.length ? o.each(a, function (a, b) { o.extend(a, e[b]) }) : o.extend(a, e), b(c, d) } } function b(a, b) { return function (c) { var d = c.ModifiedAt; a.ModifiedAt = d, b(c) } } function s(a, b, c, d) { this.setup = a, this.collectionName = b, this.options = null, this.offlineStorage = c, this.everlive = d } return s.prototype = { _isOnline: function () { return this.offlineStorage ? this.offlineStorage.isOnline() : !0 }, _getOfflineCreateData: function (a, b) { var c; if (o.isArray(a.data)) { c = []; for (var d = 0; d < a.data.length; d++) { var e = o.extend(a.data[d], b.result[d]); c.push(e) } } else c = o.extend(a.data, b.result); return c }, _applyOffline: function (a, b) { var c = this.offlineStorage && this.offlineStorage.setup.autoSync; if (c) switch (a.operation) { case f.operations.Read: case f.operations.ReadById: case f.operations.FilesGetDownloadUrlById: var d = new f(o.defaults({ data: b.result, isSync: !0, operation: f.operations.Create }, a)); return this.offlineStorage.processQuery(d); case f.operations.Create: var e = this._getOfflineCreateData(a, b), g = new f(o.defaults({ data: e, isSync: !0 }, a)); return this.offlineStorage.processQuery(g); case f.operations.Update: case f.operations.RawUpdate: return a.isSync = !0, a.ModifiedAt = b.ModifiedAt, this.offlineStorage.processQuery(a); default: return a.isSync = !0, this.offlineStorage.processQuery(a) } return new h.Promise(function (a) { a() }) }, _setOption: function (a, b) { return this.options = this.options || {}, this.options[a] = o.isObject(b) ? o.extend({}, this.options[a], b) : b, this }, _generateQueryFromFilter: function (a) { return a instanceof q ? a : new q(a) }, useOffline: function (a) { if (1 !== arguments.length) throw new Error("A single value is expected in useOffline() query modifier"); return this._setOption("useOffline", a) }, ignoreCache: function () { return this._setOption("ignoreCache", !0) }, forceCache: function () { return this._setOption("forceCache", !0) }, maxAge: function (a) { var b = 1e3 * a * 60; return this._setOption("maxAge", b) }, isSync: function (a) { if (1 !== arguments.length) throw new Error("A single value is expected in isSync() query modifier"); return this._setOption("isSync", a) }, skipAuth: function (a) { if (1 !== arguments.length) throw new Error("A single value is expected in skipAuth() query modifier"); return this._setOption("skipAuth", a) }, applyOffline: function (a) { if (1 !== arguments.length) throw new Error("A single value is expected in applyOffline() query modifier"); return this._setOption("applyOffline", a) }, withHeaders: function (a) { return this._setOption("headers", a) }, expand: function (a) { var b = { "X-Everlive-Expand": JSON.stringify(a) }; return this.withHeaders(b) }, _applyQueryOffline: function (a) { var b = this; a.applyOffline ? b.offlineStorage.processQuery(a).then(function () { a.onSuccess.apply(this, arguments) }, function (b) { b.code || (b = new j(b.message, k.generalDatabaseError.code)), a.onError.call(this, b) }) : a.onError.call(this, new j("The applyOffline must be true when working offline.")) }, _sendRequest: function (a, b) { var c = this, d = a.onSuccess; a.onSuccess = function () { var e = arguments, f = e[0]; return a.applyOffline ? c._applyOffline(a, f).then(function () { d.apply(this, e) }, function (c) { b && c.code === k.operationNotSupportedOffline.code ? d.apply(this, e) : a.onError.apply(this, arguments) }) : d.apply(this, e) }; var e = g[a.operation], f = e(a); this._setAdditionalHeaders(a, f); var h = new i(this.setup, f); h.send() }, _applyQueryOnline: function (a) { a.useCache ? this.everlive.cache._cacheDataQuery(a) : this._sendRequest(a, !0) }, _setAdditionalHeaders: function (a, b) { a.isSync && (b.headers[d.Headers.sync] = !0); var c = { sdk: "js", platform: n }; b.headers[d.Headers.sdk] = JSON.stringify(c) }, processDataQuery: function (a) { var b = this, c = this.everlive._isOfflineStorageEnabled(); a.useOffline = c ? !this.everlive.isOnline() : !1, this.options && (a = o.defaults(this.options, a)); var e = this.everlive.setup.caching === !0 || this.everlive.setup.caching && this.everlive.setup.caching.enabled, g = p.isQuerySupportedOffline(a); if (a.useCache = e && !a.isSync && g, a.applyOffline = void 0 !== a.applyOffline ? a.applyOffline : c || a.useCache, !a.useCache && a.forceCache) return a.onError.call(this, new j(k.cannotForceCacheWhenDisabled)); if (this.options = null, !a.skipAuth && this.everlive.authentication && this.everlive.authentication.isAuthenticationInProgress() && (a.onError = o.wrap(a.onError, function (c, d) { if (d.code === k.invalidToken.code || d.code === k.expiredToken.code) { var e = b.everlive.authentication._ensureAuthentication(); a.noRetry || e.then(function () { if (a.headers && a.headers.authorization) { var c = p.buildAuthHeader(b.everlive.setup); o.extend(a.headers, c) } return b.processDataQuery(a) }) } else c.call(b, d) }), b.everlive.authentication.isAuthenticating())) { var h = b.everlive.authentication._ensureAuthentication(); return a.noRetry || h.then(function () { return b.processDataQuery(a) }), h } if (o.contains(r, a.operation)) { var i = l.fromDataQuery(a); if (this.everlive._emitter.emit(d.Events.BeforeExecute, i), i.isCancelled()) return; a.applyEventQuery(i) } var n = void 0; if (p.isContentType.files(a.collectionName) && m.isDesktop) { var q = a.operation; if (a.useOffline && a.applyOffline && (q === f.operations.Create || q === f.operations.Update)) return a.onError.call(this, new j(k.filesNotSupportedInBrowser)); var s = q === f.operations.Read || q === f.operations.ReadById || q === f.operations.FilesGetDownloadUrlById || q === f.operations.Delete || q === f.operations.DeleteById; n = a.useOffline && s } else n = a.useOffline; !a.isSync && this.offlineStorage && this.offlineStorage.isSynchronizing() ? a.onError.call(this, new j(k.syncInProgress)) : n ? this._applyQueryOffline(a) : this._applyQueryOnline(a) }, get: function (a, b, d) { var e = this; return c(function (b, c) { var d = new f({ operation: f.operations.Read, collectionName: e.collectionName, query: e._generateQueryFromFilter(a), onSuccess: b, onError: c }); return e.processDataQuery(d) }, b, d) }, getById: function (a, b, d) { var e = this; return c(function (b, c) { var d = new f({ operation: f.operations.ReadById, collectionName: e.collectionName, parse: i.parsers.single, additionalOptions: { id: a }, onSuccess: b, onError: c }); return e.processDataQuery(d) }, b, d) }, aggregate: function (a, b, e) { var g = this; return c(function (b, c) { var e = new f({ operation: d.DataQueryOperations.Aggregate, query: a, collectionName: g.collectionName, parse: i.parsers.single, onSuccess: b, onError: c }); return g.processDataQuery(e) }, b, e) }, count: function (a, b, d) { var e = this; return c(function (b, c) { var d = new f({ operation: f.operations.Count, collectionName: e.collectionName, query: e._generateQueryFromFilter(a), parse: i.parsers.single, onSuccess: b, onError: c }); return e.processDataQuery(d) }, b, d) }, create: function (b, d, e) { var g = this; return c(function (c, d) { var e = new f({ operation: f.operations.Create, collectionName: g.collectionName, data: b, parse: i.parsers.single, onSuccess: a(b, c), onError: d }); return g.processDataQuery(e) }, d, e) }, rawUpdate: function (a, b, d, e) { var g = this; return c(function (c, d) { var e = new f({ operation: f.operations.RawUpdate, collectionName: g.collectionName, parse: i.parsers.update, query: b, data: a, onSuccess: c, onError: d }); return g.processDataQuery(e) }, d, e) }, _update: function (a, d, g, h, j, k) { var l = this; return c(function (c, j) { var k = {}; k[h ? "$replace" : "$set"] = a; var m = g ? b(a, c) : c, n = new f({ operation: f.operations.Update, collectionName: l.collectionName, parse: i.parsers.update, query: l._generateQueryFromFilter(d), data: k, additionalOptions: { id: g ? a[e] : void 0 }, onSuccess: m, onError: j }); return l.processDataQuery(n) }, j, k) }, updateSingle: function (a, b, d) { var e = this._validateIdForModel(a); return e ? c(function (a, b) { return b(e) }, b, d) : this._update(a, null, !0, !1, b, d) }, _validateIdForModel: function (a, b) { return "string" != typeof a && "number" != typeof a || !b ? a && void 0 !== a.Id && null !== a.Id ? void 0 : new j(k.invalidId) : void 0 }, update: function (a, b, c, d) { return this._update(a, b, !1, !1, c, d) }, _destroy: function (a, b, e, g, h) { var i = this; return c(function (c, g) { var h = a && "object" == typeof a ? a[d.idField] : a, j = new f({ operation: e ? f.operations.DeleteById : f.operations.Delete, collectionName: i.collectionName, query: i._generateQueryFromFilter(b), onSuccess: c, onError: g, additionalOptions: { id: e ? h : void 0 } }); return i.processDataQuery(j) }, g, h) }, destroySingle: function (a, b, d) { var e = this._validateIdForModel(a, !0); return e ? c(function (a, b) { return b(e) }, b, d) : this._destroy(a, null, !0, b, d) }, destroy: function (a, b, c) { return this._destroy(null, a, !1, b, c) }, setAcl: function (a, b, d, e) { var g = this; return c(function (c, d) { var e = new f({ operation: f.operations.SetAcl, collectionName: g.collectionName, parse: i.parsers.single, query: b, additionalOptions: { acl: a }, onSuccess: c, onError: d }); return g.processDataQuery(e) }, d, e) }, setOwner: function (a, b, d, e) { var g = this; return c(function (c, d) { var e = new f({ operation: f.operations.SetOwner, collectionName: g.collectionName, query: b, data: { Owner: a }, onSuccess: c, onError: d }); return g.processDataQuery(e) }, d, e) }, save: function (a, b, d) { var e = this, f = this.isNew(a); return c(function (b, c) { function d(a) { a.type = f ? "create" : "update", b(a) } function g(a) { a.type = f ? "create" : "update", c(a) } return f ? e.create(a, d, g) : e.updateSingle(a, d, g) }, b, d) }, isNew: function (a) { return "undefined" == typeof a[e] } }, s }()
}, { "../Everlive": 47, "../EverliveError": 48, "../Request": 53, "../common": 59, "../constants": 60, "../everlive.platform": 62, "../query/DataQuery": 87, "../query/EventQuery": 88, "../query/Query": 89, "../query/RequestOptionsBuilder": 91, "../utils": 102 }], 100: [function (a, b) { var c = a("../utils").buildPromise, d = a("../query/DataQuery"), e = a("../Request"), f = a("../utils"), g = a("../everlive.platform"); b.exports.addFilesFunctions = function (a) { a.getUploadUrl = function () { return f.buildUrl(this.setup) + this.collectionName }, a.getDownloadUrl = function (a) { return f.buildUrl(this.setup) + this.collectionName + "/" + a + "/Download" }, a._getUpdateUrl = function (a) { return this.collectionName + "/" + a + "/Content" }, a.getUpdateUrl = function (a) { return f.buildUrl(this.setup) + this._getUpdateUrl(a) }, a.updateContent = function (a, b, e, f) { var g = this; return c(function (c, e) { var f = new d({ operation: d.operations.FilesUpdateContent, data: b, collectionName: g.collectionName, additionalOptions: { id: a }, onSuccess: c, onError: e }); return g.processDataQuery(f) }, e, f) }, a.getDownloadUrlById = function (a, b, f) { var h = this; return c(function (b, c) { if (g.isDesktop && !h.everlive.isOnline()) { var f = h.getDownloadUrl(a); return b(f) } var i = new d({ operation: d.operations.FilesGetDownloadUrlById, collectionName: h.collectionName, additionalOptions: { id: a }, parse: e.parsers.single, onSuccess: function (a) { b(a.result.Uri) }, onError: c }); return h.processDataQuery(i) }, b, f) }, a.download = function (a, b, d, e, f, g) { var h = this; return c(function (c, f) { e || (e = !1); var g = d && d.headers ? d.headers : {}, i = new FileTransfer; h.withHeaders(g).getById(a).then(function (g) { var h = g.result; a = h.Uri, i.download(a, b, c, f, e, d) }, f) }, f, g) }, a.upload = function (a, b, d, e, f) { var g = this.getUploadUrl(); return c(function (c, e) { d || (d = !1); var f = new FileTransfer, h = encodeURI(g); f.upload(a, h, c, e, b, d) }, e, f) } } }, { "../Request": 53, "../everlive.platform": 62, "../query/DataQuery": 87, "../utils": 102 }], 101: [function (a, b) { var c = a("../utils"), d = c.buildPromise, e = c.guardUnset, f = a("../query/DataQuery"), g = a("../Request"), h = a("../common")._, i = a("../EverliveError").EverliveError, j = a("../EverliveError").EverliveErrors; b.exports.addUsersFunctions = function (a, b) { a.register = function (a, b, c, d, f) { e(a, "username"), e(b, "password"); var g = { Username: a, Password: b }; return h.extend(g, c), this.create(g, d, f) }, a.currentUser = function (a, b) { var c = this, e = c.everlive._isOfflineStorageEnabled() && c.everlive.isOffline() ? c.everlive.setup.principalId : "me"; return d(function (a, b) { return ("me" !== e || c.everlive.setup.token || c.everlive.setup.masterKey) && e ? void c.getById(e).then(function (b) { a("undefined" != typeof b.result ? { result: b.result } : { result: null }) }, function (d) { c.everlive.authentication && c.everlive.authentication.isAuthenticationInProgress() ? a({ result: null }) : 601 === d.code ? a({ result: null }) : b(801 === d.code ? new i(j.invalidToken) : d) }) : a({ result: null }) }, a, b) }, a.changePassword = function (b, c, e, g, i, j) { var k = this; return d(function (d, i) { d = h.wrap(d, function (b, c) { return c && c.result && (g || a.clearAuthorization()), b(c) }); var j = new f({ operation: f.operations.UserChangePassword, collectionName: k.collectionName, data: { Username: b, Password: c, NewPassword: e }, additionalOptions: { keepTokens: g }, skipAuth: !0, onSuccess: d, onError: i }); return k.processDataQuery(j) }, i, j) }, a.login = function (a, c, d, e) { return b.authentication.login(a, c, d, e) }, a.logout = function (a, c) { return b.authentication.logout(a, c) }, a.loginWithFacebook = function (a, c, d) { return b.authentication.loginWithFacebook(a, c, d) }, a.linkWithFacebook = function (b, c, d, e) { var f = { Provider: "Facebook", Token: c }; return a._linkWithProvider(f, b, d, e) }, a.unlinkFromFacebook = function (b, c, d) { return a._unlinkFromProvider("Facebook", b, c, d) }, a.loginWithADFS = function (a, c, d) { return b.authentication.loginWithADFS(a, c, d) }, a.linkWithADFS = function (b, c, d, e) { var f = { Provider: "ADFS", Token: c }; return a._linkWithProvider(f, b, d, e) }, a.unlinkFromADFS = function (b, c, d) { return a._unlinkFromProvider("ADFS", b, c, d) }, a.loginWithLiveID = function (a, c, d) { return b.authentication.loginWithLiveID(a, c, d) }, a.linkWithLiveID = function (b, c, d, e) { var f = { Provider: "LiveID", Token: c }; return a._linkWithProvider(f, b, d, e) }, a.unlinkFromLiveID = function (b, c, d) { return a._unlinkFromProvider("LiveID", b, c, d) }, a.loginWithGoogle = function (a, c, d) { return b.authentication.loginWithGoogle(a, c, d) }, a.linkWithGoogle = function (b, c, d, e) { var f = { Provider: "Google", Token: c }; return a._linkWithProvider(f, b, d, e) }, a.unlinkFromGoogle = function (b, c, d) { return a._unlinkFromProvider("Google", b, c, d) }, a.loginWithTwitter = function (a, c, d, e) { return b.authentication.loginWithTwitter(a, c, d, e) }, a.linkWithTwitter = function (b, c, d, e, f) { var g = { Provider: "Twitter", Token: c, TokenSecret: d }; return a._linkWithProvider(g, b, e, f) }, a.unlinkFromTwitter = function (b, c, d) { return a._unlinkFromProvider("Twitter", b, c, d) }, a.setAuthorization = function (a, c, d) { b.authentication.setAuthorization(a, c, d) }, a.clearAuthorization = function () { b.authentication.setAuthorization(null, null, null) }, a.resetPassword = function (a, b, c) { var e = this; return d(function (b, c) { var d = new f({ operation: f.operations.UserResetPassword, collectionName: e.collectionName, data: a, onSuccess: b, onError: c }); return e.processDataQuery(d) }, b, c) }, a.setPassword = function (a, b, c) { var e = this; return d(function (b, c) { var d = new f({ operation: f.operations.UserSetPassword, collectionName: e.collectionName, data: a, onSuccess: b, onError: c }); return e.processDataQuery(d) }, b, c) }, a._linkWithProvider = function (a, b, c, e) { var h = this; return d(function (c, d) { var e = new f({ additionalOptions: { id: b }, operation: f.operations.UserLinkWithProvider, collectionName: h.collectionName, data: a, parse: g.parsers.single, skipAuth: !0, onSuccess: c, onError: d }); return h.processDataQuery(e) }, c, e) }, a._unlinkFromProvider = function (a, b, c, e) { var h = { Provider: a }, i = this; return d(function (a, c) { var d = new f({ additionalOptions: { userId: b }, operation: f.operations.UserUnlinkFromProvider, collectionName: i.collectionName, data: h, parse: g.parsers.single, skipAuth: !0, onSuccess: a, onError: c }); return i.processDataQuery(d) }, c, e) } } }, { "../EverliveError": 48, "../Request": 53, "../common": 59, "../query/DataQuery": 87, "../utils": 102 }], 102: [function (a, b) { var c = a("./EverliveError").EverliveError, d = a("./common"), e = d._, f = d.rsvp, g = (a("./Everlive"), a("./everlive.platform")), h = a("path"), i = a("./constants"), j = {}; j.guardUnset = function (a, b, d) { if (d || (d = "The " + b + " is required"), "undefined" == typeof a || null === a) throw new c(d) }, j.normalizeKeys = function (a) { var b = {}; return e.each(a, function (a, c) { var d = c.toLowerCase(); b.hasOwnProperty(d) || (b[d] = a) }), b }, j.parseUtilities = { getReviver: function (a) { var b; return b = a ? j.parseUtilities.parseIsoDateString : j.parseUtilities.parseOnlyCompleteDateTimeString, function (a, c) { if ("string" == typeof c) { var d = b(c); d && (c = d) } return c } }, parseIsoDateString: function (a) { var b; if (b = a.match(/^(\d{4})(-(\d{2})(-(\d{2})(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2}))))?))$/)) { var c = b[12]; c && (c.length > 3 ? c = Math.round(Number(c.substr(0, 3) + "." + c.substr(3))) : c.length < 3 && (c += 2 === c.length ? "0" : "00")); var d = new Date(Date.UTC(Number(b[1]), Number(b[3]) - 1 || 0, Number(b[5]) || 0, Number(b[7]) || 0, Number(b[8]) || 0, Number(b[10]) || 0, Number(c) || 0)); if (b[13] && "Z" !== b[13]) { var e = Number(b[16]) || 0, f = Number(b[17]) || 0; e *= 36e5, f *= 6e4; var g = e + f; "+" === b[15] && (g = -g), d = new Date(d.valueOf() + g) } return d } return null }, parseOnlyCompleteDateTimeString: function (a) { return /^\d{4}-\d{2}-\d{2}$/.test(a) ? null : /^(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2})))?$/.test(a) ? null : j.parseUtilities.parseIsoDateString(a) }, traverse: function (a, b) { var c, d, e; for (c in a) a.hasOwnProperty(c) && (d = a[c], e = b(c, d), a[c] = e, d === e && "object" == typeof d && j.parseUtilities.traverse(d, b)); return a }, traverseAndRevive: function (a, b) { return b || (b = j.parseUtilities.getReviver()), j.parseUtilities.traverse(a, b) }, parseError: function (a, b) { if (!("string" == typeof b && b.length > 0)) return b; try { return b = JSON.parse(b), { message: b.message, code: b.errorCode } } catch (c) { return b } }, _parseInternal: function (a, b) { return "string" == typeof b && b.length > 0 ? b = JSON.parse(b, a) : "object" == typeof b && j.parseUtilities.traverseAndRevive(b, a), b }, _transformResult: function (a, b) { if (a) { var c = { result: a.Result }; return e.extend(c, b), c } return a }, parseResult: function (a, b) { return b = j.parseUtilities._parseInternal.apply(null, arguments), j.parseUtilities._transformResult(b, { count: b.Count }) }, parseSingleResult: function (a, b) { return b = j.parseUtilities._parseInternal.apply(null, arguments), j.parseUtilities._transformResult(b) }, parseUpdateResult: function (a, b) { return b = j.parseUtilities._parseInternal.apply(null, arguments), j.parseUtilities._transformResult(b, { ModifiedAt: b.ModifiedAt }) }, parseJSON: function (a) { return JSON.parse(a, j.parseUtilities.getReviver()) } }, j.buildPromise = function (a, b, c) { var d = j.getCallbacks(b, c); return a(d.success, d.error), d.promise }, j.getCallbacks = function (a, b) { var c, d = function () { return new f.Promise(function (c, d) { a = function (a) { c(a) }, b = function (a) { d(a) } }) }; if (g.isNodejs) if ("function" == typeof a && "function" != typeof b) { var e = a; a = function (a, b) { e(null, a, b) }, b = function (a) { e(a) } } else "function" != typeof a && "function" != typeof b && (c = d()); else "function" != typeof a && "function" != typeof b && (c = d()); return { promise: c, success: a, error: b } }, j.buildAuthHeader = function (a, b) { var c = null; return b && b.authHeaders === !1 ? c : (a.token ? c = (a.tokenType || "bearer") + " " + a.token : a.masterKey && (c = "masterkey " + a.masterKey), c ? { authorization: c } : null) }, j.DeviceRegistrationResult = function (a) { this.token = a }, j.cloneDate = function (a) { return new Date(a) }, j.buildUrl = function (a) { var b = ""; return "string" == typeof a.scheme && (b += a.scheme + ":"), b += a.url, a.appId && (b += a.appId + "/"), b }, j.getDbOperators = function (a, b) { var c = []; if ("string" == typeof a || "number" == typeof a) return c; var d = Object.keys(a || {}); return e.each(d, function (d) { 0 === d.indexOf("$") ? c.push(d) : "object" != typeof a[d] || b || (c = c.concat(j.getDbOperators(a[d]))) }), c }, j.disableRequestCache = function (a, b) { if ("GET" === b) { var c = (new Date).getTime(), d = a.indexOf("?") > -1 ? "&" : "?"; a += d + "_el=" + c } return a }; var k = ["$geoWithin", "$geoIntersects", "$near", "$within", "$nearSphere"]; j.getUnsupportedOperators = function (a) { var b = j.getDbOperators(a); return e.intersection(b, k) }, j.isGuid = function (a) { return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a) }, j.isQuerySupportedOffline = function (a) { var b = a.getQueryParameters(), c = !e.isEmptyObject(b.expand), d = j.getUnsupportedOperators(b.filter), f = 0 !== d.length, g = c || f; return !g }, j.b64toBlob = function (a, b, c) { b = b || "", c = c || 512; for (var d = atob(a), e = [], f = 0; f < d.length; f += c) { for (var g = d.slice(f, f + c), h = new Array(g.length), i = 0; i < g.length; i++) h[i] = g.charCodeAt(i); var j = new Uint8Array(h); e.push(j) } var k = new Blob(e, { type: b }); return k }, j.arrayBufferToBase64 = function (a) { for (var b = "", c = new Uint8Array(a), d = c.byteLength, e = 0; d > e; e++) b += String.fromCharCode(c[e]); return btoa(b) }, j.successfulPromise = function (a) { return new f.Promise(function (b) { b(a) }) }, j.rejectedPromise = function (a) { return new f.Promise(function (b, c) { c(a) }) }, j.transformPlatformPath = function (a) { return a ? (g.isWindowsPhone ? "/" === a.charAt(0) && "/" !== a.charAt(1) && (a = "/" + a) : -1 !== a.indexOf("file:/") && -1 === a.indexOf("file:///") && (a = a.replace("file:/", "file:///")), a) : "" }, j._stringCompare = function (a, b) { return a.toLowerCase() === b }, j.isContentType = { files: function (a) { return j._stringCompare(a, "files") }, users: function (a) { return j._stringCompare(a, "users") }, pushNotifications: function (a) { return j._stringCompare(a, i.Push.NotificationsType.toLowerCase()) }, pushDevices: function (a) { return j._stringCompare(a, i.Push.DevicesType.toLowerCase()) } }, j.isElement = { _isElement: function (a, b) { var c = a; return "string" != typeof c && a instanceof HTMLElement && (c = a.tagName), j._stringCompare(c, b) }, image: function (a) { return j.isElement._isElement(a, "img") }, anchor: function (a) { return j.isElement._isElement(a, "a") } }, j.joinPath = function () { var a = [].slice.apply(arguments).map(function (a) { return a || "" }), b = h.join.apply(h, a); return j.transformPlatformPath(b) }, j.uuid = function () { var a = (new Date).getTime(), b = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (b) { var c = (a + 16 * Math.random()) % 16 | 0; return a = Math.floor(a / 16), ("x" == b ? c : 3 & c | 8).toString(16) }); return b }, j.getId = function (a) { return a.Id || a._id || a.id }, j.lazyRequire = function (b, c) { c = c || b; var d = {}; return Object.defineProperty(d, c, { get: function () { return a(b) } }), d }, j._inAppBuilderSimulator = function () { return void 0 !== typeof window && window.navigator && window.navigator.simulator }, b.exports = j }, { "./Everlive": 47, "./EverliveError": 48, "./common": 59, "./constants": 60, "./everlive.platform": 62, path: 3 }]
}, {}, [67])(67)
});