관리-도구
편집 파일: featured-product.js
this.kkart=this.kkart||{},this.kkart.blocks=this.kkart.blocks||{},this.kkart.blocks["featured-product"]=function(e){function t(t){for(var r,i,a=t[0],u=t[1],s=t[2],d=0,p=[];d<a.length;d++)i=a[d],Object.prototype.hasOwnProperty.call(c,i)&&c[i]&&p.push(c[i][0]),c[i]=0;for(r in u)Object.prototype.hasOwnProperty.call(u,r)&&(e[r]=u[r]);for(l&&l(t);p.length;)p.shift()();return o.push.apply(o,s||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,a=1;a<n.length;a++){var u=n[a];0!==c[u]&&(r=!1)}r&&(o.splice(t--,1),e=i(i.s=n[0]))}return e}var r={},c={23:0},o=[];function i(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],u=a.push.bind(a);a.push=t,a=a.slice();for(var s=0;s<a.length;s++)t(a[s]);var l=u;return o.push([823,0]),n()}({0:function(e,t){!function(){e.exports=this.wp.element}()},1:function(e,t){!function(){e.exports=this.wp.i18n}()},108:function(e,t){},109:function(e,t){},110:function(e,t){},111:function(e,t){},112:function(e,t){},113:function(e,t){},114:function(e,t){},115:function(e,t){},116:function(e,t){},117:function(e,t){},118:function(e,t){},119:function(e,t){},120:function(e,t){},121:function(e,t){},13:function(e,t){!function(){e.exports=this.wp.apiFetch}()},14:function(e,t){!function(){e.exports=this.wp.blockEditor}()},143:function(e,t,n){"use strict";var r=n(51),c=n.n(r),o=n(10),i=n.n(o),a=n(0),u=n(1),s=n(6),l=(n(2),n(50)),d=n(4),p=n(7),f=n.n(p),b=n(22),g=n.n(b),h=n(25),m=n.n(h),O=n(23),v=n.n(O),j=n(24),w=n.n(j),y=n(12),k=n.n(y),_=n(26);function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k()(e);if(t){var c=k()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return w()(this,n)}}var E=Object(_.createHigherOrderComponent)((function(e){var t=function(t){v()(r,t);var n=S(r);function r(){return g()(this,r),n.apply(this,arguments)}return m()(r,[{key:"render",value:function(){var t=this.props.selected;return Object(a.createElement)(e,i()({},this.props,{selected:Object(s.isNil)(t)?[]:[t]}))}}]),r}(a.Component);return t.defaultProps={selected:null},t}),"withTransformSingleSelectToMultipleSelect"),P=n(302),x=n(15),C=n.n(x),D=n(37),R=n.n(D),I=n(19),A=n.n(I),M=n(8),B=n.n(M),T=n(43),U=n.n(T),L=n(40),N=n(44);function z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?z(Object(n),!0).forEach((function(t){B()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k()(e);if(t){var c=k()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return w()(this,n)}}var F=Object(_.createHigherOrderComponent)((function(e){var t=function(t){v()(r,t);var n=H(r);function r(){var e;g()(this,r);for(var t=arguments.length,c=new Array(t),o=0;o<t;o++)c[o]=arguments[o];return e=n.call.apply(n,[this].concat(c)),B()(A()(e),"state",{error:null,loading:!1,variations:{}}),B()(A()(e),"loadVariations",(function(){var t=e.props.products,n=e.state,r=n.loading,c=n.variations;if(!r){var o=e.getExpandedProduct();if(o&&!c[o]){var i=t.find((function(e){return e.id===o}));i.variations&&0!==i.variations.length?(e.setState({loading:!0}),Object(L.g)(o).then((function(t){var n=t.map((function(e){return V(V({},e),{},{parent:o})}));e.setState({variations:V(V({},e.state.variations),{},B()({},o,n)),loading:!1,error:null})})).catch(function(){var t=R()(C.a.mark((function t(n){var r;return C.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(N.a)(n);case 2:r=t.sent,e.setState({variations:V(V({},e.state.variations),{},B()({},o,null)),loading:!1,error:r});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())):e.setState({variations:V(V({},e.state.variations),{},B()({},o,null)),loading:!1,error:null})}}})),e}return m()(r,[{key:"componentDidMount",value:function(){var e=this.props,t=e.selected,n=e.showVariations;t&&n&&this.loadVariations()}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.isLoading,r=t.selected;t.showVariations&&(!U()(e.selected,r)||e.isLoading&&!n)&&this.loadVariations()}},{key:"isProductId",value:function(e){return this.props.products.some((function(t){return t.id===e}))}},{key:"findParentProduct",value:function(e){return this.props.products.filter((function(t){return t.variations&&t.variations.find((function(t){return t.id===e}))}))[0].id}},{key:"getExpandedProduct",value:function(){var e=this.props,t=e.isLoading,n=e.selected;if(!e.showVariations)return null;var r=n&&n.length?n[0]:null;return r?this.prevSelectedItem=r:this.prevSelectedItem&&(t||this.isProductId(this.prevSelectedItem)||(r=this.prevSelectedItem)),!t&&r?this.isProductId(r)?r:this.findParentProduct(r):null}},{key:"render",value:function(){var t=this.props,n=t.error,r=t.isLoading,c=this.state,o=c.error,u=c.loading,s=c.variations;return Object(a.createElement)(e,i()({},this.props,{error:o||n,expandedProduct:this.getExpandedProduct(),isLoading:r,variations:s,variationsLoading:u}))}}]),r}(a.Component);return B()(t,"defaultProps",{selected:[],showVariations:!1}),t}),"withProductVariations"),q=n(61),W=n(57),Q=Object(a.createElement)(W.a,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)("path",{fill:"#1E8CBE",d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"})),G=Object(a.createElement)(W.a,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(a.createElement)("path",{fill:"#757575",d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"})),J=n(49);n(200);function Y(e,t){if(!t)return e;var n=new RegExp(Object(s.escapeRegExp)(t),"ig");return e.replace(n,"<strong>$&</strong>")}var $=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?Object(a.createElement)(q.a,{srcElement:Q}):Object(a.createElement)(q.a,{srcElement:G})},K={list:Object(u.__)("Products",'kkart'),noItems:Object(u.__)("Your store doesn't have any products.",'kkart'),search:Object(u.__)("Search for a product to display",'kkart'),updated:Object(u.__)("Product search results updated.",'kkart')},X=function(e){var t=e.expandedProduct,n=e.error,r=e.isLoading,o=e.onChange,p=e.onSearch,b=e.products,g=e.renderItem,h=e.selected,m=e.showVariations,O=e.variations,v=e.variationsLoading,j=function(e){var n=e.item,r=e.search,c=e.depth,o=void 0===c?0:c,p=e.isSelected,b=e.onSelect,g=n.variations&&Array.isArray(n.variations)?n.variations.length:0,h=f()("kkart-search-product__item","kkart-search-list__item","depth-".concat(o),{"is-searching":r.length>0,"is-skip-level":0===o&&0!==n.parent,"is-variable":g>0}),m=Object.assign({},e);delete m.isSingle;var O={role:"menuitemradio"};return n.breadcrumbs.length&&(O["aria-label"]="".concat(n.breadcrumbs[0],": ").concat(n.name)),g&&(O["aria-expanded"]=n.id===t),n.breadcrumbs.length?(Object(s.isEmpty)(n.variation)||(n.name=n.variation),Object(a.createElement)(l.b,i()({className:h},e,O))):[Object(a.createElement)(d.MenuItem,i()({key:"product-".concat(n.id),isSelected:p},m,O,{className:h,onClick:function(){b(n)()}}),Object(a.createElement)("span",{className:"kkart-search-list__item-state"},$(p)),Object(a.createElement)("span",{className:"kkart-search-list__item-label"},Object(a.createElement)("span",{className:"kkart-search-list__item-name",dangerouslySetInnerHTML:{__html:Y(n.name,r)}})),g?Object(a.createElement)("span",{className:"kkart-search-list__item-variation-count"},Object(u.sprintf)(Object(u._n)("%d variation","%d variations",g,'kkart'),g)):null),t===n.id&&g>0&&v&&Object(a.createElement)("div",{key:"loading",className:"kkart-search-list__item kkart-search-product__itemdepth-1 is-loading is-not-active"},Object(a.createElement)(d.Spinner,null))]};if(n)return Object(a.createElement)(J.a,{error:n});var w=O&&O[t]?O[t]:[],y=[].concat(c()(b),c()(w));return Object(a.createElement)(l.a,{className:"kkart-products",list:y,isLoading:r,isSingle:!0,selected:y.filter((function(e){var t=e.id;return h.includes(t)})),onChange:o,renderItem:g||(m?j:null),onSearch:p,messages:K,isHierarchical:!0})};X.defaultProps={expandedProduct:null,selected:[],showVariations:!1};t.a=E(Object(P.a)(F(X)))},144:function(e,t,n){"use strict";var r=n(0),c=n(57),o=Object(r.createElement)(c.a,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}));t.a=o},147:function(e,t){},15:function(e,t){!function(){e.exports=this.regeneratorRuntime}()},17:function(e,t){!function(){e.exports=this.wp.blocks}()},18:function(e,t){!function(){e.exports=this.wp.url}()},200:function(e,t){},26:function(e,t){!function(){e.exports=this.wp.compose}()},3:function(e,t){!function(){e.exports=this.kkart.wcSettings}()},302:function(e,t,n){"use strict";var r=n(10),c=n.n(r),o=n(15),i=n.n(o),a=n(37),u=n.n(a),s=n(22),l=n.n(s),d=n(25),p=n.n(d),f=n(19),b=n.n(f),g=n(23),h=n.n(g),m=n(24),O=n.n(m),v=n(12),j=n.n(v),w=n(0),y=n(6),k=n(26),_=(n(2),n(5)),S=n(40),E=n(44);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j()(e);if(t){var c=j()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return O()(this,n)}}var x=Object(k.createHigherOrderComponent)((function(e){var t=function(t){h()(o,t);var n,r=P(o);function o(){var e;return l()(this,o),(e=r.apply(this,arguments)).state={list:[],loading:!0},e.setError=e.setError.bind(b()(e)),e.debouncedOnSearch=Object(y.debounce)(e.onSearch.bind(b()(e)),400),e}return p()(o,[{key:"componentDidMount",value:function(){var e=this,t=this.props.selected;Object(S.h)({selected:t}).then((function(t){e.setState({list:t,loading:!1})})).catch(this.setError)}},{key:"componentWillUnmount",value:function(){this.debouncedOnSearch.cancel()}},{key:"onSearch",value:function(e){var t=this,n=this.props.selected;Object(S.h)({selected:n,search:e}).then((function(e){t.setState({list:e,loading:!1})})).catch(this.setError)}},{key:"setError",value:(n=u()(i.a.mark((function e(t){var n;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(E.a)(t);case 2:n=e.sent,this.setState({list:[],loading:!1,error:n});case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"render",value:function(){var t=this,n=this.state,r=n.error,o=n.list,i=n.loading;return Object(w.createElement)(e,c()({},this.props,{error:r,products:o,isLoading:i,onSearch:_.v?function(e){t.setState({loading:!0}),t.debouncedOnSearch(e)}:null}))}}]),o}(w.Component);return t.defaultProps={selected:[]},t}),"withSearchedProducts");t.a=x},33:function(e,t){!function(){e.exports=this.wp.htmlEntities}()},35:function(e,t){!function(){e.exports=this.moment}()},36:function(e,t){!function(){e.exports=this.wp.data}()},4:function(e,t){!function(){e.exports=this.wp.components}()},40:function(e,t,n){"use strict";n.d(t,"h",(function(){return p})),n.d(t,"e",(function(){return f})),n.d(t,"b",(function(){return b})),n.d(t,"i",(function(){return g})),n.d(t,"f",(function(){return h})),n.d(t,"c",(function(){return m})),n.d(t,"d",(function(){return O})),n.d(t,"g",(function(){return v})),n.d(t,"a",(function(){return j}));var r=n(8),c=n.n(r),o=n(18),i=n(13),a=n.n(i),u=n(6),s=n(5);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var p=function(e){var t=e.selected,n=void 0===t?[]:t,r=e.search,c=void 0===r?"":r,i=e.queryArgs,l=function(e){var t=e.selected,n=void 0===t?[]:t,r=e.search,c=void 0===r?"":r,i=e.queryArgs,a=void 0===i?[]:i,u={per_page:s.v?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},l=[Object(o.addQueryArgs)("/kkart/store/products",d(d({},u),a))];return s.v&&n.length&&l.push(Object(o.addQueryArgs)("/kkart/store/products",{catalog_visibility:"any",include:n})),l}({selected:n,search:c,queryArgs:void 0===i?[]:i});return Promise.all(l.map((function(e){return a()({path:e})}))).then((function(e){return Object(u.uniqBy)(Object(u.flatten)(e),"id").map((function(e){return d(d({},e),{},{parent:0})}))})).catch((function(e){throw e}))},f=function(e){return a()({path:"/kkart/store/products/".concat(e)})},b=function(){return a()({path:"kkart/store/products/attributes"})},g=function(e){return a()({path:"kkart/store/products/attributes/".concat(e,"/terms")})},h=function(e){var t=e.selected,n=function(e){var t=e.selected,n=void 0===t?[]:t,r=e.search,c=[Object(o.addQueryArgs)("kkart/store/products/tags",{per_page:s.y?100:0,orderby:s.y?"count":"name",order:s.y?"desc":"asc",search:r})];return s.y&&n.length&&c.push(Object(o.addQueryArgs)("kkart/store/products/tags",{include:n})),c}({selected:void 0===t?[]:t,search:e.search});return Promise.all(n.map((function(e){return a()({path:e})}))).then((function(e){return Object(u.uniqBy)(Object(u.flatten)(e),"id")}))},m=function(e){return a()({path:Object(o.addQueryArgs)("kkart/store/products/categories",d({per_page:0},e))})},O=function(e){return a()({path:"kkart/store/products/categories/".concat(e)})},v=function(e){return a()({path:Object(o.addQueryArgs)("kkart/store/products",{per_page:0,type:"variation",parent:e})})},j=function(e,t){if(!e.title.raw)return e.slug;var n=1===t.filter((function(t){return t.title.raw===e.title.raw})).length;return e.title.raw+(n?"":" - ".concat(e.slug))}},43:function(e,t){!function(){e.exports=this.wp.isShallowEqual}()},44:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(15),c=n.n(r),o=n(37),i=n.n(o),a=function(){var e=i()(c.a.mark((function e(t){var n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return n=e.sent,e.abrupt("return",{message:n.message,type:n.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}()},47:function(e,t){!function(){e.exports=this.wp.escapeHtml}()},49:function(e,t,n){"use strict";var r=n(0),c=n(1),o=(n(2),n(47));t.a=function(e){var t,n,i,a=e.error;return Object(r.createElement)("div",{className:"kkart-block-error-message"},(n=(t=a).message,i=t.type,n?"general"===i?Object(r.createElement)("span",null,Object(c.__)("The following error was returned",'kkart'),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(o.escapeHTML)(n))):"api"===i?Object(r.createElement)("span",null,Object(c.__)("The following error was returned from the API",'kkart'),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(o.escapeHTML)(n))):n:Object(c.__)("An unknown error occurred which prevented the block from being updated.",'kkart')))}},5:function(e,t,n){"use strict";n.d(t,"l",(function(){return c})),n.d(t,"K",(function(){return o})),n.d(t,"Q",(function(){return i})),n.d(t,"A",(function(){return a})),n.d(t,"C",(function(){return u})),n.d(t,"m",(function(){return s})),n.d(t,"B",(function(){return l})),n.d(t,"E",(function(){return d})),n.d(t,"o",(function(){return p})),n.d(t,"D",(function(){return f})),n.d(t,"n",(function(){return b})),n.d(t,"G",(function(){return g})),n.d(t,"v",(function(){return h})),n.d(t,"y",(function(){return m})),n.d(t,"s",(function(){return O})),n.d(t,"t",(function(){return v})),n.d(t,"u",(function(){return j})),n.d(t,"k",(function(){return w})),n.d(t,"M",(function(){return y})),n.d(t,"R",(function(){return k})),n.d(t,"q",(function(){return _})),n.d(t,"r",(function(){return S})),n.d(t,"p",(function(){return E})),n.d(t,"J",(function(){return P})),n.d(t,"c",(function(){return x})),n.d(t,"w",(function(){return C})),n.d(t,"x",(function(){return D})),n.d(t,"U",(function(){return I})),n.d(t,"V",(function(){return A})),n.d(t,"L",(function(){return M})),n.d(t,"a",(function(){return B})),n.d(t,"O",(function(){return T})),n.d(t,"b",(function(){return U})),n.d(t,"N",(function(){return L})),n.d(t,"F",(function(){return N})),n.d(t,"i",(function(){return z})),n.d(t,"P",(function(){return F})),n.d(t,"h",(function(){return q})),n.d(t,"j",(function(){return W})),n.d(t,"I",(function(){return Q})),n.d(t,"H",(function(){return G})),n.d(t,"T",(function(){return J})),n.d(t,"S",(function(){return Y})),n.d(t,"d",(function(){return $})),n.d(t,"e",(function(){return K})),n.d(t,"f",(function(){return X})),n.d(t,"g",(function(){return Z})),n.d(t,"z",(function(){return ee})),n.d(t,"Y",(function(){return ne})),n.d(t,"Z",(function(){return re})),n.d(t,"W",(function(){return ce})),n.d(t,"X",(function(){return oe}));var r=n(3),c=Object(r.getSetting)("currentUserIsAdmin",!1),o=Object(r.getSetting)("reviewRatingsEnabled",!0),i=Object(r.getSetting)("showAvatars",!0),a=Object(r.getSetting)("max_columns",6),u=Object(r.getSetting)("min_columns",1),s=Object(r.getSetting)("default_columns",3),l=Object(r.getSetting)("max_rows",6),d=Object(r.getSetting)("min_rows",1),p=Object(r.getSetting)("default_rows",3),f=Object(r.getSetting)("min_height",500),b=Object(r.getSetting)("default_height",500),g=Object(r.getSetting)("placeholderImgSrc",""),h=(Object(r.getSetting)("thumbnail_size",300),Object(r.getSetting)("isLargeCatalog")),m=Object(r.getSetting)("limitTags"),O=Object(r.getSetting)("hasProducts",!0),v=Object(r.getSetting)("hasTags",!0),j=Object(r.getSetting)("homeUrl",""),w=Object(r.getSetting)("couponsEnabled",!0),y=Object(r.getSetting)("shippingEnabled",!0),k=Object(r.getSetting)("taxesEnabled",!0),_=Object(r.getSetting)("displayItemizedTaxes",!1),S=Object(r.getSetting)("hasDarkEditorStyleSupport",!1),E=(Object(r.getSetting)("displayShopPricesIncludingTax",!1),Object(r.getSetting)("displayCartPricesIncludingTax",!1)),P=Object(r.getSetting)("productCount",0),x=Object(r.getSetting)("attributes",[]),C=Object(r.getSetting)("isShippingCalculatorEnabled",!0),D=Object(r.getSetting)("isShippingCostHidden",!1),R=Object(r.getSetting)("kkartBlocksPhase",1),I=Object(r.getSetting)("wcBlocksAssetUrl",""),A=Object(r.getSetting)("wcBlocksBuildUrl",""),M=Object(r.getSetting)("shippingCountries",{}),B=Object(r.getSetting)("allowedCountries",{}),T=Object(r.getSetting)("shippingStates",{}),U=Object(r.getSetting)("allowedStates",{}),L=Object(r.getSetting)("shippingMethodsExist",!1),N=Object(r.getSetting)("paymentGatewaySortOrder",[]),z=Object(r.getSetting)("checkoutShowLoginReminder",!0),V={id:0,title:"",permalink:""},H=Object(r.getSetting)("storePages",{shop:V,cart:V,checkout:V,privacy:V,terms:V}),F=H.shop.permalink,q=H.checkout.id,W=H.checkout.permalink,Q=H.privacy.permalink,G=H.privacy.title,J=H.terms.permalink,Y=H.terms.title,$=H.cart.id,K=H.cart.permalink,X=Object(r.getSetting)("checkoutAllowsGuest",!1),Z=Object(r.getSetting)("checkoutAllowsSignup",!1),ee=Object(r.getSetting)("loginUrl","/wp-login.php"),te=n(17),ne=function(e,t){if(R>2)return Object(te.registerBlockType)(e,t)},re=function(e,t){if(R>1)return Object(te.registerBlockType)(e,t)},ce=function(){return R>2},oe=function(){return R>1}},533:function(e,t,n){"use strict";var r=n(10),c=n.n(r),o=n(15),i=n.n(o),a=n(37),u=n.n(a),s=n(22),l=n.n(s),d=n(25),p=n.n(d),f=n(19),b=n.n(f),g=n(23),h=n.n(g),m=n(24),O=n.n(m),v=n(12),j=n.n(v),w=n(8),y=n.n(w),k=n(0),_=n(26),S=n(40),E=n(44);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j()(e);if(t){var c=j()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return O()(this,n)}}var x=Object(_.createHigherOrderComponent)((function(e){return function(t){h()(r,t);var n=P(r);function r(){var e;l()(this,r);for(var t=arguments.length,c=new Array(t),o=0;o<t;o++)c[o]=arguments[o];return e=n.call.apply(n,[this].concat(c)),y()(b()(e),"state",{error:null,loading:!1,product:"preview"===e.props.attributes.productId?e.props.attributes.previewProduct:null}),y()(b()(e),"loadProduct",(function(){var t=e.props.attributes.productId;"preview"!==t&&(t?(e.setState({loading:!0}),Object(S.e)(t).then((function(t){e.setState({product:t,loading:!1,error:null})})).catch(function(){var t=u()(i.a.mark((function t(n){var r;return i.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(E.a)(n);case 2:r=t.sent,e.setState({product:null,loading:!1,error:r});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())):e.setState({product:null,loading:!1,error:null}))})),e}return p()(r,[{key:"componentDidMount",value:function(){this.loadProduct()}},{key:"componentDidUpdate",value:function(e){e.attributes.productId!==this.props.attributes.productId&&this.loadProduct()}},{key:"render",value:function(){var t=this.state,n=t.error,r=t.loading,o=t.product;return Object(k.createElement)(e,c()({},this.props,{error:n,getProduct:this.loadProduct,isLoading:r,product:o}))}}]),r}(k.Component)}),"withProduct");t.a=x},54:function(e,t){!function(){e.exports=this.wp.keycodes}()},6:function(e,t){!function(){e.exports=this.lodash}()},61:function(e,t,n){"use strict";var r=n(8),c=n.n(r),o=n(27),i=n.n(o),a=n(9);n(2);function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}t.a=function(e){var t=e.srcElement,n=e.size,r=void 0===n?24:n,o=i()(e,["srcElement","size"]);return Object(a.isValidElement)(t)&&Object(a.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({width:r,height:r},o))}},75:function(e,t){!function(){e.exports=this.wp.hooks}()},77:function(e,t){!function(){e.exports=this.ReactDOM}()},78:function(e,t){!function(){e.exports=this.wp.dom}()},823:function(e,t,n){e.exports=n(911)},824:function(e,t){},825:function(e,t){},826:function(e,t,n){"use strict";var r=n(0),c=n(57),o=Object(r.createElement)(c.a,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(r.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(r.createElement)("path",{d:"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"}));t.a=o},827:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(1),c=n(5),o=[{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:Object(r.__)("Fly your WordPress banner with this beauty! Deck out your office space or add it to your kids walls. This banner will spruce up any space it’s hung!",'kkart'),description:"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",price:"7.99",price_html:'<span class="kkart-Price-amount amount"><span class="kkart-Price-currencySymbol">$</span>7.99</span>',images:[{id:1,src:c.U+"img/pennant.jpg",thumbnail:c.U+"img/pennant.jpg",name:"pennant-1.jpg",alt:"WordPress Pennant",srcset:"",sizes:""}],average_rating:5,review_count:1,prices:{currency_code:"GBP",decimal_separator:".",thousand_separator:",",decimals:2,price_prefix:"£",price_suffix:"",price:"7.99",regular_price:"9.99",sale_price:"7.99",price_range:null},add_to_cart:{text:Object(r.__)("Add to cart",'kkart'),description:Object(r.__)("Add to cart",'kkart')},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}]},83:function(e,t){!function(){e.exports=this.wp.viewport}()},9:function(e,t){!function(){e.exports=this.React}()},911:function(e,t,n){"use strict";n.r(t);var r=n(0),c=n(1),o=n(14),i=n(17),a=n(5),u=n(61),s=n(826),l=(n(824),n(825),n(827)),d={attributes:{contentAlign:"center",dimRatio:50,editMode:!1,height:a.n,mediaSrc:"",showDesc:!0,productId:"preview",previewProduct:l.a[0]}},p=n(10),f=n.n(p),b=n(22),g=n.n(b),h=n(25),m=n.n(h),O=n(19),v=n.n(O),j=n(23),w=n.n(j),y=n(24),k=n.n(y),_=n(12),S=n.n(_),E=n(8),P=n.n(E),x=n(36),C=n(4),D=n(7),R=n.n(D),I=n(26),A=n(6),M=(n(2),n(143)),B=n(93),T=n(533);function U(e){return e&&e.images&&e.images.length&&e.images[0].src||""}function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L(Object(n),!0).forEach((function(t){P()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S()(e);if(t){var c=S()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return k()(this,n)}}var V=Object(I.compose)([T.a,Object(o.withColors)({overlayColor:"background-color"}),C.withSpokenMessages,Object(x.withSelect)((function(e,t,n){var r,c,o=t.clientId,i=n.dispatch,a=e("core/block-editor").getBlock(o),u=(null==a||null===(r=a.innerBlocks[0])||void 0===r?void 0:r.clientId)||"";return{updateBlockAttributes:function(e){u&&i("core/block-editor").updateBlockAttributes(u,e)},currentButtonAttributes:(null==a||null===(c=a.innerBlocks[0])||void 0===c?void 0:c.attributes)||{}}})),Object(I.createHigherOrderComponent)((function(e){return function(t){w()(c,t);var n=z(c);function c(){var e;g()(this,c);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e=n.call.apply(n,[this].concat(r)),P()(v()(e),"state",{doUrlUpdate:!1}),P()(v()(e),"triggerUrlUpdate",(function(){e.setState({doUrlUpdate:!0})})),e}return m()(c,[{key:"componentDidUpdate",value:function(){var e=this.props,t=e.attributes,n=e.updateBlockAttributes,r=e.currentButtonAttributes,c=e.product;this.state.doUrlUpdate&&!t.editMode&&(null==c?void 0:c.permalink)&&(null==r?void 0:r.url)&&c.permalink!==r.url&&(n(N(N({},r),{},{url:c.permalink})),this.setState({doUrlUpdate:!1}))}},{key:"render",value:function(){return Object(r.createElement)(e,f()({triggerUrlUpdate:this.triggerUrlUpdate},this.props))}}]),c}(r.Component)}),"withUpdateButtonAttributes")])((function(e){var t,n,i,l,d=e.attributes,p=e.debouncedSpeak,f=e.error,b=e.getProduct,g=e.isLoading,h=e.isSelected,m=e.overlayColor,O=e.product,v=e.setAttributes,j=e.setOverlayColor,w=e.triggerUrlUpdate,y=void 0===w?function(){}:w,k=function(){var e=d.contentAlign,t=d.editMode,n=d.mediaId||function(e){return e&&e.images&&e.images.length&&e.images[0].id||0}(O);return Object(r.createElement)(o.BlockControls,null,Object(r.createElement)(o.AlignmentToolbar,{value:e,onChange:function(e){v({contentAlign:e})}}),Object(r.createElement)(o.MediaUploadCheck,null,Object(r.createElement)(C.Toolbar,null,Object(r.createElement)(o.MediaUpload,{onSelect:function(e){v({mediaId:e.id,mediaSrc:e.url})},allowedTypes:["image"],value:n,render:function(e){var t=e.open;return Object(r.createElement)(C.IconButton,{className:"components-toolbar__control",label:Object(c.__)("Edit media"),icon:"format-image",onClick:t,disabled:!O})}}))),Object(r.createElement)(C.Toolbar,{controls:[{icon:"edit",title:Object(c.__)("Edit"),onClick:function(){return v({editMode:!t})},isActive:t}]}))},_=function(){var e=R()("wp-block-button__link","is-style-fill");return"preview"===d.productId?Object(r.createElement)("div",{className:"wp-block-button aligncenter",style:{width:"100%"}},Object(r.createElement)(o.RichText.Content,{tagName:"a",className:e,href:O.permalink,title:d.linkText,style:{backgroundColor:"vivid-green-cyan",borderRadius:"5px"},value:d.linkText,target:O.permalink})):Object(r.createElement)(o.InnerBlocks,{template:[["core/button",{text:Object(c.__)("Shop now",'kkart'),url:O.permalink,align:"center"}]],templateLock:"all"})},S=d.editMode;return f?Object(r.createElement)(B.a,{className:"kkart-block-featured-product-error",error:f,isLoading:g,onRetry:b}):S?Object(r.createElement)(r.Fragment,null,k(),Object(r.createElement)(C.Placeholder,{icon:Object(r.createElement)(u.a,{srcElement:s.a}),label:Object(c.__)("Featured Product",'kkart'),className:"kkart-block-featured-product"},Object(c.__)("Visually highlight a product or variation and encourage prompt action",'kkart'),Object(r.createElement)("div",{className:"kkart-block-featured-product__selection"},Object(r.createElement)(M.a,{selected:d.productId||0,showVariations:!0,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e[0]?e[0].id:0;v({productId:t,mediaId:0,mediaSrc:""}),y()}}),Object(r.createElement)(C.Button,{isPrimary:!0,onClick:function(){v({editMode:!1}),p(Object(c.__)("Showing Featured Product block preview.",'kkart'))}},Object(c.__)("Done",'kkart'))))):Object(r.createElement)(r.Fragment,null,k(),(t=d.mediaSrc||U(O),n=d.focalPoint,i=void 0===n?{x:.5,y:.5}:n,l="function"==typeof C.FocalPointPicker,Object(r.createElement)(o.InspectorControls,{key:"inspector"},Object(r.createElement)(C.PanelBody,{title:Object(c.__)("Content",'kkart')},Object(r.createElement)(C.ToggleControl,{label:Object(c.__)("Show description",'kkart'),checked:d.showDesc,onChange:function(){return v({showDesc:!d.showDesc})}}),Object(r.createElement)(C.ToggleControl,{label:Object(c.__)("Show price",'kkart'),checked:d.showPrice,onChange:function(){return v({showPrice:!d.showPrice})}})),Object(r.createElement)(o.PanelColorSettings,{title:Object(c.__)("Overlay",'kkart'),colorSettings:[{value:m.color,onChange:j,label:Object(c.__)("Overlay Color",'kkart')}]},!!t&&Object(r.createElement)(r.Fragment,null,Object(r.createElement)(C.RangeControl,{label:Object(c.__)("Background Opacity",'kkart'),value:d.dimRatio,onChange:function(e){return v({dimRatio:e})},min:0,max:100,step:10}),l&&Object(r.createElement)(C.FocalPointPicker,{label:Object(c.__)("Focal Point Picker"),url:t,value:i,onChange:function(e){return v({focalPoint:e})}}))))),O?function(){var e,t,n=d.className,c=d.contentAlign,o=d.dimRatio,i=d.focalPoint,u=d.height,s=d.showDesc,l=d.showPrice,p=R()("kkart-block-featured-product",{"is-selected":h&&"preview"!==d.productId,"is-loading":!O&&g,"is-not-found":!O&&!g,"has-background-dim":0!==o},0===(e=o)||50===e?null:"has-background-dim-".concat(10*Math.round(e/10)),"center"!==c&&"has-".concat(c,"-content"),n),f=(t=d.mediaSrc||O,Object(A.isObject)(t)&&(t=U(t)),t?{backgroundImage:"url(".concat(t,")")}:{});if(m.color&&(f.backgroundColor=m.color),i){var b=100*i.x,j=100*i.y;f.backgroundPosition="".concat(b,"% ").concat(j,"%")}return Object(r.createElement)(C.ResizableBox,{className:p,size:{height:u},minHeight:a.D,enable:{bottom:!0},onResizeStop:function(e,t,n){v({height:parseInt(n.style.height,10)})},style:f},Object(r.createElement)("div",{className:"kkart-block-featured-product__wrapper"},Object(r.createElement)("h2",{className:"kkart-block-featured-product__title",dangerouslySetInnerHTML:{__html:O.name}}),!Object(A.isEmpty)(O.variation)&&Object(r.createElement)("h3",{className:"kkart-block-featured-product__variation",dangerouslySetInnerHTML:{__html:O.variation}}),s&&Object(r.createElement)("div",{className:"kkart-block-featured-product__description",dangerouslySetInnerHTML:{__html:O.short_description}}),l&&Object(r.createElement)("div",{className:"kkart-block-featured-product__price",dangerouslySetInnerHTML:{__html:O.price_html}}),Object(r.createElement)("div",{className:"kkart-block-featured-product__link"},_())))}():Object(r.createElement)(C.Placeholder,{className:"kkart-block-featured-product",icon:Object(r.createElement)(u.a,{srcElement:s.a}),label:Object(c.__)("Featured Product",'kkart')},g?Object(r.createElement)(C.Spinner,null):Object(c.__)("No product is selected.",'kkart')))}));Object(i.registerBlockType)("kkart/featured-product",{title:Object(c.__)("Featured Product",'kkart'),icon:{src:Object(r.createElement)(u.a,{srcElement:s.a}),foreground:"#96588a"},category:"kkart",keywords:[Object(c.__)("Kkart",'kkart')],description:Object(c.__)("Visually highlight a product or variation and encourage prompt action.",'kkart'),supports:{align:["wide","full"],html:!1},example:d,attributes:{contentAlign:{type:"string",default:"center"},dimRatio:{type:"number",default:50},editMode:{type:"boolean",default:!0},focalPoint:{type:"object"},height:{type:"number",default:a.n},mediaId:{type:"number",default:0},mediaSrc:{type:"string",default:""},overlayColor:{type:"string"},customOverlayColor:{type:"string"},linkText:{type:"string",default:Object(c.__)("Shop now",'kkart')},productId:{type:"number"},showDesc:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},previewProduct:{type:"object",default:null}},edit:function(e){return Object(r.createElement)(V,e)},save:function(){return Object(r.createElement)(o.InnerBlocks.Content,null)}})},93:function(e,t,n){"use strict";var r=n(0),c=n(1),o=(n(2),n(61)),i=n(144),a=n(7),u=n.n(a),s=n(4),l=n(49);n(147);t.a=function(e){var t=e.className,n=e.error,a=e.isLoading,d=e.onRetry;return Object(r.createElement)(s.Placeholder,{icon:Object(r.createElement)(o.a,{srcElement:i.a}),label:Object(c.__)("Sorry, an error occurred",'kkart'),className:u()("kkart-block-api-error",t)},Object(r.createElement)(l.a,{error:n}),d&&Object(r.createElement)(r.Fragment,null,a?Object(r.createElement)(s.Spinner,null):Object(r.createElement)(s.Button,{isDefault:!0,onClick:d},Object(c.__)("Retry",'kkart'))))}},94:function(e,t){!function(){e.exports=this.wp.date}()}});