woocommerce/packages/woocommerce-blocks/build/product-tag.js

5 lines
28 KiB
JavaScript

this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["product-tag"]=function(e){function t(t){for(var n,i,l=t[0],a=t[1],u=t[2],b=0,d=[];b<l.length;b++)i=l[b],Object.prototype.hasOwnProperty.call(c,i)&&c[i]&&d.push(c[i][0]),c[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);d.length;)d.shift()();return o.push.apply(o,u||[]),r()}function r(){for(var e,t=0;t<o.length;t++){for(var r=o[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==c[a]&&(n=!1)}n&&(o.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},c={34:0},o=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},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 l=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var u=0;u<l.length;u++)t(l[u]);var s=a;return o.push([779,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.React},12:function(e,t){e.exports=window.wp.blockEditor},121:function(e,t){},122:function(e,t){e.exports=window.wp.coreData},130:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(4);r(2),t.a=function(e){var t=e.value,r=e.setAttributes;return Object(n.createElement)(o.SelectControl,{label:Object(c.__)("Order products by",'woocommerce'),value:t,options:[{label:Object(c.__)("Newness - newest first",'woocommerce'),value:"date"},{label:Object(c.__)("Price - low to high",'woocommerce'),value:"price_asc"},{label:Object(c.__)("Price - high to low",'woocommerce'),value:"price_desc"},{label:Object(c.__)("Rating - highest first",'woocommerce'),value:"rating"},{label:Object(c.__)("Sales - most first",'woocommerce'),value:"popularity"},{label:Object(c.__)("Title - alphabetical",'woocommerce'),value:"title"},{label:Object(c.__)("Menu Order",'woocommerce'),value:"menu_order"}],onChange:function(e){return r({orderby:e})}})}},14:function(e,t){e.exports=window.wp.data},15:function(e,t){e.exports=window.wp.apiFetch},188:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),c=Object(n.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(n.createElement)("title",null,"Grid Block Preview"),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"}))},21:function(e,t){e.exports=window.wp.compose},22:function(e,t){e.exports=window.regeneratorRuntime},23:function(e,t){e.exports=window.wp.url},25:function(e,t){e.exports=window.wp.htmlEntities},26:function(e,t){e.exports=window.wp.blocks},28:function(e,t){e.exports=window.wp.primitives},3:function(e,t){e.exports=window.wc.wcSettings},31:function(e,t){e.exports=window.moment},36:function(e,t){e.exports=window.wp.dataControls},37:function(e,t,r){"use strict";r.d(t,"o",(function(){return o})),r.d(t,"m",(function(){return i})),r.d(t,"l",(function(){return l})),r.d(t,"n",(function(){return a})),r.d(t,"j",(function(){return u})),r.d(t,"e",(function(){return s})),r.d(t,"f",(function(){return b})),r.d(t,"g",(function(){return d})),r.d(t,"k",(function(){return g})),r.d(t,"c",(function(){return p})),r.d(t,"d",(function(){return h})),r.d(t,"h",(function(){return f})),r.d(t,"a",(function(){return E})),r.d(t,"i",(function(){return w})),r.d(t,"b",(function(){return O}));var n,c=r(3),o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=o.pluginUrl+"images/",l=o.pluginUrl+"build/",a=o.buildPhase,u=null===(n=c.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,s=c.STORE_PAGES.checkout.id,b=c.STORE_PAGES.checkout.permalink,d=c.STORE_PAGES.privacy.permalink,g=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),p=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id),h=c.STORE_PAGES.cart.permalink,f=(c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),Object(c.getSetting)("shippingCountries",{})),E=Object(c.getSetting)("allowedCountries",{}),w=Object(c.getSetting)("shippingStates",{}),O=Object(c.getSetting)("allowedStates",{})},39:function(e,t,r){"use strict";r.d(t,"h",(function(){return g})),r.d(t,"e",(function(){return p})),r.d(t,"b",(function(){return h})),r.d(t,"i",(function(){return f})),r.d(t,"f",(function(){return E})),r.d(t,"c",(function(){return w})),r.d(t,"d",(function(){return O})),r.d(t,"g",(function(){return m})),r.d(t,"a",(function(){return j}));var n=r(5),c=r.n(n),o=r(23),i=r(15),l=r.n(i),a=r(7),u=r(3),s=r(37);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var g=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,i=e.queryArgs,u=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=void 0===n?"":n,i=e.queryArgs,l=void 0===i?{}:i,a=s.o.productCount>100,u={per_page:a?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},b=[Object(o.addQueryArgs)("/wc/store/products",d(d({},u),l))];return a&&r.length&&b.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:r,per_page:0})),b}({selected:r,search:c,queryArgs:void 0===i?{}:i});return Promise.all(u.map((function(e){return l()({path:e})}))).then((function(e){return Object(a.uniqBy)(Object(a.flatten)(e),"id").map((function(e){return d(d({},e),{},{parent:0})}))})).catch((function(e){throw e}))},p=function(e){return l()({path:"/wc/store/products/".concat(e)})},h=function(){return l()({path:"wc/store/products/attributes"})},f=function(e){return l()({path:"wc/store/products/attributes/".concat(e,"/terms")})},E=function(e){var t=e.selected,r=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=Object(u.getSetting)("limitTags",!1),i=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:c?100:0,orderby:c?"count":"name",order:c?"desc":"asc",search:n})];return c&&r.length&&i.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:r})),i}({selected:void 0===t?[]:t,search:e.search});return Promise.all(r.map((function(e){return l()({path:e})}))).then((function(e){return Object(a.uniqBy)(Object(a.flatten)(e),"id")}))},w=function(e){return l()({path:Object(o.addQueryArgs)("wc/store/products/categories",d({per_page:0},e))})},O=function(e){return l()({path:"wc/store/products/categories/".concat(e)})},m=function(e){return l()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})})},j=function(e,t){if(!e.title.raw)return e.slug;var r=1===t.filter((function(t){return t.title.raw===e.title.raw})).length;return e.title.raw+(r?"":" - ".concat(e.slug))}},4:function(e,t){e.exports=window.wp.components},46:function(e,t){e.exports=window.wp.keycodes},55:function(e,t){e.exports=window.wp.hooks},56:function(e,t){e.exports=window.wp.deprecated},66:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(16),i=r.n(o),l=r(0),a=["srcElement","size"];function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,o=i()(e,a);return Object(l.isValidElement)(t)?Object(l.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:n,height:n},o)):null}},7:function(e,t){e.exports=window.lodash},74:function(e,t){e.exports=window.wp.dom},779:function(e,t,r){e.exports=r(866)},780:function(e,t){},781:function(e,t){},84:function(e,t){e.exports=window.wp.serverSideRender},866:function(e,t,r){"use strict";r.r(t);var n=r(0),c=r(1),o=r(26),i=r(3),l=r(66),a=r(28),u=Object(n.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(n.createElement)("path",{d:"M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.97.89 1.66.89H22c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14z"}),Object(n.createElement)("circle",{cx:"9",cy:"12",r:"1.5"}),Object(n.createElement)("circle",{cx:"14",cy:"12",r:"1.5"}),Object(n.createElement)("circle",{cx:"19",cy:"12",r:"1.5"})),s=(r(780),r(5)),b=r.n(s),d=r(17),g=r.n(d),p=r(18),h=r.n(p),f=r(13),E=r.n(f),w=r(19),O=r.n(w),m=r(20),j=r.n(m),y=r(10),v=r.n(y),_=r(12),x=r(84),k=r.n(x),P=r(4),S=(r(2),r(92)),C=r(93),A=r(9),T=r.n(A),R=r(7),B=r(49),D=r(6),N=r.n(D),G=r(39);r(781);var M=function(e){O()(l,e);var t,r,o=(t=l,r=function(){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(){var e,n=v()(t);if(r){var c=v()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return j()(this,e)});function l(){var e;return g()(this,l),(e=o.apply(this,arguments)).state={list:[],loading:!0},e.renderItem=e.renderItem.bind(E()(e)),e.debouncedOnSearch=Object(R.debounce)(e.onSearch.bind(E()(e)),400),e}return h()(l,[{key:"componentDidMount",value:function(){var e=this,t=this.props.selected;Object(G.f)({selected:t}).then((function(t){e.setState({list:t,loading:!1})})).catch((function(){e.setState({list:[],loading:!1})}))}},{key:"onSearch",value:function(e){var t=this,r=this.props.selected;this.setState({loading:!0}),Object(G.f)({selected:r,search:e}).then((function(e){t.setState({list:e,loading:!1})})).catch((function(){t.setState({list:[],loading:!1})}))}},{key:"renderItem",value:function(e){var t=e.item,r=e.search,o=e.depth,i=void 0===o?0:o,l=t.breadcrumbs.length?"".concat(t.breadcrumbs.join(", "),", ").concat(t.name):t.name;return Object(n.createElement)(B.c,T()({className:N()("woocommerce-product-tags__item","has-count",{"is-searching":r.length>0,"is-skip-level":0===i&&0!==t.parent})},e,{"aria-label":Object(c.sprintf)(
/* translators: %1$d is the count of products, %2$s is the name of the tag. */
Object(c._n)("%1$d product tagged as %2$s","%1$d products tagged as %2$s",t.count,'woocommerce'),t.count,l)}))}},{key:"render",value:function(){var e=this.state,t=e.list,r=e.loading,o=this.props,l=o.isCompact,a=o.onChange,u=o.onOperatorChange,s=o.operator,b=o.selected,d={clear:Object(c.__)("Clear all product tags",'woocommerce'),list:Object(c.__)("Product Tags",'woocommerce'),noItems:Object(c.__)("Your store doesn't have any product tags.",'woocommerce'),search:Object(c.__)("Search for product tags",'woocommerce'),selected:function(e){return Object(c.sprintf)(
/* translators: %d is the count of selected tags. */
Object(c._n)("%d tag selected","%d tags selected",e,'woocommerce'),e)},updated:Object(c.__)("Tag search results updated.",'woocommerce')},g=Object(i.getSetting)("limitTags",!1);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(B.b,{className:"woocommerce-product-tags",list:t,isLoading:r,selected:b.map((function(e){return t.find((function(t){return t.id===e}))})).filter(Boolean),onChange:a,onSearch:g?this.debouncedOnSearch:null,renderItem:this.renderItem,messages:d,isCompact:l,isHierarchical:!0}),!!u&&Object(n.createElement)("div",{hidden:b.length<2},Object(n.createElement)(P.SelectControl,{className:"woocommerce-product-tags__operator",label:Object(c.__)("Display products matching",'woocommerce'),help:Object(c.__)("Pick at least two tags to use this setting.",'woocommerce'),value:s,onChange:u,options:[{label:Object(c.__)("Any selected tags",'woocommerce'),value:"any"},{label:Object(c.__)("All selected tags",'woocommerce'),value:"all"}]})))}}]),l}(n.Component);M.defaultProps={isCompact:!1,operator:"any"};var I=M,V=r(130),H=r(188);function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){b()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var q=function(e){O()(a,e);var t,r,o=(t=a,r=function(){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(){var e,n=v()(t);if(r){var c=v()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return j()(this,e)});function a(){var e;return g()(this,a),(e=o.apply(this,arguments)).state={changedAttributes:{},isEditing:!1},e.startEditing=e.startEditing.bind(E()(e)),e.stopEditing=e.stopEditing.bind(E()(e)),e.setChangedAttributes=e.setChangedAttributes.bind(E()(e)),e.save=e.save.bind(E()(e)),e}return h()(a,[{key:"componentDidMount",value:function(){this.props.attributes.tags.length||this.setState({isEditing:!0})}},{key:"startEditing",value:function(){this.setState({isEditing:!0,changedAttributes:{}})}},{key:"stopEditing",value:function(){this.setState({isEditing:!1,changedAttributes:{}})}},{key:"setChangedAttributes",value:function(e){this.setState((function(t){return{changedAttributes:Q(Q({},t.changedAttributes),e)}}))}},{key:"save",value:function(){var e=this.state.changedAttributes;(0,this.props.setAttributes)(e),this.stopEditing()}},{key:"getInspectorControls",value:function(){var e=this.props,t=e.attributes,r=e.setAttributes,o=this.state.isEditing,l=t.columns,a=t.tagOperator,u=t.contentVisibility,s=t.orderby,b=t.rows,d=t.alignButtons;return Object(n.createElement)(_.InspectorControls,{key:"inspector"},Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Product Tag",'woocommerce'),initialOpen:!t.tags.length&&!o},Object(n.createElement)(I,{selected:t.tags,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e.map((function(e){return e.id}));r({tags:t})},operator:a,onOperatorChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return r({tagOperator:e})},isCompact:!0})),Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Layout",'woocommerce'),initialOpen:!0},Object(n.createElement)(C.a,{columns:l,rows:b,alignButtons:d,setAttributes:r,minColumns:Object(i.getSetting)("min_columns",1),maxColumns:Object(i.getSetting)("max_columns",6),minRows:Object(i.getSetting)("min_rows",1),maxRows:Object(i.getSetting)("max_rows",6)})),Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Content",'woocommerce'),initialOpen:!0},Object(n.createElement)(S.a,{settings:u,onChange:function(e){return r({contentVisibility:e})}})),Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Order By",'woocommerce'),initialOpen:!1},Object(n.createElement)(V.a,{setAttributes:r,value:s})))}},{key:"renderEditMode",value:function(){var e=this,t=this.props,r=t.attributes,o=t.debouncedSpeak,i=this.state.changedAttributes,a=Q(Q({},r),i);return Object(n.createElement)(P.Placeholder,{icon:Object(n.createElement)(l.a,{srcElement:u,className:"block-editor-block-icon"}),label:Object(c.__)("Products by Tag",'woocommerce'),className:"wc-block-products-grid wc-block-product-tag"},Object(c.__)("Display a grid of products from your selected tags.",'woocommerce'),Object(n.createElement)("div",{className:"wc-block-product-tag__selection"},Object(n.createElement)(I,{selected:a.tags,onChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=t.map((function(e){return e.id}));e.setChangedAttributes({tags:r})},operator:a.tagOperator,onOperatorChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return e.setChangedAttributes({tagOperator:t})}}),Object(n.createElement)(P.Button,{isPrimary:!0,onClick:function(){e.save(),o(Object(c.__)("Showing Products by Tag block preview.",'woocommerce'))}},Object(c.__)("Done",'woocommerce')),Object(n.createElement)(P.Button,{className:"wc-block-product-tag__cancel-button",isTertiary:!0,onClick:function(){e.stopEditing(),o(Object(c.__)("Showing Products by Tag block preview.",'woocommerce'))}},Object(c.__)("Cancel",'woocommerce'))))}},{key:"renderViewMode",value:function(){var e=this.props,t=e.attributes,r=e.name,o=t.tags.length;return Object(n.createElement)(P.Disabled,null,o?Object(n.createElement)(k.a,{block:r,attributes:t}):Object(n.createElement)(P.Placeholder,{icon:Object(n.createElement)(l.a,{icon:u,className:"block-editor-block-icon"}),label:Object(c.__)("Products by Tag",'woocommerce'),className:"wc-block-products-grid wc-block-product-tag"},Object(c.__)("This block displays products from selected tags. Select at least one tag to display its products.",'woocommerce')))}},{key:"render",value:function(){var e=this,t=this.state.isEditing;return this.props.attributes.isPreview?H.a:Object(i.getSetting)("hasTags",!0)?Object(n.createElement)(n.Fragment,null,Object(n.createElement)(_.BlockControls,null,Object(n.createElement)(P.ToolbarGroup,{controls:[{icon:"edit",title:Object(c.__)("Edit"),onClick:function(){return t?e.stopEditing():e.startEditing()},isActive:t}]})),this.getInspectorControls(),t?this.renderEditMode():this.renderViewMode()):Object(n.createElement)(P.Placeholder,{icon:Object(n.createElement)(l.a,{icon:u,className:"block-editor-block-icon"}),label:Object(c.__)("Products by Tag",'woocommerce'),className:"wc-block-products-grid wc-block-product-tag"},Object(c.__)("This block displays products from selected tags. In order to preview this you'll first need to create a product and assign it some tags.",'woocommerce'))}}]),a}(n.Component),z=Object(P.withSpokenMessages)(q);Object(o.registerBlockType)("woocommerce/product-tag",{title:Object(c.__)("Products by Tag",'woocommerce'),icon:{src:Object(n.createElement)(l.a,{srcElement:u}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(c.__)("WooCommerce",'woocommerce')],description:Object(c.__)("Display a grid of products with selected tags.",'woocommerce'),supports:{align:["wide","full"],html:!1},example:{attributes:{isPreview:!0}},attributes:{columns:{type:"number",default:Object(i.getSetting)("default_columns",3)},rows:{type:"number",default:Object(i.getSetting)("default_rows",3)},alignButtons:{type:"boolean",default:!1},contentVisibility:{type:"object",default:{title:!0,price:!0,rating:!0,button:!0}},tags:{type:"array",default:[]},tagOperator:{type:"string",default:"any"},orderby:{type:"string",default:"date"},isPreview:{type:"boolean",default:!1}},edit:function(e){return Object(n.createElement)(z,e)},save:function(){return null}})},87:function(e,t){e.exports=window.ReactDOM},89:function(e,t){e.exports=window.wp.viewport},92:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),i=r(1),l=(r(2),r(4));function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){c()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}t.a=function(e){var t=e.onChange,r=e.settings,n=r.button,c=r.price,a=r.rating,s=r.title;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(l.ToggleControl,{label:Object(i.__)("Product title",'woocommerce'),help:s?Object(i.__)("Product title is visible.",'woocommerce'):Object(i.__)("Product title is hidden.",'woocommerce'),checked:s,onChange:function(){return t(u(u({},r),{},{title:!s}))}}),Object(o.createElement)(l.ToggleControl,{label:Object(i.__)("Product price",'woocommerce'),help:c?Object(i.__)("Product price is visible.",'woocommerce'):Object(i.__)("Product price is hidden.",'woocommerce'),checked:c,onChange:function(){return t(u(u({},r),{},{price:!c}))}}),Object(o.createElement)(l.ToggleControl,{label:Object(i.__)("Product rating",'woocommerce'),help:a?Object(i.__)("Product rating is visible.",'woocommerce'):Object(i.__)("Product rating is hidden.",'woocommerce'),checked:a,onChange:function(){return t(u(u({},r),{},{rating:!a}))}}),Object(o.createElement)(l.ToggleControl,{label:Object(i.__)("Add to Cart button",'woocommerce'),help:n?Object(i.__)("Add to Cart button is visible.",'woocommerce'):Object(i.__)("Add to Cart button is hidden.",'woocommerce'),checked:n,onChange:function(){return t(u(u({},r),{},{button:!n}))}}))}},93:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(7),i=(r(2),r(4));t.a=function(e){var t=e.columns,r=e.rows,l=e.setAttributes,a=e.alignButtons,u=e.minColumns,s=void 0===u?1:u,b=e.maxColumns,d=void 0===b?6:b,g=e.minRows,p=void 0===g?1:g,h=e.maxRows,f=void 0===h?6:h;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(i.RangeControl,{label:Object(c.__)("Columns",'woocommerce'),value:t,onChange:function(e){var t=Object(o.clamp)(e,s,d);l({columns:Number.isNaN(t)?"":t})},min:s,max:d}),Object(n.createElement)(i.RangeControl,{label:Object(c.__)("Rows",'woocommerce'),value:r,onChange:function(e){var t=Object(o.clamp)(e,p,f);l({rows:Number.isNaN(t)?"":t})},min:p,max:f}),Object(n.createElement)(i.ToggleControl,{label:Object(c.__)("Align Last Block",'woocommerce'),help:a?Object(c.__)("The last inner block will be aligned vertically.",'woocommerce'):Object(c.__)("The last inner block will follow other content.",'woocommerce'),checked:a,onChange:function(){return l({alignButtons:!a})}}))}},96:function(e,t){e.exports=window.wp.date}});