\";\n return div.innerHTML.indexOf('
') > 0;\n} // #3663: IE encodes newlines inside attribute values while other browsers don't\n\n\nvar shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false; // #6828: chrome encodes content in a[href]\n\nvar shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;\n/* */\n\nvar idToTemplate = cached(function (id) {\n var el = query(id);\n return el && el.innerHTML;\n});\nvar mount = Vue.prototype.$mount;\n\nVue.prototype.$mount = function (el, hydrating) {\n el = el && query(el);\n /* istanbul ignore if */\n\n if (el === document.body || el === document.documentElement) {\n process.env.NODE_ENV !== 'production' && warn(\"Do not mount Vue to or - mount to normal elements instead.\");\n return this;\n }\n\n var options = this.$options; // resolve template/el and convert to render function\n\n if (!options.render) {\n var template = options.template;\n\n if (template) {\n if (typeof template === 'string') {\n if (template.charAt(0) === '#') {\n template = idToTemplate(template);\n /* istanbul ignore if */\n\n if (process.env.NODE_ENV !== 'production' && !template) {\n warn(\"Template element not found or is empty: \" + options.template, this);\n }\n }\n } else if (template.nodeType) {\n template = template.innerHTML;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n warn('invalid template option:' + template, this);\n }\n\n return this;\n }\n } else if (el) {\n template = getOuterHTML(el);\n }\n\n if (template) {\n /* istanbul ignore if */\n if (process.env.NODE_ENV !== 'production' && config.performance && mark) {\n mark('compile');\n }\n\n var ref = compileToFunctions(template, {\n outputSourceRange: process.env.NODE_ENV !== 'production',\n shouldDecodeNewlines: shouldDecodeNewlines,\n shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,\n delimiters: options.delimiters,\n comments: options.comments\n }, this);\n var render = ref.render;\n var staticRenderFns = ref.staticRenderFns;\n options.render = render;\n options.staticRenderFns = staticRenderFns;\n /* istanbul ignore if */\n\n if (process.env.NODE_ENV !== 'production' && config.performance && mark) {\n mark('compile end');\n measure(\"vue \" + this._name + \" compile\", 'compile', 'compile end');\n }\n }\n }\n\n return mount.call(this, el, hydrating);\n};\n/**\n * Get outerHTML of elements, taking care\n * of SVG elements in IE as well.\n */\n\n\nfunction getOuterHTML(el) {\n if (el.outerHTML) {\n return el.outerHTML;\n } else {\n var container = document.createElement('div');\n container.appendChild(el.cloneNode(true));\n return container.innerHTML;\n }\n}\n\nVue.compile = compileToFunctions;\nexport default Vue;","import { Model } from '@vuex-orm/core';\nimport Post from \"@models/Post\";\nimport Comment from \"@models/Comment\";\n\nclass User extends Model {\n static entity = 'users'\n\n static fields () {\n return {\n id: this.attr(null),\n email: this.attr(''),\n // relationships\n posts: this.hasMany(Post, 'user_id'),\n comments: this.hasMany(Comment, 'user_id')\n }\n }\n}\n\nexport default User","import {Model} from '@vuex-orm/core';\nimport Comment from '@models/Comment';\nimport User from '@models/User';\n\nclass Post extends Model {\n static entity = 'posts'\n\n static fields() {\n return {\n id: this.attr(null),\n title: this.attr(''),\n follow_frequency: this.attr(false),\n body: this.attr(null),\n user_id: this.attr(null),\n description: this.attr(null),\n owner: this.attr(null),\n owner_id: this.attr(null),\n my_group_id: this.attr(null),\n comment_count: this.attr(null),\n attachment_order_type: this.attr([]),\n attachment_order_id: this.attr([]),\n image_ids: this.attr([]),\n my_card_ids: this.attr([]),\n other_card_ids: this.attr([]),\n my_folder_ids: this.attr([]),\n other_folder_ids: this.attr([]),\n my_product_ids: this.attr([]),\n other_product_ids: this.attr([]),\n external_url: this.attr([]),\n first_attachment: this.attr(null),\n text_embed_id: this.attr(null),\n text_embed: this.attr(null),\n url_hash: this.attr([]), //[{url:'', title:'', image:''}]\n likes: this.attr(0),\n liked: this.attr(null),\n card: this.attr(null),\n created_at: this.attr(null),\n group: this.attr(null),\n folder: this.attr(null),\n product: this.attr(null),\n type: this.attr(null),\n four_cards_logo: this.attr(null),\n card_type: this.attr(null),\n privacy: this.attr('friends'), //public|friends|friends_group\n friends_group: this.attr([]),\n group_ids: this.attr([]),\n share_post_id: this.attr(null),\n share_post: this.attr(null),\n mentions: this.attr([]),\n // relationships\n // comments: this.hasMany(Comment, 'post_id'),\n user: this.belongsTo(User, 'user_id'),\n\n // ui fields\n isNew: this.attr(false),\n }\n }\n}\n\nexport default Post","export default {\n capitalize(value){\n if (!value) return ''\n value = value.toString()\n return value.charAt(0).toUpperCase() + value.slice(1)\n },\n\n unSnakeCase(value){\n if (!value) return ''\n value = value.toString()\n return value.replace(/_/g, ' ');\n }\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction createCommonjsModule(fn, module) {\n return module = {\n exports: {}\n }, fn(module, module.exports), module.exports;\n}\n\nvar _global = createCommonjsModule(function (module) {\n // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\n var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func\n : Function('return this')();\n if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n});\n\nvar _core = createCommonjsModule(function (module) {\n var core = module.exports = {\n version: '2.6.11'\n };\n if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n});\n\nvar _core_1 = _core.version;\n\nvar _isObject = function _isObject(it) {\n return _typeof(it) === 'object' ? it !== null : typeof it === 'function';\n};\n\nvar _anObject = function _anObject(it) {\n if (!_isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n\nvar _fails = function _fails(exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n}; // Thank's IE8 for his funny defineProperty\n\n\nvar _descriptors = !_fails(function () {\n return Object.defineProperty({}, 'a', {\n get: function get() {\n return 7;\n }\n }).a != 7;\n});\n\nvar document = _global.document; // typeof document.createElement is 'object' in old IE\n\nvar is = _isObject(document) && _isObject(document.createElement);\n\nvar _domCreate = function _domCreate(it) {\n return is ? document.createElement(it) : {};\n};\n\nvar _ie8DomDefine = !_descriptors && !_fails(function () {\n return Object.defineProperty(_domCreate('div'), 'a', {\n get: function get() {\n return 7;\n }\n }).a != 7;\n}); // 7.1.1 ToPrimitive(input [, PreferredType])\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\n\n\nvar _toPrimitive = function _toPrimitive(it, S) {\n if (!_isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n\nvar dP = Object.defineProperty;\nvar f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n _anObject(O);\n\n P = _toPrimitive(P, true);\n\n _anObject(Attributes);\n\n if (_ie8DomDefine) try {\n return dP(O, P, Attributes);\n } catch (e) {\n /* empty */\n }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\nvar _objectDp = {\n f: f\n};\n\nvar _propertyDesc = function _propertyDesc(bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n\nvar _hide = _descriptors ? function (object, key, value) {\n return _objectDp.f(object, key, _propertyDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n\nvar hasOwnProperty = {}.hasOwnProperty;\n\nvar _has = function _has(it, key) {\n return hasOwnProperty.call(it, key);\n};\n\nvar id = 0;\nvar px = Math.random();\n\nvar _uid = function _uid(key) {\n return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n\nvar _shared = createCommonjsModule(function (module) {\n var SHARED = '__core-js_shared__';\n var store = _global[SHARED] || (_global[SHARED] = {});\n (module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n })('versions', []).push({\n version: _core.version,\n mode: 'global',\n copyright: '© 2019 Denis Pushkarev (zloirock.ru)'\n });\n});\n\nvar _functionToString = _shared('native-function-to-string', Function.toString);\n\nvar _redefine = createCommonjsModule(function (module) {\n var SRC = _uid('src');\n\n var TO_STRING = 'toString';\n\n var TPL = ('' + _functionToString).split(TO_STRING);\n\n _core.inspectSource = function (it) {\n return _functionToString.call(it);\n };\n\n (module.exports = function (O, key, val, safe) {\n var isFunction = typeof val == 'function';\n if (isFunction) _has(val, 'name') || _hide(val, 'name', key);\n if (O[key] === val) return;\n if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));\n\n if (O === _global) {\n O[key] = val;\n } else if (!safe) {\n delete O[key];\n\n _hide(O, key, val);\n } else if (O[key]) {\n O[key] = val;\n } else {\n _hide(O, key, val);\n } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n\n })(Function.prototype, TO_STRING, function toString() {\n return typeof this == 'function' && this[SRC] || _functionToString.call(this);\n });\n});\n\nvar _aFunction = function _aFunction(it) {\n if (typeof it != 'function') throw TypeError(it + ' is not a function!');\n return it;\n}; // optional / simple context binding\n\n\nvar _ctx = function _ctx(fn, that, length) {\n _aFunction(fn);\n\n if (that === undefined) return fn;\n\n switch (length) {\n case 1:\n return function (a) {\n return fn.call(that, a);\n };\n\n case 2:\n return function (a, b) {\n return fn.call(that, a, b);\n };\n\n case 3:\n return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n\n return function ()\n /* ...args */\n {\n return fn.apply(that, arguments);\n };\n};\n\nvar PROTOTYPE = 'prototype';\n\nvar $export = function $export(type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];\n var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});\n var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});\n var key, own, out, exp;\n if (IS_GLOBAL) source = name;\n\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined; // export native or passed\n\n out = (own ? target : source)[key]; // bind timers to global for call from export context\n\n exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global\n\n if (target) _redefine(target, key, out, type & $export.U); // export\n\n if (exports[key] != out) _hide(exports, key, exp);\n if (IS_PROTO && expProto[key] != out) expProto[key] = out;\n }\n};\n\n_global.core = _core; // type bitmap\n\n$export.F = 1; // forced\n\n$export.G = 2; // global\n\n$export.S = 4; // static\n\n$export.P = 8; // proto\n\n$export.B = 16; // bind\n\n$export.W = 32; // wrap\n\n$export.U = 64; // safe\n\n$export.R = 128; // real proto method for `library`\n\nvar _export = $export;\nvar toString = {}.toString;\n\nvar _cof = function _cof(it) {\n return toString.call(it).slice(8, -1);\n}; // fallback for non-array-like ES3 and non-enumerable old V8 strings\n// eslint-disable-next-line no-prototype-builtins\n\n\nvar _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {\n return _cof(it) == 'String' ? it.split('') : Object(it);\n}; // 7.2.1 RequireObjectCoercible(argument)\n\n\nvar _defined = function _defined(it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n}; // to indexed object, toObject with fallback for non-array-like ES3 strings\n\n\nvar _toIobject = function _toIobject(it) {\n return _iobject(_defined(it));\n}; // 7.1.4 ToInteger\n\n\nvar ceil = Math.ceil;\nvar floor = Math.floor;\n\nvar _toInteger = function _toInteger(it) {\n return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);\n}; // 7.1.15 ToLength\n\n\nvar min = Math.min;\n\nvar _toLength = function _toLength(it) {\n return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991\n};\n\nvar max = Math.max;\nvar min$1 = Math.min;\n\nvar _toAbsoluteIndex = function _toAbsoluteIndex(index, length) {\n index = _toInteger(index);\n return index < 0 ? max(index + length, 0) : min$1(index, length);\n}; // false -> Array#indexOf\n// true -> Array#includes\n\n\nvar _arrayIncludes = function _arrayIncludes(IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = _toIobject($this);\n\n var length = _toLength(O.length);\n\n var index = _toAbsoluteIndex(fromIndex, length);\n\n var value; // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare\n\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++]; // eslint-disable-next-line no-self-compare\n\n if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not\n } else for (; length > index; index++) {\n if (IS_INCLUDES || index in O) {\n if (O[index] === el) return IS_INCLUDES || index || 0;\n }\n }\n return !IS_INCLUDES && -1;\n };\n};\n\nvar _wks = createCommonjsModule(function (module) {\n var store = _shared('wks');\n\n var _Symbol = _global.Symbol;\n var USE_SYMBOL = typeof _Symbol == 'function';\n\n var $exports = module.exports = function (name) {\n return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : _uid)('Symbol.' + name));\n };\n\n $exports.store = store;\n}); // 22.1.3.31 Array.prototype[@@unscopables]\n\n\nvar UNSCOPABLES = _wks('unscopables');\n\nvar ArrayProto = Array.prototype;\nif (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});\n\nvar _addToUnscopables = function _addToUnscopables(key) {\n ArrayProto[UNSCOPABLES][key] = true;\n}; // https://github.com/tc39/Array.prototype.includes\n\n\nvar $includes = _arrayIncludes(true);\n\n_export(_export.P, 'Array', {\n includes: function includes(el\n /* , fromIndex = 0 */\n ) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n_addToUnscopables('includes');\n\nvar includes = _core.Array.includes;\n\nvar shared = _shared('keys');\n\nvar _sharedKey = function _sharedKey(key) {\n return shared[key] || (shared[key] = _uid(key));\n};\n\nvar arrayIndexOf = _arrayIncludes(false);\n\nvar IE_PROTO = _sharedKey('IE_PROTO');\n\nvar _objectKeysInternal = function _objectKeysInternal(object, names) {\n var O = _toIobject(object);\n\n var i = 0;\n var result = [];\n var key;\n\n for (key in O) {\n if (key != IE_PROTO) _has(O, key) && result.push(key);\n } // Don't enum bug & hidden keys\n\n\n while (names.length > i) {\n if (_has(O, key = names[i++])) {\n ~arrayIndexOf(result, key) || result.push(key);\n }\n }\n\n return result;\n}; // IE 8- don't enum bug keys\n\n\nvar _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); // 19.1.2.14 / 15.2.3.14 Object.keys(O)\n\n\nvar _objectKeys = Object.keys || function keys(O) {\n return _objectKeysInternal(O, _enumBugKeys);\n};\n\nvar f$1 = Object.getOwnPropertySymbols;\nvar _objectGops = {\n f: f$1\n};\nvar f$2 = {}.propertyIsEnumerable;\nvar _objectPie = {\n f: f$2\n}; // 7.1.13 ToObject(argument)\n\nvar _toObject = function _toObject(it) {\n return Object(_defined(it));\n}; // 19.1.2.1 Object.assign(target, source, ...)\n\n\nvar $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug)\n\nvar _objectAssign = !$assign || _fails(function () {\n var A = {};\n var B = {}; // eslint-disable-next-line no-undef\n\n var S = Symbol();\n var K = 'abcdefghijklmnopqrst';\n A[S] = 7;\n K.split('').forEach(function (k) {\n B[k] = k;\n });\n return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;\n}) ? function assign(target, source) {\n // eslint-disable-line no-unused-vars\n var T = _toObject(target);\n\n var aLen = arguments.length;\n var index = 1;\n var getSymbols = _objectGops.f;\n var isEnum = _objectPie.f;\n\n while (aLen > index) {\n var S = _iobject(arguments[index++]);\n\n var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);\n var length = keys.length;\n var j = 0;\n var key;\n\n while (length > j) {\n key = keys[j++];\n if (!_descriptors || isEnum.call(S, key)) T[key] = S[key];\n }\n }\n\n return T;\n} : $assign; // 19.1.3.1 Object.assign(target, source)\n\n\n_export(_export.S + _export.F, 'Object', {\n assign: _objectAssign\n});\n\nvar assign = _core.Object.assign;\nvar isEnum = _objectPie.f;\n\nvar _objectToArray = function _objectToArray(isEntries) {\n return function (it) {\n var O = _toIobject(it);\n\n var keys = _objectKeys(O);\n\n var length = keys.length;\n var i = 0;\n var result = [];\n var key;\n\n while (length > i) {\n key = keys[i++];\n\n if (!_descriptors || isEnum.call(O, key)) {\n result.push(isEntries ? [key, O[key]] : O[key]);\n }\n }\n\n return result;\n };\n}; // https://github.com/tc39/proposal-object-values-entries\n\n\nvar $entries = _objectToArray(true);\n\n_export(_export.S, 'Object', {\n entries: function entries(it) {\n return $entries(it);\n }\n});\n\nvar entries = _core.Object.entries; // https://github.com/tc39/proposal-object-values-entries\n\nvar $values = _objectToArray(false);\n\n_export(_export.S, 'Object', {\n values: function values(it) {\n return $values(it);\n }\n});\n\nvar values = _core.Object.values; // 7.2.8 IsRegExp(argument)\n\nvar MATCH = _wks('match');\n\nvar _isRegexp = function _isRegexp(it) {\n var isRegExp;\n return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp');\n}; // helper for String#{startsWith, endsWith, includes}\n\n\nvar _stringContext = function _stringContext(that, searchString, NAME) {\n if (_isRegexp(searchString)) throw TypeError('String#' + NAME + \" doesn't accept regex!\");\n return String(_defined(that));\n};\n\nvar MATCH$1 = _wks('match');\n\nvar _failsIsRegexp = function _failsIsRegexp(KEY) {\n var re = /./;\n\n try {\n '/./'[KEY](re);\n } catch (e) {\n try {\n re[MATCH$1] = false;\n return !'/./'[KEY](re);\n } catch (f) {\n /* empty */\n }\n }\n\n return true;\n};\n\nvar STARTS_WITH = 'startsWith';\nvar $startsWith = ''[STARTS_WITH];\n\n_export(_export.P + _export.F * _failsIsRegexp(STARTS_WITH), 'String', {\n startsWith: function startsWith(searchString\n /* , position = 0 */\n ) {\n var that = _stringContext(this, searchString, STARTS_WITH);\n\n var index = _toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));\n\n var search = String(searchString);\n return $startsWith ? $startsWith.call(that, search, index) : that.slice(index, index + search.length) === search;\n }\n});\n\nvar startsWith = _core.String.startsWith; // true -> String#at\n// false -> String#codePointAt\n\nvar _stringAt = function _stringAt(TO_STRING) {\n return function (that, pos) {\n var s = String(_defined(that));\n\n var i = _toInteger(pos);\n\n var l = s.length;\n var a, b;\n if (i < 0 || i >= l) return TO_STRING ? '' : undefined;\n a = s.charCodeAt(i);\n return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;\n };\n};\n\nvar _iterators = {};\n\nvar _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {\n _anObject(O);\n\n var keys = _objectKeys(Properties);\n\n var length = keys.length;\n var i = 0;\n var P;\n\n while (length > i) {\n _objectDp.f(O, P = keys[i++], Properties[P]);\n }\n\n return O;\n};\n\nvar document$1 = _global.document;\n\nvar _html = document$1 && document$1.documentElement; // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\n\n\nvar IE_PROTO$1 = _sharedKey('IE_PROTO');\n\nvar Empty = function Empty() {\n /* empty */\n};\n\nvar PROTOTYPE$1 = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype\n\nvar _createDict = function createDict() {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = _domCreate('iframe');\n\n var i = _enumBugKeys.length;\n var lt = '<';\n var gt = '>';\n var iframeDocument;\n iframe.style.display = 'none';\n\n _html.appendChild(iframe);\n\n iframe.src = 'javascript:'; // eslint-disable-line no-script-url\n // createDict = iframe.contentWindow.Object;\n // html.removeChild(iframe);\n\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);\n iframeDocument.close();\n _createDict = iframeDocument.F;\n\n while (i--) {\n delete _createDict[PROTOTYPE$1][_enumBugKeys[i]];\n }\n\n return _createDict();\n};\n\nvar _objectCreate = Object.create || function create(O, Properties) {\n var result;\n\n if (O !== null) {\n Empty[PROTOTYPE$1] = _anObject(O);\n result = new Empty();\n Empty[PROTOTYPE$1] = null; // add \"__proto__\" for Object.getPrototypeOf polyfill\n\n result[IE_PROTO$1] = O;\n } else result = _createDict();\n\n return Properties === undefined ? result : _objectDps(result, Properties);\n};\n\nvar def = _objectDp.f;\n\nvar TAG = _wks('toStringTag');\n\nvar _setToStringTag = function _setToStringTag(it, tag, stat) {\n if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {\n configurable: true,\n value: tag\n });\n};\n\nvar IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\n\n_hide(IteratorPrototype, _wks('iterator'), function () {\n return this;\n});\n\nvar _iterCreate = function _iterCreate(Constructor, NAME, next) {\n Constructor.prototype = _objectCreate(IteratorPrototype, {\n next: _propertyDesc(1, next)\n });\n\n _setToStringTag(Constructor, NAME + ' Iterator');\n}; // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)\n\n\nvar IE_PROTO$2 = _sharedKey('IE_PROTO');\n\nvar ObjectProto = Object.prototype;\n\nvar _objectGpo = Object.getPrototypeOf || function (O) {\n O = _toObject(O);\n if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];\n\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n }\n\n return O instanceof Object ? ObjectProto : null;\n};\n\nvar ITERATOR = _wks('iterator');\n\nvar BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`\n\nvar FF_ITERATOR = '@@iterator';\nvar KEYS = 'keys';\nvar VALUES = 'values';\n\nvar returnThis = function returnThis() {\n return this;\n};\n\nvar _iterDefine = function _iterDefine(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {\n _iterCreate(Constructor, NAME, next);\n\n var getMethod = function getMethod(kind) {\n if (!BUGGY && kind in proto) return proto[kind];\n\n switch (kind) {\n case KEYS:\n return function keys() {\n return new Constructor(this, kind);\n };\n\n case VALUES:\n return function values() {\n return new Constructor(this, kind);\n };\n }\n\n return function entries() {\n return new Constructor(this, kind);\n };\n };\n\n var TAG = NAME + ' Iterator';\n var DEF_VALUES = DEFAULT == VALUES;\n var VALUES_BUG = false;\n var proto = Base.prototype;\n var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];\n var $default = $native || getMethod(DEFAULT);\n var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;\n var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;\n var methods, key, IteratorPrototype; // Fix native\n\n if ($anyNative) {\n IteratorPrototype = _objectGpo($anyNative.call(new Base()));\n\n if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {\n // Set @@toStringTag to native iterators\n _setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines\n\n\n if (typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);\n }\n } // fix Array#{values, @@iterator}.name in V8 / FF\n\n\n if (DEF_VALUES && $native && $native.name !== VALUES) {\n VALUES_BUG = true;\n\n $default = function values() {\n return $native.call(this);\n };\n } // Define iterator\n\n\n if (BUGGY || VALUES_BUG || !proto[ITERATOR]) {\n _hide(proto, ITERATOR, $default);\n } // Plug for library\n\n\n _iterators[NAME] = $default;\n _iterators[TAG] = returnThis;\n\n if (DEFAULT) {\n methods = {\n values: DEF_VALUES ? $default : getMethod(VALUES),\n keys: IS_SET ? $default : getMethod(KEYS),\n entries: $entries\n };\n if (FORCED) for (key in methods) {\n if (!(key in proto)) _redefine(proto, key, methods[key]);\n } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);\n }\n\n return methods;\n};\n\nvar $at = _stringAt(true); // 21.1.3.27 String.prototype[@@iterator]()\n\n\n_iterDefine(String, 'String', function (iterated) {\n this._t = String(iterated); // target\n\n this._i = 0; // next index\n // 21.1.5.2.1 %StringIteratorPrototype%.next()\n}, function () {\n var O = this._t;\n var index = this._i;\n var point;\n if (index >= O.length) return {\n value: undefined,\n done: true\n };\n point = $at(O, index);\n this._i += point.length;\n return {\n value: point,\n done: false\n };\n}); // call something on iterator step with safe closing on error\n\n\nvar _iterCall = function _iterCall(iterator, fn, value, entries) {\n try {\n return entries ? fn(_anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion)\n } catch (e) {\n var ret = iterator['return'];\n if (ret !== undefined) _anObject(ret.call(iterator));\n throw e;\n }\n}; // check on default Array iterator\n\n\nvar ITERATOR$1 = _wks('iterator');\n\nvar ArrayProto$1 = Array.prototype;\n\nvar _isArrayIter = function _isArrayIter(it) {\n return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR$1] === it);\n};\n\nvar _createProperty = function _createProperty(object, index, value) {\n if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));else object[index] = value;\n}; // getting tag from 19.1.3.6 Object.prototype.toString()\n\n\nvar TAG$1 = _wks('toStringTag'); // ES3 wrong here\n\n\nvar ARG = _cof(function () {\n return arguments;\n}()) == 'Arguments'; // fallback for IE11 Script Access Denied error\n\nvar tryGet = function tryGet(it, key) {\n try {\n return it[key];\n } catch (e) {\n /* empty */\n }\n};\n\nvar _classof = function _classof(it) {\n var O, T, B;\n return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case\n : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T // builtinTag case\n : ARG ? _cof(O) // ES3 arguments fallback\n : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;\n};\n\nvar ITERATOR$2 = _wks('iterator');\n\nvar core_getIteratorMethod = _core.getIteratorMethod = function (it) {\n if (it != undefined) return it[ITERATOR$2] || it['@@iterator'] || _iterators[_classof(it)];\n};\n\nvar ITERATOR$3 = _wks('iterator');\n\nvar SAFE_CLOSING = false;\n\ntry {\n var riter = [7][ITERATOR$3]();\n\n riter['return'] = function () {\n SAFE_CLOSING = true;\n }; // eslint-disable-next-line no-throw-literal\n\n\n Array.from(riter, function () {\n throw 2;\n });\n} catch (e) {\n /* empty */\n}\n\nvar _iterDetect = function _iterDetect(exec, skipClosing) {\n if (!skipClosing && !SAFE_CLOSING) return false;\n var safe = false;\n\n try {\n var arr = [7];\n var iter = arr[ITERATOR$3]();\n\n iter.next = function () {\n return {\n done: safe = true\n };\n };\n\n arr[ITERATOR$3] = function () {\n return iter;\n };\n\n exec(arr);\n } catch (e) {\n /* empty */\n }\n\n return safe;\n};\n\n_export(_export.S + _export.F * !_iterDetect(function (iter) {\n Array.from(iter);\n}), 'Array', {\n // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)\n from: function from(arrayLike\n /* , mapfn = undefined, thisArg = undefined */\n ) {\n var O = _toObject(arrayLike);\n\n var C = typeof this == 'function' ? this : Array;\n var aLen = arguments.length;\n var mapfn = aLen > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var index = 0;\n var iterFn = core_getIteratorMethod(O);\n var length, result, step, iterator;\n if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case\n\n if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {\n for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {\n _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value);\n }\n } else {\n length = _toLength(O.length);\n\n for (result = new C(length); length > index; index++) {\n _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);\n }\n }\n\n result.length = index;\n return result;\n }\n});\n\nvar from_1 = _core.Array.from;\n\nvar Container =\n/** @class */\nfunction () {\n function Container() {}\n /**\n * Register the store instance.\n */\n\n\n Container.register = function (store) {\n this.store = store;\n };\n\n return Container;\n}();\n\nvar install = function install(database, options) {\n if (options === void 0) {\n options = {};\n }\n\n var namespace = options.namespace || 'entities';\n return function (store) {\n database.start(store, namespace);\n Container.register(store);\n };\n};\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\n\n/* global Reflect, Promise */\n\n\nvar _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (b.hasOwnProperty(p)) d[p] = b[p];\n }\n };\n\n return _extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n _extendStatics(d, b);\n\n function __() {\n this.constructor = d;\n }\n\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar _assign = function __assign() {\n _assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n }\n\n return t;\n };\n\n return _assign.apply(this, arguments);\n};\n\nfunction __awaiter(thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n\n function step(result) {\n result.done ? resolve(result.value) : new P(function (resolve) {\n resolve(result.value);\n }).then(fulfilled, rejected);\n }\n\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nfunction __generator(thisArg, body) {\n var _ = {\n label: 0,\n sent: function sent() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n },\n f,\n y,\n t,\n g;\n return g = {\n next: verb(0),\n \"throw\": verb(1),\n \"return\": verb(2)\n }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function () {\n return this;\n }), g;\n\n function verb(n) {\n return function (v) {\n return step([n, v]);\n };\n }\n\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n\n while (_) {\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n\n case 7:\n op = _.ops.pop();\n\n _.trys.pop();\n\n continue;\n\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n\n if (t && _.label < t[2]) {\n _.label = t[2];\n\n _.ops.push(op);\n\n break;\n }\n\n if (t[2]) _.ops.pop();\n\n _.trys.pop();\n\n continue;\n }\n\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n }\n\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\n\nfunction __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) {\n s += arguments[i].length;\n }\n\n for (var r = Array(s), k = 0, i = 0; i < il; i++) {\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {\n r[k] = a[j];\n }\n }\n\n return r;\n}\n/**\n * Check if the given value is the type of array.\n */\n\n\nfunction isArray(value) {\n return Array.isArray(value);\n}\n/**\n * Gets the size of collection by returning its length for array-like values\n * or the number of own enumerable string keyed properties for objects.\n */\n\n\nfunction size(collection) {\n return isArray(collection) ? collection.length : Object.keys(collection).length;\n}\n/**\n * Check if the given array or object is empty.\n */\n\n\nfunction isEmpty(collection) {\n return size(collection) === 0;\n}\n/**\n * Iterates over own enumerable string keyed properties of an object and\n * invokes `iteratee` for each property.\n */\n\n\nfunction forOwn(object, iteratee) {\n Object.keys(object).forEach(function (key) {\n return iteratee(object[key], key, object);\n });\n}\n/**\n * Creates an array of values by running each element in collection thru\n * iteratee. The iteratee is invoked with three arguments:\n * (value, key, collection).\n */\n\n\nfunction map(object, iteratee) {\n var result = [];\n\n for (var key in object) {\n result.push(iteratee(object[key], key, object));\n }\n\n return result;\n}\n/**\n * Creates an object with the same keys as object and values generated by\n * running each own enumerable string keyed property of object thru\n * iteratee. The iteratee is invoked with three arguments:\n * (value, key, object).\n */\n\n\nfunction mapValues(object, iteratee) {\n var newObject = Object.assign({}, object);\n return Object.keys(object).reduce(function (records, key) {\n records[key] = iteratee(object[key], key, object);\n return records;\n }, newObject);\n}\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of collection by the given key.\n */\n\n\nfunction keyBy(collection, key) {\n var o = {};\n collection.forEach(function (item) {\n o[item[key]] = item;\n });\n return o;\n}\n/**\n * Creates an array of elements, sorted in specified order by the results\n * of running each element in a collection thru each iteratee.\n */\n\n\nfunction orderBy(collection, iteratees, directions) {\n var index = -1;\n var result = collection.map(function (value) {\n var criteria = iteratees.map(function (iteratee) {\n return typeof iteratee === 'function' ? iteratee(value) : value[iteratee];\n });\n return {\n criteria: criteria,\n index: ++index,\n value: value\n };\n });\n return baseSortBy(result, function (object, other) {\n return compareMultiple(object, other, directions);\n });\n}\n/**\n * Creates an array of elements, sorted in ascending order by the results of\n * running each element in a collection thru each iteratee. This method\n * performs a stable sort, that is, it preserves the original sort order\n * of equal elements.\n */\n\n\nfunction baseSortBy(array, comparer) {\n var length = array.length;\n array.sort(comparer);\n var newArray = [];\n\n while (length--) {\n newArray[length] = array[length].value;\n }\n\n return newArray;\n}\n/**\n * Used by `orderBy` to compare multiple properties of a value to another\n * and stable sort them.\n *\n * If `orders` is unspecified, all values are sorted in ascending order.\n * Otherwise, specify an order of \"desc\" for descending or \"asc\" for\n * ascending sort order of corresponding values.\n */\n\n\nfunction compareMultiple(object, other, orders) {\n var index = -1;\n var objCriteria = object.criteria;\n var othCriteria = other.criteria;\n var length = objCriteria.length;\n var ordersLength = orders.length;\n\n while (++index < length) {\n var result = compareAscending(objCriteria[index], othCriteria[index]);\n\n if (result) {\n if (index >= ordersLength) {\n return result;\n }\n\n var order = orders[index];\n return result * (order === 'desc' ? -1 : 1);\n }\n }\n\n return object.index - other.index;\n}\n/**\n * Compares values to sort them in ascending order.\n */\n\n\nfunction compareAscending(value, other) {\n if (value !== other) {\n var valIsDefined = value !== undefined;\n var valIsNull = value === null;\n var valIsReflexive = value === value;\n var othIsDefined = other !== undefined;\n var othIsNull = other === null;\n var othIsReflexive = other === other;\n\n if (typeof value !== 'number' || typeof other !== 'number') {\n value = String(value);\n other = String(other);\n }\n\n if (!othIsNull && value > other || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {\n return 1;\n }\n\n if (!valIsNull && value < other || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {\n return -1;\n }\n }\n\n return 0;\n}\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of collection thru iteratee.\n */\n\n\nfunction groupBy(collection, iteratee) {\n return collection.reduce(function (records, record) {\n var key = iteratee(record);\n\n if (records[key] === undefined) {\n records[key] = [];\n }\n\n records[key].push(record);\n return records;\n }, {});\n}\n/**\n * Deep clone the given target object.\n */\n\n\nfunction cloneDeep(target) {\n if (target === null) {\n return target;\n }\n\n if (isArray(target)) {\n var cp_1 = [];\n target.forEach(function (v) {\n return cp_1.push(v);\n });\n return cp_1.map(function (n) {\n return cloneDeep(n);\n });\n }\n\n if (_typeof(target) === 'object' && target !== {}) {\n var cp_2 = _assign({}, target);\n\n Object.keys(cp_2).forEach(function (k) {\n return cp_2[k] = cloneDeep(cp_2[k]);\n });\n return cp_2;\n }\n\n return target;\n}\n\nvar Utils = {\n isArray: isArray,\n size: size,\n isEmpty: isEmpty,\n forOwn: forOwn,\n map: map,\n mapValues: mapValues,\n keyBy: keyBy,\n orderBy: orderBy,\n groupBy: groupBy,\n cloneDeep: cloneDeep\n};\n\nvar Uid =\n/** @class */\nfunction () {\n function Uid() {}\n /**\n * Generate an UUID.\n */\n\n\n Uid.make = function () {\n this.count++;\n return \"\" + this.prefix + this.count;\n };\n /**\n * Reset the count to 0.\n */\n\n\n Uid.reset = function () {\n this.count = 0;\n };\n /**\n * Count to create a unique id.\n */\n\n\n Uid.count = 0;\n /**\n * Prefix string to be used for the id.\n */\n\n Uid.prefix = '$uid';\n return Uid;\n}();\n\nvar Attribute =\n/** @class */\nfunction () {\n /**\n * Create a new attribute instance.\n */\n function Attribute(model) {\n this.model = model;\n }\n\n return Attribute;\n}();\n\nvar Type =\n/** @class */\nfunction (_super) {\n __extends(Type, _super);\n /**\n * Create a new type instance.\n */\n\n\n function Type(model, value, mutator) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n /**\n * Whether if the attribute can accept `null` as a value.\n */\n\n\n _this.isNullable = false;\n _this.value = value;\n _this.mutator = mutator;\n return _this;\n }\n /**\n * Set `isNullable` to be `true`.\n */\n\n\n Type.prototype.nullable = function () {\n this.isNullable = true;\n return this;\n };\n /**\n * Mutate the given value by mutator.\n */\n\n\n Type.prototype.mutate = function (value, key) {\n var mutator = this.mutator || this.model.mutators()[key];\n return mutator ? mutator(value) : value;\n };\n\n return Type;\n}(Attribute);\n\nvar Attr =\n/** @class */\nfunction (_super) {\n __extends(Attr, _super);\n /**\n * Create a new attr instance.\n */\n\n\n function Attr(model, value, mutator) {\n /* istanbul ignore next */\n return _super.call(this, model, value, mutator) || this;\n }\n /**\n * Make value to be set to model property. This method is used when\n * instantiating a model or creating a plain object from a model.\n */\n\n\n Attr.prototype.make = function (value, _parent, key) {\n value = value !== undefined ? value : this.value; // Default Value might be a function (taking no parameter).\n\n var localValue = value;\n\n if (typeof value === 'function') {\n localValue = value();\n }\n\n return this.mutate(localValue, key);\n };\n\n return Attr;\n}(Type);\n\nvar String$1 =\n/** @class */\nfunction (_super) {\n __extends(String, _super);\n /**\n * Create a new string instance.\n */\n\n\n function String(model, value, mutator) {\n /* istanbul ignore next */\n return _super.call(this, model, value, mutator) || this;\n }\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n String.prototype.make = function (value, _parent, key) {\n return this.mutate(this.fix(value), key);\n };\n /**\n * Convert given value to the string.\n */\n\n\n String.prototype.fix = function (value) {\n if (value === undefined) {\n return this.value;\n }\n\n if (typeof value === 'string') {\n return value;\n }\n\n if (value === null && this.isNullable) {\n return value;\n }\n\n return value + '';\n };\n\n return String;\n}(Type);\n\nvar Number =\n/** @class */\nfunction (_super) {\n __extends(Number, _super);\n /**\n * Create a new number instance.\n */\n\n\n function Number(model, value, mutator) {\n /* istanbul ignore next */\n return _super.call(this, model, value, mutator) || this;\n }\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n Number.prototype.make = function (value, _parent, key) {\n return this.mutate(this.fix(value), key);\n };\n /**\n * Transform given data to the number.\n */\n\n\n Number.prototype.fix = function (value) {\n if (value === undefined) {\n return this.value;\n }\n\n if (typeof value === 'number') {\n return value;\n }\n\n if (typeof value === 'string') {\n return parseFloat(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? 1 : 0;\n }\n\n if (value === null && this.isNullable) {\n return value;\n }\n\n return 0;\n };\n\n return Number;\n}(Type);\n\nvar Boolean =\n/** @class */\nfunction (_super) {\n __extends(Boolean, _super);\n /**\n * Create a new number instance.\n */\n\n\n function Boolean(model, value, mutator) {\n /* istanbul ignore next */\n return _super.call(this, model, value, mutator) || this;\n }\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n Boolean.prototype.make = function (value, _parent, key) {\n return this.mutate(this.fix(value), key);\n };\n /**\n * Transform given data to the boolean.\n */\n\n\n Boolean.prototype.fix = function (value) {\n if (value === undefined) {\n return this.value;\n }\n\n if (typeof value === 'boolean') {\n return value;\n }\n\n if (typeof value === 'string') {\n if (value.length === 0) {\n return false;\n }\n\n var _int = parseInt(value, 0);\n\n return isNaN(_int) ? true : !!_int;\n }\n\n if (typeof value === 'number') {\n return !!value;\n }\n\n if (value === null && this.isNullable) {\n return value;\n }\n\n return false;\n };\n\n return Boolean;\n}(Type);\n\nvar Uid$1 =\n/** @class */\nfunction (_super) {\n __extends(Uid$1, _super);\n /**\n * Create a new uid instance.\n */\n\n\n function Uid$1(model, value) {\n /* istanbul ignore next */\n return _super.call(this, model, value) || this;\n }\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n Uid$1.prototype.make = function (value) {\n if (typeof value === 'number' || typeof value === 'string') {\n return value;\n }\n\n if (typeof this.value === 'function') {\n return this.value();\n }\n\n return Uid.make();\n };\n\n return Uid$1;\n}(Type);\n\nvar Relation =\n/** @class */\nfunction (_super) {\n __extends(Relation, _super);\n\n function Relation() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n /**\n * Get relation query instance with constraint attached.\n */\n\n\n Relation.prototype.getRelation = function (query, name, constraints) {\n var relation = query.newQuery(name);\n constraints.forEach(function (constraint) {\n constraint(relation);\n });\n return relation;\n };\n /**\n * Get specified keys from the given collection.\n */\n\n\n Relation.prototype.getKeys = function (collection, key) {\n return collection.reduce(function (models, model) {\n if (model[key] === null || model[key] === undefined) {\n return models;\n }\n\n models.push(model[key]);\n return models;\n }, []);\n };\n /**\n * Create a new indexed map for the single relation by specified key.\n */\n\n\n Relation.prototype.mapSingleRelations = function (collection, key) {\n var relations = new Map();\n collection.forEach(function (record) {\n var id = record[key];\n !relations.get(id) && relations.set(id, record);\n });\n return relations;\n };\n /**\n * Create a new indexed map for the many relation by specified key.\n */\n\n\n Relation.prototype.mapManyRelations = function (collection, key) {\n var relations = new Map();\n collection.forEach(function (record) {\n var id = record[key];\n var ownerKeys = relations.get(id);\n\n if (!ownerKeys) {\n ownerKeys = [];\n relations.set(id, ownerKeys);\n }\n\n ownerKeys.push(record);\n });\n return relations;\n };\n /**\n * Create a new indexed map for relations with order constraints.\n */\n\n\n Relation.prototype.mapRelationsByOrders = function (collection, relations, ownerKey, relationKey) {\n var records = {};\n relations.forEach(function (related, id) {\n collection.filter(function (record) {\n return record[relationKey] === id;\n }).forEach(function (record) {\n var id = record[ownerKey];\n\n if (!records[id]) {\n records[id] = [];\n }\n\n records[id] = records[id].concat(related);\n });\n });\n return records;\n };\n /**\n * Check if the given record is a single relation, which is an object.\n */\n\n\n Relation.prototype.isOneRelation = function (record) {\n if (!isArray(record) && record !== null && _typeof(record) === 'object') {\n return true;\n }\n\n return false;\n };\n /**\n * Check if the given records is a many relation, which is an array\n * of object.\n */\n\n\n Relation.prototype.isManyRelation = function (records) {\n if (!isArray(records)) {\n return false;\n }\n\n if (records.length < 1) {\n return false;\n }\n\n return true;\n };\n /**\n * Wrap the given object into a model instance.\n */\n\n\n Relation.prototype.makeOneRelation = function (record, model) {\n if (!this.isOneRelation(record)) {\n return null;\n }\n\n var relatedModel = model.getModelFromRecord(record) || model;\n return new relatedModel(record);\n };\n /**\n * Wrap the given records into a collection of model instances.\n */\n\n\n Relation.prototype.makeManyRelation = function (records, model) {\n var _this = this;\n\n if (!this.isManyRelation(records)) {\n return [];\n }\n\n return records.filter(function (record) {\n return _this.isOneRelation(record);\n }).map(function (record) {\n var relatedModel = model.getModelFromRecord(record) || model;\n return new relatedModel(record);\n });\n };\n\n return Relation;\n}(Attribute);\n\nvar HasOne =\n/** @class */\nfunction (_super) {\n __extends(HasOne, _super);\n /**\n * Create a new has one instance.\n */\n\n\n function HasOne(model, related, foreignKey, localKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.related = _this.model.relation(related);\n _this.foreignKey = foreignKey;\n _this.localKey = localKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n HasOne.prototype.define = function (schema) {\n return schema.one(this.related);\n };\n /**\n * Attach the relational key to the related data. For example,\n * when User has one Phone, it will attach value to the\n * `user_id` field of Phone record.\n */\n\n\n HasOne.prototype.attach = function (key, record, data) {\n // Check if the record has local key set. If not, set the local key to be\n // the id value. This happens if the user defines the custom local key\n // and didn't include it in the data being normalized.\n if (!record[this.localKey]) {\n record[this.localKey] = this.model.getIndexIdFromRecord(record);\n } // Then set the foreign key of the related record if it exists to be the\n // local key of this record.\n\n\n var related = data[this.related.entity] && data[this.related.entity][key];\n\n if (related) {\n related[this.foreignKey] = record[this.localKey];\n }\n };\n /**\n * Make value to be set to model property. This method is used when\n * instantiating a model or creating a plain object from a model.\n */\n\n\n HasOne.prototype.make = function (value, _parent, _key) {\n return this.makeOneRelation(value, this.related);\n };\n /**\n * Load the has one relationship for the collection.\n */\n\n\n HasOne.prototype.load = function (query, collection, name, constraints) {\n var relation = this.getRelation(query, this.related.entity, constraints);\n this.addEagerConstraints(relation, collection);\n this.match(collection, relation.get(), name);\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n HasOne.prototype.addEagerConstraints = function (relation, collection) {\n relation.whereFk(this.foreignKey, this.getKeys(collection, this.localKey));\n };\n /**\n * Match the eagerly loaded results to their parents.\n */\n\n\n HasOne.prototype.match = function (collection, relations, name) {\n var _this = this;\n\n var dictionary = this.buildDictionary(relations);\n collection.forEach(function (model) {\n var id = model[_this.localKey];\n var relation = dictionary[id];\n model[name] = relation || null;\n });\n };\n /**\n * Build model dictionary keyed by the relation's foreign key.\n */\n\n\n HasOne.prototype.buildDictionary = function (relations) {\n var _this = this;\n\n return relations.reduce(function (dictionary, relation) {\n var key = relation[_this.foreignKey];\n dictionary[key] = relation;\n return dictionary;\n }, {});\n };\n\n return HasOne;\n}(Relation);\n\nvar BelongsTo =\n/** @class */\nfunction (_super) {\n __extends(BelongsTo, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function BelongsTo(model, parent, foreignKey, ownerKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.parent = _this.model.relation(parent);\n _this.foreignKey = foreignKey;\n _this.ownerKey = ownerKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n BelongsTo.prototype.define = function (schema) {\n return schema.one(this.parent);\n };\n /**\n * Attach the relational key to the given data. For example, when Post\n * belongs to User, it will attach value to the `user_id` field of\n * Post record.\n */\n\n\n BelongsTo.prototype.attach = function (key, record, data) {\n // See if the record has the foreign key, if yes, it means the user has\n // provided the key explicitly so do nothing and return.\n if (record[this.foreignKey] !== undefined) {\n return;\n } // If there is no foreign key, let's set it here.\n\n\n record[this.foreignKey] = data[this.parent.entity] && data[this.parent.entity][key] ? data[this.parent.entity][key][this.ownerKey] : key;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n BelongsTo.prototype.make = function (value, _parent, _key) {\n return this.makeOneRelation(value, this.parent);\n };\n /**\n * Load the belongs to relationship for the collection.\n */\n\n\n BelongsTo.prototype.load = function (query, collection, name, constraints) {\n var relation = this.getRelation(query, this.parent.entity, constraints);\n this.addEagerConstraints(relation, collection);\n this.match(collection, relation.get(), name);\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n BelongsTo.prototype.addEagerConstraints = function (relation, collection) {\n relation.whereFk(this.ownerKey, this.getKeys(collection, this.foreignKey));\n };\n /**\n * Match the eagerly loaded results to their parents.\n */\n\n\n BelongsTo.prototype.match = function (collection, relations, name) {\n var _this = this;\n\n var dictionary = this.buildDictionary(relations);\n collection.forEach(function (model) {\n var id = model[_this.foreignKey];\n var relation = id !== null ? dictionary[id] : null;\n model[name] = relation || null;\n });\n };\n /**\n * Build model dictionary keyed by the relation's foreign key.\n */\n\n\n BelongsTo.prototype.buildDictionary = function (relations) {\n var _this = this;\n\n return relations.reduce(function (dictionary, relation) {\n var key = relation[_this.ownerKey];\n dictionary[key] = relation;\n return dictionary;\n }, {});\n };\n\n return BelongsTo;\n}(Relation);\n\nvar HasMany =\n/** @class */\nfunction (_super) {\n __extends(HasMany, _super);\n /**\n * Create a new has many instance.\n */\n\n\n function HasMany(model, related, foreignKey, localKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.related = _this.model.relation(related);\n _this.foreignKey = foreignKey;\n _this.localKey = localKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n HasMany.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given data.\n */\n\n\n HasMany.prototype.attach = function (key, record, data) {\n var _this = this;\n\n key.forEach(function (index) {\n var related = data[_this.related.entity];\n\n if (!related || !related[index] || related[index][_this.foreignKey] !== undefined) {\n return;\n }\n\n related[index][_this.foreignKey] = record[_this.localKey];\n });\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n HasMany.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the has many relationship for the collection.\n */\n\n\n HasMany.prototype.load = function (query, collection, name, constraints) {\n var relation = this.getRelation(query, this.related.entity, constraints);\n this.addEagerConstraints(relation, collection);\n this.match(collection, relation.get(), name);\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n HasMany.prototype.addEagerConstraints = function (relation, collection) {\n relation.whereFk(this.foreignKey, this.getKeys(collection, this.localKey));\n };\n /**\n * Match the eagerly loaded results to their parents.\n */\n\n\n HasMany.prototype.match = function (collection, relations, name) {\n var _this = this;\n\n var dictionary = this.buildDictionary(relations);\n collection.forEach(function (model) {\n var id = model[_this.localKey];\n var relation = dictionary[id];\n model[name] = relation || [];\n });\n };\n /**\n * Build model dictionary keyed by the relation's foreign key.\n */\n\n\n HasMany.prototype.buildDictionary = function (relations) {\n var _this = this;\n\n return relations.reduce(function (dictionary, relation) {\n var key = relation[_this.foreignKey];\n\n if (!dictionary[key]) {\n dictionary[key] = [];\n }\n\n dictionary[key].push(relation);\n return dictionary;\n }, {});\n };\n\n return HasMany;\n}(Relation);\n\nvar HasManyBy =\n/** @class */\nfunction (_super) {\n __extends(HasManyBy, _super);\n /**\n * Create a new has many by instance.\n */\n\n\n function HasManyBy(model, parent, foreignKey, ownerKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.parent = _this.model.relation(parent);\n _this.foreignKey = foreignKey;\n _this.ownerKey = ownerKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n HasManyBy.prototype.define = function (schema) {\n return schema.many(this.parent);\n };\n /**\n * Attach the relational key to the given data.\n */\n\n\n HasManyBy.prototype.attach = function (key, record, _data) {\n var _this = this;\n\n if (key.length === 0) {\n return;\n }\n\n record[this.foreignKey] = key.map(function (parentId) {\n return _this.parent.getIdFromRecord(_data[_this.parent.entity][parentId]);\n });\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n HasManyBy.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.parent);\n };\n /**\n * Load the has many by relationship for the collection.\n */\n\n\n HasManyBy.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.parent.entity, constraints);\n this.addConstraintForHasManyBy(relatedQuery, collection);\n var relations = this.mapSingleRelations(relatedQuery.get(), this.ownerKey);\n collection.forEach(function (item) {\n var related = _this.getRelatedRecords(relations, item[_this.foreignKey]);\n\n item[name] = related;\n });\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n HasManyBy.prototype.addConstraintForHasManyBy = function (query, collection) {\n var _this = this;\n\n var keys = collection.reduce(function (keys, item) {\n return keys.concat(item[_this.foreignKey]);\n }, []);\n query.where(this.ownerKey, keys);\n };\n /**\n * Get related records.\n */\n\n\n HasManyBy.prototype.getRelatedRecords = function (relations, keys) {\n var records = [];\n relations.forEach(function (record, id) {\n if (keys.indexOf(id) !== -1) {\n records.push(record);\n }\n });\n return records;\n };\n\n return HasManyBy;\n}(Relation);\n\nvar HasManyThrough =\n/** @class */\nfunction (_super) {\n __extends(HasManyThrough, _super);\n /**\n * Create a new has many through instance.\n */\n\n\n function HasManyThrough(model, related, through, firstKey, secondKey, localKey, secondLocalKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.related = _this.model.relation(related);\n _this.through = _this.model.relation(through);\n _this.firstKey = firstKey;\n _this.secondKey = secondKey;\n _this.localKey = localKey;\n _this.secondLocalKey = secondLocalKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n HasManyThrough.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given data. Since has many through\n * relationship doesn't have any foreign key, it would do nothing.\n */\n\n\n HasManyThrough.prototype.attach = function (_key, _record, _data) {\n return;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n HasManyThrough.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the has many through relationship for the collection.\n */\n\n\n HasManyThrough.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n var throughQuery = query.newQuery(this.through.entity);\n this.addEagerConstraintForThrough(throughQuery, collection);\n var throughs = throughQuery.get();\n this.addEagerConstraintForRelated(relatedQuery, throughs);\n var relateds = this.mapThroughRelations(throughs, relatedQuery);\n collection.forEach(function (item) {\n var related = relateds[item[_this.localKey]];\n item[name] = related || [];\n });\n };\n /**\n * Set the constraints for the through relation.\n */\n\n\n HasManyThrough.prototype.addEagerConstraintForThrough = function (query, collection) {\n query.where(this.firstKey, this.getKeys(collection, this.localKey));\n };\n /**\n * Set the constraints for the related relation.\n */\n\n\n HasManyThrough.prototype.addEagerConstraintForRelated = function (query, collection) {\n query.where(this.secondKey, this.getKeys(collection, this.secondLocalKey));\n };\n /**\n * Create a new indexed map for the through relation.\n */\n\n\n HasManyThrough.prototype.mapThroughRelations = function (throughs, relatedQuery) {\n var _this = this;\n\n var relations = this.mapManyRelations(relatedQuery.get(), this.secondKey);\n return throughs.reduce(function (records, record) {\n var id = record[_this.firstKey];\n\n if (!records[id]) {\n records[id] = [];\n }\n\n var related = relations.get(record[_this.secondLocalKey]);\n\n if (related === undefined) {\n return records;\n }\n\n records[id] = records[id].concat(related);\n return records;\n }, {});\n };\n\n return HasManyThrough;\n}(Relation);\n\nvar BelongsToMany =\n/** @class */\nfunction (_super) {\n __extends(BelongsToMany, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function BelongsToMany(model, related, pivot, foreignPivotKey, relatedPivotKey, parentKey, relatedKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n /**\n * The key name of the pivot data.\n */\n\n\n _this.pivotKey = 'pivot';\n _this.related = _this.model.relation(related);\n _this.pivot = _this.model.relation(pivot);\n _this.foreignPivotKey = foreignPivotKey;\n _this.relatedPivotKey = relatedPivotKey;\n _this.parentKey = parentKey;\n _this.relatedKey = relatedKey;\n return _this;\n }\n /**\n * Specify the custom pivot accessor to use for the relationship.\n */\n\n\n BelongsToMany.prototype.as = function (accessor) {\n this.pivotKey = accessor;\n return this;\n };\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n BelongsToMany.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given data. Since belongs to many\n * relationship doesn't have any foreign key, it would do nothing.\n */\n\n\n BelongsToMany.prototype.attach = function (_key, _record, _data) {\n return;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n BelongsToMany.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the belongs to relationship for the record.\n */\n\n\n BelongsToMany.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n var pivotQuery = query.newQuery(this.pivot.entity);\n this.addEagerConstraintForPivot(pivotQuery, collection);\n var pivots = pivotQuery.get();\n this.addEagerConstraintForRelated(relatedQuery, pivots);\n var relateds = this.mapPivotRelations(pivots, relatedQuery);\n collection.forEach(function (item) {\n var related = relateds[item[_this.parentKey]];\n item[name] = related || [];\n });\n };\n /**\n * Set the constraints for the pivot relation.\n */\n\n\n BelongsToMany.prototype.addEagerConstraintForPivot = function (query, collection) {\n query.whereFk(this.foreignPivotKey, this.getKeys(collection, this.parentKey));\n };\n /**\n * Set the constraints for the related relation.\n */\n\n\n BelongsToMany.prototype.addEagerConstraintForRelated = function (query, collection) {\n query.whereFk(this.relatedKey, this.getKeys(collection, this.relatedPivotKey));\n };\n /**\n * Create a new indexed map for the pivot relation.\n */\n\n\n BelongsToMany.prototype.mapPivotRelations = function (pivots, relatedQuery) {\n var _this = this;\n\n var relations = this.mapManyRelations(relatedQuery.get(), this.relatedKey);\n\n if (relatedQuery.orders.length) {\n return this.mapRelationsByOrders(pivots, relations, this.foreignPivotKey, this.relatedPivotKey);\n }\n\n return pivots.reduce(function (records, record) {\n var id = record[_this.foreignPivotKey];\n\n if (!records[id]) {\n records[id] = [];\n }\n\n var related = relations.get(record[_this.relatedPivotKey]);\n\n if (related) {\n records[id] = records[id].concat(related.map(function (model) {\n model[_this.pivotKey] = record;\n return model;\n }));\n }\n\n return records;\n }, {});\n };\n /**\n * Create pivot records for the given records if needed.\n */\n\n\n BelongsToMany.prototype.createPivots = function (parent, data, key) {\n var _this = this;\n\n if (!Utils.isArray(this.pivot.primaryKey)) return data;\n Utils.forOwn(data[parent.entity], function (record) {\n var related = record[key];\n\n if (related === undefined || related.length === 0) {\n return;\n }\n\n _this.createPivotRecord(data, record, related);\n });\n return data;\n };\n /**\n * Create a pivot record.\n */\n\n\n BelongsToMany.prototype.createPivotRecord = function (data, record, related) {\n var _this = this;\n\n related.forEach(function (id) {\n var _a, _b;\n\n var parentId = record[_this.parentKey];\n var relatedId = data[_this.related.entity][id][_this.relatedKey];\n var pivotKey = JSON.stringify([_this.pivot.primaryKey[0] === _this.foreignPivotKey ? parentId : relatedId, _this.pivot.primaryKey[1] === _this.foreignPivotKey ? parentId : relatedId]);\n var pivotRecord = data[_this.pivot.entity] ? data[_this.pivot.entity][pivotKey] : {};\n var pivotData = data[_this.related.entity][id][_this.pivotKey] || {};\n data[_this.pivot.entity] = _assign(_assign({}, data[_this.pivot.entity]), (_a = {}, _a[pivotKey] = _assign(_assign(_assign({}, pivotRecord), pivotData), (_b = {\n $id: pivotKey\n }, _b[_this.foreignPivotKey] = parentId, _b[_this.relatedPivotKey] = relatedId, _b)), _a));\n });\n };\n\n return BelongsToMany;\n}(Relation);\n\nvar MorphTo =\n/** @class */\nfunction (_super) {\n __extends(MorphTo, _super);\n /**\n * Create a new morph to instance.\n */\n\n\n function MorphTo(model, id, type) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.id = id;\n _this.type = type;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n MorphTo.prototype.define = function (schema) {\n var _this = this;\n\n return schema.union(function (_value, parentValue) {\n return parentValue[_this.type];\n });\n };\n /**\n * Attach the relational key to the given record. Since morph to\n * relationship doesn't have any foreign key, it would do nothing.\n */\n\n\n MorphTo.prototype.attach = function (_key, _record, _data) {\n return;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n MorphTo.prototype.make = function (value, parent, _key) {\n var related = parent[this.type];\n\n try {\n var model = this.model.relation(related);\n return this.makeOneRelation(value, model);\n } catch (_a) {\n return null;\n }\n };\n /**\n * Load the morph to relationship for the collection.\n */\n\n\n MorphTo.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var types = this.getTypes(collection);\n var relations = types.reduce(function (related, type) {\n var relatedQuery = _this.getRelation(query, type, constraints);\n\n related[type] = _this.mapSingleRelations(relatedQuery.get(), '$id');\n return related;\n }, {});\n collection.forEach(function (item) {\n var id = item[_this.id];\n var type = item[_this.type];\n var related = relations[type].get(String(id));\n item[name] = related || null;\n });\n };\n /**\n * Get all types from the collection.\n */\n\n\n MorphTo.prototype.getTypes = function (collection) {\n var _this = this;\n\n return collection.reduce(function (types, item) {\n var type = item[_this.type];\n !types.includes(type) && types.push(type);\n return types;\n }, []);\n };\n\n return MorphTo;\n}(Relation);\n\nvar MorphOne =\n/** @class */\nfunction (_super) {\n __extends(MorphOne, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function MorphOne(model, related, id, type, localKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.related = _this.model.relation(related);\n _this.id = id;\n _this.type = type;\n _this.localKey = localKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n MorphOne.prototype.define = function (schema) {\n return schema.one(this.related);\n };\n /**\n * Attach the relational key to the given data.\n */\n\n\n MorphOne.prototype.attach = function (key, record, data) {\n var relatedRecord = data[this.related.entity][key];\n relatedRecord[this.id] = relatedRecord[this.id] || this.related.getIdFromRecord(record);\n relatedRecord[this.type] = relatedRecord[this.type] || this.model.entity;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n MorphOne.prototype.make = function (value, _parent, _key) {\n return this.makeOneRelation(value, this.related);\n };\n /**\n * Load the morph many relationship for the record.\n */\n\n\n MorphOne.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n this.addEagerConstraintForMorphOne(relatedQuery, collection, query.entity);\n var relations = this.mapSingleRelations(relatedQuery.get(), this.id);\n collection.forEach(function (item) {\n var related = relations.get(item[_this.localKey]);\n item[name] = related || null;\n });\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n MorphOne.prototype.addEagerConstraintForMorphOne = function (query, collection, type) {\n query.whereFk(this.type, type).whereFk(this.id, this.getKeys(collection, this.localKey));\n };\n\n return MorphOne;\n}(Relation);\n\nvar MorphMany =\n/** @class */\nfunction (_super) {\n __extends(MorphMany, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function MorphMany(model, related, id, type, localKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n\n _this.related = _this.model.relation(related);\n _this.id = id;\n _this.type = type;\n _this.localKey = localKey;\n return _this;\n }\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n MorphMany.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given data.\n */\n\n\n MorphMany.prototype.attach = function (key, record, data) {\n var _this = this;\n\n var relatedItems = data[this.related.entity];\n key.forEach(function (id) {\n var relatedItem = relatedItems[id];\n relatedItem[_this.id] = relatedItem[_this.id] || _this.related.getIdFromRecord(record);\n relatedItem[_this.type] = relatedItem[_this.type] || _this.model.entity;\n });\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n MorphMany.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the morph many relationship for the record.\n */\n\n\n MorphMany.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n this.addEagerConstraintForMorphMany(relatedQuery, collection, query.entity);\n var relations = this.mapManyRelations(relatedQuery.get(), this.id);\n collection.forEach(function (item) {\n var related = relations.get(item[_this.localKey]);\n item[name] = related || [];\n });\n };\n /**\n * Set the constraints for an eager load of the relation.\n */\n\n\n MorphMany.prototype.addEagerConstraintForMorphMany = function (query, collection, type) {\n query.whereFk(this.type, type).whereFk(this.id, this.getKeys(collection, this.localKey));\n };\n\n return MorphMany;\n}(Relation);\n\nvar MorphToMany =\n/** @class */\nfunction (_super) {\n __extends(MorphToMany, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function MorphToMany(model, related, pivot, relatedId, id, type, parentKey, relatedKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n /**\n * The key name of the pivot data.\n */\n\n\n _this.pivotKey = 'pivot';\n _this.related = _this.model.relation(related);\n _this.pivot = _this.model.relation(pivot);\n _this.relatedId = relatedId;\n _this.id = id;\n _this.type = type;\n _this.parentKey = parentKey;\n _this.relatedKey = relatedKey;\n return _this;\n }\n /**\n * Specify the custom pivot accessor to use for the relationship.\n */\n\n\n MorphToMany.prototype.as = function (accessor) {\n this.pivotKey = accessor;\n return this;\n };\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n MorphToMany.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given record. Since morph to many\n * relationship doesn't have any foreign key, it would do nothing.\n */\n\n\n MorphToMany.prototype.attach = function (_key, _record, _data) {\n return;\n };\n /**\n * Convert given value to the appropriate value for the attribute.\n */\n\n\n MorphToMany.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the morph to many relationship for the collection.\n */\n\n\n MorphToMany.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n var pivotQuery = query.newQuery(this.pivot.entity);\n this.addEagerConstraintForPivot(pivotQuery, collection, query.entity);\n var pivots = pivotQuery.get();\n this.addEagerConstraintForRelated(relatedQuery, pivots);\n var relateds = this.mapPivotRelations(pivots, relatedQuery);\n collection.forEach(function (item) {\n var related = relateds[item[_this.parentKey]];\n item[name] = related || [];\n });\n };\n /**\n * Set the constraints for the pivot relation.\n */\n\n\n MorphToMany.prototype.addEagerConstraintForPivot = function (query, collection, type) {\n query.whereFk(this.type, type).whereFk(this.id, this.getKeys(collection, this.parentKey));\n };\n /**\n * Set the constraints for the related relation.\n */\n\n\n MorphToMany.prototype.addEagerConstraintForRelated = function (query, collection) {\n query.whereFk(this.relatedKey, this.getKeys(collection, this.relatedId));\n };\n /**\n * Create a new indexed map for the pivot relation.\n */\n\n\n MorphToMany.prototype.mapPivotRelations = function (pivots, relatedQuery) {\n var _this = this;\n\n var relations = this.mapManyRelations(relatedQuery.get(), this.relatedKey);\n\n if (relatedQuery.orders.length) {\n return this.mapRelationsByOrders(pivots, relations, this.id, this.relatedId);\n }\n\n return pivots.reduce(function (records, record) {\n var id = record[_this.id];\n\n if (!records[id]) {\n records[id] = [];\n }\n\n var related = relations.get(record[_this.relatedId]);\n /* istanbul ignore if */\n\n if (related === undefined || related.length === 0) {\n return records;\n }\n\n records[id] = records[id].concat(related.map(function (model) {\n model[_this.pivotKey] = record;\n return model;\n }));\n return records;\n }, {});\n };\n /**\n * Create pivot records for the given records if needed.\n */\n\n\n MorphToMany.prototype.createPivots = function (parent, data, key) {\n var _this = this;\n\n Utils.forOwn(data[parent.entity], function (record) {\n var relatedIds = parent.query().newQuery(_this.pivot.entity).where(_this.id, record[_this.parentKey]).where(_this.type, parent.entity).get();\n var relateds = (record[key] || []).filter(function (relatedId) {\n return !relatedIds.includes(relatedId);\n });\n\n if (!Utils.isArray(relateds) || relateds.length === 0) {\n return;\n }\n\n _this.createPivotRecord(parent, data, record, relateds);\n });\n return data;\n };\n /**\n * Create a pivot record.\n */\n\n\n MorphToMany.prototype.createPivotRecord = function (parent, data, record, related) {\n var _this = this;\n\n related.forEach(function (id) {\n var _a, _b;\n\n var parentId = record[_this.parentKey];\n var relatedId = data[_this.related.entity][id][_this.relatedKey];\n var pivotKey = parentId + \"_\" + id + \"_\" + parent.entity;\n var pivotData = data[_this.related.entity][id][_this.pivotKey] || {};\n data[_this.pivot.entity] = _assign(_assign({}, data[_this.pivot.entity]), (_a = {}, _a[pivotKey] = _assign(_assign({}, pivotData), (_b = {\n $id: pivotKey\n }, _b[_this.relatedId] = relatedId, _b[_this.id] = parentId, _b[_this.type] = parent.entity, _b)), _a));\n });\n };\n\n return MorphToMany;\n}(Relation);\n\nvar MorphedByMany =\n/** @class */\nfunction (_super) {\n __extends(MorphedByMany, _super);\n /**\n * Create a new belongs to instance.\n */\n\n\n function MorphedByMany(model, related, pivot, relatedId, id, type, parentKey, relatedKey) {\n var _this = _super.call(this, model)\n /* istanbul ignore next */\n || this;\n /**\n * The key name of the pivot data.\n */\n\n\n _this.pivotKey = 'pivot';\n _this.related = _this.model.relation(related);\n _this.pivot = _this.model.relation(pivot);\n _this.relatedId = relatedId;\n _this.id = id;\n _this.type = type;\n _this.parentKey = parentKey;\n _this.relatedKey = relatedKey;\n return _this;\n }\n /**\n * Specify the custom pivot accessor to use for the relationship.\n */\n\n\n MorphedByMany.prototype.as = function (accessor) {\n this.pivotKey = accessor;\n return this;\n };\n /**\n * Define the normalizr schema for the relationship.\n */\n\n\n MorphedByMany.prototype.define = function (schema) {\n return schema.many(this.related);\n };\n /**\n * Attach the relational key to the given data. Since morphed by many\n * relationship doesn't have any foreign key, it would do nothing.\n */\n\n\n MorphedByMany.prototype.attach = function (_key, _record, _data) {\n return;\n };\n /**\n * Make value to be set to model property. This method is used when\n * instantiating a model or creating a plain object from a model.\n */\n\n\n MorphedByMany.prototype.make = function (value, _parent, _key) {\n return this.makeManyRelation(value, this.related);\n };\n /**\n * Load the morph many relationship for the record.\n */\n\n\n MorphedByMany.prototype.load = function (query, collection, name, constraints) {\n var _this = this;\n\n var relatedQuery = this.getRelation(query, this.related.entity, constraints);\n var pivotQuery = query.newQuery(this.pivot.entity);\n this.addEagerConstraintForPivot(pivotQuery, collection, this.related.entity);\n var pivots = pivotQuery.get();\n this.addEagerConstraintForRelated(relatedQuery, pivots);\n var relateds = this.mapPivotRelations(pivots, relatedQuery);\n collection.forEach(function (item) {\n var related = relateds[item[_this.parentKey]];\n item[name] = related || [];\n });\n };\n /**\n * Set the constraints for the pivot relation.\n */\n\n\n MorphedByMany.prototype.addEagerConstraintForPivot = function (query, collection, type) {\n query.whereFk(this.type, type).whereFk(this.relatedId, this.getKeys(collection, this.parentKey));\n };\n /**\n * Set the constraints for the related relation.\n */\n\n\n MorphedByMany.prototype.addEagerConstraintForRelated = function (query, collection) {\n query.whereFk(this.relatedKey, this.getKeys(collection, this.id));\n };\n /**\n * Create a new indexed map for the pivot relation.\n */\n\n\n MorphedByMany.prototype.mapPivotRelations = function (pivots, relatedQuery) {\n var _this = this;\n\n var relations = this.mapManyRelations(relatedQuery.get(), this.relatedKey);\n\n if (relatedQuery.orders.length) {\n return this.mapRelationsByOrders(pivots, relations, this.relatedId, this.id);\n }\n\n return pivots.reduce(function (records, record) {\n var id = record[_this.relatedId];\n\n if (!records[id]) {\n records[id] = [];\n }\n\n var related = relations.get(record[_this.id]);\n /* istanbul ignore if */\n\n if (related === undefined || related.length === 0) {\n return records;\n }\n\n records[id] = records[id].concat(related.map(function (model) {\n model[_this.pivotKey] = record;\n return model;\n }));\n return records;\n }, {});\n };\n /**\n * Create pivot records for the given records if needed.\n */\n\n\n MorphedByMany.prototype.createPivots = function (parent, data, key) {\n var _this = this;\n\n Utils.forOwn(data[parent.entity], function (record) {\n var related = record[key];\n\n if (!Utils.isArray(related)) {\n return;\n }\n\n _this.createPivotRecord(data, record, related);\n });\n return data;\n };\n /**\n * Create a pivot record.\n */\n\n\n MorphedByMany.prototype.createPivotRecord = function (data, record, related) {\n var _this = this;\n\n related.forEach(function (id) {\n var _a, _b;\n\n var parentId = record[_this.parentKey];\n var pivotKey = id + \"_\" + parentId + \"_\" + _this.related.entity;\n var pivotData = data[_this.related.entity][id][_this.pivotKey] || {};\n data[_this.pivot.entity] = _assign(_assign({}, data[_this.pivot.entity]), (_a = {}, _a[pivotKey] = _assign(_assign({}, pivotData), (_b = {\n $id: pivotKey\n }, _b[_this.relatedId] = parentId, _b[_this.id] = _this.model.getIdFromRecord(data[_this.related.entity][id]), _b[_this.type] = _this.related.entity, _b)), _a));\n });\n };\n\n return MorphedByMany;\n}(Relation);\n\nvar defaultOption = {\n relations: true\n};\n/**\n * Serialize the given model to attributes. This method will ignore\n * relationships, and it includes the index id.\n */\n\nfunction toAttributes(model) {\n var record = toJson(model, {\n relations: false\n });\n record.$id = model.$id;\n return record;\n}\n/**\n * Serialize given model POJO.\n */\n\n\nfunction toJson(model, option) {\n if (option === void 0) {\n option = {};\n }\n\n option = _assign(_assign({}, defaultOption), option);\n var record = {};\n var fields = model.$fields();\n\n for (var key in fields) {\n var f = fields[key];\n var v = model[key];\n\n if (f instanceof Relation) {\n record[key] = option.relations ? relation(v) : emptyRelation(v);\n continue;\n }\n\n record[key] = value(model[key]);\n }\n\n return record;\n}\n/**\n * Serialize given value.\n */\n\n\nfunction value(v) {\n if (v === null) {\n return null;\n }\n\n if (isArray(v)) {\n return array(v);\n }\n\n if (_typeof(v) === 'object') {\n return object(v);\n }\n\n return v;\n}\n/**\n * Serialize an array into json.\n */\n\n\nfunction array(a) {\n return a.map(function (v) {\n return value(v);\n });\n}\n/**\n * Serialize an object into json.\n */\n\n\nfunction object(o) {\n var obj = {};\n\n for (var key in o) {\n obj[key] = value(o[key]);\n }\n\n return obj;\n}\n\nfunction relation(relation) {\n if (relation === null) {\n return null;\n }\n\n if (isArray(relation)) {\n return relation.map(function (model) {\n return model.$toJson();\n });\n }\n\n return relation.$toJson();\n}\n\nfunction emptyRelation(relation) {\n return isArray(relation) ? [] : null;\n}\n\nvar Model =\n/** @class */\nfunction () {\n /**\n * Create a new model instance.\n */\n function Model(record) {\n /**\n * The index ID for the model.\n */\n this.$id = null;\n this.$fill(record);\n }\n /**\n * The definition of the fields of the model and its relations.\n */\n\n\n Model.fields = function () {\n return {};\n };\n /**\n * Create an attr attribute.\n */\n\n\n Model.attr = function (value, mutator) {\n return new Attr(this, value, mutator);\n };\n /**\n * Create a string attribute.\n */\n\n\n Model.string = function (value, mutator) {\n return new String$1(this, value, mutator);\n };\n /**\n * Create a number attribute.\n */\n\n\n Model.number = function (value, mutator) {\n return new Number(this, value, mutator);\n };\n /**\n * Create a boolean attribute.\n */\n\n\n Model[\"boolean\"] = function (value, mutator) {\n return new Boolean(this, value, mutator);\n };\n /**\n * Create an uid attribute.\n */\n\n\n Model.uid = function (value) {\n return new Uid$1(this, value);\n };\n /**\n * @deprecated Use `uid` attribute instead.\n */\n\n\n Model.increment = function () {\n /* istanbul ignore next */\n if (process.env.NODE_ENV !== 'production') {\n console.warn('[Vuex ORM] Attribute type `increment` has been deprecated and replaced with `uid`.');\n }\n\n return this.uid();\n };\n /**\n * Create a has one relationship.\n */\n\n\n Model.hasOne = function (related, foreignKey, localKey) {\n return new HasOne(this, related, foreignKey, this.localKey(localKey));\n };\n /**\n * Create a belongs to relationship.\n */\n\n\n Model.belongsTo = function (parent, foreignKey, ownerKey) {\n return new BelongsTo(this, parent, foreignKey, this.relation(parent).localKey(ownerKey));\n };\n /**\n * Create a has many relationship.\n */\n\n\n Model.hasMany = function (related, foreignKey, localKey) {\n return new HasMany(this, related, foreignKey, this.localKey(localKey));\n };\n /**\n * Create a has many by relationship.\n */\n\n\n Model.hasManyBy = function (parent, foreignKey, ownerKey) {\n return new HasManyBy(this, parent, foreignKey, this.relation(parent).localKey(ownerKey));\n };\n /**\n * Create a has many through relationship.\n */\n\n\n Model.hasManyThrough = function (related, through, firstKey, secondKey, localKey, secondLocalKey) {\n return new HasManyThrough(this, related, through, firstKey, secondKey, this.localKey(localKey), this.relation(through).localKey(secondLocalKey));\n };\n /**\n * Create a belongs to many relationship.\n */\n\n\n Model.belongsToMany = function (related, pivot, foreignPivotKey, relatedPivotKey, parentKey, relatedKey) {\n return new BelongsToMany(this, related, pivot, foreignPivotKey, relatedPivotKey, this.localKey(parentKey), this.relation(related).localKey(relatedKey));\n };\n /**\n * Create a morph to relationship.\n */\n\n\n Model.morphTo = function (id, type) {\n return new MorphTo(this, id, type);\n };\n /**\n * Create a morph one relationship.\n */\n\n\n Model.morphOne = function (related, id, type, localKey) {\n return new MorphOne(this, related, id, type, this.localKey(localKey));\n };\n /**\n * Create a morph many relationship.\n */\n\n\n Model.morphMany = function (related, id, type, localKey) {\n return new MorphMany(this, related, id, type, this.localKey(localKey));\n };\n /**\n * Create a morph to many relationship.\n */\n\n\n Model.morphToMany = function (related, pivot, relatedId, id, type, parentKey, relatedKey) {\n return new MorphToMany(this, related, pivot, relatedId, id, type, this.localKey(parentKey), this.relation(related).localKey(relatedKey));\n };\n /**\n * Create a morphed by many relationship.\n */\n\n\n Model.morphedByMany = function (related, pivot, relatedId, id, type, parentKey, relatedKey) {\n return new MorphedByMany(this, related, pivot, relatedId, id, type, this.localKey(parentKey), this.relation(related).localKey(relatedKey));\n };\n /**\n * Mutators to mutate matching fields when instantiating the model.\n */\n\n\n Model.mutators = function () {\n return {};\n };\n /**\n * Types mapping used to dispatch entities based on their discriminator field\n */\n\n\n Model.types = function () {\n return {};\n };\n /**\n * Get the store instance from the container.\n */\n\n\n Model.store = function () {\n return Container.store;\n };\n /**\n * Get the database instance from store.\n */\n\n\n Model.database = function () {\n return this.store().$db();\n };\n /**\n * Create a namespaced method name for Vuex Module from the given\n * method name.\n */\n\n\n Model.namespace = function (method) {\n return this.database().namespace + \"/\" + this.entity + \"/\" + method;\n };\n /**\n * Call Vuex Getters.\n */\n\n\n Model.getters = function (method) {\n return this.store().getters[this.namespace(method)];\n };\n /**\n * Dispatch Vuex Action.\n */\n\n\n Model.dispatch = function (method, payload) {\n return this.store().dispatch(this.namespace(method), payload);\n };\n /**\n * Commit Vuex Mutation.\n */\n\n\n Model.commit = function (callback) {\n this.store().commit(this.database().namespace + \"/$mutate\", {\n entity: this.entity,\n callback: callback\n });\n };\n /**\n * Get the Model schema definition from the cache.\n */\n\n\n Model.getFields = function () {\n if (!this.cachedFields) {\n this.cachedFields = {};\n }\n\n if (this.cachedFields[this.entity]) {\n return this.cachedFields[this.entity];\n }\n\n this.cachedFields[this.entity] = this.fields();\n return this.cachedFields[this.entity];\n };\n /**\n * Get all records.\n */\n\n\n Model.all = function () {\n return this.getters('all')();\n };\n /**\n * Find a record.\n */\n\n\n Model.find = function (id) {\n return this.getters('find')(id);\n };\n /**\n * Get the record of the given array of ids.\n */\n\n\n Model.findIn = function (idList) {\n return this.getters('findIn')(idList);\n };\n /**\n * Get query instance.\n */\n\n\n Model.query = function () {\n return this.getters('query')();\n };\n /**\n * Check wether the associated database contains data.\n */\n\n\n Model.exists = function () {\n return this.query().exists();\n };\n /**\n * Create new data with all fields filled by default values.\n */\n\n\n Model[\"new\"] = function () {\n return this.dispatch('new');\n };\n /**\n * Save given data to the store by replacing all existing records in the\n * store. If you want to save data without replacing existing records,\n * use the `insert` method instead.\n */\n\n\n Model.create = function (payload) {\n return this.dispatch('create', payload);\n };\n /**\n * Insert records.\n */\n\n\n Model.insert = function (payload) {\n return this.dispatch('insert', payload);\n };\n /**\n * Update records.\n */\n\n\n Model.update = function (payload) {\n return this.dispatch('update', payload);\n };\n /**\n * Insert or update records.\n */\n\n\n Model.insertOrUpdate = function (payload) {\n return this.dispatch('insertOrUpdate', payload);\n };\n\n Model[\"delete\"] = function (payload) {\n return this.dispatch('delete', payload);\n };\n /**\n * Delete all records from the store.\n */\n\n\n Model.deleteAll = function () {\n return this.dispatch('deleteAll');\n };\n /**\n * Check if the given key is the primary key. If the model has composite\n * primary key, this method is going to check if the given key is included\n * in the composite key.\n */\n\n\n Model.isPrimaryKey = function (key) {\n if (!Utils.isArray(this.primaryKey)) {\n return this.primaryKey === key;\n }\n\n return this.primaryKey.includes(key);\n };\n /**\n * Check if the primary key is a composite key.\n */\n\n\n Model.isCompositePrimaryKey = function () {\n return Utils.isArray(this.primaryKey);\n };\n /**\n * Get the id (value of primary key) from teh given record. If primary key is\n * not present, or it is invalid primary key value, which is other than\n * `string` or `number`, it's going to return `null`.\n *\n * If the model has composite key, it's going to return array of ids. If any\n * composite key missing, it will return `null`.\n */\n\n\n Model.getIdFromRecord = function (record) {\n var _this = this;\n\n var key = this.primaryKey;\n\n if (typeof key === 'string') {\n return this.getIdFromValue(record[key]);\n }\n\n var ids = key.reduce(function (keys, k) {\n var id = _this.getIdFromValue(record[k]);\n\n id !== null && keys.push(id);\n return keys;\n }, []);\n return ids.length === key.length ? ids : null;\n };\n /**\n * Get correct index id, which is `string` | `number`, from the given value.\n */\n\n\n Model.getIdFromValue = function (value) {\n if (typeof value === 'string' && value !== '') {\n return value;\n }\n\n if (typeof value === 'number') {\n return value;\n }\n\n return null;\n };\n /**\n * Get the index ID value from the given record. An index ID is a value that\n * used as a key for records within the Vuex Store.\n *\n * Most of the time, it's same as the value for the Model's primary key but\n * it's always `string`, even if the primary key value is `number`.\n *\n * If the Model has a composite primary key, each value corresponding to\n * those primary key will be stringified and become a single string value\n * such as `'[1,2]'`.\n *\n * If the primary key is not present at the given record, it returns `null`.\n * For the composite primary key, every key must exist at a given record,\n * or it will return `null`.\n */\n\n\n Model.getIndexIdFromRecord = function (record) {\n var id = this.getIdFromRecord(record);\n\n if (id === null) {\n return null;\n }\n\n if (Utils.isArray(id)) {\n return JSON.stringify(id);\n }\n\n return String(id);\n };\n /**\n * Get local key to pass to the attributes.\n */\n\n\n Model.localKey = function (key) {\n if (key) {\n return key;\n }\n\n return typeof this.primaryKey === 'string' ? this.primaryKey : 'id';\n };\n /**\n * Get the model object that matches the given record type. The method is for\n * getting the correct model object when the model has any inheritance\n * children model.\n *\n * For example, if a User Model have `static types()` declared, and if you\n * pass record with `{ type: 'admin' }`, then the method will likely to\n * return SuperUser class.\n */\n\n\n Model.getModelFromRecord = function (record) {\n // If the given record is already a model instance, return the\n // model object.\n if (record instanceof this) {\n return record.$self();\n } // Else, get the corresponding model for the type value if there's any.\n\n\n return this.getTypeModel(record[this.typeKey]);\n };\n /**\n * Get a model from the container.\n */\n\n\n Model.relation = function (model) {\n if (typeof model !== 'string') {\n return model;\n }\n\n return this.database().model(model);\n };\n /**\n * Get all `belongsToMany` fields from the schema.\n */\n\n\n Model.pivotFields = function () {\n var fields = [];\n Utils.forOwn(this.getFields(), function (field, key) {\n var _a;\n\n if (field instanceof BelongsToMany || field instanceof MorphToMany || field instanceof MorphedByMany) {\n fields.push((_a = {}, _a[key] = field, _a));\n }\n });\n return fields;\n };\n /**\n * Check if fields contains the `belongsToMany` field type.\n */\n\n\n Model.hasPivotFields = function () {\n return this.pivotFields().length > 0;\n };\n /**\n * Check if the current model has a type definition\n */\n\n\n Model.hasTypes = function () {\n return Object.keys(this.types()).length > 0;\n };\n /**\n * Get the model corresponding to the given type name. If it can't be found,\n * it'll return `null`.\n */\n\n\n Model.getTypeModel = function (name) {\n var model = this.types()[name];\n\n if (!model) {\n return null;\n }\n\n return model;\n };\n /**\n * Given a Model, this returns the corresponding key in the InheritanceTypes mapping\n */\n\n\n Model.getTypeKeyValueFromModel = function (model) {\n var modelToCheck = model || this;\n var types = this.types();\n\n for (var type in types) {\n if (types[type].entity === modelToCheck.entity) {\n return type;\n }\n }\n\n return null;\n };\n /**\n * Tries to find a Relation field in all types defined in the InheritanceTypes mapping\n */\n\n\n Model.findRelationInSubTypes = function (relationName) {\n var types = this.types();\n\n for (var type in types) {\n var fields = types[type].getFields();\n\n for (var fieldName in fields) {\n if (fieldName === relationName && fields[fieldName] instanceof Relation) {\n return fields[fieldName];\n }\n }\n }\n\n return null;\n };\n /**\n * Fill any missing fields in the given record with the default value defined\n * in the model schema.\n */\n\n\n Model.hydrate = function (record) {\n return new this(record).$getAttributes();\n };\n /**\n * Get the constructor of this model.\n */\n\n\n Model.prototype.$self = function () {\n return this.constructor;\n };\n /**\n * Get the primary key for the model.\n */\n\n\n Model.prototype.$primaryKey = function () {\n return this.$self().primaryKey;\n };\n /**\n * The definition of the fields of the model and its relations.\n */\n\n\n Model.prototype.$fields = function () {\n return this.$self().getFields();\n };\n /**\n * Set index id.\n */\n\n\n Model.prototype.$setIndexId = function (id) {\n this.$id = id;\n return this;\n };\n /**\n * Get the store instance from the container.\n */\n\n\n Model.prototype.$store = function () {\n return this.$self().store();\n };\n /**\n * Create a namespaced method name for Vuex Module from the given\n * method name.\n */\n\n\n Model.prototype.$namespace = function (method) {\n return this.$self().namespace(method);\n };\n /**\n * Call Vuex Getetrs.\n */\n\n\n Model.prototype.$getters = function (method) {\n return this.$self().getters(method);\n };\n /**\n * Dispatch Vuex Action.\n */\n\n\n Model.prototype.$dispatch = function (method, payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , this.$self().dispatch(method, payload)];\n });\n });\n };\n /**\n * Get all records.\n */\n\n\n Model.prototype.$all = function () {\n return this.$getters('all')();\n };\n /**\n * Find a record.\n */\n\n\n Model.prototype.$find = function (id) {\n return this.$getters('find')(id);\n };\n /**\n * Find record of the given array of ids.\n */\n\n\n Model.prototype.$findIn = function (idList) {\n return this.$getters('findIn')(idList);\n };\n /**\n * Get query instance.\n */\n\n\n Model.prototype.$query = function () {\n return this.$getters('query')();\n };\n /**\n * Create records.\n */\n\n\n Model.prototype.$create = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , this.$dispatch('create', payload)];\n });\n });\n };\n /**\n * Create records.\n */\n\n\n Model.prototype.$insert = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , this.$dispatch('insert', payload)];\n });\n });\n };\n /**\n * Update records.\n */\n\n\n Model.prototype.$update = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n if (Utils.isArray(payload)) {\n return [2\n /*return*/\n , this.$dispatch('update', payload)];\n }\n\n if (payload.where !== undefined) {\n return [2\n /*return*/\n , this.$dispatch('update', payload)];\n }\n\n if (this.$self().getIndexIdFromRecord(payload) === null) {\n return [2\n /*return*/\n , this.$dispatch('update', {\n where: this.$self().getIdFromRecord(this),\n data: payload\n })];\n }\n\n return [2\n /*return*/\n , this.$dispatch('update', payload)];\n });\n });\n };\n /**\n * Insert or update records.\n */\n\n\n Model.prototype.$insertOrUpdate = function (payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , this.$dispatch('insertOrUpdate', payload)];\n });\n });\n };\n /**\n * Save record.\n */\n\n\n Model.prototype.$save = function () {\n return __awaiter(this, void 0, void 0, function () {\n var fields, record, records;\n\n var _this = this;\n\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n fields = this.$self().getFields();\n record = Object.keys(fields).reduce(function (record, key) {\n if (fields[key] instanceof Type) {\n record[key] = _this[key];\n }\n\n return record;\n }, {});\n return [4\n /*yield*/\n , this.$dispatch('insertOrUpdate', {\n data: record\n })];\n\n case 1:\n records = _a.sent();\n this.$fill(records[this.$self().entity][0]);\n return [2\n /*return*/\n , this];\n }\n });\n });\n };\n /**\n * Delete records that matches the given condition.\n */\n\n\n Model.prototype.$delete = function () {\n return __awaiter(this, void 0, void 0, function () {\n var primaryKey;\n\n var _this = this;\n\n return __generator(this, function (_a) {\n primaryKey = this.$primaryKey();\n\n if (!Utils.isArray(primaryKey)) {\n return [2\n /*return*/\n , this.$dispatch('delete', this[primaryKey])];\n }\n\n return [2\n /*return*/\n , this.$dispatch('delete', function (model) {\n return primaryKey.every(function (id) {\n return model[id] === _this[id];\n });\n })];\n });\n });\n };\n /**\n * Delete all records.\n */\n\n\n Model.prototype.$deleteAll = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , this.$dispatch('deleteAll')];\n });\n });\n };\n /**\n * Fill the model instance with the given record. If no record were passed,\n * or if the record has any missing fields, each value of the fields will\n * be filled with its default value defined at model fields definition.\n */\n\n\n Model.prototype.$fill = function (record) {\n if (record === void 0) {\n record = {};\n }\n\n var fields = this.$fields();\n\n for (var key in fields) {\n var field = fields[key];\n var value = record[key];\n this[key] = field.make(value, record, key);\n } // If the record contains index id, set it to the model.\n\n\n record.$id !== undefined && this.$setIndexId(record.$id);\n };\n /**\n * Generate missing primary ids and index id.\n */\n\n\n Model.prototype.$generateId = function () {\n return this.$generatePrimaryId().$generateIndexId();\n };\n /**\n * Generate any missing primary ids.\n */\n\n\n Model.prototype.$generatePrimaryId = function () {\n var _this = this;\n\n var key = this.$self().primaryKey;\n var keys = Utils.isArray(key) ? key : [key];\n keys.forEach(function (k) {\n if (_this[k] === undefined || _this[k] === null) {\n _this[k] = Uid.make();\n }\n });\n return this;\n };\n /**\n * Generate index id from current model attributes.\n */\n\n\n Model.prototype.$generateIndexId = function () {\n return this.$setIndexId(this.$getIndexIdFromAttributes());\n };\n /**\n * Get index id based on current model attributes.\n */\n\n\n Model.prototype.$getIndexIdFromAttributes = function () {\n return this.$self().getIndexIdFromRecord(this);\n };\n /**\n * Get all of the current attributes on the model. It includes index id\n * value as well. This method is mainly used when saving a model to\n * the store.\n */\n\n\n Model.prototype.$getAttributes = function () {\n return toAttributes(this);\n };\n /**\n * Serialize field values into json.\n */\n\n\n Model.prototype.$toJson = function () {\n return toJson(this);\n };\n /**\n * The primary key to be used for the model.\n */\n\n\n Model.primaryKey = 'id';\n /**\n * The discriminator key to be used for the model when inheritance is used\n */\n\n Model.typeKey = 'type';\n /**\n * Vuex Store state definition.\n */\n\n Model.state = {};\n return Model;\n}();\n/**\n * Create a new Query instance.\n */\n\n\nvar query = function query(state, _getters, _rootState, rootGetters) {\n return function () {\n return rootGetters[state.$connection + \"/query\"](state.$name);\n };\n};\n/**\n * Get all data of given entity.\n */\n\n\nvar all = function all(state, _getters, _rootState, rootGetters) {\n return function () {\n return rootGetters[state.$connection + \"/all\"](state.$name);\n };\n};\n/**\n * Find a data of the given entity by given id.\n */\n\n\nvar find = function find(state, _getters, _rootState, rootGetters) {\n return function (id) {\n return rootGetters[state.$connection + \"/find\"](state.$name, id);\n };\n};\n/**\n * Find array of data of the given entity by given ids.\n */\n\n\nvar findIn = function findIn(state, _getters, _rootState, rootGetters) {\n return function (idList) {\n return rootGetters[state.$connection + \"/findIn\"](state.$name, idList);\n };\n};\n\nvar Getters = {\n query: query,\n all: all,\n find: find,\n findIn: findIn\n};\n/**\n * Create new data with all fields filled by default values.\n */\n\nfunction newRecord(context) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/new\", {\n entity: entity\n }, {\n root: true\n })];\n });\n });\n}\n/**\n * Save given data to the store by replacing all existing records in the\n * store. If you want to save data without replacing existing records,\n * use the `insert` method instead.\n */\n\n\nfunction create(context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/create\", _assign(_assign({}, payload), {\n entity: entity\n }), {\n root: true\n })];\n });\n });\n}\n/**\n * Insert given data to the state. Unlike `create`, this method will not\n * remove existing data within the state, but it will update the data\n * with the same primary key.\n */\n\n\nfunction insert(context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/insert\", _assign(_assign({}, payload), {\n entity: entity\n }), {\n root: true\n })];\n });\n });\n}\n/**\n * Update data in the store.\n */\n\n\nfunction update(context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name; // If the payload is an array, then the payload should be an array of\n // data so let's pass the whole payload as data.\n\n if (isArray(payload)) {\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/update\", {\n entity: entity,\n data: payload\n }, {\n root: true\n })];\n } // If the payload doesn't have `data` property, we'll assume that\n // the user has passed the object as the payload so let's define\n // the whole payload as a data.\n\n\n if (payload.data === undefined) {\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/update\", {\n entity: entity,\n data: payload\n }, {\n root: true\n })];\n } // Else destructure the payload and let root action handle it.\n\n\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/update\", _assign({\n entity: entity\n }, payload), {\n root: true\n })];\n });\n });\n}\n/**\n * Insert or update given data to the state. Unlike `insert`, this method\n * will not replace existing data within the state, but it will update only\n * the submitted data with the same primary key.\n */\n\n\nfunction insertOrUpdate(context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/insertOrUpdate\", _assign({\n entity: entity\n }, payload), {\n root: true\n })];\n });\n });\n}\n\nfunction destroy(context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity, where;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n where = payload;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/delete\", {\n entity: entity,\n where: where\n }, {\n root: true\n })];\n });\n });\n}\n/**\n * Delete all data from the store.\n */\n\n\nfunction deleteAll(context) {\n return __awaiter(this, void 0, void 0, function () {\n var state, entity;\n return __generator(this, function (_a) {\n state = context.state;\n entity = state.$name;\n return [2\n /*return*/\n , context.dispatch(state.$connection + \"/deleteAll\", {\n entity: entity\n }, {\n root: true\n })];\n });\n });\n}\n\nvar Actions = {\n \"new\": newRecord,\n create: create,\n insert: insert,\n update: update,\n insertOrUpdate: insertOrUpdate,\n \"delete\": destroy,\n deleteAll: deleteAll\n};\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nfunction _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}\n/**\n * Helpers to enable Immutable compatibility *without* bringing in\n * the 'immutable' package as a dependency.\n */\n\n/**\n * Check if an object is immutable by checking if it has a key specific\n * to the immutable library.\n *\n * @param {any} object\n * @return {bool}\n */\n\n\nfunction isImmutable(object) {\n return !!(object && typeof object.hasOwnProperty === 'function' && (object.hasOwnProperty('__ownerID') || // Immutable.Map\n object._map && object._map.hasOwnProperty('__ownerID'))); // Immutable.Record\n}\n/**\n * Denormalize an immutable entity.\n *\n * @param {Schema} schema\n * @param {Immutable.Map|Immutable.Record} input\n * @param {function} unvisit\n * @param {function} getDenormalizedEntity\n * @return {Immutable.Map|Immutable.Record}\n */\n\n\nfunction denormalizeImmutable(schema, input, unvisit) {\n return Object.keys(schema).reduce(function (object, key) {\n // Immutable maps cast keys to strings on write so we need to ensure\n // we're accessing them using string keys.\n var stringKey = \"\" + key;\n\n if (object.has(stringKey)) {\n return object.set(stringKey, unvisit(object.get(stringKey), schema[stringKey]));\n } else {\n return object;\n }\n }, input);\n}\n\nvar getDefaultGetId = function getDefaultGetId(idAttribute) {\n return function (input) {\n return isImmutable(input) ? input.get(idAttribute) : input[idAttribute];\n };\n};\n\nvar EntitySchema = /*#__PURE__*/function () {\n function EntitySchema(key, definition, options) {\n if (definition === void 0) {\n definition = {};\n }\n\n if (options === void 0) {\n options = {};\n }\n\n if (!key || typeof key !== 'string') {\n throw new Error(\"Expected a string key for Entity, but found \" + key + \".\");\n }\n\n var _options = options,\n _options$idAttribute = _options.idAttribute,\n idAttribute = _options$idAttribute === void 0 ? 'id' : _options$idAttribute,\n _options$mergeStrateg = _options.mergeStrategy,\n mergeStrategy = _options$mergeStrateg === void 0 ? function (entityA, entityB) {\n return _extends({}, entityA, entityB);\n } : _options$mergeStrateg,\n _options$processStrat = _options.processStrategy,\n processStrategy = _options$processStrat === void 0 ? function (input) {\n return _extends({}, input);\n } : _options$processStrat,\n _options$fallbackStra = _options.fallbackStrategy,\n fallbackStrategy = _options$fallbackStra === void 0 ? function (key, schema) {\n return undefined;\n } : _options$fallbackStra;\n this._key = key;\n this._getId = typeof idAttribute === 'function' ? idAttribute : getDefaultGetId(idAttribute);\n this._idAttribute = idAttribute;\n this._mergeStrategy = mergeStrategy;\n this._processStrategy = processStrategy;\n this._fallbackStrategy = fallbackStrategy;\n this.define(definition);\n }\n\n var _proto = EntitySchema.prototype;\n\n _proto.define = function define(definition) {\n this.schema = Object.keys(definition).reduce(function (entitySchema, key) {\n var _extends2;\n\n var schema = definition[key];\n return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema, _extends2));\n }, this.schema || {});\n };\n\n _proto.getId = function getId(input, parent, key) {\n return this._getId(input, parent, key);\n };\n\n _proto.merge = function merge(entityA, entityB) {\n return this._mergeStrategy(entityA, entityB);\n };\n\n _proto.fallback = function fallback(id, schema) {\n return this._fallbackStrategy(id, schema);\n };\n\n _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) {\n var _this = this;\n\n var id = this.getId(input, parent, key);\n var entityType = this.key;\n\n if (!(entityType in visitedEntities)) {\n visitedEntities[entityType] = {};\n }\n\n if (!(id in visitedEntities[entityType])) {\n visitedEntities[entityType][id] = [];\n }\n\n if (visitedEntities[entityType][id].some(function (entity) {\n return entity === input;\n })) {\n return id;\n }\n\n visitedEntities[entityType][id].push(input);\n\n var processedEntity = this._processStrategy(input, parent, key);\n\n Object.keys(this.schema).forEach(function (key) {\n if (processedEntity.hasOwnProperty(key) && _typeof(processedEntity[key]) === 'object') {\n var schema = _this.schema[key];\n var resolvedSchema = typeof schema === 'function' ? schema(input) : schema;\n processedEntity[key] = visit(processedEntity[key], processedEntity, key, resolvedSchema, addEntity, visitedEntities);\n }\n });\n addEntity(this, processedEntity, input, parent, key);\n return id;\n };\n\n _proto.denormalize = function denormalize(entity, unvisit) {\n var _this2 = this;\n\n if (isImmutable(entity)) {\n return denormalizeImmutable(this.schema, entity, unvisit);\n }\n\n Object.keys(this.schema).forEach(function (key) {\n if (entity.hasOwnProperty(key)) {\n var schema = _this2.schema[key];\n entity[key] = unvisit(entity[key], schema);\n }\n });\n return entity;\n };\n\n _createClass(EntitySchema, [{\n key: \"key\",\n get: function get() {\n return this._key;\n }\n }, {\n key: \"idAttribute\",\n get: function get() {\n return this._idAttribute;\n }\n }]);\n\n return EntitySchema;\n}();\n\nvar PolymorphicSchema = /*#__PURE__*/function () {\n function PolymorphicSchema(definition, schemaAttribute) {\n if (schemaAttribute) {\n this._schemaAttribute = typeof schemaAttribute === 'string' ? function (input) {\n return input[schemaAttribute];\n } : schemaAttribute;\n }\n\n this.define(definition);\n }\n\n var _proto = PolymorphicSchema.prototype;\n\n _proto.define = function define(definition) {\n this.schema = definition;\n };\n\n _proto.getSchemaAttribute = function getSchemaAttribute(input, parent, key) {\n return !this.isSingleSchema && this._schemaAttribute(input, parent, key);\n };\n\n _proto.inferSchema = function inferSchema(input, parent, key) {\n if (this.isSingleSchema) {\n return this.schema;\n }\n\n var attr = this.getSchemaAttribute(input, parent, key);\n return this.schema[attr];\n };\n\n _proto.normalizeValue = function normalizeValue(value, parent, key, visit, addEntity, visitedEntities) {\n var schema = this.inferSchema(value, parent, key);\n\n if (!schema) {\n return value;\n }\n\n var normalizedValue = visit(value, parent, key, schema, addEntity, visitedEntities);\n return this.isSingleSchema || normalizedValue === undefined || normalizedValue === null ? normalizedValue : {\n id: normalizedValue,\n schema: this.getSchemaAttribute(value, parent, key)\n };\n };\n\n _proto.denormalizeValue = function denormalizeValue(value, unvisit) {\n var schemaKey = isImmutable(value) ? value.get('schema') : value.schema;\n\n if (!this.isSingleSchema && !schemaKey) {\n return value;\n }\n\n var id = this.isSingleSchema ? undefined : isImmutable(value) ? value.get('id') : value.id;\n var schema = this.isSingleSchema ? this.schema : this.schema[schemaKey];\n return unvisit(id || value, schema);\n };\n\n _createClass(PolymorphicSchema, [{\n key: \"isSingleSchema\",\n get: function get() {\n return !this._schemaAttribute;\n }\n }]);\n\n return PolymorphicSchema;\n}();\n\nvar UnionSchema = /*#__PURE__*/function (_PolymorphicSchema) {\n _inheritsLoose(UnionSchema, _PolymorphicSchema);\n\n function UnionSchema(definition, schemaAttribute) {\n if (!schemaAttribute) {\n throw new Error('Expected option \"schemaAttribute\" not found on UnionSchema.');\n }\n\n return _PolymorphicSchema.call(this, definition, schemaAttribute) || this;\n }\n\n var _proto = UnionSchema.prototype;\n\n _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) {\n return this.normalizeValue(input, parent, key, visit, addEntity, visitedEntities);\n };\n\n _proto.denormalize = function denormalize(input, unvisit) {\n return this.denormalizeValue(input, unvisit);\n };\n\n return UnionSchema;\n}(PolymorphicSchema);\n\nvar ValuesSchema = /*#__PURE__*/function (_PolymorphicSchema) {\n _inheritsLoose(ValuesSchema, _PolymorphicSchema);\n\n function ValuesSchema() {\n return _PolymorphicSchema.apply(this, arguments) || this;\n }\n\n var _proto = ValuesSchema.prototype;\n\n _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) {\n var _this = this;\n\n return Object.keys(input).reduce(function (output, key, index) {\n var _extends2;\n\n var value = input[key];\n return value !== undefined && value !== null ? _extends({}, output, (_extends2 = {}, _extends2[key] = _this.normalizeValue(value, input, key, visit, addEntity, visitedEntities), _extends2)) : output;\n }, {});\n };\n\n _proto.denormalize = function denormalize(input, unvisit) {\n var _this2 = this;\n\n return Object.keys(input).reduce(function (output, key) {\n var _extends3;\n\n var entityOrId = input[key];\n return _extends({}, output, (_extends3 = {}, _extends3[key] = _this2.denormalizeValue(entityOrId, unvisit), _extends3));\n }, {});\n };\n\n return ValuesSchema;\n}(PolymorphicSchema);\n\nvar validateSchema = function validateSchema(definition) {\n var isArray = Array.isArray(definition);\n\n if (isArray && definition.length > 1) {\n throw new Error(\"Expected schema definition to be a single schema, but found \" + definition.length + \".\");\n }\n\n return definition[0];\n};\n\nvar getValues = function getValues(input) {\n return Array.isArray(input) ? input : Object.keys(input).map(function (key) {\n return input[key];\n });\n};\n\nvar normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {\n schema = validateSchema(schema);\n var values = getValues(input); // Special case: Arrays pass *their* parent on to their children, since there\n // is not any special information that can be gathered from themselves directly\n\n return values.map(function (value, index) {\n return visit(value, parent, key, schema, addEntity, visitedEntities);\n });\n};\n\nvar ArraySchema = /*#__PURE__*/function (_PolymorphicSchema) {\n _inheritsLoose(ArraySchema, _PolymorphicSchema);\n\n function ArraySchema() {\n return _PolymorphicSchema.apply(this, arguments) || this;\n }\n\n var _proto = ArraySchema.prototype;\n\n _proto.normalize = function normalize(input, parent, key, visit, addEntity, visitedEntities) {\n var _this = this;\n\n var values = getValues(input);\n return values.map(function (value, index) {\n return _this.normalizeValue(value, parent, key, visit, addEntity, visitedEntities);\n }).filter(function (value) {\n return value !== undefined && value !== null;\n });\n };\n\n _proto.denormalize = function denormalize(input, unvisit) {\n var _this2 = this;\n\n return input && input.map ? input.map(function (value) {\n return _this2.denormalizeValue(value, unvisit);\n }) : input;\n };\n\n return ArraySchema;\n}(PolymorphicSchema);\n\nvar _normalize = function normalize(schema, input, parent, key, visit, addEntity, visitedEntities) {\n var object = _extends({}, input);\n\n Object.keys(schema).forEach(function (key) {\n var localSchema = schema[key];\n var resolvedLocalSchema = typeof localSchema === 'function' ? localSchema(input) : localSchema;\n var value = visit(input[key], input, key, resolvedLocalSchema, addEntity, visitedEntities);\n\n if (value === undefined || value === null) {\n delete object[key];\n } else {\n object[key] = value;\n }\n });\n return object;\n};\n\nvar _denormalize = function denormalize(schema, input, unvisit) {\n if (isImmutable(input)) {\n return denormalizeImmutable(schema, input, unvisit);\n }\n\n var object = _extends({}, input);\n\n Object.keys(schema).forEach(function (key) {\n if (object[key] != null) {\n object[key] = unvisit(object[key], schema[key]);\n }\n });\n return object;\n};\n\nvar ObjectSchema = /*#__PURE__*/function () {\n function ObjectSchema(definition) {\n this.define(definition);\n }\n\n var _proto = ObjectSchema.prototype;\n\n _proto.define = function define(definition) {\n this.schema = Object.keys(definition).reduce(function (entitySchema, key) {\n var _extends2;\n\n var schema = definition[key];\n return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema, _extends2));\n }, this.schema || {});\n };\n\n _proto.normalize = function normalize() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _normalize.apply(void 0, [this.schema].concat(args));\n };\n\n _proto.denormalize = function denormalize() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return _denormalize.apply(void 0, [this.schema].concat(args));\n };\n\n return ObjectSchema;\n}();\n\nvar visit = function visit(value, parent, key, schema, addEntity, visitedEntities) {\n if (_typeof(value) !== 'object' || !value) {\n return value;\n }\n\n if (_typeof(schema) === 'object' && (!schema.normalize || typeof schema.normalize !== 'function')) {\n var method = Array.isArray(schema) ? normalize : _normalize;\n return method(schema, value, parent, key, visit, addEntity, visitedEntities);\n }\n\n return schema.normalize(value, parent, key, visit, addEntity, visitedEntities);\n};\n\nvar addEntities = function addEntities(entities) {\n return function (schema, processedEntity, value, parent, key) {\n var schemaKey = schema.key;\n var id = schema.getId(value, parent, key);\n\n if (!(schemaKey in entities)) {\n entities[schemaKey] = {};\n }\n\n var existingEntity = entities[schemaKey][id];\n\n if (existingEntity) {\n entities[schemaKey][id] = schema.merge(existingEntity, processedEntity);\n } else {\n entities[schemaKey][id] = processedEntity;\n }\n };\n};\n\nvar schema = {\n Array: ArraySchema,\n Entity: EntitySchema,\n Object: ObjectSchema,\n Union: UnionSchema,\n Values: ValuesSchema\n};\n\nvar normalize$1 = function normalize(input, schema) {\n if (!input || _typeof(input) !== 'object') {\n throw new Error(\"Unexpected input given to normalize. Expected type to be \\\"object\\\", found \\\"\" + (input === null ? 'null' : _typeof(input)) + \"\\\".\");\n }\n\n var entities = {};\n var addEntity = addEntities(entities);\n var visitedEntities = {};\n var result = visit(input, input, null, schema, addEntity, visitedEntities);\n return {\n entities: entities,\n result: result\n };\n};\n\nvar Normalizer =\n/** @class */\nfunction () {\n function Normalizer() {}\n /**\n * Normalize the record.\n */\n\n\n Normalizer.process = function (query, record) {\n if (Utils.isEmpty(record)) {\n return {};\n }\n\n var entity = query.database.schemas[query.model.entity];\n var schema = Utils.isArray(record) ? [entity] : entity;\n return normalize$1(record, schema).entities;\n };\n\n return Normalizer;\n}();\n\nvar PivotCreator =\n/** @class */\nfunction () {\n function PivotCreator() {}\n /**\n * Create an intermediate entity if the data contains any entities that\n * require it for example `belongsTo` or `morphMany`.\n */\n\n\n PivotCreator.process = function (query, data) {\n Object.keys(data).forEach(function (entity) {\n var model = query.getModel(entity);\n\n if (model.hasPivotFields()) {\n Utils.forOwn(model.pivotFields(), function (field) {\n Utils.forOwn(field, function (attr, key) {\n attr.createPivots(model, data, key);\n });\n });\n }\n });\n return data;\n };\n\n return PivotCreator;\n}();\n\nvar Attacher =\n/** @class */\nfunction () {\n function Attacher() {}\n /**\n * Attach missing relational key to the records.\n */\n\n\n Attacher.process = function (query, data) {\n Utils.forOwn(data, function (entity, name) {\n var fields = query.getModel(name).fields();\n Utils.forOwn(entity, function (record) {\n Utils.forOwn(record, function (value, key) {\n var field = fields[key];\n\n if (field instanceof Relation) {\n value !== null && field.attach(value, record, data);\n }\n });\n });\n });\n return data;\n };\n\n return Attacher;\n}();\n\nvar Processor =\n/** @class */\nfunction () {\n function Processor() {}\n /**\n * Normalize the given data.\n */\n\n\n Processor.normalize = function (query, record) {\n // First, let's normalize the data.\n var data = Normalizer.process(query, record); // Then, attach any missing foreign keys. For example, if a User has many\n // Post nested but without foreign key such as `user_id`, we can attach\n // the `user_id` value to the Post entities.\n\n data = Attacher.process(query, data); // Now we'll create any missing pivot entities for relationships such as\n // `belongsTo` or `morphMany`.\n\n data = PivotCreator.process(query, data); // And we'll return the result as a normalized data.\n\n return data;\n };\n\n return Processor;\n}();\n\nvar WhereFilter =\n/** @class */\nfunction () {\n function WhereFilter() {}\n /**\n * Filter the given data by registered where clause.\n */\n\n\n WhereFilter.filter = function (query, records) {\n var _this = this;\n\n if (query.wheres.length === 0) {\n return records;\n }\n\n return records.filter(function (record) {\n return _this.check(query, record);\n });\n };\n /**\n * Checks if given Record matches the registered where clause.\n */\n\n\n WhereFilter.check = function (query, record) {\n var whereTypes = Utils.groupBy(query.wheres, function (where) {\n return where[\"boolean\"];\n });\n var comparator = this.getComparator(query, record);\n var results = [];\n whereTypes.and && results.push(whereTypes.and.every(comparator));\n whereTypes.or && results.push(whereTypes.or.some(comparator));\n return results.indexOf(true) !== -1;\n };\n /**\n * Get comparator for the where clause.\n */\n\n\n WhereFilter.getComparator = function (query, record) {\n var _this = this;\n\n return function (where) {\n // Function with Record and Query as argument.\n if (typeof where.field === 'function') {\n var newQuery = new Query(query.store, query.entity);\n\n var result = _this.executeWhereClosure(newQuery, record, where.field);\n\n if (typeof result === 'boolean') {\n return result;\n } // If closure returns undefined, we need to execute the local query.\n\n\n var matchingRecords = newQuery.get(); // And check if current record is part of the result.\n\n return !Utils.isEmpty(matchingRecords.filter(function (rec) {\n return rec['$id'] === record['$id'];\n }));\n } // Function with Record value as argument.\n\n\n if (typeof where.value === 'function') {\n return where.value(record[where.field]);\n } // Check if field value is in given where Array.\n\n\n if (Utils.isArray(where.value)) {\n return where.value.indexOf(record[where.field]) !== -1;\n } // Simple equal check.\n\n\n return record[where.field] === where.value;\n };\n };\n /**\n * Execute where closure.\n */\n\n\n WhereFilter.executeWhereClosure = function (query, record, closure) {\n if (closure.length !== 3) {\n return closure(record, query);\n }\n\n var model = new query.model(record);\n return closure(record, query, model);\n };\n\n return WhereFilter;\n}();\n\nvar OrderByFilter =\n/** @class */\nfunction () {\n function OrderByFilter() {}\n /**\n * Sort the given data by registered orders.\n */\n\n\n OrderByFilter.filter = function (query, records) {\n if (query.orders.length === 0) {\n return records;\n }\n\n var keys = query.orders.map(function (order) {\n return order.key;\n });\n var directions = query.orders.map(function (order) {\n return order.direction;\n });\n return Utils.orderBy(records, keys, directions);\n };\n\n return OrderByFilter;\n}();\n\nvar LimitFilter =\n/** @class */\nfunction () {\n function LimitFilter() {}\n /**\n * Limit the given records by the lmilt and offset.\n */\n\n\n LimitFilter.filter = function (query, records) {\n return records.slice(query.offsetNumber, query.offsetNumber + query.limitNumber);\n };\n\n return LimitFilter;\n}();\n\nvar Filter =\n/** @class */\nfunction () {\n function Filter() {}\n /**\n * Filter the given data by registered where clause.\n */\n\n\n Filter.where = function (query, records) {\n return WhereFilter.filter(query, records);\n };\n /**\n * Sort the given data by registered orders.\n */\n\n\n Filter.orderBy = function (query, records) {\n return OrderByFilter.filter(query, records);\n };\n /**\n * Limit the given records by the lmilt and offset.\n */\n\n\n Filter.limit = function (query, records) {\n return LimitFilter.filter(query, records);\n };\n\n return Filter;\n}();\n\nvar Loader =\n/** @class */\nfunction () {\n function Loader() {}\n /**\n * Set the relationships that should be eager loaded with the query.\n */\n\n\n Loader[\"with\"] = function (query, name, constraint) {\n var _this = this; // If the name of the relation is `*`, we'll load all relationships.\n\n\n if (name === '*') {\n this.withAll(query);\n return;\n } // If we passed an array, we dispatch the bits to with queries.\n\n\n if (isArray(name)) {\n name.forEach(function (relationName) {\n return _this[\"with\"](query, relationName, constraint);\n });\n return;\n } // Else parse relations and set appropriate constraints.\n\n\n this.parseWithRelations(query, name.split('.'), constraint);\n };\n /**\n * Set all relationships to be eager loaded with the query.\n */\n\n\n Loader.withAll = function (query, constraint) {\n if (constraint === void 0) {\n constraint = function constraint() {\n return null;\n };\n }\n\n var fields = query.model.getFields();\n\n for (var field in fields) {\n fields[field] instanceof Relation && this[\"with\"](query, field, constraint);\n }\n };\n /**\n * Set relationships to be recursively eager loaded with the query.\n */\n\n\n Loader.withAllRecursive = function (query, depth) {\n this.withAll(query, function (relatedQuery) {\n depth > 0 && relatedQuery.withAllRecursive(depth - 1);\n });\n };\n /**\n * Set eager load relation and constraint.\n */\n\n\n Loader.setEagerLoad = function (query, name, constraint) {\n if (constraint === void 0) {\n constraint = null;\n }\n\n if (!query.load[name]) {\n query.load[name] = [];\n }\n\n constraint && query.load[name].push(constraint);\n };\n /**\n * Parse a list of relations into individuals.\n */\n\n\n Loader.parseWithRelations = function (query, relations, constraint) {\n var _this = this; // First we'll get the very first relationship from teh whole relations.\n\n\n var relation = relations[0]; // If the first relation has \"or\" syntax which is `|` for example\n // `posts|videos`, set each of them as separate eager load.\n\n relation.split('|').forEach(function (name) {\n // If there's only one relationship in relations array, that means\n // there's no nested relationship. So we'll set the given\n // constraint to the relationship loading.\n if (relations.length === 1) {\n _this.setEagerLoad(query, name, constraint);\n\n return;\n } // Else we'll skip adding constraint because the constraint has to be\n // applied to the nested relationship. We'll let `addNestedWiths`\n // method to handle that later.\n\n\n _this.setEagerLoad(query, name);\n }); // If the given relations only contains a single name, which means it\n // doesn't have any nested relations such as `posts.comments`, we\n // don't need go farther so return here.\n\n if (relations.length === 1) {\n return;\n } // Finally, we shift the first relation from the array and handle lest\n // of relations as a nested relation.\n\n\n relations.shift();\n this.addNestedWiths(query, relation, relations, constraint);\n };\n /**\n * Parse the nested relationships in a relation.\n */\n\n\n Loader.addNestedWiths = function (query, name, children, constraint) {\n this.setEagerLoad(query, name, function (nestedQuery) {\n nestedQuery[\"with\"](children.join('.'), constraint);\n });\n };\n /**\n * Eager load the relationships for the given collection.\n */\n\n\n Loader.eagerLoadRelations = function (query, collection) {\n var fields = query.model.getFields();\n\n for (var name_1 in query.load) {\n var constraints = query.load[name_1];\n var relation = fields[name_1];\n\n if (relation instanceof Relation) {\n relation.load(query, collection, name_1, constraints);\n continue;\n } // If no relation was found on the query, it might be run on the\n // base entity of a hierarchy. In this case, we try looking up\n // the relation on the derived entities\n\n\n if (query.model.hasTypes()) {\n var candidateRelation = query.model.findRelationInSubTypes(name_1);\n\n if (candidateRelation !== null) {\n candidateRelation.load(query, collection, name_1, constraints);\n }\n }\n }\n };\n\n return Loader;\n}();\n\nvar Rollcaller =\n/** @class */\nfunction () {\n function Rollcaller() {}\n /**\n * Set where constraint based on relationship existence.\n */\n\n\n Rollcaller.has = function (query, relation, operator, count) {\n this.setHas(query, relation, 'exists', operator, count);\n };\n /**\n * Set where constraint based on relationship absence.\n */\n\n\n Rollcaller.hasNot = function (query, relation, operator, count) {\n this.setHas(query, relation, 'doesntExist', operator, count);\n };\n /**\n * Add where has condition.\n */\n\n\n Rollcaller.whereHas = function (query, relation, constraint) {\n this.setHas(query, relation, 'exists', undefined, undefined, constraint);\n };\n /**\n * Add where has not condition.\n */\n\n\n Rollcaller.whereHasNot = function (query, relation, constraint) {\n this.setHas(query, relation, 'doesntExist', undefined, undefined, constraint);\n };\n /**\n * Set `has` condition.\n */\n\n\n Rollcaller.setHas = function (query, relation, type, operator, count, constraint) {\n if (operator === void 0) {\n operator = '>=';\n }\n\n if (count === void 0) {\n count = 1;\n }\n\n if (constraint === void 0) {\n constraint = null;\n }\n\n if (typeof operator === 'number') {\n query.have.push({\n relation: relation,\n type: type,\n operator: '>=',\n count: operator,\n constraint: constraint\n });\n return;\n }\n\n query.have.push({\n relation: relation,\n type: type,\n operator: operator,\n count: count,\n constraint: constraint\n });\n };\n /**\n * Convert `has` conditions to where clause. It will check any relationship\n * existence, or absence for the records then set ids of the records that\n * matched the condition to `where` clause.\n *\n * This way, when the query gets executed, only those records that matched\n * the `has` condition get retrieved. In the future, once relationship index\n * mapping is implemented, we can simply do all checks inside the where\n * filter since we can treat `has` condition as usual `where` condition.\n *\n * For now, since we must fetch any relationship by eager loading them, due\n * to performance concern, we'll apply `has` conditions this way to gain\n * maximum performance.\n */\n\n\n Rollcaller.applyConstraints = function (query) {\n if (query.have.length === 0) {\n return;\n }\n\n var newQuery = query.newQuery();\n this.addHasWhereConstraints(query, newQuery);\n this.addHasConstraints(query, newQuery.get());\n };\n /**\n * Add has constraints to the given query. It's going to set all relationship\n * as `with` alongside with its closure constraints.\n */\n\n\n Rollcaller.addHasWhereConstraints = function (query, newQuery) {\n query.have.forEach(function (constraint) {\n newQuery[\"with\"](constraint.relation, constraint.constraint);\n });\n };\n /**\n * Add has constraints as where clause.\n */\n\n\n Rollcaller.addHasConstraints = function (query, collection) {\n var comparators = this.getComparators(query);\n var ids = [];\n collection.forEach(function (model) {\n if (comparators.every(function (comparator) {\n return comparator(model);\n })) {\n ids.push(model.$self().getIdFromRecord(model));\n }\n });\n query.whereIdIn(ids);\n };\n /**\n * Get comparators for the has clause.\n */\n\n\n Rollcaller.getComparators = function (query) {\n var _this = this;\n\n return query.have.map(function (constraint) {\n return _this.getComparator(constraint);\n });\n };\n /**\n * Get a comparator for the has clause.\n */\n\n\n Rollcaller.getComparator = function (constraint) {\n var _this = this;\n\n var compare = this.getCountComparator(constraint.operator);\n return function (model) {\n var count = _this.getRelationshipCount(model[constraint.relation]);\n\n var result = compare(count, constraint.count);\n return constraint.type === 'exists' ? result : !result;\n };\n };\n /**\n * Get count of the relationship.\n */\n\n\n Rollcaller.getRelationshipCount = function (relation) {\n if (isArray(relation)) {\n return relation.length;\n }\n\n return relation ? 1 : 0;\n };\n /**\n * Get comparator function for the `has` clause.\n */\n\n\n Rollcaller.getCountComparator = function (operator) {\n switch (operator) {\n case '=':\n return function (x, y) {\n return x === y;\n };\n\n case '>':\n return function (x, y) {\n return x > y;\n };\n\n case '>=':\n return function (x, y) {\n return x >= y;\n };\n\n case '<':\n return function (x, y) {\n return x > 0 && x < y;\n };\n\n case '<=':\n return function (x, y) {\n return x > 0 && x <= y;\n };\n\n default:\n return function (x, y) {\n return x === y;\n };\n }\n };\n\n return Rollcaller;\n}();\n\nvar Query =\n/** @class */\nfunction () {\n /**\n * Create a new Query instance.\n */\n function Query(store, entity) {\n /**\n * This flag lets us know if current Query instance applies to\n * a base class or not (in order to know when to filter out\n * some records).\n */\n this.appliedOnBase = true;\n /**\n * Primary key ids to filter records by. It is used for filtering records\n * direct key lookup when a user is trying to fetch records by its\n * primary key.\n *\n * It should not be used if there is a logic which prevents index usage, for\n * example, an \"or\" condition which already requires a full scan of records.\n */\n\n this.idFilter = null;\n /**\n * Whether to use `idFilter` key lookup. True if there is a logic which\n * prevents index usage, for example, an \"or\" condition which already\n * requires full scan.\n */\n\n this.cancelIdFilter = false;\n /**\n * Primary key ids to filter joined records. It is used for filtering\n * records direct key lookup. It should not be cancelled, because it\n * is free from the effects of normal where methods.\n */\n\n this.joinedIdFilter = null;\n /**\n * The where constraints for the query.\n */\n\n this.wheres = [];\n /**\n * The has constraints for the query.\n */\n\n this.have = [];\n /**\n * The orders of the query result.\n */\n\n this.orders = [];\n /**\n * Number of results to skip.\n */\n\n this.offsetNumber = 0;\n /**\n * Maximum number of records to return.\n *\n * We use polyfill of `Number.MAX_SAFE_INTEGER` for IE11 here.\n */\n\n this.limitNumber = Math.pow(2, 53) - 1;\n /**\n * The relationships that should be eager loaded with the result.\n */\n\n this.load = {};\n this.store = store;\n this.database = store.$db();\n this.model = this.getModel(entity);\n this.baseModel = this.getBaseModel(entity);\n this.entity = entity;\n this.baseEntity = this.baseModel.entity;\n this.rootState = this.database.getState();\n this.state = this.rootState[this.baseEntity];\n this.appliedOnBase = this.baseEntity === this.entity;\n }\n /**\n * Delete all records from the store.\n */\n\n\n Query.deleteAll = function (store) {\n var database = store.$db();\n var models = database.models();\n\n for (var entity in models) {\n var state = database.getState()[entity];\n state && new this(store, entity).deleteAll();\n }\n };\n /**\n * Register a global hook. It will return ID for the hook that users may use\n * it to unregister hooks.\n */\n\n\n Query.on = function (on, callback) {\n var id = ++this.lastHookId;\n\n if (!this.hooks[on]) {\n this.hooks[on] = [];\n }\n\n this.hooks[on].push({\n id: id,\n callback: callback\n });\n return id;\n };\n /**\n * Unregister global hook with the given id.\n */\n\n\n Query.off = function (id) {\n var _this = this;\n\n return Object.keys(this.hooks).some(function (on) {\n var hooks = _this.hooks[on];\n var index = hooks.findIndex(function (h) {\n return h.id === id;\n });\n\n if (index === -1) {\n return false;\n }\n\n hooks.splice(index, 1);\n return true;\n });\n };\n /**\n * Get query class.\n */\n\n\n Query.prototype.self = function () {\n return this.constructor;\n };\n /**\n * Create a new query instance.\n */\n\n\n Query.prototype.newQuery = function (entity) {\n entity = entity || this.entity;\n return new Query(this.store, entity);\n };\n /**\n * Get model of given name from the container.\n */\n\n\n Query.prototype.getModel = function (name) {\n var entity = name || this.entity;\n return this.database.model(entity);\n };\n /**\n * Get all models from the container.\n */\n\n\n Query.prototype.getModels = function () {\n return this.database.models();\n };\n /**\n * Get base model of given name from the container.\n */\n\n\n Query.prototype.getBaseModel = function (name) {\n return this.database.baseModel(name);\n };\n /**\n * Returns all record of the query chain result. This method is alias\n * of the `get` method.\n */\n\n\n Query.prototype.all = function () {\n return this.get();\n };\n /**\n * Find the record by the given id.\n */\n\n\n Query.prototype.find = function (value) {\n var record = this.state.data[this.normalizeIndexId(value)];\n\n if (!record) {\n return null;\n }\n\n return this.item(this.hydrate(record));\n };\n /**\n * Get the record of the given array of ids.\n */\n\n\n Query.prototype.findIn = function (values) {\n var _this = this;\n\n if (!Utils.isArray(values)) {\n return [];\n }\n\n var records = values.reduce(function (collection, value) {\n var record = _this.state.data[_this.normalizeIndexId(value)];\n\n if (!record) {\n return collection;\n }\n\n collection.push(_this.hydrate(record));\n return collection;\n }, []);\n return this.collect(records);\n };\n /**\n * Returns all record of the query chain result.\n */\n\n\n Query.prototype.get = function () {\n var records = this.select();\n return this.collect(records);\n };\n /**\n * Returns the first record of the query chain result.\n */\n\n\n Query.prototype.first = function () {\n var records = this.select();\n\n if (records.length === 0) {\n return null;\n }\n\n return this.item(this.hydrate(records[0]));\n };\n /**\n * Returns the last record of the query chain result.\n */\n\n\n Query.prototype.last = function () {\n var records = this.select();\n\n if (records.length === 0) {\n return null;\n }\n\n return this.item(this.hydrate(records[records.length - 1]));\n };\n /**\n * Checks whether a result of the query chain exists.\n */\n\n\n Query.prototype.exists = function () {\n var records = this.select();\n return records.length > 0;\n };\n /**\n * Add a and where clause to the query.\n */\n\n\n Query.prototype.where = function (field, value) {\n if (this.isIdfilterable(field)) {\n this.setIdFilter(value);\n }\n\n this.wheres.push({\n field: field,\n value: value,\n \"boolean\": 'and'\n });\n return this;\n };\n /**\n * Add a or where clause to the query.\n */\n\n\n Query.prototype.orWhere = function (field, value) {\n // Cancel id filter usage, since \"or\" needs full scan.\n this.cancelIdFilter = true;\n this.wheres.push({\n field: field,\n value: value,\n \"boolean\": 'or'\n });\n return this;\n };\n /**\n * Filter records by their primary key.\n */\n\n\n Query.prototype.whereId = function (value) {\n if (this.model.isCompositePrimaryKey()) {\n return this.where('$id', this.normalizeIndexId(value));\n }\n\n return this.where(this.model.primaryKey, value);\n };\n /**\n * Filter records by their primary keys.\n */\n\n\n Query.prototype.whereIdIn = function (values) {\n var _this = this;\n\n if (this.model.isCompositePrimaryKey()) {\n var idList = values.reduce(function (keys, value) {\n return __spreadArrays(keys, [_this.normalizeIndexId(value)]);\n }, []);\n return this.where('$id', idList);\n }\n\n return this.where(this.model.primaryKey, values);\n };\n /**\n * Fast comparison for foreign keys. If the foreign key is the primary key,\n * it uses object lookup, fallback normal where otherwise.\n *\n * Why separate `whereFk` instead of just `where`? Additional logic needed\n * for the distinction between where and orWhere in normal queries, but\n * Fk lookups are always \"and\" type.\n */\n\n\n Query.prototype.whereFk = function (field, value) {\n var values = Utils.isArray(value) ? value : [value]; // If lookup filed is the primary key. Initialize or get intersection,\n // because boolean and could have a condition such as\n // `whereId(1).whereId(2).get()`.\n\n if (field === this.model.primaryKey) {\n this.setJoinedIdFilter(values);\n return this;\n } // Else fallback to normal where.\n\n\n this.where(field, values);\n return this;\n };\n /**\n * Convert value to string for composite primary keys as it expects an array.\n * Otherwise return as is.\n *\n * Throws an error when malformed value is given:\n * - Composite primary key defined on model, expects value to be array.\n * - Normal primary key defined on model, expects a primitive value.\n */\n\n\n Query.prototype.normalizeIndexId = function (value) {\n if (this.model.isCompositePrimaryKey()) {\n if (!Utils.isArray(value)) {\n throw new Error('[Vuex ORM] Entity `' + this.entity + '` is configured with a composite ' + 'primary key and expects an array value but instead received: ' + JSON.stringify(value));\n }\n\n return JSON.stringify(value);\n }\n\n if (Utils.isArray(value)) {\n throw new Error('[Vuex ORM] Entity `' + this.entity + '` expects a single value but ' + 'instead received: ' + JSON.stringify(value));\n }\n\n return value;\n };\n /**\n * Check whether the given field is filterable through primary key\n * direct look up.\n */\n\n\n Query.prototype.isIdfilterable = function (field) {\n return (field === this.model.primaryKey || field === '$id') && !this.cancelIdFilter;\n };\n /**\n * Set id filter for the given where condition.\n */\n\n\n Query.prototype.setIdFilter = function (value) {\n var _this = this;\n\n var values = Utils.isArray(value) ? value : [value]; // Initialize or get intersection, because boolean and could have a\n // condition such as `whereIdIn([1,2,3]).whereIdIn([1,2]).get()`.\n\n if (this.idFilter === null) {\n this.idFilter = new Set(values);\n return;\n }\n\n this.idFilter = new Set(values.filter(function (v) {\n return _this.idFilter.has(v);\n }));\n };\n /**\n * Set joined id filter for the given where condition.\n */\n\n\n Query.prototype.setJoinedIdFilter = function (values) {\n var _this = this; // Initialize or get intersection, because boolean and could have a\n // condition such as `whereId(1).whereId(2).get()`.\n\n\n if (this.joinedIdFilter === null) {\n this.joinedIdFilter = new Set(values);\n return;\n }\n\n this.joinedIdFilter = new Set(values.filter(function (v) {\n return _this.joinedIdFilter.has(v);\n }));\n };\n /**\n * Add an order to the query.\n */\n\n\n Query.prototype.orderBy = function (key, direction) {\n if (direction === void 0) {\n direction = 'asc';\n }\n\n this.orders.push({\n key: key,\n direction: direction\n });\n return this;\n };\n /**\n * Add an offset to the query.\n */\n\n\n Query.prototype.offset = function (offset) {\n this.offsetNumber = offset;\n return this;\n };\n /**\n * Add limit to the query.\n */\n\n\n Query.prototype.limit = function (limit) {\n this.limitNumber = limit;\n return this;\n };\n /**\n * Set the relationships that should be loaded.\n */\n\n\n Query.prototype[\"with\"] = function (name, constraint) {\n if (constraint === void 0) {\n constraint = null;\n }\n\n Loader[\"with\"](this, name, constraint);\n return this;\n };\n /**\n * Query all relations.\n */\n\n\n Query.prototype.withAll = function () {\n Loader.withAll(this);\n return this;\n };\n /**\n * Query all relations recursively.\n */\n\n\n Query.prototype.withAllRecursive = function (depth) {\n if (depth === void 0) {\n depth = 3;\n }\n\n Loader.withAllRecursive(this, depth);\n return this;\n };\n /**\n * Set where constraint based on relationship existence.\n */\n\n\n Query.prototype.has = function (relation, operator, count) {\n Rollcaller.has(this, relation, operator, count);\n return this;\n };\n /**\n * Set where constraint based on relationship absence.\n */\n\n\n Query.prototype.hasNot = function (relation, operator, count) {\n Rollcaller.hasNot(this, relation, operator, count);\n return this;\n };\n /**\n * Add where has condition.\n */\n\n\n Query.prototype.whereHas = function (relation, constraint) {\n Rollcaller.whereHas(this, relation, constraint);\n return this;\n };\n /**\n * Add where has not condition.\n */\n\n\n Query.prototype.whereHasNot = function (relation, constraint) {\n Rollcaller.whereHasNot(this, relation, constraint);\n return this;\n };\n /**\n * Get all records from the state and convert them into the array of\n * model instances.\n */\n\n\n Query.prototype.records = function () {\n var _this = this;\n\n this.finalizeIdFilter();\n return this.getIdsToLookup().reduce(function (models, id) {\n var record = _this.state.data[id];\n\n if (!record) {\n return models;\n }\n\n var model = _this.hydrate(record); // Ignore if the model is not current type of model.\n\n\n if (!_this.appliedOnBase && !(_this.model.entity === model.$self().entity)) {\n return models;\n }\n\n models.push(model);\n return models;\n }, []);\n };\n /**\n * Check whether if id filters should on select. If not, clear out id filter.\n */\n\n\n Query.prototype.finalizeIdFilter = function () {\n if (!this.cancelIdFilter || this.idFilter === null) {\n return;\n }\n\n this.where(this.model.isCompositePrimaryKey() ? '$id' : this.model.primaryKey, Array.from(this.idFilter.values()));\n this.idFilter = null;\n };\n /**\n * Get a list of id that should be used to lookup when fetching records\n * from the state.\n */\n\n\n Query.prototype.getIdsToLookup = function () {\n var _this = this; // If both id filter and joined id filter are set, intersect them.\n\n\n if (this.idFilter && this.joinedIdFilter) {\n return Array.from(this.idFilter.values()).filter(function (id) {\n return _this.joinedIdFilter.has(id);\n });\n } // If only either one is set, return which one is set.\n\n\n if (this.idFilter || this.joinedIdFilter) {\n return Array.from((this.idFilter || this.joinedIdFilter).values());\n } // If none is set, return all keys.\n\n\n return Object.keys(this.state.data);\n };\n /**\n * Process the query and filter data.\n */\n\n\n Query.prototype.select = function () {\n // At first, well apply any `has` condition to the query.\n Rollcaller.applyConstraints(this); // Next, get all record as an array and then start filtering it through.\n\n var records = this.records(); // Process `beforeSelect` hook.\n\n records = this.executeSelectHook('beforeSelect', records); // Let's filter the records at first by the where clauses.\n\n records = this.filterWhere(records); // Process `afterWhere` hook.\n\n records = this.executeSelectHook('afterWhere', records); // Next, lets sort the data.\n\n records = this.filterOrderBy(records); // Process `afterOrderBy` hook.\n\n records = this.executeSelectHook('afterOrderBy', records); // Finally, slice the record by limit and offset.\n\n records = this.filterLimit(records); // Process `afterLimit` hook.\n\n records = this.executeSelectHook('afterLimit', records);\n return records;\n };\n /**\n * Filter the given data by registered where clause.\n */\n\n\n Query.prototype.filterWhere = function (records) {\n return Filter.where(this, records);\n };\n /**\n * Sort the given data by registered orders.\n */\n\n\n Query.prototype.filterOrderBy = function (records) {\n return Filter.orderBy(this, records);\n };\n /**\n * Limit the given records by the limit and offset.\n */\n\n\n Query.prototype.filterLimit = function (records) {\n return Filter.limit(this, records);\n };\n /**\n * Get the count of the retrieved data.\n */\n\n\n Query.prototype.count = function () {\n return this.get().length;\n };\n /**\n * Get the max value of the specified filed.\n */\n\n\n Query.prototype.max = function (field) {\n var numbers = this.get().reduce(function (numbers, item) {\n if (typeof item[field] === 'number') {\n numbers.push(item[field]);\n }\n\n return numbers;\n }, []);\n return numbers.length === 0 ? 0 : Math.max.apply(Math, numbers);\n };\n /**\n * Get the min value of the specified filed.\n */\n\n\n Query.prototype.min = function (field) {\n var numbers = this.get().reduce(function (numbers, item) {\n if (typeof item[field] === 'number') {\n numbers.push(item[field]);\n }\n\n return numbers;\n }, []);\n return numbers.length === 0 ? 0 : Math.min.apply(Math, numbers);\n };\n /**\n * Get the sum value of the specified filed.\n */\n\n\n Query.prototype.sum = function (field) {\n return this.get().reduce(function (sum, item) {\n if (typeof item[field] === 'number') {\n sum += item[field];\n }\n\n return sum;\n }, 0);\n };\n /**\n * Create a item from given record.\n */\n\n\n Query.prototype.item = function (item) {\n if (Object.keys(this.load).length > 0) {\n Loader.eagerLoadRelations(this, [item]);\n }\n\n return item;\n };\n /**\n * Create a collection (array) from given records.\n */\n\n\n Query.prototype.collect = function (collection) {\n var _this = this;\n\n if (collection.length < 1) {\n return [];\n }\n\n if (Object.keys(this.load).length > 0) {\n collection = collection.map(function (item) {\n var model = _this.model.getModelFromRecord(item);\n\n return new model(item);\n });\n Loader.eagerLoadRelations(this, collection);\n }\n\n return collection;\n };\n /**\n * Create new data with all fields filled by default values.\n */\n\n\n Query.prototype[\"new\"] = function () {\n var model = new this.model().$generateId();\n this.commitInsert(model.$getAttributes());\n return model;\n };\n /**\n * Save given data to the store by replacing all existing records in the\n * store. If you want to save data without replacing existing records,\n * use the `insert` method instead.\n */\n\n\n Query.prototype.create = function (data, options) {\n return this.persist('create', data, options);\n };\n /**\n * Create records to the state.\n */\n\n\n Query.prototype.createRecords = function (records) {\n this.deleteAll();\n return this.insertRecords(records);\n };\n /**\n * Insert given data to the store. Unlike `create`, this method will not\n * remove existing data within the store, but it will update the data\n * with the same primary key.\n */\n\n\n Query.prototype.insert = function (data, options) {\n return this.persist('insert', data, options);\n };\n /**\n * Insert records to the store.\n */\n\n\n Query.prototype.insertRecords = function (records) {\n var collection = this.mapHydrateRecords(records);\n collection = this.executeMutationHooks('beforeCreate', collection);\n this.commitInsertRecords(this.convertCollectionToRecords(collection));\n this.executeMutationHooks('afterCreate', collection);\n return collection;\n };\n /**\n * Update data in the state.\n */\n\n\n Query.prototype.update = function (data, condition, options) {\n // If the data is array, simply normalize the data and update them.\n if (Utils.isArray(data)) {\n return this.persist('update', data, options);\n } // OK, the data is not an array. Now let's check `data` to see what we can\n // do if it's a closure.\n\n\n if (typeof data === 'function') {\n // If the data is closure, but if there's no condition, we wouldn't know\n // what record to update so raise an error and abort.\n if (!condition) {\n throw new Error('You must specify `where` to update records by specifying `data` as a closure.');\n } // If the condition is a closure, then update records by the closure.\n\n\n if (typeof condition === 'function') {\n return this.updateByCondition(data, condition);\n } // Else the condition is either String or Number, so let's\n // update the record by ID.\n\n\n return this.updateById(data, condition);\n } // Now the data is not a closure, and it's not an array, so it should be an object.\n // If the condition is closure, we can't normalize the data so let's update\n // records using the closure.\n\n\n if (typeof condition === 'function') {\n return this.updateByCondition(data, condition);\n } // If there's no condition, let's normalize the data and update them.\n\n\n if (!condition) {\n return this.persist('update', data, options);\n } // Now since the condition is either String or Number, let's check if the\n // model's primary key is not a composite key. If yes, we can't set the\n // condition as ID value for the record so throw an error and abort.\n\n\n if (this.model.isCompositePrimaryKey() && !Utils.isArray(condition)) {\n throw new Error('[Vuex ORM] You can\\'t specify `where` value as `string` or `number` ' + 'when you have a composite key defined in your model. Please include ' + 'composite keys to the `data` fields.');\n } // Finally, let's add condition as the primary key of the object and\n // then normalize them to update the records.\n\n\n return this.updateById(data, condition);\n };\n /**\n * Update all records.\n */\n\n\n Query.prototype.updateRecords = function (records) {\n var models = this.hydrateRecordsByMerging(records);\n return this.performUpdate(models);\n };\n /**\n * Update the state by id.\n */\n\n\n Query.prototype.updateById = function (data, id) {\n var _a;\n\n id = typeof id === 'number' ? id.toString() : this.normalizeIndexId(id);\n var record = this.state.data[id];\n\n if (!record) {\n return null;\n }\n\n var model = this.hydrate(record);\n var instances = (_a = {}, _a[id] = this.processUpdate(data, model), _a);\n this.performUpdate(instances);\n return instances[id];\n };\n /**\n * Update the state by condition.\n */\n\n\n Query.prototype.updateByCondition = function (data, condition) {\n var _this = this;\n\n var instances = Object.keys(this.state.data).reduce(function (instances, id) {\n var instance = _this.hydrate(_this.state.data[id]);\n\n if (!condition(instance)) {\n return instances;\n }\n\n instances[id] = _this.processUpdate(data, instance);\n return instances;\n }, {});\n return this.performUpdate(instances);\n };\n /**\n * Update the given record with given data.\n */\n\n\n Query.prototype.processUpdate = function (data, instance) {\n if (typeof data === 'function') {\n data(instance);\n return instance;\n } // When the updated instance is not the base model, we tell te hydrate what model to use\n\n\n if (instance.constructor !== this.model && instance instanceof Model) {\n return this.hydrate(_assign(_assign({}, instance), data), instance.constructor);\n }\n\n return this.hydrate(_assign(_assign({}, instance), data));\n };\n /**\n * Commit `update` to the state.\n */\n\n\n Query.prototype.performUpdate = function (models) {\n var _this = this;\n\n models = this.updateIndexes(models);\n var beforeHooks = this.buildHooks('beforeUpdate');\n var afterHooks = this.buildHooks('afterUpdate');\n var updated = [];\n\n var _loop_1 = function _loop_1(id) {\n var model = models[id];\n\n if (beforeHooks.some(function (hook) {\n return hook(model, null, _this.entity) === false;\n })) {\n return \"continue\";\n }\n\n this_1.commitInsert(model.$getAttributes());\n afterHooks.forEach(function (hook) {\n hook(model, null, _this.entity);\n });\n updated.push(model);\n };\n\n var this_1 = this;\n\n for (var id in models) {\n _loop_1(id);\n }\n\n return updated;\n };\n /**\n * Update the key of the instances. This is needed when a user updates\n * record's primary key. We must then update the index key to\n * correspond with new id value.\n */\n\n\n Query.prototype.updateIndexes = function (instances) {\n var _this = this;\n\n return Object.keys(instances).reduce(function (instances, key) {\n var instance = instances[key];\n var id = String(_this.model.getIndexIdFromRecord(instance));\n\n if (key !== id) {\n instance.$id = id;\n instances[id] = instance;\n delete instances[key];\n }\n\n return instances;\n }, instances);\n };\n /**\n * Insert or update given data to the state. Unlike `insert`, this method\n * will not replace existing data within the state, but it will update only\n * the submitted data with the same primary key.\n */\n\n\n Query.prototype.insertOrUpdate = function (data, options) {\n return this.persist('insertOrUpdate', data, options);\n };\n /**\n * Insert or update the records.\n */\n\n\n Query.prototype.insertOrUpdateRecords = function (records) {\n var _this = this;\n\n var toBeInserted = {};\n var toBeUpdated = {};\n Object.keys(records).forEach(function (id) {\n var record = records[id];\n\n if (_this.state.data[id]) {\n toBeUpdated[id] = record;\n return;\n }\n\n toBeInserted[id] = record;\n });\n return __spreadArrays(this.insertRecords(toBeInserted), this.updateRecords(toBeUpdated));\n };\n /**\n * Persist data into the state while preserving it's original structure.\n */\n\n\n Query.prototype.persist = function (method, data, options) {\n var _this = this;\n\n var clonedData = Utils.cloneDeep(data);\n var normalizedData = this.normalize(clonedData);\n\n if (Utils.isEmpty(normalizedData)) {\n if (method === 'create') {\n this.emptyState();\n }\n\n return {};\n }\n\n return Object.entries(normalizedData).reduce(function (collections, _a) {\n var entity = _a[0],\n records = _a[1];\n\n var newQuery = _this.newQuery(entity);\n\n var methodForEntity = _this.getPersistMethod(entity, options, method);\n\n var collection = newQuery.persistRecords(methodForEntity, records);\n\n if (collection.length > 0) {\n collections[entity] = collection;\n }\n\n return collections;\n }, {});\n };\n /**\n * Persist given records to the store by the given method.\n */\n\n\n Query.prototype.persistRecords = function (method, records) {\n switch (method) {\n case 'create':\n return this.createRecords(records);\n\n case 'insert':\n return this.insertRecords(records);\n\n case 'update':\n return this.updateRecords(records);\n\n case 'insertOrUpdate':\n return this.insertOrUpdateRecords(records);\n }\n };\n /**\n * Get persist method from given information.\n */\n\n\n Query.prototype.getPersistMethod = function (entity, options, fallback) {\n if (options.create && options.create.includes(entity)) {\n return 'create';\n }\n\n if (options.insert && options.insert.includes(entity)) {\n return 'insert';\n }\n\n if (options.update && options.update.includes(entity)) {\n return 'update';\n }\n\n if (options.insertOrUpdate && options.insertOrUpdate.includes(entity)) {\n return 'insertOrUpdate';\n }\n\n return fallback;\n };\n\n Query.prototype[\"delete\"] = function (condition) {\n if (typeof condition === 'function') {\n return this.deleteByCondition(condition);\n }\n\n return this.deleteById(condition);\n };\n /**\n * Delete all records from the store. Even when deleting all records, we'll\n * iterate over all records to ensure that before and after hook will be\n * called for each existing records.\n */\n\n\n Query.prototype.deleteAll = function () {\n var _this = this; // If the target entity is the base entity and not inherited entity, we can\n // just delete all records.\n\n\n if (this.appliedOnBase) {\n return this.deleteByCondition(function () {\n return true;\n });\n } // Otherwise, we should filter out any derived entities from being deleted\n // so we'll add such filter here.\n\n\n return this.deleteByCondition(function (model) {\n return model.$self().entity === _this.model.entity;\n });\n };\n /**\n * Delete a record from the store by given id.\n */\n\n\n Query.prototype.deleteById = function (id) {\n var item = this.find(id);\n\n if (!item) {\n return null;\n }\n\n return this.deleteByCondition(function (model) {\n return model.$id === item.$id;\n })[0];\n };\n /**\n * Perform the actual delete query to the store.\n */\n\n\n Query.prototype.deleteByCondition = function (condition) {\n var collection = this.mapHydrateAndFilterRecords(this.state.data, condition);\n collection = this.executeMutationHooks('beforeDelete', collection);\n\n if (collection.length === 0) {\n return [];\n }\n\n this.commitDelete(collection.map(function (model) {\n return model.$id;\n }));\n this.executeMutationHooks('afterDelete', collection);\n return collection;\n };\n /**\n * Commit mutation.\n */\n\n\n Query.prototype.commit = function (name, payload) {\n this.store.commit(this.database.namespace + \"/\" + name, _assign({\n entity: this.baseEntity\n }, payload));\n };\n /**\n * Commit insert mutation.\n */\n\n\n Query.prototype.commitInsert = function (record) {\n this.commit('insert', {\n record: record\n });\n };\n /**\n * Commit insert records mutation.\n */\n\n\n Query.prototype.commitInsertRecords = function (records) {\n this.commit('insertRecords', {\n records: records\n });\n };\n /**\n * Commit delete mutation.\n */\n\n\n Query.prototype.commitDelete = function (id) {\n this.commit('delete', {\n id: id\n });\n };\n /**\n * Normalize the given data.\n */\n\n\n Query.prototype.normalize = function (data) {\n return Processor.normalize(this, data);\n };\n /**\n * Convert given record to the model instance.\n */\n\n\n Query.prototype.hydrate = function (record, forceModel) {\n var _a;\n\n if (forceModel) {\n return new forceModel(record);\n }\n\n var newModel = this.model.getModelFromRecord(record);\n\n if (newModel !== null) {\n return new newModel(record);\n }\n\n if (!this.appliedOnBase && record[this.model.typeKey] === undefined) {\n var typeValue = this.model.getTypeKeyValueFromModel();\n record = _assign(_assign({}, record), (_a = {}, _a[this.model.typeKey] = typeValue, _a));\n return new this.model(record);\n }\n\n var baseModel = this.getBaseModel(this.entity);\n return new baseModel(record);\n };\n /**\n * Convert given records to instances by merging existing record. If there's\n * no existing record, that record will not be included in the result.\n */\n\n\n Query.prototype.hydrateRecordsByMerging = function (records) {\n var _this = this;\n\n return Object.keys(records).reduce(function (instances, id) {\n var recordInStore = _this.state.data[id];\n\n if (!recordInStore) {\n return instances;\n }\n\n var record = records[id];\n\n var modelForRecordInStore = _this.model.getModelFromRecord(recordInStore);\n\n if (modelForRecordInStore === null) {\n instances[id] = _this.hydrate(_assign(_assign({}, recordInStore), record));\n return instances;\n }\n\n instances[id] = _this.hydrate(_assign(_assign({}, recordInStore), record), modelForRecordInStore);\n return instances;\n }, {});\n };\n /**\n * Convert all given records and return it as a collection.\n */\n\n\n Query.prototype.mapHydrateRecords = function (records) {\n var _this = this;\n\n return Utils.map(records, function (record) {\n return _this.hydrate(record);\n });\n };\n /**\n * Convert all given records and return it as a collection.\n */\n\n\n Query.prototype.mapHydrateAndFilterRecords = function (records, condition) {\n var collection = [];\n\n for (var key in records) {\n var model = this.hydrate(records[key]);\n condition(model) && collection.push(model);\n }\n\n return collection;\n };\n /**\n * Convert given collection to records by using index id as a key.\n */\n\n\n Query.prototype.convertCollectionToRecords = function (collection) {\n return collection.reduce(function (carry, model) {\n carry[model['$id']] = model.$getAttributes();\n return carry;\n }, {});\n };\n /**\n * Clears the current state from any data related to current model.\n *\n * - Everything if not in a inheritance scheme.\n * - Only derived instances if applied to a derived entity.\n */\n\n\n Query.prototype.emptyState = function () {\n this.deleteAll();\n };\n /**\n * Build executable hook collection for the given hook.\n */\n\n\n Query.prototype.buildHooks = function (on) {\n var hooks = this.getGlobalHookAsArray(on);\n var localHook = this.model[on];\n localHook && hooks.push(localHook.bind(this.model));\n return hooks;\n };\n /**\n * Get global hook of the given name as array by stripping id key and keep\n * only hook functions.\n */\n\n\n Query.prototype.getGlobalHookAsArray = function (on) {\n var _this = this;\n\n var hooks = this.self().hooks[on];\n return hooks ? hooks.map(function (h) {\n return h.callback.bind(_this);\n }) : [];\n };\n /**\n * Execute mutation hooks to the given collection.\n */\n\n\n Query.prototype.executeMutationHooks = function (on, collection) {\n var _this = this;\n\n var hooks = this.buildHooks(on);\n\n if (hooks.length === 0) {\n return collection;\n }\n\n return collection.filter(function (model) {\n return !hooks.some(function (hook) {\n return hook(model, null, _this.entity) === false;\n });\n });\n };\n /**\n * Execute retrieve hook for the given method.\n */\n\n\n Query.prototype.executeSelectHook = function (on, models) {\n var _this = this;\n\n var hooks = this.buildHooks(on);\n return hooks.reduce(function (collection, hook) {\n collection = hook(models, _this.entity);\n return collection;\n }, models);\n };\n /**\n * The global lifecycle hook registries.\n */\n\n\n Query.hooks = {};\n /**\n * The counter to generate the UID for global hooks.\n */\n\n Query.lastHookId = 0;\n return Query;\n}();\n/**\n * Create a new Query instance.\n */\n\n\nfunction query$1(_state) {\n var _this = this;\n\n return function (entity) {\n return new Query(_this, entity);\n };\n}\n/**\n * Get all data of given entity.\n */\n\n\nfunction all$1(_state) {\n var _this = this;\n\n return function (entity) {\n return new Query(_this, entity).all();\n };\n}\n/**\n * Find a data of the given entity by given id.\n */\n\n\nfunction find$1(_state) {\n var _this = this;\n\n return function (entity, id) {\n return new Query(_this, entity).find(id);\n };\n}\n/**\n * Find a data of the given entity by given id.\n */\n\n\nfunction findIn$1(_state) {\n var _this = this;\n\n return function (entity, idList) {\n return new Query(_this, entity).findIn(idList);\n };\n}\n\nvar RootGetters = {\n query: query$1,\n all: all$1,\n find: find$1,\n findIn: findIn$1\n};\n\nvar OptionsBuilder =\n/** @class */\nfunction () {\n function OptionsBuilder() {}\n /**\n * Get persist options from the given payload.\n */\n\n\n OptionsBuilder.createPersistOptions = function (payload) {\n return {\n create: payload.create,\n insert: payload.insert,\n update: payload.update,\n insertOrUpdate: payload.insertOrUpdate\n };\n };\n\n return OptionsBuilder;\n}();\n/**\n * Create new data with all fields filled by default values.\n */\n\n\nfunction newRecord$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2\n /*return*/\n , new Query(this, payload.entity)[\"new\"]()];\n });\n });\n}\n/**\n * Save given data to the store by replacing all existing records in the\n * store. If you want to save data without replacing existing records,\n * use the `insert` method instead.\n */\n\n\nfunction create$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var entity, data, options;\n return __generator(this, function (_a) {\n entity = payload.entity;\n data = payload.data;\n options = OptionsBuilder.createPersistOptions(payload);\n return [2\n /*return*/\n , new Query(this, entity).create(data, options)];\n });\n });\n}\n/**\n * Insert given data to the state. Unlike `create`, this method will not\n * remove existing data within the state, but it will update the data\n * with the same primary key.\n */\n\n\nfunction insert$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var entity, data, options;\n return __generator(this, function (_a) {\n entity = payload.entity;\n data = payload.data;\n options = OptionsBuilder.createPersistOptions(payload);\n return [2\n /*return*/\n , new Query(this, entity).insert(data, options)];\n });\n });\n}\n/**\n * Update data in the store.\n */\n\n\nfunction update$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var entity, data, where, options;\n return __generator(this, function (_a) {\n entity = payload.entity;\n data = payload.data;\n where = payload.where || null;\n options = OptionsBuilder.createPersistOptions(payload);\n return [2\n /*return*/\n , new Query(this, entity).update(data, where, options)];\n });\n });\n}\n/**\n * Insert or update given data to the state. Unlike `insert`, this method\n * will not replace existing data within the state, but it will update only\n * the submitted data with the same primary key.\n */\n\n\nfunction insertOrUpdate$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var entity, data, options;\n return __generator(this, function (_a) {\n entity = payload.entity;\n data = payload.data;\n options = OptionsBuilder.createPersistOptions(payload);\n return [2\n /*return*/\n , new Query(this, entity).insertOrUpdate(data, options)];\n });\n });\n}\n\nfunction destroy$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n var entity, where;\n return __generator(this, function (_a) {\n entity = payload.entity, where = payload.where;\n return [2\n /*return*/\n , new Query(this, entity)[\"delete\"](where)];\n });\n });\n}\n/**\n * Delete all data from the store.\n */\n\n\nfunction deleteAll$1(_context, payload) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n if (payload && payload.entity) {\n new Query(this, payload.entity).deleteAll();\n return [2\n /*return*/\n ];\n }\n\n Query.deleteAll(this);\n return [2\n /*return*/\n ];\n });\n });\n}\n\nvar RootActions = {\n \"new\": newRecord$1,\n create: create$1,\n insert: insert$1,\n update: update$1,\n insertOrUpdate: insertOrUpdate$1,\n \"delete\": destroy$1,\n deleteAll: deleteAll$1\n};\n\nvar Connection =\n/** @class */\nfunction () {\n /**\n * Create a new connection instance.\n */\n function Connection(store, connection, entity) {\n this.store = store;\n this.connection = connection;\n this.entity = entity;\n this.rootState = this.store.state[connection];\n this.state = this.rootState[entity];\n }\n /**\n * Insert the given record.\n */\n\n\n Connection.prototype.insert = function (record) {\n var _a;\n\n this.state.data = _assign(_assign({}, this.state.data), (_a = {}, _a[record.$id] = record, _a));\n };\n /**\n * Insert the given records.\n */\n\n\n Connection.prototype.insertRecords = function (records) {\n this.state.data = _assign(_assign({}, this.state.data), records);\n };\n /**\n * Delete records that matches the given id.\n */\n\n\n Connection.prototype[\"delete\"] = function (id) {\n var data = {};\n\n for (var i in this.state.data) {\n if (!id.includes(i)) {\n data[i] = this.state.data[i];\n }\n }\n\n this.state.data = data;\n };\n\n return Connection;\n}();\n/**\n * Execute generic mutation. This method is used by `Model.commit` method so\n * that user can commit any state changes easily through models.\n */\n\n\nfunction $mutate(state, payload) {\n payload.callback(state[payload.entity]);\n}\n/**\n * Insert the given record.\n */\n\n\nfunction insert$2(state, payload) {\n var entity = payload.entity,\n record = payload.record;\n new Connection(this, state.$name, entity).insert(record);\n}\n/**\n * Insert the given records.\n */\n\n\nfunction insertRecords(state, payload) {\n var entity = payload.entity,\n records = payload.records;\n new Connection(this, state.$name, entity).insertRecords(records);\n}\n/**\n * Delete records from the store. The actual name for this mutation is\n * `delete`, but named `destroy` here because `delete` can't be declared at\n * this scope level.\n */\n\n\nfunction destroy$2(state, payload) {\n var entity = payload.entity,\n id = payload.id;\n new Connection(this, state.$name, entity)[\"delete\"](id);\n}\n\nvar RootMutations = {\n $mutate: $mutate,\n insert: insert$2,\n insertRecords: insertRecords,\n \"delete\": destroy$2\n};\n\nvar IdAttribute =\n/** @class */\nfunction () {\n function IdAttribute() {}\n /**\n * Creates a closure that generates the required id's for an entity.\n */\n\n\n IdAttribute.create = function (model) {\n var _this = this;\n\n return function (value, _parentValue, _key) {\n _this.generateIds(value, model);\n\n var indexId = _this.generateIndexId(value, model);\n\n return indexId;\n };\n };\n /**\n * Generate a field that is defined as primary keys. For keys with a proper\n * value set, it will do nothing. If a key is missing, it will generate\n * UID for it.\n */\n\n\n IdAttribute.generateIds = function (record, model) {\n var keys = isArray(model.primaryKey) ? model.primaryKey : [model.primaryKey];\n keys.forEach(function (k) {\n if (record[k] !== undefined && record[k] !== null) {\n return;\n }\n\n var attr = model.getFields()[k];\n record[k] = attr instanceof Uid$1 ? attr.make() : Uid.make();\n });\n };\n /**\n * Generate index id field (which is `$id`) and attach to the given record.\n */\n\n\n IdAttribute.generateIndexId = function (record, model) {\n record.$id = model.getIndexIdFromRecord(record);\n return record.$id;\n };\n\n return IdAttribute;\n}();\n\nvar Schema =\n/** @class */\nfunction () {\n /**\n * Create a new schema instance.\n */\n function Schema(model) {\n var _this = this;\n /**\n * List of generated schemas.\n */\n\n\n this.schemas = {};\n this.model = model;\n var models = model.database().models();\n Object.keys(models).forEach(function (name) {\n _this.one(models[name]);\n });\n }\n /**\n * Create a schema for the given model.\n */\n\n\n Schema.create = function (model) {\n return new this(model).one();\n };\n /**\n * Create a single schema for the given model.\n */\n\n\n Schema.prototype.one = function (model) {\n model = model || this.model;\n\n if (this.schemas[model.entity]) {\n return this.schemas[model.entity];\n }\n\n var schema$1 = new schema.Entity(model.entity, {}, {\n idAttribute: IdAttribute.create(model)\n });\n this.schemas[model.entity] = schema$1;\n var definition = this.definition(model);\n schema$1.define(definition);\n return schema$1;\n };\n /**\n * Create an array schema for the given model.\n */\n\n\n Schema.prototype.many = function (model) {\n return new schema.Array(this.one(model));\n };\n /**\n * Create an union schema for the given model.\n */\n\n\n Schema.prototype.union = function (callback) {\n return new schema.Union(this.schemas, callback);\n };\n /**\n * Create a dfinition for the given model.\n */\n\n\n Schema.prototype.definition = function (model) {\n var _this = this;\n\n var fields = model.getFields();\n return Object.keys(fields).reduce(function (definition, key) {\n var field = fields[key];\n\n if (field instanceof Relation) {\n definition[key] = field.define(_this);\n }\n\n return definition;\n }, {});\n };\n\n return Schema;\n}();\n\nvar Database =\n/** @class */\nfunction () {\n function Database() {\n /**\n * The list of entities. It contains models and modules with its name.\n * The name is going to be the namespace for the Vuex Modules.\n */\n this.entities = [];\n /**\n * The normalizr schema.\n */\n\n this.schemas = {};\n /**\n * Whether the database has already been installed to Vuex or not.\n * Model registration steps depend on its value.\n */\n\n this.isStarted = false;\n }\n /**\n * Initialize the database before a user can start using it.\n */\n\n\n Database.prototype.start = function (store, namespace) {\n this.store = store;\n this.namespace = namespace;\n this.connect();\n this.registerModules();\n this.createSchema();\n this.isStarted = true;\n };\n /**\n * Register a model and a module to Database.\n */\n\n\n Database.prototype.register = function (model, module) {\n if (module === void 0) {\n module = {};\n }\n\n this.checkModelTypeMappingCapability(model);\n var entity = {\n name: model.entity,\n base: model.baseEntity || model.entity,\n model: this.createBindingModel(model),\n module: module\n };\n this.entities.push(entity);\n\n if (this.isStarted) {\n this.registerModule(entity);\n this.registerSchema(entity);\n }\n };\n\n Database.prototype.model = function (model) {\n var name = typeof model === 'string' ? model : model.entity;\n var m = this.models()[name];\n\n if (!m) {\n throw new Error(\"[Vuex ORM] Could not find the model `\" + name + \"`. Please check if you \" + 'have registered the model to the database.');\n }\n\n return m;\n };\n\n Database.prototype.baseModel = function (model) {\n var name = typeof model === 'string' ? model : model.entity;\n var m = this.baseModels()[name];\n\n if (!m) {\n throw new Error(\"[Vuex ORM] Could not find the model `\" + name + \"`. Please check if you \" + 'have registered the model to the database.');\n }\n\n return m;\n };\n /**\n * Get all models from the entities list.\n */\n\n\n Database.prototype.models = function () {\n return this.entities.reduce(function (models, entity) {\n models[entity.name] = entity.model;\n return models;\n }, {});\n };\n /**\n * Get all base models from the entities list.\n */\n\n\n Database.prototype.baseModels = function () {\n var _this = this;\n\n return this.entities.reduce(function (models, entity) {\n models[entity.name] = _this.model(entity.base);\n return models;\n }, {});\n };\n /**\n * Get the module of the given name from the entities list.\n */\n\n\n Database.prototype.module = function (name) {\n var module = this.modules()[name];\n\n if (!module) {\n throw new Error(\"[Vuex ORM] Could not find the module `\" + name + \"`. Please check if you \" + 'have registered the module to the database.');\n }\n\n return module;\n };\n /**\n * Get all modules from the entities list.\n */\n\n\n Database.prototype.modules = function () {\n return this.entities.reduce(function (modules, entity) {\n modules[entity.name] = entity.module;\n return modules;\n }, {});\n };\n /**\n * Get the root state from the store.\n */\n\n\n Database.prototype.getState = function () {\n return this.store.state[this.namespace];\n };\n /**\n * Create a new model that binds the database.\n *\n * Transpiled classes cannot extend native classes. Implemented a workaround\n * until Babel releases a fix (https://github.com/babel/babel/issues/9367).\n */\n\n\n Database.prototype.createBindingModel = function (model) {\n var _this = this;\n\n var proxy;\n\n try {\n proxy = new Function('model', \"\\n 'use strict';\\n return class \" + model.name + \" extends model {}\\n \")(model);\n } catch (_a) {\n /* istanbul ignore next: rollback (mostly <= IE10) */\n proxy =\n /** @class */\n function (_super) {\n __extends(proxy, _super);\n\n function proxy() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n\n return proxy;\n }(model);\n /* istanbul ignore next: allocate model name */\n\n\n Object.defineProperty(proxy, 'name', {\n get: function get() {\n return model.name;\n }\n });\n }\n\n Object.defineProperty(proxy, 'store', {\n value: function value() {\n return _this.store;\n }\n });\n return proxy;\n };\n /**\n * Create Vuex Module from the registered entities, and register to\n * the store.\n */\n\n\n Database.prototype.registerModules = function () {\n this.store.registerModule(this.namespace, this.createModule());\n };\n /**\n * Generate module from the given entity, and register to the store.\n */\n\n\n Database.prototype.registerModule = function (entity) {\n this.store.registerModule([this.namespace, entity.name], this.createSubModule(entity));\n };\n /**\n * Create Vuex Module from the registered entities.\n */\n\n\n Database.prototype.createModule = function () {\n var _this = this;\n\n var module = this.createRootModule();\n this.entities.forEach(function (entity) {\n module.modules[entity.name] = _this.createSubModule(entity);\n });\n return module;\n };\n /**\n * Create root module.\n */\n\n\n Database.prototype.createRootModule = function () {\n return {\n namespaced: true,\n state: this.createRootState(),\n getters: this.createRootGetters(),\n actions: this.createRootActions(),\n mutations: this.createRootMutations(),\n modules: {}\n };\n };\n /**\n * Create root state.\n */\n\n\n Database.prototype.createRootState = function () {\n var _this = this;\n\n return function () {\n return {\n $name: _this.namespace\n };\n };\n };\n /**\n * Create root getters. For the getters, we bind the store instance to each\n * function to retrieve database instances within getters. We only need this\n * for the getter since actions and mutations are already bound to store.\n */\n\n\n Database.prototype.createRootGetters = function () {\n var _this = this;\n\n return mapValues(RootGetters, function (_getter, name) {\n return RootGetters[name].bind(_this.store);\n });\n };\n /**\n * Create root actions.\n */\n\n\n Database.prototype.createRootActions = function () {\n return RootActions;\n };\n /**\n * Create root mutations.\n */\n\n\n Database.prototype.createRootMutations = function () {\n return RootMutations;\n };\n /**\n * Create sub module.\n */\n\n\n Database.prototype.createSubModule = function (entity) {\n return {\n namespaced: true,\n state: this.createSubState(entity),\n getters: this.createSubGetters(entity),\n actions: this.createSubActions(entity),\n mutations: this.createSubMutations(entity)\n };\n };\n /**\n * Create sub state.\n */\n\n\n Database.prototype.createSubState = function (entity) {\n var _this = this;\n\n var name = entity.name,\n model = entity.model,\n module = entity.module;\n var modelState = typeof model.state === 'function' ? model.state() : model.state;\n var moduleState = typeof module.state === 'function' ? module.state() : module.state;\n return function () {\n return _assign(_assign(_assign({}, modelState), moduleState), {\n $connection: _this.namespace,\n $name: name,\n data: {}\n });\n };\n };\n /**\n * Create sub getters.\n */\n\n\n Database.prototype.createSubGetters = function (entity) {\n return _assign(_assign({}, Getters), entity.module.getters);\n };\n /**\n * Create sub actions.\n */\n\n\n Database.prototype.createSubActions = function (entity) {\n return _assign(_assign({}, Actions), entity.module.actions);\n };\n /**\n * Create sub mutations.\n */\n\n\n Database.prototype.createSubMutations = function (entity) {\n var _a;\n\n return _a = entity.module.mutations, _a !== null && _a !== void 0 ? _a : {};\n };\n /**\n * Create the schema definition from registered entities list and set it to\n * the `schema` property. This schema will be used by the normalizer\n * to normalize data before persisting them to the Vuex Store.\n */\n\n\n Database.prototype.createSchema = function () {\n var _this = this;\n\n this.entities.forEach(function (entity) {\n _this.registerSchema(entity);\n });\n };\n /**\n * Generate schema from the given entity.\n */\n\n\n Database.prototype.registerSchema = function (entity) {\n this.schemas[entity.name] = Schema.create(entity.model);\n };\n /**\n * Inject database to the store instance.\n */\n\n\n Database.prototype.connect = function () {\n var _this = this;\n\n this.store.$db = function () {\n return _this;\n };\n };\n /**\n * Warn user if the given model is a type of an inherited model that is being\n * defined without overwriting `Model.types()` because the user will not be\n * able to use the type mapping feature in this case.\n */\n\n\n Database.prototype.checkModelTypeMappingCapability = function (model) {\n // We'll not be logging any warning if it's on a production environment,\n // so let's return here if it is.\n\n /* istanbul ignore next */\n if (process.env.NODE_ENV === 'production') {\n return;\n } // If the model doesn't have `baseEntity` property set, we'll assume it is\n // not an inherited model so we can stop here.\n\n\n if (!model.baseEntity) {\n return;\n } // Now it seems like the model is indeed an inherited model. Let's check if\n // it has `types()` method declared, or we'll warn the user that it's not\n // possible to use type mapping feature.\n\n\n var baseModel = this.model(model.baseEntity);\n\n if (baseModel && baseModel.types === Model.types) {\n console.warn(\"[Vuex ORM] Model `\" + model.name + \"` extends `\" + baseModel.name + \"` which doesn't \" + 'overwrite Model.types(). You will not be able to use type mapping.');\n }\n };\n\n return Database;\n}();\n\nfunction use(plugin, options) {\n if (options === void 0) {\n options = {};\n }\n\n var components = {\n Model: Model,\n Attribute: Attribute,\n Type: Type,\n Attr: Attr,\n String: String$1,\n Number: Number,\n Boolean: Boolean,\n Uid: Uid$1,\n Relation: Relation,\n HasOne: HasOne,\n BelongsTo: BelongsTo,\n HasMany: HasMany,\n HasManyBy: HasManyBy,\n BelongsToMany: BelongsToMany,\n HasManyThrough: HasManyThrough,\n MorphTo: MorphTo,\n MorphOne: MorphOne,\n MorphMany: MorphMany,\n MorphToMany: MorphToMany,\n MorphedByMany: MorphedByMany,\n Getters: Getters,\n Actions: Actions,\n RootGetters: RootGetters,\n RootActions: RootActions,\n RootMutations: RootMutations,\n Query: Query,\n Database: Database\n };\n plugin.install(components, options);\n}\n\nvar index = {\n install: install,\n use: use,\n Container: Container,\n Database: Database,\n Model: Model,\n Attribute: Attribute,\n Type: Type,\n Attr: Attr,\n String: String$1,\n Number: Number,\n Boolean: Boolean,\n Uid: Uid$1,\n Relation: Relation,\n HasOne: HasOne,\n BelongsTo: BelongsTo,\n HasMany: HasMany,\n HasManyBy: HasManyBy,\n BelongsToMany: BelongsToMany,\n HasManyThrough: HasManyThrough,\n MorphTo: MorphTo,\n MorphOne: MorphOne,\n MorphMany: MorphMany,\n MorphToMany: MorphToMany,\n MorphedByMany: MorphedByMany,\n Getters: Getters,\n Actions: Actions,\n RootGetters: RootGetters,\n RootActions: RootActions,\n RootMutations: RootMutations,\n Query: Query\n};\nexport default index;\nexport { Actions, Attr, Attribute, BelongsTo, BelongsToMany, Boolean, Container, Database, Getters, HasMany, HasManyBy, HasManyThrough, HasOne, Model, MorphMany, MorphOne, MorphTo, MorphToMany, MorphedByMany, Number, Query, Relation, RootActions, RootGetters, RootMutations, String$1 as String, Type, Uid$1 as Uid, install, use };","'use strict';\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar bind = require('./helpers/bind');\n/*global toString:true*/\n// utils is a library of generic helper functions non-specific to axios\n\n\nvar toString = Object.prototype.toString;\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\n\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\n\n\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\n\n\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\n\n\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\n\n\nfunction isFormData(val) {\n return typeof FormData !== 'undefined' && val instanceof FormData;\n}\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\n\n\nfunction isArrayBufferView(val) {\n var result;\n\n if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {\n result = ArrayBuffer.isView(val);\n } else {\n result = val && val.buffer && val.buffer instanceof ArrayBuffer;\n }\n\n return result;\n}\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\n\n\nfunction isString(val) {\n return typeof val === 'string';\n}\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\n\n\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\n\n\nfunction isObject(val) {\n return val !== null && _typeof(val) === 'object';\n}\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\n\n\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\n\n\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\n\n\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\n\n\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\n\n\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\n\n\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\n\n\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\n\n\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || navigator.product === 'NativeScript' || navigator.product === 'NS')) {\n return false;\n }\n\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\n\n\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n } // Force an array if not already something iterable\n\n\n if (_typeof(obj) !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\n\n\nfunction merge()\n/* obj1, obj2, obj3, ... */\n{\n var result = {};\n\n function assignValue(val, key) {\n if (_typeof(result[key]) === 'object' && _typeof(val) === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n\n return result;\n}\n/**\n * Function equal to merge with the difference being that no reference\n * to original objects is kept.\n *\n * @see merge\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\n\n\nfunction deepMerge()\n/* obj1, obj2, obj3, ... */\n{\n var result = {};\n\n function assignValue(val, key) {\n if (_typeof(result[key]) === 'object' && _typeof(val) === 'object') {\n result[key] = deepMerge(result[key], val);\n } else if (_typeof(val) === 'object') {\n result[key] = deepMerge({}, val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n\n return result;\n}\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\n\n\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n deepMerge: deepMerge,\n extend: extend,\n trim: trim\n};","import { Model } from '@vuex-orm/core';\nimport Post from \"@models/Post\";\nimport Reply from \"@models/Reply\";\n// import User from '@models/User';\n\nclass Comment extends Model {\n static entity = 'comments'\n\n static fields () {\n return {\n id: this.attr(),\n class: this.attr(null),\n post_id: this.attr(null),\n user_id: this.attr(null),\n content: this.attr(''),\n first_attachment: this.attr(null),\n attachment_order_type: this.attr(null),\n user: this.attr(null),\n image_ids: this.attr(null),\n my_card_ids: this.attr(null),\n attachment_order_id: this.attr(null),\n my_folder_ids: this.attr(null),\n other_card_ids: this.attr(null),\n card: this.attr(null),\n folder: this.attr(null),\n product: this.attr(null),\n logo_image: this.attr(null),\n updated_at: this.attr(null),\n category_name: this.attr(null),\n card_type: this.attr(null),\n created_at: this.attr(null),\n reply_count: this.attr(null),\n external_url: this.attr(null),\n url_hash: this.attr(null),\n mentions: this.attr([]),\n reply: this.hasMany(Reply, 'parent_comment_id'),\n // relationships\n post: this.belongsTo(Post, 'post_id'),\n // user: this.belongsTo(User, 'user_id')\n }\n }\n}\n\nexport default Comment","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _cropperjs = require('cropperjs');\n\nvar _cropperjs2 = _interopRequireDefault(_cropperjs);\n\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n \"default\": obj\n };\n}\n\nfunction _objectWithoutProperties(obj, keys) {\n var target = {};\n\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n\n return target;\n}\n\nvar previewPropType = typeof window === 'undefined' ? [String, Array] : [String, Array, Element, NodeList];\nexports[\"default\"] = {\n render: function render(h) {\n return h('div', {\n style: this.containerStyle\n }, [h('img', {\n ref: 'img',\n attrs: {\n src: this.src,\n alt: this.alt || 'image',\n style: 'max-width: 100%'\n },\n on: this.$listeners,\n style: this.imgStyle\n })]);\n },\n props: {\n containerStyle: Object,\n src: {\n type: String,\n \"default\": ''\n },\n alt: String,\n imgStyle: Object,\n viewMode: Number,\n dragMode: String,\n initialAspectRatio: Number,\n aspectRatio: Number,\n data: Object,\n preview: previewPropType,\n responsive: {\n type: Boolean,\n \"default\": true\n },\n restore: {\n type: Boolean,\n \"default\": true\n },\n checkCrossOrigin: {\n type: Boolean,\n \"default\": true\n },\n checkOrientation: {\n type: Boolean,\n \"default\": true\n },\n modal: {\n type: Boolean,\n \"default\": true\n },\n guides: {\n type: Boolean,\n \"default\": true\n },\n center: {\n type: Boolean,\n \"default\": true\n },\n highlight: {\n type: Boolean,\n \"default\": true\n },\n background: {\n type: Boolean,\n \"default\": true\n },\n autoCrop: {\n type: Boolean,\n \"default\": true\n },\n autoCropArea: Number,\n movable: {\n type: Boolean,\n \"default\": true\n },\n rotatable: {\n type: Boolean,\n \"default\": true\n },\n scalable: {\n type: Boolean,\n \"default\": true\n },\n zoomable: {\n type: Boolean,\n \"default\": true\n },\n zoomOnTouch: {\n type: Boolean,\n \"default\": true\n },\n zoomOnWheel: {\n type: Boolean,\n \"default\": true\n },\n wheelZoomRatio: Number,\n cropBoxMovable: {\n type: Boolean,\n \"default\": true\n },\n cropBoxResizable: {\n type: Boolean,\n \"default\": true\n },\n toggleDragModeOnDblclick: {\n type: Boolean,\n \"default\": true\n },\n minCanvasWidth: Number,\n minCanvasHeight: Number,\n minCropBoxWidth: Number,\n minCropBoxHeight: Number,\n minContainerWidth: Number,\n minContainerHeight: Number,\n ready: Function,\n cropstart: Function,\n cropmove: Function,\n cropend: Function,\n crop: Function,\n zoom: Function\n },\n mounted: function mounted() {\n var _$options$props = this.$options.props,\n containerStyle = _$options$props.containerStyle,\n src = _$options$props.src,\n alt = _$options$props.alt,\n imgStyle = _$options$props.imgStyle,\n data = _objectWithoutProperties(_$options$props, ['containerStyle', 'src', 'alt', 'imgStyle']);\n\n var props = {};\n\n for (var key in data) {\n if (this[key] !== undefined) {\n props[key] = this[key];\n }\n }\n\n this.cropper = new _cropperjs2[\"default\"](this.$refs.img, props);\n },\n methods: {\n reset: function reset() {\n return this.cropper.reset();\n },\n clear: function clear() {\n return this.cropper.clear();\n },\n initCrop: function initCrop() {\n return this.cropper.crop();\n },\n replace: function replace(url) {\n var onlyColorChanged = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n return this.cropper.replace(url, onlyColorChanged);\n },\n enable: function enable() {\n return this.cropper.enable();\n },\n disable: function disable() {\n return this.cropper.disable();\n },\n destroy: function destroy() {\n return this.cropper.destroy();\n },\n move: function move(offsetX, offsetY) {\n return this.cropper.move(offsetX, offsetY);\n },\n moveTo: function moveTo(x) {\n var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;\n return this.cropper.moveTo(x, y);\n },\n relativeZoom: function relativeZoom(ratio, _originalEvent) {\n return this.cropper.zoom(ratio, _originalEvent);\n },\n zoomTo: function zoomTo(ratio, _originalEvent) {\n return this.cropper.zoomTo(ratio, _originalEvent);\n },\n rotate: function rotate(degree) {\n return this.cropper.rotate(degree);\n },\n rotateTo: function rotateTo(degree) {\n return this.cropper.rotateTo(degree);\n },\n scaleX: function scaleX(_scaleX) {\n return this.cropper.scaleX(_scaleX);\n },\n scaleY: function scaleY(_scaleY) {\n return this.cropper.scaleY(_scaleY);\n },\n scale: function scale(scaleX) {\n var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;\n return this.cropper.scale(scaleX, scaleY);\n },\n getData: function getData() {\n var rounded = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n return this.cropper.getData(rounded);\n },\n setData: function setData(data) {\n return this.cropper.setData(data);\n },\n getContainerData: function getContainerData() {\n return this.cropper.getContainerData();\n },\n getImageData: function getImageData() {\n return this.cropper.getImageData();\n },\n getCanvasData: function getCanvasData() {\n return this.cropper.getCanvasData();\n },\n setCanvasData: function setCanvasData(data) {\n return this.cropper.setCanvasData(data);\n },\n getCropBoxData: function getCropBoxData() {\n return this.cropper.getCropBoxData();\n },\n setCropBoxData: function setCropBoxData(data) {\n return this.cropper.setCropBoxData(data);\n },\n getCroppedCanvas: function getCroppedCanvas() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return this.cropper.getCroppedCanvas(options);\n },\n setAspectRatio: function setAspectRatio(aspectRatio) {\n return this.cropper.setAspectRatio(aspectRatio);\n },\n setDragMode: function setDragMode(mode) {\n return this.cropper.setDragMode(mode);\n }\n }\n};","import request from '@utils/request'\n\nexport function getPosts(payload, link, group_id = '') {\n return request({\n url: `/${link}${link === 'groups' || 'users' ? `/${group_id}`: ''}/posts`,\n method: 'get',\n params: {\n ...payload\n }\n })\n}\n\nexport function getPost(id) {\n return request({\n url: `/posts/${id}`,\n method: 'get'\n })\n}\n\nexport function createPost(payload) {\n return request({\n url: '/posts',\n method: 'post',\n data: {\n ...payload\n }\n })\n}\n\nexport function updatePost(payload) {\n return request({\n url: `/posts/${payload.id}`,\n method: 'put',\n data: {\n ...payload\n }\n })\n}\n\nexport function deletePost(id) {\n return request({\n url: `/posts/${id}`,\n method: 'delete',\n })\n}\n\nexport function searchAttachments(keyword) {\n return request({\n url: '/feed/comments/search_comment_attachment',\n method: 'get',\n params: {\n key_word: keyword\n }\n })\n}\n\nexport function likePost(post_id) {\n return request({\n url: `/feed/posts/${post_id}/like`,\n method: 'post'\n })\n}\n\nexport function getLikers(_params) {\n let { id, post_id, ...params } = typeof(_params) === 'object' ? _params : {}\n post_id = post_id || id || _params\n return request({\n url: `/posts/${ post_id }/likers`,\n method: 'get',\n params //{ offset, limit }\n })\n}\n\nexport function getPostAttachments(post_id) {\n return request({\n url: `/feed/posts/${post_id}/get_attachments`,\n method: 'get',\n })\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if ((typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction _slicedToArray(arr, i) {\n return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();\n}\n\nfunction _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nfunction _iterableToArrayLimit(arr, i) {\n if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) {\n return;\n }\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}\n\nfunction arrayToObject() {\n var fields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n return fields.reduce(function (prev, path) {\n var key = path.split(\".\").slice(-1)[0];\n\n if (prev[key]) {\n throw new Error(\"The key `\".concat(key, \"` is already in use.\"));\n } // eslint-disable-next-line no-param-reassign\n\n\n prev[key] = path;\n return prev;\n }, {});\n}\n\nfunction objectEntries(obj) {\n return Object.keys(obj).map(function (key) {\n return [key, obj[key]];\n });\n}\n\nfunction normalizeNamespace(fn) {\n return function () {\n for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {\n params[_key] = arguments[_key];\n } // eslint-disable-next-line prefer-const\n\n\n var _ref = typeof params[0] === \"string\" ? [].concat(params) : [\"\"].concat(params),\n _ref2 = _slicedToArray(_ref, 4),\n namespace = _ref2[0],\n map = _ref2[1],\n getterType = _ref2[2],\n mutationType = _ref2[3];\n\n if (namespace.length && namespace.charAt(namespace.length - 1) !== \"/\") {\n namespace += \"/\";\n }\n\n getterType = \"\".concat(namespace).concat(getterType || \"getField\");\n mutationType = \"\".concat(namespace).concat(mutationType || \"updateField\");\n return fn(namespace, map, getterType, mutationType);\n };\n}\n\nfunction getField(state) {\n return function (path) {\n return path.split(/[.[\\]]+/).reduce(function (prev, key) {\n return prev[key];\n }, state);\n };\n}\n\nfunction updateField(state, _ref3) {\n var path = _ref3.path,\n value = _ref3.value;\n path.split(/[.[\\]]+/).reduce(function (prev, key, index, array) {\n if (array.length === index + 1) {\n // eslint-disable-next-line no-param-reassign\n prev[key] = value;\n }\n\n return prev[key];\n }, state);\n}\n\nvar mapFields = normalizeNamespace(function (namespace, fields, getterType, mutationType) {\n var fieldsObject = Array.isArray(fields) ? arrayToObject(fields) : fields;\n return Object.keys(fieldsObject).reduce(function (prev, key) {\n var path = fieldsObject[key];\n var field = {\n get: function get() {\n return this.$store.getters[getterType](path);\n },\n set: function set(value) {\n this.$store.commit(mutationType, {\n path: path,\n value: value\n });\n }\n }; // eslint-disable-next-line no-param-reassign\n\n prev[key] = field;\n return prev;\n }, {});\n});\nvar mapMultiRowFields = normalizeNamespace(function (namespace, paths, getterType, mutationType) {\n var pathsObject = Array.isArray(paths) ? arrayToObject(paths) : paths;\n return Object.keys(pathsObject).reduce(function (entries, key) {\n var path = pathsObject[key]; // eslint-disable-next-line no-param-reassign\n\n entries[key] = {\n get: function get() {\n var store = this.$store;\n var rows = objectEntries(store.getters[getterType](path));\n return rows.map(function (fieldsObject) {\n return Object.keys(fieldsObject[1]).reduce(function (prev, fieldKey) {\n var fieldPath = \"\".concat(path, \"[\").concat(fieldsObject[0], \"].\").concat(fieldKey);\n return Object.defineProperty(prev, fieldKey, {\n get: function get() {\n return store.getters[getterType](fieldPath);\n },\n set: function set(value) {\n store.commit(mutationType, {\n path: fieldPath,\n value: value\n });\n }\n });\n }, {});\n });\n }\n };\n return entries;\n }, {});\n});\n\nvar createHelpers = function createHelpers(_ref4) {\n var _ref5;\n\n var getterType = _ref4.getterType,\n mutationType = _ref4.mutationType;\n return _ref5 = {}, _defineProperty(_ref5, getterType, getField), _defineProperty(_ref5, mutationType, updateField), _defineProperty(_ref5, \"mapFields\", normalizeNamespace(function (namespace, fields) {\n return mapFields(namespace, fields, getterType, mutationType);\n })), _defineProperty(_ref5, \"mapMultiRowFields\", normalizeNamespace(function (namespace, paths) {\n return mapMultiRowFields(namespace, paths, getterType, mutationType);\n })), _ref5;\n};\n\nexport { createHelpers, getField, mapFields, mapMultiRowFields, updateField };","import request from '@utils/request'\n\nexport function SignIn(payload) {\n return request({\n baseURL: `${window.location.origin}`,\n url: '/users/login',\n method: 'post',\n data: {\n ...payload\n }\n })\n}\n\nexport function Logout() {\n return request({\n baseURL: `${window.location.origin}`,\n url: '/users/logout',\n method: 'delete',\n headers: {'Accept': 'text/javascript'}\n })\n}\n\nexport function SignUp(payload) {\n return request({\n url: '/auth',\n method: 'post',\n data: {\n ...payload\n }\n })\n}\n\nexport function ForgotPass(payload) {\n return request({\n url: '/auth/password',\n method: 'post',\n data: {\n ...payload\n }\n })\n}\n\nexport function getUser(id) {\n return request({\n baseURL: `${window.location.origin}`,\n url: '/users/current',\n method: 'get',\n })\n}\n\nexport function getUserInfo() {\n return request({\n url: '/users/me',\n method: 'get',\n })\n}\n\nexport function ResendEmail(payload) {\n return request({\n url: '/auth/confirmation',\n method: 'post',\n data: {\n ...payload\n }\n })\n}\n\nexport function CheckConfirmToken(token) {\n return request({\n url: `/auth/password/edit?reset_password_token=${token}`,\n method: 'get'\n })\n}\n\nexport function UpdatePassword(payload) {\n return request({\n url: '/auth/password',\n method: 'patch',\n data: {\n ...payload\n }\n })\n}\n","// shim for using process in browser\nvar process = module.exports = {}; // cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\n\nfunction defaultClearTimeout() {\n throw new Error('clearTimeout has not been defined');\n}\n\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n})();\n\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n } // if setTimeout wasn't available but was latter defined\n\n\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch (e) {\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch (e) {\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n}\n\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n } // if clearTimeout wasn't available but was latter defined\n\n\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e) {\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e) {\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n}\n\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n\n draining = false;\n\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n var len = queue.length;\n\n while (len) {\n currentQueue = queue;\n queue = [];\n\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n\n queueIndex = -1;\n len = queue.length;\n }\n\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n\n queue.push(new Item(fun, args));\n\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n}; // v8 likes predictible objects\n\n\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\n\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\n\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) {\n return [];\n};\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () {\n return '/';\n};\n\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\n\nprocess.umask = function () {\n return 0;\n};","import { Model } from '@vuex-orm/core';\nimport Post from '@models/Post';\n\nclass Group extends Model {\n static entity = 'group'\n\n static fields () {\n return {\n id: this.attr(),\n name: this.attr(),\n score: this.attr(),\n avatar: this.attr(),\n is_active: this.attr(),\n description: this.attr(),\n shares_count: this.attr(),\n members_count: this.attr(),\n elevates_count: this.attr(),\n followers_count: this.attr(),\n group_folder_count: this.attr(),\n created_at: this.attr(),\n group_email: this.attr(),\n group_tags: this.attr(),\n group_website: this.attr(),\n group_rules: this.attr(),\n group_privacy: this.attr(),\n is_admin: this.attr(),\n is_approved: this.attr(),\n is_blocked: this.attr(),\n is_following: this.attr(),\n is_joined: this.attr(),\n is_owner: this.attr(),\n group_elevate_count: this.attr(),\n elevated: this.attr(),\n is_elevated: this.attr(),\n is_admin_post: this.attr(),\n is_admin_invited: this.attr(),\n is_admin_library: this.attr(),\n is_content_approved: this.attr(),\n is_post_approved_request: this.attr()\n }\n }\n\n static apiConfig = {\n actions: {\n async toggleElevation(id) {\n try {\n return await this.post(`/groups/${id}/toggle_elevation`, {}, {dataKey: 'response'})\n }catch(response){\n let message = `${Object.values(response.data.message)[0]}`\n iziToast.error({ message: message, maxWidth: '700px' })\n return;\n }\n }\n }\n }\n}\n\n// window.group = Group\nexport default Group","import request from '@utils/request'\n\nexport function getCommentsById(payload) {\n return request({\n url: '/feed/comments',\n method: 'get',\n params: {\n ...payload\n }\n })\n}\n\nexport function getCommentById(id) {\n return request({\n url: `/feed/comments/${id}`,\n method: 'get'\n })\n}\n\nexport function addNewReply(payload) {\n return request({\n url: '/feed/comments',\n method: 'post',\n params: {\n ...payload\n }\n })\n}\n\nexport function loadReplies(pagination, comment_id) {\n return request({\n url: '/feed/comments',\n method: 'get',\n params: {\n parent_comment_id: comment_id,\n ...pagination\n }\n })\n}\n\nexport function updateComment(id, payload) {\n return request({\n url: `/feed/comments/${id}`,\n method: 'put',\n data: {\n ...payload\n }\n })\n}\n\nexport function getCommentAttachmentsById(id) {\n return request({\n url: '/feed/comments/get_attachments',\n method: 'get',\n params: {\n id: id\n }\n })\n}\n\nexport function createImage(payload) {\n return request({\n url: '/images',\n method: 'post',\n headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n data: payload\n })\n}\n\nexport function uploadImageToS3({data, file}, requestParams={} ) {\n return request({\n url: data.upload_links.put_url,\n method: 'put',\n timeout: 60 * 60 * 1000,\n headers: {\n 'Content-Type': file.type\n },\n data: file,\n onUploadProgress: function (progressEvent) {\n // console.log(`uploaded: ${parseInt(Math.round((progressEvent.loaded / progressEvent.total) * 100))}%`)\n },\n ...requestParams\n })\n}\n\nexport function updateImage(payload, id) {\n return request({\n url: `/images/${id}`,\n method: 'put',\n headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n data: payload\n })\n}\n\nexport function addComment(payload) {\n return request({\n url: '/feed/comments',\n method: 'post',\n data: {\n ...payload,\n }\n })\n}\n\nexport function deleteComment(payload) {\n return request({\n url: `/feed/comments/${payload.id}`,\n method: 'delete'\n })\n}\n\nexport function updateReply(payload) {\n return request({\n url: `/feed/comments/${payload.id}`,\n method: 'put',\n params: {\n ...payload\n }\n })\n}\n\nexport function deleteReply(payload) {\n return request({\n url: `/feed/comments/${payload.id}`,\n method: 'delete',\n })\n}","import { Model } from '@vuex-orm/core';\nimport Comment from '@models/Comment';\n\nclass Reply extends Model {\n static entity = 'replies'\n\n static fields () {\n return {\n id: this.attr(null),\n parent_comment_id: this.string(\"\"),\n content: this.attr(''),\n user: this.attr(null),\n comment: this.belongsTo(Comment, 'id'),\n updated_at: this.attr(null),\n created_at: this.attr(null),\n }\n }\n}\n\nexport default Reply","module.exports = function (module) {\n if (!module.webpackPolyfill) {\n module.deprecate = function () {};\n\n module.paths = []; // module.parent = undefined by default\n\n if (!module.children) module.children = [];\n Object.defineProperty(module, \"loaded\", {\n enumerable: true,\n get: function get() {\n return module.l;\n }\n });\n Object.defineProperty(module, \"id\", {\n enumerable: true,\n get: function get() {\n return module.i;\n }\n });\n module.webpackPolyfill = 1;\n }\n\n return module;\n};","export default {\n isObjectEmpty(object) {\n return Object.values(object).some(field => (field === null || field === ''));\n },\n removeDuplicates(arr, key) {\n return [...new Map(arr.map(item => [item[key], item])).values()]\n },\n debounce (fn, delay) {\n var timeoutID = null\n return function () {\n clearTimeout(timeoutID)\n var args = arguments\n var that = this\n timeoutID = setTimeout(function () {\n fn.apply(that, args)\n }, delay)\n }\n },\n formatBytes(bytes, decimals = 2) {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n \n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n },\n extractHostname(url) {\n var hostname;\n //find & remove protocol (http, ftp, etc.) and get hostname\n \n if (url.indexOf(\"//\") > -1) {\n hostname = url.split('/')[2];\n }\n else {\n hostname = url.split('/')[0];\n }\n \n //find & remove port number\n hostname = hostname.split(':')[0];\n //find & remove \"?\"\n hostname = hostname.split('?')[0];\n hostname = hostname.replace('www.', '')\n \n return hostname;\n },\n toBase64 (file) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result);\n reader.onerror = error => reject(error);\n })\n },\n removeObjectFromArray(array, key, value) {\n const index = array.findIndex(obj => obj[key] === value);\n return index >= 0 ? [\n ...array.slice(0, index),\n ...array.slice(index + 1)\n ] : array;\n }\n}\n ","import {Model} from '@vuex-orm/core'\nimport Album from '@models/Album'\n\nclass Photo extends Model {\n static entity = 'photos'\n\n static fields() {\n return {\n // api partial\n id: this.uid(),\n album_id: this.attr(null),\n origin_name: this.attr(''),\n origin_type: this.attr(''),\n origin_size: this.attr(0),\n image_url: this.attr(''),\n image_thumb_url: this.attr(''),\n processing_stage: this.attr(''), // 'RESERVED', 'UPLOADING', 'UPLOADED', 'COMPLETED'\n image_upload_links: this.attr({}),\n created_at: this.attr(''),\n updated_at: this.attr(''),\n // only ui\n image_tmp_url: this.attr(''),\n upload_percentage: this.attr(null),\n selected: this.attr(false),\n // relations\n photoable_id: this.attr(''),\n photos: this.belongsTo(Album, 'album_id')\n }\n }\n\n get preview_url(){\n if (this.processing_stage === 'COMPLETED'){\n return this.image_thumb_url\n }else if (this.image_tmp_url) {\n return this.image_tmp_url\n } else {\n return this.image_url\n }\n }\n\n static apiConfig = {\n actions: {\n async fetch(params = {}) {\n return await this.get(\"/storage/photos\", {\n params: params,\n dataKey: 'response'\n })\n },\n\n async destroy(id) {\n return await this.delete(`/storage/photos/${id}`, { delete: id })\n },\n\n // Send information about the file to make sure file is valid and getting upload links\n async create(file){\n let data = {\n origin_name: file.name,\n origin_type: file.type,\n origin_size: file.size\n }\n let create_result;\n try {\n create_result = await this.post('/storage/photos', data, {\n dataKey: 'response'\n })\n }catch(response){\n let message = `${file.name} - ${Object.values(response.data.message)[0]}`\n iziToast.error({ message: message, maxWidth: '700px' })\n return;\n }\n\n // uploading\n let photo = Photo.find(create_result.response.data.response.id),\n signedUrl = photo.image_upload_links.put_url,\n publicUrl = photo.image_upload_links.public_url\n await Photo.update({id: photo.id, processing_stage: 'UPLOADING', image_tmp_url: URL.createObjectURL(file)})\n\n let upload_result;\n try {\n upload_result = await this.put(signedUrl, file, {\n timeout: 60 * 60 * 1000,\n headers: {'Content-Type': file.type},\n onUploadProgress: function (progressEvent) {\n let percent = parseInt(Math.round((progressEvent.loaded / progressEvent.total) * 100))\n Photo.update({id: photo.id, upload_percentage: percent})\n }\n })\n }catch(response){\n let message = `${file.name} - Uploading failed`\n iziToast.error({ message: message, maxWidth: '700px' })\n Photo.delete(photo.id)\n return;\n }\n\n Photo.update({id: photo.id, image_url: publicUrl})\n\n let data2 = {\n remote_image_url: publicUrl\n }\n try {\n const update_result = await this.put(`/storage/photos/${photo.id}`, data2, {\n dataKey: 'response'\n })\n } catch(response) {\n let message = `${file.name} - ${Object.values(response.data.message)[0]}`\n iziToast.error({ message: message, maxWidth: '700px' })\n Photo.delete(photo.id)\n return;\n }\n }\n }\n }\n}\n\nexport default Photo","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"CoverImg cover-img-component\"},[_c('div',{staticClass:\"cover-img\",style:({'background-image': (\"url(\" + _vm.src + \")\"), 'padding-top': ((_vm.height_ratio * 100) + \"%\") })},[_vm._t(\"default\")],2)])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import mod from \"-!../../../../../node_modules/babel-loader/lib/index.js??ref--7-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./CoverImg.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/babel-loader/lib/index.js??ref--7-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./CoverImg.vue?vue&type=script&lang=js&\"","
\n\n\n\n\n\n","import { render, staticRenderFns } from \"./CoverImg.vue?vue&type=template&id=3c48dbd1&scoped=true&\"\nimport script from \"./CoverImg.vue?vue&type=script&lang=js&\"\nexport * from \"./CoverImg.vue?vue&type=script&lang=js&\"\nimport style0 from \"./CoverImg.vue?vue&type=style&index=0&id=3c48dbd1&lang=scss&scoped=true&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"3c48dbd1\",\n null\n \n)\n\nexport default component.exports","const TokenKey = 'token'\n\nexport function getToken() {\n return localStorage.getItem(TokenKey)\n}\n\nexport function setToken(token) {\n localStorage.setItem(TokenKey, `${token}`)\n}\n\nexport function removeTokens() {\n localStorage.removeItem(TokenKey)\n}\n","import { Model } from '@vuex-orm/core';\n\nclass Profile extends Model {\n static entity = 'profile'\n\n static fields () {\n return {\n id: this.attr(),\n first_name: this.attr(),\n last_name: this.attr(),\n phone: this.attr(),\n description: this.attr(),\n profile_email: this.attr(),\n profile_website: this.attr(),\n profile_attachment: this.attr(),\n gender: this.attr(),\n link_facebook: this.attr(),\n link_twitter: this.attr(),\n link_instagram: this.attr(),\n link_linkedin: this.attr(),\n link_blog: this.attr(),\n link_other: this.attr(),\n avatar: this.attr(),\n social_avatar: this.attr(),\n email: this.attr(),\n age_range: this.attr(),\n only_friend_can_see: this.attr(),\n location_address: this.attr(),\n friend_count: this.attr(),\n followers_count: this.attr(),\n public_email: this.attr(),\n use_email_as_public_email: this.attr(),\n folders_count: this.attr(),\n is_plus_account: this.attr(),\n banner: this.attr(),\n banner_image_url: this.attr(),\n products_count: this.attr(),\n trusted: this.attr(),\n trusteds_count: this.attr(),\n followed: this.attr(),\n is_friend: this.attr(),\n sent_friend_status: this.attr(),\n bio: this.attr()\n }\n }\n}\n\nexport default Profile","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n!function (t, e) {\n \"object\" == (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) && \"object\" == (typeof module === \"undefined\" ? \"undefined\" : _typeof(module)) ? module.exports = e() : \"function\" == typeof define && define.amd ? define([], e) : \"object\" == (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) ? exports.VueSelect = e() : t.VueSelect = e();\n}(\"undefined\" != typeof self ? self : this, function () {\n return function (t) {\n var e = {};\n\n function n(o) {\n if (e[o]) return e[o].exports;\n var i = e[o] = {\n i: o,\n l: !1,\n exports: {}\n };\n return t[o].call(i.exports, i, i.exports, n), i.l = !0, i.exports;\n }\n\n return n.m = t, n.c = e, n.d = function (t, e, o) {\n n.o(t, e) || Object.defineProperty(t, e, {\n enumerable: !0,\n get: o\n });\n }, n.r = function (t) {\n \"undefined\" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {\n value: \"Module\"\n }), Object.defineProperty(t, \"__esModule\", {\n value: !0\n });\n }, n.t = function (t, e) {\n if (1 & e && (t = n(t)), 8 & e) return t;\n if (4 & e && \"object\" == _typeof(t) && t && t.__esModule) return t;\n var o = Object.create(null);\n if (n.r(o), Object.defineProperty(o, \"default\", {\n enumerable: !0,\n value: t\n }), 2 & e && \"string\" != typeof t) for (var i in t) {\n n.d(o, i, function (e) {\n return t[e];\n }.bind(null, i));\n }\n return o;\n }, n.n = function (t) {\n var e = t && t.__esModule ? function () {\n return t[\"default\"];\n } : function () {\n return t;\n };\n return n.d(e, \"a\", e), e;\n }, n.o = function (t, e) {\n return Object.prototype.hasOwnProperty.call(t, e);\n }, n.p = \"/\", n(n.s = 8);\n }([function (t, e, n) {\n var o = n(4),\n i = n(5),\n r = n(6);\n\n t.exports = function (t) {\n return o(t) || i(t) || r();\n };\n }, function (t, e) {\n function n(e) {\n return \"function\" == typeof Symbol && \"symbol\" == _typeof(Symbol.iterator) ? t.exports = n = function n(t) {\n return _typeof(t);\n } : t.exports = n = function n(t) {\n return t && \"function\" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? \"symbol\" : _typeof(t);\n }, n(e);\n }\n\n t.exports = n;\n }, function (t, e, n) {}, function (t, e) {\n t.exports = function (t, e, n) {\n return e in t ? Object.defineProperty(t, e, {\n value: n,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : t[e] = n, t;\n };\n }, function (t, e) {\n t.exports = function (t) {\n if (Array.isArray(t)) {\n for (var e = 0, n = new Array(t.length); e < t.length; e++) {\n n[e] = t[e];\n }\n\n return n;\n }\n };\n }, function (t, e) {\n t.exports = function (t) {\n if (Symbol.iterator in Object(t) || \"[object Arguments]\" === Object.prototype.toString.call(t)) return Array.from(t);\n };\n }, function (t, e) {\n t.exports = function () {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n };\n }, function (t, e, n) {\n \"use strict\";\n\n var o = n(2);\n n.n(o).a;\n }, function (t, e, n) {\n \"use strict\";\n\n n.r(e);\n var o = n(0),\n i = n.n(o),\n r = n(1),\n s = n.n(r),\n a = n(3),\n l = n.n(a),\n c = {\n props: {\n autoscroll: {\n type: Boolean,\n \"default\": !0\n }\n },\n watch: {\n typeAheadPointer: function typeAheadPointer() {\n this.autoscroll && this.maybeAdjustScroll();\n }\n },\n methods: {\n maybeAdjustScroll: function maybeAdjustScroll() {\n var t,\n e = (null === (t = this.$refs.dropdownMenu) || void 0 === t ? void 0 : t.children[this.typeAheadPointer]) || !1;\n\n if (e) {\n var n = this.getDropdownViewport(),\n o = e.getBoundingClientRect(),\n i = o.top,\n r = o.bottom,\n s = o.height;\n if (i < n.top) return this.$refs.dropdownMenu.scrollTop = e.offsetTop;\n if (r > n.bottom) return this.$refs.dropdownMenu.scrollTop = e.offsetTop - (n.height - s);\n }\n },\n getDropdownViewport: function getDropdownViewport() {\n return this.$refs.dropdownMenu ? this.$refs.dropdownMenu.getBoundingClientRect() : {\n height: 0,\n top: 0,\n bottom: 0\n };\n }\n }\n },\n u = {\n data: function data() {\n return {\n typeAheadPointer: -1\n };\n },\n watch: {\n filteredOptions: function filteredOptions() {\n for (var t = 0; t < this.filteredOptions.length; t++) {\n if (this.selectable(this.filteredOptions[t])) {\n this.typeAheadPointer = t;\n break;\n }\n }\n }\n },\n methods: {\n typeAheadUp: function typeAheadUp() {\n for (var t = this.typeAheadPointer - 1; t >= 0; t--) {\n if (this.selectable(this.filteredOptions[t])) {\n this.typeAheadPointer = t;\n break;\n }\n }\n },\n typeAheadDown: function typeAheadDown() {\n for (var t = this.typeAheadPointer + 1; t < this.filteredOptions.length; t++) {\n if (this.selectable(this.filteredOptions[t])) {\n this.typeAheadPointer = t;\n break;\n }\n }\n },\n typeAheadSelect: function typeAheadSelect() {\n var t = this.filteredOptions[this.typeAheadPointer];\n t && this.select(t);\n }\n }\n },\n p = {\n props: {\n loading: {\n type: Boolean,\n \"default\": !1\n }\n },\n data: function data() {\n return {\n mutableLoading: !1\n };\n },\n watch: {\n search: function search() {\n this.$emit(\"search\", this.search, this.toggleLoading);\n },\n loading: function loading(t) {\n this.mutableLoading = t;\n }\n },\n methods: {\n toggleLoading: function toggleLoading() {\n var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;\n return this.mutableLoading = null == t ? !this.mutableLoading : t;\n }\n }\n };\n\n function h(t, e, n, o, i, r, s, a) {\n var l,\n c = \"function\" == typeof t ? t.options : t;\n if (e && (c.render = e, c.staticRenderFns = n, c._compiled = !0), o && (c.functional = !0), r && (c._scopeId = \"data-v-\" + r), s ? (l = function l(t) {\n (t = t || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) || \"undefined\" == typeof __VUE_SSR_CONTEXT__ || (t = __VUE_SSR_CONTEXT__), i && i.call(this, t), t && t._registeredComponents && t._registeredComponents.add(s);\n }, c._ssrRegister = l) : i && (l = a ? function () {\n i.call(this, this.$root.$options.shadowRoot);\n } : i), l) if (c.functional) {\n c._injectStyles = l;\n var u = c.render;\n\n c.render = function (t, e) {\n return l.call(e), u(t, e);\n };\n } else {\n var p = c.beforeCreate;\n c.beforeCreate = p ? [].concat(p, l) : [l];\n }\n return {\n exports: t,\n options: c\n };\n }\n\n var d = {\n Deselect: h({}, function () {\n var t = this.$createElement,\n e = this._self._c || t;\n return e(\"svg\", {\n attrs: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: \"10\",\n height: \"10\"\n }\n }, [e(\"path\", {\n attrs: {\n d: \"M6.895455 5l2.842897-2.842898c.348864-.348863.348864-.914488 0-1.263636L9.106534.261648c-.348864-.348864-.914489-.348864-1.263636 0L5 3.104545 2.157102.261648c-.348863-.348864-.914488-.348864-1.263636 0L.261648.893466c-.348864.348864-.348864.914489 0 1.263636L3.104545 5 .261648 7.842898c-.348864.348863-.348864.914488 0 1.263636l.631818.631818c.348864.348864.914773.348864 1.263636 0L5 6.895455l2.842898 2.842897c.348863.348864.914772.348864 1.263636 0l.631818-.631818c.348864-.348864.348864-.914489 0-1.263636L6.895455 5z\"\n }\n })]);\n }, [], !1, null, null, null).exports,\n OpenIndicator: h({}, function () {\n var t = this.$createElement,\n e = this._self._c || t;\n return e(\"svg\", {\n attrs: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: \"14\",\n height: \"10\"\n }\n }, [e(\"path\", {\n attrs: {\n d: \"M9.211364 7.59931l4.48338-4.867229c.407008-.441854.407008-1.158247 0-1.60046l-.73712-.80023c-.407008-.441854-1.066904-.441854-1.474243 0L7 5.198617 2.51662.33139c-.407008-.441853-1.066904-.441853-1.474243 0l-.737121.80023c-.407008.441854-.407008 1.158248 0 1.600461l4.48338 4.867228L7 10l2.211364-2.40069z\"\n }\n })]);\n }, [], !1, null, null, null).exports\n },\n f = {\n inserted: function inserted(t, e, n) {\n var o = n.context;\n\n if (o.appendToBody) {\n var i = o.$refs.toggle.getBoundingClientRect(),\n r = i.height,\n s = i.top,\n a = i.left,\n l = i.width,\n c = window.scrollX || window.pageXOffset,\n u = window.scrollY || window.pageYOffset;\n t.unbindPosition = o.calculatePosition(t, o, {\n width: l + \"px\",\n left: c + a + \"px\",\n top: u + s + r + \"px\"\n }), document.body.appendChild(t);\n }\n },\n unbind: function unbind(t, e, n) {\n n.context.appendToBody && (t.unbindPosition && \"function\" == typeof t.unbindPosition && t.unbindPosition(), t.parentNode && t.parentNode.removeChild(t));\n }\n };\n\n var y = function y(t) {\n var e = {};\n return Object.keys(t).sort().forEach(function (n) {\n e[n] = t[n];\n }), JSON.stringify(e);\n },\n b = 0;\n\n var g = function g() {\n return ++b;\n };\n\n function v(t, e) {\n var n = Object.keys(t);\n\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(t);\n e && (o = o.filter(function (e) {\n return Object.getOwnPropertyDescriptor(t, e).enumerable;\n })), n.push.apply(n, o);\n }\n\n return n;\n }\n\n function m(t) {\n for (var e = 1; e < arguments.length; e++) {\n var n = null != arguments[e] ? arguments[e] : {};\n e % 2 ? v(Object(n), !0).forEach(function (e) {\n l()(t, e, n[e]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : v(Object(n)).forEach(function (e) {\n Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e));\n });\n }\n\n return t;\n }\n\n var _ = {\n components: m({}, d),\n mixins: [c, u, p],\n directives: {\n appendToBody: f\n },\n props: {\n value: {},\n components: {\n type: Object,\n \"default\": function _default() {\n return {};\n }\n },\n options: {\n type: Array,\n \"default\": function _default() {\n return [];\n }\n },\n disabled: {\n type: Boolean,\n \"default\": !1\n },\n clearable: {\n type: Boolean,\n \"default\": !0\n },\n searchable: {\n type: Boolean,\n \"default\": !0\n },\n multiple: {\n type: Boolean,\n \"default\": !1\n },\n placeholder: {\n type: String,\n \"default\": \"\"\n },\n transition: {\n type: String,\n \"default\": \"vs__fade\"\n },\n clearSearchOnSelect: {\n type: Boolean,\n \"default\": !0\n },\n closeOnSelect: {\n type: Boolean,\n \"default\": !0\n },\n label: {\n type: String,\n \"default\": \"label\"\n },\n autocomplete: {\n type: String,\n \"default\": \"off\"\n },\n reduce: {\n type: Function,\n \"default\": function _default(t) {\n return t;\n }\n },\n selectable: {\n type: Function,\n \"default\": function _default(t) {\n return !0;\n }\n },\n getOptionLabel: {\n type: Function,\n \"default\": function _default(t) {\n return \"object\" === s()(t) ? t.hasOwnProperty(this.label) ? t[this.label] : console.warn('[vue-select warn]: Label key \"option.'.concat(this.label, '\" does not') + \" exist in options object \".concat(JSON.stringify(t), \".\\n\") + \"https://vue-select.org/api/props.html#getoptionlabel\") : t;\n }\n },\n getOptionKey: {\n type: Function,\n \"default\": function _default(t) {\n if (\"object\" !== s()(t)) return t;\n\n try {\n return t.hasOwnProperty(\"id\") ? t.id : y(t);\n } catch (e) {\n return console.warn(\"[vue-select warn]: Could not stringify this option to generate unique key. Please provide'getOptionKey' prop to return a unique key for each option.\\nhttps://vue-select.org/api/props.html#getoptionkey\", t, e);\n }\n }\n },\n onTab: {\n type: Function,\n \"default\": function _default() {\n this.selectOnTab && !this.isComposing && this.typeAheadSelect();\n }\n },\n taggable: {\n type: Boolean,\n \"default\": !1\n },\n tabindex: {\n type: Number,\n \"default\": null\n },\n pushTags: {\n type: Boolean,\n \"default\": !1\n },\n filterable: {\n type: Boolean,\n \"default\": !0\n },\n filterBy: {\n type: Function,\n \"default\": function _default(t, e, n) {\n return (e || \"\").toLowerCase().indexOf(n.toLowerCase()) > -1;\n }\n },\n filter: {\n type: Function,\n \"default\": function _default(t, e) {\n var n = this;\n return t.filter(function (t) {\n var o = n.getOptionLabel(t);\n return \"number\" == typeof o && (o = o.toString()), n.filterBy(t, o, e);\n });\n }\n },\n createOption: {\n type: Function,\n \"default\": function _default(t) {\n return \"object\" === s()(this.optionList[0]) ? l()({}, this.label, t) : t;\n }\n },\n resetOnOptionsChange: {\n \"default\": !1,\n validator: function validator(t) {\n return [\"function\", \"boolean\"].includes(s()(t));\n }\n },\n clearSearchOnBlur: {\n type: Function,\n \"default\": function _default(t) {\n var e = t.clearSearchOnSelect,\n n = t.multiple;\n return e && !n;\n }\n },\n noDrop: {\n type: Boolean,\n \"default\": !1\n },\n inputId: {\n type: String\n },\n dir: {\n type: String,\n \"default\": \"auto\"\n },\n selectOnTab: {\n type: Boolean,\n \"default\": !1\n },\n selectOnKeyCodes: {\n type: Array,\n \"default\": function _default() {\n return [13];\n }\n },\n searchInputQuerySelector: {\n type: String,\n \"default\": \"[type=search]\"\n },\n mapKeydown: {\n type: Function,\n \"default\": function _default(t, e) {\n return t;\n }\n },\n appendToBody: {\n type: Boolean,\n \"default\": !1\n },\n calculatePosition: {\n type: Function,\n \"default\": function _default(t, e, n) {\n var o = n.width,\n i = n.top,\n r = n.left;\n t.style.top = i, t.style.left = r, t.style.width = o;\n }\n }\n },\n data: function data() {\n return {\n uid: g(),\n search: \"\",\n open: !1,\n isComposing: !1,\n pushedTags: [],\n _value: []\n };\n },\n watch: {\n options: function options(t, e) {\n var n = this;\n !this.taggable && (\"function\" == typeof n.resetOnOptionsChange ? n.resetOnOptionsChange(t, e, n.selectedValue) : n.resetOnOptionsChange) && this.clearSelection(), this.value && this.isTrackingValues && this.setInternalValueFromOptions(this.value);\n },\n value: function value(t) {\n this.isTrackingValues && this.setInternalValueFromOptions(t);\n },\n multiple: function multiple() {\n this.clearSelection();\n },\n open: function open(t) {\n this.$emit(t ? \"open\" : \"close\");\n }\n },\n created: function created() {\n this.mutableLoading = this.loading, void 0 !== this.value && this.isTrackingValues && this.setInternalValueFromOptions(this.value), this.$on(\"option:created\", this.pushTag);\n },\n methods: {\n setInternalValueFromOptions: function setInternalValueFromOptions(t) {\n var e = this;\n Array.isArray(t) ? this.$data._value = t.map(function (t) {\n return e.findOptionFromReducedValue(t);\n }) : this.$data._value = this.findOptionFromReducedValue(t);\n },\n select: function select(t) {\n this.isOptionSelected(t) || (this.taggable && !this.optionExists(t) && this.$emit(\"option:created\", t), this.multiple && (t = this.selectedValue.concat(t)), this.updateValue(t)), this.onAfterSelect(t);\n },\n deselect: function deselect(t) {\n var e = this;\n this.updateValue(this.selectedValue.filter(function (n) {\n return !e.optionComparator(n, t);\n }));\n },\n clearSelection: function clearSelection() {\n this.updateValue(this.multiple ? [] : null);\n },\n onAfterSelect: function onAfterSelect(t) {\n this.closeOnSelect && (this.open = !this.open, this.searchEl.blur()), this.clearSearchOnSelect && (this.search = \"\");\n },\n updateValue: function updateValue(t) {\n var e = this;\n void 0 === this.value && (this.$data._value = t), null !== t && (t = Array.isArray(t) ? t.map(function (t) {\n return e.reduce(t);\n }) : this.reduce(t)), this.$emit(\"input\", t);\n },\n toggleDropdown: function toggleDropdown(t) {\n var e = t.target !== this.searchEl;\n e && t.preventDefault(), [].concat(i()(this.$refs.deselectButtons || []), i()([this.$refs.clearButton] || !1)).some(function (e) {\n return e.contains(t.target) || e === t.target;\n }) ? t.preventDefault() : this.open && e ? this.searchEl.blur() : this.disabled || (this.open = !0, this.searchEl.focus());\n },\n isOptionSelected: function isOptionSelected(t) {\n var e = this;\n return this.selectedValue.some(function (n) {\n return e.optionComparator(n, t);\n });\n },\n optionComparator: function optionComparator(t, e) {\n return this.getOptionKey(t) === this.getOptionKey(e);\n },\n findOptionFromReducedValue: function findOptionFromReducedValue(t) {\n var e = this,\n n = [].concat(i()(this.options), i()(this.pushedTags)).filter(function (n) {\n return JSON.stringify(e.reduce(n)) === JSON.stringify(t);\n });\n return 1 === n.length ? n[0] : n.find(function (t) {\n return e.optionComparator(t, e.$data._value);\n }) || t;\n },\n closeSearchOptions: function closeSearchOptions() {\n this.open = !1, this.$emit(\"search:blur\");\n },\n maybeDeleteValue: function maybeDeleteValue() {\n if (!this.searchEl.value.length && this.selectedValue && this.selectedValue.length && this.clearable) {\n var t = null;\n this.multiple && (t = i()(this.selectedValue.slice(0, this.selectedValue.length - 1))), this.updateValue(t);\n }\n },\n optionExists: function optionExists(t) {\n var e = this;\n return this.optionList.some(function (n) {\n return e.optionComparator(n, t);\n });\n },\n normalizeOptionForSlot: function normalizeOptionForSlot(t) {\n return \"object\" === s()(t) ? t : l()({}, this.label, t);\n },\n pushTag: function pushTag(t) {\n this.pushedTags.push(t);\n },\n onEscape: function onEscape() {\n this.search.length ? this.search = \"\" : this.searchEl.blur();\n },\n onSearchBlur: function onSearchBlur() {\n if (!this.mousedown || this.searching) {\n var t = this.clearSearchOnSelect,\n e = this.multiple;\n return this.clearSearchOnBlur({\n clearSearchOnSelect: t,\n multiple: e\n }) && (this.search = \"\"), void this.closeSearchOptions();\n }\n\n this.mousedown = !1, 0 !== this.search.length || 0 !== this.options.length || this.closeSearchOptions();\n },\n onSearchFocus: function onSearchFocus() {\n this.open = !0, this.$emit(\"search:focus\");\n },\n onMousedown: function onMousedown() {\n this.mousedown = !0;\n },\n onMouseUp: function onMouseUp() {\n this.mousedown = !1;\n },\n onSearchKeyDown: function onSearchKeyDown(t) {\n var e = this,\n n = function n(t) {\n return t.preventDefault(), !e.isComposing && e.typeAheadSelect();\n },\n o = {\n 8: function _(t) {\n return e.maybeDeleteValue();\n },\n 9: function _(t) {\n return e.onTab();\n },\n 27: function _(t) {\n return e.onEscape();\n },\n 38: function _(t) {\n return t.preventDefault(), e.typeAheadUp();\n },\n 40: function _(t) {\n return t.preventDefault(), e.typeAheadDown();\n }\n };\n\n this.selectOnKeyCodes.forEach(function (t) {\n return o[t] = n;\n });\n var i = this.mapKeydown(o, this);\n if (\"function\" == typeof i[t.keyCode]) return i[t.keyCode](t);\n }\n },\n computed: {\n isTrackingValues: function isTrackingValues() {\n return void 0 === this.value || this.$options.propsData.hasOwnProperty(\"reduce\");\n },\n selectedValue: function selectedValue() {\n var t = this.value;\n return this.isTrackingValues && (t = this.$data._value), t ? [].concat(t) : [];\n },\n optionList: function optionList() {\n return this.options.concat(this.pushTags ? this.pushedTags : []);\n },\n searchEl: function searchEl() {\n return this.$scopedSlots.search ? this.$refs.selectedOptions.querySelector(this.searchInputQuerySelector) : this.$refs.search;\n },\n scope: function scope() {\n var t = this,\n e = {\n search: this.search,\n loading: this.loading,\n searching: this.searching,\n filteredOptions: this.filteredOptions\n };\n return {\n search: {\n attributes: m({\n disabled: this.disabled,\n placeholder: this.searchPlaceholder,\n tabindex: this.tabindex,\n readonly: !this.searchable,\n id: this.inputId,\n \"aria-autocomplete\": \"list\",\n \"aria-labelledby\": \"vs\".concat(this.uid, \"__combobox\"),\n \"aria-controls\": \"vs\".concat(this.uid, \"__listbox\"),\n ref: \"search\",\n type: \"search\",\n autocomplete: this.autocomplete,\n value: this.search\n }, this.dropdownOpen && this.filteredOptions[this.typeAheadPointer] ? {\n \"aria-activedescendant\": \"vs\".concat(this.uid, \"__option-\").concat(this.typeAheadPointer)\n } : {}),\n events: {\n compositionstart: function compositionstart() {\n return t.isComposing = !0;\n },\n compositionend: function compositionend() {\n return t.isComposing = !1;\n },\n keydown: this.onSearchKeyDown,\n blur: this.onSearchBlur,\n focus: this.onSearchFocus,\n input: function input(e) {\n return t.search = e.target.value;\n }\n }\n },\n spinner: {\n loading: this.mutableLoading\n },\n noOptions: {\n search: this.search,\n loading: this.loading,\n searching: this.searching\n },\n openIndicator: {\n attributes: {\n ref: \"openIndicator\",\n role: \"presentation\",\n \"class\": \"vs__open-indicator\"\n }\n },\n listHeader: e,\n listFooter: e,\n header: m({}, e, {\n deselect: this.deselect\n }),\n footer: m({}, e, {\n deselect: this.deselect\n })\n };\n },\n childComponents: function childComponents() {\n return m({}, d, {}, this.components);\n },\n stateClasses: function stateClasses() {\n return {\n \"vs--open\": this.dropdownOpen,\n \"vs--single\": !this.multiple,\n \"vs--searching\": this.searching && !this.noDrop,\n \"vs--searchable\": this.searchable && !this.noDrop,\n \"vs--unsearchable\": !this.searchable,\n \"vs--loading\": this.mutableLoading,\n \"vs--disabled\": this.disabled\n };\n },\n searching: function searching() {\n return !!this.search;\n },\n dropdownOpen: function dropdownOpen() {\n return !this.noDrop && this.open && !this.mutableLoading;\n },\n searchPlaceholder: function searchPlaceholder() {\n if (this.isValueEmpty && this.placeholder) return this.placeholder;\n },\n filteredOptions: function filteredOptions() {\n var t = [].concat(this.optionList);\n if (!this.filterable && !this.taggable) return t;\n var e = this.search.length ? this.filter(t, this.search, this) : t;\n\n if (this.taggable && this.search.length) {\n var n = this.createOption(this.search);\n this.optionExists(n) || e.unshift(n);\n }\n\n return e;\n },\n isValueEmpty: function isValueEmpty() {\n return 0 === this.selectedValue.length;\n },\n showClearButton: function showClearButton() {\n return !this.multiple && this.clearable && !this.open && !this.isValueEmpty;\n }\n }\n },\n O = (n(7), h(_, function () {\n var t = this,\n e = t.$createElement,\n n = t._self._c || e;\n return n(\"div\", {\n staticClass: \"v-select\",\n \"class\": t.stateClasses,\n attrs: {\n dir: t.dir\n }\n }, [t._t(\"header\", null, null, t.scope.header), t._v(\" \"), n(\"div\", {\n ref: \"toggle\",\n staticClass: \"vs__dropdown-toggle\",\n attrs: {\n id: \"vs\" + t.uid + \"__combobox\",\n role: \"combobox\",\n \"aria-expanded\": t.dropdownOpen.toString(),\n \"aria-owns\": \"vs\" + t.uid + \"__listbox\",\n \"aria-label\": \"Search for option\"\n },\n on: {\n mousedown: function mousedown(e) {\n return t.toggleDropdown(e);\n }\n }\n }, [n(\"div\", {\n ref: \"selectedOptions\",\n staticClass: \"vs__selected-options\"\n }, [t._l(t.selectedValue, function (e) {\n return t._t(\"selected-option-container\", [n(\"span\", {\n key: t.getOptionKey(e),\n staticClass: \"vs__selected\"\n }, [t._t(\"selected-option\", [t._v(\"\\n \" + t._s(t.getOptionLabel(e)) + \"\\n \")], null, t.normalizeOptionForSlot(e)), t._v(\" \"), t.multiple ? n(\"button\", {\n ref: \"deselectButtons\",\n refInFor: !0,\n staticClass: \"vs__deselect\",\n attrs: {\n disabled: t.disabled,\n type: \"button\",\n title: \"Deselect \" + t.getOptionLabel(e),\n \"aria-label\": \"Deselect \" + t.getOptionLabel(e)\n },\n on: {\n click: function click(n) {\n return t.deselect(e);\n }\n }\n }, [n(t.childComponents.Deselect, {\n tag: \"component\"\n })], 1) : t._e()], 2)], {\n option: t.normalizeOptionForSlot(e),\n deselect: t.deselect,\n multiple: t.multiple,\n disabled: t.disabled\n });\n }), t._v(\" \"), t._t(\"search\", [n(\"input\", t._g(t._b({\n staticClass: \"vs__search\"\n }, \"input\", t.scope.search.attributes, !1), t.scope.search.events))], null, t.scope.search)], 2), t._v(\" \"), n(\"div\", {\n ref: \"actions\",\n staticClass: \"vs__actions\"\n }, [n(\"button\", {\n directives: [{\n name: \"show\",\n rawName: \"v-show\",\n value: t.showClearButton,\n expression: \"showClearButton\"\n }],\n ref: \"clearButton\",\n staticClass: \"vs__clear\",\n attrs: {\n disabled: t.disabled,\n type: \"button\",\n title: \"Clear Selected\",\n \"aria-label\": \"Clear Selected\"\n },\n on: {\n click: t.clearSelection\n }\n }, [n(t.childComponents.Deselect, {\n tag: \"component\"\n })], 1), t._v(\" \"), t._t(\"open-indicator\", [t.noDrop ? t._e() : n(t.childComponents.OpenIndicator, t._b({\n tag: \"component\"\n }, \"component\", t.scope.openIndicator.attributes, !1))], null, t.scope.openIndicator), t._v(\" \"), t._t(\"spinner\", [n(\"div\", {\n directives: [{\n name: \"show\",\n rawName: \"v-show\",\n value: t.mutableLoading,\n expression: \"mutableLoading\"\n }],\n staticClass: \"vs__spinner\"\n }, [t._v(\"Loading...\")])], null, t.scope.spinner)], 2)]), t._v(\" \"), n(\"transition\", {\n attrs: {\n name: t.transition\n }\n }, [t.dropdownOpen ? n(\"ul\", {\n directives: [{\n name: \"append-to-body\",\n rawName: \"v-append-to-body\"\n }],\n key: \"vs\" + t.uid + \"__listbox\",\n ref: \"dropdownMenu\",\n staticClass: \"vs__dropdown-menu\",\n attrs: {\n id: \"vs\" + t.uid + \"__listbox\",\n role: \"listbox\"\n },\n on: {\n mousedown: function mousedown(e) {\n return e.preventDefault(), t.onMousedown(e);\n },\n mouseup: t.onMouseUp\n }\n }, [t._t(\"list-header\", null, null, t.scope.listHeader), t._v(\" \"), t._l(t.filteredOptions, function (e, o) {\n return n(\"li\", {\n key: t.getOptionKey(e),\n staticClass: \"vs__dropdown-option\",\n \"class\": {\n \"vs__dropdown-option--selected\": t.isOptionSelected(e),\n \"vs__dropdown-option--highlight\": o === t.typeAheadPointer,\n \"vs__dropdown-option--disabled\": !t.selectable(e)\n },\n attrs: {\n role: \"option\",\n id: \"vs\" + t.uid + \"__option-\" + o,\n \"aria-selected\": o === t.typeAheadPointer || null\n },\n on: {\n mouseover: function mouseover(n) {\n t.selectable(e) && (t.typeAheadPointer = o);\n },\n mousedown: function mousedown(n) {\n n.preventDefault(), n.stopPropagation(), t.selectable(e) && t.select(e);\n }\n }\n }, [t._t(\"option\", [t._v(\"\\n \" + t._s(t.getOptionLabel(e)) + \"\\n \")], null, t.normalizeOptionForSlot(e))], 2);\n }), t._v(\" \"), 0 === t.filteredOptions.length ? n(\"li\", {\n staticClass: \"vs__no-options\"\n }, [t._t(\"no-options\", [t._v(\"Sorry, no matching options.\")], null, t.scope.noOptions)], 2) : t._e(), t._v(\" \"), t._t(\"list-footer\", null, null, t.scope.listFooter)], 2) : n(\"ul\", {\n staticStyle: {\n display: \"none\",\n visibility: \"hidden\"\n },\n attrs: {\n id: \"vs\" + t.uid + \"__listbox\",\n role: \"listbox\"\n }\n })]), t._v(\" \"), t._t(\"footer\", null, null, t.scope.footer)], 2);\n }, [], !1, null, null, null).exports),\n w = {\n ajax: p,\n pointer: u,\n pointerScroll: c\n };\n n.d(e, \"VueSelect\", function () {\n return O;\n }), n.d(e, \"mixins\", function () {\n return w;\n });\n e[\"default\"] = O;\n }]);\n});","import request from '@utils/request'\n\nexport function getFriendLists(payload) {\n return request({\n url: `/friends/lists`,\n method: 'get',\n params: {\n ...payload\n }\n })\n}\n\nexport function userFollowToggle (data) {\n return request({\n url: '/friends/follow_toggle',\n method: 'post',\n data //{ user_id }\n })\n}\n\nexport function addFriend(data) {\n return request({\n url: `/friends`,\n method: 'post',\n data //{ user_id }\n })\n}\n","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/*!\n * vue-i18n v8.21.1 \n * (c) 2020 kazuya kawaguchi\n * Released under the MIT License.\n */\n\n/* */\n\n/**\n * constants\n */\nvar numberFormatKeys = ['style', 'currency', 'currencyDisplay', 'useGrouping', 'minimumIntegerDigits', 'minimumFractionDigits', 'maximumFractionDigits', 'minimumSignificantDigits', 'maximumSignificantDigits', 'localeMatcher', 'formatMatcher', 'unit'];\n/**\n * utilities\n */\n\nfunction warn(msg, err) {\n if (typeof console !== 'undefined') {\n console.warn('[vue-i18n] ' + msg);\n /* istanbul ignore if */\n\n if (err) {\n console.warn(err.stack);\n }\n }\n}\n\nfunction error(msg, err) {\n if (typeof console !== 'undefined') {\n console.error('[vue-i18n] ' + msg);\n /* istanbul ignore if */\n\n if (err) {\n console.error(err.stack);\n }\n }\n}\n\nvar isArray = Array.isArray;\n\nfunction isObject(obj) {\n return obj !== null && _typeof(obj) === 'object';\n}\n\nfunction isBoolean(val) {\n return typeof val === 'boolean';\n}\n\nfunction isString(val) {\n return typeof val === 'string';\n}\n\nvar toString = Object.prototype.toString;\nvar OBJECT_STRING = '[object Object]';\n\nfunction isPlainObject(obj) {\n return toString.call(obj) === OBJECT_STRING;\n}\n\nfunction isNull(val) {\n return val === null || val === undefined;\n}\n\nfunction isFunction(val) {\n return typeof val === 'function';\n}\n\nfunction parseArgs() {\n var args = [],\n len = arguments.length;\n\n while (len--) {\n args[len] = arguments[len];\n }\n\n var locale = null;\n var params = null;\n\n if (args.length === 1) {\n if (isObject(args[0]) || isArray(args[0])) {\n params = args[0];\n } else if (typeof args[0] === 'string') {\n locale = args[0];\n }\n } else if (args.length === 2) {\n if (typeof args[0] === 'string') {\n locale = args[0];\n }\n /* istanbul ignore if */\n\n\n if (isObject(args[1]) || isArray(args[1])) {\n params = args[1];\n }\n }\n\n return {\n locale: locale,\n params: params\n };\n}\n\nfunction looseClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}\n\nfunction remove(arr, item) {\n if (arr.length) {\n var index = arr.indexOf(item);\n\n if (index > -1) {\n return arr.splice(index, 1);\n }\n }\n}\n\nfunction includes(arr, item) {\n return !!~arr.indexOf(item);\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction hasOwn(obj, key) {\n return hasOwnProperty.call(obj, key);\n}\n\nfunction merge(target) {\n var arguments$1 = arguments;\n var output = Object(target);\n\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments$1[i];\n\n if (source !== undefined && source !== null) {\n var key = void 0;\n\n for (key in source) {\n if (hasOwn(source, key)) {\n if (isObject(source[key])) {\n output[key] = merge(output[key], source[key]);\n } else {\n output[key] = source[key];\n }\n }\n }\n }\n }\n\n return output;\n}\n\nfunction looseEqual(a, b) {\n if (a === b) {\n return true;\n }\n\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n\n if (isObjectA && isObjectB) {\n try {\n var isArrayA = isArray(a);\n var isArrayB = isArray(b);\n\n if (isArrayA && isArrayB) {\n return a.length === b.length && a.every(function (e, i) {\n return looseEqual(e, b[i]);\n });\n } else if (!isArrayA && !isArrayB) {\n var keysA = Object.keys(a);\n var keysB = Object.keys(b);\n return keysA.length === keysB.length && keysA.every(function (key) {\n return looseEqual(a[key], b[key]);\n });\n } else {\n /* istanbul ignore next */\n return false;\n }\n } catch (e) {\n /* istanbul ignore next */\n return false;\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b);\n } else {\n return false;\n }\n}\n/* */\n\n\nfunction extend(Vue) {\n if (!Vue.prototype.hasOwnProperty('$i18n')) {\n // $FlowFixMe\n Object.defineProperty(Vue.prototype, '$i18n', {\n get: function get() {\n return this._i18n;\n }\n });\n }\n\n Vue.prototype.$t = function (key) {\n var values = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n values[len] = arguments[len + 1];\n }\n\n var i18n = this.$i18n;\n return i18n._t.apply(i18n, [key, i18n.locale, i18n._getMessages(), this].concat(values));\n };\n\n Vue.prototype.$tc = function (key, choice) {\n var values = [],\n len = arguments.length - 2;\n\n while (len-- > 0) {\n values[len] = arguments[len + 2];\n }\n\n var i18n = this.$i18n;\n return i18n._tc.apply(i18n, [key, i18n.locale, i18n._getMessages(), this, choice].concat(values));\n };\n\n Vue.prototype.$te = function (key, locale) {\n var i18n = this.$i18n;\n return i18n._te(key, i18n.locale, i18n._getMessages(), locale);\n };\n\n Vue.prototype.$d = function (value) {\n var ref;\n var args = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n args[len] = arguments[len + 1];\n }\n\n return (ref = this.$i18n).d.apply(ref, [value].concat(args));\n };\n\n Vue.prototype.$n = function (value) {\n var ref;\n var args = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n args[len] = arguments[len + 1];\n }\n\n return (ref = this.$i18n).n.apply(ref, [value].concat(args));\n };\n}\n/* */\n\n\nvar mixin = {\n beforeCreate: function beforeCreate() {\n var options = this.$options;\n options.i18n = options.i18n || (options.__i18n ? {} : null);\n\n if (options.i18n) {\n if (options.i18n instanceof VueI18n) {\n // init locale messages via custom blocks\n if (options.__i18n) {\n try {\n var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};\n\n options.__i18n.forEach(function (resource) {\n localeMessages = merge(localeMessages, JSON.parse(resource));\n });\n\n Object.keys(localeMessages).forEach(function (locale) {\n options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);\n });\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n error(\"Cannot parse locale messages via custom blocks.\", e);\n }\n }\n }\n\n this._i18n = options.i18n;\n this._i18nWatcher = this._i18n.watchI18nData();\n } else if (isPlainObject(options.i18n)) {\n var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n ? this.$root.$i18n : null; // component local i18n\n\n if (rootI18n) {\n options.i18n.root = this.$root;\n options.i18n.formatter = rootI18n.formatter;\n options.i18n.fallbackLocale = rootI18n.fallbackLocale;\n options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;\n options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;\n options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;\n options.i18n.pluralizationRules = rootI18n.pluralizationRules;\n options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;\n } // init locale messages via custom blocks\n\n\n if (options.__i18n) {\n try {\n var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};\n\n options.__i18n.forEach(function (resource) {\n localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));\n });\n\n options.i18n.messages = localeMessages$1;\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Cannot parse locale messages via custom blocks.\", e);\n }\n }\n }\n\n var ref = options.i18n;\n var sharedMessages = ref.sharedMessages;\n\n if (sharedMessages && isPlainObject(sharedMessages)) {\n options.i18n.messages = merge(options.i18n.messages, sharedMessages);\n }\n\n this._i18n = new VueI18n(options.i18n);\n this._i18nWatcher = this._i18n.watchI18nData();\n\n if (options.i18n.sync === undefined || !!options.i18n.sync) {\n this._localeWatcher = this.$i18n.watchLocale();\n }\n\n if (rootI18n) {\n rootI18n.onComponentInstanceCreated(this._i18n);\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Cannot be interpreted 'i18n' option.\");\n }\n }\n } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {\n // root i18n\n this._i18n = this.$root.$i18n;\n } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {\n // parent i18n\n this._i18n = options.parent.$i18n;\n }\n },\n beforeMount: function beforeMount() {\n var options = this.$options;\n options.i18n = options.i18n || (options.__i18n ? {} : null);\n\n if (options.i18n) {\n if (options.i18n instanceof VueI18n) {\n // init locale messages via custom blocks\n this._i18n.subscribeDataChanging(this);\n\n this._subscribing = true;\n } else if (isPlainObject(options.i18n)) {\n this._i18n.subscribeDataChanging(this);\n\n this._subscribing = true;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Cannot be interpreted 'i18n' option.\");\n }\n }\n } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {\n this._i18n.subscribeDataChanging(this);\n\n this._subscribing = true;\n } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {\n this._i18n.subscribeDataChanging(this);\n\n this._subscribing = true;\n }\n },\n beforeDestroy: function beforeDestroy() {\n if (!this._i18n) {\n return;\n }\n\n var self = this;\n this.$nextTick(function () {\n if (self._subscribing) {\n self._i18n.unsubscribeDataChanging(self);\n\n delete self._subscribing;\n }\n\n if (self._i18nWatcher) {\n self._i18nWatcher();\n\n self._i18n.destroyVM();\n\n delete self._i18nWatcher;\n }\n\n if (self._localeWatcher) {\n self._localeWatcher();\n\n delete self._localeWatcher;\n }\n });\n }\n};\n/* */\n\nvar interpolationComponent = {\n name: 'i18n',\n functional: true,\n props: {\n tag: {\n type: [String, Boolean, Object],\n \"default\": 'span'\n },\n path: {\n type: String,\n required: true\n },\n locale: {\n type: String\n },\n places: {\n type: [Array, Object]\n }\n },\n render: function render(h, ref) {\n var data = ref.data;\n var parent = ref.parent;\n var props = ref.props;\n var slots = ref.slots;\n var $i18n = parent.$i18n;\n\n if (!$i18n) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot find VueI18n instance!');\n }\n\n return;\n }\n\n var path = props.path;\n var locale = props.locale;\n var places = props.places;\n var params = slots();\n var children = $i18n.i(path, locale, onlyHasDefaultPlace(params) || places ? useLegacyPlaces(params[\"default\"], places) : params);\n var tag = !!props.tag && props.tag !== true || props.tag === false ? props.tag : 'span';\n return tag ? h(tag, data, children) : children;\n }\n};\n\nfunction onlyHasDefaultPlace(params) {\n var prop;\n\n for (prop in params) {\n if (prop !== 'default') {\n return false;\n }\n }\n\n return Boolean(prop);\n}\n\nfunction useLegacyPlaces(children, places) {\n var params = places ? createParamsFromPlaces(places) : {};\n\n if (!children) {\n return params;\n } // Filter empty text nodes\n\n\n children = children.filter(function (child) {\n return child.tag || child.text.trim() !== '';\n });\n var everyPlace = children.every(vnodeHasPlaceAttribute);\n\n if (process.env.NODE_ENV !== 'production' && everyPlace) {\n warn('`place` attribute is deprecated in next major version. Please switch to Vue slots.');\n }\n\n return children.reduce(everyPlace ? assignChildPlace : assignChildIndex, params);\n}\n\nfunction createParamsFromPlaces(places) {\n if (process.env.NODE_ENV !== 'production') {\n warn('`places` prop is deprecated in next major version. Please switch to Vue slots.');\n }\n\n return Array.isArray(places) ? places.reduce(assignChildIndex, {}) : Object.assign({}, places);\n}\n\nfunction assignChildPlace(params, child) {\n if (child.data && child.data.attrs && child.data.attrs.place) {\n params[child.data.attrs.place] = child;\n }\n\n return params;\n}\n\nfunction assignChildIndex(params, child, index) {\n params[index] = child;\n return params;\n}\n\nfunction vnodeHasPlaceAttribute(vnode) {\n return Boolean(vnode.data && vnode.data.attrs && vnode.data.attrs.place);\n}\n/* */\n\n\nvar numberComponent = {\n name: 'i18n-n',\n functional: true,\n props: {\n tag: {\n type: [String, Boolean, Object],\n \"default\": 'span'\n },\n value: {\n type: Number,\n required: true\n },\n format: {\n type: [String, Object]\n },\n locale: {\n type: String\n }\n },\n render: function render(h, ref) {\n var props = ref.props;\n var parent = ref.parent;\n var data = ref.data;\n var i18n = parent.$i18n;\n\n if (!i18n) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot find VueI18n instance!');\n }\n\n return null;\n }\n\n var key = null;\n var options = null;\n\n if (isString(props.format)) {\n key = props.format;\n } else if (isObject(props.format)) {\n if (props.format.key) {\n key = props.format.key;\n } // Filter out number format options only\n\n\n options = Object.keys(props.format).reduce(function (acc, prop) {\n var obj;\n\n if (includes(numberFormatKeys, prop)) {\n return Object.assign({}, acc, (obj = {}, obj[prop] = props.format[prop], obj));\n }\n\n return acc;\n }, null);\n }\n\n var locale = props.locale || i18n.locale;\n\n var parts = i18n._ntp(props.value, locale, key, options);\n\n var values = parts.map(function (part, index) {\n var obj;\n var slot = data.scopedSlots && data.scopedSlots[part.type];\n return slot ? slot((obj = {}, obj[part.type] = part.value, obj.index = index, obj.parts = parts, obj)) : part.value;\n });\n var tag = !!props.tag && props.tag !== true || props.tag === false ? props.tag : 'span';\n return tag ? h(tag, {\n attrs: data.attrs,\n 'class': data['class'],\n staticClass: data.staticClass\n }, values) : values;\n }\n};\n/* */\n\nfunction bind(el, binding, vnode) {\n if (!assert(el, vnode)) {\n return;\n }\n\n t(el, binding, vnode);\n}\n\nfunction update(el, binding, vnode, oldVNode) {\n if (!assert(el, vnode)) {\n return;\n }\n\n var i18n = vnode.context.$i18n;\n\n if (localeEqual(el, vnode) && looseEqual(binding.value, binding.oldValue) && looseEqual(el._localeMessage, i18n.getLocaleMessage(i18n.locale))) {\n return;\n }\n\n t(el, binding, vnode);\n}\n\nfunction unbind(el, binding, vnode, oldVNode) {\n var vm = vnode.context;\n\n if (!vm) {\n warn('Vue instance does not exists in VNode context');\n return;\n }\n\n var i18n = vnode.context.$i18n || {};\n\n if (!binding.modifiers.preserve && !i18n.preserveDirectiveContent) {\n el.textContent = '';\n }\n\n el._vt = undefined;\n delete el['_vt'];\n el._locale = undefined;\n delete el['_locale'];\n el._localeMessage = undefined;\n delete el['_localeMessage'];\n}\n\nfunction assert(el, vnode) {\n var vm = vnode.context;\n\n if (!vm) {\n warn('Vue instance does not exists in VNode context');\n return false;\n }\n\n if (!vm.$i18n) {\n warn('VueI18n instance does not exists in Vue instance');\n return false;\n }\n\n return true;\n}\n\nfunction localeEqual(el, vnode) {\n var vm = vnode.context;\n return el._locale === vm.$i18n.locale;\n}\n\nfunction t(el, binding, vnode) {\n var ref$1, ref$2;\n var value = binding.value;\n var ref = parseValue(value);\n var path = ref.path;\n var locale = ref.locale;\n var args = ref.args;\n var choice = ref.choice;\n\n if (!path && !locale && !args) {\n warn('value type not supported');\n return;\n }\n\n if (!path) {\n warn('`path` is required in v-t directive');\n return;\n }\n\n var vm = vnode.context;\n\n if (choice != null) {\n el._vt = el.textContent = (ref$1 = vm.$i18n).tc.apply(ref$1, [path, choice].concat(makeParams(locale, args)));\n } else {\n el._vt = el.textContent = (ref$2 = vm.$i18n).t.apply(ref$2, [path].concat(makeParams(locale, args)));\n }\n\n el._locale = vm.$i18n.locale;\n el._localeMessage = vm.$i18n.getLocaleMessage(vm.$i18n.locale);\n}\n\nfunction parseValue(value) {\n var path;\n var locale;\n var args;\n var choice;\n\n if (isString(value)) {\n path = value;\n } else if (isPlainObject(value)) {\n path = value.path;\n locale = value.locale;\n args = value.args;\n choice = value.choice;\n }\n\n return {\n path: path,\n locale: locale,\n args: args,\n choice: choice\n };\n}\n\nfunction makeParams(locale, args) {\n var params = [];\n locale && params.push(locale);\n\n if (args && (Array.isArray(args) || isPlainObject(args))) {\n params.push(args);\n }\n\n return params;\n}\n\nvar Vue;\n\nfunction install(_Vue) {\n /* istanbul ignore if */\n if (process.env.NODE_ENV !== 'production' && install.installed && _Vue === Vue) {\n warn('already installed.');\n return;\n }\n\n install.installed = true;\n Vue = _Vue;\n var version = Vue.version && Number(Vue.version.split('.')[0]) || -1;\n /* istanbul ignore if */\n\n if (process.env.NODE_ENV !== 'production' && version < 2) {\n warn(\"vue-i18n (\" + install.version + \") need to use Vue 2.0 or later (Vue: \" + Vue.version + \").\");\n return;\n }\n\n extend(Vue);\n Vue.mixin(mixin);\n Vue.directive('t', {\n bind: bind,\n update: update,\n unbind: unbind\n });\n Vue.component(interpolationComponent.name, interpolationComponent);\n Vue.component(numberComponent.name, numberComponent); // use simple mergeStrategies to prevent i18n instance lose '__proto__'\n\n var strats = Vue.config.optionMergeStrategies;\n\n strats.i18n = function (parentVal, childVal) {\n return childVal === undefined ? parentVal : childVal;\n };\n}\n/* */\n\n\nvar BaseFormatter = function BaseFormatter() {\n this._caches = Object.create(null);\n};\n\nBaseFormatter.prototype.interpolate = function interpolate(message, values) {\n if (!values) {\n return [message];\n }\n\n var tokens = this._caches[message];\n\n if (!tokens) {\n tokens = parse(message);\n this._caches[message] = tokens;\n }\n\n return compile(tokens, values);\n};\n\nvar RE_TOKEN_LIST_VALUE = /^(?:\\d)+/;\nvar RE_TOKEN_NAMED_VALUE = /^(?:\\w)+/;\n\nfunction parse(format) {\n var tokens = [];\n var position = 0;\n var text = '';\n\n while (position < format.length) {\n var _char = format[position++];\n\n if (_char === '{') {\n if (text) {\n tokens.push({\n type: 'text',\n value: text\n });\n }\n\n text = '';\n var sub = '';\n _char = format[position++];\n\n while (_char !== undefined && _char !== '}') {\n sub += _char;\n _char = format[position++];\n }\n\n var isClosed = _char === '}';\n var type = RE_TOKEN_LIST_VALUE.test(sub) ? 'list' : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? 'named' : 'unknown';\n tokens.push({\n value: sub,\n type: type\n });\n } else if (_char === '%') {\n // when found rails i18n syntax, skip text capture\n if (format[position] !== '{') {\n text += _char;\n }\n } else {\n text += _char;\n }\n }\n\n text && tokens.push({\n type: 'text',\n value: text\n });\n return tokens;\n}\n\nfunction compile(tokens, values) {\n var compiled = [];\n var index = 0;\n var mode = Array.isArray(values) ? 'list' : isObject(values) ? 'named' : 'unknown';\n\n if (mode === 'unknown') {\n return compiled;\n }\n\n while (index < tokens.length) {\n var token = tokens[index];\n\n switch (token.type) {\n case 'text':\n compiled.push(token.value);\n break;\n\n case 'list':\n compiled.push(values[parseInt(token.value, 10)]);\n break;\n\n case 'named':\n if (mode === 'named') {\n compiled.push(values[token.value]);\n } else {\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Type of token '\" + token.type + \"' and format of value '\" + mode + \"' don't match!\");\n }\n }\n\n break;\n\n case 'unknown':\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Detect 'unknown' type of token!\");\n }\n\n break;\n }\n\n index++;\n }\n\n return compiled;\n}\n/* */\n\n/**\n * Path parser\n * - Inspired:\n * Vue.js Path parser\n */\n// actions\n\n\nvar APPEND = 0;\nvar PUSH = 1;\nvar INC_SUB_PATH_DEPTH = 2;\nvar PUSH_SUB_PATH = 3; // states\n\nvar BEFORE_PATH = 0;\nvar IN_PATH = 1;\nvar BEFORE_IDENT = 2;\nvar IN_IDENT = 3;\nvar IN_SUB_PATH = 4;\nvar IN_SINGLE_QUOTE = 5;\nvar IN_DOUBLE_QUOTE = 6;\nvar AFTER_PATH = 7;\nvar ERROR = 8;\nvar pathStateMachine = [];\npathStateMachine[BEFORE_PATH] = {\n 'ws': [BEFORE_PATH],\n 'ident': [IN_IDENT, APPEND],\n '[': [IN_SUB_PATH],\n 'eof': [AFTER_PATH]\n};\npathStateMachine[IN_PATH] = {\n 'ws': [IN_PATH],\n '.': [BEFORE_IDENT],\n '[': [IN_SUB_PATH],\n 'eof': [AFTER_PATH]\n};\npathStateMachine[BEFORE_IDENT] = {\n 'ws': [BEFORE_IDENT],\n 'ident': [IN_IDENT, APPEND],\n '0': [IN_IDENT, APPEND],\n 'number': [IN_IDENT, APPEND]\n};\npathStateMachine[IN_IDENT] = {\n 'ident': [IN_IDENT, APPEND],\n '0': [IN_IDENT, APPEND],\n 'number': [IN_IDENT, APPEND],\n 'ws': [IN_PATH, PUSH],\n '.': [BEFORE_IDENT, PUSH],\n '[': [IN_SUB_PATH, PUSH],\n 'eof': [AFTER_PATH, PUSH]\n};\npathStateMachine[IN_SUB_PATH] = {\n \"'\": [IN_SINGLE_QUOTE, APPEND],\n '\"': [IN_DOUBLE_QUOTE, APPEND],\n '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],\n ']': [IN_PATH, PUSH_SUB_PATH],\n 'eof': ERROR,\n 'else': [IN_SUB_PATH, APPEND]\n};\npathStateMachine[IN_SINGLE_QUOTE] = {\n \"'\": [IN_SUB_PATH, APPEND],\n 'eof': ERROR,\n 'else': [IN_SINGLE_QUOTE, APPEND]\n};\npathStateMachine[IN_DOUBLE_QUOTE] = {\n '\"': [IN_SUB_PATH, APPEND],\n 'eof': ERROR,\n 'else': [IN_DOUBLE_QUOTE, APPEND]\n};\n/**\n * Check if an expression is a literal value.\n */\n\nvar literalValueRE = /^\\s?(?:true|false|-?[\\d.]+|'[^']*'|\"[^\"]*\")\\s?$/;\n\nfunction isLiteral(exp) {\n return literalValueRE.test(exp);\n}\n/**\n * Strip quotes from a string\n */\n\n\nfunction stripQuotes(str) {\n var a = str.charCodeAt(0);\n var b = str.charCodeAt(str.length - 1);\n return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;\n}\n/**\n * Determine the type of a character in a keypath.\n */\n\n\nfunction getPathCharType(ch) {\n if (ch === undefined || ch === null) {\n return 'eof';\n }\n\n var code = ch.charCodeAt(0);\n\n switch (code) {\n case 0x5B: // [\n\n case 0x5D: // ]\n\n case 0x2E: // .\n\n case 0x22: // \"\n\n case 0x27:\n // '\n return ch;\n\n case 0x5F: // _\n\n case 0x24: // $\n\n case 0x2D:\n // -\n return 'ident';\n\n case 0x09: // Tab\n\n case 0x0A: // Newline\n\n case 0x0D: // Return\n\n case 0xA0: // No-break space\n\n case 0xFEFF: // Byte Order Mark\n\n case 0x2028: // Line Separator\n\n case 0x2029:\n // Paragraph Separator\n return 'ws';\n }\n\n return 'ident';\n}\n/**\n * Format a subPath, return its plain form if it is\n * a literal string or number. Otherwise prepend the\n * dynamic indicator (*).\n */\n\n\nfunction formatSubPath(path) {\n var trimmed = path.trim(); // invalid leading 0\n\n if (path.charAt(0) === '0' && isNaN(path)) {\n return false;\n }\n\n return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed;\n}\n/**\n * Parse a string path into an array of segments\n */\n\n\nfunction parse$1(path) {\n var keys = [];\n var index = -1;\n var mode = BEFORE_PATH;\n var subPathDepth = 0;\n var c;\n var key;\n var newChar;\n var type;\n var transition;\n var action;\n var typeMap;\n var actions = [];\n\n actions[PUSH] = function () {\n if (key !== undefined) {\n keys.push(key);\n key = undefined;\n }\n };\n\n actions[APPEND] = function () {\n if (key === undefined) {\n key = newChar;\n } else {\n key += newChar;\n }\n };\n\n actions[INC_SUB_PATH_DEPTH] = function () {\n actions[APPEND]();\n subPathDepth++;\n };\n\n actions[PUSH_SUB_PATH] = function () {\n if (subPathDepth > 0) {\n subPathDepth--;\n mode = IN_SUB_PATH;\n actions[APPEND]();\n } else {\n subPathDepth = 0;\n\n if (key === undefined) {\n return false;\n }\n\n key = formatSubPath(key);\n\n if (key === false) {\n return false;\n } else {\n actions[PUSH]();\n }\n }\n };\n\n function maybeUnescapeQuote() {\n var nextChar = path[index + 1];\n\n if (mode === IN_SINGLE_QUOTE && nextChar === \"'\" || mode === IN_DOUBLE_QUOTE && nextChar === '\"') {\n index++;\n newChar = '\\\\' + nextChar;\n actions[APPEND]();\n return true;\n }\n }\n\n while (mode !== null) {\n index++;\n c = path[index];\n\n if (c === '\\\\' && maybeUnescapeQuote()) {\n continue;\n }\n\n type = getPathCharType(c);\n typeMap = pathStateMachine[mode];\n transition = typeMap[type] || typeMap['else'] || ERROR;\n\n if (transition === ERROR) {\n return; // parse error\n }\n\n mode = transition[0];\n action = actions[transition[1]];\n\n if (action) {\n newChar = transition[2];\n newChar = newChar === undefined ? c : newChar;\n\n if (action() === false) {\n return;\n }\n }\n\n if (mode === AFTER_PATH) {\n return keys;\n }\n }\n}\n\nvar I18nPath = function I18nPath() {\n this._cache = Object.create(null);\n};\n/**\n * External parse that check for a cache hit first\n */\n\n\nI18nPath.prototype.parsePath = function parsePath(path) {\n var hit = this._cache[path];\n\n if (!hit) {\n hit = parse$1(path);\n\n if (hit) {\n this._cache[path] = hit;\n }\n }\n\n return hit || [];\n};\n/**\n * Get path value from path string\n */\n\n\nI18nPath.prototype.getPathValue = function getPathValue(obj, path) {\n if (!isObject(obj)) {\n return null;\n }\n\n var paths = this.parsePath(path);\n\n if (paths.length === 0) {\n return null;\n } else {\n var length = paths.length;\n var last = obj;\n var i = 0;\n\n while (i < length) {\n var value = last[paths[i]];\n\n if (value === undefined) {\n return null;\n }\n\n last = value;\n i++;\n }\n\n return last;\n }\n};\n/* */\n\n\nvar htmlTagMatcher = /<\\/?[\\w\\s=\"/.':;#-\\/]+>/;\nvar linkKeyMatcher = /(?:@(?:\\.[a-z]+)?:(?:[\\w\\-_|.]+|\\([\\w\\-_|.]+\\)))/g;\nvar linkKeyPrefixMatcher = /^@(?:\\.([a-z]+))?:/;\nvar bracketsMatcher = /[()]/g;\nvar defaultModifiers = {\n 'upper': function upper(str) {\n return str.toLocaleUpperCase();\n },\n 'lower': function lower(str) {\n return str.toLocaleLowerCase();\n },\n 'capitalize': function capitalize(str) {\n return \"\" + str.charAt(0).toLocaleUpperCase() + str.substr(1);\n }\n};\nvar defaultFormatter = new BaseFormatter();\n\nvar VueI18n = function VueI18n(options) {\n var this$1 = this;\n if (options === void 0) options = {}; // Auto install if it is not done yet and `window` has `Vue`.\n // To allow users to avoid auto-installation in some cases,\n // this code should be placed here. See #290\n\n /* istanbul ignore if */\n\n if (!Vue && typeof window !== 'undefined' && window.Vue) {\n install(window.Vue);\n }\n\n var locale = options.locale || 'en-US';\n var fallbackLocale = options.fallbackLocale === false ? false : options.fallbackLocale || 'en-US';\n var messages = options.messages || {};\n var dateTimeFormats = options.dateTimeFormats || {};\n var numberFormats = options.numberFormats || {};\n this._vm = null;\n this._formatter = options.formatter || defaultFormatter;\n this._modifiers = options.modifiers || {};\n this._missing = options.missing || null;\n this._root = options.root || null;\n this._sync = options.sync === undefined ? true : !!options.sync;\n this._fallbackRoot = options.fallbackRoot === undefined ? true : !!options.fallbackRoot;\n this._formatFallbackMessages = options.formatFallbackMessages === undefined ? false : !!options.formatFallbackMessages;\n this._silentTranslationWarn = options.silentTranslationWarn === undefined ? false : options.silentTranslationWarn;\n this._silentFallbackWarn = options.silentFallbackWarn === undefined ? false : !!options.silentFallbackWarn;\n this._dateTimeFormatters = {};\n this._numberFormatters = {};\n this._path = new I18nPath();\n this._dataListeners = [];\n this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;\n this._preserveDirectiveContent = options.preserveDirectiveContent === undefined ? false : !!options.preserveDirectiveContent;\n this.pluralizationRules = options.pluralizationRules || {};\n this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';\n this._postTranslation = options.postTranslation || null;\n /**\n * @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`\n * @param choicesLength {number} an overall amount of available choices\n * @returns a final choice index\n */\n\n this.getChoiceIndex = function (choice, choicesLength) {\n var thisPrototype = Object.getPrototypeOf(this$1);\n\n if (thisPrototype && thisPrototype.getChoiceIndex) {\n var prototypeGetChoiceIndex = thisPrototype.getChoiceIndex;\n return prototypeGetChoiceIndex.call(this$1, choice, choicesLength);\n } // Default (old) getChoiceIndex implementation - english-compatible\n\n\n var defaultImpl = function defaultImpl(_choice, _choicesLength) {\n _choice = Math.abs(_choice);\n\n if (_choicesLength === 2) {\n return _choice ? _choice > 1 ? 1 : 0 : 1;\n }\n\n return _choice ? Math.min(_choice, 2) : 0;\n };\n\n if (this$1.locale in this$1.pluralizationRules) {\n return this$1.pluralizationRules[this$1.locale].apply(this$1, [choice, choicesLength]);\n } else {\n return defaultImpl(choice, choicesLength);\n }\n };\n\n this._exist = function (message, key) {\n if (!message || !key) {\n return false;\n }\n\n if (!isNull(this$1._path.getPathValue(message, key))) {\n return true;\n } // fallback for flat key\n\n\n if (message[key]) {\n return true;\n }\n\n return false;\n };\n\n if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {\n Object.keys(messages).forEach(function (locale) {\n this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);\n });\n }\n\n this._initVM({\n locale: locale,\n fallbackLocale: fallbackLocale,\n messages: messages,\n dateTimeFormats: dateTimeFormats,\n numberFormats: numberFormats\n });\n};\n\nvar prototypeAccessors = {\n vm: {\n configurable: true\n },\n messages: {\n configurable: true\n },\n dateTimeFormats: {\n configurable: true\n },\n numberFormats: {\n configurable: true\n },\n availableLocales: {\n configurable: true\n },\n locale: {\n configurable: true\n },\n fallbackLocale: {\n configurable: true\n },\n formatFallbackMessages: {\n configurable: true\n },\n missing: {\n configurable: true\n },\n formatter: {\n configurable: true\n },\n silentTranslationWarn: {\n configurable: true\n },\n silentFallbackWarn: {\n configurable: true\n },\n preserveDirectiveContent: {\n configurable: true\n },\n warnHtmlInMessage: {\n configurable: true\n },\n postTranslation: {\n configurable: true\n }\n};\n\nVueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage(locale, level, message) {\n var paths = [];\n\n var fn = function fn(level, locale, message, paths) {\n if (isPlainObject(message)) {\n Object.keys(message).forEach(function (key) {\n var val = message[key];\n\n if (isPlainObject(val)) {\n paths.push(key);\n paths.push('.');\n fn(level, locale, val, paths);\n paths.pop();\n paths.pop();\n } else {\n paths.push(key);\n fn(level, locale, val, paths);\n paths.pop();\n }\n });\n } else if (isArray(message)) {\n message.forEach(function (item, index) {\n if (isPlainObject(item)) {\n paths.push(\"[\" + index + \"]\");\n paths.push('.');\n fn(level, locale, item, paths);\n paths.pop();\n paths.pop();\n } else {\n paths.push(\"[\" + index + \"]\");\n fn(level, locale, item, paths);\n paths.pop();\n }\n });\n } else if (isString(message)) {\n var ret = htmlTagMatcher.test(message);\n\n if (ret) {\n var msg = \"Detected HTML in message '\" + message + \"' of keypath '\" + paths.join('') + \"' at '\" + locale + \"'. Consider component interpolation with '
' to avoid XSS. See https://bit.ly/2ZqJzkp\";\n\n if (level === 'warn') {\n warn(msg);\n } else if (level === 'error') {\n error(msg);\n }\n }\n }\n };\n\n fn(level, locale, message, paths);\n};\n\nVueI18n.prototype._initVM = function _initVM(data) {\n var silent = Vue.config.silent;\n Vue.config.silent = true;\n this._vm = new Vue({\n data: data\n });\n Vue.config.silent = silent;\n};\n\nVueI18n.prototype.destroyVM = function destroyVM() {\n this._vm.$destroy();\n};\n\nVueI18n.prototype.subscribeDataChanging = function subscribeDataChanging(vm) {\n this._dataListeners.push(vm);\n};\n\nVueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging(vm) {\n remove(this._dataListeners, vm);\n};\n\nVueI18n.prototype.watchI18nData = function watchI18nData() {\n var self = this;\n return this._vm.$watch('$data', function () {\n var i = self._dataListeners.length;\n\n while (i--) {\n Vue.nextTick(function () {\n self._dataListeners[i] && self._dataListeners[i].$forceUpdate();\n });\n }\n }, {\n deep: true\n });\n};\n\nVueI18n.prototype.watchLocale = function watchLocale() {\n /* istanbul ignore if */\n if (!this._sync || !this._root) {\n return null;\n }\n\n var target = this._vm;\n return this._root.$i18n.vm.$watch('locale', function (val) {\n target.$set(target, 'locale', val);\n target.$forceUpdate();\n }, {\n immediate: true\n });\n};\n\nVueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated(newI18n) {\n if (this._componentInstanceCreatedListener) {\n this._componentInstanceCreatedListener(newI18n, this);\n }\n};\n\nprototypeAccessors.vm.get = function () {\n return this._vm;\n};\n\nprototypeAccessors.messages.get = function () {\n return looseClone(this._getMessages());\n};\n\nprototypeAccessors.dateTimeFormats.get = function () {\n return looseClone(this._getDateTimeFormats());\n};\n\nprototypeAccessors.numberFormats.get = function () {\n return looseClone(this._getNumberFormats());\n};\n\nprototypeAccessors.availableLocales.get = function () {\n return Object.keys(this.messages).sort();\n};\n\nprototypeAccessors.locale.get = function () {\n return this._vm.locale;\n};\n\nprototypeAccessors.locale.set = function (locale) {\n this._vm.$set(this._vm, 'locale', locale);\n};\n\nprototypeAccessors.fallbackLocale.get = function () {\n return this._vm.fallbackLocale;\n};\n\nprototypeAccessors.fallbackLocale.set = function (locale) {\n this._localeChainCache = {};\n\n this._vm.$set(this._vm, 'fallbackLocale', locale);\n};\n\nprototypeAccessors.formatFallbackMessages.get = function () {\n return this._formatFallbackMessages;\n};\n\nprototypeAccessors.formatFallbackMessages.set = function (fallback) {\n this._formatFallbackMessages = fallback;\n};\n\nprototypeAccessors.missing.get = function () {\n return this._missing;\n};\n\nprototypeAccessors.missing.set = function (handler) {\n this._missing = handler;\n};\n\nprototypeAccessors.formatter.get = function () {\n return this._formatter;\n};\n\nprototypeAccessors.formatter.set = function (formatter) {\n this._formatter = formatter;\n};\n\nprototypeAccessors.silentTranslationWarn.get = function () {\n return this._silentTranslationWarn;\n};\n\nprototypeAccessors.silentTranslationWarn.set = function (silent) {\n this._silentTranslationWarn = silent;\n};\n\nprototypeAccessors.silentFallbackWarn.get = function () {\n return this._silentFallbackWarn;\n};\n\nprototypeAccessors.silentFallbackWarn.set = function (silent) {\n this._silentFallbackWarn = silent;\n};\n\nprototypeAccessors.preserveDirectiveContent.get = function () {\n return this._preserveDirectiveContent;\n};\n\nprototypeAccessors.preserveDirectiveContent.set = function (preserve) {\n this._preserveDirectiveContent = preserve;\n};\n\nprototypeAccessors.warnHtmlInMessage.get = function () {\n return this._warnHtmlInMessage;\n};\n\nprototypeAccessors.warnHtmlInMessage.set = function (level) {\n var this$1 = this;\n var orgLevel = this._warnHtmlInMessage;\n this._warnHtmlInMessage = level;\n\n if (orgLevel !== level && (level === 'warn' || level === 'error')) {\n var messages = this._getMessages();\n\n Object.keys(messages).forEach(function (locale) {\n this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);\n });\n }\n};\n\nprototypeAccessors.postTranslation.get = function () {\n return this._postTranslation;\n};\n\nprototypeAccessors.postTranslation.set = function (handler) {\n this._postTranslation = handler;\n};\n\nVueI18n.prototype._getMessages = function _getMessages() {\n return this._vm.messages;\n};\n\nVueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats() {\n return this._vm.dateTimeFormats;\n};\n\nVueI18n.prototype._getNumberFormats = function _getNumberFormats() {\n return this._vm.numberFormats;\n};\n\nVueI18n.prototype._warnDefault = function _warnDefault(locale, key, result, vm, values, interpolateMode) {\n if (!isNull(result)) {\n return result;\n }\n\n if (this._missing) {\n var missingRet = this._missing.apply(null, [locale, key, vm, values]);\n\n if (isString(missingRet)) {\n return missingRet;\n }\n } else {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn(\"Cannot translate the value of keypath '\" + key + \"'. \" + 'Use the value of keypath as default.');\n }\n }\n\n if (this._formatFallbackMessages) {\n var parsedArgs = parseArgs.apply(void 0, values);\n return this._render(key, interpolateMode, parsedArgs.params, key);\n } else {\n return key;\n }\n};\n\nVueI18n.prototype._isFallbackRoot = function _isFallbackRoot(val) {\n return !val && !isNull(this._root) && this._fallbackRoot;\n};\n\nVueI18n.prototype._isSilentFallbackWarn = function _isSilentFallbackWarn(key) {\n return this._silentFallbackWarn instanceof RegExp ? this._silentFallbackWarn.test(key) : this._silentFallbackWarn;\n};\n\nVueI18n.prototype._isSilentFallback = function _isSilentFallback(locale, key) {\n return this._isSilentFallbackWarn(key) && (this._isFallbackRoot() || locale !== this.fallbackLocale);\n};\n\nVueI18n.prototype._isSilentTranslationWarn = function _isSilentTranslationWarn(key) {\n return this._silentTranslationWarn instanceof RegExp ? this._silentTranslationWarn.test(key) : this._silentTranslationWarn;\n};\n\nVueI18n.prototype._interpolate = function _interpolate(locale, message, key, host, interpolateMode, values, visitedLinkStack) {\n if (!message) {\n return null;\n }\n\n var pathRet = this._path.getPathValue(message, key);\n\n if (isArray(pathRet) || isPlainObject(pathRet)) {\n return pathRet;\n }\n\n var ret;\n\n if (isNull(pathRet)) {\n /* istanbul ignore else */\n if (isPlainObject(message)) {\n ret = message[key];\n\n if (!(isString(ret) || isFunction(ret))) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallback(locale, key)) {\n warn(\"Value of key '\" + key + \"' is not a string or function !\");\n }\n\n return null;\n }\n } else {\n return null;\n }\n } else {\n /* istanbul ignore else */\n if (isString(pathRet) || isFunction(pathRet)) {\n ret = pathRet;\n } else {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallback(locale, key)) {\n warn(\"Value of key '\" + key + \"' is not a string or function!\");\n }\n\n return null;\n }\n } // Check for the existence of links within the translated string\n\n\n if (isString(ret) && (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0)) {\n ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack);\n }\n\n return this._render(ret, interpolateMode, values, key);\n};\n\nVueI18n.prototype._link = function _link(locale, message, str, host, interpolateMode, values, visitedLinkStack) {\n var ret = str; // Match all the links within the local\n // We are going to replace each of\n // them with its translation\n\n var matches = ret.match(linkKeyMatcher);\n\n for (var idx in matches) {\n // ie compatible: filter custom array\n // prototype method\n if (!matches.hasOwnProperty(idx)) {\n continue;\n }\n\n var link = matches[idx];\n var linkKeyPrefixMatches = link.match(linkKeyPrefixMatcher);\n var linkPrefix = linkKeyPrefixMatches[0];\n var formatterName = linkKeyPrefixMatches[1]; // Remove the leading @:, @.case: and the brackets\n\n var linkPlaceholder = link.replace(linkPrefix, '').replace(bracketsMatcher, '');\n\n if (includes(visitedLinkStack, linkPlaceholder)) {\n if (process.env.NODE_ENV !== 'production') {\n warn(\"Circular reference found. \\\"\" + link + \"\\\" is already visited in the chain of \" + visitedLinkStack.reverse().join(' <- '));\n }\n\n return ret;\n }\n\n visitedLinkStack.push(linkPlaceholder); // Translate the link\n\n var translated = this._interpolate(locale, message, linkPlaceholder, host, interpolateMode === 'raw' ? 'string' : interpolateMode, interpolateMode === 'raw' ? undefined : values, visitedLinkStack);\n\n if (this._isFallbackRoot(translated)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(linkPlaceholder)) {\n warn(\"Fall back to translate the link placeholder '\" + linkPlaceholder + \"' with root locale.\");\n }\n /* istanbul ignore if */\n\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n var root = this._root.$i18n;\n translated = root._translate(root._getMessages(), root.locale, root.fallbackLocale, linkPlaceholder, host, interpolateMode, values);\n }\n\n translated = this._warnDefault(locale, linkPlaceholder, translated, host, isArray(values) ? values : [values], interpolateMode);\n\n if (this._modifiers.hasOwnProperty(formatterName)) {\n translated = this._modifiers[formatterName](translated);\n } else if (defaultModifiers.hasOwnProperty(formatterName)) {\n translated = defaultModifiers[formatterName](translated);\n }\n\n visitedLinkStack.pop(); // Replace the link with the translated\n\n ret = !translated ? ret : ret.replace(link, translated);\n }\n\n return ret;\n};\n\nVueI18n.prototype._createMessageContext = function _createMessageContext(values) {\n var _list = isArray(values) ? values : [];\n\n var _named = isObject(values) ? values : {};\n\n var list = function list(index) {\n return _list[index];\n };\n\n var named = function named(key) {\n return _named[key];\n };\n\n return {\n list: list,\n named: named\n };\n};\n\nVueI18n.prototype._render = function _render(message, interpolateMode, values, path) {\n if (isFunction(message)) {\n return message(this._createMessageContext(values));\n }\n\n var ret = this._formatter.interpolate(message, values, path); // If the custom formatter refuses to work - apply the default one\n\n\n if (!ret) {\n ret = defaultFormatter.interpolate(message, values, path);\n } // if interpolateMode is **not** 'string' ('row'),\n // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter\n\n\n return interpolateMode === 'string' && !isString(ret) ? ret.join('') : ret;\n};\n\nVueI18n.prototype._appendItemToChain = function _appendItemToChain(chain, item, blocks) {\n var follow = false;\n\n if (!includes(chain, item)) {\n follow = true;\n\n if (item) {\n follow = item[item.length - 1] !== '!';\n item = item.replace(/!/g, '');\n chain.push(item);\n\n if (blocks && blocks[item]) {\n follow = blocks[item];\n }\n }\n }\n\n return follow;\n};\n\nVueI18n.prototype._appendLocaleToChain = function _appendLocaleToChain(chain, locale, blocks) {\n var follow;\n var tokens = locale.split('-');\n\n do {\n var item = tokens.join('-');\n follow = this._appendItemToChain(chain, item, blocks);\n tokens.splice(-1, 1);\n } while (tokens.length && follow === true);\n\n return follow;\n};\n\nVueI18n.prototype._appendBlockToChain = function _appendBlockToChain(chain, block, blocks) {\n var follow = true;\n\n for (var i = 0; i < block.length && isBoolean(follow); i++) {\n var locale = block[i];\n\n if (isString(locale)) {\n follow = this._appendLocaleToChain(chain, locale, blocks);\n }\n }\n\n return follow;\n};\n\nVueI18n.prototype._getLocaleChain = function _getLocaleChain(start, fallbackLocale) {\n if (start === '') {\n return [];\n }\n\n if (!this._localeChainCache) {\n this._localeChainCache = {};\n }\n\n var chain = this._localeChainCache[start];\n\n if (!chain) {\n if (!fallbackLocale) {\n fallbackLocale = this.fallbackLocale;\n }\n\n chain = []; // first block defined by start\n\n var block = [start]; // while any intervening block found\n\n while (isArray(block)) {\n block = this._appendBlockToChain(chain, block, fallbackLocale);\n } // last block defined by default\n\n\n var defaults;\n\n if (isArray(fallbackLocale)) {\n defaults = fallbackLocale;\n } else if (isObject(fallbackLocale)) {\n /* $FlowFixMe */\n if (fallbackLocale['default']) {\n defaults = fallbackLocale['default'];\n } else {\n defaults = null;\n }\n } else {\n defaults = fallbackLocale;\n } // convert defaults to array\n\n\n if (isString(defaults)) {\n block = [defaults];\n } else {\n block = defaults;\n }\n\n if (block) {\n this._appendBlockToChain(chain, block, null);\n }\n\n this._localeChainCache[start] = chain;\n }\n\n return chain;\n};\n\nVueI18n.prototype._translate = function _translate(messages, locale, fallback, key, host, interpolateMode, args) {\n var chain = this._getLocaleChain(locale, fallback);\n\n var res;\n\n for (var i = 0; i < chain.length; i++) {\n var step = chain[i];\n res = this._interpolate(step, messages[step], key, host, interpolateMode, args, [key]);\n\n if (!isNull(res)) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to translate the keypath '\" + key + \"' with '\" + step + \"' locale.\");\n }\n\n return res;\n }\n }\n\n return null;\n};\n\nVueI18n.prototype._t = function _t(key, _locale, messages, host) {\n var ref;\n var values = [],\n len = arguments.length - 4;\n\n while (len-- > 0) {\n values[len] = arguments[len + 4];\n }\n\n if (!key) {\n return '';\n }\n\n var parsedArgs = parseArgs.apply(void 0, values);\n var locale = parsedArgs.locale || _locale;\n\n var ret = this._translate(messages, locale, this.fallbackLocale, key, host, 'string', parsedArgs.params);\n\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to translate the keypath '\" + key + \"' with root locale.\");\n }\n /* istanbul ignore if */\n\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n return (ref = this._root).$t.apply(ref, [key].concat(values));\n } else {\n ret = this._warnDefault(locale, key, ret, host, values, 'string');\n\n if (this._postTranslation && ret !== null && ret !== undefined) {\n ret = this._postTranslation(ret, key);\n }\n\n return ret;\n }\n};\n\nVueI18n.prototype.t = function t(key) {\n var ref;\n var values = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n values[len] = arguments[len + 1];\n }\n\n return (ref = this)._t.apply(ref, [key, this.locale, this._getMessages(), null].concat(values));\n};\n\nVueI18n.prototype._i = function _i(key, locale, messages, host, values) {\n var ret = this._translate(messages, locale, this.fallbackLocale, key, host, 'raw', values);\n\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn(\"Fall back to interpolate the keypath '\" + key + \"' with root locale.\");\n }\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n return this._root.$i18n.i(key, locale, values);\n } else {\n return this._warnDefault(locale, key, ret, host, [values], 'raw');\n }\n};\n\nVueI18n.prototype.i = function i(key, locale, values) {\n /* istanbul ignore if */\n if (!key) {\n return '';\n }\n\n if (!isString(locale)) {\n locale = this.locale;\n }\n\n return this._i(key, locale, this._getMessages(), null, values);\n};\n\nVueI18n.prototype._tc = function _tc(key, _locale, messages, host, choice) {\n var ref;\n var values = [],\n len = arguments.length - 5;\n\n while (len-- > 0) {\n values[len] = arguments[len + 5];\n }\n\n if (!key) {\n return '';\n }\n\n if (choice === undefined) {\n choice = 1;\n }\n\n var predefined = {\n 'count': choice,\n 'n': choice\n };\n var parsedArgs = parseArgs.apply(void 0, values);\n parsedArgs.params = Object.assign(predefined, parsedArgs.params);\n values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params];\n return this.fetchChoice((ref = this)._t.apply(ref, [key, _locale, messages, host].concat(values)), choice);\n};\n\nVueI18n.prototype.fetchChoice = function fetchChoice(message, choice) {\n /* istanbul ignore if */\n if (!message && !isString(message)) {\n return null;\n }\n\n var choices = message.split('|');\n choice = this.getChoiceIndex(choice, choices.length);\n\n if (!choices[choice]) {\n return message;\n }\n\n return choices[choice].trim();\n};\n\nVueI18n.prototype.tc = function tc(key, choice) {\n var ref;\n var values = [],\n len = arguments.length - 2;\n\n while (len-- > 0) {\n values[len] = arguments[len + 2];\n }\n\n return (ref = this)._tc.apply(ref, [key, this.locale, this._getMessages(), null, choice].concat(values));\n};\n\nVueI18n.prototype._te = function _te(key, locale, messages) {\n var args = [],\n len = arguments.length - 3;\n\n while (len-- > 0) {\n args[len] = arguments[len + 3];\n }\n\n var _locale = parseArgs.apply(void 0, args).locale || locale;\n\n return this._exist(messages[_locale], key);\n};\n\nVueI18n.prototype.te = function te(key, locale) {\n return this._te(key, this.locale, this._getMessages(), locale);\n};\n\nVueI18n.prototype.getLocaleMessage = function getLocaleMessage(locale) {\n return looseClone(this._vm.messages[locale] || {});\n};\n\nVueI18n.prototype.setLocaleMessage = function setLocaleMessage(locale, message) {\n if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {\n this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);\n }\n\n this._vm.$set(this._vm.messages, locale, message);\n};\n\nVueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage(locale, message) {\n if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {\n this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);\n }\n\n this._vm.$set(this._vm.messages, locale, merge({}, this._vm.messages[locale] || {}, message));\n};\n\nVueI18n.prototype.getDateTimeFormat = function getDateTimeFormat(locale) {\n return looseClone(this._vm.dateTimeFormats[locale] || {});\n};\n\nVueI18n.prototype.setDateTimeFormat = function setDateTimeFormat(locale, format) {\n this._vm.$set(this._vm.dateTimeFormats, locale, format);\n\n this._clearDateTimeFormat(locale, format);\n};\n\nVueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat(locale, format) {\n this._vm.$set(this._vm.dateTimeFormats, locale, merge(this._vm.dateTimeFormats[locale] || {}, format));\n\n this._clearDateTimeFormat(locale, format);\n};\n\nVueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat(locale, format) {\n for (var key in format) {\n var id = locale + \"__\" + key;\n\n if (!this._dateTimeFormatters.hasOwnProperty(id)) {\n continue;\n }\n\n delete this._dateTimeFormatters[id];\n }\n};\n\nVueI18n.prototype._localizeDateTime = function _localizeDateTime(value, locale, fallback, dateTimeFormats, key) {\n var _locale = locale;\n var formats = dateTimeFormats[_locale];\n\n var chain = this._getLocaleChain(locale, fallback);\n\n for (var i = 0; i < chain.length; i++) {\n var current = _locale;\n var step = chain[i];\n formats = dateTimeFormats[step];\n _locale = step; // fallback locale\n\n if (isNull(formats) || isNull(formats[key])) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to '\" + step + \"' datetime formats from '\" + current + \"' datetime formats.\");\n }\n } else {\n break;\n }\n }\n\n if (isNull(formats) || isNull(formats[key])) {\n return null;\n } else {\n var format = formats[key];\n var id = _locale + \"__\" + key;\n var formatter = this._dateTimeFormatters[id];\n\n if (!formatter) {\n formatter = this._dateTimeFormatters[id] = new Intl.DateTimeFormat(_locale, format);\n }\n\n return formatter.format(value);\n }\n};\n\nVueI18n.prototype._d = function _d(value, locale, key) {\n /* istanbul ignore if */\n if (process.env.NODE_ENV !== 'production' && !VueI18n.availabilities.dateTimeFormat) {\n warn('Cannot format a Date value due to not supported Intl.DateTimeFormat.');\n return '';\n }\n\n if (!key) {\n return new Intl.DateTimeFormat(locale).format(value);\n }\n\n var ret = this._localizeDateTime(value, locale, this.fallbackLocale, this._getDateTimeFormats(), key);\n\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to datetime localization of root: key '\" + key + \"'.\");\n }\n /* istanbul ignore if */\n\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n return this._root.$i18n.d(value, key, locale);\n } else {\n return ret || '';\n }\n};\n\nVueI18n.prototype.d = function d(value) {\n var args = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n args[len] = arguments[len + 1];\n }\n\n var locale = this.locale;\n var key = null;\n\n if (args.length === 1) {\n if (isString(args[0])) {\n key = args[0];\n } else if (isObject(args[0])) {\n if (args[0].locale) {\n locale = args[0].locale;\n }\n\n if (args[0].key) {\n key = args[0].key;\n }\n }\n } else if (args.length === 2) {\n if (isString(args[0])) {\n key = args[0];\n }\n\n if (isString(args[1])) {\n locale = args[1];\n }\n }\n\n return this._d(value, locale, key);\n};\n\nVueI18n.prototype.getNumberFormat = function getNumberFormat(locale) {\n return looseClone(this._vm.numberFormats[locale] || {});\n};\n\nVueI18n.prototype.setNumberFormat = function setNumberFormat(locale, format) {\n this._vm.$set(this._vm.numberFormats, locale, format);\n\n this._clearNumberFormat(locale, format);\n};\n\nVueI18n.prototype.mergeNumberFormat = function mergeNumberFormat(locale, format) {\n this._vm.$set(this._vm.numberFormats, locale, merge(this._vm.numberFormats[locale] || {}, format));\n\n this._clearNumberFormat(locale, format);\n};\n\nVueI18n.prototype._clearNumberFormat = function _clearNumberFormat(locale, format) {\n for (var key in format) {\n var id = locale + \"__\" + key;\n\n if (!this._numberFormatters.hasOwnProperty(id)) {\n continue;\n }\n\n delete this._numberFormatters[id];\n }\n};\n\nVueI18n.prototype._getNumberFormatter = function _getNumberFormatter(value, locale, fallback, numberFormats, key, options) {\n var _locale = locale;\n var formats = numberFormats[_locale];\n\n var chain = this._getLocaleChain(locale, fallback);\n\n for (var i = 0; i < chain.length; i++) {\n var current = _locale;\n var step = chain[i];\n formats = numberFormats[step];\n _locale = step; // fallback locale\n\n if (isNull(formats) || isNull(formats[key])) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to '\" + step + \"' number formats from '\" + current + \"' number formats.\");\n }\n } else {\n break;\n }\n }\n\n if (isNull(formats) || isNull(formats[key])) {\n return null;\n } else {\n var format = formats[key];\n var formatter;\n\n if (options) {\n // If options specified - create one time number formatter\n formatter = new Intl.NumberFormat(_locale, Object.assign({}, format, options));\n } else {\n var id = _locale + \"__\" + key;\n formatter = this._numberFormatters[id];\n\n if (!formatter) {\n formatter = this._numberFormatters[id] = new Intl.NumberFormat(_locale, format);\n }\n }\n\n return formatter;\n }\n};\n\nVueI18n.prototype._n = function _n(value, locale, key, options) {\n /* istanbul ignore if */\n if (!VueI18n.availabilities.numberFormat) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot format a Number value due to not supported Intl.NumberFormat.');\n }\n\n return '';\n }\n\n if (!key) {\n var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);\n return nf.format(value);\n }\n\n var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);\n\n var ret = formatter && formatter.format(value);\n\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn(\"Fall back to number localization of root: key '\" + key + \"'.\");\n }\n /* istanbul ignore if */\n\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n return this._root.$i18n.n(value, Object.assign({}, {\n key: key,\n locale: locale\n }, options));\n } else {\n return ret || '';\n }\n};\n\nVueI18n.prototype.n = function n(value) {\n var args = [],\n len = arguments.length - 1;\n\n while (len-- > 0) {\n args[len] = arguments[len + 1];\n }\n\n var locale = this.locale;\n var key = null;\n var options = null;\n\n if (args.length === 1) {\n if (isString(args[0])) {\n key = args[0];\n } else if (isObject(args[0])) {\n if (args[0].locale) {\n locale = args[0].locale;\n }\n\n if (args[0].key) {\n key = args[0].key;\n } // Filter out number format options only\n\n\n options = Object.keys(args[0]).reduce(function (acc, key) {\n var obj;\n\n if (includes(numberFormatKeys, key)) {\n return Object.assign({}, acc, (obj = {}, obj[key] = args[0][key], obj));\n }\n\n return acc;\n }, null);\n }\n } else if (args.length === 2) {\n if (isString(args[0])) {\n key = args[0];\n }\n\n if (isString(args[1])) {\n locale = args[1];\n }\n }\n\n return this._n(value, locale, key, options);\n};\n\nVueI18n.prototype._ntp = function _ntp(value, locale, key, options) {\n /* istanbul ignore if */\n if (!VueI18n.availabilities.numberFormat) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot format to parts a Number value due to not supported Intl.NumberFormat.');\n }\n\n return [];\n }\n\n if (!key) {\n var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);\n return nf.formatToParts(value);\n }\n\n var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);\n\n var ret = formatter && formatter.formatToParts(value);\n\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn(\"Fall back to format number to parts of root: key '\" + key + \"' .\");\n }\n /* istanbul ignore if */\n\n\n if (!this._root) {\n throw Error('unexpected error');\n }\n\n return this._root.$i18n._ntp(value, locale, key, options);\n } else {\n return ret || [];\n }\n};\n\nObject.defineProperties(VueI18n.prototype, prototypeAccessors);\nvar availabilities; // $FlowFixMe\n\nObject.defineProperty(VueI18n, 'availabilities', {\n get: function get() {\n if (!availabilities) {\n var intlDefined = typeof Intl !== 'undefined';\n availabilities = {\n dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',\n numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'\n };\n }\n\n return availabilities;\n }\n});\nVueI18n.install = install;\nVueI18n.version = '8.21.1';\nexport default VueI18n;","import Vue from 'vue/dist/vue.esm'\nimport VueI18n from 'vue-i18n'\n\nVue.use(VueI18n)\n\nimport en from './locales/en.json'\n\nconst messages = {\n en: en\n}\n\nconst i18n = new VueI18n({\n locale: 'en',\n fallbackLocale: 'en',\n messages\n})\n\nexport default i18n","import Vue from 'vue/dist/vue.esm'\nexport const eventBus = new Vue()","import {Model} from '@vuex-orm/core'\nimport axios from 'axios'\nclass Image extends Model {\n static entity = 'images'\n\n static fields() {\n return {\n // api partial\n id: this.uid(),\n is_temp: this.attr(false),\n owner_id: this.attr(null),\n is_vendor_avatar: this.attr(null),\n file_size: this.attr(0),\n crop_x: this.attr(0),\n crop_y: this.attr(0),\n crop_w: this.attr(0),\n crop_h: this.attr(0),\n width: this.attr(0),\n height: this.attr(0),\n class_name: this.attr('Image'),\n thumb_avatar: this.attr(null),\n preview_image: this.attr(null),\n main_image: this.attr(null),\n avatar: this.attr(null),\n upload_links: this.attr({}),\n\n // only ui\n processing_stage: this.attr(''), // 'RESERVED', 'UPLOADING', 'UPLOADED', 'COMPLETED'\n image_tmp_url: this.attr(''),\n upload_percentage: this.attr(null),\n cancelTokenSource: this.attr(null),\n // relations\n }\n }\n\n static apiConfig = {\n actions: {\n // async fetch(params = {}) {\n // return await this.get(\"/images\", {\n // params: params,\n // dataKey: 'response'\n // })\n // },\n\n // async destroy(id) {\n // return await this.delete(`/images/${id}`, { delete: id })\n // },\n\n // Send information about the file to make sure file is valid and getting upload links\n async createAndUpload(file, processingParams={}){\n const {onCreate, onUploaded} = processingParams\n let data = {\n file_name: file.name,\n file_type: file.type,\n file_size: file.size\n }\n\n let create_response;\n try {\n create_response = (await this.post('/images', {image: data}, {\n dataKey: 'response'\n })).response.data.response\n }catch(response){\n console.error(response)\n let message = `${file.name} - ${Object.values(response.data.message)[0]}`\n iziToast.error({ message: message, maxWidth: '700px' })\n return;\n }\n\n if (onCreate) { onCreate(create_response) }\n\n // uploading\n let image = Image.find(create_response.id),\n signedUrl = image.upload_links.put_url,\n publicUrl = image.upload_links.public_url\n Image.update({id: image.id, processing_stage: 'UPLOADING', image_tmp_url: URL.createObjectURL(file)})\n\n\n let upload_result;\n try {\n const cancelTokenSource = axios.CancelToken.source();\n Image.update({id: image.id, cancelTokenSource})\n upload_result = await this.put(signedUrl, file, {\n timeout: 60 * 60 * 1000,\n headers: {'Content-Type': file.type},\n cancelToken: cancelTokenSource.token,\n onUploadProgress: function (progressEvent) {\n let percent = parseInt(Math.round((progressEvent.loaded / progressEvent.total) * 100))\n Image.update({id: image.id, upload_percentage: percent})\n }\n })\n }catch(response){ //by cancelToken ('cancel img upload by user') or by something went wrong '\n console.error(response)\n let message = `${file.name} - Uploading failed`\n iziToast.error({ message: message, maxWidth: '700px' })\n Image.delete(image.id)\n return;\n }\n\n if (onUploaded) { onUploaded() }\n\n Image.update({id: image.id, processing_stage: 'UPLOADED', avatar: publicUrl, cancelTokenSource: null})\n\n let data2 = {\n remote_avatar_url: publicUrl\n }\n try {\n const update_result = await this.put(`/images/${image.id}`, {image: data2}, {\n dataKey: 'response'\n })\n } catch(response) {\n console.error(response)\n let message = `${file.name} - ${Object.values(response.data.message)[0]}`\n iziToast.error({ message: message, maxWidth: '700px' })\n Image.delete(image.id)\n return;\n }\n Image.update({id: image.id, processing_stage: 'COMPLETED'})\n }\n }\n }\n}\n\nexport default Image","let awsConfigs = {\n CognitoIdentityPoolId: process.env.AWS_COGNITO_IDENTITY_POOL_ID,\n S3VideoRegion: process.env.AWS_REGION,\n S3VideoBucket: process.env.AWS_BUCKET,\n}\n\nmodule.exports = {\n awsConfigs\n}","'use strict';\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar has = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\nvar hexTable = function () {\n var array = [];\n\n for (var i = 0; i < 256; ++i) {\n array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());\n }\n\n return array;\n}();\n\nvar compactQueue = function compactQueue(queue) {\n while (queue.length > 1) {\n var item = queue.pop();\n var obj = item.obj[item.prop];\n\n if (isArray(obj)) {\n var compacted = [];\n\n for (var j = 0; j < obj.length; ++j) {\n if (typeof obj[j] !== 'undefined') {\n compacted.push(obj[j]);\n }\n }\n\n item.obj[item.prop] = compacted;\n }\n }\n};\n\nvar arrayToObject = function arrayToObject(source, options) {\n var obj = options && options.plainObjects ? Object.create(null) : {};\n\n for (var i = 0; i < source.length; ++i) {\n if (typeof source[i] !== 'undefined') {\n obj[i] = source[i];\n }\n }\n\n return obj;\n};\n\nvar merge = function merge(target, source, options) {\n /* eslint no-param-reassign: 0 */\n if (!source) {\n return target;\n }\n\n if (_typeof(source) !== 'object') {\n if (isArray(target)) {\n target.push(source);\n } else if (target && _typeof(target) === 'object') {\n if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {\n target[source] = true;\n }\n } else {\n return [target, source];\n }\n\n return target;\n }\n\n if (!target || _typeof(target) !== 'object') {\n return [target].concat(source);\n }\n\n var mergeTarget = target;\n\n if (isArray(target) && !isArray(source)) {\n mergeTarget = arrayToObject(target, options);\n }\n\n if (isArray(target) && isArray(source)) {\n source.forEach(function (item, i) {\n if (has.call(target, i)) {\n var targetItem = target[i];\n\n if (targetItem && _typeof(targetItem) === 'object' && item && _typeof(item) === 'object') {\n target[i] = merge(targetItem, item, options);\n } else {\n target.push(item);\n }\n } else {\n target[i] = item;\n }\n });\n return target;\n }\n\n return Object.keys(source).reduce(function (acc, key) {\n var value = source[key];\n\n if (has.call(acc, key)) {\n acc[key] = merge(acc[key], value, options);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, mergeTarget);\n};\n\nvar assign = function assignSingleSource(target, source) {\n return Object.keys(source).reduce(function (acc, key) {\n acc[key] = source[key];\n return acc;\n }, target);\n};\n\nvar decode = function decode(str, decoder, charset) {\n var strWithoutPlus = str.replace(/\\+/g, ' ');\n\n if (charset === 'iso-8859-1') {\n // unescape never throws, no try...catch needed:\n return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);\n } // utf-8\n\n\n try {\n return decodeURIComponent(strWithoutPlus);\n } catch (e) {\n return strWithoutPlus;\n }\n};\n\nvar encode = function encode(str, defaultEncoder, charset) {\n // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n // It has been adapted here for stricter adherence to RFC 3986\n if (str.length === 0) {\n return str;\n }\n\n var string = str;\n\n if (_typeof(str) === 'symbol') {\n string = Symbol.prototype.toString.call(str);\n } else if (typeof str !== 'string') {\n string = String(str);\n }\n\n if (charset === 'iso-8859-1') {\n return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {\n return '%26%23' + parseInt($0.slice(2), 16) + '%3B';\n });\n }\n\n var out = '';\n\n for (var i = 0; i < string.length; ++i) {\n var c = string.charCodeAt(i);\n\n if (c === 0x2D // -\n || c === 0x2E // .\n || c === 0x5F // _\n || c === 0x7E // ~\n || c >= 0x30 && c <= 0x39 // 0-9\n || c >= 0x41 && c <= 0x5A // a-z\n || c >= 0x61 && c <= 0x7A // A-Z\n ) {\n out += string.charAt(i);\n continue;\n }\n\n if (c < 0x80) {\n out = out + hexTable[c];\n continue;\n }\n\n if (c < 0x800) {\n out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);\n continue;\n }\n\n if (c < 0xD800 || c >= 0xE000) {\n out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);\n continue;\n }\n\n i += 1;\n c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);\n out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];\n }\n\n return out;\n};\n\nvar compact = function compact(value) {\n var queue = [{\n obj: {\n o: value\n },\n prop: 'o'\n }];\n var refs = [];\n\n for (var i = 0; i < queue.length; ++i) {\n var item = queue[i];\n var obj = item.obj[item.prop];\n var keys = Object.keys(obj);\n\n for (var j = 0; j < keys.length; ++j) {\n var key = keys[j];\n var val = obj[key];\n\n if (_typeof(val) === 'object' && val !== null && refs.indexOf(val) === -1) {\n queue.push({\n obj: obj,\n prop: key\n });\n refs.push(val);\n }\n }\n }\n\n compactQueue(queue);\n return value;\n};\n\nvar isRegExp = function isRegExp(obj) {\n return Object.prototype.toString.call(obj) === '[object RegExp]';\n};\n\nvar isBuffer = function isBuffer(obj) {\n if (!obj || _typeof(obj) !== 'object') {\n return false;\n }\n\n return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));\n};\n\nvar combine = function combine(a, b) {\n return [].concat(a, b);\n};\n\nvar maybeMap = function maybeMap(val, fn) {\n if (isArray(val)) {\n var mapped = [];\n\n for (var i = 0; i < val.length; i += 1) {\n mapped.push(fn(val[i]));\n }\n\n return mapped;\n }\n\n return fn(val);\n};\n\nmodule.exports = {\n arrayToObject: arrayToObject,\n assign: assign,\n combine: combine,\n compact: compact,\n decode: decode,\n encode: encode,\n isBuffer: isBuffer,\n isRegExp: isRegExp,\n maybeMap: maybeMap,\n merge: merge\n};","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/*!\n * vuex v3.5.1\n * (c) 2020 Evan You\n * @license MIT\n */\n(function (global, factory) {\n (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.Vuex = factory());\n})(this, function () {\n 'use strict';\n /**\n * Get the first item that pass the test\n * by second argument function\n *\n * @param {Array} list\n * @param {Function} f\n * @return {*}\n */\n\n function find(list, f) {\n return list.filter(f)[0];\n }\n /**\n * Deep copy the given object considering circular structure.\n * This function caches all nested objects and its copies.\n * If it detects circular structure, use cached copy to avoid infinite loop.\n *\n * @param {*} obj\n * @param {Array