UNPKG

@nguyenmv2/buy-button

Version:

BuyButton.js allows merchants to build Shopify interfaces into any website

1 lines 347 kB
var ShopifyBuy=function(){"use strict";function a(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function o(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(n,!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],a=!0,i=!1,o=void 0;try{for(var r,d=t[Symbol.iterator]();!(a=(r=d.next()).done)&&(n.push(r.value),!e||n.length!==e);a=!0);}catch(t){i=!0,o=t}finally{try{a||null==d.return||d.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function l(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t=function(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),t};function h(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function m(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.join(" ")}function y(t){return Boolean(t)&&"[object Object]"===Object.prototype.toString.call(t.valueOf())}function g(n,a){return n(a)?a:y(a)?Object.freeze(Object.keys(a).reduce(function(t,e){return t[e]=g(n,a[e]),t},{})):Array.isArray(a)?Object.freeze(a.map(function(t){return g(n,t)})):a}function b(t,e,n){var a=2<arguments.length&&void 0!==n?n:null,i=t.types[e];if(i)return i;if(a&&"INTERFACE"===a.kind)return a;throw new Error("No type of "+e+" found in schema")}function _(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var v=function(t,e,n){return e&&C(t.prototype,e),n&&C(t,n),t};function C(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":f(e)));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function x(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==(void 0===e?"undefined":f(e))&&"function"!=typeof e?t:e}var P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},w=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],a=!0,i=!1,o=void 0;try{for(var r,d=t[Symbol.iterator]();!(a=(r=d.next()).done)&&(n.push(r.value),!e||n.length!==e);a=!0);}catch(t){i=!0,o=t}finally{try{!a&&d.return&&d.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},A=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)},F=(v(I,[{key:"toInputValueString",value:function(){return"$"+this.name}},{key:"toString",value:function(){var t=this.defaultValue?" = "+D(this.defaultValue):"";return"$"+this.name+":"+this.type+t}}]),I);function I(t,e,n){_(this,I),this.name=t,this.type=e,this.defaultValue=n,Object.freeze(this)}function V(t){return F.prototype.isPrototypeOf(t)}function O(t,e,n){return new F(t,e,n)}var S=(v(E,[{key:"toString",value:function(){return this.key}},{key:"valueOf",value:function(){return this.key.valueOf()}}]),E);function E(t){_(this,E),this.key=t}var T=(v(U,[{key:"toString",value:function(){return this.value.toString()}},{key:"valueOf",value:function(){return this.value.valueOf()}},{key:"unwrapped",get:function(){return this.value}}]),U);function U(t){_(this,U),this.value=t}function D(t){return F.prototype.isPrototypeOf(t)?t.toInputValueString():S.prototype.isPrototypeOf(t)?String(t):T.prototype.isPrototypeOf(t)?JSON.stringify(t.valueOf()):Array.isArray(t)?"["+m.apply(void 0,A(t.map(D)))+"]":y(t)?N(t,"{","}"):JSON.stringify(t)}function N(e,t,n){var a=1<arguments.length&&void 0!==t?t:"",i=2<arguments.length&&void 0!==n?n:"",o=Object.keys(e).map(function(t){return t+": "+D(e[t])});return""+a+m.apply(void 0,A(o))+i}function q(){}var z=q,M=q;function B(t){var e=q,n={},a=null;if(2===t.length)if("function"==typeof t[1]){var i=w(t,2);n=i[0],e=i[1]}else{var o=w(t,2);n=o[0],a=o[1]}else 1===t.length&&($.prototype.isPrototypeOf(t[0])?a=t[0]:"function"==typeof t[0]?e=t[0]:n=t[0]);return{options:n,selectionSet:a,callback:e}}var L=Object.freeze({}),j=Object.freeze({}),R=(v(W,[{key:"toString",value:function(){return(this.alias?this.alias+": ":"")+this.name+function(t){return Object.keys(t).length?" ("+N(t)+")":""}(this.args)+function(n){if(!Object.keys(n).length)return"";var t=Object.keys(n).map(function(t){var e=n[t];return"@"+t+(e&&Object.keys(e).length?"("+N(e)+")":"")});return" "+m.apply(void 0,A(t))}(this.directives)+this.selectionSet}}]),W);function W(t,e,n){_(this,W),this.name=t,this.alias=e.alias||null,this.responseKey=this.alias||this.name,this.args=e.args?g(V,e.args):L,this.directives=e.directives?g(V,e.directives):j,this.selectionSet=n,Object.freeze(this)}var Q=function t(){_(this,t)},G=(k(H,Q),v(H,[{key:"toString",value:function(){return"... on "+this.typeName+this.selectionSet}}]),H);function H(t,e){_(this,H);var n=x(this,(H.__proto__||Object.getPrototypeOf(H)).call(this));return n.typeName=t,n.selectionSet=e,Object.freeze(n),n}var J=(k(K,Q),v(K,[{key:"toString",value:function(){return"..."+this.name}},{key:"toDefinition",value:function(){return new Y(this.name,this.selectionSet.typeSchema.name,this.selectionSet)}}]),K);function K(t){_(this,K);var e=x(this,(K.__proto__||Object.getPrototypeOf(K)).call(this));return e.name=t.name,e.selectionSet=t.selectionSet,Object.freeze(e),e}var Y=(v(X,[{key:"toString",value:function(){return"fragment "+this.name+" on "+this.typeName+" "+this.selectionSet}}]),X);function X(t,e,n){_(this,X),this.name=t,this.typeName=e,this.selectionSet=n,this.spread=new J(this),Object.freeze(this)}var $=(v(Z,[{key:"toString",value:function(){return"SCALAR"===this.typeSchema.kind||"ENUM"===this.typeSchema.kind?"":" { "+m(this.selections)+" }"}}]),Z);function Z(t,e,n){_(this,Z),this.typeSchema="string"==typeof e?b(t,e):e,z(this.typeSchema.name),this.typeBundle=t,this.selections=[],n&&n(new tt(this.typeBundle,this.typeSchema,this.selections)),!this.typeSchema.implementsNode&&"Node"!==this.typeSchema.name||function e(t){return t.some(function(t){return R.prototype.isPrototypeOf(t)?"id"===t.name:!(!Q.prototype.isPrototypeOf(t)||!t.selectionSet.typeSchema.implementsNode)&&e(t.selectionSet.selections)})}(this.selections)||this.selections.unshift(new R("id",{},new Z(t,"ID"))),"INTERFACE"!==this.typeSchema.kind||function e(t){return t.some(function(t){return R.prototype.isPrototypeOf(t)?"__typename"===t.name:!(!Q.prototype.isPrototypeOf(t)||!t.selectionSet.typeSchema.implementsNode)&&e(t.selectionSet.selections)})}(this.selections)||this.selections.unshift(new R("__typename",{},new Z(t,"String"))),this.selectionsByResponseKey=function(t){function a(t,e,n){Array.isArray(t[e])?t[e].push(n):t[e]=[n]}var e=t.reduce(function(e,n){n.responseKey?a(e,n.responseKey,n):Object.keys(n.selectionSet.selectionsByResponseKey).forEach(function(t){a(e,t,n)});return e},{});return Object.keys(e).forEach(function(t){Object.freeze(e[t])}),Object.freeze(e)}(this.selections),Object.freeze(this.selections),Object.freeze(this)}var tt=(v(et,[{key:"hasSelectionWithResponseKey",value:function(e){return this.selections.some(function(t){return t.responseKey===e})}},{key:"add",value:function(t){var e=void 0;if("[object String]"===Object.prototype.toString.call(t)){M(this.typeSchema.name,t);for(var n=arguments.length,a=Array(1<n?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];e=this.field.apply(this,[t].concat(a))}else R.prototype.isPrototypeOf(t)&&M(this.typeSchema.name,t.name),e=t;if(e.responseKey&&this.hasSelectionWithResponseKey(e.responseKey))throw new Error("The field name or alias '"+e.responseKey+"' has already been added.");this.selections.push(e)}},{key:"field",value:function(t){for(var e=arguments.length,n=Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];var i=B(n),o=i.options,r=i.callback,d=i.selectionSet;if(!d){if(!this.typeSchema.fieldBaseTypes[t])throw new Error('No field of name "'+t+'" found on type "'+this.typeSchema.name+'" in schema');var c=b(this.typeBundle,this.typeSchema.fieldBaseTypes[t]);d=new $(this.typeBundle,c,r)}return new R(t,o,d)}},{key:"inlineFragmentOn",value:function(t,e){var n=1<arguments.length&&void 0!==e?e:q,a=void 0;return a=$.prototype.isPrototypeOf(n)?n:new $(this.typeBundle,b(this.typeBundle,t),n),new G(t,a)}},{key:"addField",value:function(t){for(var e=arguments.length,n=Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];this.add.apply(this,[t].concat(n))}},{key:"addConnection",value:function(t){for(var e=arguments.length,n=Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];var i=B(n),o=i.options,r=i.callback,d=i.selectionSet;this.add(t,o,function(t){t.add("pageInfo",{},function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",{},function(t){t.add("cursor"),t.addField("node",{},d||r)})})}},{key:"addInlineFragmentOn",value:function(t,e){var n=1<arguments.length&&void 0!==e?e:q;this.add(this.inlineFragmentOn(t,n))}},{key:"addFragment",value:function(t){this.add(t)}}]),et);function et(t,e,n){_(this,et),this.typeBundle=t,this.typeSchema=e,this.selections=n}var nt=(v(at,[{key:"toString",value:function(){return 0===this.variableDefinitions.length?"":" ("+m(this.variableDefinitions)+") "}}]),at);function at(t){_(this,at),this.variableDefinitions=t?[].concat(A(t)):[],Object.freeze(this.variableDefinitions),Object.freeze(this)}var it=(v(ot,[{key:"toString",value:function(){var t=this.name?" "+this.name:"";return this.operationType+t+this.variableDefinitions+this.selectionSet}},{key:"isAnonymous",get:function(){return!this.name}}]),ot);function ot(t,e){_(this,ot);for(var n=arguments.length,a=Array(2<n?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];var o=function(t){var e=void 0,n=void 0,a=void 0;if(3===t.length){var i=w(t,3);e=i[0],n=i[1],a=i[2]}else 2===t.length?("[object String]"===Object.prototype.toString.call(t[0])?(e=t[0],n=null):Array.isArray(t[0])&&(n=t[0],e=null),a=t[1]):(a=t[0],e=null);return{name:e,variables:n,selectionSetCallback:a}}(a),r=o.name,d=o.variables,c=o.selectionSetCallback;this.typeBundle=t,this.name=r,this.variableDefinitions=new nt(d),"query"===(this.operationType=e)?(this.selectionSet=new $(t,t.queryType,c),this.typeSchema=b(t,t.queryType)):(this.selectionSet=new $(t,t.mutationType,c),this.typeSchema=b(t,t.mutationType)),Object.freeze(this)}var rt=(k(dt,it),dt);function dt(t){var e;_(this,dt);for(var n=arguments.length,a=Array(1<n?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return x(this,(e=dt.__proto__||Object.getPrototypeOf(dt)).call.apply(e,[this,t,"query"].concat(a)))}var ct=(k(st,it),st);function st(t){var e;_(this,st);for(var n=arguments.length,a=Array(1<n?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return x(this,(e=st.__proto__||Object.getPrototypeOf(st)).call.apply(e,[this,t,"mutation"].concat(a)))}function ut(t){return t.isAnonymous}function lt(t){return 1!==t.length&&(function(t){return t.some(ut)}(t)||function(t){var a=t.map(function(t){return t.name});return a.reduce(function(t,e,n){return t||a.indexOf(e)!==n},!1)}(t))}var pt=(v(ft,[{key:"toString",value:function(){return m(this.definitions)}},{key:"addOperation",value:function(t){for(var e=arguments.length,n=Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];var i=function(t,e){for(var n=arguments.length,a=Array(2<n?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];return it.prototype.isPrototypeOf(a[0])?a[0]:"query"===e?new(Function.prototype.bind.apply(rt,[null].concat([t],a))):new(Function.prototype.bind.apply(ct,[null].concat([t],a)))}.apply(void 0,[this.typeBundle,t].concat(n));if(lt(this.operations.concat(i)))throw new Error("All operations must be uniquely named on a multi-operation document");this.definitions.push(i)}},{key:"addQuery",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];this.addOperation.apply(this,["query"].concat(e))}},{key:"addMutation",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];this.addOperation.apply(this,["mutation"].concat(e))}},{key:"defineFragment",value:function(t,e,n){if(function(t,e){return t.some(function(t){return t.name===e})}(this.fragmentDefinitions,t))throw new Error("All fragments must be uniquely named on a multi-fragment document");var a=new $(this.typeBundle,e,n),i=new Y(t,e,a);return this.definitions.push(i),i.spread}},{key:"operations",get:function(){return this.definitions.filter(function(t){return it.prototype.isPrototypeOf(t)})}},{key:"fragmentDefinitions",get:function(){return this.definitions.filter(function(t){return Y.prototype.isPrototypeOf(t)})}}]),ft);function ft(t){_(this,ft),this.typeBundle=t,this.definitions=[]}function ht(n){var a=this;_(this,ht),Object.defineProperty(this,"attrs",{value:n,enumerable:!1}),Object.keys(this.attrs).filter(function(t){return!(t in a)}).forEach(function(t){var e=void 0;e=null===n[t]?{enumerable:!0,get:function(){return null}}:{enumerable:!0,get:function(){return this.attrs[t].valueOf()}},Object.defineProperty(a,t,e)})}var mt=(v(yt,[{key:"registerClassForType",value:function(t,e){this.classStore[e]=t}},{key:"unregisterClassForType",value:function(t){delete this.classStore[t]}},{key:"classForType",value:function(t){return this.classStore[t]||ht}}]),yt);function yt(){_(this,yt),this.classStore={}}function gt(t){return"[object Null]"!==Object.prototype.toString.call(t)&&"[object Undefined]"!==Object.prototype.toString.call(t)}function bt(t){return t.selection.selectionSet.typeSchema.implementsNode}function _t(t,e){var n=e[e.length-1],a=n.selection.args.first,i=Object.keys(n.selection.args).filter(function(t){return V(n.selection.args[t])}).map(function(t){return n.selection.args[t]}),o=i.find(function(t){return"first"===t.name});return o||(V(a)?o=a:(o=O("first","Int",a),i.push(o))),[new pt(t.selection.selectionSet.typeBundle),i,o]}function vt(t,e,n,a){var i=e.shift();if(n.push(i.selection.responseKey),e.length)t.add(i.selection.name,{alias:i.selection.alias,args:i.selection.args},function(t){vt(t,e,n,a)});else{var o=i.selection.selectionSet.selections.find(function(t){return"edges"===t.name}).selectionSet.selections.find(function(t){return"node"===t.name}),r=void 0;r=V(i.selection.args.first)?i.selection.args.first:O("first","Int",i.selection.args.first);var d={alias:i.selection.alias,args:Object.assign({},i.selection.args,{after:a,first:r})};t.addConnection(i.selection.name,d,o.selectionSet)}}function Ct(t){return t.reduce(function(t,e){return J.prototype.isPrototypeOf(e)&&t.push(e.toDefinition()),t.push.apply(t,A(Ct(e.selectionSet.selections))),t},[])}function kt(u,l){var p=function t(e){return null==e?null:bt(e)?e:t(e.parent)}(u);return p?function(){var t,e=[],n=p.selection.selectionSet.typeSchema,a=p.responseData.id,i=function t(e){return e.selection.selectionSet.typeSchema.implementsNode?[e]:t(e.parent).concat(e)}(u),o=_t(u,i),r=w(o,2),d=r[0],c=r[1];d.addQuery(c,function(t){e.push("node"),t.add("node",{args:{id:a}},function(t){t.addInlineFragmentOn(n.name,function(t){vt(t,i.slice(1),e,l)})})});var s=Ct(d.operations[0].selectionSet.selections);return(t=d.definitions).unshift.apply(t,A(s)),[d,e]}:function(){var t,e=[],n=function t(e){return e.parent?t(e.parent).concat(e):[e]}(u),a=_t(u,n),i=w(a,2),o=i[0],r=i[1];o.addQuery(r,function(t){vt(t,n.slice(1),e,l)});var d=Ct(o.operations[0].selectionSet.selections);return(t=o.definitions).unshift.apply(t,A(d)),[o,e]}}function xt(a){return function(e,n){if(function(t){return t.selection.selectionSet.typeSchema.name.endsWith("Connection")}(e)){if(!(n.pageInfo&&n.pageInfo.hasOwnProperty("hasNextPage")&&n.pageInfo.hasOwnProperty("hasPreviousPage")))throw new Error('Connections must include the selections "pageInfo { hasNextPage, hasPreviousPage }".');return n.edges.map(function(t){return Object.assign(t.node,{nextPageQueryAndPath:kt(e,t.cursor),hasNextPage:function(t,e){return e!==t.edges[t.edges.length-1]?new T(!0):t.pageInfo.hasNextPage}(n,t),hasPreviousPage:function(t,e){return e!==t.edges[0]?new T(!0):t.pageInfo.hasPreviousPage}(n,t),variableValues:a})})}return n}}var Pt=(v(wt,[{key:"contextForObjectProperty",value:function(t){var e=this.selection.selectionSet.selectionsByResponseKey[t],n=e&&e[0],a=void 0;if(a=Q.prototype.isPrototypeOf(n)?new wt(n,this.responseData,this.parent):new wt(n,this.responseData[t],this),!n)throw new Error('Unexpected response key "'+t+'", not found in selection set: '+this.selection.selectionSet);return R.prototype.isPrototypeOf(n)?a:a.contextForObjectProperty(t)}},{key:"contextForArrayItem",value:function(t){return new wt(this.selection,t,this.parent)}}]),wt);function wt(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;_(this,wt),this.selection=t,this.responseData=e,this.parent=n,Object.freeze(this)}function At(t,e){var n=t.responseData;return Array.isArray(n)?n=function(e,n){return e.responseData.map(function(t){return At(e.contextForArrayItem(t),n)})}(t,e):y(n)&&(n=function(n,a){return Object.keys(n.responseData).reduce(function(t,e){return t[e]=At(n.contextForObjectProperty(e),a),t},{})}(t,e)),function(t,n,e){return t.reduce(function(t,e){return e(n,t)},e)}(e,t,n)}function Ft(e,t){return gt(t)&&bt(e)&&(t.refetchQuery=function(){return new rt(e.selection.selectionSet.typeBundle,function(t){t.add("node",{args:{id:e.responseData.id}},function(t){t.addInlineFragmentOn(e.selection.selectionSet.typeSchema.name,e.selection.selectionSet)})})}),t}function It(t,e){if(gt(e)){if("SCALAR"===t.selection.selectionSet.typeSchema.kind)return new T(e);if("ENUM"===t.selection.selectionSet.typeSchema.kind)return new S(e)}return e}function Vt(t,e){var n=t.selection.selectionSet,a=n.typeBundle,i=n.typeSchema;return gt(e)&&(e.__typename?e.type=b(a,e.__typename,i):e.type=i),e}function Ot(t){var e=t.classRegistry,n=void 0===e?new mt:e;return[It,Ft,xt(t.variableValues),Vt,function(n){return function(t,e){return y(e)?new(n.classForType(t.selection.selectionSet.typeSchema.name))(e):e}}(n)]}var St=(v(Et,[{key:"document",value:function(){return new pt(this.typeBundle)}},{key:"query",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return new(Function.prototype.bind.apply(rt,[null].concat([this.typeBundle],e)))}},{key:"mutation",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return new(Function.prototype.bind.apply(ct,[null].concat([this.typeBundle],e)))}},{key:"send",value:function(t,e,n,a){var i=1<arguments.length&&void 0!==e?e:null,o=this,r=2<arguments.length&&void 0!==n?n:null,d=3<arguments.length&&void 0!==a?a:null,c=void 0,s={query:(c=Function.prototype.isPrototypeOf(t)?t(this):t).toString()};i&&(s.variables=i),Object.assign(s,r);var u=void 0;if(it.prototype.isPrototypeOf(c))u=c;else{var l=c;if(1===l.operations.length)u=l.operations[0];else{if(!r.operationName)throw new Error("\n A document must contain exactly one operation, or an operationName\n must be specified. Example:\n\n client.send(document, null, {operationName: 'myFancyQuery'});\n ");u=l.operations.find(function(t){return t.name===r.operationName})}}return this.fetcher(s,d).then(function(t){return t.data&&(t.model=function(t,e,n){var a=2<arguments.length&&void 0!==n?n:{},i=a.transformers||Ot(a);return At(new Pt(t,e),i)}(u,t.data,{classRegistry:o.classRegistry,variableValues:i})),t})}},{key:"fetchNextPage",value:function(t,e){var n=void 0,a=(n=Array.isArray(t)?t[t.length-1]:t).nextPageQueryAndPath(),i=w(a,2),o=i[0],r=i[1],d=void 0;return(n.variableValues||e)&&(d=Object.assign({},n.variableValues,e)),this.send(o,d).then(function(t){return t.model=r.reduce(function(t,e){return t[e]},t.model),t})}},{key:"fetchAllPages",value:function(a,t){var i=this,o=t.pageSize;return function(t){return t&&t.length&&t[t.length-1].hasNextPage}(a)?this.fetchNextPage(a,{first:o}).then(function(t){var e=t.model,n=a.concat(e);return i.fetchAllPages(n,{pageSize:o})}):Promise.resolve(a)}},{key:"refetch",value:function(t){if(!t)throw new Error("'client#refetch' must be called with a non-null instance of a Node.");if(!t.type.implementsNode)throw new Error("'client#refetch' must be called with a type that implements Node. Received "+t.type.name+".");return this.send(t.refetchQuery()).then(function(t){return t.model.node})}},{key:"variable",value:function(t,e,n){return O(t,e,n)}},{key:"enum",value:function(t){return function(t){return new S(t)}(t)}}]),Et);function Et(t,e){var n=e.url,a=e.fetcherOptions,i=e.fetcher,o=e.registry,r=void 0===o?new mt:o;if(_(this,Et),this.typeBundle=t,this.classRegistry=r,n&&i)throw new Error("Arguments not supported: supply either `url` and optional `fetcherOptions` OR use a `fetcher` function for further customization.");if(n)this.fetcher=function(n,t){var a=1<arguments.length&&void 0!==t?t:{};return function(t,e){return fetch(n,P({body:JSON.stringify(t),method:"POST",mode:"cors"},a,{headers:P({"Content-Type":"application/json",Accept:"application/json"},a.headers,e)})).then(function(t){return-1<t.headers.get("content-type").indexOf("application/json")?t.json():t.text().then(function(t){return{text:t}})})}}(n,a);else{if(!i)throw new Error("Invalid arguments: one of `url` or `fetcher` is needed.");if(a)throw new Error("Arguments not supported: when specifying your own `fetcher`, set options through it and not with `fetcherOptions`");this.fetcher=i}}var Tt=(t(Ut,[{key:"requiredProperties",get:function(){return["storefrontAccessToken","domain"]}},{key:"deprecatedProperties",get:function(){return{accessToken:"storefrontAccessToken",apiKey:"storefrontAccessToken"}}}]),Ut);function Ut(e){var n=this;p(this,Ut),Object.keys(this.deprecatedProperties).forEach(function(t){e.hasOwnProperty(t)&&(console.warn("[ShopifyBuy] Config property "+t+" is deprecated as of v1.0, please use "+n.deprecatedProperties[t]+" instead."),e[n.deprecatedProperties[t]]=e[t])}),this.requiredProperties.forEach(function(t){if(!e.hasOwnProperty(t))throw new Error("new Config() requires the option '"+t+"'");n[t]=e[t]}),e.hasOwnProperty("apiVersion")?this.apiVersion=e.apiVersion:this.apiVersion="2020-07",e.hasOwnProperty("source")&&(this.source=e.source),e.hasOwnProperty("language")&&(this.language=e.language)}function Dt(t){p(this,Dt),this.graphQLClient=t}var Nt=[{message:"an unknown error has occurred."}];function qt(t){var i=t.split(".");return function(t){var n=t.model,a=t.errors;return new Promise(function(t,e){try{t(i.reduce(function(t,e){return t[e]},n))}catch(t){e(a||Nt)}})}}function zt(t,n){var e=[].concat(t);return Promise.all(e.reduce(function(t,e){return null===e||(t.push(n.fetchAllPages(e.images,{pageSize:250}).then(function(t){e.attrs.images=t})),t.push(n.fetchAllPages(e.variants,{pageSize:250}).then(function(t){e.attrs.variants=t}))),t},[]))}function Mt(e){return function(t){return zt(t,e).then(function(){return t})}}function Bt(n){return function(t){var e=[].concat(t);return Promise.all(e.reduce(function(t,e){return t.concat(zt(e.products,n))},[])).then(function(){return t})}}var Lt={variantForOptions:function(t,e){return t.variants.find(function(t){return t.selectedOptions.every(function(t){return e[t.name]===t.value.valueOf()})})}};function jt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.id=t.variable("id","ID!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.id],function(t){t.add("node",{args:{id:a.__defaultOperation__.id}},function(t){t.addFragment(n.ProductFragment)})}),e}function Rt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.ids=t.variable("ids","[ID!]!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.ids],function(t){t.add("nodes",{args:{ids:a.__defaultOperation__.ids}},function(t){t.addFragment(n.ProductFragment)})}),e}function Wt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.first=t.variable("first","Int!"),a.__defaultOperation__.query=t.variable("query","String"),a.__defaultOperation__.sortKey=t.variable("sortKey","ProductSortKeys"),a.__defaultOperation__.reverse=t.variable("reverse","Boolean"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.first,a.__defaultOperation__.query,a.__defaultOperation__.sortKey,a.__defaultOperation__.reverse],function(t){t.add("products",{args:{first:a.__defaultOperation__.first,query:a.__defaultOperation__.query,sortKey:a.__defaultOperation__.sortKey,reverse:a.__defaultOperation__.reverse}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.ProductFragment)})})})}),e}function Qt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.handle=t.variable("handle","String!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.handle],function(t){t.add("productByHandle",{args:{handle:a.__defaultOperation__.handle}},function(t){t.addFragment(n.ProductFragment)})}),e}var Gt=(e(Ht,Dt),t(Ht,[{key:"fetchAll",value:function(t){var e=0<arguments.length&&void 0!==t?t:20;return this.graphQLClient.send(Wt,{first:e}).then(qt("products")).then(Mt(this.graphQLClient))}},{key:"fetch",value:function(t){return this.graphQLClient.send(jt,{id:t}).then(qt("node")).then(Mt(this.graphQLClient))}},{key:"fetchMultiple",value:function(t){return this.graphQLClient.send(Rt,{ids:t}).then(qt("nodes")).then(Mt(this.graphQLClient))}},{key:"fetchByHandle",value:function(t){return this.graphQLClient.send(Qt,{handle:t}).then(qt("productByHandle")).then(Mt(this.graphQLClient))}},{key:"fetchQuery",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},n=e.first,a=void 0===n?20:n,i=e.sortKey,o=void 0===i?"ID":i,r=e.query,d=e.reverse;return this.graphQLClient.send(Wt,{first:a,sortKey:o,query:r,reverse:d}).then(qt("products")).then(Mt(this.graphQLClient))}},{key:"helpers",get:function(){return Lt}}]),Ht);function Ht(){return p(this,Ht),n(this,(Ht.__proto__||Object.getPrototypeOf(Ht)).apply(this,arguments))}function Jt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.id=t.variable("id","ID!"),n.CollectionFragment=e.defineFragment("CollectionFragment","Collection",function(t){t.add("id"),t.add("handle"),t.add("description"),t.add("descriptionHtml"),t.add("updatedAt"),t.add("title"),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")})}),e.addQuery([a.__defaultOperation__.id],function(t){t.add("node",{args:{id:a.__defaultOperation__.id}},function(t){t.addFragment(n.CollectionFragment)})}),e}function Kt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.id=t.variable("id","ID!"),a.__defaultOperation__.productsFirst=t.variable("productsFirst","Int!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.CollectionFragment=e.defineFragment("CollectionFragment","Collection",function(t){t.add("id"),t.add("handle"),t.add("description"),t.add("descriptionHtml"),t.add("updatedAt"),t.add("title"),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.id,a.__defaultOperation__.productsFirst],function(t){t.add("node",{args:{id:a.__defaultOperation__.id}},function(t){t.addFragment(n.CollectionFragment),t.addInlineFragmentOn("Collection",function(t){t.add("products",{args:{first:a.__defaultOperation__.productsFirst}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.ProductFragment)})})})})})}),e}function Yt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.first=t.variable("first","Int!"),a.__defaultOperation__.query=t.variable("query","String"),a.__defaultOperation__.sortKey=t.variable("sortKey","CollectionSortKeys"),a.__defaultOperation__.reverse=t.variable("reverse","Boolean"),n.CollectionFragment=e.defineFragment("CollectionFragment","Collection",function(t){t.add("id"),t.add("handle"),t.add("description"),t.add("descriptionHtml"),t.add("updatedAt"),t.add("title"),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")})}),e.addQuery([a.__defaultOperation__.first,a.__defaultOperation__.query,a.__defaultOperation__.sortKey,a.__defaultOperation__.reverse],function(t){t.add("collections",{args:{first:a.__defaultOperation__.first,query:a.__defaultOperation__.query,sortKey:a.__defaultOperation__.sortKey,reverse:a.__defaultOperation__.reverse}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.CollectionFragment)})})})}),e}function Xt(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.first=t.variable("first","Int!"),a.__defaultOperation__.query=t.variable("query","String"),a.__defaultOperation__.sortKey=t.variable("sortKey","CollectionSortKeys"),a.__defaultOperation__.reverse=t.variable("reverse","Boolean"),a.__defaultOperation__.productsFirst=t.variable("productsFirst","Int!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.CollectionFragment=e.defineFragment("CollectionFragment","Collection",function(t){t.add("id"),t.add("handle"),t.add("description"),t.add("descriptionHtml"),t.add("updatedAt"),t.add("title"),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),e.addQuery([a.__defaultOperation__.first,a.__defaultOperation__.query,a.__defaultOperation__.sortKey,a.__defaultOperation__.reverse,a.__defaultOperation__.productsFirst],function(t){t.add("collections",{args:{first:a.__defaultOperation__.first,query:a.__defaultOperation__.query,sortKey:a.__defaultOperation__.sortKey,reverse:a.__defaultOperation__.reverse}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.CollectionFragment),t.add("products",{args:{first:a.__defaultOperation__.productsFirst}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.ProductFragment)})})})})})})}),e}function $t(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.handle=t.variable("handle","String!"),n.VariantFragment=e.defineFragment("VariantFragment","ProductVariant",function(t){t.add("id"),t.add("title"),t.add("price"),t.add("priceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("presentmentPrices",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("node",function(t){t.add("price",function(t){t.add("amount"),t.add("currencyCode")}),t.add("compareAtPrice",function(t){t.add("amount"),t.add("currencyCode")})})})}),t.add("weight"),t.add("availableForSale",{alias:"available"}),t.add("sku"),t.add("compareAtPrice"),t.add("compareAtPriceV2",function(t){t.add("amount"),t.add("currencyCode")}),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")}),t.add("selectedOptions",function(t){t.add("name"),t.add("value")}),t.add("unitPrice",function(t){t.add("amount"),t.add("currencyCode")}),t.add("unitPriceMeasurement",function(t){t.add("measuredType"),t.add("quantityUnit"),t.add("quantityValue"),t.add("referenceUnit"),t.add("referenceValue")})}),n.ProductFragment=e.defineFragment("ProductFragment","Product",function(t){t.add("id"),t.add("availableForSale"),t.add("createdAt"),t.add("updatedAt"),t.add("descriptionHtml"),t.add("description"),t.add("handle"),t.add("productType"),t.add("title"),t.add("vendor"),t.add("publishedAt"),t.add("onlineStoreUrl"),t.add("options",function(t){t.add("name"),t.add("values")}),t.add("images",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.add("id"),t.add("src"),t.add("altText")})})}),t.add("variants",{args:{first:250}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.VariantFragment)})})})}),n.CollectionFragment=e.defineFragment("CollectionFragment","Collection",function(t){t.add("id"),t.add("handle"),t.add("description"),t.add("descriptionHtml"),t.add("updatedAt"),t.add("title"),t.add("image",function(t){t.add("id"),t.add("originalSrc",{alias:"src"}),t.add("altText")})}),n.CollectionsProductsFragment=e.defineFragment("CollectionsProductsFragment","Collection",function(t){t.add("products",{args:{first:20}},function(t){t.add("pageInfo",function(t){t.add("hasNextPage"),t.add("hasPreviousPage")}),t.add("edges",function(t){t.add("cursor"),t.add("node",function(t){t.addFragment(n.ProductFragment)})})})}),e.addQuery([a.__defaultOperation__.handle],function(t){t.add("collectionByHandle",{args:{handle:a.__defaultOperation__.handle}},function(t){t.addFragment(n.CollectionFragment),t.addFragment(n.CollectionsProductsFragment)})}),e}var Zt=(e(te,Dt),t(te,[{key:"fetchAll",value:function(t){var e=0<arguments.length&&void 0!==t?t:20;return this.graphQLClient.send(Yt,{first:e}).then(qt("collections"))}},{key:"fetchAllWithProducts",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},n=e.first,a=void 0===n?20:n,i=e.productsFirst,o=void 0===i?20:i;return this.graphQLClient.send(Xt,{first:a,productsFirst:o}).then(qt("collections")).then(Bt(this.graphQLClient))}},{key:"fetch",value:function(t){return this.graphQLClient.send(Jt,{id:t}).then(qt("node"))}},{key:"fetchWithProducts",value:function(t,e){var n=(1<arguments.length&&void 0!==e?e:{}).productsFirst,a=void 0===n?20:n;return this.graphQLClient.send(Kt,{id:t,productsFirst:a}).then(qt("node")).then(Bt(this.graphQLClient))}},{key:"fetchByHandle",value:function(t){return this.graphQLClient.send($t,{handle:t}).then(qt("collectionByHandle"))}},{key:"fetchQuery",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},n=e.first,a=void 0===n?20:n,i=e.sortKey,o=void 0===i?"ID":i,r=e.query,d=e.reverse;return this.graphQLClient.send(Yt,{first:a,sortKey:o,query:r,reverse:d}).then(qt("collections"))}}]),te);function te(){return p(this,te),n(this,(te.__proto__||Object.getPrototypeOf(te)).apply(this,arguments))}function ee(t){var e=t.document();return e.addQuery(function(t){t.add("shop",function(t){t.add("currencyCode"),t.add("paymentSettings",function(t){t.add("enabledPresentmentCurrencies")}),t.add("description"),t.add("moneyFormat"),t.add("name"),t.add("primaryDomain",function(t){t.add("host"),t.add("sslEnabled"),t.add("url")})})}),e}function ne(t){var e=t.document(),n={};return n.PolicyFragment=e.defineFragment("PolicyFragment","ShopPolicy",function(t){t.add("id"),t.add("title"),t.add("url"),t.add("body")}),e.addQuery(function(t){t.add("shop",function(t){t.add("privacyPolicy",function(t){t.addFragment(n.PolicyFragment)}),t.add("termsOfService",function(t){t.addFragment(n.PolicyFragment)}),t.add("refundPolicy",function(t){t.addFragment(n.PolicyFragment)})})}),e}var ae=(e(ie,Dt),t(ie,[{key:"fetchInfo",value:function(){return this.graphQLClient.send(ee).then(qt("shop"))}},{key:"fetchPolicies",value:function(){return this.graphQLClient.send(ne).then(qt("shop"))}}]),ie);function ie(){return p(this,ie),n(this,(ie.__proto__||Object.getPrototypeOf(ie)).apply(this,arguments))}function oe(c,s){return function(t){var e=t.data,n=void 0===e?{}:e,a=t.errors,i=t.model,o=void 0===i?{}:i,r=n[c],d=o[c];return r&&r.checkout?s.fetchAllPages(d.checkout.lineItems,{pageSize:250}).then(function(t){return d.checkout.attrs.lineItems=t,d.checkout.errors=a,d.checkout.userErrors=d.userErrors,d.checkout}):a&&a.length?Promise.reject(new Error(JSON.stringify(a))):r&&r.checkoutUserErrors&&r.checkoutUserErrors.length?Promise.reject(new Error(JSON.stringify(r.checkoutUserErrors))):r&&r.userErrors&&r.userErrors.length?Promise.reject(new Error(JSON.stringify(r.userErrors))):Promise.reject(new Error("The "+c+" mutation failed due to an unknown error."))}}function re(t){var e=t.document(),n={},a={__defaultOperation__:{}};return a.__defaultOperation__.id=t.variable("id","ID!"),n.VariantFragment=e.d