@plasmicpkgs/commerce 0.0.68 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),r=require("react"),n=e(r),o=require("@plasmicapp/host"),a=require("react-hook-form"),i=require("@plasmicapp/query"),c=e(require("js-cookie")),l=e(require("lodash.debounce"));function u(e,t,r,n,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){u(a,n,o,i,c,"next",e)}function c(e){u(a,n,o,i,c,"throw",e)}i(void 0)}))}}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function v(e,t,r){return(v=y()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return v(e,arguments,m(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e,t){return e(t={exports:{}},t.exports),t.exports}var b=C((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof p?t:p).prototype),a=new E(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=C(i,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=u(e,t,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===s)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(e,r,a),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var s={};function p(){}function d(){}function m(){}var f={};c(f,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(w([])));v&&v!==t&&r.call(v,o)&&(f=v);var h=m.prototype=p.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,c){var l=u(e[o],e,a);if("throw"!==l.type){var s=l.arg,p=s.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return n("throw",e,i,c)}))}c(l.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function C(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,C(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,s;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function w(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=m,c(h,"constructor",m),c(m,"constructor",d),d.displayName=c(m,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,c(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},g(x.prototype),c(x.prototype,a,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new x(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},g(h),c(h,i,"Generator"),c(h,o,(function(){return this})),c(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=w,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:w(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})),P={id:"123456789",name:"Product name",description:"",descriptionHtml:"\n <p>This is a <strong>placeholder</strong>.</p>\n ",images:[{url:"https://static1.plasmic.app/commerce/lightweight-jacket-0.png",alt:"Lightweight Jacket"},{url:"https://static1.plasmic.app/commerce/lightweight-jacket-1.png",alt:"Lightweight Jacket"},{url:"https://static1.plasmic.app/commerce/lightweight-jacket-2.png",alt:"Lightweight Jacket"}],variants:[{id:"variant1",name:"Variant 1",options:[]},{id:"variant2",name:"Variant 2",options:[]}],price:{value:0,currencyCode:"USD"},options:[]};function E(e){var t=e.product,r=e.children,i=a.useForm();return n.createElement(o.DataProvider,{name:"currentProduct",data:t,key:t.id},n.createElement(a.FormProvider,Object.assign({},i),r))}var w=function(){var e=o.useSelector("currentProduct");return null!=e?e:P},N=n.createContext(void 0);function k(e){var t=e.category;return n.createElement(o.DataProvider,{name:"currentCategory",data:t,key:t.id},e.children)}var L=function(){return o.useSelector("currentCategory")};function M(e){var t=e.mediaIndex,r=e.onClick,a=e.children;return n.createElement(o.DataProvider,{name:"currentMedia",data:t,key:t},n.cloneElement(n.isValidElement(a)?a:n.createElement(n.Fragment,null),{onClick:r}))}var S=["children"],V=r.createContext({});function O(e){var t=e.provider,o=e.children,a=r.useRef(t),i=r.useRef(t.fetcher),c=a.current,l=c.locale,u=c.cartCookie,s=r.useMemo((function(){return{providerRef:a,fetcherRef:i,locale:l,cartCookie:u}}),[l,u]);return n.createElement(V.Provider,{value:s},o)}function I(){return r.useContext(V)}var _=function(e){function t(t){var r,n=t.message,o=t.code,a=t.errors,i=n?p({message:n},o?{code:o}:{}):a[0];return(r=e.call(this,i.message)||this).errors=n?[i]:a,i.code&&(r.code=i.code),r}return d(t,e),t}(h(Error)),F=function(e){function t(t){var r;return(r=e.call(this,t)||this).code="validation_error",r}return d(t,e),t}(_),j=function(e){function t(t){var r;return(r=e.call(this,t)||this).status=t.status,r}return d(t,e),t}(_);function T(){var e,t=I();return null!=(e=t.providerRef.current.fetcher)?e:t.fetcherRef.current}function R(){return I().providerRef.current}function D(e){return e(I().providerRef.current)}function A(e){var t=T(),r=R();return e.useHook({useData:function(n){var o;return function(e,t,r,n,o){var a=Array.isArray(t)?t:Object.entries(t),c=i.useMutablePlasmicQueryData((function(){var t=e.fetchOptions;return t?[t.url,t.query,t.method].concat(a.map((function(e){return e[1]}))):null}),function(){var t=s(b.mark((function t(n,i,c){var l,u,s,p=arguments;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(t.prev=0,l=p.length,u=new Array(l>3?l-3:0),s=3;s<l;s++)u[s-3]=p[s];return t.next=4,e.fetcher({options:{url:n,query:i,method:c},input:u.reduce((function(e,t,r){return e[a[r][0]]=t,e}),{}),fetch:r,provider:o});case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),t.t0 instanceof _||console.error(t.t0),t.t0;case 11:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e,r,n){return t.apply(this,arguments)}}(),n);return"isLoading"in c||Object.defineProperty(c,"isLoading",{get:function(){return void 0===c.data},enumerable:!0}),c}(e,null!=(o=null==n?void 0:n.input)?o:[],t,null==n?void 0:n.swrOptions,r)}})}function B(e){var t=T(),n=R();return e.useHook({fetch:r.useCallback((function(r){return e.fetcher({input:(void 0===r?{}:r).input,options:e.fetchOptions,fetch:t,provider:n})}),[t,e.fetchOptions])})}var q=function(e){return(0,e.fetch)(e.options)},G=function(e){return(0,e.fetch)(p({},e.options,{body:e.input}))},H=G,Q=function(e){var t;return null==(t=e.cart)?void 0:t.useAddItem},U=function(){var e=D(Q);return B(p({fetcher:H},e)).apply(void 0,arguments)},Y={name:"plasmic-commerce-add-to-cart-button",displayName:"Add To Cart Button",props:{children:{type:"slot",defaultValue:[{type:"button",value:"Add To Cart"}]}},importPath:"@plasmicpkgs/commerce",importName:"AddToCartButton"};function W(e){var t=e.children,r=w(),o=a.useFormContext(),i=U(),c=function(){var e=s(b.mark((function e(){var t,n,a,c;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=+(null!=(t=o.getValues().ProductQuantity)?t:1),!(isNaN(n)||n<1)){e.next=3;break}throw new _({message:"The item quantity has to be a valid integer greater than 0"});case 3:if(!r){e.next=7;break}return c=null!=(a=o.getValues().ProductVariant)?a:r.variants[0].id,e.next=7,i({productId:r.id,variantId:c,quantity:n});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return n.isValidElement(t)?n.cloneElement(t,{onClick:function(e){t.props.onClick&&"function"==typeof t.props.onClick&&t.props.onClick(e),c()}}):null}function z(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(W,null!=r?r:Y)}var J=function(){var e=s(b.mark((function e(t){var r,n;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.options,n=t.fetch,!t.input.cartId){e.next=7;break}return e.next=4,n(r);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=null;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),$=function(e){var t;return null==(t=e.cart)?void 0:t.useCart},K=function(e){var t,r=D($),n=I().cartCookie,o=null!=(t=r.fetcher)?t:J;return A(p({},r,{fetcher:function(e){return e.input.cartId=c.get(n),o(e)}}))(e)};function X(e){var t=e.amount;return new Intl.NumberFormat(e.locale,{style:"currency",currency:e.currencyCode}).format(t)}function Z(e){var t=null!=e?e:{},n=t.amount,o=t.baseAmount,a=t.currencyCode,i=I().locale,c=r.useMemo((function(){return"number"==typeof n&&a?o?function(e){var t=e.amount,r=e.baseAmount,n=e.currencyCode,o=e.locale,a=r>t,i=new Intl.NumberFormat(o,{style:"percent"}),c=a?i.format((r-t)/r):null;return{price:X({amount:t,currencyCode:n,locale:o}),basePrice:a?X({amount:r,currencyCode:n,locale:o}):null,discount:c}}({amount:n,baseAmount:o,currencyCode:a,locale:i}):X({amount:n,currencyCode:a,locale:i}):""}),[n,o,a]);return"string"==typeof c?{price:c}:c}var ee={name:"plasmic-commerce-cart",displayName:"Cart",props:{field:{type:"choice",options:["Size","Total Price"]},hideIfIsEmpty:{type:"boolean",defaultValue:!1,description:"You can hide this component if the cart is empty"}},importPath:"@plasmicpkgs/commerce",importName:"CartComponent"};function te(e){var t,r,o,a,i=e.className,c=e.field,l=e.hideIfIsEmpty,u=K().data,s=Z({amount:null!=(t=null==u?void 0:u.totalPrice)?t:0,currencyCode:null!=(r=null==u?void 0:u.currency.code)?r:"USD"}).price;return c?("Size"===c?o=null!=(a=null==u?void 0:u.lineItems.length)?a:0:"Total Price"===c&&(o=null!=s?s:0),l&&0===o?null:n.createElement("span",{className:i},o)):n.createElement("p",null,"You must set the field prop")}function re(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(te,null!=r?r:ee)}var ne=q,oe=function(e){var t;return null==(t=e.site)?void 0:t.useCategories},ae=function(e){var t=D(oe);return A(p({fetcher:ne},t))(e)},ie={name:"plasmic-commerce-category-collection",displayName:"Category Collection",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-category-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-collection"}],styles:{width:"100%",minWidth:0}}]},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No collection found!"}},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},category:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.categories.map((function(e){var t;return{label:""+" ".repeat(null!=(t=e.depth)?t:0)+e.name,value:e.id}})))?r:[]}},noLayout:{type:"boolean",displayName:"No layout",description:"Do not render a container element."},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every category."}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr",gridRowGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"CategoryCollection",providesData:!0};function ce(e){var t,r=e.children,a=e.noLayout,i=e.noAutoRepeat,c=e.className,l=e.loadingMessage,u=e.emptyMessage,s=e.category,p=e.setControlContextData,d=n.useContext(o.PlasmicCanvasContext),m=ae(),f=m.data,y=m.isLoading,v=ae({categoryId:s,addIsEmptyField:!!d}),h=v.data,g=v.isLoading;f&&(null==p||p({categories:f}));var x=null==h?void 0:h.find((function(e){return!e.isEmpty})),C=null!=(t=null==h?void 0:h.findIndex((function(e){return!e.isEmpty})))?t:-1,b=i?r:null==h?void 0:h.map((function(e,t){return n.createElement(k,{category:e,key:e.id},o.repeatedElement(t<C?t+1:t===C?0:t,r))}));return[y,g].includes(!0)?n.isValidElement(l)?l:null:h&&0!==h.length?n.createElement(o.DataProvider,{name:"categories",data:h},n.createElement(N.Provider,{value:null!=x?x:h[0]},a?n.createElement(n.Fragment,null,b):n.createElement("div",{className:c},b))):n.isValidElement(u)?u:null}function le(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ce,null!=r?r:ie)}var ue={name:"plasmic-commerce-category-field",displayName:"Category Field",props:{field:{type:"choice",options:["id","name","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"CategoryField"};function se(e){var t=e.className,r=e.field,o=L();return r?n.createElement("span",{className:t},o?o[r]:"Category field placeholder"):n.createElement("span",null,"You must set the field prop")}function pe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(se,null!=r?r:ue)}var de={name:"plasmic-commerce-category-link",displayName:"Category Link",props:{children:"slot",linkDest:{type:"string",defaultValueHint:"category/{slug}",description:"Set the link destination. You can use {slug} to replace by the category slug"}},importPath:"@plasmicpkgs/commerce",importName:"CategoryLink"};function me(e){var t=e.className,r=e.children,o=e.linkDest,a=L();return n.createElement("a",{className:t,href:function(e){var t;if(e){for(var r,n=/{[^}]*}/,o=new RegExp(n,"g"),i=null!=(t=e.match(o))?t:[],c=e,l=x(i);!(r=l()).done;){var u=r.value.slice(1,-1);if(!a||!(u in a))return;c=c.replace(n,a[u])}return c}}(o),style:{color:"inherit",textDecoration:"inherit"}},r)}function fe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(me,null!=r?r:de)}var ye={name:"plasmic-commerce-category-media",displayName:"Category Media",props:{mediaIndex:"number"},importPath:"@plasmicpkgs/commerce",importName:"CategoryMedia"},ve=n.forwardRef((function(e,t){var r,o=e.className,a=e.mediaIndex,i=void 0===a?0:a,c=L(),l=null!=c&&c.images?c.images[i]:void 0;return n.createElement("img",{ref:t,alt:(null==c?void 0:c.name)||"Category Image",src:null!=(r=null==l?void 0:l.url)?r:"",loading:"lazy",className:o})}));function he(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ve,null!=r?r:ye)}var ge=q,xe=function(e){var t;return null==(t=e.products)?void 0:t.useProduct},Ce=function(e){var t=D(xe);return A(p({fetcher:ge},t))(e)},be=q,Pe=function(e){var t;return null==(t=e.products)?void 0:t.useSearch},Ee=function(e){var t=D(Pe);return A(p({fetcher:be},t))(e)},we={name:"plasmic-commerce-product-box",displayName:"Product Box",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-text-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-media"}],styles:{width:"100%",minWidth:0}}]},noLayout:"boolean",id:{type:"cardPicker",modalTitle:"Product",onSearch:function(e,t){return null==t?void 0:t.onSearch},options:function(e,t){var r;return null!=(r=null==t?void 0:t.products.map((function(e){var t;return{imgUrl:e.images[0].url,value:e.id,label:null!=(t=e.slug)?t:e.name,footer:n.createElement("div",null,n.createElement("div",null,n.createElement("strong",null,e.name)),n.createElement("div",null,e.slug))}})))?r:[]}}},importPath:"@plasmicpkgs/commerce",importName:"ProductBox",providesData:!0};function Ne(e){var t=e.className,r=e.children,o=e.noLayout,a=e.id,i=e.setControlContextData,c=n.useState(""),u=c[0],s=c[1],p=Ee({search:""!==u?u:void 0}).data,d=n.useCallback(l((function(e){return s(e)}),300),[]);p&&(null==i||i({products:p.products,onSearch:d}));var m=Ce({id:a}),f=m.data,y=m.error,v=m.isLoading;if(!a)return n.createElement("span",null,"You must set the id prop");if(y)throw new _({message:y.message,code:y.code});if(v)return n.createElement("span",null,"Loading...");if(!f)throw new Error("Product not found!");var h=n.createElement(E,{product:f},r);return o?n.createElement(n.Fragment,null,h):n.createElement("div",{className:t},h)}function ke(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ne,null!=r?r:we)}var Le=q,Me=function(e){var t;return null==(t=e.site)?void 0:t.useBrands},Se=function(e){var t=D(Me);return A(p({fetcher:Le},t))(e)},Ve={name:"plasmic-commerce-product-collection",displayName:"Product Collection",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-text-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-media"}],styles:{width:"100%",minWidth:0}}]},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No product found!"}},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},count:"number",category:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.categories.map((function(e){var t;return{label:""+" ".repeat(null!=(t=e.depth)?t:0)+e.name,value:e.id}})))?r:[]},defaultValueHint:function(e,t){var r;return null==t||null==(r=t.categoryCtx)?void 0:r.name},readOnly:function(e,t){return!(null==t||!t.categoryCtx)}},includeSubCategories:{type:"boolean",hidden:function(e,t){var r;return!(null!=t&&null!=(r=t.features)&&r.includeSubCategories)}},brand:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.brands.map((function(e){return{label:e.name,value:e.entityId}})))?r:[]}},search:{type:"string"},sort:{type:"choice",options:[{label:"Trending",value:"trending-desc"},{label:"New Arrivals",value:"latest-desc"},{label:"Price: Low to High",value:"price-asc"},{label:"Price: High to Low",value:"price-desc"}]},noLayout:{type:"boolean",displayName:"No layout",description:"Do not render a container element."},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every category."}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductCollection",providesData:!0};function Oe(e){var t,a=e.className,i=e.children,c=e.count,l=e.category,u=e.includeSubCategories,s=e.brand,p=e.noLayout,d=e.noAutoRepeat,m=e.setControlContextData,f=e.emptyMessage,y=e.loadingMessage,v=e.search,h=e.sort,g=ae(),x=g.data,C=g.isLoading,b=Se(),P=b.data,w=b.isLoading,k=L(),M=Ee({categoryId:null!=(t=null==k?void 0:k.id)?t:l,brandId:s,count:c,categories:null!=x?x:[],includeSubCategories:u,search:v,sort:h}),S=M.data,V=M.isLoading,O=I().providerRef.current.extraFeatures,_=r.useContext(N);x&&P&&(null==m||m({categories:x,brands:P,features:O,categoryCtx:_}));var F=d?i:null==S?void 0:S.products.map((function(e,t){return n.createElement(E,{product:e,key:e.id},o.repeatedElement(t,i))}));return[V,w,C].includes(!0)?n.isValidElement(y)?y:null:S&&0!==S.products.length?n.createElement(o.DataProvider,{name:"products",data:null==S?void 0:S.products},p?n.createElement(n.Fragment,null,F):n.createElement("div",{className:a},F)):n.isValidElement(f)?f:null}function Ie(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Oe,null!=r?r:Ve)}var _e={name:"plasmic-commerce-product-link",displayName:"Product Link",props:{children:"slot",linkDest:{type:"string",defaultValueHint:"products/{slug}",description:"Set the link destination. You can use {slug} to replace by the product slug"}},importPath:"@plasmicpkgs/commerce",importName:"ProductLink"};function Fe(e){var t=e.className,r=e.children,o=e.linkDest,a=w();return n.createElement("a",{className:t,href:function(e){var t;if(e){for(var r,n=/{[^}]*}/,o=new RegExp(n,"g"),i=null!=(t=e.match(o))?t:[],c=e,l=x(i);!(r=l()).done;){var u=r.value.slice(1,-1);if(!a||!(u in a))return;c=c.replace(n,a[u])}return c}}(o),style:{color:"inherit",textDecoration:"inherit"}},r)}function je(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Fe,null!=r?r:_e)}var Te={name:"plasmic-commerce-product-media",displayName:"Product Media",props:{mediaIndex:{type:"number",min:0,hidden:function(e,t){return!(null==t||!t.inMediaContext)}}},importPath:"@plasmicpkgs/commerce",importName:"ProductMedia"},Re=n.forwardRef((function(e,t){var r,a=e.className,i=e.mediaIndex,c=void 0===i?0:i,l=e.setControlContextData,u=w(),s=o.useSelector("currentMedia");null==l||l({inMediaContext:void 0!==s});var p=null==u?void 0:u.images[null!=s?s:c];return n.createElement("img",{ref:t,alt:(null==u?void 0:u.name)||"Product Image",src:u?null!=(r=null==p?void 0:p.url)?r:"":"https://static1.plasmic.app/commerce/lightweight-jacket-0.png",loading:"lazy",className:a})}));function De(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Re,null!=r?r:Te)}var Ae={name:"plasmic-commerce-product-media-collection",displayName:"Product Media Collection",props:{media:{type:"slot",defaultValue:{type:"component",name:"plasmic-commerce-product-media"},allowedComponents:["plasmic-commerce-product-media"]}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductMediaCollection",providesData:!0};function Be(e){var t=e.media,r=e.className,a=w();return n.createElement("div",{className:r},null==a?void 0:a.images.map((function(e,r){return o.repeatedElement(r,n.createElement(M,{mediaIndex:r,children:t}))})))}function qe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Be,null!=r?r:Ae)}var Ge=function(e,t){var r,n;return null!=(r=null==(n=e.variants.find((function(e){return e.id===t})))?void 0:n.price)?r:e.price.value},He={name:"plasmic-commerce-product-price",displayName:"Product Price",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductPriceComponent"};function Qe(e){var t,r=e.className,o=w(),i=a.useFormContext(),c=null==i?void 0:i.watch("ProductVariant",null!=(t=o.price)?t:""),l=Z({amount:o?Ge(o,c):0,currencyCode:o?o.price.currencyCode:"USD"});return n.createElement("span",{className:r},l.price)}function Ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Qe,null!=r?r:He)}var Ye={name:"plasmic-commerce-product-quantity",displayName:"Product Quantity",props:{children:{type:"slot",defaultValue:[{type:"input",attrs:{value:"1"}}]}},importPath:"@plasmicpkgs/commerce",importName:"ProductQuantity"};function We(e){var t=e.className,r=e.children,o=a.useFormContext();return n.createElement("div",{className:t},n.createElement(a.Controller,{name:"ProductQuantity",defaultValue:1,control:null==o?void 0:o.control,render:function(e){var t=e.field;return n.isValidElement(r)?n.cloneElement(r,p({},r.props,t,{name:"ProductQuantity"})):n.createElement(n.Fragment,null)}}))}function ze(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(We,null!=r?r:Ye)}var Je={name:"plasmic-commerce-product-slider",displayName:"Product Slider",providesData:!0,props:{thumbsVisible:{type:"number",description:"Number of thumbs visible",defaultValue:4,defaultValueHint:4},slideContainer:{type:"slot",defaultValue:{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-media"}]}},thumbsContainer:{type:"slot",defaultValue:{type:"hbox",children:[{type:"component",name:"plasmic-commerce-product-media"}]}},slideSelected:{type:"number",defaultValue:0,defaultValueHint:0,description:"Current slide selected"}},importPath:"@plasmicpkgs/commerce",importName:"ProductSlider"};function $e(e){var t=e.className,r=e.slideContainer,a=e.thumbsContainer,i=e.thumbsVisible,c=void 0===i?4:i,l=e.slideSelected,u=void 0===l?0:l,s=w(),p=n.useState(u),d=p[0],m=p[1],f=Math.max(0,s.images.length-c),y=Math.min(f,Math.max(0,d-1));return n.createElement("div",{className:t},n.createElement(M,{mediaIndex:d,children:r}),n.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat("+c+", 1fr)"}},s.images.slice(y,y+c).map((function(e,t){return o.repeatedElement(t,n.createElement(M,{mediaIndex:y+t,children:a,onClick:function(){return m(y+t)}}))}))))}function Ke(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}($e,null!=r?r:Je)}var Xe={name:"plasmic-commerce-product-text-field",displayName:"Product Text Field",props:{field:{type:"choice",options:["id","name","description","sku","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"ProductTextField"};function Ze(e){var t,r=e.className,o=e.field,a=w();return a?o?"description"===o?n.createElement("div",{className:r,dangerouslySetInnerHTML:{__html:null!=(t=a.descriptionHtml)?t:a.description}}):n.createElement("span",{className:r},a[o]):n.createElement("span",{className:r},"Unknown Product Field"):n.createElement("span",{className:r},"Fake Product Field")}function et(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ze,null!=r?r:Xe)}var tt={name:"plasmic-commerce-product-variant-picker",displayName:"Product Variant Picker",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductVariantPicker"};function rt(e){var t,r,o=e.className,i=w(),c=null!=(t=a.useFormContext())?t:a.useForm();return n.createElement(a.Controller,{name:"ProductVariant",control:null==c?void 0:c.control,defaultValue:null==i||null==(r=i.variants.find((function(e){return e.price===i.price.value})))?void 0:r.id,render:function(e){var t;return n.createElement("select",Object.assign({className:o},e.field),null!=(t=null==i?void 0:i.variants.map((function(e){return n.createElement("option",{value:e.id},e.name)})))?t:n.createElement("option",null,"Product Variant Placeholder"))}})}function nt(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(rt,null!=r?r:tt)}var ot=G,at=function(e){var t;return null==(t=e.cart)?void 0:t.useRemoveItem},it=G,ct=function(e){var t;return null==(t=e.cart)?void 0:t.useUpdateItem};exports.AddToCartButton=W,exports.CartComponent=te,exports.CartType={__proto__:null},exports.CategoryCollection=ce,exports.CategoryField=se,exports.CategoryLink=me,exports.CategoryMedia=ve,exports.CommerceError=_,exports.CoreCommerceProvider=O,exports.FetcherError=j,exports.ProductBox=Ne,exports.ProductCollection=Oe,exports.ProductLink=Fe,exports.ProductMedia=Re,exports.ProductMediaCollection=Be,exports.ProductPlaceholder=P,exports.ProductPriceComponent=Qe,exports.ProductQuantity=We,exports.ProductSlider=$e,exports.ProductTextField=Ze,exports.ProductTypes={__proto__:null},exports.ProductVariantPicker=rt,exports.SiteTypes={__proto__:null},exports.ValidationError=F,exports.addToCartButtonMeta=Y,exports.cartMeta=ee,exports.categoryCollectionMeta=ie,exports.categoryFieldMeta=ue,exports.categoryLinkMeta=de,exports.categoryMediaMeta=ye,exports.fetcher=be,exports.getCommerceProvider=function(e){return function(t){var r=t.children,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}(t,S);return n.createElement(O,{provider:p({},e,o)},r)}},exports.productBoxMeta=we,exports.productCollectionMeta=Ve,exports.productLinkMeta=_e,exports.productMediaCollectionMeta=Ae,exports.productMediaMeta=Te,exports.productPriceMeta=He,exports.productQuantityMeta=Ye,exports.productSliderMeta=Je,exports.productTextFieldMeta=Xe,exports.productVariantPickerMeta=tt,exports.registerAddToCartButton=z,exports.registerAll=function(e){Ie(e),et(e),Ue(e),De(e),qe(e),re(e),z(e),ze(e),nt(e),ke(e),Ke(e),je(e),le(e),pe(e),fe(e),he(e)},exports.registerCart=re,exports.registerCategoryCollection=le,exports.registerCategoryField=pe,exports.registerCategoryLink=fe,exports.registerCategoryMedia=he,exports.registerProductBox=ke,exports.registerProductCollection=Ie,exports.registerProductLink=je,exports.registerProductMedia=De,exports.registerProductMediaCollection=qe,exports.registerProductPrice=Ue,exports.registerProductQuantity=ze,exports.registerProductSlider=Ke,exports.registerProductVariantPicker=nt,exports.registerTextField=et,exports.useAddItem=U,exports.useBrands=Se,exports.useCart=K,exports.useCategories=ae,exports.useCommerce=I,exports.useProduct=Ce,exports.useRemoveItem=function(e){var t=D(at);return B(p({fetcher:ot},t))(e)},exports.useSearch=Ee,exports.useUpdateItem=function(e){var t=D(ct);return B(p({fetcher:it},t))(e)};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),r=require("react"),n=e(r),o=require("@plasmicapp/host"),a=require("react-hook-form"),i=require("@plasmicapp/query"),c=e(require("js-cookie")),l=e(require("debounce"));function u(e,t,r,n,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){u(a,n,o,i,c,"next",e)}function c(e){u(a,n,o,i,c,"throw",e)}i(void 0)}))}}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function v(e,t,r){return(v=y()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return v(e,arguments,m(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e,t){return e(t={exports:{}},t.exports),t.exports}var b=C((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof p?t:p).prototype),a=new E(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=C(i,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=u(e,t,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===s)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(e,r,a),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var s={};function p(){}function d(){}function m(){}var f={};c(f,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(w([])));v&&v!==t&&r.call(v,o)&&(f=v);var h=m.prototype=p.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,c){var l=u(e[o],e,a);if("throw"!==l.type){var s=l.arg,p=s.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return n("throw",e,i,c)}))}c(l.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function C(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,C(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,s;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function w(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=m,c(h,"constructor",m),c(m,"constructor",d),d.displayName=c(m,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,c(e,i,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},g(x.prototype),c(x.prototype,a,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new x(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},g(h),c(h,i,"Generator"),c(h,o,(function(){return this})),c(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=w,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:w(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})),P={id:"123456789",name:"Product name",description:"",descriptionHtml:"\n <p>This is a <strong>placeholder</strong>.</p>\n ",images:[{url:"https://static1.plasmic.app/commerce/lightweight-jacket-0.png",alt:"Lightweight Jacket"},{url:"https://static1.plasmic.app/commerce/lightweight-jacket-1.png",alt:"Lightweight Jacket"},{url:"https://static1.plasmic.app/commerce/lightweight-jacket-2.png",alt:"Lightweight Jacket"}],variants:[{id:"variant1",name:"Variant 1",options:[]},{id:"variant2",name:"Variant 2",options:[]}],price:{value:0,currencyCode:"USD"},options:[]};function E(e){var t=e.product,r=e.children,i=a.useForm();return n.createElement(o.DataProvider,{name:"currentProduct",data:t,key:t.id},n.createElement(a.FormProvider,Object.assign({},i),r))}var w=function(){var e=o.useSelector("currentProduct");return null!=e?e:P},N=n.createContext(void 0);function k(e){var t=e.category;return n.createElement(o.DataProvider,{name:"currentCategory",data:t,key:t.id},e.children)}var L=function(){return o.useSelector("currentCategory")};function M(e){var t=e.mediaIndex,r=e.onClick,a=e.children;return n.createElement(o.DataProvider,{name:"currentMedia",data:t,key:t},n.cloneElement(n.isValidElement(a)?a:n.createElement(n.Fragment,null),{onClick:r}))}var S=["children"],V=r.createContext({});function O(e){var t=e.provider,o=e.children,a=r.useRef(t),i=r.useRef(t.fetcher),c=a.current,l=c.locale,u=c.cartCookie,s=r.useMemo((function(){return{providerRef:a,fetcherRef:i,locale:l,cartCookie:u}}),[l,u]);return n.createElement(V.Provider,{value:s},o)}function I(){return r.useContext(V)}var _=function(e){function t(t){var r,n=t.message,o=t.code,a=t.errors,i=n?p({message:n},o?{code:o}:{}):a[0];return(r=e.call(this,i.message)||this).errors=n?[i]:a,i.code&&(r.code=i.code),r}return d(t,e),t}(h(Error)),F=function(e){function t(t){var r;return(r=e.call(this,t)||this).code="validation_error",r}return d(t,e),t}(_),j=function(e){function t(t){var r;return(r=e.call(this,t)||this).status=t.status,r}return d(t,e),t}(_);function T(){var e,t=I();return null!=(e=t.providerRef.current.fetcher)?e:t.fetcherRef.current}function R(){return I().providerRef.current}function D(e){return e(I().providerRef.current)}function A(e){var t=T(),r=R();return e.useHook({useData:function(n){var o;return function(e,t,r,n,o){var a=Array.isArray(t)?t:Object.entries(t),c=i.useMutablePlasmicQueryData((function(){var t=e.fetchOptions;return t?[t.url,t.query,t.method].concat(a.map((function(e){return e[1]}))):null}),function(){var t=s(b.mark((function t(n,i,c){var l,u,s,p=arguments;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(t.prev=0,l=p.length,u=new Array(l>3?l-3:0),s=3;s<l;s++)u[s-3]=p[s];return t.next=4,e.fetcher({options:{url:n,query:i,method:c},input:u.reduce((function(e,t,r){return e[a[r][0]]=t,e}),{}),fetch:r,provider:o});case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),t.t0 instanceof _||console.error(t.t0),t.t0;case 11:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e,r,n){return t.apply(this,arguments)}}(),n);return"isLoading"in c||Object.defineProperty(c,"isLoading",{get:function(){return void 0===c.data},enumerable:!0}),c}(e,null!=(o=null==n?void 0:n.input)?o:[],t,null==n?void 0:n.swrOptions,r)}})}function B(e){var t=T(),n=R();return e.useHook({fetch:r.useCallback((function(r){return e.fetcher({input:(void 0===r?{}:r).input,options:e.fetchOptions,fetch:t,provider:n})}),[t,e.fetchOptions])})}var q=function(e){return(0,e.fetch)(e.options)},G=function(e){return(0,e.fetch)(p({},e.options,{body:e.input}))},H=G,Q=function(e){var t;return null==(t=e.cart)?void 0:t.useAddItem},U=function(){var e=D(Q);return B(p({fetcher:H},e)).apply(void 0,arguments)},Y={name:"plasmic-commerce-add-to-cart-button",displayName:"Add To Cart Button",props:{children:{type:"slot",defaultValue:[{type:"button",value:"Add To Cart"}]}},importPath:"@plasmicpkgs/commerce",importName:"AddToCartButton"};function W(e){var t=e.children,r=w(),o=a.useFormContext(),i=U(),c=function(){var e=s(b.mark((function e(){var t,n,a,c;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=+(null!=(t=o.getValues().ProductQuantity)?t:1),!(isNaN(n)||n<1)){e.next=3;break}throw new _({message:"The item quantity has to be a valid integer greater than 0"});case 3:if(!r){e.next=7;break}return c=null!=(a=o.getValues().ProductVariant)?a:r.variants[0].id,e.next=7,i({productId:r.id,variantId:c,quantity:n});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return n.isValidElement(t)?n.cloneElement(t,{onClick:function(e){t.props.onClick&&"function"==typeof t.props.onClick&&t.props.onClick(e),c()}}):null}function z(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(W,null!=r?r:Y)}var J=function(){var e=s(b.mark((function e(t){var r,n;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.options,n=t.fetch,!t.input.cartId){e.next=7;break}return e.next=4,n(r);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=null;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),$=function(e){var t;return null==(t=e.cart)?void 0:t.useCart},K=function(e){var t,r=D($),n=I().cartCookie,o=null!=(t=r.fetcher)?t:J;return A(p({},r,{fetcher:function(e){return e.input.cartId=c.get(n),o(e)}}))(e)};function X(e){var t=e.amount;return new Intl.NumberFormat(e.locale,{style:"currency",currency:e.currencyCode}).format(t)}function Z(e){var t=null!=e?e:{},n=t.amount,o=t.baseAmount,a=t.currencyCode,i=I().locale,c=r.useMemo((function(){return"number"==typeof n&&a?o?function(e){var t=e.amount,r=e.baseAmount,n=e.currencyCode,o=e.locale,a=r>t,i=new Intl.NumberFormat(o,{style:"percent"}),c=a?i.format((r-t)/r):null;return{price:X({amount:t,currencyCode:n,locale:o}),basePrice:a?X({amount:r,currencyCode:n,locale:o}):null,discount:c}}({amount:n,baseAmount:o,currencyCode:a,locale:i}):X({amount:n,currencyCode:a,locale:i}):""}),[n,o,a]);return"string"==typeof c?{price:c}:c}var ee={name:"plasmic-commerce-cart",displayName:"Cart",props:{field:{type:"choice",options:["Size","Total Price"]},hideIfIsEmpty:{type:"boolean",defaultValue:!1,description:"You can hide this component if the cart is empty"}},importPath:"@plasmicpkgs/commerce",importName:"CartComponent"};function te(e){var t,r,o,a,i=e.className,c=e.field,l=e.hideIfIsEmpty,u=K().data,s=Z({amount:null!=(t=null==u?void 0:u.totalPrice)?t:0,currencyCode:null!=(r=null==u?void 0:u.currency.code)?r:"USD"}).price;return c?("Size"===c?o=null!=(a=null==u?void 0:u.lineItems.length)?a:0:"Total Price"===c&&(o=null!=s?s:0),l&&0===o?null:n.createElement("span",{className:i},o)):n.createElement("p",null,"You must set the field prop")}function re(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(te,null!=r?r:ee)}var ne=q,oe=function(e){var t;return null==(t=e.site)?void 0:t.useCategories},ae=function(e){var t=D(oe);return A(p({fetcher:ne},t))(e)},ie={name:"plasmic-commerce-category-collection",displayName:"Category Collection",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-category-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-collection"}],styles:{width:"100%",minWidth:0}}]},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No collection found!"}},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},category:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.categories.map((function(e){var t;return{label:""+" ".repeat(null!=(t=e.depth)?t:0)+e.name,value:e.id}})))?r:[]}},noLayout:{type:"boolean",displayName:"No layout",description:"Do not render a container element."},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every category."}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr",gridRowGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"CategoryCollection",providesData:!0};function ce(e){var t,r=e.children,a=e.noLayout,i=e.noAutoRepeat,c=e.className,l=e.loadingMessage,u=e.emptyMessage,s=e.category,p=e.setControlContextData,d=n.useContext(o.PlasmicCanvasContext),m=ae(),f=m.data,y=m.isLoading,v=ae({categoryId:s,addIsEmptyField:!!d}),h=v.data,g=v.isLoading;f&&(null==p||p({categories:f}));var x=null==h?void 0:h.find((function(e){return!e.isEmpty})),C=null!=(t=null==h?void 0:h.findIndex((function(e){return!e.isEmpty})))?t:-1,b=i?r:null==h?void 0:h.map((function(e,t){return n.createElement(k,{category:e,key:e.id},o.repeatedElement(t<C?t+1:t===C?0:t,r))}));return[y,g].includes(!0)?n.isValidElement(l)?l:null:h&&0!==h.length?n.createElement(o.DataProvider,{name:"categories",data:h},n.createElement(N.Provider,{value:null!=x?x:h[0]},a?n.createElement(n.Fragment,null,b):n.createElement("div",{className:c},b))):n.isValidElement(u)?u:null}function le(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ce,null!=r?r:ie)}var ue={name:"plasmic-commerce-category-field",displayName:"Category Field",props:{field:{type:"choice",options:["id","name","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"CategoryField"};function se(e){var t=e.className,r=e.field,o=L();return r?n.createElement("span",{className:t},o?o[r]:"Category field placeholder"):n.createElement("span",null,"You must set the field prop")}function pe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(se,null!=r?r:ue)}var de={name:"plasmic-commerce-category-link",displayName:"Category Link",props:{children:"slot",linkDest:{type:"string",defaultValueHint:"category/{slug}",description:"Set the link destination. You can use {slug} to replace by the category slug"}},importPath:"@plasmicpkgs/commerce",importName:"CategoryLink"};function me(e){var t=e.className,r=e.children,o=e.linkDest,a=L();return n.createElement("a",{className:t,href:function(e){var t;if(e){for(var r,n=/{[^}]*}/,o=new RegExp(n,"g"),i=null!=(t=e.match(o))?t:[],c=e,l=x(i);!(r=l()).done;){var u=r.value.slice(1,-1);if(!a||!(u in a))return;c=c.replace(n,a[u])}return c}}(o),style:{color:"inherit",textDecoration:"inherit"}},r)}function fe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(me,null!=r?r:de)}var ye={name:"plasmic-commerce-category-media",displayName:"Category Media",props:{mediaIndex:"number"},importPath:"@plasmicpkgs/commerce",importName:"CategoryMedia"},ve=n.forwardRef((function(e,t){var r,o=e.className,a=e.mediaIndex,i=void 0===a?0:a,c=L(),l=null!=c&&c.images?c.images[i]:void 0;return n.createElement("img",{ref:t,alt:(null==c?void 0:c.name)||"Category Image",src:null!=(r=null==l?void 0:l.url)?r:"",loading:"lazy",className:o})}));function he(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ve,null!=r?r:ye)}var ge=q,xe=function(e){var t;return null==(t=e.products)?void 0:t.useProduct},Ce=function(e){var t=D(xe);return A(p({fetcher:ge},t))(e)},be=q,Pe=function(e){var t;return null==(t=e.products)?void 0:t.useSearch},Ee=function(e){var t=D(Pe);return A(p({fetcher:be},t))(e)},we={name:"plasmic-commerce-product-box",displayName:"Product Box",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-text-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-media"}],styles:{width:"100%",minWidth:0}}]},noLayout:"boolean",id:{type:"cardPicker",modalTitle:"Product",onSearch:function(e,t){return null==t?void 0:t.onSearch},options:function(e,t){var r;return null!=(r=null==t?void 0:t.products.map((function(e){var t;return{imgUrl:e.images[0].url,value:e.id,label:null!=(t=e.slug)?t:e.name,footer:n.createElement("div",null,n.createElement("div",null,n.createElement("strong",null,e.name)),n.createElement("div",null,e.slug))}})))?r:[]}}},importPath:"@plasmicpkgs/commerce",importName:"ProductBox",providesData:!0};function Ne(e){var t=e.className,r=e.children,o=e.noLayout,a=e.id,i=e.setControlContextData,c=n.useState(""),u=c[0],s=c[1],p=Ee({search:""!==u?u:void 0}).data,d=n.useCallback(l((function(e){return s(e)}),300),[]);p&&(null==i||i({products:p.products,onSearch:d}));var m=Ce({id:a}),f=m.data,y=m.error,v=m.isLoading;if(!a)return n.createElement("span",null,"You must set the id prop");if(y)throw new _({message:y.message,code:y.code});if(v)return n.createElement("span",null,"Loading...");if(!f)throw new Error("Product not found!");var h=n.createElement(E,{product:f},r);return o?n.createElement(n.Fragment,null,h):n.createElement("div",{className:t},h)}function ke(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ne,null!=r?r:we)}var Le=q,Me=function(e){var t;return null==(t=e.site)?void 0:t.useBrands},Se=function(e){var t=D(Me);return A(p({fetcher:Le},t))(e)},Ve={name:"plasmic-commerce-product-collection",displayName:"Product Collection",props:{children:{type:"slot",defaultValue:[{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-text-field",props:{field:"name"}},{type:"component",name:"plasmic-commerce-product-media"}],styles:{width:"100%",minWidth:0}}]},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No product found!"}},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},count:"number",category:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.categories.map((function(e){var t;return{label:""+" ".repeat(null!=(t=e.depth)?t:0)+e.name,value:e.id}})))?r:[]},defaultValueHint:function(e,t){var r;return null==t||null==(r=t.categoryCtx)?void 0:r.name},readOnly:function(e,t){return!(null==t||!t.categoryCtx)}},includeSubCategories:{type:"boolean",hidden:function(e,t){var r;return!(null!=t&&null!=(r=t.features)&&r.includeSubCategories)}},brand:{type:"choice",options:function(e,t){var r;return null!=(r=null==t?void 0:t.brands.map((function(e){return{label:e.name,value:e.entityId}})))?r:[]}},search:{type:"string"},sort:{type:"choice",options:[{label:"Trending",value:"trending-desc"},{label:"New Arrivals",value:"latest-desc"},{label:"Price: Low to High",value:"price-asc"},{label:"Price: High to Low",value:"price-desc"}]},noLayout:{type:"boolean",displayName:"No layout",description:"Do not render a container element."},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every category."}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductCollection",providesData:!0};function Oe(e){var t,a=e.className,i=e.children,c=e.count,l=e.category,u=e.includeSubCategories,s=e.brand,p=e.noLayout,d=e.noAutoRepeat,m=e.setControlContextData,f=e.emptyMessage,y=e.loadingMessage,v=e.search,h=e.sort,g=ae(),x=g.data,C=g.isLoading,b=Se(),P=b.data,w=b.isLoading,k=L(),M=Ee({categoryId:null!=(t=null==k?void 0:k.id)?t:l,brandId:s,count:c,categories:null!=x?x:[],includeSubCategories:u,search:v,sort:h}),S=M.data,V=M.isLoading,O=I().providerRef.current.extraFeatures,_=r.useContext(N);x&&P&&(null==m||m({categories:x,brands:P,features:O,categoryCtx:_}));var F=d?i:null==S?void 0:S.products.map((function(e,t){return n.createElement(E,{product:e,key:e.id},o.repeatedElement(t,i))}));return[V,w,C].includes(!0)?n.isValidElement(y)?y:null:S&&0!==S.products.length?n.createElement(o.DataProvider,{name:"products",data:null==S?void 0:S.products},p?n.createElement(n.Fragment,null,F):n.createElement("div",{className:a},F)):n.isValidElement(f)?f:null}function Ie(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Oe,null!=r?r:Ve)}var _e={name:"plasmic-commerce-product-link",displayName:"Product Link",props:{children:"slot",linkDest:{type:"string",defaultValueHint:"products/{slug}",description:"Set the link destination. You can use {slug} to replace by the product slug"}},importPath:"@plasmicpkgs/commerce",importName:"ProductLink"};function Fe(e){var t=e.className,r=e.children,o=e.linkDest,a=w();return n.createElement("a",{className:t,href:function(e){var t;if(e){for(var r,n=/{[^}]*}/,o=new RegExp(n,"g"),i=null!=(t=e.match(o))?t:[],c=e,l=x(i);!(r=l()).done;){var u=r.value.slice(1,-1);if(!a||!(u in a))return;c=c.replace(n,a[u])}return c}}(o),style:{color:"inherit",textDecoration:"inherit"}},r)}function je(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Fe,null!=r?r:_e)}var Te={name:"plasmic-commerce-product-media",displayName:"Product Media",props:{mediaIndex:{type:"number",min:0,hidden:function(e,t){return!(null==t||!t.inMediaContext)}}},importPath:"@plasmicpkgs/commerce",importName:"ProductMedia"},Re=n.forwardRef((function(e,t){var r,a=e.className,i=e.mediaIndex,c=void 0===i?0:i,l=e.setControlContextData,u=w(),s=o.useSelector("currentMedia");null==l||l({inMediaContext:void 0!==s});var p=null==u?void 0:u.images[null!=s?s:c];return n.createElement("img",{ref:t,alt:(null==u?void 0:u.name)||"Product Image",src:u?null!=(r=null==p?void 0:p.url)?r:"":"https://static1.plasmic.app/commerce/lightweight-jacket-0.png",loading:"lazy",className:a})}));function De(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Re,null!=r?r:Te)}var Ae={name:"plasmic-commerce-product-media-collection",displayName:"Product Media Collection",props:{media:{type:"slot",defaultValue:{type:"component",name:"plasmic-commerce-product-media"},allowedComponents:["plasmic-commerce-product-media"]}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductMediaCollection",providesData:!0};function Be(e){var t=e.media,r=e.className,a=w();return n.createElement("div",{className:r},null==a?void 0:a.images.map((function(e,r){return o.repeatedElement(r,n.createElement(M,{mediaIndex:r,children:t}))})))}function qe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Be,null!=r?r:Ae)}var Ge=function(e,t){var r,n;return null!=(r=null==(n=e.variants.find((function(e){return e.id===t})))?void 0:n.price)?r:e.price.value},He={name:"plasmic-commerce-product-price",displayName:"Product Price",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductPriceComponent"};function Qe(e){var t,r=e.className,o=w(),i=a.useFormContext(),c=null==i?void 0:i.watch("ProductVariant",null!=(t=o.price)?t:""),l=Z({amount:o?Ge(o,c):0,currencyCode:o?o.price.currencyCode:"USD"});return n.createElement("span",{className:r},l.price)}function Ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Qe,null!=r?r:He)}var Ye={name:"plasmic-commerce-product-quantity",displayName:"Product Quantity",props:{children:{type:"slot",defaultValue:[{type:"input",attrs:{value:"1"}}]}},importPath:"@plasmicpkgs/commerce",importName:"ProductQuantity"};function We(e){var t=e.className,r=e.children,o=a.useFormContext();return n.createElement("div",{className:t},n.createElement(a.Controller,{name:"ProductQuantity",defaultValue:1,control:null==o?void 0:o.control,render:function(e){var t=e.field;return n.isValidElement(r)?n.cloneElement(r,p({},r.props,t,{name:"ProductQuantity"})):n.createElement(n.Fragment,null)}}))}function ze(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(We,null!=r?r:Ye)}var Je={name:"plasmic-commerce-product-slider",displayName:"Product Slider",providesData:!0,props:{thumbsVisible:{type:"number",description:"Number of thumbs visible",defaultValue:4,defaultValueHint:4},slideContainer:{type:"slot",defaultValue:{type:"vbox",children:[{type:"component",name:"plasmic-commerce-product-media"}]}},thumbsContainer:{type:"slot",defaultValue:{type:"hbox",children:[{type:"component",name:"plasmic-commerce-product-media"}]}},slideSelected:{type:"number",defaultValue:0,defaultValueHint:0,description:"Current slide selected"}},importPath:"@plasmicpkgs/commerce",importName:"ProductSlider"};function $e(e){var t=e.className,r=e.slideContainer,a=e.thumbsContainer,i=e.thumbsVisible,c=void 0===i?4:i,l=e.slideSelected,u=void 0===l?0:l,s=w(),p=n.useState(u),d=p[0],m=p[1],f=Math.max(0,s.images.length-c),y=Math.min(f,Math.max(0,d-1));return n.createElement("div",{className:t},n.createElement(M,{mediaIndex:d,children:r}),n.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat("+c+", 1fr)"}},s.images.slice(y,y+c).map((function(e,t){return o.repeatedElement(t,n.createElement(M,{mediaIndex:y+t,children:a,onClick:function(){return m(y+t)}}))}))))}function Ke(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}($e,null!=r?r:Je)}var Xe={name:"plasmic-commerce-product-text-field",displayName:"Product Text Field",props:{field:{type:"choice",options:["id","name","description","sku","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"ProductTextField"};function Ze(e){var t,r=e.className,o=e.field,a=w();return a?o?"description"===o?n.createElement("div",{className:r,dangerouslySetInnerHTML:{__html:null!=(t=a.descriptionHtml)?t:a.description}}):n.createElement("span",{className:r},a[o]):n.createElement("span",{className:r},"Unknown Product Field"):n.createElement("span",{className:r},"Fake Product Field")}function et(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ze,null!=r?r:Xe)}var tt={name:"plasmic-commerce-product-variant-picker",displayName:"Product Variant Picker",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductVariantPicker"};function rt(e){var t,r,o=e.className,i=w(),c=null!=(t=a.useFormContext())?t:a.useForm();return n.createElement(a.Controller,{name:"ProductVariant",control:null==c?void 0:c.control,defaultValue:null==i||null==(r=i.variants.find((function(e){return e.price===i.price.value})))?void 0:r.id,render:function(e){var t;return n.createElement("select",Object.assign({className:o},e.field),null!=(t=null==i?void 0:i.variants.map((function(e){return n.createElement("option",{value:e.id},e.name)})))?t:n.createElement("option",null,"Product Variant Placeholder"))}})}function nt(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(rt,null!=r?r:tt)}var ot=G,at=function(e){var t;return null==(t=e.cart)?void 0:t.useRemoveItem},it=G,ct=function(e){var t;return null==(t=e.cart)?void 0:t.useUpdateItem};exports.AddToCartButton=W,exports.CartComponent=te,exports.CartType={__proto__:null},exports.CategoryCollection=ce,exports.CategoryField=se,exports.CategoryLink=me,exports.CategoryMedia=ve,exports.CommerceError=_,exports.CoreCommerceProvider=O,exports.FetcherError=j,exports.ProductBox=Ne,exports.ProductCollection=Oe,exports.ProductLink=Fe,exports.ProductMedia=Re,exports.ProductMediaCollection=Be,exports.ProductPlaceholder=P,exports.ProductPriceComponent=Qe,exports.ProductQuantity=We,exports.ProductSlider=$e,exports.ProductTextField=Ze,exports.ProductTypes={__proto__:null},exports.ProductVariantPicker=rt,exports.SiteTypes={__proto__:null},exports.ValidationError=F,exports.addToCartButtonMeta=Y,exports.cartMeta=ee,exports.categoryCollectionMeta=ie,exports.categoryFieldMeta=ue,exports.categoryLinkMeta=de,exports.categoryMediaMeta=ye,exports.fetcher=be,exports.getCommerceProvider=function(e){return function(t){var r=t.children,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}(t,S);return n.createElement(O,{provider:p({},e,o)},r)}},exports.productBoxMeta=we,exports.productCollectionMeta=Ve,exports.productLinkMeta=_e,exports.productMediaCollectionMeta=Ae,exports.productMediaMeta=Te,exports.productPriceMeta=He,exports.productQuantityMeta=Ye,exports.productSliderMeta=Je,exports.productTextFieldMeta=Xe,exports.productVariantPickerMeta=tt,exports.registerAddToCartButton=z,exports.registerAll=function(e){Ie(e),et(e),Ue(e),De(e),qe(e),re(e),z(e),ze(e),nt(e),ke(e),Ke(e),je(e),le(e),pe(e),fe(e),he(e)},exports.registerCart=re,exports.registerCategoryCollection=le,exports.registerCategoryField=pe,exports.registerCategoryLink=fe,exports.registerCategoryMedia=he,exports.registerProductBox=ke,exports.registerProductCollection=Ie,exports.registerProductLink=je,exports.registerProductMedia=De,exports.registerProductMediaCollection=qe,exports.registerProductPrice=Ue,exports.registerProductQuantity=ze,exports.registerProductSlider=Ke,exports.registerProductVariantPicker=nt,exports.registerTextField=et,exports.useAddItem=U,exports.useBrands=Se,exports.useCart=K,exports.useCategories=ae,exports.useCommerce=I,exports.useProduct=Ce,exports.useRemoveItem=function(e){var t=D(at);return B(p({fetcher:ot},t))(e)},exports.useSearch=Ee,exports.useUpdateItem=function(e){var t=D(ct);return B(p({fetcher:it},t))(e)};
2
2
  //# sourceMappingURL=commerce.cjs.production.min.js.map