UNPKG

@apollo/client

Version:

A fully-featured caching GraphQL client.

1 lines 133 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("ts-invariant"),r=require("@wry/equality"),n=require("graphql"),i=require("zen-observable-ts");require("symbol-observable");var o=require("optimism"),s=require("@wry/context"),a=require("@wry/trie"),u=require("graphql-tag"),c=require("react");function l(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);if(e)for(var r in e)t[r]=e[r];return t.default=e,Object.freeze(t)}var h=l(r),p=f(c),d="3.8.4";function v(e){try{return e()}catch(e){}}var y=v((function(){return globalThis}))||v((function(){return window}))||v((function(){return self}))||v((function(){return global}))||v((function(){return v.constructor("return this")()})),m=new Map;function g(e){var t=m.get(e)||1;return m.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function b(e,t){void 0===t&&(t=0);var r=g("stringifyForDisplay");return JSON.stringify(e,(function(e,t){return void 0===t?r:t}),t).split(JSON.stringify(r)).join("<undefined>")}function _(t){return function(r){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];"number"==typeof r?t(S(r,n)):t.apply(void 0,e.__spreadArray([r],n,!1))}}var w=Object.assign((function(e,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];e||t.invariant(e,S(r,n))}),{debug:_(t.invariant.debug),log:_(t.invariant.log),warn:_(t.invariant.warn),error:_(t.invariant.error)});function O(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return new t.InvariantError(S(e,r))}var k=Symbol.for("ApolloErrorMessageHandler_"+d);function S(e,t){if(void 0===t&&(t=[]),e){var r=t.map((function(e){return"string"==typeof e?e:b(e,2).slice(0,1e3)}));return y[k]&&y[k](e,r)||"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:d,message:e,args:r})))}}function x(e,t){var r=e.directives;return!r||!r.length||function(e){var t=[];e&&e.length&&e.forEach((function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var r=e.arguments,n=e.name.value;w(r&&1===r.length,65,n);var i=r[0];w(i.name&&"if"===i.name.value,66,n);var o=i.value;w(o&&("Variable"===o.kind||"BooleanValue"===o.kind),67,n),t.push({directive:e,ifArgument:i})}}));return t}(r).every((function(e){var r=e.directive,n=e.ifArgument,i=!1;return"Variable"===n.value.kind?(i=t&&t[n.value.name.value],w(void 0!==i,64,r.name.value)):i=n.value.value,"skip"===r.name.value?!i:i}))}function q(e,t,r){var i=new Set(e),o=i.size;return n.visit(t,{Directive:function(e){if(i.delete(e.name.value)&&(!r||!i.size))return n.BREAK}}),r?!i.size:i.size<o}function E(e){return e&&q(["client","export"],e,!0)}var R="function"==typeof WeakMap&&"ReactNative"!==v((function(){return navigator.product})),P="function"==typeof WeakSet,Q="function"==typeof Symbol&&"function"==typeof Symbol.for,D=Q&&Symbol.asyncIterator,T="function"==typeof v((function(){return window.document.createElement})),C=v((function(){return navigator.userAgent.indexOf("jsdom")>=0}))||!1,F=T&&!C;function M(e){return null!==e&&"object"==typeof e}function I(t,r){var n=r,i=[];return t.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw O(68,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&(w(1===i.length,69,i.length),n=i[0].name.value),e.__assign(e.__assign({},t),{definitions:e.__spreadArray([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],t.definitions,!0)})}function N(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function j(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var r=e.name.value;if("function"==typeof t)return t(r);var n=t&&t[r];return w(n,70,r),n||null;default:return null}}function A(e){return{__ref:String(e)}}function L(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function V(e,t,r,n){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[t.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[t.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var i={};r.fields.map((function(e){return V(i,e.name,e.value,n)})),e[t.value]=i}else if(function(e){return"Variable"===e.kind}(r)){var o=(n||{})[r.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(r))e[t.value]=r.values.map((function(e){var r={};return V(r,t,e,n),r[t.value]}));else if(function(e){return"EnumValue"===e.kind}(r))e[t.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw O(79,t.value,r.kind);e[t.value]=null}}var z=["connection","include","skip","client","rest","export","nonreactive"],W=Object.assign((function(e,t,r){if(t&&r&&r.connection&&r.connection.key){if(r.connection.filter&&r.connection.filter.length>0){var n=r.connection.filter?r.connection.filter:[];n.sort();var i={};return n.forEach((function(e){i[e]=t[e]})),"".concat(r.connection.key,"(").concat(B(i),")")}return r.connection.key}var o=e;if(t){var s=B(t);o+="(".concat(s,")")}return r&&Object.keys(r).forEach((function(e){-1===z.indexOf(e)&&(r[e]&&Object.keys(r[e]).length?o+="@".concat(e,"(").concat(B(r[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=B;return B=e,t}}),B=function(e){return JSON.stringify(e,U)};function U(e,t){return M(t)&&!Array.isArray(t)&&(t=Object.keys(t).sort().reduce((function(e,r){return e[r]=t[r],e}),{})),t}function K(e,t){if(e.arguments&&e.arguments.length){var r={};return e.arguments.forEach((function(e){var n=e.name,i=e.value;return V(r,n,i,t)})),r}return null}function H(e){return e.alias?e.alias.value:e.name.value}function J(e,t,r){for(var n,i=0,o=t.selections;i<o.length;i++){if(G(u=o[i])){if("__typename"===u.name.value)return e[H(u)]}else n?n.push(u):n=[u]}if("string"==typeof e.__typename)return e.__typename;if(n)for(var s=0,a=n;s<a.length;s++){var u,c=J(e,j(u=a[s],r).selectionSet,r);if("string"==typeof c)return c}}function G(e){return"Field"===e.kind}function Y(e){w(e&&"Document"===e.kind,71);var t=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw O(72,e.kind);return e}));return w(t.length<=1,73,t.length),e}function X(e){return Y(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function $(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&!!e.name})).map((function(e){return e.name.value}))[0]||null}function Z(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function ee(e){var t=X(e);return w(t&&"query"===t.operation,74),t}function te(e){var t;Y(e);for(var r=0,n=e.definitions;r<n.length;r++){var i=n[r];if("OperationDefinition"===i.kind){var o=i.operation;if("query"===o||"mutation"===o||"subscription"===o)return i}"FragmentDefinition"!==i.kind||t||(t=i)}if(t)return t;throw O(78)}function re(e){var t=Object.create(null),r=e&&e.variableDefinitions;return r&&r.length&&r.forEach((function(e){e.defaultValue&&V(t,e.variable.name,e.defaultValue)})),t}function ne(e){return e}var ie=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=P?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),!1!==t.cache&&(this.stableCacheKeys=new a.Trie(R,(function(e){return{key:e}})))}return e.prototype.getCacheKey=function(e){return[e]},e.identity=function(){return new e(ne,{cache:!1})},e.split=function(t,r,n){return void 0===n&&(n=e.identity()),new e((function(e){return(t(e)?r:n).transformDocument(e)}),{cache:!1})},e.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.getStableCacheEntry(e);if(t&&t.value)return t.value;Y(e);var r=this.transform(e);return this.resultCache.add(r),t&&(t.value=r),r},e.prototype.concat=function(t){var r=this;return new e((function(e){return t.transformDocument(r.transformDocument(e))}),{cache:!1})},e.prototype.getStableCacheEntry=function(e){if(this.stableCacheKeys){var t=this.getCacheKey(e);return t?(w(Array.isArray(t),63),this.stableCacheKeys.lookupArray(t)):void 0}},e}(),oe=R?new WeakMap:void 0,se=function(e){var t;return(t=null==oe?void 0:oe.get(e))||(t=n.print(e),null==oe||oe.set(e,t)),t},ae=Array.isArray;function ue(e){return Array.isArray(e)&&e.length>0}var ce={kind:n.Kind.FIELD,name:{kind:n.Kind.NAME,value:"__typename"}};function le(e,t){return!e||e.selectionSet.selections.every((function(e){return e.kind===n.Kind.FRAGMENT_SPREAD&&le(t[e.name.value],t)}))}function fe(e){return le(X(e)||function(e){w("Document"===e.kind,75),w(e.definitions.length<=1,76);var t=e.definitions[0];return w("FragmentDefinition"===t.kind,77),t}(e),N(Z(e)))?null:e}function he(e){var t=new Map;return function(r){void 0===r&&(r=e);var n=t.get(r);return n||t.set(r,n={variables:new Set,fragmentSpreads:new Set}),n}}function pe(t,r){Y(r);for(var i=he(""),o=he(""),s=function(e){for(var t=0,r=void 0;t<e.length&&(r=e[t]);++t)if(!ae(r)){if(r.kind===n.Kind.OPERATION_DEFINITION)return i(r.name&&r.name.value);if(r.kind===n.Kind.FRAGMENT_DEFINITION)return o(r.name.value)}return null},a=0,u=r.definitions.length-1;u>=0;--u)r.definitions[u].kind===n.Kind.OPERATION_DEFINITION&&++a;var c,l,f,h=(c=t,l=new Map,f=new Map,c.forEach((function(e){e&&(e.name?l.set(e.name,e):e.test&&f.set(e.test,e))})),function(e){var t=l.get(e.name.value);return!t&&f.size&&f.forEach((function(r,n){n(e)&&(t=r)})),t}),p=function(e){return ue(e)&&e.map(h).some((function(e){return e&&e.remove}))},d=new Map,v=!1,y={enter:function(e){if(p(e.directives))return v=!0,null}},m=n.visit(r,{Field:y,InlineFragment:y,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,r,n,i){var o=s(i);o&&o.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,r,n,i){if(p(e.directives))return v=!0,null;var o=s(i);o&&o.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,r,n){d.set(JSON.stringify(n),e)},leave:function(e,t,r,i){return e===d.get(JSON.stringify(i))?e:a>0&&e.selectionSet.selections.every((function(e){return e.kind===n.Kind.FIELD&&"__typename"===e.name.value}))?(o(e.name.value).removed=!0,v=!0,null):void 0}},Directive:{leave:function(e){if(h(e))return v=!0,null}}});if(!v)return r;var g=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach((function(t){g(o(t)).transitiveVars.forEach((function(t){e.transitiveVars.add(t)}))}))),e},b=new Set;m.definitions.forEach((function(e){e.kind===n.Kind.OPERATION_DEFINITION?g(i(e.name&&e.name.value)).fragmentSpreads.forEach((function(e){b.add(e)})):e.kind!==n.Kind.FRAGMENT_DEFINITION||0!==a||o(e.name.value).removed||b.add(e.name.value)})),b.forEach((function(e){g(o(e)).fragmentSpreads.forEach((function(e){b.add(e)}))}));var _={enter:function(e){if(t=e.name.value,!b.has(t)||o(t).removed)return null;var t}};return fe(n.visit(m,{FragmentSpread:_,FragmentDefinition:_,OperationDefinition:{leave:function(t){if(t.variableDefinitions){var r=g(i(t.name&&t.name.value)).transitiveVars;if(r.size<t.variableDefinitions.length)return e.__assign(e.__assign({},t),{variableDefinitions:t.variableDefinitions.filter((function(e){return r.has(e.variable.name.value)}))})}}}}))}var de=Object.assign((function(t){return n.visit(t,{SelectionSet:{enter:function(t,r,i){if(!i||i.kind!==n.Kind.OPERATION_DEFINITION){var o=t.selections;if(o)if(!o.some((function(e){return G(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var s=i;if(!(G(s)&&s.directives&&s.directives.some((function(e){return"export"===e.name.value}))))return e.__assign(e.__assign({},t),{selections:e.__spreadArray(e.__spreadArray([],o,!0),[ce],!1)})}}}}})}),{added:function(e){return e===ce}});function ve(t){return"query"===te(t).operation?t:n.visit(t,{OperationDefinition:{enter:function(t){return e.__assign(e.__assign({},t),{operation:"query"})}}})}function ye(e){return Y(e),pe([{test:function(e){return"client"===e.name.value},remove:!0}],e)}var me=Object.prototype.hasOwnProperty;function ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return be(e)}function be(e){var t=e[0]||{},r=e.length;if(r>1)for(var n=new we,i=1;i<r;++i)t=n.merge(t,e[i]);return t}var _e=function(e,t,r){return this.merge(e[r],t[r])},we=function(){function t(e){void 0===e&&(e=_e),this.reconciler=e,this.isObject=M,this.pastCopies=new Set}return t.prototype.merge=function(t,r){for(var n=this,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];return M(r)&&M(t)?(Object.keys(r).forEach((function(o){if(me.call(t,o)){var s=t[o];if(r[o]!==s){var a=n.reconciler.apply(n,e.__spreadArray([t,r,o],i,!1));a!==s&&((t=n.shallowCopyForMerge(t))[o]=a)}}else(t=n.shallowCopyForMerge(t))[o]=r[o]})),t):r},t.prototype.shallowCopyForMerge=function(t){return M(t)&&(this.pastCopies.has(t)||(t=Array.isArray(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t),this.pastCopies.add(t))),t},t}();function Oe(e){var t=Promise.resolve(e);return t.status="fulfilled",t.value=e,t}var ke=Object.prototype.toString;function Se(e){return xe(e)}function xe(e,t){switch(ke.call(e)){case"[object Array]":if((t=t||new Map).has(e))return t.get(e);var r=e.slice(0);return t.set(e,r),r.forEach((function(e,n){r[n]=xe(e,t)})),r;case"[object Object]":if((t=t||new Map).has(e))return t.get(e);var n=Object.create(Object.getPrototypeOf(e));return t.set(e,n),Object.keys(e).forEach((function(r){n[r]=xe(e[r],t)})),n;default:return e}}function qe(e,t,r){var n=[];e.forEach((function(e){return e[t]&&n.push(e)})),n.forEach((function(e){return e[t](r)}))}function Ee(e,t,r){return new i.Observable((function(n){var i=n.next,o=n.error,s=n.complete,a=0,u=!1,c={then:function(e){return new Promise((function(t){return t(e())}))}};function l(e,t){return e?function(t){++a;var r=function(){return e(t)};c=c.then(r,r).then((function(e){--a,i&&i.call(n,e),u&&f.complete()}),(function(e){throw--a,e})).catch((function(e){o&&o.call(n,e)}))}:function(e){return t&&t.call(n,e)}}var f={next:l(t,i),error:l(r,o),complete:function(){u=!0,a||s&&s.call(n)}},h=e.subscribe(f);return function(){return h.unsubscribe()}}))}function Re(e){function t(t){Object.defineProperty(e,t,{value:i.Observable})}return Q&&Symbol.species&&t(Symbol.species),t("@@species"),e}function Pe(e){return e&&"function"==typeof e.then}var Qe=function(t){function r(e){var r=t.call(this,(function(e){return r.addObserver(e),function(){return r.removeObserver(e)}}))||this;return r.observers=new Set,r.promise=new Promise((function(e,t){r.resolve=e,r.reject=t})),r.handlers={next:function(e){null!==r.sub&&(r.latest=["next",e],r.notify("next",e),qe(r.observers,"next",e))},error:function(e){var t=r.sub;null!==t&&(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest=["error",e],r.reject(e),r.notify("error",e),qe(r.observers,"error",e))},complete:function(){var e=r,t=e.sub,n=e.sources;if(null!==t){var i=(void 0===n?[]:n).shift();i?Pe(i)?i.then((function(e){return r.sub=e.subscribe(r.handlers)})):r.sub=i.subscribe(r.handlers):(t&&setTimeout((function(){return t.unsubscribe()})),r.sub=null,r.latest&&"next"===r.latest[0]?r.resolve(r.latest[1]):r.resolve(),r.notify("complete"),qe(r.observers,"complete"))}}},r.nextResultListeners=new Set,r.cancel=function(e){r.reject(e),r.sources=[],r.handlers.complete()},r.promise.catch((function(e){})),"function"==typeof e&&(e=[new i.Observable(e)]),Pe(e)?e.then((function(e){return r.start(e)}),r.handlers.error):r.start(e),r}return e.__extends(r,t),r.prototype.start=function(e){void 0===this.sub&&(this.sources=Array.from(e),this.handlers.complete())},r.prototype.deliverLastMessage=function(e){if(this.latest){var t=this.latest[0],r=e[t];r&&r.call(e,this.latest[1]),null===this.sub&&"next"===t&&e.complete&&e.complete()}},r.prototype.addObserver=function(e){this.observers.has(e)||(this.deliverLastMessage(e),this.observers.add(e))},r.prototype.removeObserver=function(e){this.observers.delete(e)&&this.observers.size<1&&this.handlers.complete()},r.prototype.notify=function(e,t){var r=this.nextResultListeners;r.size&&(this.nextResultListeners=new Set,r.forEach((function(r){return r(e,t)})))},r.prototype.beforeNext=function(e){var t=!1;this.nextResultListeners.add((function(r,n){t||(t=!0,e(r,n))}))},r}(i.Observable);function De(e){return"incremental"in e}function Te(e){return M(e)&&"payload"in e}function Ce(e,t){var r=e,n=new we;return De(t)&&ue(t.incremental)&&t.incremental.forEach((function(e){for(var t=e.data,i=e.path,o=i.length-1;o>=0;--o){var s=i[o],a=!isNaN(+s)?[]:{};a[s]=t,t=a}r=n.merge(r,t)})),r}function Fe(e){return ue(Me(e))}function Me(e){var t=ue(e.errors)?e.errors.slice(0):[];return De(e)&&ue(e.incremental)&&e.incremental.forEach((function(e){e.errors&&t.push.apply(t,e.errors)})),t}function Ie(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Object.create(null);return e.forEach((function(e){e&&Object.keys(e).forEach((function(t){var n=e[t];void 0!==n&&(r[t]=n)}))})),r}function Ne(t,r){return Ie(t,r,r.variables&&{variables:Ie(e.__assign(e.__assign({},t&&t.variables),r.variables))})}function je(e){return new i.Observable((function(t){t.error(e)}))}Re(Qe);var Ae=function(e,t,r){var n=new Error(r);throw n.name="ServerError",n.response=e,n.statusCode=e.status,n.result=t,n};function Le(e,t){return t?t(e):i.Observable.of()}function Ve(e){return"function"==typeof e?new We(e):e}function ze(e){return e.request.length<=1}var We=function(){function t(e){e&&(this.request=e)}return t.empty=function(){return new t((function(){return i.Observable.of()}))},t.from=function(e){return 0===e.length?t.empty():e.map(Ve).reduce((function(e,t){return e.concat(t)}))},t.split=function(e,r,n){var o=Ve(r),s=Ve(n||new t(Le));return ze(o)&&ze(s)?new t((function(t){return e(t)?o.request(t)||i.Observable.of():s.request(t)||i.Observable.of()})):new t((function(t,r){return e(t)?o.request(t,r)||i.Observable.of():s.request(t,r)||i.Observable.of()}))},t.execute=function(t,r){return t.request(function(t,r){var n=e.__assign({},t);return Object.defineProperty(r,"setContext",{enumerable:!1,value:function(t){n="function"==typeof t?e.__assign(e.__assign({},n),t(n)):e.__assign(e.__assign({},n),t)}}),Object.defineProperty(r,"getContext",{enumerable:!1,value:function(){return e.__assign({},n)}}),r}(r.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!=typeof t.query?$(t.query)||void 0:""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];if(t.indexOf(i)<0)throw O(41,i)}return e}(r))))||i.Observable.of()},t.concat=function(e,r){var n=Ve(e);if(ze(n))return n;var o=Ve(r);return ze(o)?new t((function(e){return n.request(e,(function(e){return o.request(e)||i.Observable.of()}))||i.Observable.of()})):new t((function(e,t){return n.request(e,(function(e){return o.request(e,t)||i.Observable.of()}))||i.Observable.of()}))},t.prototype.split=function(e,r,n){return this.concat(t.split(e,r,n||new t(Le)))},t.prototype.concat=function(e){return t.concat(this,e)},t.prototype.request=function(e,t){throw O(34)},t.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},t.prototype.setOnError=function(e){return this.onError=e,this},t}(),Be=We.empty,Ue=We.from,Ke=We.split,He=We.concat,Je=We.execute;function Ge(e){var t=null,r=null,n=!1,i=[],o=[];function s(e){if(!r){if(o.length){var t=o.shift();if(Array.isArray(t)&&t[0])return t[0]({value:e,done:!1})}i.push(e)}}function a(e){r=e,o.slice().forEach((function(t){t[1](e)})),!t||t()}function u(){n=!0,o.slice().forEach((function(e){e[0]({value:void 0,done:!0})})),!t||t()}t=function(){t=null,e.removeListener("data",s),e.removeListener("error",a),e.removeListener("end",u),e.removeListener("finish",u),e.removeListener("close",u)},e.on("data",s),e.on("error",a),e.on("end",u),e.on("finish",u),e.on("close",u);var c={next:function(){return new Promise((function(e,t){return r?t(r):i.length?e({value:i.shift(),done:!1}):n?e({value:void 0,done:!0}):void o.push([e,t])}))}};return D&&(c[Symbol.asyncIterator]=function(){return this}),c}function Ye(e){var t={next:function(){return e.read()}};return D&&(t[Symbol.asyncIterator]=function(){return this}),t}function Xe(e){var t,r,n=e;if(e.body&&(n=e.body),function(e){return!(!D||!e[Symbol.asyncIterator])}(n))return r=n[Symbol.asyncIterator](),(t={next:function(){return r.next()}})[Symbol.asyncIterator]=function(){return this},t;if(function(e){return!!e.getReader}(n))return Ye(n.getReader());if(function(e){return!!e.stream}(n))return Ye(n.stream().getReader());if(function(e){return!!e.arrayBuffer}(n))return function(e){var t=!1,r={next:function(){return t?Promise.resolve({value:void 0,done:!0}):(t=!0,new Promise((function(t,r){e.then((function(e){t({value:e,done:!1})})).catch(r)})))}};return D&&(r[Symbol.asyncIterator]=function(){return this}),r}(n.arrayBuffer());if(function(e){return!!e.pipe}(n))return Ge(n);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var $e=Symbol();function Ze(e){return e.hasOwnProperty("graphQLErrors")}var et=function(t){function r(n){var i,o,s=n.graphQLErrors,a=n.protocolErrors,u=n.clientErrors,c=n.networkError,l=n.errorMessage,f=n.extraInfo,h=t.call(this,l)||this;return h.name="ApolloError",h.graphQLErrors=s||[],h.protocolErrors=a||[],h.clientErrors=u||[],h.networkError=c||null,h.message=l||(i=h,o=e.__spreadArray(e.__spreadArray(e.__spreadArray([],i.graphQLErrors,!0),i.clientErrors,!0),i.protocolErrors,!0),i.networkError&&o.push(i.networkError),o.map((function(e){return M(e)&&e.message||"Error message not found."})).join("\n")),h.extraInfo=f,h.__proto__=r.prototype,h}return e.__extends(r,t),r}(Error),tt=Object.prototype.hasOwnProperty;function rt(e){var t={};return e.split("\n").forEach((function(e){var r=e.indexOf(":");if(r>-1){var n=e.slice(0,r).trim().toLowerCase(),i=e.slice(r+1).trim();t[n]=i}})),t}function nt(e,t){if(e.status>=300){Ae(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(n){var r=n;throw r.name="ServerParseError",r.response=e,r.statusCode=e.status,r.bodyText=t,r}}function it(e){return function(t){return t.text().then((function(e){return nt(t,e)})).then((function(r){return t.status>=300&&Ae(t,r,"Response not successful: Received status code ".concat(t.status)),Array.isArray(r)||tt.call(r,"data")||tt.call(r,"errors")||Ae(t,r,"Server response was missing for query '".concat(Array.isArray(e)?e.map((function(e){return e.operationName})):e.operationName,"'.")),r}))}}var ot=function(e,t){var r;try{r=JSON.stringify(e)}catch(e){var n=O(37,t,e.message);throw n.parseError=e,n}return r},st={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},at=function(e,t){return t(e)};function ut(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var o={},s={};n.forEach((function(t){o=e.__assign(e.__assign(e.__assign({},o),t.options),{headers:e.__assign(e.__assign({},o.headers),t.headers)}),t.credentials&&(o.credentials=t.credentials),s=e.__assign(e.__assign({},s),t.http)})),o.headers&&(o.headers=function(e,t){if(!t){var r=Object.create(null);return Object.keys(Object(e)).forEach((function(t){r[t.toLowerCase()]=e[t]})),r}var n=Object.create(null);Object.keys(Object(e)).forEach((function(t){n[t.toLowerCase()]={originalName:t,value:e[t]}}));var i=Object.create(null);return Object.keys(n).forEach((function(e){i[n[e].originalName]=n[e].value})),i}(o.headers,s.preserveHeaderCase));var a=t.operationName,u=t.extensions,c=t.variables,l=t.query,f={operationName:a,variables:c};return s.includeExtensions&&(f.extensions=u),s.includeQuery&&(f.query=r(l,se)),{options:o,body:f}}var ct=function(e){if(!e&&"undefined"==typeof fetch)throw O(35)},lt=function(e,t){var r=e.getContext().uri;return r||("function"==typeof t?t(e):t||"/graphql")};function ft(e,t){var r=[],n=function(e,t){r.push("".concat(e,"=").concat(encodeURIComponent(t)))};if("query"in t&&n("query",t.query),t.operationName&&n("operationName",t.operationName),t.variables){var i=void 0;try{i=ot(t.variables,"Variables map")}catch(e){return{parseError:e}}n("variables",i)}if(t.extensions){var o=void 0;try{o=ot(t.extensions,"Extensions map")}catch(e){return{parseError:e}}n("extensions",o)}var s="",a=e,u=e.indexOf("#");-1!==u&&(s=e.substr(u),a=e.substr(0,u));var c=-1===a.indexOf("?")?"?":"&";return{newURI:a+c+r.join("&")+s}}var ht=v((function(){return fetch})),pt=function(t){void 0===t&&(t={});var r=t.uri,o=void 0===r?"/graphql":r,s=t.fetch,a=t.print,u=void 0===a?at:a,c=t.includeExtensions,l=t.preserveHeaderCase,f=t.useGETForQueries,h=t.includeUnusedVariables,p=void 0!==h&&h,d=e.__rest(t,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);var y={http:{includeExtensions:c,preserveHeaderCase:l},options:d.fetchOptions,credentials:d.credentials,headers:d.headers};return new We((function(t){var r=lt(t,o),a=t.getContext(),c={};if(a.clientAwareness){var l=a.clientAwareness,h=l.name,d=l.version;h&&(c["apollographql-client-name"]=h),d&&(c["apollographql-client-version"]=d)}var m=e.__assign(e.__assign({},c),a.headers),g={http:a.http,options:a.fetchOptions,credentials:a.credentials,headers:m};if(q(["client"],t.query)){var b=ye(t.query);if(!b)return je(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));t.query=b}var _,w,O,k,S,x=ut(t,u,st,y,g),E=x.options,R=x.body;R.variables&&!p&&(R.variables=(_=R.variables,w=t.query,O=e.__assign({},_),k=new Set(Object.keys(_)),n.visit(w,{Variable:function(e,t,r){r&&"VariableDefinition"!==r.kind&&k.delete(e.name.value)}}),k.forEach((function(e){delete O[e]})),O)),E.signal||"undefined"==typeof AbortController||(S=new AbortController,E.signal=S.signal);var P,Q="OperationDefinition"===(P=te(t.query)).kind&&"subscription"===P.operation,D=q(["defer"],t.query);if(f&&!t.query.definitions.some((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation}))&&(E.method="GET"),D||Q){E.headers=E.headers||{};var T="multipart/mixed;";Q?T+="boundary=graphql;subscriptionSpec=1.0,application/json":D&&(T+="deferSpec=20220824,application/json"),E.headers.accept=T}if("GET"===E.method){var C=ft(r,R),F=C.newURI,M=C.parseError;if(M)return je(M);r=F}else try{E.body=ot(R,"Payload")}catch(M){return je(M)}return new i.Observable((function(n){var i=s||v((function(){return fetch}))||ht,o=n.next.bind(n);return i(r,E).then((function(r){var n;t.setContext({response:r});var i=null===(n=r.headers)||void 0===n?void 0:n.get("content-type");return null!==i&&/^multipart\/mixed/i.test(i)?function(t,r){var n;return e.__awaiter(this,void 0,void 0,(function(){var i,o,s,a,u,c,l,f,h,p,d,v,y,m,g,b,_,w,O,k,S,x,q;return e.__generator(this,(function(E){switch(E.label){case 0:if(void 0===TextDecoder)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");i=new TextDecoder("utf-8"),o=null===(n=t.headers)||void 0===n?void 0:n.get("content-type"),s="boundary=",a=(null==o?void 0:o.includes(s))?null==o?void 0:o.substring((null==o?void 0:o.indexOf(s))+9).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",u="\r\n--".concat(a),c="",l=Xe(t),f=!0,E.label=1;case 1:return f?[4,l.next()]:[3,3];case 2:for(h=E.sent(),p=h.value,d=h.done,v="string"==typeof p?p:i.decode(p),y=c.length-u.length+1,f=!d,m=(c+=v).indexOf(u,y);m>-1;){if(g=void 0,x=[c.slice(0,m),c.slice(m+u.length)],c=x[1],b=(g=x[0]).indexOf("\r\n\r\n"),_=rt(g.slice(0,b)),(w=_["content-type"])&&-1===w.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(O=g.slice(b))if(k=nt(t,O),Object.keys(k).length>1||"data"in k||"incremental"in k||"errors"in k||"payload"in k)Te(k)?(S={},"payload"in k&&(S=e.__assign({},k.payload)),"errors"in k&&(S=e.__assign(e.__assign({},S),{extensions:e.__assign(e.__assign({},"extensions"in S?S.extensions:null),(q={},q[$e]=k.errors,q))})),r(S)):r(k);else if(1===Object.keys(k).length&&"hasNext"in k&&!k.hasNext)return[2];m=c.indexOf(u)}return[3,1];case 3:return[2]}}))}))}(r,o):it(t)(r).then(o)})).then((function(){S=void 0,n.complete()})).catch((function(e){S=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)})),function(){S&&S.abort()}}))}))},dt=function(t){function r(e){void 0===e&&(e={});var r=t.call(this,pt(e).request)||this;return r.options=e,r}return e.__extends(r,t),r}(We),vt=function(){function t(){this.assumeImmutableResults=!1,this.getFragmentDoc=o.wrap(I)}return t.prototype.batch=function(e){var t,r=this,n="string"==typeof e.optimistic?e.optimistic:!1===e.optimistic?null:void 0;return this.performTransaction((function(){return t=e.update(r)}),n),t},t.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},t.prototype.transformDocument=function(e){return e},t.prototype.transformForLink=function(e){return e},t.prototype.identify=function(e){},t.prototype.gc=function(){return[]},t.prototype.modify=function(e){return!1},t.prototype.readQuery=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{rootId:t.id||"ROOT_QUERY",optimistic:r}))},t.prototype.readFragment=function(t,r){return void 0===r&&(r=!!t.optimistic),this.read(e.__assign(e.__assign({},t),{query:this.getFragmentDoc(t.fragment,t.fragmentName),rootId:t.id,optimistic:r}))},t.prototype.writeQuery=function(t){var r=t.id,n=t.data,i=e.__rest(t,["id","data"]);return this.write(Object.assign(i,{dataId:r||"ROOT_QUERY",result:n}))},t.prototype.writeFragment=function(t){var r=t.id,n=t.data,i=t.fragment,o=t.fragmentName,s=e.__rest(t,["id","data","fragment","fragmentName"]);return this.write(Object.assign(s,{query:this.getFragmentDoc(i,o),dataId:r,result:n}))},t.prototype.updateQuery=function(t,r){return this.batch({update:function(n){var i=n.readQuery(t),o=r(i);return null==o?i:(n.writeQuery(e.__assign(e.__assign({},t),{data:o})),o)}})},t.prototype.updateFragment=function(t,r){return this.batch({update:function(n){var i=n.readFragment(t),o=r(i);return null==o?i:(n.writeFragment(e.__assign(e.__assign({},t),{data:o})),o)}})},t}();exports.Cache=void 0,exports.Cache||(exports.Cache={});var yt=function(t){function r(e,n,i,o){var s,a=t.call(this,e)||this;if(a.message=e,a.path=n,a.query=i,a.variables=o,Array.isArray(a.path)){a.missing=a.message;for(var u=a.path.length-1;u>=0;--u)a.missing=((s={})[a.path[u]]=a.missing,s)}else a.missing=a.path;return a.__proto__=r.prototype,a}return e.__extends(r,t),r}(Error),mt=Object.prototype.hasOwnProperty;function gt(e){return null==e}function bt(e,t){var r=e.__typename,n=e.id,i=e._id;if("string"==typeof r&&(t&&(t.keyObject=gt(n)?gt(i)?void 0:{_id:i}:{id:n}),gt(n)&&!gt(i)&&(n=i),!gt(n)))return"".concat(r,":").concat("number"==typeof n||"string"==typeof n?n:JSON.stringify(n))}var _t={dataIdFromObject:bt,addTypename:!0,resultCaching:!0,canonizeResults:!1};function wt(e){var t=e.canonizeResults;return void 0===t?_t.canonizeResults:t}var Ot=/^[_a-z][_0-9a-z]*/i;function kt(e){var t=e.match(Ot);return t?t[0]:e}function St(e,t,r){return!!M(t)&&(ae(t)?t.every((function(t){return St(e,t,r)})):e.selections.every((function(e){if(G(e)&&x(e,r)){var n=H(e);return mt.call(t,n)&&(!e.selectionSet||St(e.selectionSet,t[n],r))}return!0})))}function xt(e){return M(e)&&!L(e)&&!ae(e)}function qt(e,t){var r=N(Z(e));return{fragmentMap:r,lookupFragment:function(e){var n=r[e];return!n&&t&&(n=t.lookup(e)),n||null}}}var Et=Object.create(null),Rt=function(){return Et},Pt=Object.create(null),Qt=function(){function t(e,t){var r=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return L(e)?r.get(e.__ref,t):e&&e[t]},this.canRead=function(e){return L(e)?r.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return A(e);if(L(e))return e;var n=r.policies.identify(e)[0];if(n){var i=A(n);return t&&r.merge(n,e),i}}}return t.prototype.toObject=function(){return e.__assign({},this.data)},t.prototype.has=function(e){return void 0!==this.lookup(e,!0)},t.prototype.get=function(e,t){if(this.group.depend(e,t),mt.call(this.data,e)){var r=this.data[e];if(r&&mt.call(r,t))return r[t]}return"__typename"===t&&mt.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof Ft?this.parent.get(e,t):void 0},t.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),mt.call(this.data,e)?this.data[e]:this instanceof Ft?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},t.prototype.merge=function(e,t){var r,n=this;L(e)&&(e=e.__ref),L(t)&&(t=t.__ref);var i="string"==typeof e?this.lookup(r=e):e,o="string"==typeof t?this.lookup(r=t):t;if(o){w("string"==typeof r,1);var s=new we(It).merge(i,o);if(this.data[r]=s,s!==i&&(delete this.refs[r],this.group.caching)){var a=Object.create(null);i||(a.__exists=1),Object.keys(o).forEach((function(e){if(!i||i[e]!==s[e]){a[e]=1;var t=kt(e);t===e||n.policies.hasKeyArgs(s.__typename,t)||(a[t]=1),void 0!==s[e]||n instanceof Ft||delete s[e]}})),!a.__typename||i&&i.__typename||this.policies.rootTypenamesById[r]!==s.__typename||delete a.__typename,Object.keys(a).forEach((function(e){return n.group.dirty(r,e)}))}}},t.prototype.modify=function(t,r){var n=this,i=this.lookup(t);if(i){var o=Object.create(null),s=!1,a=!0,u={DELETE:Et,INVALIDATE:Pt,isReference:L,toReference:this.toReference,canRead:this.canRead,readField:function(e,r){return n.policies.readField("string"==typeof e?{fieldName:e,from:r||A(t)}:e,{store:n})}};if(Object.keys(i).forEach((function(c){var l=kt(c),f=i[c];if(void 0!==f){var h="function"==typeof r?r:r[c]||r[l];if(h){var p=h===Rt?Et:h(f,e.__assign(e.__assign({},u),{fieldName:l,storeFieldName:c,storage:n.getStorage(t,c)}));p===Pt?n.group.dirty(t,c):(p===Et&&(p=void 0),p!==f&&(o[c]=p,s=!0,f=p))}void 0!==f&&(a=!1)}})),s)return this.merge(t,o),a&&(this instanceof Ft?this.data[t]=void 0:delete this.data[t],this.group.dirty(t,"__exists")),!0}return!1},t.prototype.delete=function(e,t,r){var n,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),s=t&&r?this.policies.getStoreFieldName({typename:o,fieldName:t,args:r}):t;return this.modify(e,s?((n={})[s]=Rt,n):Rt)}return!1},t.prototype.evict=function(e,t){var r=!1;return e.id&&(mt.call(this.data,e.id)&&(r=this.delete(e.id,e.fieldName,e.args)),this instanceof Ft&&this!==t&&(r=this.parent.evict(e,t)||r),(e.fieldName||r)&&this.group.dirty(e.id,e.fieldName||"__exists")),r},t.prototype.clear=function(){this.replace(null)},t.prototype.extract=function(){var e=this,t=this.toObject(),r=[];return this.getRootIdSet().forEach((function(t){mt.call(e.policies.rootTypenamesById,t)||r.push(t)})),r.length&&(t.__META={extraRootIds:r.sort()}),t},t.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&mt.call(t,e)||r.delete(e)})),t){var n=t.__META,i=e.__rest(t,["__META"]);Object.keys(i).forEach((function(e){r.merge(e,i[e])})),n&&n.extraRootIds.forEach(this.retain,this)}},t.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},t.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},t.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Ft?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},t.prototype.gc=function(){var e=this,t=this.getRootIdSet(),r=this.toObject();t.forEach((function(n){mt.call(r,n)&&(Object.keys(e.findChildRefIds(n)).forEach(t.add,t),delete r[n])}));var n=Object.keys(r);if(n.length){for(var i=this;i instanceof Ft;)i=i.parent;n.forEach((function(e){return i.delete(e)}))}return n},t.prototype.findChildRefIds=function(e){if(!mt.call(this.refs,e)){var t=this.refs[e]=Object.create(null),r=this.data[e];if(!r)return t;var n=new Set([r]);n.forEach((function(e){L(e)&&(t[e.__ref]=!0),M(e)&&Object.keys(e).forEach((function(t){var r=e[t];M(r)&&n.add(r)}))}))}return this.refs[e]},t.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},t}(),Dt=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?o.dep():null,this.keyMaker=new a.Trie(R)},e.prototype.depend=function(e,t){if(this.d){this.d(Tt(e,t));var r=kt(t);r!==t&&this.d(Tt(e,r)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(Tt(e,t),"__exists"===t?"forget":"setDirty")},e}();function Tt(e,t){return t+"#"+e}function Ct(e,t){Nt(e)&&e.group.depend(t,"__exists")}!function(t){var r=function(t){function r(e){var r=e.policies,n=e.resultCaching,i=void 0===n||n,o=e.seed,s=t.call(this,r,new Dt(i))||this;return s.stump=new Mt(s),s.storageTrie=new a.Trie(R),o&&s.replace(o),s}return e.__extends(r,t),r.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},r.prototype.removeLayer=function(){return this},r.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},r}(t);t.Root=r}(Qt||(Qt={}));var Ft=function(t){function n(e,r,n,i){var o=t.call(this,r.policies,i)||this;return o.id=e,o.parent=r,o.replay=n,o.group=i,n(o),o}return e.__extends(n,t),n.prototype.addLayer=function(e,t){return new n(e,this,t,this.group)},n.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(e){var i=t.data[e],o=n.lookup(e);o?i?i!==o&&Object.keys(i).forEach((function(n){r.equal(i[n],o[n])||t.group.dirty(e,n)})):(t.group.dirty(e,"__exists"),Object.keys(o).forEach((function(r){t.group.dirty(e,r)}))):t.delete(e)})),n):n===this.parent?this:n.addLayer(this.id,this.replay)},n.prototype.toObject=function(){return e.__assign(e.__assign({},this.parent.toObject()),this.data)},n.prototype.findChildRefIds=function(r){var n=this.parent.findChildRefIds(r);return mt.call(this.data,r)?e.__assign(e.__assign({},n),t.prototype.findChildRefIds.call(this,r)):n},n.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},n}(Qt),Mt=function(t){function r(e){return t.call(this,"EntityStore.Stump",e,(function(){}),new Dt(e.group.caching,e.group))||this}return e.__extends(r,t),r.prototype.removeLayer=function(){return this},r.prototype.merge=function(){return this.parent.merge.apply(this.parent,arguments)},r}(Ft);function It(e,t,n){var i=e[n],o=t[n];return r.equal(i,o)?i:o}function Nt(e){return!!(e instanceof Qt&&e.group.caching)}var jt,At,Lt=function(){function t(){this.known=new(P?WeakSet:Set),this.pool=new a.Trie(R),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return t.prototype.isKnown=function(e){return M(e)&&this.known.has(e)},t.prototype.pass=function(t){if(M(t)){var r=function(t){return M(t)?ae(t)?t.slice(0):e.__assign({__proto__:Object.getPrototypeOf(t)},t):t}(t);return this.passes.set(r,t),r}return t},t.prototype.admit=function(e){var t=this;if(M(e)){var r=this.passes.get(e);if(r)return r;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var n=e.map(this.admit,this);return(a=this.pool.lookupArray(n)).array||this.known.add(a.array=n),a.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],s=this.sortedKeys(e);o.push(s.json);var a,u=o.length;if(s.sorted.forEach((function(r){o.push(t.admit(e[r]))})),!(a=this.pool.lookupArray(o)).object){var c=a.object=Object.create(i);this.known.add(c),s.sorted.forEach((function(e,t){c[e]=o[u+t]}))}return a.object}}return e},t.prototype.sortedKeys=function(e){var t=Object.keys(e),r=this.pool.lookupArray(t);if(!r.keys){t.sort();var n=JSON.stringify(t);(r.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,r.keys={sorted:t,json:n})}return r.keys},t}(),Vt=Object.assign((function(e){if(M(e)){void 0===jt&&zt();var t=jt.admit(e),r=At.get(t);return void 0===r&&At.set(t,r=JSON.stringify(t)),r}return JSON.stringify(e)}),{reset:zt});function zt(){jt=new Lt,At=new(R?WeakMap:Map)}function Wt(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var Bt=function(){function t(t){var r=this;this.knownResults=new(R?WeakMap:Map),this.config=Ie(t,{addTypename:!1!==t.addTypename,canonizeResults:wt(t)}),this.canon=t.canon||new Lt,this.executeSelectionSet=o.wrap((function(t){var n,i=t.context.canonizeResults,o=Wt(t);o[3]=!i;var s=(n=r.executeSelectionSet).peek.apply(n,o);return s?i?e.__assign(e.__assign({},s),{result:r.canon.admit(s.result)}):s:(Ct(t.context.store,t.enclosingRef.__ref),r.execSelectionSetImpl(t))}),{max:this.config.resultCacheMaxSize,keyArgs:Wt,makeCacheKey:function(e,t,r,n){if(Nt(r.store))return r.store.makeCacheKey(e,L(t)?t.__ref:t,r.varString,n)}}),this.executeSubSelectedArray=o.wrap((function(e){return Ct(e.context.store,e.enclosingRef.__ref),r.execSubSelectedArrayImpl(e)}),{max:this.config.resultCacheMaxSize,makeCacheKey:function(e){var t=e.field,r=e.array,n=e.context;if(Nt(n.store))return n.store.makeCacheKey(t,r,n.varString)}})}return t.prototype.resetCanon=function(){this.canon=new Lt},t.prototype.diffQueryAgainstStore=function(t){var r=t.store,n=t.query,i=t.rootId,o=void 0===i?"ROOT_QUERY":i,s=t.variables,a=t.returnPartialData,u=void 0===a||a,c=t.canonizeResults,l=void 0===c?this.config.canonizeResults:c,f=this.config.cache.policies;s=e.__assign(e.__assign({},re(ee(n))),s);var h,p=A(o),d=this.executeSelectionSet({selectionSet:te(n).selectionSet,objectOrReference:p,enclosingRef:p,context:e.__assign({store:r,query:n,policies:f,variables:s,varString:Vt(s),canonizeResults:l},qt(n,this.config.fragments))});if(d.missing&&(h=[new yt(Ut(d.missing),d.missing,n,s)],!u))throw h[0];return{result:d.result,complete:!h,missing:h}},t.prototype.isFresh=function(e,t,r,n){if(Nt(n.store)&&this.knownResults.get(e)===r){var i=this.executeSelectionSet.peek(r,t,n,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},t.prototype.execSelectionSetImpl=function(e){var t=this,r=e.selectionSet,i=e.objectOrReference,o=e.enclosingRef,s=e.context;if(L(i)&&!s.policies.rootTypenamesById[i.__ref]&&!s.store.has(i.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(i.__ref," object")};var a,u=s.variables,c=s.policies,l=s.store.getFieldValue(i,"__typename"),f=[],h=new we;function p(e,t){var r;return e.missing&&(a=h.merge(a,((r={})[t]=e.missing,r))),e.result}this.config.addTypename&&"string"==typeof l&&!c.rootIdsByTypename[l]&&f.push({__typename:l});var d=new Set(r.selections);d.forEach((function(e){var r,v;if(x(e,u))if(G(e)){var y=c.readField({fieldName:e.name.value,field:e,variables:s.variables,from:i},s),m=H(e);void 0===y?de.added(e)||(a=h.merge(a,((r={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(L(i)?i.__ref+" object":"object "+JSON.stringify(i,null,2)),r))):ae(y)?y=p(t.executeSubSelectedArray({field:e,array:y,enclosingRef:o,context:s}),m):e.selectionSet?null!=y&&(y=p(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:y,enclosingRef:L(y)?y:o,context:s}),m)):s.canonizeResults&&(y=t.canon.pass(y)),void 0!==y&&f.push(((v={})[m]=y,v))}else{var g=j(e,s.lookupFragment);if(!g&&e.kind===n.Kind.FRAGMENT_SPREAD)throw O(7,e.name.value);g&&c.fragmentMatches(g,l)&&g.selectionSet.selections.forEach(d.add,d)}}));var v={result:be(f),missing:a},y=s.canonizeResults?this.canon.admit(v):v;return y.result&&this.knownResults.set(y.result,r),y},t.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,i=e.array,o=e.enclosingRef,s=e.context,a=new we;function u(e,r){var n;return e.missing&&(t=a.merge(t,((n={})[r]=e.missing,n))),e.result}return n.selectionSet&&(i=i.filter(s.store.canRead)),i=i.map((function(e,t){return null===e?null:ae(e)?u(r.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:s}),t):n.selectionSet?u(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:L(e)?e:o,context:s}),t):e})),{result:s.canonizeResults?this.canon.admit(i):i,missing:t}},t}();function Ut(e){try{JSON.stringify(e,(function(e,t){if("string"==typeof t)throw t;return t}))}catch(e){return e}}var Kt=new s.Slot,Ht=new WeakMap;function Jt(e){var t=Ht.get(e);return t||Ht.set(e,t={vars:new Set,dep:o.dep()}),t}function Gt(e){Jt(e).vars.forEach((function(t){return t.forgetCache(e)}))}function Yt(e){var t=new Set,r=new Set,n=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach((function(e){Jt(e).dep.dirty(n),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)}));var s=Array.from(r);r.clear(),s.forEach((function(t){return t(e)}))}}else{var a=Kt.getValue();a&&(i(a),Jt(a).dep(n))}return e};n.onNextChange=function(e){return r.add(e),function(){r.delete(e)}};var i=n.attachCache=function(e){return t.add(e),Jt(e).vars.add(n),n};return n.forgetCache=function(e){return t.delete(e)},n}var Xt=Object.create(null);function $t(e){var t=JSON.stringify(e);return Xt[t]||(Xt[t]=Object.create(null))}function Zt(e){var t=$t(e);return t.keyFieldsFn||(t.keyFieldsFn=function(t,r){var n=function(e,t){return r.readField(t,e)},i=r.keyObject=tr(e,(function(e){var i=ir(r.storeObject,e,n);return void 0===i&&t!==r.storeObject&&mt.call(t,e[0])&&(i=ir(t,e,nr)),w(void 0!==i,2,e.join("."),t),i}));return"".concat(r.typename,":").concat(JSON.stringify(i))})}function er(e){var t=$t(e);return t.keyArgsFn||(t.keyArgsFn=function(t,r){var n=r.field,i=r.variables,o=r.fieldName,s=tr(e,(function(e){var r=e[0],o=r.charAt(0);if("@"!==o)if("$"!==o){if(t)return ir(t,e)}else{var s=r.slice(1);if(i&&mt.call(i,s)){var a=e.slice(0);return a[0]=s,ir(i,a)}}else if(n&&ue(n.directives)){var u=r.slice(1),c=n.directives.find((function(e){return e.name.value===u})),l=c&&K(c,i);return l&&ir(l,e.slice(1))}})),a=JSON.stringify(s);return(t||"{}"!==a)&&(o+=":"+a),o})}function tr(e,t){var r=new we;return rr(e).reduce((function(e,n){var i,o=t(n);if(void 0!==o){for(var s=n.length-1;s>=0;--s)(i={})[n[s]]=o,o=i;e=r.merge(e,o)}return e}),Object.create(null))}function rr(e){var t=$t(e);if(!t.paths){var r=t.paths=[],n=[];e.forEach((function(t,i){ae(t)?(rr(t).forEach((function(e){return r.push(n.concat(e))})),n.length=0):(n.push(t),ae(e[i+1])||(r.push(n.slice(0)),n.length=0))}))}return t.paths}function nr(e,t){return e[t]}function ir(e,t,r){return r=r||nr,or(t.reduce((function e(t,n){return ae(t)?t.map((function(t){return e(t,n)})):t&&r(t,n)}),e))}function or(e){return M(e)?ae(e)?e.map(or):tr(Object.keys(e).sort(),(function(t){return ir(e,t)})):e}function sr(e){return void 0!==e.args?e.args:e.field?K(e.field,e.variables):null}W.setStringify(Vt);var ar=function(){},ur=function(e,t){return t.fieldName},cr=function(e,t,r){return(0,r.mergeObjects)(e,t)},lr=function(e,t){return t},fr=function(){function t(t){this.config=t,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=e.__assign({dataIdFromObject:bt},t),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),t.possibleTypes&&this.addPossibleTypes(t.possibleTypes),t.typePolicies&&this.addTypePolicies(t.typePolicies)}return t.prototype.identify=function(t,r){var n,i=this,o=r&&(r.typename||(null===(n=r.storeObject)||void 0===n?void 0:n.__typename))||t.__typename;if(o===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var s,a=r&&r.storeObject||t,u=e.__assign(e.__assign({},r),{typename:o,storeObject:a,readField:r&&r.readField||function(){var e=pr(arguments,a);return i.readField(e,{store:i.cache.data,variables:e.variables})}}),c=o&&this.getTypePolicy(o),l=c&&c.keyFn||this.config.dataIdFromObject;l;){var f=l(e.__assign(e.__assign({},t),a),u);if(!ae(f)){s=f;break}l=Zt(f)}return s=s?String(s):void 0,u.keyObject?[s,u.keyObject]:[s]},t.prototype.addTypePolicies=function(t){var r=this;Object.keys(t).forEach((function(n){var i=t[n],o=i.queryType,s=i.mutationType,a=i.subscriptionType,u=e.__rest(i,["queryType","mutationType","subscriptionType"]);o&&r.setRootTypename("Query",n),s&&r.setRootTypename("Mutation",n),a&&r.setRootTypename("Subscription",n),mt.call(r.toBeAdded,n)?r.toBeAdded[n].push(u):r.toBeAdded[n]=[u]}))},t.prototype.updateTypePolicy=function(e,t){var r=this,n=this.getTypePolicy(e),i=t.keyFields,o=t.fields;function s(e,t){e.merge="function"==typeof t?t:!0===t?cr:!1===t?lr:e.merge}s(n,t.merge),n.keyFn=!1===i?ar:ae(i)?Zt(i):"function"==typeof i?i:n.keyFn,o&&Object.keys(o).forEach((function(t){var n=r.getFieldPolicy(e,t,!0),i=o[t];if("function"==typeof i)n.read=i;else{var a=i.keyArgs,u=i.read,c=i.merge;n.keyFn=!1===a?ur:ae(a)?er(a):"function"==typeof a?a:n.keyFn,"function"==typeof u&&(n.read=u),s(n,c)}n.read&&n.merge&&(n.keyFn=n.keyFn||ur)}))},t.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var r="ROOT_"+e.toUpperCase(),n=this.rootTypenamesById[r];t!==n&&(w(!n||n===e,3,e),n&&delete this.rootIdsByTypename[n],this.rootIdsByTypename[t]=r,this.rootTypenamesById[r]=t)},t.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach((function(r){t.getSupertypeSet(r,!0),e[r].forEach((function(e){t.getSupertypeSet(e,!0).add(r);va