text: "use strict";var e=require("wonka"),t=require("graphql/error/GraphQLError"),r=require("graphql/language/parser"),n=require("graphql/language/printer"),o=require("graphql/language/kinds"),i=require("graphql/language/visitor");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var u=function(e){return"string"==typeof e?new t.GraphQLError(e):"object"==typeof e&&e.message?new t.GraphQLError(e.message,e.nodes,e.source,e.positions,e.path,e,e.extensions||{}):e};function s(){return this.message}var c=function(e){function t(t){var r=t.networkError,n=t.response,o=function(e,t){var r="";return void 0!==e?r="[Network] "+e.message:(void 0!==t&&t.forEach((function(e){r+="[GraphQL] "+e.message+"\n"})),r.trim())}(r,t=(t.graphQLErrors||[]).map(u));e.call(this,o),this.name="CombinedError",this.message=o,this.graphQLErrors=t,this.networkError=r,this.response=n}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.toString=s,t}(Error),f=function(e,t){e|=0;for(var r=0,n=0|t.length;r<n;r++)e=(e<<5)+e+t.charCodeAt(r);return e},p=new Set,l=new WeakMap,h=function(e){if(null===e||p.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return e.toJSON();if(Array.isArray(e)){for(var t="[",r=0,n=e.length;r<n;r++){0<r&&(t+=",");var o=h(e[r]);t+=0<o.length?o:"null"}return t+"]"}if(!(t=Object.keys(e).sort()).length&&e.constructor&&e.constructor!==Object)return t=l.get(e)||Math.random().toString(36).slice(2),l.set(e,t),'{"__key":"'+t+'"}';for(p.add(e),r="{",n=0,o=t.length;n<o;n++){var i=t[n],a=h(e[i]);a&&(1<r.length&&(r+=","),r+=h(i)+":"+a)}return p.delete(e),r+"}"},y=function(e){return p.clear(),h(e)},d=function(e){return function(e){return f(5381,e)>>>0}(e.replace(/[\s,]+/g," ").trim())},v=Object.create(null),m=function(e,t){if("string"==typeof e){var o=d(e);e=void 0!==v[o]?v[o]:r.parse(e)}else void 0!==e.__key?o=e.__key:(o=d(n.print(e)),e=void 0!==v[o]?v[o]:e);return v[o]=e,e.__key=o,{key:t?f(o,y(t))>>>0:o,query:e,variables:t||{}}},x=function(e,t){return a({},e,{context:a({},e.context,{meta:a({},e.context.meta,t)})})},g=function(e,t,r){return{operation:e,data:t.data,error:Array.isArray(t.errors)?new c({graphQLErrors:t.errors,response:r}):void 0,extensions:"object"==typeof t.extensions&&t.extensions||void 0}},k=function(e,t,r){return{operation:e,data:void 0,error:new c({networkError:t,response:r}),extensions:void 0}},O=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){O(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):O(e[r],t);return t};function b(e,t,r){return r.indexOf(e)===t}var q=function(e){return O(e).filter(b)};function E(e){return e.kind===o.Kind.FIELD&&"__typename"===e.name.value}var w=function(e){if(e.selectionSet&&!e.selectionSet.selections.some(E))return e.selectionSet.selections.push({kind:o.Kind.FIELD,name:{kind:o.Kind.NAME,value:"__typename"}}),e},N=function(e){return i.visit(e,{Field:w,InlineFragment:w})},S=function(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,r){var n=e[r];return"__typename"===r?Object.defineProperty(t,"__typename",{enumerable:!1,value:n}):t[r]=Array.isArray(n)?n.map(S):n&&"object"==typeof n&&"__typename"in n?S(n):n,t}),{}):e};function _(t){return t.toPromise=function(){return e.toPromise(e.take(1)(t))},t}var j=function(e){return"subscription"!==(e=e.operationName)&&"query"!==e};function P(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var Q=function(e){return"mutation"!==(e=e.operationName)&&"query"!==e};function A(e){return a({},e,{query:N(e.query)})}function L(e){return"query"!==e.operationName||"cache-only"!==e.context.requestPolicy}function R(e){return x(e,{cacheOutcome:"miss"})}function C(e){return Q(e)}var M=function(t){function r(e){var t=c.get(e.key);return t=a({},t,{operation:x(e,{cacheOutcome:t?"hit":"miss"})}),"cache-and-network"===e.context.requestPolicy&&(t.stale=!0,I(s,e)),t}function n(e){return!Q(e)&&h(e)}function o(e){e.operation&&"mutation"===e.operation.operationName?p(e):e.operation&&"query"===e.operation.operationName&&l(e)}function i(e){return!Q(e)&&!h(e)}var u=t.forward,s=t.client,c=new Map;t=Object.create(null);var f=A,p=T(c,t,s),l=G(c,t),h=function(e){var t=e.context.requestPolicy;return"query"===e.operationName&&"network-only"!==t&&("cache-only"===t||c.has(e.key))};return function(t){var a=e.share(t);return t=e.map(r)(e.filter(n)(a)),a=e.tap(o)(u(e.filter(L)(e.map(R)(e.merge([e.map(f)(e.filter(i)(a)),e.filter(C)(a)]))))),e.merge([t,a])}},I=function(e,t){return e.reexecuteOperation(a({},t,{context:a({},t.context,{requestPolicy:"network-only"})}))},T=function(e,t,r){function n(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),I(r,n)}}return function(e){function r(e){o.add(e)}var o=new Set,i=e.operation.context.additionalTypenames;q(e.data).concat(i||[]).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),o.forEach(n)}},G=function(e,t){return function(r){var n=r.operation,o=r.data,i=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),q(r.data).concat(i||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},D=function(t){var r=t.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.operationName)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(t){return t=e.filter(o)(t),e.tap(i)(r(t))}};function $(e){return"query"===e.operationName||"mutation"===e.operationName}function F(e){return"query"!==e.operationName&&"mutation"!==e.operationName}var J=function(t){var r=t.forward;return function(t){var n=e.share(t);t=e.mergeMap((function(t){var r=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===r}))(n);return e.takeUntil(o)(K(t,"query"===t.operationName&&!!t.context.preferGetMethod))}))(e.filter($)(n));var o=r(e.filter(F)(n));return e.merge([t,o])}};function U(e){return e.kind===o.Kind.OPERATION_DEFINITION&&e.name}var K=function(t,r){return e.make((function(e){var o=e.next,i=e.complete,u="undefined"!=typeof AbortController?new AbortController:void 0;e="function"==typeof(e=t.context).fetchOptions?e.fetchOptions():e.fetchOptions||{};var s=function(e){return(e=e.definitions.find(U))?e.name.value:null}(t.query),c={query:n.print(t.query),variables:t.variables};null!==s&&(c.operationName=s);var f=a({},e,{body:r?void 0:JSON.stringify(c),method:r?"GET":"POST",headers:a({},{"content-type":"application/json"},e.headers),signal:void 0!==u?u.signal:void 0});r&&(t.context.url=W(t.context.url,c));var p=!1;return Promise.resolve().then((function(){return p?void 0:V(t,f)})).then((function(e){p||(p=!0,e&&o(e),i())})),function(){p=!0,void 0!==u&&u.abort()}}))},V=function(e,t){var r,n=e.context,o=!1;return(n.fetch||fetch)(n.url,t).then((function(e){return r=e,o=200>e.status||e.status>=("manual"===t.redirect?400:300),e.json()})).then((function(t){if(!("data"in t)&&!("errors"in t))throw Error("No Content");return g(e,t,r)})).catch((function(t){if("AbortError"!==t.name)return k(e,o?Error(r.statusText):t,r)}))},W=function(e,t){var r=["query="+encodeURIComponent(t.query)];return t.variables&&r.push("variables="+encodeURIComponent(JSON.stringify(t.variables))),e+"?"+r.join("&")};function z(){return!1}function B(e){}var H=function(t){return e.filter(z)(e.tap(B)(t))},X=function(e){return 1===e.length?e[0]:function(t){return e.reduceRight((function(e,r){return r({client:t.client,forward:e})}),t.forward)}},Y=[D,M,J],Z=function(t){var r=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(e){return a({},{url:r.url,fetchOptions:r.fetchOptions,fetch:r.fetch,preferGetMethod:r.preferGetMethod},e,{requestPolicy:(e||{}).requestPolicy||r.requestPolicy})},this.createRequestOperation=function(e,t,n){return{key:t.key,query:t.query,variables:t.variables,operationName:e,context:r.createOperationContext(n)}},this.reexecuteOperation=function(e){0<(r.activeOperations[e.key]||0)&&(r.queue.push(e),r.dispatchOperation())},this.executeQuery=function(t,n){t=r.createRequestOperation("query",t,n);var o=r.executeRequestOperation(t);return(t=t.context.pollInterval)?e.switchMap((function(){return o}))(e.merge([e.fromValue(0),e.interval(t)])):o},this.executeSubscription=function(e,t){return e=r.createRequestOperation("subscription",e,t),r.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=r.createRequestOperation("mutation",e,t),r.executeRequestOperation(e)},this.url=t.url,this.fetchOptions=t.fetchOptions,this.fetch=t.fetch,this.suspense=!!t.suspense,this.requestPolicy=t.requestPolicy||"cache-first",this.preferGetMethod=!!t.preferGetMethod,this.maskTypename=!!t.maskTypename;var n=e.makeSubject(),o=n.next;this.operations$=n.source;var i=!1;this.dispatchOperation=function(e){if(i)e&&o(e);else{for(i=!0,e&&o(e);e=r.queue.shift();)o(e);i=!1}},t=X(void 0!==t.exchanges?t.exchanges:Y),this.results$=e.share(t({client:this,forward:H})(this.operations$)),e.publish(this.results$)};function ee(e){return e.data=S(e.data),e}Z.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},Z.prototype.onOperationEnd=function(e){var t=e.key,r=this.activeOperations[t]||0;0>=(this.activeOperations[t]=0>=r?0:r-1)&&this.dispatchOperation(a({},e,{operationName:"teardown"}))},Z.prototype.executeRequestOperation=function(t){var r=this,n=t.key,o=t.operationName,i=e.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=e.map(ee)(i)),"mutation"===o)return e.take(1)(e.onStart((function(){return r.dispatchOperation(t)}))(i));var a=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(this.operations$);return i=e.onEnd((function(){r.onOperationEnd(t)}))(e.onStart((function(){r.onOperationStart(t)}))(e.takeUntil(a)(i))),!1!==t.context.suspense&&this.suspense&&"query"===o?function(t){return function(r){var n=e.share(t),o=!1,i=!1;if(e.onPush((function(){return o=!0}))(e.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),e.toPromise(e.take(1)(n))}}(i):i},Z.prototype.query=function(e,t,r){return r&&"boolean"==typeof r.suspense||(r=a({},r,{suspense:!1})),_(this.executeQuery(m(e,t),r))},Z.prototype.readQuery=function(t,r,n){var o=null;return e.subscribe((function(e){o=e}))(this.executeQuery(m(t,r),n)).unsubscribe(),o},Z.prototype.mutation=function(e,t,r){return _(this.executeMutation(m(e,t),r))},exports.Client=Z,exports.CombinedError=c,exports.cacheExchange=M,exports.composeExchanges=X,exports.createClient=function(e){return new Z(e)},exports.createRequest=m,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=D,exports.defaultExchanges=Y,exports.fallbackExchangeIO=H,exports.fetchExchange=J,exports.formatDocument=N,exports.makeErrorResult=k,exports.makeResult=g,exports.maskTypename=S,exports.ssrExchange=function(t){function r(e){return!f(e)}function n(e){return function(e,t){var r=t.error;return{operation:e,data:t.data,extensions:void 0,error:r?new c({networkError:r.networkError?Error(r.networkError):void 0,graphQLErrors:r.graphQLErrors&&r.graphQLErrors.length?r.graphQLErrors:void 0}):void 0}}(e,s[e.key])}function o(e){return f(e)}function i(e){var t=e.operation;j(t)||(e=function(e){var t=e.error;return e={data:e.data,error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(P),networkError:t.networkError?""+t.networkError:void 0}),e}(e),s[t.key]=e)}function u(e){delete s[e.operation.key]}var s={},f=function(e){return!j(e)&&void 0!==s[e.key]},p=function(a){var s=a.client,c=a.forward;return function(a){var f=t&&"boolean"==typeof t.isClient?!!t.isClient:!s.suspense,p=e.share(a);return a=c(e.filter(r)(p)),p=e.map(n)(e.filter(o)(p)),f?p=e.tap(u)(p):a=e.tap(i)(a),e.merge([a,p])}};return p.restoreData=function(e){return a(s,e)},p.extractData=function(){return a({},s)},t&&t.initialState&&p.restoreData(t.initialState),p},exports.stringifyVariables=y,exports.subscriptionExchange=function(t){function r(e){return"subscription"===(e=e.operationName)||!!i&&("query"===e||"mutation"===e)}var o=t.forwardSubscription,i=t.enableAllOperations;return function(t){function i(e){return!f(e)}var u=t.client,s=t.forward,c=function(t){var r=o({key:t.key.toString(36),query:n.print(t.query),variables:t.variables,context:a({},t.context)});return e.make((function(e){function n(e){return c(g(t,e))}function o(e){return c(k(t,e))}function i(){p||(p=!0,"subscription"===t.operationName&&u.reexecuteOperation(a({},t,{operationName:"teardown"})),f())}var s,c=e.next,f=e.complete,p=!1;return Promise.resolve().then((function(){p||(s=r.subscribe({next:n,error:o,complete:i}))})),function(){p=!0,s&&s.unsubscribe()}}))},f=r;return function(t){var r=e.share(t);t=e.mergeMap((function(t){var n=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(r);return e.takeUntil(o)(c(t))}))(e.filter(f)(r));var n=s(e.filter(i)(r));return e.merge([t,n])}}};
  //# sourceMappingURL=urql-core.min.js.map
  