@plasmicpkgs/commerce 0.0.41 → 0.0.44

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"));function l(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 u(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){l(a,n,o,i,c,"next",e)}function c(e){l(a,n,o,i,c,"throw",e)}i(void 0)}))}}function s(){return(s=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 p(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){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 y(e,t,r){return(y=f()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&m(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 y(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,e)})(e)}function v(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 g(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 v(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)?v(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 x(e,t){return e(t={exports:{}},t.exports),t.exports}var C=x((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 w(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,h=y&&y(y(E([])));h&&h!==t&&r.call(h,o)&&(f=h);var v=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 w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function E(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:k}}function k(){return{value:void 0,done:!0}}return d.prototype=m,c(v,"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(v),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(v),c(v,i,"Generator"),c(v,o,(function(){return this})),c(v,"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=E,w.prototype={constructor:w,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:E(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)}})),b={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 P(e){var t=e.product,r=e.children,i=a.useForm();return n.createElement(o.DataProvider,{name:"product",data:t,key:t.id},n.createElement(a.FormProvider,Object.assign({},i),r))}var w=function(){var e=o.useSelector("product");return null!=e?e:b},E=n.createContext(void 0);function k(e){var t=e.category;return n.createElement(o.DataProvider,{name:"category",data:t,key:t.id},e.children)}var N=function(){return o.useSelector("category")};function L(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 M=["children"],V=r.createContext({});function S(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 O(){return r.useContext(V)}var I=function(e){function t(t){var r,n=t.message,o=t.code,a=t.errors,i=n?s({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 p(t,e),t}(h(Error)),_=function(e){function t(t){var r;return(r=e.call(this,t)||this).code="validation_error",r}return p(t,e),t}(I),F=function(e){function t(t){var r;return(r=e.call(this,t)||this).status=t.status,r}return p(t,e),t}(I);function j(){var e,t=O();return null!=(e=t.providerRef.current.fetcher)?e:t.fetcherRef.current}function T(e){return e(O().providerRef.current)}function R(e){var t=j();return e.useHook({useData:function(r){var n,o,a,c,l,s,p;return o=e,a=null!=(n=null==r?void 0:r.input)?n:[],c=t,l=null==r?void 0:r.swrOptions,s=Array.isArray(a)?a:Object.entries(a),"isLoading"in(p=i.useMutablePlasmicQueryData((function(){var e=o.fetchOptions;return e?[e.url,e.query,e.method].concat(s.map((function(e){return e[1]}))):null}),function(){var e=u(C.mark((function e(t,r,n){var a,i,l,u=arguments;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,a=u.length,i=new Array(a>3?a-3:0),l=3;l<a;l++)i[l-3]=u[l];return e.next=4,o.fetcher({options:{url:t,query:r,method:n},input:i.reduce((function(e,t,r){return e[s[r][0]]=t,e}),{}),fetch:c});case 4:return e.abrupt("return",e.sent);case 7:throw e.prev=7,e.t0=e.catch(0),e.t0 instanceof I||console.error(e.t0),e.t0;case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t,r,n){return e.apply(this,arguments)}}(),l))||Object.defineProperty(p,"isLoading",{get:function(){return void 0===p.data},enumerable:!0}),p}})}function A(e){var t=j();return e.useHook({fetch:r.useCallback((function(r){return e.fetcher({input:(void 0===r?{}:r).input,options:e.fetchOptions,fetch:t})}),[t,e.fetchOptions])})}var D=function(e){return(0,e.fetch)(e.options)},B=function(e){return(0,e.fetch)(s({},e.options,{body:e.input}))},G=B,q=function(e){var t;return null==(t=e.cart)?void 0:t.useAddItem},H=function(){var e=T(q);return A(s({fetcher:G},e)).apply(void 0,arguments)},Q={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 Y(e){var t=e.children,r=w(),o=a.useFormContext(),i=H(),c=function(){var e=u(C.mark((function e(){var t,n,a,c;return C.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 I({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 U(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Y,null!=r?r:Q)}var W=function(){var e=u(C.mark((function e(t){var r,n;return C.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)}}(),z=function(e){var t;return null==(t=e.cart)?void 0:t.useCart},J=function(e){var t,r=T(z),n=O().cartCookie,o=null!=(t=r.fetcher)?t:W;return R(s({},r,{fetcher:function(e){return e.input.cartId=c.get(n),o(e)}}))(e)};function $(e){var t=e.amount;return new Intl.NumberFormat(e.locale,{style:"currency",currency:e.currencyCode}).format(t)}function K(e){var t=null!=e?e:{},n=t.amount,o=t.baseAmount,a=t.currencyCode,i=O().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:$({amount:t,currencyCode:n,locale:o}),basePrice:a?$({amount:r,currencyCode:n,locale:o}):null,discount:c}}({amount:n,baseAmount:o,currencyCode:a,locale:i}):$({amount:n,currencyCode:a,locale:i}):""}),[n,o,a]);return"string"==typeof c?{price:c}:c}var X={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 Z(e){var t,r,o,a,i=e.className,c=e.field,l=e.hideIfIsEmpty,u=J().data,s=K({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 ee(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Z,null!=r?r:X)}var te=D,re=function(e){var t;return null==(t=e.site)?void 0:t.useCategories},ne=function(e){var t=T(re);return R(s({fetcher:te},t))(e)},oe={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}}]},noLayout:{type:"boolean"},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:[]}}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr",gridRowGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"CategoryCollection"};function ae(e){var t=e.children,r=e.noLayout,a=e.className,i=e.loadingMessage,c=e.emptyMessage,l=e.category,u=e.setControlContextData,s=n.useContext(o.PlasmicCanvasContext),p=ne(),d=p.data,m=p.isLoading,f=ne({categoryId:l,addIsEmptyField:!!s}),y=f.data,h=f.isLoading;d&&(null==u||u({categories:d}));var v=null==y?void 0:y.find((function(e){return!e.isEmpty})),g=null==y?void 0:y.map((function(e,r){return n.createElement(k,{category:e,key:e.id},o.repeatedElement(v?e===v:0===r,t))}));return[m,h].includes(!0)?n.isValidElement(i)?i:null:y&&0!==y.length?n.createElement(E.Provider,{value:null!=v?v:y[0]},r?n.createElement(n.Fragment,null,g):n.createElement("div",{className:a},g)):n.isValidElement(c)?c:null}function ie(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ae,null!=r?r:oe)}var ce={name:"plasmic-commerce-category-field",displayName:"Category Field",props:{field:{type:"choice",options:["id","name","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"CategoryField"};function le(e){var t=e.className,r=e.field,o=N();return r?n.createElement("span",{className:t},o?o[r]:"Category field placeholder"):n.createElement("span",null,"You must set the field prop")}function ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(le,null!=r?r:ce)}var se={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 pe(e){var t=e.className,r=e.children,o=e.linkDest,a=N();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=g(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 de(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(pe,null!=r?r:se)}var me={name:"plasmic-commerce-category-media",displayName:"Category Media",props:{mediaIndex:"number"},importPath:"@plasmicpkgs/commerce",importName:"CategoryMedia"},fe=n.forwardRef((function(e,t){var r,o=e.className,a=e.mediaIndex,i=void 0===a?0:a,c=N(),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 ye(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(fe,null!=r?r:me)}var he=D,ve=function(e){var t;return null==(t=e.products)?void 0:t.useProduct},ge=function(e){var t=T(ve);return R(s({fetcher:he},t))(e)},xe={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:"string",description:"Fetch a product by its slug or ID"}},importPath:"@plasmicpkgs/commerce",importName:"ProductBox"};function Ce(e){var t=e.className,r=e.children,o=e.noLayout,a=e.id,i=ge({id:a}),c=i.data,l=i.error,u=i.isLoading;if(!a)return n.createElement("span",null,"You must set the id prop");if(l)throw new I({message:l.message,code:l.code});if(u)return n.createElement("span",null,"Loading...");if(!c)throw new Error("Product not found!");var s=n.createElement(P,{product:c},r);return o?n.createElement(n.Fragment,null,s):n.createElement("div",{className:t},s)}function be(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ce,null!=r?r:xe)}var Pe=D,we=function(e){var t;return null==(t=e.products)?void 0:t.useSearch},Ee=function(e){var t=T(we);return R(s({fetcher:Pe},t))(e)},ke=D,Ne=function(e){var t;return null==(t=e.site)?void 0:t.useBrands},Le=function(e){var t=T(Ne);return R(s({fetcher:ke},t))(e)},Me={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:"boolean"},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductCollection"};function Ve(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.setControlContextData,m=e.emptyMessage,f=e.loadingMessage,y=e.search,h=e.sort,v=ne(),g=v.data,x=v.isLoading,C=Le(),b=C.data,w=C.isLoading,k=N(),L=Ee({categoryId:null!=(t=null==k?void 0:k.id)?t:l,brandId:s,count:c,categories:null!=g?g:[],includeSubCategories:u,search:y,sort:h}),M=L.data,V=L.isLoading,S=O().providerRef.current.extraFeatures,I=r.useContext(E);g&&b&&(null==d||d({categories:g,brands:b,features:S,categoryCtx:I}));var _=null==M?void 0:M.products.map((function(e,t){return n.createElement(P,{product:e,key:e.id},o.repeatedElement(0===t,i))}));return[V,w,x].includes(!0)?n.isValidElement(f)?f:null:M&&0!==M.products.length?p?n.createElement(n.Fragment,null,_):n.createElement("div",{className:a},_):n.isValidElement(m)?m:null}function Se(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ve,null!=r?r:Me)}var Oe={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 Ie(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=g(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 _e(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ie,null!=r?r:Oe)}var Fe={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"},je=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 Te(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(je,null!=r?r:Fe)}var Re={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"};function Ae(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(0===r,n.createElement(L,{mediaIndex:r,children:t}))})))}function De(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ae,null!=r?r:Re)}var Be=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},Ge={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=K({amount:o?Be(o,c):0,currencyCode:o?o.price.currencyCode:"USD"});return n.createElement("span",{className:r},l.price)}function He(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(qe,null!=r?r:Ge)}var Qe={name:"plasmic-commerce-product-quantity",displayName:"Product Quantity",props:{children:{type:"slot",defaultValue:[{type:"input",attrs:{value:"1"}}]}},importPath:"@plasmicpkgs/commerce",importName:"ProductQuantity"};function Ye(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,s({},r.props,t,{name:"ProductQuantity"})):n.createElement(n.Fragment,null)}}))}function Ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ye,null!=r?r:Qe)}var We={name:"plasmic-commerce-product-slider",displayName:"Product Slider",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 ze(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(L,{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(0===t,n.createElement(L,{mediaIndex:y+t,children:a,onClick:function(){return m(y+t)}}))}))))}function Je(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ze,null!=r?r:We)}var $e={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 Ke(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 Xe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ke,null!=r?r:$e)}var Ze={name:"plasmic-commerce-product-variant-picker",displayName:"Product Variant Picker",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductVariantPicker"};function et(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 tt(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(et,null!=r?r:Ze)}var rt=B,nt=function(e){var t;return null==(t=e.cart)?void 0:t.useRemoveItem},ot=B,at=function(e){var t;return null==(t=e.cart)?void 0:t.useUpdateItem};exports.AddToCartButton=Y,exports.CartComponent=Z,exports.CartType={__proto__:null},exports.CategoryCollection=ae,exports.CategoryField=le,exports.CategoryLink=pe,exports.CategoryMedia=fe,exports.CommerceError=I,exports.CoreCommerceProvider=S,exports.FetcherError=F,exports.ProductBox=Ce,exports.ProductCollection=Ve,exports.ProductLink=Ie,exports.ProductMedia=je,exports.ProductMediaCollection=Ae,exports.ProductPlaceholder=b,exports.ProductPriceComponent=qe,exports.ProductQuantity=Ye,exports.ProductSlider=ze,exports.ProductTextField=Ke,exports.ProductTypes={__proto__:null},exports.ProductVariantPicker=et,exports.SiteTypes={__proto__:null},exports.ValidationError=_,exports.addToCartButtonMeta=Q,exports.cartMeta=X,exports.categoryCollectionMeta=oe,exports.categoryFieldMeta=ce,exports.categoryLinkMeta=se,exports.categoryMediaMeta=me,exports.fetcher=Pe,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,M);return n.createElement(S,{provider:s({},e,o)},r)}},exports.productBoxMeta=xe,exports.productCollectionMeta=Me,exports.productLinkMeta=Oe,exports.productMediaCollectionMeta=Re,exports.productMediaMeta=Fe,exports.productPriceMeta=Ge,exports.productQuantityMeta=Qe,exports.productSliderMeta=We,exports.productTextFieldMeta=$e,exports.productVariantPickerMeta=Ze,exports.registerAddToCartButton=U,exports.registerAll=function(e){Se(e),Xe(e),He(e),Te(e),De(e),ee(e),U(e),Ue(e),tt(e),be(e),Je(e),_e(e),ie(e),ue(e),de(e),ye(e)},exports.registerCart=ee,exports.registerCategoryCollection=ie,exports.registerCategoryField=ue,exports.registerCategoryLink=de,exports.registerCategoryMedia=ye,exports.registerProductBox=be,exports.registerProductCollection=Se,exports.registerProductLink=_e,exports.registerProductMedia=Te,exports.registerProductMediaCollection=De,exports.registerProductPrice=He,exports.registerProductQuantity=Ue,exports.registerProductSlider=Je,exports.registerProductVariantPicker=tt,exports.registerTextField=Xe,exports.useAddItem=H,exports.useBrands=Le,exports.useCart=J,exports.useCategories=ne,exports.useCommerce=O,exports.useProduct=ge,exports.useRemoveItem=function(e){var t=T(nt);return A(s({fetcher:rt},t))(e)},exports.useSearch=Ee,exports.useUpdateItem=function(e){var t=T(at);return A(s({fetcher:ot},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"));function l(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 u(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){l(a,n,o,i,c,"next",e)}function c(e){l(a,n,o,i,c,"throw",e)}i(void 0)}))}}function s(){return(s=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 p(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){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 y(e,t,r){return(y=f()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&m(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 y(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,e)})(e)}function v(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 g(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 v(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)?v(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 x(e,t){return e(t={exports:{}},t.exports),t.exports}var C=x((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 w(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,h=y&&y(y(E([])));h&&h!==t&&r.call(h,o)&&(f=h);var v=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 w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function E(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:k}}function k(){return{value:void 0,done:!0}}return d.prototype=m,c(v,"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(v),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(v),c(v,i,"Generator"),c(v,o,(function(){return this})),c(v,"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=E,w.prototype={constructor:w,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:E(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)}})),b={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 P(e){var t=e.product,r=e.children,i=a.useForm();return n.createElement(o.DataProvider,{name:"product",data:t,key:t.id},n.createElement(a.FormProvider,Object.assign({},i),r))}var w=function(){var e=o.useSelector("product");return null!=e?e:b},E=n.createContext(void 0);function k(e){var t=e.category;return n.createElement(o.DataProvider,{name:"category",data:t,key:t.id},e.children)}var N=function(){return o.useSelector("category")};function L(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 M=["children"],V=r.createContext({});function S(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 O=function(e){function t(t){var r,n=t.message,o=t.code,a=t.errors,i=n?s({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 p(t,e),t}(h(Error)),_=function(e){function t(t){var r;return(r=e.call(this,t)||this).code="validation_error",r}return p(t,e),t}(O),F=function(e){function t(t){var r;return(r=e.call(this,t)||this).status=t.status,r}return p(t,e),t}(O);function j(){var e,t=I();return null!=(e=t.providerRef.current.fetcher)?e:t.fetcherRef.current}function T(e){return e(I().providerRef.current)}function R(e){var t=j();return e.useHook({useData:function(r){var n,o,a,c,l,s,p;return o=e,a=null!=(n=null==r?void 0:r.input)?n:[],c=t,l=null==r?void 0:r.swrOptions,s=Array.isArray(a)?a:Object.entries(a),"isLoading"in(p=i.useMutablePlasmicQueryData((function(){var e=o.fetchOptions;return e?[e.url,e.query,e.method].concat(s.map((function(e){return e[1]}))):null}),function(){var e=u(C.mark((function e(t,r,n){var a,i,l,u=arguments;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,a=u.length,i=new Array(a>3?a-3:0),l=3;l<a;l++)i[l-3]=u[l];return e.next=4,o.fetcher({options:{url:t,query:r,method:n},input:i.reduce((function(e,t,r){return e[s[r][0]]=t,e}),{}),fetch:c});case 4:return e.abrupt("return",e.sent);case 7:throw e.prev=7,e.t0=e.catch(0),e.t0 instanceof O||console.error(e.t0),e.t0;case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t,r,n){return e.apply(this,arguments)}}(),l))||Object.defineProperty(p,"isLoading",{get:function(){return void 0===p.data},enumerable:!0}),p}})}function A(e){var t=j();return e.useHook({fetch:r.useCallback((function(r){return e.fetcher({input:(void 0===r?{}:r).input,options:e.fetchOptions,fetch:t})}),[t,e.fetchOptions])})}var D=function(e){return(0,e.fetch)(e.options)},B=function(e){return(0,e.fetch)(s({},e.options,{body:e.input}))},G=B,q=function(e){var t;return null==(t=e.cart)?void 0:t.useAddItem},H=function(){var e=T(q);return A(s({fetcher:G},e)).apply(void 0,arguments)},Q={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 Y(e){var t=e.children,r=w(),o=a.useFormContext(),i=H(),c=function(){var e=u(C.mark((function e(){var t,n,a,c;return C.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 O({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 U(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Y,null!=r?r:Q)}var W=function(){var e=u(C.mark((function e(t){var r,n;return C.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)}}(),z=function(e){var t;return null==(t=e.cart)?void 0:t.useCart},J=function(e){var t,r=T(z),n=I().cartCookie,o=null!=(t=r.fetcher)?t:W;return R(s({},r,{fetcher:function(e){return e.input.cartId=c.get(n),o(e)}}))(e)};function $(e){var t=e.amount;return new Intl.NumberFormat(e.locale,{style:"currency",currency:e.currencyCode}).format(t)}function K(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:$({amount:t,currencyCode:n,locale:o}),basePrice:a?$({amount:r,currencyCode:n,locale:o}):null,discount:c}}({amount:n,baseAmount:o,currencyCode:a,locale:i}):$({amount:n,currencyCode:a,locale:i}):""}),[n,o,a]);return"string"==typeof c?{price:c}:c}var X={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 Z(e){var t,r,o,a,i=e.className,c=e.field,l=e.hideIfIsEmpty,u=J().data,s=K({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 ee(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Z,null!=r?r:X)}var te=D,re=function(e){var t;return null==(t=e.site)?void 0:t.useCategories},ne=function(e){var t=T(re);return R(s({fetcher:te},t))(e)},oe={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}}]},noLayout:{type:"boolean"},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:[]}}},defaultStyles:{display:"grid",gridTemplateColumns:"1fr",gridRowGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"CategoryCollection"};function ae(e){var t,r=e.children,a=e.noLayout,i=e.className,c=e.loadingMessage,l=e.emptyMessage,u=e.category,s=e.setControlContextData,p=n.useContext(o.PlasmicCanvasContext),d=ne(),m=d.data,f=d.isLoading,y=ne({categoryId:u,addIsEmptyField:!!p}),h=y.data,v=y.isLoading;m&&(null==s||s({categories:m}));var g=null==h?void 0:h.find((function(e){return!e.isEmpty})),x=null!=(t=null==h?void 0:h.findIndex((function(e){return!e.isEmpty})))?t:-1,C=null==h?void 0:h.map((function(e,t){return n.createElement(k,{category:e,key:e.id},o.repeatedElement(t<x?t+1:t===x?0:t,r))}));return[f,v].includes(!0)?n.isValidElement(c)?c:null:h&&0!==h.length?n.createElement(E.Provider,{value:null!=g?g:h[0]},a?n.createElement(n.Fragment,null,C):n.createElement("div",{className:i},C)):n.isValidElement(l)?l:null}function ie(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ae,null!=r?r:oe)}var ce={name:"plasmic-commerce-category-field",displayName:"Category Field",props:{field:{type:"choice",options:["id","name","slug","path"]}},importPath:"@plasmicpkgs/commerce",importName:"CategoryField"};function le(e){var t=e.className,r=e.field,o=N();return r?n.createElement("span",{className:t},o?o[r]:"Category field placeholder"):n.createElement("span",null,"You must set the field prop")}function ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(le,null!=r?r:ce)}var se={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 pe(e){var t=e.className,r=e.children,o=e.linkDest,a=N();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=g(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 de(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(pe,null!=r?r:se)}var me={name:"plasmic-commerce-category-media",displayName:"Category Media",props:{mediaIndex:"number"},importPath:"@plasmicpkgs/commerce",importName:"CategoryMedia"},fe=n.forwardRef((function(e,t){var r,o=e.className,a=e.mediaIndex,i=void 0===a?0:a,c=N(),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 ye(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(fe,null!=r?r:me)}var he=D,ve=function(e){var t;return null==(t=e.products)?void 0:t.useProduct},ge=function(e){var t=T(ve);return R(s({fetcher:he},t))(e)},xe={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:"string",description:"Fetch a product by its slug or ID"}},importPath:"@plasmicpkgs/commerce",importName:"ProductBox"};function Ce(e){var t=e.className,r=e.children,o=e.noLayout,a=e.id,i=ge({id:a}),c=i.data,l=i.error,u=i.isLoading;if(!a)return n.createElement("span",null,"You must set the id prop");if(l)throw new O({message:l.message,code:l.code});if(u)return n.createElement("span",null,"Loading...");if(!c)throw new Error("Product not found!");var s=n.createElement(P,{product:c},r);return o?n.createElement(n.Fragment,null,s):n.createElement("div",{className:t},s)}function be(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ce,null!=r?r:xe)}var Pe=D,we=function(e){var t;return null==(t=e.products)?void 0:t.useSearch},Ee=function(e){var t=T(we);return R(s({fetcher:Pe},t))(e)},ke=D,Ne=function(e){var t;return null==(t=e.site)?void 0:t.useBrands},Le=function(e){var t=T(Ne);return R(s({fetcher:ke},t))(e)},Me={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:"boolean"},defaultStyles:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gridRowGap:"8px",gridColumnGap:"8px",padding:"8px",maxWidth:"100%"},importPath:"@plasmicpkgs/commerce",importName:"ProductCollection"};function Ve(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.setControlContextData,m=e.emptyMessage,f=e.loadingMessage,y=e.search,h=e.sort,v=ne(),g=v.data,x=v.isLoading,C=Le(),b=C.data,w=C.isLoading,k=N(),L=Ee({categoryId:null!=(t=null==k?void 0:k.id)?t:l,brandId:s,count:c,categories:null!=g?g:[],includeSubCategories:u,search:y,sort:h}),M=L.data,V=L.isLoading,S=I().providerRef.current.extraFeatures,O=r.useContext(E);g&&b&&(null==d||d({categories:g,brands:b,features:S,categoryCtx:O}));var _=null==M?void 0:M.products.map((function(e,t){return n.createElement(P,{product:e,key:e.id},o.repeatedElement(t,i))}));return[V,w,x].includes(!0)?n.isValidElement(f)?f:null:M&&0!==M.products.length?p?n.createElement(n.Fragment,null,_):n.createElement("div",{className:a},_):n.isValidElement(m)?m:null}function Se(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ve,null!=r?r:Me)}var Ie={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 Oe(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=g(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 _e(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Oe,null!=r?r:Ie)}var Fe={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"},je=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 Te(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(je,null!=r?r:Fe)}var Re={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"};function Ae(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(L,{mediaIndex:r,children:t}))})))}function De(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ae,null!=r?r:Re)}var Be=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},Ge={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=K({amount:o?Be(o,c):0,currencyCode:o?o.price.currencyCode:"USD"});return n.createElement("span",{className:r},l.price)}function He(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(qe,null!=r?r:Ge)}var Qe={name:"plasmic-commerce-product-quantity",displayName:"Product Quantity",props:{children:{type:"slot",defaultValue:[{type:"input",attrs:{value:"1"}}]}},importPath:"@plasmicpkgs/commerce",importName:"ProductQuantity"};function Ye(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,s({},r.props,t,{name:"ProductQuantity"})):n.createElement(n.Fragment,null)}}))}function Ue(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ye,null!=r?r:Qe)}var We={name:"plasmic-commerce-product-slider",displayName:"Product Slider",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 ze(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(L,{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(L,{mediaIndex:y+t,children:a,onClick:function(){return m(y+t)}}))}))))}function Je(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(ze,null!=r?r:We)}var $e={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 Ke(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 Xe(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(Ke,null!=r?r:$e)}var Ze={name:"plasmic-commerce-product-variant-picker",displayName:"Product Variant Picker",props:{},importPath:"@plasmicpkgs/commerce",importName:"ProductVariantPicker"};function et(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 tt(e,r){!function(){e?e.registerComponent.apply(e,arguments):t.apply(void 0,arguments)}(et,null!=r?r:Ze)}var rt=B,nt=function(e){var t;return null==(t=e.cart)?void 0:t.useRemoveItem},ot=B,at=function(e){var t;return null==(t=e.cart)?void 0:t.useUpdateItem};exports.AddToCartButton=Y,exports.CartComponent=Z,exports.CartType={__proto__:null},exports.CategoryCollection=ae,exports.CategoryField=le,exports.CategoryLink=pe,exports.CategoryMedia=fe,exports.CommerceError=O,exports.CoreCommerceProvider=S,exports.FetcherError=F,exports.ProductBox=Ce,exports.ProductCollection=Ve,exports.ProductLink=Oe,exports.ProductMedia=je,exports.ProductMediaCollection=Ae,exports.ProductPlaceholder=b,exports.ProductPriceComponent=qe,exports.ProductQuantity=Ye,exports.ProductSlider=ze,exports.ProductTextField=Ke,exports.ProductTypes={__proto__:null},exports.ProductVariantPicker=et,exports.SiteTypes={__proto__:null},exports.ValidationError=_,exports.addToCartButtonMeta=Q,exports.cartMeta=X,exports.categoryCollectionMeta=oe,exports.categoryFieldMeta=ce,exports.categoryLinkMeta=se,exports.categoryMediaMeta=me,exports.fetcher=Pe,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,M);return n.createElement(S,{provider:s({},e,o)},r)}},exports.productBoxMeta=xe,exports.productCollectionMeta=Me,exports.productLinkMeta=Ie,exports.productMediaCollectionMeta=Re,exports.productMediaMeta=Fe,exports.productPriceMeta=Ge,exports.productQuantityMeta=Qe,exports.productSliderMeta=We,exports.productTextFieldMeta=$e,exports.productVariantPickerMeta=Ze,exports.registerAddToCartButton=U,exports.registerAll=function(e){Se(e),Xe(e),He(e),Te(e),De(e),ee(e),U(e),Ue(e),tt(e),be(e),Je(e),_e(e),ie(e),ue(e),de(e),ye(e)},exports.registerCart=ee,exports.registerCategoryCollection=ie,exports.registerCategoryField=ue,exports.registerCategoryLink=de,exports.registerCategoryMedia=ye,exports.registerProductBox=be,exports.registerProductCollection=Se,exports.registerProductLink=_e,exports.registerProductMedia=Te,exports.registerProductMediaCollection=De,exports.registerProductPrice=He,exports.registerProductQuantity=Ue,exports.registerProductSlider=Je,exports.registerProductVariantPicker=tt,exports.registerTextField=Xe,exports.useAddItem=H,exports.useBrands=Le,exports.useCart=J,exports.useCategories=ne,exports.useCommerce=I,exports.useProduct=ge,exports.useRemoveItem=function(e){var t=T(nt);return A(s({fetcher:rt},t))(e)},exports.useSearch=Ee,exports.useUpdateItem=function(e){var t=T(at);return A(s({fetcher:ot},t))(e)};
2
2
  //# sourceMappingURL=commerce.cjs.production.min.js.map