diff --git a/build/active-filters-frontend.asset.php b/build/active-filters-frontend.asset.php new file mode 100644 index 00000000000..7c4644b95b2 --- /dev/null +++ b/build/active-filters-frontend.asset.php @@ -0,0 +1 @@ + array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'e09af3ca58a99332252405146ba7159a'); \ No newline at end of file diff --git a/build/active-filters-frontend.js b/build/active-filters-frontend.js new file mode 100644 index 00000000000..2700762cbfa --- /dev/null +++ b/build/active-filters-frontend.js @@ -0,0 +1,15 @@ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var c=t[n]={i:n,l:!1,exports:{}};return e[n].call(c.exports,c,c.exports,r),c.l=!0,c.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)r.d(n,c,function(t){return e[t]}.bind(null,c));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=251)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},101:function(e,t){},114:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{icon:t,size:r=24,...c}=e;return Object(n.cloneElement)(t,{width:r,height:r,...c})}},115:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=e.filter(e=>e.attribute===r.taxonomy),s=o.length?o[0]:null;if(!(s&&s.slug&&Array.isArray(s.slug)&&s.slug.includes(c)))return;const a=s.slug.filter(e=>e!==c),l=e.filter(e=>e.attribute!==r.taxonomy);a.length>0&&(s.slug=a.sort(),l.push(s)),t(Object(n.sortBy)(l,"attribute"))},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const s=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(s):(s.push({attribute:r.taxonomy,operator:o,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(s,"attribute"))),s}},12:function(e,t){function r(){return e.exports=r=Object.assign||function(e){for(var t=1;t{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},s=e=>{if(e)return c.find(t=>t.taxonomy===e)}},13:function(e,t){e.exports=window.wp.isShallowEqual},139:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},14:function(e,t){e.exports=window.wp.url},15:function(e,t){e.exports=window.wp.primitives},159:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(31),s=r(2),a=r(4),l=r.n(a),i=r(19),u=r(74),b=r(20),p=r(226),d=r(71),f=r(67);r(230);var m=r(120),g=r(42),O=r(61),j=r(23),y=r(115),_=e=>{let{attributeObject:t,slugs:r=[],operator:a="in",displayStyle:l,isLoadingCallback:i}=e;const{results:b,isLoading:d}=Object(O.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[f,m]=Object(o.b)("attributes",[]);if(Object(n.useEffect)(()=>{i(d)},[d,i]),!Array.isArray(b)||!Object(p.b)(b)||!Object(p.a)(f))return null;const _=t.label,w=Object(s.getSettingWithCoercion)("is_rendering_php_template",!1,u.a);return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},_,":"),Object(n.createElement)("ul",null,r.map((e,r)=>{const o=b.find(t=>t.slug===e);if(!o)return null;let s="";return r>0&&"and"===a&&(s=Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(c.__)("All","woo-gutenberg-products-block"))),Object(g.f)({type:_,name:Object(j.decodeEntities)(o.name||e),prefix:s,isLoading:d,removeCallback:()=>{const r=f.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?Object(g.e)("query_type_"+t.name,"filter_"+t.name):Object(g.e)({["filter_"+t.name]:e}),w||Object(y.a)(f,m,t,e)},showLabel:!1,displayStyle:l})})))},w=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(n.createElement)(n.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(n.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(n.createElement)("span",{className:"show-loading-state__inner"})))):null},h=r(45);t.a=e=>{let{attributes:t,isEditor:r=!1}=e;const a=Object(h.b)(),O=function(){const e=Object(n.useRef)(!1);return Object(n.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(n.useCallback)(()=>e.current,[])}()(),j=Object(s.getSettingWithCoercion)("is_rendering_php_template",!1,u.a),[y,E]=Object(n.useState)(!0),v=Object(g.c)()&&!r&&y,[k,S]=Object(o.b)("attributes",[]),[x,A]=Object(o.b)("stock_status",[]),[P,N]=Object(o.b)("min_price"),[C,R]=Object(o.b)("max_price"),[T,L]=Object(o.b)("rating"),B=Object(s.getSetting)("stockStatusOptions",[]),F=Object(s.getSetting)("attributes",[]),M=Object(n.useMemo)(()=>{if(v||0===x.length||(e=x,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(b.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(B))return null;var e;const r=Object(c.__)("Stock Status","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,x.map(e=>Object(g.f)({type:r,name:B[e],removeCallback:()=>{if(Object(g.e)({filter_stock_status:e}),!j){const t=x.filter(t=>t!==e);A(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[v,B,x,A,t.displayStyle,j]),Q=Object(n.useMemo)(()=>v||!Number.isFinite(P)&&!Number.isFinite(C)?null:Object(g.f)({type:Object(c.__)("Price","woo-gutenberg-products-block"),name:Object(g.b)(P,C),removeCallback:()=>{Object(g.e)("max_price","min_price"),j||(N(void 0),R(void 0))},displayStyle:t.displayStyle}),[v,P,C,t.displayStyle,N,R,j]),G=Object(n.useMemo)(()=>!Object(p.a)(k)&&O||!k.length&&!Object(g.g)(F)?(y&&E(!1),null):k.map(e=>{const r=Object(m.b)(e.attribute);return r?Object(n.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:E}):(y&&E(!1),null)}),[k,O,F,y,t.displayStyle]);Object(n.useEffect)(()=>{var e;if(!j)return;if(T.length&&T.length>0)return;const t=null===(e=Object(d.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&L(t.split(","))},[j,T,L]);const U=Object(n.useMemo)(()=>{if(v||0===T.length||(e=T,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(c.__)("Rating","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,T.map(e=>Object(g.f)({type:r,name:Object(c.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(g.e)({rating_filter:e}),!j){const t=T.filter(t=>t!==e);L(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[v,T,L,t.displayStyle,j]);if(!v&&!(k.length>0||x.length>0||T.length>0||Number.isFinite(P)||Number.isFinite(C))&&!r)return a(!1),null;const Y="h"+t.headingLevel,q=Object(n.createElement)(Y,{className:"wc-block-active-filters__title"},t.heading),V=v?Object(n.createElement)(f.a,null,q):q;if(!Object(s.getSettingWithCoercion)("has_filterable_products",!1,u.a))return a(!1),null;a(!0);const D=l()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":v});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&V,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(g.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(g.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(w,{isLoading:v,displayStyle:t.displayStyle}),Q,M,G,U)),v?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(g.a)(),j||(N(void 0),R(void 0),S([]),A([]),L([]))}},Object(n.createElement)(i.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},16:function(e,t,r){"use strict";var n=r(17),c=r.n(n),o=r(0),s=r(8),a=r(1),l=r(46),i=e=>{let{imageUrl:t=l.l+"/block-error.svg",header:r=Object(a.__)("Oops!","woo-gutenberg-products-block"),text:n=Object(a.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:c,errorMessagePrefix:s=Object(a.__)("Error:","woo-gutenberg-products-block"),button:i,showErrorBlock:u=!0}=e;return u?Object(o.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(o.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(o.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},r&&Object(o.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},r),n&&Object(o.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},n),c&&Object(o.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},s?s+" ":"",c),i&&Object(o.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},i))):null};r(35);class u extends s.Component{constructor(){super(...arguments),c()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(o.createElement)(o.Fragment,null,Object(o.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:r=!0,showErrorBlock:n=!0,text:c,errorMessagePrefix:s,renderError:a,button:l}=this.props,{errorMessage:u,hasError:b}=this.state;return b?"function"==typeof a?a({errorMessage:u}):Object(o.createElement)(i,{showErrorBlock:n,errorMessage:r?u:null,header:e,imageUrl:t,text:c,errorMessagePrefix:s,button:l}):this.props.children}}t.a=u},17:function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},19:function(e,t,r){"use strict";var n=r(0),c=r(4),o=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:s,wrapperProps:a={}}=e;const l=null!=r,i=null!=c;return!l&&i?(t=s||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,c)):(t=s||n.Fragment,l&&i&&r!==c?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,a,r))}},2:function(e,t){e.exports=window.wc.wcSettings},20:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},219:function(e,t){},226:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return a}));var n=r(20);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),s=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(s)},229:function(e,t,r){"use strict";var n=r(0),c=r(15);const o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)(c.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=o},23:function(e,t){e.exports=window.wp.htmlEntities},230:function(e,t){},235:function(e,t,r){"use strict";var n=r(12),c=r.n(n),o=r(0),s=r(4),a=r.n(s),l=r(1),i=r(114),u=r(229);r(219);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:s="",radius:l="small",children:i=null,...u}=e;const b=n,p=a()(s,"wc-block-components-chip","wc-block-components-chip--radius-"+l),d=Boolean(r&&r!==t);return Object(o.createElement)(b,c()({className:p},u),Object(o.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(o.createElement)("span",{className:"screen-reader-text"},r),i)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:s=(()=>{}),removeOnAnyClick:p=!1,text:d,screenReaderText:f="",...m}=e;const g=p?"span":"button";if(!t){const e=f&&"string"==typeof f?f:d;t="string"!=typeof e? +/* translators: Remove chip. */ +Object(l.__)("Remove","woo-gutenberg-products-block"):Object(l.sprintf)( +/* translators: %s text of the chip to remove. */ +Object(l.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:s,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||s()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},m,j,{className:a()(r,"is-removable"),element:p?"button":m.element,screenReaderText:f,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},25:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0);const c=Object(n.createContext)("page"),o=()=>Object(n.useContext)(c);c.Provider},251:function(e,t,r){e.exports=r(252)},252:function(e,t,r){"use strict";r.r(t);var n=r(48),c=r(159),o=r(42);Object(n.a)({selector:".wp-block-woocommerce-active-filters",Block:c.a,getProps:e=>({attributes:Object(o.d)(e.dataset),isEditor:!1})})},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(13),o=r.n(c);function s(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},3:function(e,t){e.exports=window.wc.wcBlocksData},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e},31:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return d}));var n=r(3),c=r(6),o=r(0),s=r(13),a=r.n(s),l=r(29),i=r(62),u=r(25);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:s}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(o.useCallback)(t=>{s(e,t)},[e,s])]},p=(e,t,r)=>{const s=Object(u.a)();r=r||s;const a=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[a,Object(o.useCallback)(t=>{l(r,e,t)},[r,e,l])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),s=Object(l.a)(n),p=Object(l.a)(e),d=Object(i.a)(p),f=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},s,p)),f.current=!0)},[s,p,d,c]),f.current?[n,c]:[e,c]}},35:function(e,t){},4:function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function c(){for(var e=[],t=0;tNumber.isFinite(e)&&Number.isFinite(t)?Object(c.sprintf)( +/* translators: %1$s min price, %2$s max price */ +Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(o.formatPrice)(e),Object(o.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)( +/* translators: %s min price */ +Object(c.__)("From %s","woo-gutenberg-products-block"),Object(o.formatPrice)(e)):Object(c.sprintf)( +/* translators: %s max price */ +Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(o.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:o="",removeCallback:l=(()=>null),showLabel:i=!0,displayStyle:p}=e;const d=o?Object(n.createElement)(n.Fragment,null,o," ",r):r,f=Object(c.sprintf)( +/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */ +Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},i&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===p?Object(n.createElement)(s.a,{element:"span",text:d,onRemove:l,radius:"large",ariaLabel:f}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:l},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(a.a,{screenReaderLabel:f})),d))},g=function(){if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const s=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(l.addQueryArgs)(r,s);Object(i.c)(a)},O=["min_price","max_price","rating_filter","filter_","query_type_"],j=e=>{let t=!1;for(let r=0;O.length>r;r++){const n=O[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object(l.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!j(e)).map(e=>[e,t[e]])),c=Object(l.addQueryArgs)(r,n);Object(i.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(l.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(j(t)){n=!0;break}}return n},w=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(l.getQueryArgs)(r),c=Object.keys(n);let o=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){o=!0;break}}return o},h=e=>({heading:Object(p.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(p.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(p.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},45:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(0);const c=Object(n.createContext)({}),o=()=>{const{wrapper:e}=Object(n.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},46:function(e,t,r){"use strict";r.d(t,"n",(function(){return o})),r.d(t,"l",(function(){return s})),r.d(t,"k",(function(){return a})),r.d(t,"m",(function(){return l})),r.d(t,"i",(function(){return i})),r.d(t,"d",(function(){return u})),r.d(t,"f",(function(){return b})),r.d(t,"j",(function(){return p})),r.d(t,"c",(function(){return d})),r.d(t,"e",(function(){return f})),r.d(t,"g",(function(){return m})),r.d(t,"a",(function(){return g})),r.d(t,"h",(function(){return O})),r.d(t,"b",(function(){return j}));var n,c=r(2);const o=Object(c.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),s=o.pluginUrl+"images/",a=o.pluginUrl+"build/",l=o.buildPhase,i=null===(n=c.STORE_PAGES.shop)||void 0===n?void 0:n.permalink,u=(c.STORE_PAGES.checkout.id,c.STORE_PAGES.checkout.permalink),b=c.STORE_PAGES.privacy.permalink,p=(c.STORE_PAGES.privacy.title,c.STORE_PAGES.terms.permalink),d=(c.STORE_PAGES.terms.title,c.STORE_PAGES.cart.id,c.STORE_PAGES.cart.permalink),f=c.STORE_PAGES.myaccount.permalink?c.STORE_PAGES.myaccount.permalink:Object(c.getSetting)("wpLoginUrl","/wp-login.php"),m=Object(c.getSetting)("shippingCountries",{}),g=Object(c.getSetting)("allowedCountries",{}),O=Object(c.getSetting)("shippingStates",{}),j=Object(c.getSetting)("allowedStates",{})},48:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(12),c=r.n(n),o=r(0),s=r(16);const a=[".wp-block-woocommerce-cart"],l=e=>{let{Block:t,containers:r,getProps:n=(()=>({})),getErrorBoundaryProps:a=(()=>({}))}=e;0!==r.length&&Array.prototype.forEach.call(r,(e,r)=>{const l=n(e,r),i=a(e,r),u={...e.dataset,...l.attributes||{}};(e=>{let{Block:t,container:r,attributes:n={},props:a={},errorBoundaryProps:l={}}=e;Object(o.render)(Object(o.createElement)(s.a,l,Object(o.createElement)(o.Suspense,{fallback:Object(o.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(o.createElement)(t,c()({},a,{attributes:n})))),r,()=>{r.classList&&r.classList.remove("is-loading")})})({Block:t,container:e,props:l,attributes:u,errorBoundaryProps:i})})},i=e=>{const t=document.body.querySelectorAll(a.join(",")),{Block:r,getProps:n,getErrorBoundaryProps:c,selector:o}=e;(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:n,selector:c,wrappers:o}=e;const s=document.body.querySelectorAll(c);o&&o.length>0&&Array.prototype.filter.call(s,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,o)),l({Block:t,containers:s,getProps:r,getErrorBoundaryProps:n})})({Block:r,getProps:n,getErrorBoundaryProps:c,selector:o,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:r,getErrorBoundaryProps:n,selector:c,wrapper:o}=e;const s=o.querySelectorAll(c);l({Block:t,containers:s,getProps:r,getErrorBoundaryProps:n})})({...e,wrapper:t})})})}},5:function(e,t){e.exports=window.lodash},6:function(e,t){e.exports=window.wp.data},61:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(3),c=r(6),o=r(0),s=r(29),a=r(76);const l=e=>{const{namespace:t,resourceName:r,resourceValues:l=[],query:i={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),p=Object(s.a)(i),d=Object(s.a)(l),f=Object(a.a)(),m=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,p,d],s=c.getCollectionError(...o);if(s){if(!(s instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");f(s)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==m&&(b.current=m),b.current}},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(8);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},67:function(e,t,r){"use strict";var n=r(0);r(101),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},71:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return l})),r.d(t,"d",(function(){return i})),r.d(t,"c",(function(){return u}));var n=r(14),c=r(2),o=r(74);const s=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",l="filter_";function i(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){s?window.location.href=e:window.history.replaceState({},"",e)}},74:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},76:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}},8:function(e,t){e.exports=window.React}}); \ No newline at end of file diff --git a/build/active-filters-wrapper-frontend.js b/build/active-filters-wrapper-frontend.js new file mode 100644 index 00000000000..783b82e6400 --- /dev/null +++ b/build/active-filters-wrapper-frontend.js @@ -0,0 +1,15 @@ +(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{101:function(e,t){},114:function(e,t,r){"use strict";var n=r(0);t.a=function(e){let{icon:t,size:r=24,...c}=e;return Object(n.cloneElement)(t,{width:r,height:r,...c})}},115:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return a}));var n=r(5);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=e.filter(e=>e.attribute===r.taxonomy),l=a.length?a[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(c)))return;const s=l.slug.filter(e=>e!==c),i=e.filter(e=>e.attribute!==r.taxonomy);s.length>0&&(l.slug=s.sort(),i.push(l)),t(Object(n.sortBy)(i,"attribute"))},a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const l=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(l):(l.push({attribute:r.taxonomy,operator:a,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(l,"attribute"))),l}},120:function(e,t,r){"use strict";r.d(t,"a",(function(){return a})),r.d(t,"b",(function(){return l}));var n=r(2);const c=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),a=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},139:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},159:function(e,t,r){"use strict";var n=r(0),c=r(1),a=r(31),l=r(2),s=r(4),i=r.n(s),o=r(19),u=r(74),b=r(20),f=r(226),d=r(71),p=r(67);r(230);var m=r(120),O=r(42),j=r(61),g=r(23),y=r(115),_=e=>{let{attributeObject:t,slugs:r=[],operator:s="in",displayStyle:i,isLoadingCallback:o}=e;const{results:b,isLoading:d}=Object(j.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[p,m]=Object(a.b)("attributes",[]);if(Object(n.useEffect)(()=>{o(d)},[d,o]),!Array.isArray(b)||!Object(f.b)(b)||!Object(f.a)(p))return null;const _=t.label,v=Object(l.getSettingWithCoercion)("is_rendering_php_template",!1,u.a);return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},_,":"),Object(n.createElement)("ul",null,r.map((e,r)=>{const a=b.find(t=>t.slug===e);if(!a)return null;let l="";return r>0&&"and"===s&&(l=Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(c.__)("All","woo-gutenberg-products-block"))),Object(O.f)({type:_,name:Object(g.decodeEntities)(a.name||e),prefix:l,isLoading:d,removeCallback:()=>{const r=p.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?Object(O.e)("query_type_"+t.name,"filter_"+t.name):Object(O.e)({["filter_"+t.name]:e}),v||Object(y.a)(p,m,t,e)},showLabel:!1,displayStyle:i})})))},v=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(n.createElement)(n.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(n.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(n.createElement)("span",{className:"show-loading-state__inner"})))):null},h=r(45);t.a=e=>{let{attributes:t,isEditor:r=!1}=e;const s=Object(h.b)(),j=function(){const e=Object(n.useRef)(!1);return Object(n.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(n.useCallback)(()=>e.current,[])}()(),g=Object(l.getSettingWithCoercion)("is_rendering_php_template",!1,u.a),[y,w]=Object(n.useState)(!0),k=Object(O.c)()&&!r&&y,[E,S]=Object(a.b)("attributes",[]),[N,x]=Object(a.b)("stock_status",[]),[A,C]=Object(a.b)("min_price"),[L,R]=Object(a.b)("max_price"),[F,T]=Object(a.b)("rating"),Q=Object(l.getSetting)("stockStatusOptions",[]),P=Object(l.getSetting)("attributes",[]),B=Object(n.useMemo)(()=>{if(k||0===N.length||(e=N,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(b.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(Q))return null;var e;const r=Object(c.__)("Stock Status","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,N.map(e=>Object(O.f)({type:r,name:Q[e],removeCallback:()=>{if(Object(O.e)({filter_stock_status:e}),!g){const t=N.filter(t=>t!==e);x(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[k,Q,N,x,t.displayStyle,g]),Y=Object(n.useMemo)(()=>k||!Number.isFinite(A)&&!Number.isFinite(L)?null:Object(O.f)({type:Object(c.__)("Price","woo-gutenberg-products-block"),name:Object(O.b)(A,L),removeCallback:()=>{Object(O.e)("max_price","min_price"),g||(C(void 0),R(void 0))},displayStyle:t.displayStyle}),[k,A,L,t.displayStyle,C,R,g]),V=Object(n.useMemo)(()=>!Object(f.a)(E)&&j||!E.length&&!Object(O.g)(P)?(y&&w(!1),null):E.map(e=>{const r=Object(m.b)(e.attribute);return r?Object(n.createElement)(_,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:w}):(y&&w(!1),null)}),[E,j,P,y,t.displayStyle]);Object(n.useEffect)(()=>{var e;if(!g)return;if(F.length&&F.length>0)return;const t=null===(e=Object(d.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&T(t.split(","))},[g,F,T]);const K=Object(n.useMemo)(()=>{if(k||0===F.length||(e=F,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(c.__)("Rating","woo-gutenberg-products-block");return Object(n.createElement)("li",null,Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(n.createElement)("ul",null,F.map(e=>Object(O.f)({type:r,name:Object(c.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(Object(O.e)({rating_filter:e}),!g){const t=F.filter(t=>t!==e);T(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[k,F,T,t.displayStyle,g]);if(!k&&!(E.length>0||N.length>0||F.length>0||Number.isFinite(A)||Number.isFinite(L))&&!r)return s(!1),null;const W="h"+t.headingLevel,U=Object(n.createElement)(W,{className:"wc-block-active-filters__title"},t.heading),z=k?Object(n.createElement)(p.a,null,U):U;if(!Object(l.getSettingWithCoercion)("has_filterable_products",!1,u.a))return s(!1),null;s(!0);const D=i()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":k});return Object(n.createElement)(n.Fragment,null,!r&&t.heading&&z,Object(n.createElement)("div",{className:"wc-block-active-filters"},Object(n.createElement)("ul",{className:D},r?Object(n.createElement)(n.Fragment,null,Object(O.f)({type:Object(c.__)("Size","woo-gutenberg-products-block"),name:Object(c.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),Object(O.f)({type:Object(c.__)("Color","woo-gutenberg-products-block"),name:Object(c.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(v,{isLoading:k,displayStyle:t.displayStyle}),Y,B,V,K)),k?Object(n.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(n.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{Object(O.a)(),g||(C(void 0),R(void 0),S([]),x([]),T([]))}},Object(n.createElement)(o.a,{label:Object(c.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(c.__)("Clear All Filters","woo-gutenberg-products-block")}))))}},19:function(e,t,r){"use strict";var n=r(0),c=r(4),a=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:l,wrapperProps:s={}}=e;const i=null!=r,o=null!=c;return!i&&o?(t=l||"span",s={...s,className:a()(s.className,"screen-reader-text")},Object(n.createElement)(t,s,c)):(t=l||n.Fragment,i&&o&&r!==c?Object(n.createElement)(t,s,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,s,r))}},20:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},216:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r(100);var n=r(46);const c=()=>n.m>1},217:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(30),c=r(20);const a=e=>Object(n.a)(e)?JSON.parse(e)||{}:Object(c.a)(e)?e:{}},219:function(e,t){},226:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return s}));var n=r(20);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,a=e=>Array.isArray(e)&&e.every(c),l=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),s=e=>Array.isArray(e)&&e.every(l)},229:function(e,t,r){"use strict";var n=r(0),c=r(15);const a=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(n.createElement)(c.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));t.a=a},230:function(e,t){},235:function(e,t,r){"use strict";var n=r(12),c=r.n(n),a=r(0),l=r(4),s=r.n(l),i=r(1),o=r(114),u=r(229);r(219);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:l="",radius:i="small",children:o=null,...u}=e;const b=n,f=s()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+i),d=Boolean(r&&r!==t);return Object(a.createElement)(b,c()({className:f},u),Object(a.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(a.createElement)("span",{className:"screen-reader-text"},r),o)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:l=(()=>{}),removeOnAnyClick:f=!1,text:d,screenReaderText:p="",...m}=e;const O=f?"span":"button";if(!t){const e=p&&"string"==typeof p?p:d;t="string"!=typeof e? +/* translators: Remove chip. */ +Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)( +/* translators: %s text of the chip to remove. */ +Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const j={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},g=f?j:{},y=f?{"aria-hidden":!0}:j;return Object(a.createElement)(b,c()({},m,g,{className:s()(r,"is-removable"),element:f?"button":m.element,screenReaderText:p,text:d}),Object(a.createElement)(O,c()({className:"wc-block-components-chip__remove"},y),Object(a.createElement)(o.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},25:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0);const c=Object(n.createContext)("page"),a=()=>Object(n.useContext)(c);c.Provider},29:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(0),c=r(13),a=r.n(c);function l(e){const t=Object(n.useRef)(e);return a()(e,t.current)||(t.current=e),t.current}},292:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(111),c=r(216),a=r(20),l=r(217);const s=e=>{if(!Object(c.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},r=Object(l.a)(t.style);return Object(n.__experimentalUseColorProps)({...t,style:r})}},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e},31:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return f})),r.d(t,"c",(function(){return d}));var n=r(3),c=r(6),a=r(0),l=r(13),s=r.n(l),i=r(29),o=r(62),u=r(25);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(a.useCallback)(t=>{l(e,t)},[e,l])]},f=(e,t,r)=>{const l=Object(u.a)();r=r||l;const s=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:i}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[s,Object(a.useCallback)(t=>{i(r,e,t)},[r,e,i])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),l=Object(i.a)(n),f=Object(i.a)(e),d=Object(o.a)(f),p=Object(a.useRef)(!1);return Object(a.useEffect)(()=>{s()(d,f)||(c(Object.assign({},l,f)),p.current=!0)},[l,f,d,c]),p.current?[n,c]:[e,c]}},4:function(e,t,r){var n;!function(){"use strict";var r={}.hasOwnProperty;function c(){for(var e=[],t=0;tNumber.isFinite(e)&&Number.isFinite(t)?Object(c.sprintf)( +/* translators: %1$s min price, %2$s max price */ +Object(c.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(a.formatPrice)(e),Object(a.formatPrice)(t)):Number.isFinite(e)?Object(c.sprintf)( +/* translators: %s min price */ +Object(c.__)("From %s","woo-gutenberg-products-block"),Object(a.formatPrice)(e)):Object(c.sprintf)( +/* translators: %s max price */ +Object(c.__)("Up to %s","woo-gutenberg-products-block"),Object(a.formatPrice)(t)),m=e=>{let{type:t,name:r,prefix:a="",removeCallback:i=(()=>null),showLabel:o=!0,displayStyle:f}=e;const d=a?Object(n.createElement)(n.Fragment,null,a," ",r):r,p=Object(c.sprintf)( +/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */ +Object(c.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(n.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},o&&Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===f?Object(n.createElement)(l.a,{element:"span",text:d,onRemove:i,radius:"large",ariaLabel:p}):Object(n.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(n.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:i},Object(n.createElement)(u.a,{className:"wc-block-components-chip__remove-icon",icon:b.a,size:16}),Object(n.createElement)(s.a,{screenReaderLabel:p})),d))},O=function(){if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),a=0;a{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),s=Object(i.addQueryArgs)(r,l);Object(o.c)(s)},j=["min_price","max_price","rating_filter","filter_","query_type_"],g=e=>{let t=!1;for(let r=0;j.length>r;r++){const n=j[r];if(n===e.substring(0,n.length)){t=!0;break}}return t},y=()=>{if(!window)return;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object(i.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!g(e)).map(e=>[e,t[e]])),c=Object(i.addQueryArgs)(r,n);Object(o.c)(c)},_=()=>{if(!window)return!1;const e=window.location.href,t=Object(i.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(g(t)){n=!0;break}}return n},v=e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(i.getQueryArgs)(r),c=Object.keys(n);let a=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){a=!0;break}}return a},h=e=>({heading:Object(f.a)(null==e?void 0:e.heading)?e.heading:"",headingLevel:Object(f.a)(null==e?void 0:e.headingLevel)&&parseInt(e.headingLevel,10)||d.attributes.headingLevel.default,displayStyle:Object(f.a)(null==e?void 0:e.displayStyle)&&e.displayStyle||d.attributes.displayStyle.default})},456:function(e,t,r){"use strict";r.r(t);var n=r(0),c=r(292),a=r(30),l=r(159),s=r(42);t.default=e=>{const t=Object(c.a)(e);return Object(n.createElement)("div",{className:Object(a.a)(e.className)?e.className:"",style:{...t.style}},Object(n.createElement)(l.a,{isEditor:!1,attributes:Object(s.d)(e)}))}},61:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(3),c=r(6),a=r(0),l=r(29),s=r(76);const i=e=>{const{namespace:t,resourceName:r,resourceValues:i=[],query:o={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(a.useRef)({results:[],isLoading:!0}),f=Object(l.a)(o),d=Object(l.a)(i),p=Object(s.a)(),m=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),a=[t,r,f,d],l=c.getCollectionError(...a);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");p(l)}return{results:c.getCollection(...a),isLoading:!c.hasFinishedResolution("getCollection",a)}},[t,r,d,f,u]);return null!==m&&(b.current=m),b.current}},62:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(8);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},67:function(e,t,r){"use strict";var n=r(0);r(101),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},71:function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return i})),r.d(t,"d",(function(){return o})),r.d(t,"c",(function(){return u}));var n=r(14),c=r(2),a=r(74);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,a.a),s="query_type_",i="filter_";function o(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},74:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},76:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}}}]); \ No newline at end of file diff --git a/build/active-filters.asset.php b/build/active-filters.asset.php new file mode 100644 index 00000000000..744d316b64d --- /dev/null +++ b/build/active-filters.asset.php @@ -0,0 +1 @@ + array('lodash', 'react', 'wc-blocks-data-store', 'wc-price-format', 'wc-settings', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'c27e4d28804e4ed8e41cc91a6802d542'); \ No newline at end of file diff --git a/build/active-filters.js b/build/active-filters.js new file mode 100644 index 00000000000..0b31e066650 --- /dev/null +++ b/build/active-filters.js @@ -0,0 +1,15 @@ +this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["active-filters"]=function(e){function t(t){for(var n,l,a=t[0],i=t[1],s=t[2],b=0,p=[];b{const{wrapper:e}=Object(n.useContext)(c);return t=>{e&&e.current&&(e.current.hidden=!t)}}},103:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(12);function c(e,t){const r=Object(n.useRef)();return Object(n.useEffect)(()=>{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},107:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(9),c=r(7),o=r(0),l=r(40),a=r(142);const i=e=>{const{namespace:t,resourceName:r,resourceValues:i=[],query:s={},shouldSelect:u=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const b=Object(o.useRef)({results:[],isLoading:!0}),p=Object(l.a)(s),d=Object(l.a)(i),m=Object(a.a)(),f=Object(c.useSelect)(e=>{if(!u)return null;const c=e(n.COLLECTIONS_STORE_KEY),o=[t,r,p,d],l=c.getCollectionError(...o);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");m(l)}return{results:c.getCollection(...o),isLoading:!c.hasFinishedResolution("getCollection",o)}},[t,r,d,p,u]);return null!==f&&(b.current=f),b.current}},11:function(e,t){e.exports=window.wp.compose},12:function(e,t){e.exports=window.React},122:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),c=r(1),o=r(10),l=r(7),a=r(3),i=r(5);const s=e=>{let{clientId:t,setAttributes:r,filterType:s,attributes:u}=e;const{replaceBlock:b}=Object(l.useDispatch)("core/block-editor"),{heading:p,headingLevel:d}=u;if(Object(l.useSelect)(e=>{const{getBlockParentsByBlockName:r}=e("core/block-editor");return r(t,"woocommerce/filter-wrapper").length>0},[t])||!s)return null;const m=[Object(n.createElement)(a.Button,{key:"convert",onClick:()=>{const e=[Object(o.createBlock)("woocommerce/"+s,{...u,heading:""})];p&&""!==p&&e.unshift(Object(o.createBlock)("core/heading",{content:p,level:null!=d?d:2})),b(t,Object(o.createBlock)("woocommerce/filter-wrapper",{heading:p,filterType:s},[...e])),r({heading:"",lock:{remove:!0}})},variant:"primary"},Object(c.__)("Upgrade block","woo-gutenberg-products-block"))];return Object(n.createElement)(i.Warning,{actions:m},Object(c.__)("Filter block: We have improved this block to make styling easier. Upgrade it using the button below.","woo-gutenberg-products-block"))}},123:function(e,t,r){"use strict";var n=r(0),c=r(5),o=r(11),l=r(1);r(168),t.a=Object(o.withInstanceId)(e=>{let{className:t,headingLevel:r,onChange:o,heading:a,instanceId:i}=e;const s="h"+r;return Object(n.createElement)(s,{className:t},Object(n.createElement)("label",{className:"screen-reader-text",htmlFor:"block-title-"+i},Object(l.__)("Block title","woo-gutenberg-products-block")),Object(n.createElement)(c.PlainText,{id:"block-title-"+i,className:"wc-block-editor-components-title",value:a,onChange:o}))})},124:function(e,t,r){"use strict";var n=r(0);r(169),t.a=e=>{let{children:t}=e;return Object(n.createElement)("div",{className:"wc-block-filter-title-placeholder"},t)}},127:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"boolean"==typeof e},13:function(e,t){e.exports=window.wp.primitives},142:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0);const c=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}},15:function(e,t){e.exports=window.wp.htmlEntities},16:function(e,t){e.exports=window.wp.url},168:function(e,t){},169:function(e,t){},183:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return o}));var n=r(8);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=e.filter(e=>e.attribute===r.taxonomy),l=o.length?o[0]:null;if(!(l&&l.slug&&Array.isArray(l.slug)&&l.slug.includes(c)))return;const a=l.slug.filter(e=>e!==c),i=e.filter(e=>e.attribute!==r.taxonomy);a.length>0&&(l.slug=a.sort(),i.push(l)),t(Object(n.sortBy)(i,"attribute"))},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"in";if(!r||!r.taxonomy)return[];const l=e.filter(e=>e.attribute!==r.taxonomy);return 0===c.length?t(l):(l.push({attribute:r.taxonomy,operator:o,slug:c.map(e=>{let{slug:t}=e;return t}).sort()}),t(Object(n.sortBy)(l,"attribute"))),l}},185:function(e){e.exports=JSON.parse('{"name":"woocommerce/active-filters","version":"1.0.0","title":"Active Product Filters Controls","description":"Display the currently active product filters.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"inserter":false,"color":{"text":true,"background":false},"lock":false},"attributes":{"displayStyle":{"type":"string","default":"list"},"headingLevel":{"type":"number","default":3}},"textdomain":"woo-gutenberg-products-block","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')},2:function(e,t){e.exports=window.wc.wcSettings},200:function(e,t){},223:function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return l}));var n=r(2);const c=Object(n.getSetting)("attributes",[]).reduce((e,t)=>{const r=(n=t)&&n.attribute_name?{id:parseInt(n.attribute_id,10),name:n.attribute_name,taxonomy:"pa_"+n.attribute_name,label:n.attribute_label}:null;var n;return r&&r.id&&e.push(r),e},[]),o=e=>{if(e)return c.find(t=>t.id===e)},l=e=>{if(e)return c.find(t=>t.taxonomy===e)}},241:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i})),r.d(t,"d",(function(){return s})),r.d(t,"c",(function(){return u}));var n=r(16),c=r(2),o=r(127);const l=Object(c.getSettingWithCoercion)("is_rendering_php_template",!1,o.a),a="query_type_",i="filter_";function s(e){return window?Object(n.getQueryArg)(window.location.href,e):null}function u(e){l?window.location.href=e:window.history.replaceState({},"",e)}},25:function(e,t){e.exports=window.wp.isShallowEqual},256:function(e,t,r){"use strict";var n=r(6),c=r.n(n),o=r(0),l=r(4),a=r.n(l),i=r(1),s=r(117),u=r(548);r(200);var b=e=>{let{text:t,screenReaderText:r="",element:n="li",className:l="",radius:i="small",children:s=null,...u}=e;const b=n,p=a()(l,"wc-block-components-chip","wc-block-components-chip--radius-"+i),d=Boolean(r&&r!==t);return Object(o.createElement)(b,c()({className:p},u),Object(o.createElement)("span",{"aria-hidden":d,className:"wc-block-components-chip__text"},t),d&&Object(o.createElement)("span",{className:"screen-reader-text"},r),s)};t.a=e=>{let{ariaLabel:t="",className:r="",disabled:n=!1,onRemove:l=(()=>{}),removeOnAnyClick:p=!1,text:d,screenReaderText:m="",...f}=e;const g=p?"span":"button";if(!t){const e=m&&"string"==typeof m?m:d;t="string"!=typeof e? +/* translators: Remove chip. */ +Object(i.__)("Remove","woo-gutenberg-products-block"):Object(i.sprintf)( +/* translators: %s text of the chip to remove. */ +Object(i.__)('Remove "%s"',"woo-gutenberg-products-block"),e)}const O={"aria-label":t,disabled:n,onClick:l,onKeyDown:e=>{"Backspace"!==e.key&&"Delete"!==e.key||l()}},j=p?O:{},y=p?{"aria-hidden":!0}:O;return Object(o.createElement)(b,c()({},f,j,{className:a()(r,"is-removable"),element:p?"button":f.element,screenReaderText:m,text:d}),Object(o.createElement)(g,c()({className:"wc-block-components-chip__remove"},y),Object(o.createElement)(s.a,{className:"wc-block-components-chip__remove-icon",icon:u.a,size:16})))}},26:function(e,t){e.exports=window.wc.priceFormat},28:function(e,t,r){"use strict";var n=r(0),c=r(4),o=r.n(c);t.a=e=>{let t,{label:r,screenReaderLabel:c,wrapperElement:l,wrapperProps:a={}}=e;const i=null!=r,s=null!=c;return!i&&s?(t=l||"span",a={...a,className:o()(a.className,"screen-reader-text")},Object(n.createElement)(t,a,c)):(t=l||n.Fragment,i&&s&&r!==c?Object(n.createElement)(t,a,Object(n.createElement)("span",{"aria-hidden":"true"},r),Object(n.createElement)("span",{className:"screen-reader-text"},c)):Object(n.createElement)(t,a,r))}},3:function(e,t){e.exports=window.wp.components},35:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return c}));const n=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function c(e,t){return n(e)&&t in e}},40:function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var n=r(0),c=r(25),o=r.n(c);function l(e){const t=Object(n.useRef)(e);return o()(e,t.current)||(t.current=e),t.current}},410:function(e,t,r){"use strict";r.d(t,"b",(function(){return o})),r.d(t,"a",(function(){return a}));var n=r(35);const c=e=>Object(n.b)(e,"count")&&Object(n.b)(e,"description")&&Object(n.b)(e,"id")&&Object(n.b)(e,"name")&&Object(n.b)(e,"parent")&&Object(n.b)(e,"slug")&&"number"==typeof e.count&&"string"==typeof e.description&&"number"==typeof e.id&&"string"==typeof e.name&&"number"==typeof e.parent&&"string"==typeof e.slug,o=e=>Array.isArray(e)&&e.every(c),l=e=>Object(n.b)(e,"attribute")&&Object(n.b)(e,"operator")&&Object(n.b)(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every(e=>"string"==typeof e),a=e=>Array.isArray(e)&&e.every(l)},417:function(e,t,r){e.exports=r(482)},418:function(e,t,r){"use strict";var n=r(0),c=r(13);const o=Object(n.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(n.createElement)("path",{fill:"none",d:"M0 0h24v24H0z"}),Object(n.createElement)("path",{d:"M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zm0-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"}));t.a=o},419:function(e,t){},420:function(e,t){},46:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0);const c=Object(n.createContext)("page"),o=()=>Object(n.useContext)(c);c.Provider},482:function(e,t,r){"use strict";r.r(t);var n=r(6),c=r.n(n),o=r(0),l=r(10),a=r(418),i=r(117),s=r(4),u=r.n(s),b=r(5),p=r(1),d=r(123),m=r(3),f=r(52),g=r(2),O=r(28),j=r(127),y=r(35),w=r(410),_=r(241),h=r(124);r(420);var v=r(223),k=r(26),E=r(256),S=r(16),x=r(548),N=(r(96),r(185));const C=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)?Object(p.sprintf)( +/* translators: %1$s min price, %2$s max price */ +Object(p.__)("Between %1$s and %2$s","woo-gutenberg-products-block"),Object(k.formatPrice)(e),Object(k.formatPrice)(t)):Number.isFinite(e)?Object(p.sprintf)( +/* translators: %s min price */ +Object(p.__)("From %s","woo-gutenberg-products-block"),Object(k.formatPrice)(e)):Object(p.sprintf)( +/* translators: %s max price */ +Object(p.__)("Up to %s","woo-gutenberg-products-block"),Object(k.formatPrice)(t)),A=e=>{let{type:t,name:r,prefix:n="",removeCallback:c=(()=>null),showLabel:l=!0,displayStyle:a}=e;const s=n?Object(o.createElement)(o.Fragment,null,n," ",r):r,u=Object(p.sprintf)( +/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */ +Object(p.__)("Remove %s filter","woo-gutenberg-products-block"),r);return Object(o.createElement)("li",{className:"wc-block-active-filters__list-item",key:t+":"+r},l&&Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},t+": "),"chips"===a?Object(o.createElement)(E.a,{element:"span",text:s,onRemove:c,radius:"large",ariaLabel:u}):Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-name"},Object(o.createElement)("button",{className:"wc-block-active-filters__list-item-remove",onClick:c},Object(o.createElement)(i.a,{className:"wc-block-components-chip__remove-icon",icon:x.a,size:16}),Object(o.createElement)(O.a,{screenReaderLabel:u})),s))},R=function(){if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t));for(var n=arguments.length,c=new Array(n),o=0;o{if("string"==typeof e)return delete t[e];if("object"==typeof e){const r=Object.keys(e)[0],n=t[r].toString().split(",");t[r]=n.filter(t=>t!==e[r]).join(",")}});const l=Object.fromEntries(Object.entries(t).filter(e=>{let[,t]=e;return t})),a=Object(S.addQueryArgs)(r,l);Object(_.c)(a)},T=["min_price","max_price","rating_filter","filter_","query_type_"],L=e=>{let t=!1;for(let r=0;T.length>r;r++){const n=T[r];if(n===e.substring(0,n.length)){t=!0;break}}return t};var B=r(107),F=r(15),P=r(183),Q=e=>{let{attributeObject:t,slugs:r=[],operator:n="in",displayStyle:c,isLoadingCallback:l}=e;const{results:a,isLoading:i}=Object(B.a)({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[t.id]}),[s,u]=Object(f.b)("attributes",[]);if(Object(o.useEffect)(()=>{l(i)},[i,l]),!Array.isArray(a)||!Object(w.b)(a)||!Object(w.a)(s))return null;const b=t.label,d=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,j.a);return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},b,":"),Object(o.createElement)("ul",null,r.map((e,r)=>{const l=a.find(t=>t.slug===e);if(!l)return null;let m="";return r>0&&"and"===n&&(m=Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-operator"},Object(p.__)("All","woo-gutenberg-products-block"))),A({type:b,name:Object(F.decodeEntities)(l.name||e),prefix:m,isLoading:i,removeCallback:()=>{const r=s.find(e=>{let{attribute:r}=e;return r==="pa_"+t.name});1===(null==r?void 0:r.slug.length)?R("query_type_"+t.name,"filter_"+t.name):R({["filter_"+t.name]:e}),d||Object(P.a)(s,u,t,e)},showLabel:!1,displayStyle:c})})))},M=e=>{let{displayStyle:t,isLoading:r}=e;return r?Object(o.createElement)(o.Fragment,null,[...Array("list"===t?2:3)].map((e,r)=>Object(o.createElement)("li",{className:"list"===t?"show-loading-state-list":"show-loading-state-chips",key:r},Object(o.createElement)("span",{className:"show-loading-state__inner"})))):null},D=r(102),I=e=>{let{attributes:t,isEditor:r=!1}=e;const n=Object(D.a)(),c=function(){const e=Object(o.useRef)(!1);return Object(o.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),Object(o.useCallback)(()=>e.current,[])}()(),l=Object(g.getSettingWithCoercion)("is_rendering_php_template",!1,j.a),[a,i]=Object(o.useState)(!0),s=(()=>{if(!window)return!1;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object.keys(t);let n=!1;for(let e=0;r.length>e;e++){const t=r[e];if(L(t)){n=!0;break}}return n})()&&!r&&a,[b,d]=Object(f.b)("attributes",[]),[m,k]=Object(f.b)("stock_status",[]),[E,x]=Object(f.b)("min_price"),[N,T]=Object(f.b)("max_price"),[B,F]=Object(f.b)("rating"),P=Object(g.getSetting)("stockStatusOptions",[]),I=Object(g.getSetting)("attributes",[]),V=Object(o.useMemo)(()=>{if(s||0===m.length||(e=m,!Array.isArray(e)||!e.every(e=>["instock","outofstock","onbackorder"].includes(e)))||!(e=>Object(y.a)(e)&&Object.keys(e).every(e=>["instock","outofstock","onbackorder"].includes(e)))(P))return null;var e;const r=Object(p.__)("Stock Status","woo-gutenberg-products-block");return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(o.createElement)("ul",null,m.map(e=>A({type:r,name:P[e],removeCallback:()=>{if(R({filter_stock_status:e}),!l){const t=m.filter(t=>t!==e);k(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[s,P,m,k,t.displayStyle,l]),W=Object(o.useMemo)(()=>s||!Number.isFinite(E)&&!Number.isFinite(N)?null:A({type:Object(p.__)("Price","woo-gutenberg-products-block"),name:C(E,N),removeCallback:()=>{R("max_price","min_price"),l||(x(void 0),T(void 0))},displayStyle:t.displayStyle}),[s,E,N,t.displayStyle,x,T,l]),Y=Object(o.useMemo)(()=>!Object(w.a)(b)&&c||!b.length&&!(e=>{if(!window)return!1;const t=e.map(e=>"filter_"+e.attribute_name),r=window.location.href,n=Object(S.getQueryArgs)(r),c=Object.keys(n);let o=!1;for(let e=0;c.length>e;e++){const r=c[e];if(t.includes(r)){o=!0;break}}return o})(I)?(a&&i(!1),null):b.map(e=>{const r=Object(v.b)(e.attribute);return r?Object(o.createElement)(Q,{attributeObject:r,displayStyle:t.displayStyle,slugs:e.slug,key:e.attribute,operator:e.operator,isLoadingCallback:i}):(a&&i(!1),null)}),[b,c,I,a,t.displayStyle]);Object(o.useEffect)(()=>{var e;if(!l)return;if(B.length&&B.length>0)return;const t=null===(e=Object(_.d)("rating_filter"))||void 0===e?void 0:e.toString();t&&F(t.split(","))},[l,B,F]);const z=Object(o.useMemo)(()=>{if(s||0===B.length||(e=B,!Array.isArray(e)||!e.every(e=>["1","2","3","4","5"].includes(e))))return null;var e;const r=Object(p.__)("Rating","woo-gutenberg-products-block");return Object(o.createElement)("li",null,Object(o.createElement)("span",{className:"wc-block-active-filters__list-item-type"},r,":"),Object(o.createElement)("ul",null,B.map(e=>A({type:r,name:Object(p.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(p.__)("Rated %s out of 5","woo-gutenberg-products-block"),e),removeCallback:()=>{if(R({rating_filter:e}),!l){const t=B.filter(t=>t!==e);F(t)}},showLabel:!1,displayStyle:t.displayStyle}))))},[s,B,F,t.displayStyle,l]);if(!s&&!(b.length>0||m.length>0||B.length>0||Number.isFinite(E)||Number.isFinite(N))&&!r)return n(!1),null;const K="h"+t.headingLevel,U=Object(o.createElement)(K,{className:"wc-block-active-filters__title"},t.heading),q=s?Object(o.createElement)(h.a,null,U):U;if(!Object(g.getSettingWithCoercion)("has_filterable_products",!1,j.a))return n(!1),null;n(!0);const G=u()("wc-block-active-filters__list",{"wc-block-active-filters__list--chips":"chips"===t.displayStyle,"wc-block-active-filters--loading":s});return Object(o.createElement)(o.Fragment,null,!r&&t.heading&&q,Object(o.createElement)("div",{className:"wc-block-active-filters"},Object(o.createElement)("ul",{className:G},r?Object(o.createElement)(o.Fragment,null,A({type:Object(p.__)("Size","woo-gutenberg-products-block"),name:Object(p.__)("Small","woo-gutenberg-products-block"),displayStyle:t.displayStyle}),A({type:Object(p.__)("Color","woo-gutenberg-products-block"),name:Object(p.__)("Blue","woo-gutenberg-products-block"),displayStyle:t.displayStyle})):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(M,{isLoading:s,displayStyle:t.displayStyle}),W,V,Y,z)),s?Object(o.createElement)("span",{className:"wc-block-active-filters__clear-all-placeholder"}):Object(o.createElement)("button",{className:"wc-block-active-filters__clear-all",onClick:()=>{(()=>{if(!window)return;const e=window.location.href,t=Object(S.getQueryArgs)(e),r=Object(S.removeQueryArgs)(e,...Object.keys(t)),n=Object.fromEntries(Object.keys(t).filter(e=>!L(e)).map(e=>[e,t[e]])),c=Object(S.addQueryArgs)(r,n);Object(_.c)(c)})(),l||(x(void 0),T(void 0),d([]),k([]),F([]))}},Object(o.createElement)(O.a,{label:Object(p.__)("Clear All","woo-gutenberg-products-block"),screenReaderLabel:Object(p.__)("Clear All Filters","woo-gutenberg-products-block")}))))},V=(r(419),r(122)),W=Object(m.withSpokenMessages)(e=>{let{attributes:t,setAttributes:r,clientId:n}=e;const{className:c,displayStyle:l,heading:a,headingLevel:i}=t,s=Object(b.useBlockProps)({className:c});return Object(o.createElement)("div",s,Object(o.createElement)(b.InspectorControls,{key:"inspector"},Object(o.createElement)(m.PanelBody,{title:Object(p.__)("Display Settings","woo-gutenberg-products-block")},Object(o.createElement)(m.__experimentalToggleGroupControl,{label:Object(p.__)("Display Style","woo-gutenberg-products-block"),value:l,onChange:e=>r({displayStyle:e}),className:"wc-block-active-filter__style-toggle"},Object(o.createElement)(m.__experimentalToggleGroupControlOption,{value:"list",label:Object(p.__)("List","woo-gutenberg-products-block")}),Object(o.createElement)(m.__experimentalToggleGroupControlOption,{value:"chips",label:Object(p.__)("Chips","woo-gutenberg-products-block")})))),Object(o.createElement)(V.a,{attributes:t,clientId:n,setAttributes:r,filterType:"active-filters"}),a&&Object(o.createElement)(d.a,{className:"wc-block-active-filters__title",headingLevel:i,heading:a,onChange:e=>r({heading:e})}),Object(o.createElement)(m.Disabled,null,Object(o.createElement)(I,{attributes:t,isEditor:!0})))});const Y={heading:{type:"string",default:Object(p.__)("Active filters","woo-gutenberg-products-block")}};Object(l.registerBlockType)(N,{icon:{src:Object(o.createElement)(i.a,{icon:a.a,className:"wc-block-editor-components-block-icon"})},attributes:{...N.attributes,...Y},edit:W,save(e){let{attributes:t}=e;const{className:r,displayStyle:n,heading:l,headingLevel:a}=t,i={"data-display-style":n,"data-heading":l,"data-heading-level":a};return Object(o.createElement)("div",c()({},b.useBlockProps.save({className:u()("is-loading",r)}),i),Object(o.createElement)("span",{"aria-hidden":!0,className:"wc-block-active-product-filters__placeholder"}))}})},5:function(e,t){e.exports=window.wp.blockEditor},52:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return d}));var n=r(9),c=r(7),o=r(0),l=r(25),a=r.n(l),i=r(40),s=r(103),u=r(46);const b=e=>{const t=Object(u.a)();e=e||t;const r=Object(c.useSelect)(t=>t(n.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:l}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[r,Object(o.useCallback)(t=>{l(e,t)},[e,l])]},p=(e,t,r)=>{const l=Object(u.a)();r=r||l;const a=Object(c.useSelect)(c=>c(n.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t),[r,e]),{setQueryValue:i}=Object(c.useDispatch)(n.QUERY_STATE_STORE_KEY);return[a,Object(o.useCallback)(t=>{i(r,e,t)},[r,e,i])]},d=(e,t)=>{const r=Object(u.a)();t=t||r;const[n,c]=b(t),l=Object(i.a)(n),p=Object(i.a)(e),d=Object(s.a)(p),m=Object(o.useRef)(!1);return Object(o.useEffect)(()=>{a()(d,p)||(c(Object.assign({},l,p)),m.current=!0)},[l,p,d,c]),m.current?[n,c]:[e,c]}},7:function(e,t){e.exports=window.wp.data},8:function(e,t){e.exports=window.lodash},9:function(e,t){e.exports=window.wc.wcBlocksData},96:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e}}); \ No newline at end of file diff --git a/build/active-filters/block.json b/build/active-filters/block.json new file mode 100644 index 00000000000..09f8e1b571c --- /dev/null +++ b/build/active-filters/block.json @@ -0,0 +1,31 @@ +{ + "name": "woocommerce/active-filters", + "version": "1.0.0", + "title": "Active Product Filters Controls", + "description": "Display the currently active product filters.", + "category": "woocommerce", + "keywords": [ "WooCommerce" ], + "supports": { + "html": false, + "multiple": false, + "inserter": false, + "color": { + "text": true, + "background": false + }, + "lock": false + }, + "attributes": { + "displayStyle": { + "type": "string", + "default": "list" + }, + "headingLevel": { + "type": "number", + "default": 3 + } + }, + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2, + "$schema": "https://schemas.wp.org/trunk/block.json" +} diff --git a/build/all-products-frontend.asset.php b/build/all-products-frontend.asset.php new file mode 100644 index 00000000000..ad2e50b1d87 --- /dev/null +++ b/build/all-products-frontend.asset.php @@ -0,0 +1 @@ + array('lodash', 'react', 'wc-blocks-data-store', 'wc-blocks-registry', 'wc-blocks-shared-context', 'wc-blocks-shared-hocs', 'wc-price-format', 'wc-settings', 'wp-a11y', 'wp-api-fetch', 'wp-autop', 'wp-block-editor', 'wp-blocks', 'wp-compose', 'wp-data', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-warning', 'wp-wordcount'), 'version' => 'cf49a89284b324a0aedbe457e1962c20'); \ No newline at end of file diff --git a/build/all-products-frontend.js b/build/all-products-frontend.js new file mode 100644 index 00000000000..934c1e7873c --- /dev/null +++ b/build/all-products-frontend.js @@ -0,0 +1,11 @@ +!function(e){function t(t){for(var n,o,c=t[0],i=t[1],a=0,s=[];a{let{imageUrl:t=l.l+"/block-error.svg",header:n=Object(a.__)("Oops!","woo-gutenberg-products-block"),text:r=Object(a.__)("There was an error loading the content.","woo-gutenberg-products-block"),errorMessage:o,errorMessagePrefix:i=Object(a.__)("Error:","woo-gutenberg-products-block"),button:s,showErrorBlock:u=!0}=e;return u?Object(c.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&Object(c.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),Object(c.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},n&&Object(c.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},n),r&&Object(c.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},r),o&&Object(c.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),s&&Object(c.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},s))):null};n(35);class u extends i.Component{constructor(){super(...arguments),o()(this,"state",{errorMessage:"",hasError:!1})}static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:Object(c.createElement)(c.Fragment,null,Object(c.createElement)("strong",null,e.status),": ",e.statusText),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:n=!0,showErrorBlock:r=!0,text:o,errorMessagePrefix:i,renderError:a,button:l}=this.props,{errorMessage:u,hasError:d}=this.state;return d?"function"==typeof a?a({errorMessage:u}):Object(c.createElement)(s,{showErrorBlock:r,errorMessage:n?u:null,header:e,imageUrl:t,text:o,errorMessagePrefix:i,button:l}):this.props.children}}t.a=u},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,n){"use strict";var r=n(0),o=n(4),c=n.n(o);t.a=e=>{let t,{label:n,screenReaderLabel:o,wrapperElement:i,wrapperProps:a={}}=e;const l=null!=n,s=null!=o;return!l&&s?(t=i||"span",a={...a,className:c()(a.className,"screen-reader-text")},Object(r.createElement)(t,a,o)):(t=i||r.Fragment,l&&s&&n!==o?Object(r.createElement)(t,a,Object(r.createElement)("span",{"aria-hidden":"true"},n),Object(r.createElement)("span",{className:"screen-reader-text"},o)):Object(r.createElement)(t,a,n))}},,function(e,t){e.exports=window.wp.deprecated},,function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wp.a11y},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);const o=Object(r.createContext)("page"),c=()=>Object(r.useContext)(o);o.Provider},function(e,t,n){"use strict";(function(e){var r=n(0);n(39);const o=Object(r.createContext)({slots:{},fills:{},registerSlot:()=>{void 0!==e&&e.env},updateSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{}});t.a=o}).call(this,n(66))},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),o=n(13),c=n.n(o);function i(e){const t=Object(r.useRef)(e);return c()(e,t.current)||(t.current=e),t.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"string"==typeof e},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"c",(function(){return m}));var r=n(3),o=n(6),c=n(0),i=n(13),a=n.n(i),l=n(29),s=n(62),u=n(25);const d=e=>{const t=Object(u.a)();e=e||t;const n=Object(o.useSelect)(t=>t(r.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:i}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[n,Object(c.useCallback)(t=>{i(e,t)},[e,i])]},p=(e,t,n)=>{const i=Object(u.a)();n=n||i;const a=Object(o.useSelect)(o=>o(r.QUERY_STATE_STORE_KEY).getValueForQueryKey(n,e,t),[n,e]),{setQueryValue:l}=Object(o.useDispatch)(r.QUERY_STATE_STORE_KEY);return[a,Object(c.useCallback)(t=>{l(n,e,t)},[n,e,l])]},m=(e,t)=>{const n=Object(u.a)();t=t||n;const[r,o]=d(t),i=Object(l.a)(r),p=Object(l.a)(e),m=Object(s.a)(p),b=Object(c.useRef)(!1);return Object(c.useEffect)(()=>{a()(m,p)||(o(Object.assign({},i,p)),b.current=!0)},[i,p,m,o]),b.current?[r,o]:[e,o]}},,function(e,t){e.exports=window.wp.apiFetch},,function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(0);n(6);const o=Object(r.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>{}}),c=()=>Object(r.useContext)(o)},function(e,t,n){"use strict";var r=n(4),o=n.n(r),c=n(0);t.a=Object(c.forwardRef)((function({as:e="div",className:t,...n},r){return function({as:e="div",...t}){return"function"==typeof t.children?t.children(t):Object(c.createElement)(e,t)}({as:e,className:o()("components-visually-hidden",t),...n,ref:r})}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return O}));var r=n(5),o=n(0),c=n(3),i=n(6),a=n(23),l=n(132),s=n(36),u=n(91);const d=e=>{const t=e.detail;t&&t.preserveCartData||Object(i.dispatch)(c.CART_STORE_KEY).invalidateResolutionForStore()},p=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},m=()=>{Object(o.useEffect)(()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),0===window.wcBlocksStoreCartListeners.count){const e=Object(u.b)("added_to_cart","wc-blocks_added_to_cart"),t=Object(u.b)("removed_from_cart","wc-blocks_removed_from_cart");document.body.addEventListener("wc-blocks_added_to_cart",d),document.body.addEventListener("wc-blocks_removed_from_cart",d),window.wcBlocksStoreCartListeners.count=0,window.wcBlocksStoreCartListeners.remove=()=>{e(),t(),document.body.removeEventListener("wc-blocks_added_to_cart",d),document.body.removeEventListener("wc-blocks_removed_from_cart",d)}}window.wcBlocksStoreCartListeners.count++})(),p),[])},b={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},f={...b,email:""},g={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},h=e=>Object.fromEntries(Object.entries(e).map(e=>{let[t,n]=e;return[t,Object(a.decodeEntities)(n)]})),E={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:c.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:g,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:f,shippingAddress:b,shippingRates:c.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},extensions:c.EMPTY_EXTENSIONS},O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{shouldSelect:!0};const{isEditor:t,previewData:n}=Object(s.a)(),a=null==n?void 0:n.previewCart,{shouldSelect:u}=e,d=Object(o.useRef)();m();const p=Object(i.useSelect)((e,n)=>{let{dispatch:r}=n;if(!u)return E;if(t)return{cartCoupons:a.coupons,cartItems:a.items,crossSellsProducts:a.cross_sells,cartFees:a.fees,cartItemsCount:a.items_count,cartItemsWeight:a.items_weight,cartNeedsPayment:a.needs_payment,cartNeedsShipping:a.needs_shipping,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:a.totals,cartIsLoading:!1,cartErrors:c.EMPTY_CART_ERRORS,billingData:f,billingAddress:f,shippingAddress:b,extensions:c.EMPTY_EXTENSIONS,shippingRates:a.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:a.has_calculated_shipping,paymentRequirements:a.paymentRequirements,receiveCart:"function"==typeof(null==a?void 0:a.receiveCart)?a.receiveCart:()=>{}};const o=e(c.CART_STORE_KEY),i=o.getCartData(),s=o.getCartErrors(),d=o.getCartTotals(),p=!o.hasFinishedResolution("getCartData"),m=o.isCustomerDataUpdating(),{receiveCart:g}=r(c.CART_STORE_KEY),O=h(i.billingAddress),w=i.needsShipping?h(i.shippingAddress):O,y=i.fees.length>0?i.fees.map(e=>h(e)):c.EMPTY_CART_FEES;return{cartCoupons:i.coupons.length>0?i.coupons.map(e=>({...e,label:e.code})):c.EMPTY_CART_COUPONS,cartItems:i.items,crossSellsProducts:i.crossSells,cartFees:y,cartItemsCount:i.itemsCount,cartItemsWeight:i.itemsWeight,cartNeedsPayment:i.needsPayment,cartNeedsShipping:i.needsShipping,cartItemErrors:i.errors,cartTotals:d,cartIsLoading:p,cartErrors:s,billingData:Object(l.a)(O),billingAddress:Object(l.a)(O),shippingAddress:Object(l.a)(w),extensions:i.extensions,shippingRates:i.shippingRates,isLoadingRates:m,cartHasCalculatedShipping:i.hasCalculatedShipping,paymentRequirements:i.paymentRequirements,receiveCart:g}},[u]);return d.current&&Object(r.isEqual)(d.current,p)||(d.current=p),d.current}},function(e,t){e.exports=window.wp.warning},function(e,t){e.exports=window.wc.priceFormat},function(e,t,n){"use strict";var r=n(9),o=n(0),c=n(15),i=function({icon:e,className:t,...n}){const c=["dashicon","dashicons","dashicons-"+e,t].filter(Boolean).join(" ");return Object(o.createElement)("span",Object(r.a)({className:c},n))};t.a=function({icon:e=null,size:t=24,...n}){if("string"==typeof e)return Object(o.createElement)(i,Object(r.a)({icon:e},n));if(Object(o.isValidElement)(e)&&i===e.type)return Object(o.cloneElement)(e,{...n});if("function"==typeof e)return e.prototype instanceof o.Component?Object(o.createElement)(e,{size:t,...n}):e({size:t,...n});if(e&&("svg"===e.type||e.type===c.SVG)){const r={width:t,height:t,...e.props,...n};return Object(o.createElement)(c.SVG,r)}return Object(o.isValidElement)(e)?Object(o.cloneElement)(e,{size:t,...n}):e}},,,function(e,t,n){"use strict";var r=n(9),o=n(0),c=n(4),i=n.n(c),a=n(5),l=n(21),s=n.n(l),u=n(11),d=n(47),p=n(92),m=n(1);function b(e,t,n){const{defaultView:r}=t,{frameElement:o}=r;if(!o||t===n.ownerDocument)return e;const c=o.getBoundingClientRect();return new r.DOMRect(e.left+c.left,e.top+c.top,e.width,e.height)}let f=0;function g(e){const t=document.scrollingElement||document.body;e&&(f=t.scrollTop);const n=e?"add":"remove";t.classList[n]("lockscroll"),document.documentElement.classList[n]("lockscroll"),e||(t.scrollTop=f)}let h=0;function E(){return Object(o.useEffect)(()=>(0===h&&g(!0),++h,()=>{1===h&&g(!1),--h}),[]),null}var O=n(26);function w(e){const t=Object(o.useContext)(O.a),n=t.slots[e]||{},r=t.fills[e],c=Object(o.useMemo)(()=>r||[],[r]);return{...n,updateSlot:Object(o.useCallback)(n=>{t.updateSlot(e,n)},[e,t.updateSlot]),unregisterSlot:Object(o.useCallback)(n=>{t.unregisterSlot(e,n)},[e,t.unregisterSlot]),fills:c,registerFill:Object(o.useCallback)(n=>{t.registerFill(e,n)},[e,t.registerFill]),unregisterFill:Object(o.useCallback)(n=>{t.unregisterFill(e,n)},[e,t.unregisterFill])}}var y=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function v({name:e,children:t,registerFill:n,unregisterFill:r}){const c=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(y),[r,c]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(c(t(e)),n(()=>{c(t(e))})),[e]),r})(e),i=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,i.current),()=>r(e,i.current)),[]),Object(o.useLayoutEffect)(()=>{i.current.children=t,c&&c.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==i.current.name&&(r(i.current.name,i.current),i.current.name=e,n(e,i.current))},[e]),c&&c.node?(Object(a.isFunction)(t)&&(t=t(c.props.fillProps)),Object(o.createPortal)(t,c.node)):null}var j=e=>Object(o.createElement)(y.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(v,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class _ extends o.Component{constructor(){super(...arguments),this.isUnmounted=!1,this.bindNode=this.bindNode.bind(this)}componentDidMount(){const{registerSlot:e}=this.props;e(this.props.name,this)}componentWillUnmount(){const{unregisterSlot:e}=this.props;this.isUnmounted=!0,e(this.props.name,this)}componentDidUpdate(e){const{name:t,unregisterSlot:n,registerSlot:r}=this.props;e.name!==t&&(n(e.name),r(t,this))}bindNode(e){this.node=e}forceUpdate(){this.isUnmounted||super.forceUpdate()}render(){const{children:e,name:t,fillProps:n={},getFills:r}=this.props,c=Object(a.map)(r(t,this),e=>{const t=Object(a.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(a.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(a.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(a.isFunction)(e)?e(c):c)}}var x=e=>Object(o.createElement)(y.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:c})=>Object(o.createElement)(_,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:c})));function k(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function S({name:e,children:t}){const n=w(e),r=Object(o.useRef)({rerender:k()});return Object(o.useEffect)(()=>(n.registerFill(r),()=>{n.unregisterFill(r)}),[n.registerFill,n.unregisterFill]),n.ref&&n.ref.current?("function"==typeof t&&(t=t(n.fillProps)),Object(o.createPortal)(t,n.ref.current)):null}var T=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...c},i){const a=Object(o.useContext)(O.a),l=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(a.registerSlot(e,l,t),()=>{a.unregisterSlot(e,l)}),[a.registerSlot,a.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{a.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([i,l])},c))}));function N(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(j,e),Object(o.createElement)(S,e))}n(13),o.Component;const C=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(T,Object(r.a)({},t,{ref:n})):Object(o.createElement)(x,t));function R(e){return"appear"===e?"top":"left"}function A(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:c}=(i=t).ownerDocument.defaultView.getComputedStyle(i);var i;const a=n?parseInt(n,10):0,l=r?parseInt(r,10):0,s=o?parseInt(o,10):0,u=c?parseInt(c,10):0;return{x:e.left+s,y:e.top+a,width:e.width-s-u,height:e.height-a-l,left:e.left+s,right:e.right-u,top:e.top+a,bottom:e.bottom-l}}function L(e,t,n){n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.hasAttribute(t)&&e.removeAttribute(t)}function P(e,t,n=""){e.style[t]!==n&&(e.style[t]=n)}function M(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const D=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:c,noArrow:a=!0,isAlternate:l,position:f="bottom right",range:g,focusOnMount:h="firstElement",anchorRef:O,shouldAnchorIncludePadding:y,anchorRect:v,getAnchorRect:j,expandOnMobile:_,animate:x=!0,onClickOutside:k,onFocusOutside:S,__unstableStickyBoundaryElement:T,__unstableSlotName:C="Popover",__unstableObserveElement:D,__unstableBoundaryParent:F,__unstableForcePosition:B,__unstableForceXAlignment:I,...H},z)=>{const U=Object(o.useRef)(null),W=Object(o.useRef)(null),G=Object(o.useRef)(),Y=Object(u.useViewportMatch)("medium","<"),[V,Q]=Object(o.useState)(),K=w(C),X=_&&Y,[$,J]=Object(u.useResizeObserver)();a=X||a,Object(o.useLayoutEffect)(()=>{if(X)return M(G.current,"is-without-arrow",a),M(G.current,"is-alternate",l),L(G.current,"data-x-axis"),L(G.current,"data-y-axis"),P(G.current,"top"),P(G.current,"left"),P(W.current,"maxHeight"),void P(W.current,"maxWidth");const e=()=>{if(!G.current||!W.current)return;let e=function(e,t,n,r=!1,o,c){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return b(t,t.ownerDocument||e.current.ownerDocument,c)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return b(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,c);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=b(r.getBoundingClientRect(),r.ownerDocument,c);return o?e:A(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=b(new window.DOMRect(n.left,n.top,n.width,i.bottom-n.top),e.ownerDocument,c);return o?a:A(a,r)}if(!e.current)return;const{parentNode:i}=e.current,a=i.getBoundingClientRect();return o?a:A(a,i)}(U,v,j,O,y,G.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=G.current;let r,o=0;if(t&&t!==n.body){const n=t.getBoundingClientRect();o=n.top,e=new window.DOMRect(e.left-n.left,e.top-n.top,e.width,e.height)}var c;F&&(r=null===(c=G.current.closest(".popover-slot"))||void 0===c?void 0:c.parentNode);const i=J.height?J:W.current.getBoundingClientRect(),{popoverTop:s,popoverLeft:u,xAxis:p,yAxis:g,contentHeight:h,contentWidth:E}=function(e,t,n="top",r,o,c,i,a,l){const[s,u="center",d]=n.split(" "),p=function(e,t,n,r,o,c,i,a){const{height:l}=t;if(o){const t=o.getBoundingClientRect().top+l-i;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let s=e.top+e.height/2;"bottom"===r?s=e.bottom:"top"===r&&(s=e.top);const u={popoverTop:s,contentHeight:(s-l/2>0?l/2:s)+(s+l/2>window.innerHeight?window.innerHeight-s:l/2)},d={popoverTop:e.top,contentHeight:e.top-10-l>0?l:e.top-10},p={popoverTop:e.bottom,contentHeight:e.bottom+10+l>window.innerHeight?window.innerHeight-10-e.bottom:l};let m,b=n,f=null;if(!o&&!a)if("middle"===n&&u.contentHeight===l)b="middle";else if("top"===n&&d.contentHeight===l)b="top";else if("bottom"===n&&p.contentHeight===l)b="bottom";else{b=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===b?d.contentHeight:p.contentHeight;f=e!==l?e:null}return m="middle"===b?u.popoverTop:"top"===b?d.popoverTop:p.popoverTop,{yAxis:b,popoverTop:m,contentHeight:f}}(e,t,s,d,r,0,c,a);return{...function(e,t,n,r,o,c,i,a,l){const{width:s}=t;"left"===n&&Object(m.isRTL)()?n="right":"right"===n&&Object(m.isRTL)()&&(n="left"),"left"===r&&Object(m.isRTL)()?r="right":"right"===r&&Object(m.isRTL)()&&(r="left");const u=Math.round(e.left+e.width/2),d={popoverLeft:u,contentWidth:(u-s/2>0?s/2:u)+(u+s/2>window.innerWidth?window.innerWidth-u:s/2)};let p=e.left;"right"===r?p=e.right:"middle"===c||l||(p=u);let b=e.right;"left"===r?b=e.left:"middle"===c||l||(b=u);const f={popoverLeft:p,contentWidth:p-s>0?s:p},g={popoverLeft:b,contentWidth:b+s>window.innerWidth?window.innerWidth-b:s};let h,E=n,O=null;if(!o&&!a)if("center"===n&&d.contentWidth===s)E="center";else if("left"===n&&f.contentWidth===s)E="left";else if("right"===n&&g.contentWidth===s)E="right";else{E=f.contentWidth>g.contentWidth?"left":"right";const e="left"===E?f.contentWidth:g.contentWidth;s>window.innerWidth&&(O=window.innerWidth),e!==s&&(E="center",d.popoverLeft=window.innerWidth/2)}if(h="center"===E?d.popoverLeft:"left"===E?f.popoverLeft:g.popoverLeft,i){const e=i.getBoundingClientRect();h=Math.min(h,e.right-s),Object(m.isRTL)()||(h=Math.max(h,0))}return{xAxis:E,popoverLeft:h,contentWidth:O}}(e,t,u,d,r,p.yAxis,i,a,l),...p}}(e,i,f,T,G.current,o,r,B,I);"number"==typeof s&&"number"==typeof u&&(P(G.current,"top",s+"px"),P(G.current,"left",u+"px")),M(G.current,"is-without-arrow",a||"center"===p&&"middle"===g),M(G.current,"is-alternate",l),L(G.current,"data-x-axis",p),L(G.current,"data-y-axis",g),P(W.current,"maxHeight","number"==typeof h?h+"px":""),P(W.current,"maxWidth","number"==typeof E?E+"px":""),Q(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[g]||"middle"))};e();const{ownerDocument:t}=G.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const c=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",c),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const i=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(O);let s;return i&&i!==t&&(i.defaultView.addEventListener("resize",e),i.defaultView.addEventListener("scroll",e,!0)),D&&(s=new n.MutationObserver(e),s.observe(D,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",c),n.cancelAnimationFrame(o),i&&i!==t&&(i.defaultView.removeEventListener("resize",e),i.defaultView.removeEventListener("scroll",e,!0)),s&&s.disconnect()}},[X,v,j,O,y,f,J,T,D,F]);const Z=(e,n)=>{if("focus-outside"===e&&S)S(n);else if("focus-outside"===e&&k){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),s()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),k(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:h,__unstableOnClose:Z,onClose:Z}),ne=Object(u.useMergeRefs)([G,ee,z]),re=Boolean(x&&V)&&function(e){if("loading"===e.type)return i()("components-animate__loading");const{type:t,origin:n=R(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return i()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?i()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:V});let oe=Object(o.createElement)("div",Object(r.a)({className:i()("components-popover",c,re,{"is-expanded":X,"is-without-arrow":a,"is-alternate":l})},H,{ref:ne},te,{tabIndex:"-1"}),X&&Object(o.createElement)(E,null),X&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(q,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:W,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},$,n)));return K.ref&&(oe=Object(o.createElement)(N,{name:C},oe)),O||v?oe:Object(o.createElement)("span",{ref:U},oe)});D.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(C,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var F=D,B=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(a.isString)(e)&&(n=e),Object(a.isObject)(e)&&(n=e.display,r=e.ariaLabel),Object(o.createElement)("span",{className:t,"aria-label":r},n)};const I=Object(o.createElement)("div",{className:"event-catcher"}),H=({eventHandlers:e,child:t,childrenWithPopover:n})=>Object(o.cloneElement)(Object(o.createElement)("span",{className:"disabled-element-wrapper"},Object(o.cloneElement)(I,e),Object(o.cloneElement)(t,{children:n}),","),e),z=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(o.cloneElement)(e,{...t,children:n}),U=(e,t,n)=>{if(1!==o.Children.count(e))return;const r=o.Children.only(e);"function"==typeof r.props[t]&&r.props[t](n)};var W=function({children:e,position:t,text:n,shortcut:r}){const[c,i]=Object(o.useState)(!1),[l,s]=Object(o.useState)(!1),d=Object(u.useDebounce)(s,700),p=t=>{U(e,"onMouseDown",t),document.addEventListener("mouseup",f),i(!0)},m=t=>{U(e,"onMouseUp",t),document.removeEventListener("mouseup",f),i(!1)},b=e=>"mouseUp"===e?m:"mouseDown"===e?p:void 0,f=b("mouseUp"),g=(t,n)=>r=>{if(U(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&c)return;d.cancel();const o=Object(a.includes)(["focus","mouseenter"],r.type);o!==l&&(n?d(o):s(o))},h=()=>{d.cancel(),document.removeEventListener("mouseup",f)};if(Object(o.useEffect)(()=>h,[]),1!==o.Children.count(e))return e;const E={onMouseEnter:g("onMouseEnter",!0),onMouseLeave:g("onMouseLeave"),onClick:g("onClick"),onFocus:g("onFocus"),onBlur:g("onBlur"),onMouseDown:b("mouseDown")},O=o.Children.only(e),{children:w,disabled:y}=O.props;return(y?H:z)({child:O,eventHandlers:E,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:c})=>Object(o.concatChildren)(e,t&&Object(o.createElement)(F,{focusOnMount:!1,position:n,className:"components-tooltip","aria-hidden":"true",animate:!1,noArrow:!0},r,Object(o.createElement)(B,{className:"components-tooltip__shortcut",shortcut:c}))))({grandchildren:w,isOver:l,position:t,text:n,shortcut:r})})},G=n(41),Y=n(37);const V=["onMouseDown","onClick"];var q=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:c,isSmall:l,isPressed:u,isBusy:d,isDestructive:p,className:m,disabled:b,icon:f,iconPosition:g="left",iconSize:h,showTooltip:E,tooltipPosition:O,shortcut:w,label:y,children:v,text:j,variant:_,__experimentalIsFocusable:x,describedBy:k,...S}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:c,...i}){let a=c;var l,u,d,p,m;return t&&(null!==(l=a)&&void 0!==l||(a="primary")),r&&(null!==(u=a)&&void 0!==u||(a="tertiary")),n&&(null!==(d=a)&&void 0!==d||(a="secondary")),e&&(s()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=a)&&void 0!==p||(a="secondary")),o&&(null!==(m=a)&&void 0!==m||(a="link")),{...i,variant:a}}(e),T=i()("components-button",m,{"is-secondary":"secondary"===_,"is-primary":"primary"===_,"is-small":l,"is-tertiary":"tertiary"===_,"is-pressed":u,"is-busy":d,"is-link":"link"===_,"is-destructive":p,"has-text":!!f&&!!v,"has-icon":!!f}),N=b&&!x,C=void 0===n||N?"button":"a",R="a"===C?{href:n,target:c}:{type:"button",disabled:N,"aria-pressed":u};if(b&&x){R["aria-disabled"]=!0;for(const e of V)S[e]=e=>{e.stopPropagation(),e.preventDefault()}}const A=!N&&(E&&y||w||!!y&&(!v||Object(a.isArray)(v)&&!v.length)&&!1!==E),L=k?Object(a.uniqueId)():null,P=S["aria-describedby"]||L,M=Object(o.createElement)(C,Object(r.a)({},R,S,{className:T,"aria-label":S["aria-label"]||y,"aria-describedby":P,ref:t}),f&&"left"===g&&Object(o.createElement)(G.a,{icon:f,size:h}),j&&Object(o.createElement)(o.Fragment,null,j),f&&"right"===g&&Object(o.createElement)(G.a,{icon:f,size:h}),v);return A?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(W,{text:k||y,shortcut:w,position:O},M),k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k))):Object(o.createElement)(o.Fragment,null,M,k&&Object(o.createElement)(Y.a,null,Object(o.createElement)("span",{id:L},k)))}))},,function(e,t,n){"use strict";n.d(t,"n",(function(){return c})),n.d(t,"l",(function(){return i})),n.d(t,"k",(function(){return a})),n.d(t,"m",(function(){return l})),n.d(t,"i",(function(){return s})),n.d(t,"d",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"j",(function(){return p})),n.d(t,"c",(function(){return m})),n.d(t,"e",(function(){return b})),n.d(t,"g",(function(){return f})),n.d(t,"a",(function(){return g})),n.d(t,"h",(function(){return h})),n.d(t,"b",(function(){return E}));var r,o=n(2);const c=Object(o.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),i=c.pluginUrl+"images/",a=c.pluginUrl+"build/",l=c.buildPhase,s=null===(r=o.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=(o.STORE_PAGES.checkout.id,o.STORE_PAGES.checkout.permalink),d=o.STORE_PAGES.privacy.permalink,p=(o.STORE_PAGES.privacy.title,o.STORE_PAGES.terms.permalink),m=(o.STORE_PAGES.terms.title,o.STORE_PAGES.cart.id,o.STORE_PAGES.cart.permalink),b=o.STORE_PAGES.myaccount.permalink?o.STORE_PAGES.myaccount.permalink:Object(o.getSetting)("wpLoginUrl","/wp-login.php"),f=Object(o.getSetting)("shippingCountries",{}),g=Object(o.getSetting)("allowedCountries",{}),h=Object(o.getSetting)("shippingStates",{}),E=Object(o.getSetting)("allowedStates",{})},function(e,t){e.exports=window.wp.dom},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(12),o=n.n(r),c=n(0),i=n(16);const a=[".wp-block-woocommerce-cart"],l=e=>{let{Block:t,containers:n,getProps:r=(()=>({})),getErrorBoundaryProps:a=(()=>({}))}=e;0!==n.length&&Array.prototype.forEach.call(n,(e,n)=>{const l=r(e,n),s=a(e,n),u={...e.dataset,...l.attributes||{}};(e=>{let{Block:t,container:n,attributes:r={},props:a={},errorBoundaryProps:l={}}=e;Object(c.render)(Object(c.createElement)(i.a,l,Object(c.createElement)(c.Suspense,{fallback:Object(c.createElement)("div",{className:"wc-block-placeholder"})},t&&Object(c.createElement)(t,o()({},a,{attributes:r})))),n,()=>{n.classList&&n.classList.remove("is-loading")})})({Block:t,container:e,props:l,attributes:u,errorBoundaryProps:s})})},s=e=>{const t=document.body.querySelectorAll(a.join(",")),{Block:n,getProps:r,getErrorBoundaryProps:o,selector:c}=e;(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrappers:c}=e;const i=document.body.querySelectorAll(o);c&&c.length>0&&Array.prototype.filter.call(i,e=>!((e,t)=>Array.prototype.some.call(t,t=>t.contains(e)&&!t.isSameNode(e)))(e,c)),l({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({Block:n,getProps:r,getErrorBoundaryProps:o,selector:c,wrappers:t}),Array.prototype.forEach.call(t,t=>{t.addEventListener("wc-blocks_render_blocks_frontend",()=>{(e=>{let{Block:t,getProps:n,getErrorBoundaryProps:r,selector:o,wrapper:c}=e;const i=c.querySelectorAll(o);l({Block:t,containers:i,getProps:n,getErrorBoundaryProps:r})})({...e,wrapper:t})})})}},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=window.wc.wcBlocksSharedContext},,,,,,,function(e,t,n){"use strict";var r=n(2),o=n(1),c=n(94),i=n(30);const a=Object(r.getSetting)("countryLocale",{}),l=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=Object(o.sprintf)( +/* translators: %s Field label. */ +Object(o.__)("%s (optional)","woo-gutenberg-products-block"),e.label)),e.priority&&(Object(c.a)(e.priority)&&(t.index=e.priority),Object(i.a)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},s=Object.entries(a).map(e=>{let[t,n]=e;return[t,Object.entries(n).map(e=>{let[t,n]=e;return[t,l(n)]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})]}).reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{});t.a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=n&&void 0!==s[n]?s[n]:{};return e.map(e=>({key:e,...r.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}})).sort((e,t)=>e.index-t.index)}},,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(3),o=n(6),c=n(0),i=n(29),a=n(76);const l=e=>{const{namespace:t,resourceName:n,resourceValues:l=[],query:s={},shouldSelect:u=!0}=e;if(!t||!n)throw new Error("The options object must have valid values for the namespace and the resource properties.");const d=Object(c.useRef)({results:[],isLoading:!0}),p=Object(i.a)(s),m=Object(i.a)(l),b=Object(a.a)(),f=Object(o.useSelect)(e=>{if(!u)return null;const o=e(r.COLLECTIONS_STORE_KEY),c=[t,n,p,m],i=o.getCollectionError(...c);if(i){if(!(i instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");b(i)}return{results:o.getCollection(...c),isLoading:!o.hasFinishedResolution("getCollection",c)}},[t,n,m,p,u]);return null!==f&&(d.current=f),d.current}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(8);function o(e,t){const n=Object(r.useRef)();return Object(r.useEffect)(()=>{n.current===e||t&&!t(e,n.current)||(n.current=e)},[e,t]),n.current}},,,,function(e,t){var n,r,o=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===c||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:c}catch(e){n=c}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var l,s=[],u=!1,d=-1;function p(){u&&l&&(u=!1,l.length?s=l.concat(s):d=-1,s.length&&m())}function m(){if(!u){var e=a(p);u=!0;for(var t=s.length;t;){for(l=s,s=[];++d1)for(var n=1;n{const e=Object(c.a)(),t=Object(o.useRef)(e);return Object(o.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(o.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(o.useCallback)((function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(r.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...n,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,function(e,t,n){e.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,n){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,n)}function n(){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 r(e,o,c){return(r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var c=new(Function.bind.apply(e,o));return r&&t(c,r.prototype),c}).apply(null,arguments)}function o(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return c(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),o=1;o/gm),Y=p(/^data-[\-\w.\u00B7-\uFFFF]/),V=p(/^aria-[\-\w]+$/),q=p(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q=p(/^(?:\w+script|data):/i),K=p(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),X=p(/^html$/i),$=function(){return"undefined"==typeof window?null:window},J=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null;n.currentScript&&n.currentScript.hasAttribute("data-tt-policy-suffix")&&(r=n.currentScript.getAttribute("data-tt-policy-suffix"));var o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$(),r=function(e){return t(e)};if(r.version="2.4.0",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var c=n.document,i=n.document,a=n.DocumentFragment,l=n.HTMLTemplateElement,s=n.Node,u=n.Element,p=n.NodeFilter,m=n.NamedNodeMap,b=void 0===m?n.NamedNodeMap||n.MozNamedAttrMap:m,f=n.HTMLFormElement,g=n.DOMParser,h=n.trustedTypes,T=u.prototype,Z=R(T,"cloneNode"),ee=R(T,"nextSibling"),te=R(T,"childNodes"),ne=R(T,"parentNode");if("function"==typeof l){var re=i.createElement("template");re.content&&re.content.ownerDocument&&(i=re.content.ownerDocument)}var oe=J(h,c),ce=oe?oe.createHTML(""):"",ie=i,ae=ie.implementation,le=ie.createNodeIterator,se=ie.createDocumentFragment,ue=ie.getElementsByTagName,de=c.importNode,pe={};try{pe=C(i).documentMode?i.documentMode:{}}catch(e){}var me={};r.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==pe;var be,fe,ge=W,he=G,Ee=Y,Oe=V,we=Q,ye=K,ve=q,je=null,_e=N({},[].concat(o(A),o(L),o(P),o(D),o(B))),xe=null,ke=N({},[].concat(o(I),o(H),o(z),o(U))),Se=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ne=null,Ce=!0,Re=!0,Ae=!1,Le=!1,Pe=!1,Me=!1,De=!1,Fe=!1,Be=!1,Ie=!1,He=!0,ze=!1,Ue="user-content-",We=!0,Ge=!1,Ye={},Ve=null,qe=N({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Qe=null,Ke=N({},["audio","video","img","source","image","track"]),Xe=null,$e=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Je="http://www.w3.org/1998/Math/MathML",Ze="http://www.w3.org/2000/svg",et="http://www.w3.org/1999/xhtml",tt=et,nt=!1,rt=["application/xhtml+xml","text/html"],ot="text/html",ct=null,it=i.createElement("form"),at=function(e){return e instanceof RegExp||e instanceof Function},lt=function(t){ct&&ct===t||(t&&"object"===e(t)||(t={}),t=C(t),be=be=-1===rt.indexOf(t.PARSER_MEDIA_TYPE)?ot:t.PARSER_MEDIA_TYPE,fe="application/xhtml+xml"===be?function(e){return e}:y,je="ALLOWED_TAGS"in t?N({},t.ALLOWED_TAGS,fe):_e,xe="ALLOWED_ATTR"in t?N({},t.ALLOWED_ATTR,fe):ke,Xe="ADD_URI_SAFE_ATTR"in t?N(C($e),t.ADD_URI_SAFE_ATTR,fe):$e,Qe="ADD_DATA_URI_TAGS"in t?N(C(Ke),t.ADD_DATA_URI_TAGS,fe):Ke,Ve="FORBID_CONTENTS"in t?N({},t.FORBID_CONTENTS,fe):qe,Te="FORBID_TAGS"in t?N({},t.FORBID_TAGS,fe):{},Ne="FORBID_ATTR"in t?N({},t.FORBID_ATTR,fe):{},Ye="USE_PROFILES"in t&&t.USE_PROFILES,Ce=!1!==t.ALLOW_ARIA_ATTR,Re=!1!==t.ALLOW_DATA_ATTR,Ae=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Le=t.SAFE_FOR_TEMPLATES||!1,Pe=t.WHOLE_DOCUMENT||!1,Fe=t.RETURN_DOM||!1,Be=t.RETURN_DOM_FRAGMENT||!1,Ie=t.RETURN_TRUSTED_TYPE||!1,De=t.FORCE_BODY||!1,He=!1!==t.SANITIZE_DOM,ze=t.SANITIZE_NAMED_PROPS||!1,We=!1!==t.KEEP_CONTENT,Ge=t.IN_PLACE||!1,ve=t.ALLOWED_URI_REGEXP||ve,tt=t.NAMESPACE||et,t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(Re=!1),Be&&(Fe=!0),Ye&&(je=N({},o(B)),xe=[],!0===Ye.html&&(N(je,A),N(xe,I)),!0===Ye.svg&&(N(je,L),N(xe,H),N(xe,U)),!0===Ye.svgFilters&&(N(je,P),N(xe,H),N(xe,U)),!0===Ye.mathMl&&(N(je,D),N(xe,z),N(xe,U))),t.ADD_TAGS&&(je===_e&&(je=C(je)),N(je,t.ADD_TAGS,fe)),t.ADD_ATTR&&(xe===ke&&(xe=C(xe)),N(xe,t.ADD_ATTR,fe)),t.ADD_URI_SAFE_ATTR&&N(Xe,t.ADD_URI_SAFE_ATTR,fe),t.FORBID_CONTENTS&&(Ve===qe&&(Ve=C(Ve)),N(Ve,t.FORBID_CONTENTS,fe)),We&&(je["#text"]=!0),Pe&&N(je,["html","head","body"]),je.table&&(N(je,["tbody"]),delete Te.tbody),d&&d(t),ct=t)},st=N({},["mi","mo","mn","ms","mtext"]),ut=N({},["foreignobject","desc","title","annotation-xml"]),dt=N({},["title","style","font","a","script"]),pt=N({},L);N(pt,P),N(pt,M);var mt=N({},D);N(mt,F);var bt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:et,tagName:"template"});var n=y(e.tagName),r=y(t.tagName);return e.namespaceURI===Ze?t.namespaceURI===et?"svg"===n:t.namespaceURI===Je?"svg"===n&&("annotation-xml"===r||st[r]):Boolean(pt[n]):e.namespaceURI===Je?t.namespaceURI===et?"math"===n:t.namespaceURI===Ze?"math"===n&&ut[r]:Boolean(mt[n]):e.namespaceURI===et&&!(t.namespaceURI===Ze&&!ut[r])&&!(t.namespaceURI===Je&&!st[r])&&!mt[n]&&(dt[n]||!pt[n])},ft=function(e){w(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ce}catch(t){e.remove()}}},gt=function(e,t){try{w(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){w(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!xe[e])if(Fe||Be)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},ht=function(e){var t,n;if(De)e=""+e;else{var r=v(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===be&&(e=''+e+"");var o=oe?oe.createHTML(e):e;if(tt===et)try{t=(new g).parseFromString(o,be)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(tt,"template",null);try{t.documentElement.innerHTML=nt?"":o}catch(e){}}var c=t.body||t.documentElement;return e&&n&&c.insertBefore(i.createTextNode(n),c.childNodes[0]||null),tt===et?ue.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:c},Et=function(e){return le.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT,null,!1)},Ot=function(e){return e instanceof f&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof b)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},wt=function(t){return"object"===e(s)?t instanceof s:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},yt=function(e,t,n){me[e]&&E(me[e],(function(e){e.call(r,t,n,ct)}))},vt=function(e){var t;if(yt("beforeSanitizeElements",e,null),Ot(e))return ft(e),!0;if(k(/[\u0080-\uFFFF]/,e.nodeName))return ft(e),!0;var n=fe(e.nodeName);if(yt("uponSanitizeElement",e,{tagName:n,allowedTags:je}),e.hasChildNodes()&&!wt(e.firstElementChild)&&(!wt(e.content)||!wt(e.content.firstElementChild))&&k(/<[/\w]/g,e.innerHTML)&&k(/<[/\w]/g,e.textContent))return ft(e),!0;if("select"===n&&k(/