diff --git a/dist/actions/destroy.d.ts b/dist/actions/destroy.d.ts index 6635a048..60cd7ab1 100644 --- a/dist/actions/destroy.d.ts +++ b/dist/actions/destroy.d.ts @@ -7,7 +7,7 @@ export default class Destroy extends Action { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ static call({ state, dispatch }: ActionParams, { id, args }: ActionParams): Promise; diff --git a/dist/actions/persist.d.ts b/dist/actions/persist.d.ts index 51210027..2885f6c7 100644 --- a/dist/actions/persist.d.ts +++ b/dist/actions/persist.d.ts @@ -7,7 +7,7 @@ export default class Persist extends Action { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ static call({ state, dispatch }: ActionParams, { id, args }: ActionParams): Promise; diff --git a/dist/orm/model.d.ts b/dist/orm/model.d.ts index 5732b081..1b7a9fa1 100644 --- a/dist/orm/model.d.ts +++ b/dist/orm/model.d.ts @@ -94,10 +94,10 @@ export default class Model { isTypeFieldOfPolymorphicRelation(name: string): boolean; /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ - getRecordWithId(id: string): import("@vuex-orm/core").Item; + getRecordWithId(id: number | string): import("@vuex-orm/core").Item; /** * Determines if we should eager load (means: add as a field in the graphql query) a related entity. belongsTo, * hasOne and morphOne related entities are always eager loaded. Others can be added to the `eagerLoad` array diff --git a/dist/support/utils.d.ts b/dist/support/utils.d.ts index 65d50341..cb1f51ac 100644 --- a/dist/support/utils.d.ts +++ b/dist/support/utils.d.ts @@ -52,3 +52,7 @@ export declare function clone(input: any): any; export declare function takeWhile(array: Array, predicate: (x: any, idx: number, array: Array) => any): any[]; export declare function matches(source: any): (object: any) => boolean; export declare function removeSymbols(input: any): any; +/** + * Converts the argument into a number. + */ +export declare function toNumber(input: string | number | null): number | string; diff --git a/dist/vuex-orm-graphql.cjs.js b/dist/vuex-orm-graphql.cjs.js index d32a58d8..576ce7f7 100644 --- a/dist/vuex-orm-graphql.cjs.js +++ b/dist/vuex-orm-graphql.cjs.js @@ -7746,6 +7746,17 @@ function takeWhile(array, predicate) { } function removeSymbols(input) { return JSON.parse(JSON.stringify(input)); +} +/** + * Converts the argument into a number. + */ +function toNumber(input) { + if (input === null) + return 0; + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + return parseInt(input.toString(), 10); } /** @@ -7901,8 +7912,8 @@ var Model = /** @class */ (function () { if (!field) return false; var context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + return field instanceof context.components.Number || + field instanceof context.components.Uid; }; /** * Tells if a field is a attribute (and thus not a relation) @@ -8058,14 +8069,14 @@ var Model = /** @class */ (function () { }; /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ Model.prototype.getRecordWithId = function (id) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); }; /** @@ -15338,7 +15349,7 @@ var Action = /** @class */ (function () { if (!(name !== context.adapter.getNameForDestroy(model))) return [3 /*break*/, 4]; newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); return [4 /*yield*/, Store.insertData((_a = {}, _a[model.pluralName] = newData, _a), dispatch)]; case 3: insertedData = _b.sent(); @@ -15423,7 +15434,7 @@ var Destroy = /** @class */ (function (_super) { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ Destroy.call = function (_a, _b) { @@ -15575,7 +15586,7 @@ var Persist = /** @class */ (function (_super) { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ Persist.call = function (_a, _b) { @@ -15591,7 +15602,7 @@ var Persist = /** @class */ (function (_super) { mutationName = Context.getInstance().adapter.getNameForPersist(model); oldRecord = model.getRecordWithId(id); mockReturnValue = model.$mockHook("persist", { - id: id, + id: toNumber(id), args: args || {} }); if (!mockReturnValue) return [3 /*break*/, 3]; @@ -15922,7 +15933,7 @@ var VuexORMGraphQL = /** @class */ (function () { return __generator(this, function (_b) { args = args || {}; if (!args["id"]) - args["id"] = this.$id; + args["id"] = toNumber(this.$id); return [2 /*return*/, this.$dispatch("mutate", { name: name, args: args, multiple: multiple })]; }); }); @@ -15933,7 +15944,7 @@ var VuexORMGraphQL = /** @class */ (function () { return __generator(this, function (_b) { filter = filter || {}; if (!filter["id"]) - filter["id"] = this.$id; + filter["id"] = toNumber(this.$id); return [2 /*return*/, this.$dispatch("query", { name: name, filter: filter, multiple: multiple, bypassCache: bypassCache })]; }); }); @@ -15955,7 +15966,7 @@ var VuexORMGraphQL = /** @class */ (function () { model.$destroy = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/, this.$dispatch("destroy", { id: this.$id })]; + return [2 /*return*/, this.$dispatch("destroy", { id: toNumber(this.$id) })]; }); }); }; diff --git a/dist/vuex-orm-graphql.esm-bundler.js b/dist/vuex-orm-graphql.esm-bundler.js index a1ebb812..ecbae0cc 100644 --- a/dist/vuex-orm-graphql.esm-bundler.js +++ b/dist/vuex-orm-graphql.esm-bundler.js @@ -7644,6 +7644,17 @@ function takeWhile(array, predicate) { } function removeSymbols(input) { return JSON.parse(JSON.stringify(input)); +} +/** + * Converts the argument into a number. + */ +function toNumber(input) { + if (input === null) + return 0; + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + return parseInt(input.toString(), 10); } /** @@ -7785,8 +7796,8 @@ class Model { if (!field) return false; const context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + return field instanceof context.components.Number || + field instanceof context.components.Uid; } /** * Tells if a field is a attribute (and thus not a relation) @@ -7940,14 +7951,14 @@ class Model { } /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ getRecordWithId(id) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); } /** @@ -15315,7 +15326,7 @@ class Action { if (name !== context.adapter.getNameForDestroy(model)) { newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); const insertedData = await Store.insertData({ [model.pluralName]: newData }, dispatch); // Try to find the record to return const records = insertedData[model.pluralName]; @@ -15392,7 +15403,7 @@ class Destroy extends Action { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ static async call({ state, dispatch }, { id, args }) { @@ -15497,7 +15508,7 @@ class Persist extends Action { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ static async call({ state, dispatch }, { id, args }) { @@ -15506,7 +15517,7 @@ class Persist extends Action { const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); const mockReturnValue = model.$mockHook("persist", { - id, + id: toNumber(id), args: args || {} }); if (mockReturnValue) { @@ -15749,13 +15760,13 @@ class VuexORMGraphQL { model.$mutate = async function ({ name, args, multiple }) { args = args || {}; if (!args["id"]) - args["id"] = this.$id; + args["id"] = toNumber(this.$id); return this.$dispatch("mutate", { name, args, multiple }); }; model.$customQuery = async function ({ name, filter, multiple, bypassCache }) { filter = filter || {}; if (!filter["id"]) - filter["id"] = this.$id; + filter["id"] = toNumber(this.$id); return this.$dispatch("query", { name, filter, multiple, bypassCache }); }; model.$persist = async function (args) { @@ -15765,7 +15776,7 @@ class VuexORMGraphQL { return this.$dispatch("push", { data: this, args }); }; model.$destroy = async function () { - return this.$dispatch("destroy", { id: this.$id }); + return this.$dispatch("destroy", { id: toNumber(this.$id) }); }; model.$deleteAndDestroy = async function () { await this.$delete(); diff --git a/dist/vuex-orm-graphql.esm.js b/dist/vuex-orm-graphql.esm.js index a1ebb812..ecbae0cc 100644 --- a/dist/vuex-orm-graphql.esm.js +++ b/dist/vuex-orm-graphql.esm.js @@ -7644,6 +7644,17 @@ function takeWhile(array, predicate) { } function removeSymbols(input) { return JSON.parse(JSON.stringify(input)); +} +/** + * Converts the argument into a number. + */ +function toNumber(input) { + if (input === null) + return 0; + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + return parseInt(input.toString(), 10); } /** @@ -7785,8 +7796,8 @@ class Model { if (!field) return false; const context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + return field instanceof context.components.Number || + field instanceof context.components.Uid; } /** * Tells if a field is a attribute (and thus not a relation) @@ -7940,14 +7951,14 @@ class Model { } /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ getRecordWithId(id) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); } /** @@ -15315,7 +15326,7 @@ class Action { if (name !== context.adapter.getNameForDestroy(model)) { newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); const insertedData = await Store.insertData({ [model.pluralName]: newData }, dispatch); // Try to find the record to return const records = insertedData[model.pluralName]; @@ -15392,7 +15403,7 @@ class Destroy extends Action { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ static async call({ state, dispatch }, { id, args }) { @@ -15497,7 +15508,7 @@ class Persist extends Action { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ static async call({ state, dispatch }, { id, args }) { @@ -15506,7 +15517,7 @@ class Persist extends Action { const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); const mockReturnValue = model.$mockHook("persist", { - id, + id: toNumber(id), args: args || {} }); if (mockReturnValue) { @@ -15749,13 +15760,13 @@ class VuexORMGraphQL { model.$mutate = async function ({ name, args, multiple }) { args = args || {}; if (!args["id"]) - args["id"] = this.$id; + args["id"] = toNumber(this.$id); return this.$dispatch("mutate", { name, args, multiple }); }; model.$customQuery = async function ({ name, filter, multiple, bypassCache }) { filter = filter || {}; if (!filter["id"]) - filter["id"] = this.$id; + filter["id"] = toNumber(this.$id); return this.$dispatch("query", { name, filter, multiple, bypassCache }); }; model.$persist = async function (args) { @@ -15765,7 +15776,7 @@ class VuexORMGraphQL { return this.$dispatch("push", { data: this, args }); }; model.$destroy = async function () { - return this.$dispatch("destroy", { id: this.$id }); + return this.$dispatch("destroy", { id: toNumber(this.$id) }); }; model.$deleteAndDestroy = async function () { await this.$delete(); diff --git a/dist/vuex-orm-graphql.esm.prod.js b/dist/vuex-orm-graphql.esm.prod.js index a1ebb812..ecbae0cc 100644 --- a/dist/vuex-orm-graphql.esm.prod.js +++ b/dist/vuex-orm-graphql.esm.prod.js @@ -7644,6 +7644,17 @@ function takeWhile(array, predicate) { } function removeSymbols(input) { return JSON.parse(JSON.stringify(input)); +} +/** + * Converts the argument into a number. + */ +function toNumber(input) { + if (input === null) + return 0; + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + return parseInt(input.toString(), 10); } /** @@ -7785,8 +7796,8 @@ class Model { if (!field) return false; const context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + return field instanceof context.components.Number || + field instanceof context.components.Uid; } /** * Tells if a field is a attribute (and thus not a relation) @@ -7940,14 +7951,14 @@ class Model { } /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ getRecordWithId(id) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); } /** @@ -15315,7 +15326,7 @@ class Action { if (name !== context.adapter.getNameForDestroy(model)) { newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); const insertedData = await Store.insertData({ [model.pluralName]: newData }, dispatch); // Try to find the record to return const records = insertedData[model.pluralName]; @@ -15392,7 +15403,7 @@ class Destroy extends Action { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ static async call({ state, dispatch }, { id, args }) { @@ -15497,7 +15508,7 @@ class Persist extends Action { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ static async call({ state, dispatch }, { id, args }) { @@ -15506,7 +15517,7 @@ class Persist extends Action { const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); const mockReturnValue = model.$mockHook("persist", { - id, + id: toNumber(id), args: args || {} }); if (mockReturnValue) { @@ -15749,13 +15760,13 @@ class VuexORMGraphQL { model.$mutate = async function ({ name, args, multiple }) { args = args || {}; if (!args["id"]) - args["id"] = this.$id; + args["id"] = toNumber(this.$id); return this.$dispatch("mutate", { name, args, multiple }); }; model.$customQuery = async function ({ name, filter, multiple, bypassCache }) { filter = filter || {}; if (!filter["id"]) - filter["id"] = this.$id; + filter["id"] = toNumber(this.$id); return this.$dispatch("query", { name, filter, multiple, bypassCache }); }; model.$persist = async function (args) { @@ -15765,7 +15776,7 @@ class VuexORMGraphQL { return this.$dispatch("push", { data: this, args }); }; model.$destroy = async function () { - return this.$dispatch("destroy", { id: this.$id }); + return this.$dispatch("destroy", { id: toNumber(this.$id) }); }; model.$deleteAndDestroy = async function () { await this.$delete(); diff --git a/dist/vuex-orm-graphql.global.js b/dist/vuex-orm-graphql.global.js index c0c7477e..861dc5a7 100644 --- a/dist/vuex-orm-graphql.global.js +++ b/dist/vuex-orm-graphql.global.js @@ -7745,6 +7745,17 @@ var VuexORMGraphQLPlugin = (function (exports) { } function removeSymbols(input) { return JSON.parse(JSON.stringify(input)); + } + /** + * Converts the argument into a number. + */ + function toNumber(input) { + if (input === null) + return 0; + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + return parseInt(input.toString(), 10); } /** @@ -7900,8 +7911,8 @@ var VuexORMGraphQLPlugin = (function (exports) { if (!field) return false; var context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + return field instanceof context.components.Number || + field instanceof context.components.Uid; }; /** * Tells if a field is a attribute (and thus not a relation) @@ -8057,14 +8068,14 @@ var VuexORMGraphQLPlugin = (function (exports) { }; /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ Model.prototype.getRecordWithId = function (id) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); }; /** @@ -15337,7 +15348,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (!(name !== context.adapter.getNameForDestroy(model))) return [3 /*break*/, 4]; newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); return [4 /*yield*/, Store.insertData((_a = {}, _a[model.pluralName] = newData, _a), dispatch)]; case 3: insertedData = _b.sent(); @@ -15422,7 +15433,7 @@ var VuexORMGraphQLPlugin = (function (exports) { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ Destroy.call = function (_a, _b) { @@ -15574,7 +15585,7 @@ var VuexORMGraphQLPlugin = (function (exports) { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ Persist.call = function (_a, _b) { @@ -15590,7 +15601,7 @@ var VuexORMGraphQLPlugin = (function (exports) { mutationName = Context.getInstance().adapter.getNameForPersist(model); oldRecord = model.getRecordWithId(id); mockReturnValue = model.$mockHook("persist", { - id: id, + id: toNumber(id), args: args || {} }); if (!mockReturnValue) return [3 /*break*/, 3]; @@ -15921,7 +15932,7 @@ var VuexORMGraphQLPlugin = (function (exports) { return __generator(this, function (_b) { args = args || {}; if (!args["id"]) - args["id"] = this.$id; + args["id"] = toNumber(this.$id); return [2 /*return*/, this.$dispatch("mutate", { name: name, args: args, multiple: multiple })]; }); }); @@ -15932,7 +15943,7 @@ var VuexORMGraphQLPlugin = (function (exports) { return __generator(this, function (_b) { filter = filter || {}; if (!filter["id"]) - filter["id"] = this.$id; + filter["id"] = toNumber(this.$id); return [2 /*return*/, this.$dispatch("query", { name: name, filter: filter, multiple: multiple, bypassCache: bypassCache })]; }); }); @@ -15954,7 +15965,7 @@ var VuexORMGraphQLPlugin = (function (exports) { model.$destroy = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/, this.$dispatch("destroy", { id: this.$id })]; + return [2 /*return*/, this.$dispatch("destroy", { id: toNumber(this.$id) })]; }); }); }; diff --git a/dist/vuex-orm-graphql.global.prod.js b/dist/vuex-orm-graphql.global.prod.js index 733e644f..a640752b 100644 --- a/dist/vuex-orm-graphql.global.prod.js +++ b/dist/vuex-orm-graphql.global.prod.js @@ -12,4 +12,4 @@ var VuexORMGraphQLPlugin=function(e){"use strict"; See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. - ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+J(e.values,", ")+"]"},ObjectValue:function(e){return"{"+J(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",J(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return J(["schema",J(t," "),W(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return J(["scalar",e.name,J(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return J(["type",t,H("implements ",J(n," & ")),J(r," "),W(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(J(n,"\n")),"\n)"):H("(",J(n,", "),")"))+": "+r+H(" ",J(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return J([t+": "+n,H("= ",r),J(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return J(["interface",t,J(n," "),W(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return J(["union",t,J(n," "),r&&0!==r.length?"= "+J(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return J(["enum",t,J(n," "),W(r)]," ")})),EnumValueDefinition:Y((function(e){return J([e.name,J(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return J(["input",t,J(n," "),W(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(J(n,"\n")),"\n)"):H("(",J(n,", "),")"))+(r?" repeatable":"")+" on "+J(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return J(["extend schema",J(t," "),W(n)]," ")},ScalarTypeExtension:function(e){return J(["extend scalar",e.name,J(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return J(["extend type",t,H("implements ",J(n," & ")),J(r," "),W(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return J(["extend interface",t,J(n," "),W(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return J(["extend union",t,J(n," "),r&&0!==r.length?"= "+J(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return J(["extend enum",t,J(n," "),W(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return J(["extend input",t,J(n," "),W(r)]," ")}};function Y(e){return function(t){return J([t.description,e(t)],"\n")}}function J(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function W(e){return e&&0!==e.length?"{\n"+X(J(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=wr.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=wr.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",e).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=wr.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof wr.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),be=Object.setPrototypeOf,Ee=void 0===be?function(e,t){return e.__proto__=t,e}:be,we=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",Ee(r,t.prototype),r}return n(t,e),t}(Error);function _e(e,t){if(!e)throw new we(t)}function Oe(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=Oe("warn"),e.error=Oe("error")}(_e||(_e={}));var ke={env:{}};if("object"==typeof process)ke=process;else try{Function("stub","process = stub")(ke)}catch(e){}var Ne=Object.prototype,Se=Ne.toString,Te=Ne.hasOwnProperty,Ie=new Map;function xe(e,t){try{return function e(t,n){if(t===n)return!0;var r=Se.call(t),i=Se.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(De(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Be(e){return e&&$e(["client"],e)&&$e(["export"],e)}function Ue(e){var t=e.name.value;return"skip"===t||"include"===t}function Ge(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new we(5):new we("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?_e(1===i.length,6):_e(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function ze(e){for(var t=[],n=1;n1){var r=[];t=Et(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var Lt,$t=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Vt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}(Lt||(Lt={}));var Bt=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=Ye(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Ct.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Vt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new $t({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:qt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Ct.loading:Ct.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&xe(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new we(3):new we("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),xe(this.variables,e)||(this.variables=r(r({},this.variables),e)),xe(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),Lt.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?_e(e.updateQuery,4):_e(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,Lt.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||_e.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&xe(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=pt((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){zt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:ct(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Ut)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(zt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Ct.error,loading:!1})),Gt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!xe(a,i)?e.refetch():Gt(e.observers,"next",n)})):Gt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Pt);function Ut(e){"production"===process.env.NODE_ENV||_e.error("Unhandled error",e.message,e.stack)}function Gt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function zt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?_e("cache-first"!==t&&"cache-only"!==t,5):_e("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Kt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?_e(!t||t.document===e.document||xe(t.document,e.document),19):_e(!t||t.document===e.document||xe(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Ct.loading&&(xe(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Ct.setVariables:e.isPoll?Ct.poll:e.isRefetch?Ct.refetch:Ct.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Ct.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Vt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Ct.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Ct.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Ct.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Ct.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Ct.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=yt(t.resolvers,e)})):this.resolvers=yt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if($e(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||_e.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ke(e);var t=it([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Ce(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?_e(!1,6):_e(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:at(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=He(e),c=We(e),l=Xe(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return Le(e,s)?Ce(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[je(e)]=t,n))}))]:(Qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?_e(i,7):_e(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return mt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=je(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,Fe(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Wt(e){var t=new Set,n=null;return new Pt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Ht=Object.prototype.hasOwnProperty,Xt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Kt,this.queryStore=new Yt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(st?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new we(8):new we("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?_e(t,9):_e(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?_e(!v||"no-cache"===v,10):_e(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Ht.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){ht(r)&&"none"===d?h=new $t({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new $t({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Vt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&ht(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,$e(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===Lt.poll,isRefetch:n===Lt.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new $t({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||_e.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||_e.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=qt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Vt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new $t({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new $t({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),it([ot],Ke(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Be(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:Ze(Ye(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?_e("standby"!==e.fetchPolicy,11):_e("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Bt({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?_e(e.query,12):_e(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?_e("Document"===e.query.kind,13):_e("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?_e(!e.returnPartialData,14):_e(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?_e(!e.pollInterval,15):_e(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new we(16):new we("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||_e.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),ht(i))throw new $t({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Pt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?_e(n,17):_e(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Wt(jt(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Wt(jt(c,l))}else o=Pt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Pt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Vt(e.errors))return l(new $t({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Ct.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Ct.ready&&t.networkStatus!==Ct.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?_e(o,18):_e(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,Lt.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),Zt=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!ht(e);i&&ht(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){ht(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!ht(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=pt((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&pt((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),en=!1,tn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=Ft.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new we(1):new we("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new Zt(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),en||"production"===process.env.NODE_ENV||(en=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Xt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?_e("cache-and-network"!==e.fetchPolicy,2):_e("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return jt(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||_e.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function nn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:rn(e)}]}}function rn(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return rn(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:rn(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var on={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},an=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:Ge(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:Ge(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:on})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:rn(t)}]}),data:s})}else this.writeQuery({query:nn(i),data:i})},e}(),sn=null,un={},cn=1,ln=Array,fn=ln["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",cn++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=sn;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===un)break;return e!==sn&&(sn.slots[this.id]=t),!0}return sn&&(sn.slots[this.id]=un),!1},e.prototype.getValue=function(){if(this.hasValue())return sn.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=sn;sn={parent:a,slots:o};try{return t.apply(r,n)}finally{sn=a}},e.bind=function(e){var t=sn;return function(){var n=sn;try{return sn=t,e.apply(this,arguments)}finally{sn=n}}},e.noContext=function(e,t,n){if(!sn)return e.apply(n,t);var r=sn;try{return sn=null,e.apply(n,t)}finally{sn=r}},e}();try{Object.defineProperty(ln,"@wry/context:Slot",{value:ln["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();fn.bind,fn.noContext;function pn(){}var hn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=pn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),dn=new fn,vn=[],yn=[];function mn(e,t){if(!e)throw new Error(t||"assertion failure")}function gn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var bn=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(mn(!this.recomputing,"already recomputing"),function(e){var t=dn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),wn(e)?kn(t,e):Nn(t,e),t}(this)||!Tn(this))return wn(this)?function(e){var t=In(e);dn.withValue(e,En,[e]),function(e){if("function"==typeof e.subscribe)try{Dn(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,wn(e))return;On(e)}(e);return t.forEach(Tn),gn(e.value)}(this):gn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,_n(this),Dn(this))},e.prototype.dispose=function(){var e=this;In(this).forEach(Tn),Dn(this),this.parents.forEach((function(t){t.setDirty(),xn(t,e)}))},e.count=0,e}();function En(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function wn(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function _n(e){e.parents.forEach((function(t){return kn(t,e)}))}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e,t){if(mn(e.childValues.has(t)),mn(wn(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=yn.pop()||new Set;e.dirtyChildren.add(t),_n(e)}function Nn(e,t){mn(e.childValues.has(t)),mn(!wn(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Sn(e,t),wn(e)||On(e)}function Sn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(yn.length<100&&yn.push(n),e.dirtyChildren=null))}function Tn(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function In(e){var t=vn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){xn(e,r),t.push(r)}))),mn(null===e.dirtyChildren),t}function xn(e,t){t.parents.delete(e),e.childValues.delete(t),Sn(e,t)}function Dn(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var An=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new we(8):new we("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&xe(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Un:o,s=He(t),u={query:t,fragmentMap:Xe(We(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if(Le(e,u))if(Ce(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[je(e)]=c,n))}else{var d=void 0;if(Qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new we(9):new we("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=mt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Me(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Pe({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,Fe(n,i),o,{resultKey:je(n),directives:Ve(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Bn(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&dt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Wn={fragmentMatcher:new qn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Hn=Object.prototype.hasOwnProperty,Xn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Hn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(Gn),Zn=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new An(st),n.silenceBroadcast=!1,n.config=r(r({},Wn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||_e.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||_e.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Vn:new Gn,n.optimisticData=n.data,n.storeWriter=new Kn,n.storeReader=new $n({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=jn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Vn?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new we(1):new we("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Xn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Xn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ke(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Ce(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Ce(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[tt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(an),er={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},tr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},nr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new we(2):new we("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},rr=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&tr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||tr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var ir,or,ar=function(e){function t(t){return e.call(this,rr(t).request)||this}return n(t,e),t}(Ft);(ir=e.ConnectionMode||(e.ConnectionMode={}))[ir.AUTO=0]="AUTO",ir[ir.PLAIN=1]="PLAIN",ir[ir.NODES=2]="NODES",ir[ir.EDGES=3]="EDGES",(or=e.ArgumentMode||(e.ArgumentMode={}))[or.TYPE=0]="TYPE",or[or.LIST=1]="LIST";var sr,ur=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o){var a=this,s=wr.getInstance(),u=e.getRelations(),c={};return void 0===i&&(i=new Map),void 0===o&&(o=!1),Object.keys(t).forEach((function(l){var f=t[l],p=e.getRelations().has(l);if(!(f instanceof Array?p&&a.isRecursion(i,f[0]):p&&a.isRecursion(i,f))&&a.shouldIncludeOutgoingField(o&&n,l,f,e,r)){var h=ge.getRelatedModel(u.get(l));if(f instanceof Array){var d=s.getModel(se(l),!0);d?(a.addRecordForRecursionDetection(i,f[0]),c[l]=f.map((function(t){return a.transformOutgoingData(d||e,t,n,void 0,i,!0)}))):c[l]=f}else"object"==typeof f&&void 0!==f.$id?(h||(h=s.getModel(f.$self().entity)),a.addRecordForRecursionDetection(i,f),c[l]=a.transformOutgoingData(h,f,n,void 0,i,!0)):c[l]=f}})),c},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=wr.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else ge.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i){if(i&&i.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(r.getRelations().has(t)){if(e)return!1;var o=r.getRelations().get(t),a=ge.getRelatedModel(o);return!(!a||!r.shouldEagerSaveRelation(t,o,a))}return!0},t.addRecordForRecursionDetection=function(e,t){var n=wr.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return wr.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=wr.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),cr=((sr=V)&&sr.default||sr).parse;function lr(e){return e.replace(/[\s,]+/g," ").trim()}var fr={},pr={};var hr=!0;var dr=!1;function vr(e){var t=lr(e);if(fr[t])return fr[t];var n=cr(e,{experimentalFragmentVariables:dr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(a.singularName);if(e.shouldEagerLoadRelation(o,i,a)&&!u){var c=t.slice(0);c.push(a.singularName),r.push(n.buildField(a,ge.isConnection(i),void 0,c,o,!1))}})),r.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(wr.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),Or=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],wr.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),kr=function(){function e(){}return e.mutation=function(e,t,n,r){return i(this,void 0,void 0,(function(){var i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=wr.getInstance()).loadSchema()]:[3,5];case 1:return a=o.sent(),s=br.returnsConnection(a.getMutation(e)),u=_r.buildQuery("mutation",r,e,t,s),[4,i.apollo.request(r,u,t,!0)];case 2:return c=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((c=c[Object.keys(c)[0]]).id=parseInt(c.id,10),[4,Or.insertData((h={},h[r.pluralName]=c,h),n)]);case 3:return l=o.sent(),f=l[r.pluralName],(p=f[f.length-1])?[2,p]:(wr.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",l,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return wr.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n){return e[t.singularName]=ur.transformOutgoingData(t,n,!1),e},e.transformArgs=function(e){var t=wr.getInstance();return Object.keys(e).forEach((function(n){var r=e[n];if(r instanceof t.components.Model){var i=t.getModel(se(r.$self().entity)),o=ur.transformOutgoingData(i,r,!1);t.logger.log("A",n,"model was found within the variables and will be transformed from",r,"to",o),e[n]=o}})),e},e}(),Nr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=wr.getInstance().adapter.getNameForDestroy(e),(i=e.$mockHook("destroy",{id:a}))?[4,Or.insertData(i,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,kr.mutation(t,s,r,e)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(kr),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return e=wr.getInstance(),i=this.getModelFromState(n),(a=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,Or.insertData(a,r)]:[4,e.loadSchema()];case 1:return o.sent(),s={},t&&t.filter&&(s=ur.transformOutgoingData(i,t.filter,!0,Object.keys(t.filter))),u=t&&t.bypassCache,c=!s.id,l=e.adapter.getNameForFetch(i,c),f=_r.buildQuery("query",i,l,s,c,c),[4,e.apollo.request(i,f,s,!1,u)];case 2:return p=o.sent(),[2,Or.insertData(p,r)]}}))}))},t}(kr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return s?(e=wr.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,Or.insertData(i,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a),[2,kr.mutation(s,a,r,t)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(kr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=wr.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),(u=e.$mockHook("persist",{id:a,args:s||{}}))?[4,Or.insertData(u,r)]:[3,3]):[3,6];case 1:return c=o.sent(),[4,this.deleteObsoleteRecord(e,c,i)];case 2:return o.sent(),[2,c];case 3:return s=this.prepareArgs(s),this.addRecordToArgs(s,e,i),[4,kr.mutation(t,s,r,e)];case 4:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 5:return o.sent(),[2,l];case 6:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(wr.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(kr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){if(a)return e=this.getModelFromState(n),t=wr.getInstance().adapter.getNameForPush(e),(i=e.$mockHook("push",{data:a,args:s||{}}))?[2,Or.insertData(i,r)]:(s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a),[2,kr.mutation(t,s,r,e)]);throw new Error("The persist action requires the 'data' to be set")}))}))},t}(kr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return a?(e=wr.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("query",{name:a,filter:s||{}}))?[2,Or.insertData(i,r)]:[4,e.loadSchema()]):[3,3];case 1:return c=o.sent(),s=s?ur.transformOutgoingData(t,s,!0):{},l=br.returnsConnection(c.getQuery(a)),f=_r.buildQuery("query",t,a,s,l,!1),[4,e.apollo.request(t,f,s,!1,u)];case 2:return p=o.sent(),[2,Or.insertData(p,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(kr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=wr.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(kr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=wr.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(kr),Mr=function(){function e(t,n){wr.setup(t,n),e.setupActions(),e.setupModelMethods()}return e.prototype.getContext=function(){return wr.getInstance()},e.setupActions=function(){var e=wr.getInstance();e.components.RootActions.simpleQuery=Ar.call.bind(Ar),e.components.RootActions.simpleMutation=Rr.call.bind(Rr),e.components.Actions.fetch=Sr.call.bind(Sr),e.components.Actions.persist=Ir.call.bind(Ir),e.components.Actions.push=xr.call.bind(xr),e.components.Actions.destroy=Nr.call.bind(Nr),e.components.Actions.mutate=Tr.call.bind(Tr),e.components.Actions.query=Dr.call.bind(Dr)},e.setupModelMethods=function(){var e=wr.getInstance();e.components.Model.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))},e.components.Model.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},e.components.Model.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))};var t=e.components.Model.prototype;t.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=this.$id),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))},t.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=this.$id),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},t.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))},t.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))},t.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:this.$id})]}))}))},t.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},e}(),Fr=function(){function e(){}return e.install=function(t,n){return e.instance=new Mr(t,n),e.instance},e}(),jr=null;var Cr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?jr.addGlobalMock(this):jr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=Er,e.Mock=Cr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!jr)throw new Error("Please call setupTestUtils() before!");return[4,jr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=Fr,e.mock=function(e,t){if(!jr)throw new Error("Please call setupTestUtils() before!");return new Cr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");jr=e.instance.getContext()},e}({}); + ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+W(e.values,", ")+"]"},ObjectValue:function(e){return"{"+W(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",W(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return W(["schema",W(t," "),J(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return W(["scalar",e.name,W(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+": "+r+H(" ",W(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return W([t+": "+n,H("= ",r),W(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["interface",t,W(n," "),J(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return W(["union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return W(["enum",t,W(n," "),J(r)]," ")})),EnumValueDefinition:Y((function(e){return W([e.name,W(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["input",t,W(n," "),J(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return W(["extend schema",W(t," "),J(n)]," ")},ScalarTypeExtension:function(e){return W(["extend scalar",e.name,W(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["extend type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend interface",t,W(n," "),J(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return W(["extend union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return W(["extend enum",t,W(n," "),J(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend input",t,W(n," "),J(r)]," ")}};function Y(e){return function(t){return W([t.description,e(t)],"\n")}}function W(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function J(e){return e&&0!==e.length?"{\n"+X(W(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=_r.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=_r.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",me(e)).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=_r.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof _r.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),Ee=Object.setPrototypeOf,we=void 0===Ee?function(e,t){return e.__proto__=t,e}:Ee,_e=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",we(r,t.prototype),r}return n(t,e),t}(Error);function Oe(e,t){if(!e)throw new _e(t)}function ke(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=ke("warn"),e.error=ke("error")}(Oe||(Oe={}));var Ne={env:{}};if("object"==typeof process)Ne=process;else try{Function("stub","process = stub")(Ne)}catch(e){}var Se=Object.prototype,Te=Se.toString,Ie=Se.hasOwnProperty,xe=new Map;function De(e,t){try{return function e(t,n){if(t===n)return!0;var r=Te.call(t),i=Te.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(Ae(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Ue(e){return e&&Be(["client"],e)&&Be(["export"],e)}function Ge(e){var t=e.name.value;return"skip"===t||"include"===t}function ze(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new _e(5):new _e("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?Oe(1===i.length,6):Oe(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function Ke(e){for(var t=[],n=1;n1){var r=[];t=wt(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var $t,Bt=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Lt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}($t||($t={}));var Ut=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=We(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Qt.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Lt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new Bt({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:Pt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Qt.loading:Qt.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&De(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new _e(3):new _e("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),De(this.variables,e)||(this.variables=r(r({},this.variables),e)),De(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),$t.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Oe(e.updateQuery,4):Oe(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,$t.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Oe.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&De(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=ht((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){Kt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:lt(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Gt)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(Kt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Qt.error,loading:!1})),zt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!De(a,i)?e.refetch():zt(e.observers,"next",n)})):zt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Vt);function Gt(e){"production"===process.env.NODE_ENV||Oe.error("Unhandled error",e.message,e.stack)}function zt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function Kt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Oe("cache-first"!==t&&"cache-only"!==t,5):Oe("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Wt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Oe(!t||t.document===e.document||De(t.document,e.document),19):Oe(!t||t.document===e.document||De(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Qt.loading&&(De(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Qt.setVariables:e.isPoll?Qt.poll:e.isRefetch?Qt.refetch:Qt.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Qt.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Lt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Qt.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Qt.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Qt.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Qt.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Qt.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=mt(t.resolvers,e)})):this.resolvers=mt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(Be(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Oe.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ye(e);var t=ot([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qe(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Oe(!1,6):Oe(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:st(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=Xe(e),c=He(e),l=Ze(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return $e(e,s)?Qe(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[Ce(e)]=t,n))}))]:(qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?Oe(i,7):Oe(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return gt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=Ce(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,je(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Ht(e){var t=new Set,n=null;return new Vt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Xt=Object.prototype.hasOwnProperty,Zt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Yt,this.queryStore=new Wt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(ut?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(8):new _e("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?Oe(t,9):Oe(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Oe(!v||"no-cache"===v,10):Oe(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Xt.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){dt(r)&&"none"===d?h=new Bt({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new Bt({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Lt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&dt(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,Be(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===$t.poll,isRefetch:n===$t.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new Bt({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||Oe.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Oe.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=Pt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Lt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new Bt({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new Bt({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),ot([at],Ye(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Ue(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:et(We(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Oe("standby"!==e.fetchPolicy,11):Oe("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Ut({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Oe(e.query,12):Oe(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Oe("Document"===e.query.kind,13):Oe("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Oe(!e.returnPartialData,14):Oe(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Oe(!e.pollInterval,15):Oe(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(16):new _e("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||Oe.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),dt(i))throw new Bt({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Vt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Oe(n,17):Oe(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Ht(Ct(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Ht(Ct(c,l))}else o=Vt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Vt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Lt(e.errors))return l(new Bt({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Qt.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Qt.ready&&t.networkStatus!==Qt.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?Oe(o,18):Oe(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,$t.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),en=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!dt(e);i&&dt(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){dt(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!dt(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=ht((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&ht((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),tn=!1,nn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=jt.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new _e(1):new _e("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new en(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),tn||"production"===process.env.NODE_ENV||(tn=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Zt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Oe("cache-and-network"!==e.fetchPolicy,2):Oe("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Ct(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Oe.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function rn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(e)}]}}function on(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return on(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:on(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var an={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},sn=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:ze(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:ze(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:an})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(t)}]}),data:s})}else this.writeQuery({query:rn(i),data:i})},e}(),un=null,cn={},ln=1,fn=Array,pn=fn["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",ln++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=un;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===cn)break;return e!==un&&(un.slots[this.id]=t),!0}return un&&(un.slots[this.id]=cn),!1},e.prototype.getValue=function(){if(this.hasValue())return un.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=un;un={parent:a,slots:o};try{return t.apply(r,n)}finally{un=a}},e.bind=function(e){var t=un;return function(){var n=un;try{return un=t,e.apply(this,arguments)}finally{un=n}}},e.noContext=function(e,t,n){if(!un)return e.apply(n,t);var r=un;try{return un=null,e.apply(n,t)}finally{un=r}},e}();try{Object.defineProperty(fn,"@wry/context:Slot",{value:fn["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();pn.bind,pn.noContext;function hn(){}var dn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=hn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),vn=new pn,yn=[],mn=[];function gn(e,t){if(!e)throw new Error(t||"assertion failure")}function bn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var En=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(gn(!this.recomputing,"already recomputing"),function(e){var t=vn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),_n(e)?Nn(t,e):Sn(t,e),t}(this)||!In(this))return _n(this)?function(e){var t=xn(e);vn.withValue(e,wn,[e]),function(e){if("function"==typeof e.subscribe)try{An(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,_n(e))return;kn(e)}(e);return t.forEach(In),bn(e.value)}(this):bn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,On(this),An(this))},e.prototype.dispose=function(){var e=this;xn(this).forEach(In),An(this),this.parents.forEach((function(t){t.setDirty(),Dn(t,e)}))},e.count=0,e}();function wn(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function _n(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e){e.parents.forEach((function(t){return Sn(t,e)}))}function Nn(e,t){if(gn(e.childValues.has(t)),gn(_n(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=mn.pop()||new Set;e.dirtyChildren.add(t),On(e)}function Sn(e,t){gn(e.childValues.has(t)),gn(!_n(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Tn(e,t),_n(e)||kn(e)}function Tn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(mn.length<100&&mn.push(n),e.dirtyChildren=null))}function In(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function xn(e){var t=yn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){Dn(e,r),t.push(r)}))),gn(null===e.dirtyChildren),t}function Dn(e,t){t.parents.delete(e),e.childValues.delete(t),Tn(e,t)}function An(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var Rn=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new _e(8):new _e("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&De(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Gn:o,s=Xe(t),u={query:t,fragmentMap:Ze(He(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if($e(e,u))if(Qe(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[Ce(e)]=c,n))}else{var d=void 0;if(qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new _e(9):new _e("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=gt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Fe(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Ve({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,je(n,i),o,{resultKey:Ce(n),directives:Le(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Un(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&vt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Hn={fragmentMatcher:new Pn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Xn=Object.prototype.hasOwnProperty,Zn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Xn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(zn),er=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new Rn(ut),n.silenceBroadcast=!1,n.config=r(r({},Hn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||Oe.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||Oe.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Ln:new zn,n.optimisticData=n.data,n.storeWriter=new Yn,n.storeReader=new Bn({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=Cn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Ln?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new _e(1):new _e("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Zn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Zn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ye(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Qe(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Qe(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[nt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(sn),tr={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},nr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},rr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new _e(2):new _e("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},ir=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&nr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||nr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var or,ar,sr=function(e){function t(t){return e.call(this,ir(t).request)||this}return n(t,e),t}(jt);(or=e.ConnectionMode||(e.ConnectionMode={}))[or.AUTO=0]="AUTO",or[or.PLAIN=1]="PLAIN",or[or.NODES=2]="NODES",or[or.EDGES=3]="EDGES",(ar=e.ArgumentMode||(e.ArgumentMode={}))[ar.TYPE=0]="TYPE",ar[ar.LIST=1]="LIST";var ur,cr=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o){var a=this,s=_r.getInstance(),u=e.getRelations(),c={};return void 0===i&&(i=new Map),void 0===o&&(o=!1),Object.keys(t).forEach((function(l){var f=t[l],p=e.getRelations().has(l);if(!(f instanceof Array?p&&a.isRecursion(i,f[0]):p&&a.isRecursion(i,f))&&a.shouldIncludeOutgoingField(o&&n,l,f,e,r)){var h=be.getRelatedModel(u.get(l));if(f instanceof Array){var d=s.getModel(se(l),!0);d?(a.addRecordForRecursionDetection(i,f[0]),c[l]=f.map((function(t){return a.transformOutgoingData(d||e,t,n,void 0,i,!0)}))):c[l]=f}else"object"==typeof f&&void 0!==f.$id?(h||(h=s.getModel(f.$self().entity)),a.addRecordForRecursionDetection(i,f),c[l]=a.transformOutgoingData(h,f,n,void 0,i,!0)):c[l]=f}})),c},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=_r.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else be.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i){if(i&&i.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(r.getRelations().has(t)){if(e)return!1;var o=r.getRelations().get(t),a=be.getRelatedModel(o);return!(!a||!r.shouldEagerSaveRelation(t,o,a))}return!0},t.addRecordForRecursionDetection=function(e,t){var n=_r.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return _r.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=_r.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),lr=((ur=V)&&ur.default||ur).parse;function fr(e){return e.replace(/[\s,]+/g," ").trim()}var pr={},hr={};var dr=!0;var vr=!1;function yr(e){var t=fr(e);if(pr[t])return pr[t];var n=lr(e,{experimentalFragmentVariables:vr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(a.singularName);if(e.shouldEagerLoadRelation(o,i,a)&&!u){var c=t.slice(0);c.push(a.singularName),r.push(n.buildField(a,be.isConnection(i),void 0,c,o,!1))}})),r.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(_r.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),kr=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],_r.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),Nr=function(){function e(){}return e.mutation=function(e,t,n,r){return i(this,void 0,void 0,(function(){var i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=_r.getInstance()).loadSchema()]:[3,5];case 1:return a=o.sent(),s=Er.returnsConnection(a.getMutation(e)),u=Or.buildQuery("mutation",r,e,t,s),[4,i.apollo.request(r,u,t,!0)];case 2:return c=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((c=c[Object.keys(c)[0]]).id=me(c.id),[4,kr.insertData((h={},h[r.pluralName]=c,h),n)]);case 3:return l=o.sent(),f=l[r.pluralName],(p=f[f.length-1])?[2,p]:(_r.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",l,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return _r.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n){return e[t.singularName]=cr.transformOutgoingData(t,n,!1),e},e.transformArgs=function(e){var t=_r.getInstance();return Object.keys(e).forEach((function(n){var r=e[n];if(r instanceof t.components.Model){var i=t.getModel(se(r.$self().entity)),o=cr.transformOutgoingData(i,r,!1);t.logger.log("A",n,"model was found within the variables and will be transformed from",r,"to",o),e[n]=o}})),e},e}(),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForDestroy(e),(i=e.$mockHook("destroy",{id:a}))?[4,kr.insertData(i,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,Nr.mutation(t,s,r,e)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(Nr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),i=this.getModelFromState(n),(a=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,kr.insertData(a,r)]:[4,e.loadSchema()];case 1:return o.sent(),s={},t&&t.filter&&(s=cr.transformOutgoingData(i,t.filter,!0,Object.keys(t.filter))),u=t&&t.bypassCache,c=!s.id,l=e.adapter.getNameForFetch(i,c),f=Or.buildQuery("query",i,l,s,c,c),[4,e.apollo.request(i,f,s,!1,u)];case 2:return p=o.sent(),[2,kr.insertData(p,r)]}}))}))},t}(Nr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return s?(e=_r.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,kr.insertData(i,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a),[2,Nr.mutation(s,a,r,t)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(Nr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),(u=e.$mockHook("persist",{id:me(a),args:s||{}}))?[4,kr.insertData(u,r)]:[3,3]):[3,6];case 1:return c=o.sent(),[4,this.deleteObsoleteRecord(e,c,i)];case 2:return o.sent(),[2,c];case 3:return s=this.prepareArgs(s),this.addRecordToArgs(s,e,i),[4,Nr.mutation(t,s,r,e)];case 4:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 5:return o.sent(),[2,l];case 6:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(_r.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(Nr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){if(a)return e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPush(e),(i=e.$mockHook("push",{data:a,args:s||{}}))?[2,kr.insertData(i,r)]:(s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a),[2,Nr.mutation(t,s,r,e)]);throw new Error("The persist action requires the 'data' to be set")}))}))},t}(Nr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return a?(e=_r.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("query",{name:a,filter:s||{}}))?[2,kr.insertData(i,r)]:[4,e.loadSchema()]):[3,3];case 1:return c=o.sent(),s=s?cr.transformOutgoingData(t,s,!0):{},l=Er.returnsConnection(c.getQuery(a)),f=Or.buildQuery("query",t,a,s,l,!1),[4,e.apollo.request(t,f,s,!1,u)];case 2:return p=o.sent(),[2,kr.insertData(p,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(Nr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(Nr),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(Nr),Fr=function(){function e(t,n){_r.setup(t,n),e.setupActions(),e.setupModelMethods()}return e.prototype.getContext=function(){return _r.getInstance()},e.setupActions=function(){var e=_r.getInstance();e.components.RootActions.simpleQuery=Rr.call.bind(Rr),e.components.RootActions.simpleMutation=Mr.call.bind(Mr),e.components.Actions.fetch=Tr.call.bind(Tr),e.components.Actions.persist=xr.call.bind(xr),e.components.Actions.push=Dr.call.bind(Dr),e.components.Actions.destroy=Sr.call.bind(Sr),e.components.Actions.mutate=Ir.call.bind(Ir),e.components.Actions.query=Ar.call.bind(Ar)},e.setupModelMethods=function(){var e=_r.getInstance();e.components.Model.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))},e.components.Model.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},e.components.Model.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))};var t=e.components.Model.prototype;t.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))},t.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},t.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))},t.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))},t.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:me(this.$id)})]}))}))},t.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},e}(),jr=function(){function e(){}return e.install=function(t,n){return e.instance=new Fr(t,n),e.instance},e}(),Cr=null;var Qr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?Cr.addGlobalMock(this):Cr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=wr,e.Mock=Qr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!Cr)throw new Error("Please call setupTestUtils() before!");return[4,Cr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=jr,e.mock=function(e,t){if(!Cr)throw new Error("Please call setupTestUtils() before!");return new Qr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");Cr=e.instance.getContext()},e}({}); diff --git a/package.json b/package.json index 3c5e7da6..1a0387c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vuex-orm/plugin-graphql", - "version": "1.0.0-rc.36", + "version": "1.0.0-rc.37", "description": "Vuex-ORM persistence plugin to sync the store against a GraphQL API.", "main": "dist/vuex-orm-graphql.cjs.js", "browser": "dist/vuex-orm-graphql.esm.js", diff --git a/src/actions/action.ts b/src/actions/action.ts index 6dda5150..4c6d6bd3 100644 --- a/src/actions/action.ts +++ b/src/actions/action.ts @@ -6,7 +6,7 @@ import Model from "../orm/model"; import RootState from "@vuex-orm/core/lib/modules/contracts/RootState"; import Transformer from "../graphql/transformer"; import Schema from "../graphql/schema"; -import { singularize } from "../support/utils"; +import { singularize, toNumber } from "../support/utils"; /** * Base class for all Vuex actions. Contains some utility and convenience methods. @@ -43,7 +43,7 @@ export default class Action { newData = newData[Object.keys(newData)[0]]; // IDs as String cause terrible issues, so we convert them to integers. - newData.id = parseInt(newData.id, 10); + newData.id = toNumber(newData.id); const insertedData: Data = await Store.insertData( { [model.pluralName]: newData } as Data, diff --git a/src/actions/destroy.ts b/src/actions/destroy.ts index 7488f57c..487ef028 100644 --- a/src/actions/destroy.ts +++ b/src/actions/destroy.ts @@ -10,7 +10,7 @@ export default class Destroy extends Action { /** * @param {State} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to delete + * @param {number} id ID of the record to delete * @returns {Promise} true */ public static async call( diff --git a/src/actions/persist.ts b/src/actions/persist.ts index 4833aa6b..5ed13c82 100644 --- a/src/actions/persist.ts +++ b/src/actions/persist.ts @@ -3,6 +3,7 @@ import { ActionParams, Data } from "../support/interfaces"; import Action from "./action"; import Model from "../orm/model"; import { Store } from "../orm/store"; +import { toNumber } from "../support/utils"; /** * Persist action for sending a create mutation. Will be used for record.$persist(). @@ -11,7 +12,7 @@ export default class Persist extends Action { /** * @param {any} state The Vuex state * @param {DispatchFunction} dispatch Vuex Dispatch method for the model - * @param {string} id ID of the record to persist + * @param {number|string} id ID of the record to persist * @returns {Promise} The saved record */ public static async call( @@ -24,7 +25,7 @@ export default class Persist extends Action { const oldRecord = model.getRecordWithId(id)!; const mockReturnValue = model.$mockHook("persist", { - id, + id: toNumber(id), args: args || {} }); diff --git a/src/orm/model.ts b/src/orm/model.ts index 0307edbc..17e9555d 100644 --- a/src/orm/model.ts +++ b/src/orm/model.ts @@ -2,7 +2,7 @@ import { Model as ORMModel, Relation } from "@vuex-orm/core"; import { Field, PatchedModel } from "../support/interfaces"; import Context from "../common/context"; import { Mock, MockOptions } from "../test-utils"; -import { pluralize, singularize, pick, isEqual } from "../support/utils"; +import { pluralize, singularize, pick, isEqual, toNumber } from "../support/utils"; /** * Wrapper around a Vuex-ORM model with some useful methods. @@ -67,8 +67,8 @@ export default class Model { if (!field) return false; const context = Context.getInstance(); - // Remove UID cause it must be a string - return field instanceof context.components.Number; + + return field instanceof context.components.Number || field instanceof context.components.Uid; } /** @@ -257,14 +257,14 @@ export default class Model { /** * Returns a record of this model with the given ID. - * @param {string} id + * @param {number|string} id * @returns {any} */ - public getRecordWithId(id: string) { + public getRecordWithId(id: number | string) { return this.baseModel .query() .withAllRecursive() - .where("id", id) + .where("id", toNumber(id)) .first(); } diff --git a/src/support/utils.ts b/src/support/utils.ts index 4c72b62d..35d8f2d6 100644 --- a/src/support/utils.ts +++ b/src/support/utils.ts @@ -126,3 +126,16 @@ export function matches(source: any) { export function removeSymbols(input: any) { return JSON.parse(JSON.stringify(input)); } + +/** + * Converts the argument into a number. + */ +export function toNumber(input: string | number | null): number | string { + if (input === null) return 0; + + if (typeof input === "string" && input.startsWith("$uid")) { + return input; + } + + return parseInt(input.toString(), 10); +} diff --git a/src/vuex-orm-graphql.ts b/src/vuex-orm-graphql.ts index cca51c10..2fba53c7 100644 --- a/src/vuex-orm-graphql.ts +++ b/src/vuex-orm-graphql.ts @@ -5,7 +5,7 @@ import { Destroy, Fetch, Mutate, Persist, Push } from "./actions"; import Query from "./actions/query"; import SimpleQuery from "./actions/simple-query"; import SimpleMutation from "./actions/simple-mutation"; -import { isPlainObject } from "./support/utils"; +import { isPlainObject, toNumber } from "./support/utils"; /** * Main class of the plugin. Setups the internal context, Vuex actions and model methods @@ -85,13 +85,13 @@ export default class VuexORMGraphQL { model.$mutate = async function({ name, args, multiple }: ActionParams) { args = args || {}; - if (!args["id"]) args["id"] = this.$id; + if (!args["id"]) args["id"] = toNumber(this.$id); return this.$dispatch("mutate", { name, args, multiple }); }; model.$customQuery = async function({ name, filter, multiple, bypassCache }: ActionParams) { filter = filter || {}; - if (!filter["id"]) filter["id"] = this.$id; + if (!filter["id"]) filter["id"] = toNumber(this.$id); return this.$dispatch("query", { name, filter, multiple, bypassCache }); }; @@ -104,7 +104,7 @@ export default class VuexORMGraphQL { }; model.$destroy = async function() { - return this.$dispatch("destroy", { id: this.$id }); + return this.$dispatch("destroy", { id: toNumber(this.$id) }); }; model.$deleteAndDestroy = async function() { diff --git a/test/integration/actions/customQuery.spec.ts b/test/integration/actions/customQuery.spec.ts index d329c1ea..0f60a91f 100644 --- a/test/integration/actions/customQuery.spec.ts +++ b/test/integration/actions/customQuery.spec.ts @@ -13,10 +13,10 @@ describe("custom query", () => { test("via Model method sends the correct query to the API", async () => { const request = await recordGraphQLRequest(async () => { // @ts-ignore - await Post.customQuery({ name: "unpublishedPosts", filter: { authorId: "3" } }); + await Post.customQuery({ name: "unpublishedPosts", filter: { authorId: 3 } }); }); - expect(request!.variables.authorId).toEqual("3"); + expect(request!.variables.authorId).toEqual(3); expect(request!.query).toEqual( ` query UnpublishedPosts($authorId: ID!) { @@ -74,11 +74,11 @@ query UnpublishedPosts($authorId: ID!) { const post: Data = Post.find(1)! as Data; const request = await recordGraphQLRequest(async () => { - await post.$customQuery({ name: "unpublishedPosts", filter: { authorId: "2" } }); + await post.$customQuery({ name: "unpublishedPosts", filter: { authorId: 2 } }); }); - expect(request!.variables.authorId).toEqual("2"); - expect(request!.variables.id).toEqual("1"); + expect(request!.variables.authorId).toEqual(2); + expect(request!.variables.id).toEqual(1); expect(request!.query).toEqual( ` query UnpublishedPosts($authorId: ID!, $id: ID!) { diff --git a/test/integration/actions/deleteAndDestroy.spec.ts b/test/integration/actions/deleteAndDestroy.spec.ts index dcf1f1fb..2bc04183 100644 --- a/test/integration/actions/deleteAndDestroy.spec.ts +++ b/test/integration/actions/deleteAndDestroy.spec.ts @@ -19,7 +19,7 @@ describe("deleteAndDestroy", () => { await post.$deleteAndDestroy(); }); - expect(request!.variables).toEqual({ id: "1" }); + expect(request!.variables).toEqual({ id: 1 }); expect(request!.query).toEqual( ` mutation DeletePost($id: ID!) { diff --git a/test/integration/actions/destroy.spec.ts b/test/integration/actions/destroy.spec.ts index 2842df92..d6bda66f 100644 --- a/test/integration/actions/destroy.spec.ts +++ b/test/integration/actions/destroy.spec.ts @@ -19,7 +19,7 @@ describe("destroy", () => { await post.$destroy(); }); - expect(request!.variables).toEqual({ id: "1" }); + expect(request!.variables).toEqual({ id: 1 }); expect(request!.query).toEqual( ` mutation DeletePost($id: ID!) { diff --git a/test/integration/actions/fetch.spec.ts b/test/integration/actions/fetch.spec.ts index bf7aedea..70e1dff1 100644 --- a/test/integration/actions/fetch.spec.ts +++ b/test/integration/actions/fetch.spec.ts @@ -14,7 +14,7 @@ describe("fetch", () => { test("also requests the otherId field", async () => { const request = await recordGraphQLRequest(async () => { // @ts-ignore - await Post.fetch("1"); + await Post.fetch(1); }); expect(request!.query).toEqual( @@ -67,7 +67,7 @@ query Post($id: ID!) { const post: Data = Post.query() .withAll() - .where("id", "1") + .where("id", 1) .first()! as Data; expect(post.title).toEqual("GraphQL"); @@ -150,7 +150,7 @@ query User($id: ID!) { posts: [ { id: expect.stringMatching(/(\$uid\d+)/), - authorId: "1", + authorId: 1, content: "This is a test!", otherId: 15, published: false, @@ -185,7 +185,7 @@ query Users($profileId: ID!, $posts: [PostFilter]!) { await Profile.fetch(2); const profile: Data = Context.getInstance() .getModel("profile") - .getRecordWithId("2")! as Data; + .getRecordWithId(2)! as Data; const request = await recordGraphQLRequest(async () => { // @ts-ignore diff --git a/test/integration/actions/push.spec.ts b/test/integration/actions/push.spec.ts index 81aa0da9..8255dc3d 100644 --- a/test/integration/actions/push.spec.ts +++ b/test/integration/actions/push.spec.ts @@ -21,8 +21,8 @@ describe("push", () => { }); expect(request!.variables).toEqual({ - id: "1", - user: { id: "1", name: "Snoopy", profileId: "1" } + id: 1, + user: { id: 1, name: "Snoopy", profileId: 1 } }); expect(request!.query).toEqual( ` diff --git a/test/integration/plugin.spec.ts b/test/integration/plugin.spec.ts index 7aaf4808..4188c6a7 100644 --- a/test/integration/plugin.spec.ts +++ b/test/integration/plugin.spec.ts @@ -46,7 +46,7 @@ describe("Plugin GraphQL", () => { expect(user.$isPersisted).toBeFalsy(); const result = await user.$persist(); - user = User.find(4)! as Data; + user = User.query().last() as Data; expect(user.$isPersisted).toBeTruthy(); }); diff --git a/test/integration/test-utils.spec.ts b/test/integration/test-utils.spec.ts index 9ebe800b..55455cd0 100644 --- a/test/integration/test-utils.spec.ts +++ b/test/integration/test-utils.spec.ts @@ -8,18 +8,18 @@ let store; let vuexOrmGraphQL; const userData = { - id: "42", + id: 42, name: "Charlie Brown" }; const userResult = { users: [ { - id: "42", + id: 42, $id: "42", $isPersisted: true, name: "Charlie Brown", - profileId: "", + profileId: 0, posts: [], comments: [], profile: null @@ -33,14 +33,14 @@ describe("TestUtils", () => { }); it("allows to mock a fetch", async () => { - mock("fetch", { filter: { id: "42" } }) + mock("fetch", { filter: { id: 42 } }) .for(User) .andReturn(userData); let result; const request = await recordGraphQLRequest(async () => { // @ts-ignore - result = await User.fetch("42"); + result = await User.fetch(42); }, true); expect(request).toEqual(null); @@ -49,7 +49,7 @@ describe("TestUtils", () => { it("allows to return multiple records", async () => { const userData2 = JSON.parse(JSON.stringify(userData)); - userData2.id = "8"; + userData2.id = 8; userData2.name = "Snoopy"; mock("fetch") @@ -66,21 +66,21 @@ describe("TestUtils", () => { expect(result).toEqual({ users: [ { - id: "8", + id: 8, $id: "8", $isPersisted: true, name: "Snoopy", - profileId: "", + profileId: 0, posts: [], comments: [], profile: null }, { - id: "42", + id: 42, $id: "42", $isPersisted: true, name: "Charlie Brown", - profileId: "", + profileId: 0, posts: [], comments: [], profile: null @@ -170,7 +170,7 @@ describe("TestUtils", () => { }); it("allows to mock a destroy", async () => { - mock("destroy", { id: "42" }) + mock("destroy", { id: 42 }) .for(User) .andReturn(userData); @@ -187,7 +187,7 @@ describe("TestUtils", () => { }); it("allows to mock a mutate", async () => { - mock("mutate", { name: "upvote", args: { id: "4" } }) + mock("mutate", { name: "upvote", args: { id: 4 } }) .for(Post) .andReturn({ id: 4, @@ -200,7 +200,7 @@ describe("TestUtils", () => { let result; const request = await recordGraphQLRequest(async () => { // @ts-ignore - result = await Post.mutate({ name: "upvote", args: { id: "4" } }); + result = await Post.mutate({ name: "upvote", args: { id: 4 } }); }, true); expect(request).toEqual(null); @@ -212,7 +212,7 @@ describe("TestUtils", () => { $id: "4", content: "Test content", title: "Test title", - authorId: "", + authorId: 0, otherId: 0, published: true, author: null, @@ -224,7 +224,7 @@ describe("TestUtils", () => { }); it("allows to mock a persist", async () => { - mock("persist", { id: "42" }) + mock("persist", { id: 42 }) .for(User) .andReturn(userData); diff --git a/test/support/mock-data.ts b/test/support/mock-data.ts index 8f2372c8..b49870f9 100644 --- a/test/support/mock-data.ts +++ b/test/support/mock-data.ts @@ -16,7 +16,7 @@ export class User extends ORMModel { return { id: this.uid(), name: this.string(""), - profileId: this.string(""), + profileId: this.number(0), posts: this.hasMany(Post, "authorId"), comments: this.hasMany(Comment, "authorId"), profile: this.belongsTo(Profile, "profileId") @@ -48,7 +48,7 @@ export class Video extends ORMModel { id: this.uid(), content: this.string(""), title: this.string(""), - authorId: this.string(""), + authorId: this.number(0), otherId: this.number(0), // This is a field which ends with `Id` but doesn't belong to any relation ignoreMe: this.string(""), author: this.belongsTo(User, "authorId"), @@ -68,7 +68,7 @@ export class Post extends ORMModel { id: this.uid(), content: this.string(""), title: this.string(""), - authorId: this.string(""), + authorId: this.number(0), otherId: this.number(0), // This is a field which ends with `Id` but doesn't belong to any relation published: this.boolean(true), author: this.belongsTo(User, "authorId"), @@ -85,9 +85,9 @@ export class Comment extends ORMModel { return { id: this.uid(), content: this.string(""), - authorId: this.string(""), + authorId: this.number(0), author: this.belongsTo(User, "authorId"), - subjectId: this.string(""), + subjectId: this.number(0), subjectType: this.string("") }; } @@ -100,7 +100,7 @@ export class TariffTariffOption extends ORMModel { static fields(): Fields { return { tariffUuid: this.string(""), - tariffOptionId: this.string("") + tariffOptionId: this.number(0) }; } } @@ -112,7 +112,7 @@ export class Tariff extends ORMModel { static fields(): Fields { return { - uuid: this.uid(), + uuid: this.string(""), name: this.string(""), displayName: this.string(""), tariffType: this.string(""), @@ -151,7 +151,7 @@ export class Category extends ORMModel { id: this.uid(), name: this.string(""), - parentId: this.string(""), + parentId: this.number(0), parent: this.belongsTo(Category, "parentId") }; } @@ -163,8 +163,8 @@ export class Taggable extends ORMModel { static fields(): Fields { return { id: this.uid(), - tagId: this.string(""), - subjectId: this.string(""), + tagId: this.number(0), + subjectId: this.number(0), subjectType: this.string("") }; } diff --git a/test/support/mock-schema.ts b/test/support/mock-schema.ts index d4d56cc8..cc8b0155 100644 --- a/test/support/mock-schema.ts +++ b/test/support/mock-schema.ts @@ -34,7 +34,7 @@ export const typeDefs = ` categories: CategoryTypeConnection! tag(id: ID!): Tag! tags: TagTypeConnection! - + unpublishedPosts(authorId: ID!): PostTypeConnection status: Status } @@ -47,7 +47,7 @@ export const typeDefs = ` deleteComment(id: ID!): Comment! deleteTariffOption(id: ID!): TariffOption! deleteTariff(uuid: String!): Tariff! - + createUser(user: UserInput!): User! createProfile(profile: ProfileInput!): Profile! createPost(post: PostInput!): Post! @@ -55,7 +55,7 @@ export const typeDefs = ` createComment(comment: CommentInput!): Comment! createTariffOption(tariffOption: TariffOptionInput!): TariffOption! createTariff(tariff: TariffInput!): Tariff! - + updateUser(id: ID!, user: UserInput!): User! updateProfile(id: ID!, profile: ProfileInput!): Profile! updatePost(id: ID!, post: PostInput!): Post! @@ -63,7 +63,7 @@ export const typeDefs = ` updateComment(id: ID!, comment: CommentInput!): Comment! updateTariffOption(id: ID!, tariffOption: TariffOptionInput!): TariffOption! updateTariff(uuid: String!, tariff: TariffInput!): Tariff! - + upvotePost(captchaToken: String!, id: ID!): Post! sendSms(to: String!, text: String!): SmsStatus! reorderItems(id: ID!, itemIds: [ID]!): PostTypeConnection @@ -365,8 +365,8 @@ export const typeDefs = ` type CategoryTypeConnection { nodes: [Category!]! } - - + + type Tag { id: ID name: String @@ -398,41 +398,41 @@ export const typeDefs = ` const users = [ { - id: "1", + id: 1, name: "Charlie Brown", - profileId: "1" + profileId: 1 }, { - id: "2", + id: 2, name: "Peppermint Patty", - profileId: "2" + profileId: 2 }, { - id: "3", + id: 3, name: "Snoopy", - profileId: "3" + profileId: 3 } ]; const profiles = [ { - id: "1", + id: 1, email: "charlie@peanuts.com", age: 8, sex: true }, { - id: "2", + id: 2, email: "peppermint@peanuts.com", age: 9, sex: false }, { - id: "3", + id: 3, email: "snoopy@peanuts.com", age: 5, sex: true @@ -441,87 +441,87 @@ const profiles = [ const videos = [ { - id: "1", + id: 1, content: "Foo", title: "Example Video 1", - otherId: "42", - authorId: "1", - tags: ["4"] + otherId: 42, + authorId: 1, + tags: [4] }, { - id: "2", + id: 2, content: "Bar", title: "Example Video 2", otherId: 67, - authorId: "2", - tags: ["1"] + authorId: 2, + tags: [1] }, { - id: "3", + id: 3, content: "FooBar", title: "Example Video 3", otherId: 491, - authorId: "2", - tags: ["1", "3"] + authorId: 2, + tags: [1, 3] } ]; const posts = [ { - id: "1", + id: 1, content: "GraphQL is so nice!", title: "GraphQL", - otherId: "123", + otherId: 123, published: true, - authorId: "1", - tags: ["1", "2"] + authorId: 1, + tags: [1, 2] }, { - id: "2", + id: 2, content: "Vue is so awesome!", title: "Vue.js", otherId: 435, published: true, - authorId: "3", - tags: ["3", "4"] + authorId: 3, + tags: [3, 4] }, { - id: "3", + id: 3, content: "Vuex-ORM is so crisp", title: "Vuex-ORM", otherId: 987, published: false, - authorId: "3", - tags: ["4", "1"] + authorId: 3, + tags: [4, 1] } ]; const comments = [ { - id: "1", + id: 1, content: "Yes!!!!", - authorId: "2", - subjectId: "1", + authorId: 2, + subjectId: 1, subjectType: "post" }, { - id: "2", + id: 2, content: "So crazy :O", - authorId: "1", - subjectId: "2", + authorId: 1, + subjectId: 2, subjectType: "video" }, { - id: "3", + id: 3, content: "Hell no!", - authorId: "3", - subjectId: "3", + authorId: 3, + subjectId: 3, subjectType: "post" } ]; @@ -554,19 +554,19 @@ const tariffs = [ const tariffOptions = [ { - id: "1", + id: 1, name: "Installation", description: "Someone will come up your house and setup the router and so on." }, { - id: "2", + id: 2, name: "Spotify Music", description: "Spotify Premium" }, { - id: "3", + id: 3, name: "HomeMatic IP Access Point", description: "Smarthome stuff." } @@ -574,72 +574,72 @@ const tariffOptions = [ const categories = [ { - id: "1", + id: 1, name: "Programming", - parentId: "0" + parentId: 0 }, { - id: "2", + id: 2, name: "Frameworks", - parentId: "1" + parentId: 1 }, { - id: "3", + id: 3, name: "Languages", - parentId: "1" + parentId: 1 }, { - id: "4", + id: 4, name: "Patterns", - parentId: "1" + parentId: 1 }, { - id: "5", + id: 5, name: "Ruby", - parentId: "3" + parentId: 3 }, { - id: "6", + id: 6, name: "JavaScript", - parentId: "3" + parentId: 3 }, { - id: "7", + id: 7, name: "PHP", - parentId: "3" + parentId: 3 }, { - id: "8", + id: 8, name: "RSpec", - parentId: "5" + parentId: 5 } ]; const tags = [ { - id: "1", + id: 1, name: "GraphQL" }, { - id: "2", + id: 2, name: "Ruby" }, { - id: "3", + id: 3, name: "JavaScript" }, { - id: "4", + id: 4, name: "Vue" } ]; @@ -680,7 +680,7 @@ function addRelations(model: typeof Model, record: any, path: Array = [] !ignoreRelation(Tag, path) && record.tags && record.tags.length > 0 && - typeof record.tags[0] === "string" + typeof record.tags[0] === "number" ) { record.tags = findMany(Tag, tags, r => record.tags.includes(r.id), path); } @@ -700,7 +700,7 @@ function addRelations(model: typeof Model, record: any, path: Array = [] !ignoreRelation(Tag, path) && record.tags && record.tags.length > 0 && - typeof record.tags[0] === "string" + typeof record.tags[0] === "number" ) { record.tags = findMany(Tag, tags, r => record.tags.includes(r.id), path); } diff --git a/test/unit/action.spec.ts b/test/unit/action.spec.ts index 8700d031..52ad225e 100644 --- a/test/unit/action.spec.ts +++ b/test/unit/action.spec.ts @@ -36,37 +36,37 @@ describe("Action", () => { // @ts-ignore await Post.fetch(1); - const record = model.getRecordWithId("1")!; + const record = model.getRecordWithId(1)!; expect(Action.addRecordToArgs({ test: 2 }, model, record)).toEqual({ post: { - id: "1", + id: 1, content: "GraphQL is so nice!", otherId: 123, published: true, title: "GraphQL", author: { - id: "1", + id: 1, name: "Charlie Brown", profile: { + id: 1, age: 8, email: "charlie@peanuts.com", - id: "1", sex: true }, - profileId: "1" + profileId: 1 }, tags: [ { - id: "1", + id: 1, name: "GraphQL" }, { - id: "2", + id: 2, name: "Ruby" } ], - authorId: "1" + authorId: 1 }, test: 2 diff --git a/test/unit/transformer.spec.ts b/test/unit/transformer.spec.ts index 8fdb1efb..492a5f47 100644 --- a/test/unit/transformer.spec.ts +++ b/test/unit/transformer.spec.ts @@ -26,19 +26,19 @@ describe("Transformer", () => { false ); expect(transformedData).toEqual({ - id: "1", + id: 1, ignoreMe: "", content: "Foo", title: "Example Video 1", otherId: 42, - authorId: "1", + authorId: 1, author: { - id: "1", + id: 1, name: "Charlie Brown", - profileId: "1", + profileId: 1, profile: { - id: "1", + id: 1, email: "charlie@peanuts.com", age: 8, sex: true @@ -62,7 +62,7 @@ describe("Transformer", () => { tariffOptions: { nodes: [ { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -78,7 +78,7 @@ describe("Transformer", () => { tariffOptions: { nodes: [ { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -94,7 +94,7 @@ describe("Transformer", () => { tariffOptions: { nodes: [ { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -113,7 +113,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -129,7 +129,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -145,7 +145,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -161,24 +161,24 @@ describe("Transformer", () => { posts: { nodes: [ { - id: "1", + id: 1, content: "example content", title: "example title", author: { - id: "15", + id: 15, name: "Charly Brown" }, - otherId: "4894.35", + otherId: 4894.35, comments: { nodes: [ { - id: "42", + id: 42, content: "Works!", author: { - id: "14", + id: 14, name: "Peppermint Patty" }, - subjectId: "1", + subjectId: 1, subjectType: "Post" } ] @@ -191,26 +191,26 @@ describe("Transformer", () => { posts: [ { $isPersisted: true, - id: "1", + id: 1, content: "example content", title: "example title", author: { $isPersisted: true, - id: "15", + id: 15, name: "Charly Brown" }, otherId: 4894.35, comments: [ { $isPersisted: true, - id: "42", + id: 42, content: "Works!", author: { $isPersisted: true, - id: "14", + id: 14, name: "Peppermint Patty" }, - subjectId: "1", + subjectId: 1, subjectType: "posts" } ] @@ -238,7 +238,7 @@ describe("Transformer", () => { tariffOptions: { nodes: [ { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -253,7 +253,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -289,7 +289,7 @@ describe("Transformer", () => { edges: [ { node: { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -309,7 +309,7 @@ describe("Transformer", () => { edges: [ { node: { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -329,7 +329,7 @@ describe("Transformer", () => { edges: [ { node: { - id: "1", + id: 1, name: "Foo Bar 1", description: "Very foo, much more bar" } @@ -350,7 +350,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -366,7 +366,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -382,7 +382,7 @@ describe("Transformer", () => { { $isPersisted: true, description: "Very foo, much more bar", - id: "1", + id: 1, name: "Foo Bar 1" } ], @@ -399,25 +399,25 @@ describe("Transformer", () => { edges: [ { node: { - id: "1", + id: 1, content: "example content", title: "example title", author: { - id: "15", + id: 15, name: "Charly Brown" }, - otherId: "4894.35", + otherId: 4894.35, comments: { edges: [ { node: { - id: "42", + id: 42, content: "Works!", author: { - id: "14", + id: 14, name: "Peppermint Patty" }, - subjectId: "1", + subjectId: 1, subjectType: "Post" } } @@ -432,26 +432,26 @@ describe("Transformer", () => { posts: [ { $isPersisted: true, - id: "1", + id: 1, content: "example content", title: "example title", author: { $isPersisted: true, - id: "15", + id: 15, name: "Charly Brown" }, otherId: 4894.35, comments: [ { $isPersisted: true, - id: "42", + id: 42, content: "Works!", author: { $isPersisted: true, - id: "14", + id: 14, name: "Peppermint Patty" }, - subjectId: "1", + subjectId: 1, subjectType: "posts" } ]