From ed9a8b7c79c1052ad633534c2fc2a7cb4b51b60e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?=
${Object(o.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(o.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(o.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#", +/* translators: An example person name used for the block previews. */ +reviewer:Object(o.__)("Bob","woo-gutenberg-products-block"),review:`${Object(o.__)("This product is awesome, I love it!","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:n.o.defaultAvatar,96:n.o.defaultAvatar},rating:null,verified:!1}]}}},14:function(e,t){e.exports=window.wp.apiFetch},157:function(e,t,r){"use strict";t.a={editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null}}},158:function(e,t,r){"use strict";var o=r(6),n=r.n(o),c=r(0),a=r(5),i=(r(173),r(61));t.a=e=>{let{attributes:t}=e;return Object(c.createElement)("div",n()({},a.useBlockProps.save({className:Object(i.a)(t)}),Object(i.b)(t)))}},163:function(e,t,r){"use strict";var o=r(0),n=r(1),c=r(9),a=r(3),i=r(5),s=r(2),l=r(76),d=r(30);r(208);var u=e=>{let{onClick:t,label:r=Object(n.__)("Load more","woo-gutenberg-products-block"),screenReaderLabel:c=Object(n.__)("Load more","woo-gutenberg-products-block")}=e;return Object(o.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(o.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(o.createElement)(d.a,{label:r,screenReaderLabel:c})))},b=r(130);r(205);var w=e=>{let{onChange:t,readOnly:r,value:c}=e;return Object(o.createElement)(b.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(n.__)("Order by","woo-gutenberg-products-block"),onChange:t,options:[{key:"most-recent",label:Object(n.__)("Most recent","woo-gutenberg-products-block")},{key:"highest-rating",label:Object(n.__)("Highest rating","woo-gutenberg-products-block")},{key:"lowest-rating",label:Object(n.__)("Lowest rating","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(n.__)("Order reviews by","woo-gutenberg-products-block"),value:c})},p=r(4),m=r.n(p),g=r(23),h=r.n(g),v=r(192),_=r.n(v);const O=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";const o=_()(e,{suffix:r,limit:t});return o.html},j=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),f=(e,t,r,o)=>{const n=((e,t,r)=>{let o={start:0,middle:0,end:e.length};for(;o.start<=o.end;)o.middle=Math.floor((o.start+o.end)/2),t.innerHTML=O(e,o.middle),o=j(o,t.clientHeight,r);return o.middle})(e,t,r);return O(e,n-o.length,o)},k={className:"read-more-content",ellipsis:"…",lessText:Object(n.__)("Read less","woo-gutenberg-products-block"),maxLines:3,moreText:Object(n.__)("Read more","woo-gutenberg-products-block")};class y extends o.Component{constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=Object(o.createRef)(),this.reviewSummary=Object(o.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,o=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:o}),o&&this.setState({summary:f(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:n}=this.props,c=e?r:n;if(c)return Object(o.createElement)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},c)}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:n,isExpanded:c}=this.state;return t?!1===n?Object(o.createElement)("div",{className:e},Object(o.createElement)("div",{ref:this.reviewContent},t)):Object(o.createElement)("div",{className:e},(!c||null===n)&&Object(o.createElement)("div",{ref:this.reviewSummary,"aria-hidden":c,dangerouslySetInnerHTML:{__html:r}}),(c||null===n)&&Object(o.createElement)("div",{ref:this.reviewContent,"aria-hidden":!c},t),this.getButton()):null}}h()(y,"defaultProps",k);var R=y;r(207);var E=e=>{let{attributes:t,review:r={}}=e;const{imageType:c,showReviewDate:a,showReviewerName:i,showReviewImage:s,showReviewRating:l,showReviewContent:d,showProductName:u}=t,{rating:b}=r,w=!(Object.keys(r).length>0),p=Number.isFinite(b)&&l;return Object(o.createElement)("li",{className:m()("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":w,"wc-block-components-review-list-item__item--has-image":s}),"aria-hidden":w},(u||a||i||s||p)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},s&&function(e,t,r){var c,a;return r||!e?Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?Object(o.createElement)("img",{"aria-hidden":"true",alt:(null===(c=e.product_image)||void 0===c?void 0:c.alt)||"",src:(null===(a=e.product_image)||void 0===a?void 0:a.thumbnail)||""}):Object(o.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&Object(o.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:Object(n.__)("Verified buyer","woo-gutenberg-products-block")},Object(n.__)("Verified buyer","woo-gutenberg-products-block")))}(r,c,w),(u||i||p||a)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},p&&function(e){const{rating:t}=e,r={width:t/5*100+"%"},c=Object(n.sprintf)( +/* translators: %f is referring to the average rating value */ +Object(n.__)("Rated %f out of 5","woo-gutenberg-products-block"),t),a={__html:Object(n.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(n.__)("Rated %s out of 5","woo-gutenberg-products-block"),Object(n.sprintf)('%f',t))};return Object(o.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(o.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(o.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(r),u&&function(e){return Object(o.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(o.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(r),i&&function(e){const{reviewer:t=""}=e;return Object(o.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(r),a&&function(e){const{date_created:t,formatted_date_created:r}=e;return Object(o.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(r))),d&&function(e){return Object(o.createElement)(R,{maxLines:10,moreText:Object(n.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(n.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(o.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(r))};r(206);var S=e=>{let{attributes:t,reviews:r}=e;const n=Object(s.getSetting)("showAvatars",!0),c=Object(s.getSetting)("reviewRatingsEnabled",!0),a=(n||"product"===t.imageType)&&t.showReviewImage,i=c&&t.showReviewRating,l={...t,showReviewImage:a,showReviewRating:i};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(E,{attributes:l}):r.map((e,t)=>Object(o.createElement)(E,{key:e.id||t,attributes:l,review:e})))},C=r(6),T=r.n(C),P=r(26),N=r.n(P),L=r(61),x=r(31);class A extends o.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:i,totalReviews:d}=this.props;if(t)return Object(o.createElement)(l.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===i.length&&!r)return Object(o.createElement)(c,{attributes:e});const b=Object(s.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(a.Disabled,null,e.showOrderby&&b&&Object(o.createElement)(w,{readOnly:!0,value:e.orderby,onChange:()=>null}),Object(o.createElement)(S,{attributes:e,reviews:i}),e.showLoadMore&&d>i.length&&Object(o.createElement)(u,{screenReaderLabel:Object(n.__)("Load more reviews","woo-gutenberg-products-block")}))}}var M=(e=>{class t extends o.Component{constructor(){super(...arguments),h()(this,"isPreview",!!this.props.attributes.previewReviews),h()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),h()(this,"isMounted",!1),h()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),h()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(x.a)(e);this.setState({reviews:[],loading:!1,error:r}),t(r)})}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},,function(e,t){e.exports=window.wp.blockEditor},,,,,,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var o=r(51),n=r(0),c=r(42);const s=()=>{const e=Object(c.a)(),t=Object(n.useRef)(e);return Object(n.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(n.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(n.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...r,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,function(e,t,r){"use strict";var o=r(0);t.a=function(e){let{icon:t,size:r=24,...n}=e;return Object(o.cloneElement)(t,{width:r,height:r,...n})}},function(e,t,r){var o=r(8),n=r(57),c=r(58),s=c.setStyleProp,a=c.canTextBeChildOfNode;function i(e){return c.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&c.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,r){for(var c,l,u,d,p,m=(r=r||{}).library||o,h=m.cloneElement,f=m.createElement,b=m.isValidElement,g=[],_="function"==typeof r.replace,y=r.trim,k=0,w=t.length;k
{r.current===e||t&&!t(e,r.current)||(r.current=e)},[e,t]),r.current}},,,,,,,,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var o=r(51),n=r(0),c=r(42);const s=()=>{const e=Object(c.a)(),t=Object(n.useRef)(e);return Object(n.useEffect)(()=>{t.current=e},[e]),{dispatchStoreEvent:Object(n.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-"+e,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:Object(n.useCallback)((function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{Object(o.doAction)("experimental__woocommerce_blocks-checkout-"+e,{...r,storeCart:t.current})}catch(e){console.error(e)}}),[])}}},,function(e,t,r){"use strict";var o=r(0);t.a=function(e){let{icon:t,size:r=24,...n}=e;return Object(o.cloneElement)(t,{width:r,height:r,...n})}},function(e,t,r){var o=r(8),n=r(57),c=r(58),s=c.setStyleProp,a=c.canTextBeChildOfNode;function i(e){return c.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&c.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,r){for(var c,l,u,d,p,m=(r=r||{}).library||o,h=m.cloneElement,b=m.createElement,f=m.isValidElement,g=[],_="function"==typeof r.replace,y=r.trim,k=0,w=t.length;k
${Object(g.__)("Branded t-shirts, jumpers, pants and more!","woo-gutenberg-products-block")}
\n`,image:{id:1,date_created:"2019-07-15T17:05:04",date_created_gmt:"2019-07-15T17:05:04",date_modified:"2019-07-15T17:05:04",date_modified_gmt:"2019-07-15T17:05:04",src:P.m+"previews/collection.jpg",name:"",alt:""},permalink:"#"},editMode:!1}};Object(x.a)(I,N,C,{icon:{src:Object(n.createElement)(a.a,{icon:o,className:"wc-block-editor-components-block-icon"})}})},56:function(e,t,r){"use strict";r.d(t,"c",(function(){return o})),r.d(t,"a",(function(){return a})),r.d(t,"b",(function(){return i}));var n=r(8),c=r(19);const o=(e,t)=>{if(c.n>2)return Object(n.registerBlockType)(e,t)},a=()=>c.n>2,i=()=>c.n>1},59:function(e,t,r){"use strict";var n=r(6),c=r.n(n),o=r(0),a=r(1),i=r(37),l=r(100),s=r(3),u=r(12),d=r(27),b=r(31),m=Object(u.createHigherOrderComponent)(e=>class extends o.Component{constructor(){super(...arguments),this.state={error:null,loading:!1,categories:[]},this.loadCategories=this.loadCategories.bind(this)}componentDidMount(){this.loadCategories()}loadCategories(){this.setState({loading:!0}),Object(d.c)().then(e=>{this.setState({categories:e,loading:!1,error:null})}).catch(async e=>{const t=await Object(b.a)(e);this.setState({categories:[],loading:!1,error:t})})}render(){const{error:t,loading:r,categories:n}=this.state;return Object(o.createElement)(e,c()({},this.props,{error:t,isLoading:r,categories:n}))}},"withCategories"),g=r(35),p=r(4),h=r.n(p);r(99);const O=e=>{let{categories:t,error:r,isLoading:n,onChange:u,onOperatorChange:d,operator:b,selected:m,isCompact:p,isSingle:O,showReviewCount:j}=e;const f={clear:Object(a.__)("Clear all product categories","woo-gutenberg-products-block"),list:Object(a.__)("Product Categories","woo-gutenberg-products-block"),noItems:Object(a.__)("Your store doesn't have any product categories.","woo-gutenberg-products-block"),search:Object(a.__)("Search for product categories","woo-gutenberg-products-block"),selected:e=>Object(a.sprintf)( +/* translators: %d is the count of selected categories. */ +Object(a._n)("%d category selected","%d categories selected",e,"woo-gutenberg-products-block"),e),updated:Object(a.__)("Category search results updated.","woo-gutenberg-products-block")};return r?Object(o.createElement)(g.a,{error:r}):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(l.a,{className:"woocommerce-product-categories",list:t,isLoading:n,selected:m.map(e=>t.find(t=>t.id===e)).filter(Boolean),onChange:u,renderItem:e=>{const{item:t,search:r,depth:n=0}=e,l=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,s=j?Object(a.sprintf)( +/* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ +Object(a._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.review_count,"woo-gutenberg-products-block"),l,t.review_count):Object(a.sprintf)( +/* translators: %1$s is the item name, %2$d is the count of products for the item. */ +Object(a._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.count,"woo-gutenberg-products-block"),l,t.count),u=j?Object(a.sprintf)( +/* translators: %d is the count of reviews. */ +Object(a._n)("%d review","%d reviews",t.review_count,"woo-gutenberg-products-block"),t.review_count):Object(a.sprintf)( +/* translators: %d is the count of products. */ +Object(a._n)("%d product","%d products",t.count,"woo-gutenberg-products-block"),t.count);return Object(o.createElement)(i.a,c()({className:h()("woocommerce-product-categories__item","has-count",{"is-searching":r.length>0,"is-skip-level":0===n&&0!==t.parent})},e,{countLabel:u,"aria-label":s}))},messages:f,isCompact:p,isHierarchical:!0,isSingle:O}),!!d&&Object(o.createElement)("div",{hidden:m.length<2},Object(o.createElement)(s.SelectControl,{className:"woocommerce-product-categories__operator",label:Object(a.__)("Display products matching","woo-gutenberg-products-block"),help:Object(a.__)("Pick at least two categories to use this setting.","woo-gutenberg-products-block"),value:b,onChange:d,options:[{label:Object(a.__)("Any selected categories","woo-gutenberg-products-block"),value:"any"},{label:Object(a.__)("All selected categories","woo-gutenberg-products-block"),value:"all"}]})))};O.defaultProps={operator:"any",isCompact:!1,isSingle:!1},t.a=m(O)},67:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>"string"==typeof e},7:function(e,t){e.exports=window.wp.data},74:function(e,t,r){"use strict";var n=r(6),c=r.n(n),o=r(0),a=r(3),i=r(37),l=r(4),s=r.n(l);t.a=e=>{let{className:t,item:r,isSelected:n,isLoading:l,onSelect:u,disabled:d,...b}=e;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(i.a,c()({},b,{key:r.id,className:t,isSelected:n,item:r,onSelect:u,disabled:d})),n&&l&&Object(o.createElement)("div",{key:"loading",className:s()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},Object(o.createElement)(a.Spinner,null)))}},76:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(80),a=r(197),i=r(4),l=r.n(i),s=r(3),u=r(35);r(124),t.a=e=>{let{className:t,error:r,isLoading:i=!1,onRetry:d}=e;return Object(n.createElement)(s.Placeholder,{icon:Object(n.createElement)(o.a,{icon:a.a}),label:Object(c.__)("Sorry, an error occurred","woo-gutenberg-products-block"),className:l()("wc-block-api-error",t)},Object(n.createElement)(u.a,{error:r}),d&&Object(n.createElement)(n.Fragment,null,i?Object(n.createElement)(s.Spinner,null):Object(n.createElement)(s.Button,{isSecondary:!0,onClick:d},Object(c.__)("Retry","woo-gutenberg-products-block"))))}},78:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(67),c=r(24);const o=e=>Object(n.a)(e)?JSON.parse(e)||{}:Object(c.b)(e)?e:{}},8:function(e,t){e.exports=window.wp.blocks},88:function(e,t,r){"use strict";var n=r(6),c=r.n(n),o=r(0),a=r(1),i=r(9),l=r(37),s=r(100),u=r(12),d=Object(u.createHigherOrderComponent)(e=>{class t extends o.Component{render(){const{selected:t}=this.props,r=null==t;return Array.isArray(t)?Object(o.createElement)(e,this.props):Object(o.createElement)(e,c()({},this.props,{selected:r?[]:[t]}))}}return t.defaultProps={selected:null},t},"withTransformSingleSelectToMultipleSelect"),b=r(202),m=r(23),g=r.n(m),p=r(26),h=r.n(p),O=r(27),j=r(31),f=Object(u.createHigherOrderComponent)(e=>{class t extends o.Component{constructor(){super(...arguments),g()(this,"state",{error:null,loading:!1,variations:{}}),g()(this,"loadVariations",()=>{const{products:e}=this.props,{loading:t,variations:r}=this.state;if(t)return;const n=this.getExpandedProduct();if(!n||r[n])return;const c=e.find(e=>e.id===n);c.variations&&0!==c.variations.length?(this.setState({loading:!0}),Object(O.g)(n).then(e=>{const t=e.map(e=>({...e,parent:n}));this.setState({variations:{...this.state.variations,[n]:t},loading:!1,error:null})}).catch(async e=>{const t=await Object(j.a)(e);this.setState({variations:{...this.state.variations,[n]:null},loading:!1,error:t})})):this.setState({variations:{...this.state.variations,[n]:null},loading:!1,error:null})})}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:r,showVariations:n}=this.props;n&&(!h()(e.selected,r)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some(t=>t.id===e)}findParentProduct(e){var t;const{products:r}=this.props;return null===(t=r.filter(t=>t.variations&&t.variations.find(t=>{let{id:r}=t;return r===e}))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:r}=this.props;if(!r)return null;let n=t&&t.length?t[0]:null;return n?this.prevSelectedItem=n:this.prevSelectedItem&&(e||this.isProductId(this.prevSelectedItem)||(n=this.prevSelectedItem)),!e&&n?this.isProductId(n)?n:this.findParentProduct(n):null}render(){const{error:t,isLoading:r}=this.props,{error:n,loading:a,variations:i}=this.state;return Object(o.createElement)(e,c()({},this.props,{error:n||t,expandedProduct:this.getExpandedProduct(),isLoading:r,variations:i,variationsLoading:a}))}}return g()(t,"defaultProps",{selected:[],showVariations:!1}),t},"withProductVariations"),_=r(35),w=r(4),v=r.n(w),E=r(74);r(147);const y={list:Object(a.__)("Products","woo-gutenberg-products-block"),noItems:Object(a.__)("Your store doesn't have any products.","woo-gutenberg-products-block"),search:Object(a.__)("Search for a product to display","woo-gutenberg-products-block"),updated:Object(a.__)("Product search results updated.","woo-gutenberg-products-block")},k=e=>{let{expandedProduct:t,error:r,instanceId:n,isCompact:u,isLoading:d,onChange:b,onSearch:m,products:g,renderItem:p,selected:h,showVariations:O,variations:j,variationsLoading:f}=e;if(r)return Object(o.createElement)(_.a,{error:r});const w=[...g,...j&&j[t]?j[t]:[]];return Object(o.createElement)(s.a,{className:"woocommerce-products",list:w,isCompact:u,isLoading:d,isSingle:!0,selected:w.filter(e=>{let{id:t}=e;return h.includes(t)}),onChange:b,renderItem:p||(O?e=>{const{item:t,search:r,depth:s=0,isSelected:u,onSelect:b}=e,m=t.variations&&Array.isArray(t.variations)?t.variations.length:0,g=v()("woocommerce-search-product__item","woocommerce-search-list__item","depth-"+s,"has-count",{"is-searching":r.length>0,"is-skip-level":0===s&&0!==t.parent,"is-variable":m>0});if(!t.breadcrumbs.length)return Object(o.createElement)(E.a,c()({},e,{className:v()(g,{"is-selected":u}),isSelected:u,item:t,onSelect:()=>()=>{b(t)()},isLoading:d||f,countLabel:t.variations.length>0?Object(a.sprintf)( +/* translators: %1$d is the number of variations of a product product. */ +Object(a.__)("%1$d variations","woo-gutenberg-products-block"),t.variations.length):null,name:"products-"+n,"aria-label":Object(a.sprintf)( +/* translators: %1$s is the product name, %2$d is the number of variations of that product. */ +Object(a._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",t.variations.length,"woo-gutenberg-products-block"),t.name,t.variations.length)}));const p=Object(i.isEmpty)(t.variation)?e:{...e,item:{...e.item,name:t.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.variation}`};return Object(o.createElement)(l.a,c()({},p,{className:g,name:"variations-"+n}))}:null),onSearch:m,messages:y,isHierarchical:!0})};k.defaultProps={isCompact:!1,expandedProduct:null,selected:[],showVariations:!1},t.a=d(Object(b.a)(f(Object(u.withInstanceId)(k))))},9:function(e,t){e.exports=window.lodash},90:function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0),c=r(50),o=r(9);function a(e){return!!e&&Object(o.isNumber)(e.id)&&"string"==typeof e.src}function i(e){let{blockName:t,item:r,mediaId:o,mediaSrc:i}=e;const[l,s]=Object(n.useState)(0),[u,d]=Object(n.useState)("");return Object(n.useEffect)(()=>{var e,n;s(o||(t===c.a.featuredProduct?(n=r)&&n.images&&n.images.length&&n.images[0].id||0:(e=r)&&a(e.image)?e.image.id:0))},[t,r,o]),Object(n.useEffect)(()=>{var e,n;d(i||(t===c.a.featuredProduct?(n=r)&&n.images&&n.images.length&&n.images[0].src||"":(e=r)&&a(e.image)?e.image.src:""))},[t,r,i]),{backgroundImageId:l,backgroundImageSrc:u}}},91:function(e,t,r){"use strict";function n(e){return e?`${Math.round(100*e.x)}% ${Math.round(100*e.y)}%`:""}function c(e){let{focalPoint:t,imageFit:r,isImgElement:c,isRepeated:o,url:a}=e,i={};var l;return i=c?{...i,...(l=t,l?{objectPosition:n(l)}:{}),objectFit:r}:{...i,...a&&{backgroundImage:`url(${a})`},backgroundPosition:n(t),...!o&&{backgroundRepeat:"no-repeat",backgroundSize:"cover"===r?r:"auto"}},i}function o(e){return"wc-block-"+e.split("/")[1]}function a(e){return 0===e||50===e?null:"has-background-dim-"+10*Math.round(e/10)}r.d(t,"b",(function(){return c})),r.d(t,"c",(function(){return o})),r.d(t,"a",(function(){return a}))},99:function(e,t){}}); \ No newline at end of file diff --git a/build/featured-category/block.json b/build/featured-category/block.json new file mode 100644 index 00000000000..8f2dbb33467 --- /dev/null +++ b/build/featured-category/block.json @@ -0,0 +1,108 @@ +{ + "name": "woocommerce/featured-category", + "version": "1.0.0", + "title": "Featured Category", + "category": "woocommerce", + "keywords": [ + "WooCommerce" + ], + "description": "Visually highlight a product category and encourage prompt action.", + "supports": { + "align": [ + "wide", + "full" + ], + "html": false, + "color": { + "background": true, + "text": true + }, + "spacing": { + "padding": true, + "__experimentalDefaultControls": { + "padding": true + }, + "__experimentalSkipSerialization": true + }, + "__experimentalBorder": { + "color": true, + "radius": true, + "width": true, + "__experimentalSkipSerialization": true + } + }, + "attributes": { + "alt": { + "type": "string", + "default": "" + }, + "contentAlign": { + "type": "string", + "default": "center" + }, + "dimRatio": { + "type": "number", + "default": 50 + }, + "editMode": { + "type": "boolean", + "default": true + }, + "focalPoint": { + "type": "object", + "default": { + "x": 0.5, + "y": 0.5 + } + }, + "imageFit": { + "type": "string", + "default": "none" + }, + "hasParallax": { + "type": "boolean", + "default": false + }, + "isRepeated": { + "type": "boolean", + "default": false + }, + "mediaId": { + "type": "number", + "default": 0 + }, + "mediaSrc": { + "type": "string", + "default": "" + }, + "minHeight": { + "type": "number", + "default": 500 + }, + "linkText": { + "default": "Shop now", + "type": "string" + }, + "categoryId": { + "type": "number" + }, + "overlayColor": { + "type": "string", + "default": "#000000" + }, + "overlayGradient": { + "type": "string" + }, + "previewCategory": { + "type": "object", + "default": null + }, + "showDesc": { + "type": "boolean", + "default": true + } + }, + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2, + "$schema": "https://schemas.wp.org/trunk/block.json" +} diff --git a/build/featured-product.asset.php b/build/featured-product.asset.php new file mode 100644 index 00000000000..e864f00c38d --- /dev/null +++ b/build/featured-product.asset.php @@ -0,0 +1 @@ + array('lodash', 'react', 'wc-settings', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-escape-html', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '3297a5fc12c27270663306d4255df3b8'); \ No newline at end of file diff --git a/build/featured-product.js b/build/featured-product.js new file mode 100644 index 00000000000..630b51d9716 --- /dev/null +++ b/build/featured-product.js @@ -0,0 +1,21 @@ +this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["featured-product"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],l=t[2],d=0,b=[];d1&&(u=f(u,{key:u.key||w})),b.push(u);else if("text"!==i.type){switch(d=i.attribs,c(i)?a(d.style,d):d&&(d=o(d)),p=null,i.type){case"script":case"style":i.children[0]&&(d.dangerouslySetInnerHTML={__html:i.children[0].data});break;case"tag":"textarea"===i.name&&i.children[0]?d.defaultValue=i.children[0].data:i.children&&i.children.length&&(p=e(i.children,n));break;default:continue}k>1&&(d.key=w),b.push(m(i.name,d,p))}else{if((l=!i.data.trim().length)&&i.parent&&!s(i.parent))continue;if(x&&l)continue;b.push(i.data)}return 1===b.length?b[0]:b}},77:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n (0===g&&b(!0),++g,()=>{1===g&&b(!1),--g}),[]),null}var v=n(35);function w(e){const t=Object(o.useContext)(v.a),n=t.slots[e]||{},r=t.fills[e],i=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:i,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 O=Object(o.createContext)({registerSlot:()=>{},unregisterSlot:()=>{},registerFill:()=>{},unregisterFill:()=>{},getSlot:()=>{},getFills:()=>{},subscribe:()=>{}});function x({name:e,children:t,registerFill:n,unregisterFill:r}){const i=(e=>{const{getSlot:t,subscribe:n}=Object(o.useContext)(O),[r,i]=Object(o.useState)(t(e));return Object(o.useEffect)(()=>(i(t(e)),n(()=>{i(t(e))})),[e]),r})(e),c=Object(o.useRef)({name:e,children:t});return Object(o.useLayoutEffect)(()=>(n(e,c.current),()=>r(e,c.current)),[]),Object(o.useLayoutEffect)(()=>{c.current.children=t,i&&i.forceUpdate()},[t]),Object(o.useLayoutEffect)(()=>{e!==c.current.name&&(r(c.current.name,c.current),c.current.name=e,n(e,c.current))},[e]),i&&i.node?(Object(s.isFunction)(t)&&(t=t(i.props.fillProps)),Object(o.createPortal)(t,i.node)):null}var k=e=>Object(o.createElement)(O.Consumer,null,({registerFill:t,unregisterFill:n})=>Object(o.createElement)(x,Object(r.a)({},e,{registerFill:t,unregisterFill:n})));class E 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,i=Object(s.map)(r(t,this),e=>{const t=Object(s.isFunction)(e.children)?e.children(n):e.children;return o.Children.map(t,(e,t)=>{if(!e||Object(s.isString)(e))return e;const n=e.key||t;return Object(o.cloneElement)(e,{key:n})})}).filter(Object(s.negate)(o.isEmptyElement));return Object(o.createElement)(o.Fragment,null,Object(s.isFunction)(e)?e(i):i)}}var j=e=>Object(o.createElement)(O.Consumer,null,({registerSlot:t,unregisterSlot:n,getFills:i})=>Object(o.createElement)(E,Object(r.a)({},e,{registerSlot:t,unregisterSlot:n,getFills:i})));function C(){const[,e]=Object(o.useState)({}),t=Object(o.useRef)(!0);return Object(o.useEffect)(()=>()=>{t.current=!1},[]),()=>{t.current&&e({})}}function _({name:e,children:t}){const n=w(e),r=Object(o.useRef)({rerender:C()});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 S=Object(o.forwardRef)((function({name:e,fillProps:t={},as:n="div",...i},c){const s=Object(o.useContext)(v.a),a=Object(o.useRef)();return Object(o.useLayoutEffect)(()=>(s.registerSlot(e,a,t),()=>{s.unregisterSlot(e,a)}),[s.registerSlot,s.unregisterSlot,e]),Object(o.useLayoutEffect)(()=>{s.updateSlot(e,t)}),Object(o.createElement)(n,Object(r.a)({ref:Object(u.useMergeRefs)([c,a])},i))}));function T(e){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(k,e),Object(o.createElement)(_,e))}n(14),o.Component;const N=Object(o.forwardRef)(({bubblesVirtually:e,...t},n)=>e?Object(o.createElement)(S,Object(r.a)({},t,{ref:n})):Object(o.createElement)(j,t));function R(e){return"appear"===e?"top":"left"}function M(e,t){const{paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:i}=(c=t).ownerDocument.defaultView.getComputedStyle(c);var c;const s=n?parseInt(n,10):0,a=r?parseInt(r,10):0,l=o?parseInt(o,10):0,u=i?parseInt(i,10):0;return{x:e.left+l,y:e.top+s,width:e.width-l-u,height:e.height-s-a,left:e.left+l,right:e.right-u,top:e.top+s,bottom:e.bottom-a}}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 A(e,t,n){n?e.classList.contains(t)||e.classList.add(t):e.classList.contains(t)&&e.classList.remove(t)}const I=Object(o.forwardRef)(({headerTitle:e,onClose:t,children:n,className:i,noArrow:s=!0,isAlternate:a,position:h="bottom right",range:b,focusOnMount:g="firstElement",anchorRef:v,shouldAnchorIncludePadding:O,anchorRect:x,getAnchorRect:k,expandOnMobile:E,animate:j=!0,onClickOutside:C,onFocusOutside:_,__unstableStickyBoundaryElement:S,__unstableSlotName:N="Popover",__unstableObserveElement:I,__unstableBoundaryParent:F,__unstableForcePosition:D,__unstableForceXAlignment:B,...H},z)=>{const W=Object(o.useRef)(null),U=Object(o.useRef)(null),V=Object(o.useRef)(),q=Object(u.useViewportMatch)("medium","<"),[G,$]=Object(o.useState)(),X=w(N),J=E&&q,[Z,K]=Object(u.useResizeObserver)();s=J||s,Object(o.useLayoutEffect)(()=>{if(J)return A(V.current,"is-without-arrow",s),A(V.current,"is-alternate",a),L(V.current,"data-x-axis"),L(V.current,"data-y-axis"),P(V.current,"top"),P(V.current,"left"),P(U.current,"maxHeight"),void P(U.current,"maxWidth");const e=()=>{if(!V.current||!U.current)return;let e=function(e,t,n,r=!1,o,i){if(t)return t;if(n){if(!e.current)return;const t=n(e.current);return f(t,t.ownerDocument||e.current.ownerDocument,i)}if(!1!==r){if(!(r&&window.Range&&window.Element&&window.DOMRect))return;if("function"==typeof(null==r?void 0:r.cloneRange))return f(Object(d.getRectangleFromRange)(r),r.endContainer.ownerDocument,i);if("function"==typeof(null==r?void 0:r.getBoundingClientRect)){const e=f(r.getBoundingClientRect(),r.ownerDocument,i);return o?e:M(e,r)}const{top:e,bottom:t}=r,n=e.getBoundingClientRect(),c=t.getBoundingClientRect(),s=f(new window.DOMRect(n.left,n.top,n.width,c.bottom-n.top),e.ownerDocument,i);return o?s:M(s,r)}if(!e.current)return;const{parentNode:c}=e.current,s=c.getBoundingClientRect();return o?s:M(s,c)}(W,x,k,v,O,V.current);if(!e)return;const{offsetParent:t,ownerDocument:n}=V.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 i;F&&(r=null===(i=V.current.closest(".popover-slot"))||void 0===i?void 0:i.parentNode);const c=K.height?K:U.current.getBoundingClientRect(),{popoverTop:l,popoverLeft:u,xAxis:p,yAxis:b,contentHeight:g,contentWidth:y}=function(e,t,n="top",r,o,i,c,s,a){const[l,u="center",d]=n.split(" "),p=function(e,t,n,r,o,i,c,s){const{height:a}=t;if(o){const t=o.getBoundingClientRect().top+a-c;if(e.top<=t)return{yAxis:n,popoverTop:Math.min(e.bottom,t)}}let l=e.top+e.height/2;"bottom"===r?l=e.bottom:"top"===r&&(l=e.top);const u={popoverTop:l,contentHeight:(l-a/2>0?a/2:l)+(l+a/2>window.innerHeight?window.innerHeight-l:a/2)},d={popoverTop:e.top,contentHeight:e.top-10-a>0?a:e.top-10},p={popoverTop:e.bottom,contentHeight:e.bottom+10+a>window.innerHeight?window.innerHeight-10-e.bottom:a};let m,f=n,h=null;if(!o&&!s)if("middle"===n&&u.contentHeight===a)f="middle";else if("top"===n&&d.contentHeight===a)f="top";else if("bottom"===n&&p.contentHeight===a)f="bottom";else{f=d.contentHeight>p.contentHeight?"top":"bottom";const e="top"===f?d.contentHeight:p.contentHeight;h=e!==a?e:null}return m="middle"===f?u.popoverTop:"top"===f?d.popoverTop:p.popoverTop,{yAxis:f,popoverTop:m,contentHeight:h}}(e,t,l,d,r,0,i,s);return{...function(e,t,n,r,o,i,c,s,a){const{width:l}=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-l/2>0?l/2:u)+(u+l/2>window.innerWidth?window.innerWidth-u:l/2)};let p=e.left;"right"===r?p=e.right:"middle"===i||a||(p=u);let f=e.right;"left"===r?f=e.left:"middle"===i||a||(f=u);const h={popoverLeft:p,contentWidth:p-l>0?l:p},b={popoverLeft:f,contentWidth:f+l>window.innerWidth?window.innerWidth-f:l};let g,y=n,v=null;if(!o&&!s)if("center"===n&&d.contentWidth===l)y="center";else if("left"===n&&h.contentWidth===l)y="left";else if("right"===n&&b.contentWidth===l)y="right";else{y=h.contentWidth>b.contentWidth?"left":"right";const e="left"===y?h.contentWidth:b.contentWidth;l>window.innerWidth&&(v=window.innerWidth),e!==l&&(y="center",d.popoverLeft=window.innerWidth/2)}if(g="center"===y?d.popoverLeft:"left"===y?h.popoverLeft:b.popoverLeft,c){const e=c.getBoundingClientRect();g=Math.min(g,e.right-l),Object(m.isRTL)()||(g=Math.max(g,0))}return{xAxis:y,popoverLeft:g,contentWidth:v}}(e,t,u,d,r,p.yAxis,c,s,a),...p}}(e,c,h,S,V.current,o,r,D,B);"number"==typeof l&&"number"==typeof u&&(P(V.current,"top",l+"px"),P(V.current,"left",u+"px")),A(V.current,"is-without-arrow",s||"center"===p&&"middle"===b),A(V.current,"is-alternate",a),L(V.current,"data-x-axis",p),L(V.current,"data-y-axis",b),P(U.current,"maxHeight","number"==typeof g?g+"px":""),P(U.current,"maxWidth","number"==typeof y?y+"px":""),$(({left:"right",right:"left"}[p]||"center")+" "+({top:"bottom",bottom:"top"}[b]||"middle"))};e();const{ownerDocument:t}=V.current,{defaultView:n}=t,r=n.setInterval(e,500);let o;const i=()=>{n.cancelAnimationFrame(o),o=n.requestAnimationFrame(e)};n.addEventListener("click",i),n.addEventListener("resize",e),n.addEventListener("scroll",e,!0);const c=function(e){if(e)return e.endContainer?e.endContainer.ownerDocument:e.top?e.top.ownerDocument:e.ownerDocument}(v);let l;return c&&c!==t&&(c.defaultView.addEventListener("resize",e),c.defaultView.addEventListener("scroll",e,!0)),I&&(l=new n.MutationObserver(e),l.observe(I,{attributes:!0})),()=>{n.clearInterval(r),n.removeEventListener("resize",e),n.removeEventListener("scroll",e,!0),n.removeEventListener("click",i),n.cancelAnimationFrame(o),c&&c!==t&&(c.defaultView.removeEventListener("resize",e),c.defaultView.removeEventListener("scroll",e,!0)),l&&l.disconnect()}},[J,x,k,v,O,h,K,S,I,F]);const Q=(e,n)=>{if("focus-outside"===e&&_)_(n);else if("focus-outside"===e&&C){const e=new window.MouseEvent("click");Object.defineProperty(e,"target",{get:()=>n.relatedTarget}),l()("Popover onClickOutside prop",{since:"5.3",alternative:"onFocusOutside"}),C(e)}else t&&t()},[ee,te]=Object(u.__experimentalUseDialog)({focusOnMount:g,__unstableOnClose:Q,onClose:Q}),ne=Object(u.useMergeRefs)([V,ee,z]),re=Boolean(j&&G)&&function(e){if("loading"===e.type)return c()("components-animate__loading");const{type:t,origin:n=R(t)}=e;if("appear"===t){const[e,t="center"]=n.split(" ");return c()("components-animate__appear",{["is-from-"+t]:"center"!==t,["is-from-"+e]:"middle"!==e})}return"slide-in"===t?c()("components-animate__slide-in","is-from-"+n):void 0}({type:"appear",origin:G});let oe=Object(o.createElement)("div",Object(r.a)({className:c()("components-popover",i,re,{"is-expanded":J,"is-without-arrow":s,"is-alternate":a})},H,{ref:ne},te,{tabIndex:"-1"}),J&&Object(o.createElement)(y,null),J&&Object(o.createElement)("div",{className:"components-popover__header"},Object(o.createElement)("span",{className:"components-popover__header-title"},e),Object(o.createElement)(Y,{className:"components-popover__close",icon:p.a,onClick:t})),Object(o.createElement)("div",{ref:U,className:"components-popover__content"},Object(o.createElement)("div",{style:{position:"relative"}},Z,n)));return X.ref&&(oe=Object(o.createElement)(T,{name:N},oe)),v||x?oe:Object(o.createElement)("span",{ref:W},oe)});I.Slot=Object(o.forwardRef)((function({name:e="Popover"},t){return Object(o.createElement)(N,{bubblesVirtually:!0,name:e,className:"popover-slot",ref:t})}));var F=I,D=function({shortcut:e,className:t}){if(!e)return null;let n,r;return Object(s.isString)(e)&&(n=e),Object(s.isObject)(e)&&(n=e.display,r=e.ariaLabel),Object(o.createElement)("span",{className:t,"aria-label":r},n)};const B=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)(B,e),Object(o.cloneElement)(t,{children:n}),","),e),z=({child:e,eventHandlers:t,childrenWithPopover:n})=>Object(o.cloneElement)(e,{...t,children:n}),W=(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 U=function({children:e,position:t,text:n,shortcut:r}){const[i,c]=Object(o.useState)(!1),[a,l]=Object(o.useState)(!1),d=Object(u.useDebounce)(l,700),p=t=>{W(e,"onMouseDown",t),document.addEventListener("mouseup",h),c(!0)},m=t=>{W(e,"onMouseUp",t),document.removeEventListener("mouseup",h),c(!1)},f=e=>"mouseUp"===e?m:"mouseDown"===e?p:void 0,h=f("mouseUp"),b=(t,n)=>r=>{if(W(e,t,r),r.currentTarget.disabled)return;if("focus"===r.type&&i)return;d.cancel();const o=Object(s.includes)(["focus","mouseenter"],r.type);o!==a&&(n?d(o):l(o))},g=()=>{d.cancel(),document.removeEventListener("mouseup",h)};if(Object(o.useEffect)(()=>g,[]),1!==o.Children.count(e))return e;const y={onMouseEnter:b("onMouseEnter",!0),onMouseLeave:b("onMouseLeave"),onClick:b("onClick"),onFocus:b("onFocus"),onBlur:b("onBlur"),onMouseDown:f("mouseDown")},v=o.Children.only(e),{children:w,disabled:O}=v.props;return(O?H:z)({child:v,eventHandlers:y,childrenWithPopover:(({grandchildren:e,isOver:t,position:n,text:r,shortcut:i})=>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)(D,{className:"components-tooltip__shortcut",shortcut:i}))))({grandchildren:w,isOver:a,position:t,text:n,shortcut:r})})},V=n(54),q=n(41);const G=["onMouseDown","onClick"];var Y=t.a=Object(o.forwardRef)((function(e,t){const{href:n,target:i,isSmall:a,isPressed:u,isBusy:d,isDestructive:p,className:m,disabled:f,icon:h,iconPosition:b="left",iconSize:g,showTooltip:y,tooltipPosition:v,shortcut:w,label:O,children:x,text:k,variant:E,__experimentalIsFocusable:j,describedBy:C,..._}=function({isDefault:e,isPrimary:t,isSecondary:n,isTertiary:r,isLink:o,variant:i,...c}){let s=i;var a,u,d,p,m;return t&&(null!==(a=s)&&void 0!==a||(s="primary")),r&&(null!==(u=s)&&void 0!==u||(s="tertiary")),n&&(null!==(d=s)&&void 0!==d||(s="secondary")),e&&(l()("Button isDefault prop",{since:"5.4",alternative:'variant="secondary"'}),null!==(p=s)&&void 0!==p||(s="secondary")),o&&(null!==(m=s)&&void 0!==m||(s="link")),{...c,variant:s}}(e),S=c()("components-button",m,{"is-secondary":"secondary"===E,"is-primary":"primary"===E,"is-small":a,"is-tertiary":"tertiary"===E,"is-pressed":u,"is-busy":d,"is-link":"link"===E,"is-destructive":p,"has-text":!!h&&!!x,"has-icon":!!h}),T=f&&!j,N=void 0===n||T?"button":"a",R="a"===N?{href:n,target:i}:{type:"button",disabled:T,"aria-pressed":u};if(f&&j){R["aria-disabled"]=!0;for(const e of G)_[e]=e=>{e.stopPropagation(),e.preventDefault()}}const M=!T&&(y&&O||w||!!O&&(!x||Object(s.isArray)(x)&&!x.length)&&!1!==y),L=C?Object(s.uniqueId)():null,P=_["aria-describedby"]||L,A=Object(o.createElement)(N,Object(r.a)({},R,_,{className:S,"aria-label":_["aria-label"]||O,"aria-describedby":P,ref:t}),h&&"left"===b&&Object(o.createElement)(V.a,{icon:h,size:g}),k&&Object(o.createElement)(o.Fragment,null,k),h&&"right"===b&&Object(o.createElement)(V.a,{icon:h,size:g}),x);return M?Object(o.createElement)(o.Fragment,null,Object(o.createElement)(U,{text:C||O,shortcut:w,position:v},A),C&&Object(o.createElement)(q.a,null,Object(o.createElement)("span",{id:L},C))):Object(o.createElement)(o.Fragment,null,A,C&&Object(o.createElement)(q.a,null,Object(o.createElement)("span",{id:L},C)))}))},,,function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r=e=>"boolean"==typeof e},function(e,t,n){"use strict";var r=n(0);t.a=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})}},function(e,t,n){var r=n(8),o=n(57),i=n(58),c=i.setStyleProp,s=i.canTextBeChildOfNode;function a(e){return i.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&i.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,n){for(var i,l,u,d,p,m=(n=n||{}).library||r,f=m.cloneElement,h=m.createElement,b=m.isValidElement,g=[],y="function"==typeof n.replace,v=n.trim,w=0,O=t.length;w
${Object(o.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:c.o.defaultAvatar,96:c.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(o.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(o.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#", +/* translators: An example person name used for the block previews. */ +reviewer:Object(o.__)("Bob","woo-gutenberg-products-block"),review:`${Object(o.__)("This product is awesome, I love it!","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:c.o.defaultAvatar,96:c.o.defaultAvatar},rating:null,verified:!1}]}}},14:function(e,t){e.exports=window.wp.apiFetch},157:function(e,t,r){"use strict";t.a={editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null}}},158:function(e,t,r){"use strict";var o=r(6),c=r.n(o),n=r(0),a=r(5),s=(r(173),r(61));t.a=e=>{let{attributes:t}=e;return Object(n.createElement)("div",c()({},a.useBlockProps.save({className:Object(s.a)(t)}),Object(s.b)(t)))}},16:function(e,t){e.exports=window.wp.url},163:function(e,t,r){"use strict";var o=r(0),c=r(1),n=r(9),a=r(3),s=r(5),i=r(2),l=r(76),d=r(30);r(208);var u=e=>{let{onClick:t,label:r=Object(c.__)("Load more","woo-gutenberg-products-block"),screenReaderLabel:n=Object(c.__)("Load more","woo-gutenberg-products-block")}=e;return Object(o.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(o.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(o.createElement)(d.a,{label:r,screenReaderLabel:n})))},b=r(130);r(205);var m=e=>{let{onChange:t,readOnly:r,value:n}=e;return Object(o.createElement)(b.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(c.__)("Order by","woo-gutenberg-products-block"),onChange:t,options:[{key:"most-recent",label:Object(c.__)("Most recent","woo-gutenberg-products-block")},{key:"highest-rating",label:Object(c.__)("Highest rating","woo-gutenberg-products-block")},{key:"lowest-rating",label:Object(c.__)("Lowest rating","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(c.__)("Order reviews by","woo-gutenberg-products-block"),value:n})},p=r(4),g=r.n(p),w=r(23),h=r.n(w),v=r(192),O=r.n(v);const _=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";const o=O()(e,{suffix:r,limit:t});return o.html},j=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),f=(e,t,r,o)=>{const c=((e,t,r)=>{let o={start:0,middle:0,end:e.length};for(;o.start<=o.end;)o.middle=Math.floor((o.start+o.end)/2),t.innerHTML=_(e,o.middle),o=j(o,t.clientHeight,r);return o.middle})(e,t,r);return _(e,c-o.length,o)},y={className:"read-more-content",ellipsis:"…",lessText:Object(c.__)("Read less","woo-gutenberg-products-block"),maxLines:3,moreText:Object(c.__)("Read more","woo-gutenberg-products-block")};class k extends o.Component{constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=Object(o.createRef)(),this.reviewSummary=Object(o.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,o=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:o}),o&&this.setState({summary:f(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:c}=this.props,n=e?r:c;if(n)return Object(o.createElement)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},n)}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:c,isExpanded:n}=this.state;return t?!1===c?Object(o.createElement)("div",{className:e},Object(o.createElement)("div",{ref:this.reviewContent},t)):Object(o.createElement)("div",{className:e},(!n||null===c)&&Object(o.createElement)("div",{ref:this.reviewSummary,"aria-hidden":n,dangerouslySetInnerHTML:{__html:r}}),(n||null===c)&&Object(o.createElement)("div",{ref:this.reviewContent,"aria-hidden":!n},t),this.getButton()):null}}h()(k,"defaultProps",y);var E=k;r(207);var R=e=>{let{attributes:t,review:r={}}=e;const{imageType:n,showReviewDate:a,showReviewerName:s,showReviewImage:i,showReviewRating:l,showReviewContent:d,showProductName:u}=t,{rating:b}=r,m=!(Object.keys(r).length>0),p=Number.isFinite(b)&&l;return Object(o.createElement)("li",{className:g()("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":m,"wc-block-components-review-list-item__item--has-image":i}),"aria-hidden":m},(u||a||s||i||p)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},i&&function(e,t,r){var n,a;return r||!e?Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):Object(o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?Object(o.createElement)("img",{"aria-hidden":"true",alt:(null===(n=e.product_image)||void 0===n?void 0:n.alt)||"",src:(null===(a=e.product_image)||void 0===a?void 0:a.thumbnail)||""}):Object(o.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&Object(o.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:Object(c.__)("Verified buyer","woo-gutenberg-products-block")},Object(c.__)("Verified buyer","woo-gutenberg-products-block")))}(r,n,m),(u||s||p||a)&&Object(o.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},p&&function(e){const{rating:t}=e,r={width:t/5*100+"%"},n=Object(c.sprintf)( +/* translators: %f is referring to the average rating value */ +Object(c.__)("Rated %f out of 5","woo-gutenberg-products-block"),t),a={__html:Object(c.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(c.__)("Rated %s out of 5","woo-gutenberg-products-block"),Object(c.sprintf)('%f',t))};return Object(o.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(o.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":n},Object(o.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(r),u&&function(e){return Object(o.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(o.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(r),s&&function(e){const{reviewer:t=""}=e;return Object(o.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(r),a&&function(e){const{date_created:t,formatted_date_created:r}=e;return Object(o.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(r))),d&&function(e){return Object(o.createElement)(E,{maxLines:10,moreText:Object(c.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(c.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(o.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(r))};r(206);var C=e=>{let{attributes:t,reviews:r}=e;const c=Object(i.getSetting)("showAvatars",!0),n=Object(i.getSetting)("reviewRatingsEnabled",!0),a=(c||"product"===t.imageType)&&t.showReviewImage,s=n&&t.showReviewRating,l={...t,showReviewImage:a,showReviewRating:s};return Object(o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(o.createElement)(R,{attributes:l}):r.map((e,t)=>Object(o.createElement)(R,{key:e.id||t,attributes:l,review:e})))},S=r(6),N=r.n(S),P=r(26),x=r.n(P),I=r(61),L=r(31);class T extends o.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:n,reviews:s,totalReviews:d}=this.props;if(t)return Object(o.createElement)(l.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===s.length&&!r)return Object(o.createElement)(n,{attributes:e});const b=Object(i.getSetting)("reviewRatingsEnabled",!0);return Object(o.createElement)(a.Disabled,null,e.showOrderby&&b&&Object(o.createElement)(m,{readOnly:!0,value:e.orderby,onChange:()=>null}),Object(o.createElement)(C,{attributes:e,reviews:s}),e.showLoadMore&&d>s.length&&Object(o.createElement)(u,{screenReaderLabel:Object(c.__)("Load more reviews","woo-gutenberg-products-block")}))}}var A=(e=>{class t extends o.Component{constructor(){super(...arguments),h()(this,"isPreview",!!this.props.attributes.previewReviews),h()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),h()(this,"isMounted",!1),h()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),h()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(L.a)(e);this.setState({reviews:[],loading:!1,error:r}),t(r)})}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay${Object(n.__)("I bought this product last week and I'm very happy with it.","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(n.__)("July 12, 2019","woo-gutenberg-products-block"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(n.__)("WordPress Pennant","woo-gutenberg-products-block"),product_permalink:"#", +/* translators: An example person name used for the block previews. */ +reviewer:Object(n.__)("Bob","woo-gutenberg-products-block"),review:`${Object(n.__)("This product is awesome, I love it!","woo-gutenberg-products-block")}
\n`,reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:null,verified:!1}]}}},14:function(e,t){e.exports=window.wp.apiFetch},147:function(e,t){},157:function(e,t,r){"use strict";t.a={editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null}}},158:function(e,t,r){"use strict";var n=r(6),o=r.n(n),c=r(0),a=r(5),s=(r(173),r(61));t.a=e=>{let{attributes:t}=e;return Object(c.createElement)("div",o()({},a.useBlockProps.save({className:Object(s.a)(t)}),Object(s.b)(t)))}},16:function(e,t){e.exports=window.wp.url},163:function(e,t,r){"use strict";var n=r(0),o=r(1),c=r(9),a=r(3),s=r(5),i=r(2),l=r(76),d=r(30);r(208);var u=e=>{let{onClick:t,label:r=Object(o.__)("Load more","woo-gutenberg-products-block"),screenReaderLabel:c=Object(o.__)("Load more","woo-gutenberg-products-block")}=e;return Object(n.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(n.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(n.createElement)(d.a,{label:r,screenReaderLabel:c})))},b=r(130);r(205);var m=e=>{let{onChange:t,readOnly:r,value:c}=e;return Object(n.createElement)(b.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(o.__)("Order by","woo-gutenberg-products-block"),onChange:t,options:[{key:"most-recent",label:Object(o.__)("Most recent","woo-gutenberg-products-block")},{key:"highest-rating",label:Object(o.__)("Highest rating","woo-gutenberg-products-block")},{key:"lowest-rating",label:Object(o.__)("Lowest rating","woo-gutenberg-products-block")}],readOnly:r,screenReaderLabel:Object(o.__)("Order reviews by","woo-gutenberg-products-block"),value:c})},p=r(4),w=r.n(p),g=r(23),h=r.n(g),v=r(192),O=r.n(v);const j=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";const n=O()(e,{suffix:r,limit:t});return n.html},_=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),f=(e,t,r,n)=>{const o=((e,t,r)=>{let n={start:0,middle:0,end:e.length};for(;n.start<=n.end;)n.middle=Math.floor((n.start+n.end)/2),t.innerHTML=j(e,n.middle),n=_(n,t.clientHeight,r);return n.middle})(e,t,r);return j(e,o-n.length,n)},y={className:"read-more-content",ellipsis:"…",lessText:Object(o.__)("Read less","woo-gutenberg-products-block"),maxLines:3,moreText:Object(o.__)("Read more","woo-gutenberg-products-block")};class k extends n.Component{constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=Object(n.createRef)(),this.reviewSummary=Object(n.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,n=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:n}),n&&this.setState({summary:f(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:o}=this.props,c=e?r:o;if(c)return Object(n.createElement)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},c)}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:o,isExpanded:c}=this.state;return t?!1===o?Object(n.createElement)("div",{className:e},Object(n.createElement)("div",{ref:this.reviewContent},t)):Object(n.createElement)("div",{className:e},(!c||null===o)&&Object(n.createElement)("div",{ref:this.reviewSummary,"aria-hidden":c,dangerouslySetInnerHTML:{__html:r}}),(c||null===o)&&Object(n.createElement)("div",{ref:this.reviewContent,"aria-hidden":!c},t),this.getButton()):null}}h()(k,"defaultProps",y);var E=k;r(207);var R=e=>{let{attributes:t,review:r={}}=e;const{imageType:c,showReviewDate:a,showReviewerName:s,showReviewImage:i,showReviewRating:l,showReviewContent:d,showProductName:u}=t,{rating:b}=r,m=!(Object.keys(r).length>0),p=Number.isFinite(b)&&l;return Object(n.createElement)("li",{className:w()("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":m,"wc-block-components-review-list-item__item--has-image":i}),"aria-hidden":m},(u||a||s||i||p)&&Object(n.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},i&&function(e,t,r){var c,a;return r||!e?Object(n.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):Object(n.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?Object(n.createElement)("img",{"aria-hidden":"true",alt:(null===(c=e.product_image)||void 0===c?void 0:c.alt)||"",src:(null===(a=e.product_image)||void 0===a?void 0:a.thumbnail)||""}):Object(n.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&Object(n.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:Object(o.__)("Verified buyer","woo-gutenberg-products-block")},Object(o.__)("Verified buyer","woo-gutenberg-products-block")))}(r,c,m),(u||s||p||a)&&Object(n.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},p&&function(e){const{rating:t}=e,r={width:t/5*100+"%"},c=Object(o.sprintf)( +/* translators: %f is referring to the average rating value */ +Object(o.__)("Rated %f out of 5","woo-gutenberg-products-block"),t),a={__html:Object(o.sprintf)( +/* translators: %s is referring to the average rating value */ +Object(o.__)("Rated %s out of 5","woo-gutenberg-products-block"),Object(o.sprintf)('%f',t))};return Object(n.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(n.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(n.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(r),u&&function(e){return Object(n.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(n.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(r),s&&function(e){const{reviewer:t=""}=e;return Object(n.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(r),a&&function(e){const{date_created:t,formatted_date_created:r}=e;return Object(n.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(r))),d&&function(e){return Object(n.createElement)(E,{maxLines:10,moreText:Object(o.__)("Read full review","woo-gutenberg-products-block"),lessText:Object(o.__)("Hide full review","woo-gutenberg-products-block"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(n.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(r))};r(206);var S=e=>{let{attributes:t,reviews:r}=e;const o=Object(i.getSetting)("showAvatars",!0),c=Object(i.getSetting)("reviewRatingsEnabled",!0),a=(o||"product"===t.imageType)&&t.showReviewImage,s=c&&t.showReviewRating,l={...t,showReviewImage:a,showReviewRating:s};return Object(n.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(n.createElement)(R,{attributes:l}):r.map((e,t)=>Object(n.createElement)(R,{key:e.id||t,attributes:l,review:e})))},C=r(6),P=r.n(C),N=r(26),I=r.n(N),x=r(61),L=r(31);class T extends n.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:c,reviews:s,totalReviews:d}=this.props;if(t)return Object(n.createElement)(l.a,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===s.length&&!r)return Object(n.createElement)(c,{attributes:e});const b=Object(i.getSetting)("reviewRatingsEnabled",!0);return Object(n.createElement)(a.Disabled,null,e.showOrderby&&b&&Object(n.createElement)(m,{readOnly:!0,value:e.orderby,onChange:()=>null}),Object(n.createElement)(S,{attributes:e,reviews:s}),e.showLoadMore&&d>s.length&&Object(n.createElement)(u,{screenReaderLabel:Object(o.__)("Load more reviews","woo-gutenberg-products-block")}))}}var A=(e=>{class t extends n.Component{constructor(){super(...arguments),h()(this,"isPreview",!!this.props.attributes.previewReviews),h()(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),h()(this,"isMounted",!1),h()(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),h()(this,"setError",async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Object(L.a)(e);this.setState({reviews:[],loading:!1,error:r}),t(r)})}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay{const e=Object(i.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){"use strict";var r=n(0);t.a=function(e){let{icon:t,size:n=24,...o}=e;return Object(r.cloneElement)(t,{width:n,height:n,...o})}},function(e,t,n){var r=n(8),o=n(57),i=n(58),a=i.setStyleProp,s=i.canTextBeChildOfNode;function c(e){return i.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&i.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,n){for(var i,l,u,d,p,h=(n=n||{}).library||r,f=h.cloneElement,m=h.createElement,g=h.isValidElement,b=[],y="function"==typeof n.replace,w=n.trim,v=0,x=t.length;v2||R(k)>3?"":" "}function D(e,t){for(;--t&&M()&&!(k<48||k>102||k>57&&k<65||k>70&&k<97););return L(e,z()+(t<6&&32==N()&&32==M()))}function V(e,t){for(;M()&&e+k!==57&&(e+k!==84||47!==N()););return"/*"+L(t,E-1)+"*"+d(47===e?e:M())}function B(e){for(;!R(N());)M();return L(e,E)}function $(e,t,n,r,o,i,a,s,l,u,d){for(var p=o-1,g=0===o?i:[""],b=w(g),y=0,O=0,x=0;y