????
Current Path : /home/webcloude/www/wp-content/plugins/woocommerce/assets/client/blocks/ |
Current File : /home/webcloude/www/wp-content/plugins/woocommerce/assets/client/blocks/product-image-frontend.js |
(self.webpackChunkwebpackWcBlocksFrontendJsonp=self.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[232,442],{1351:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>v});var o=l(1616),a=l(1609),n=l(6087),s=l(7723),r=l(851),c=l(5703),i=l(2796),d=l(4487),u=l(7277),m=l(8537),g=l(3905);l(5183);let p=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});const y=e=>(0,a.createElement)("img",{...e,src:c.PLACEHOLDER_IMG_SRC,alt:e.alt,width:void 0,height:void 0}),f=({image:e,loaded:t,showFullSize:l,fallbackAlt:o,width:s,scale:r,height:c,aspectRatio:i})=>{const{thumbnail:d,src:u,srcset:m,sizes:g,alt:p}=e||{},f={alt:p||o,hidden:!t,src:d,...l&&{src:u,srcSet:m,sizes:g}},h={height:c,width:s,objectFit:r,aspectRatio:i};return(0,a.createElement)(n.Fragment,null,f.src&&(0,a.createElement)("img",{style:h,"data-testid":"product-image",...f}),!e&&(0,a.createElement)(y,{style:h,alt:f.alt}))},h=(0,o.withProductDataContext)((e=>{const{className:t,imageSizing:l=p.SINGLE,showProductLink:o=!0,showSaleBadge:c,saleBadgeAlign:h="right",height:b,width:v,scale:k,aspectRatio:w,...S}=e,N=(0,d.p)(e),{parentClassName:E}=(0,i.useInnerBlockLayoutContext)(),{product:C,isLoading:L}=(0,i.useProductDataContext)(),{dispatchStoreEvent:_}=(0,u.y)();if(!C.id)return(0,a.createElement)("div",{className:(0,r.A)(t,"wc-block-components-product-image",{[`${E}__product-image`]:E},N.className),style:N.style},(0,a.createElement)(y,null));const A=!!C.images.length,x=A?C.images[0]:null,B=o?"a":n.Fragment,F=(0,s.sprintf)(/* translators: %s is referring to the product name */ /* translators: %s is referring to the product name */ (0,s.__)("Link to %s","woocommerce"),C.name),z={href:C.permalink,...!A&&{"aria-label":F},onClick:()=>{_("product-view-link",{product:C})}};return delete S.style,(0,a.createElement)("div",{className:(0,r.A)(t,"wc-block-components-product-image",{[`${E}__product-image`]:E},N.className),style:N.style},(0,a.createElement)(B,{...o&&z},!!c&&(0,a.createElement)(g.default,{align:h,...S}),(0,a.createElement)(f,{fallbackAlt:(0,m.decodeEntities)(C.name),image:x,loaded:!L,showFullSize:l!==p.THUMBNAIL,width:v,height:b,scale:k,aspectRatio:w})))})),b=JSON.parse('{"uK":{"showProductLink":{"type":"boolean","default":true},"showSaleBadge":{"type":"boolean","default":true},"saleBadgeAlign":{"type":"string","default":"right"},"imageSizing":{"type":"string","default":"single"},"productId":{"type":"number","default":0},"isDescendentOfQueryLoop":{"type":"boolean","default":false},"isDescendentOfSingleProductBlock":{"type":"boolean","default":false},"width":{"type":"string"},"height":{"type":"string"},"scale":{"type":"string","default":"cover"},"aspectRatio":{"type":"string"}}}'),v=(0,o.withFilteredAttributes)(b.uK)(h)},3905:(e,t,l)=>{"use strict";l.r(t),l.d(t,{Block:()=>d,default:()=>u});var o=l(1609),a=l(7723),n=l(851),s=l(4656),r=l(2796),c=l(4487),i=l(1616);l(6007);const d=e=>{const{className:t,align:l}=e,i=(0,c.p)(e),{parentClassName:d}=(0,r.useInnerBlockLayoutContext)(),{product:u}=(0,r.useProductDataContext)();if(!(u.id&&u.on_sale||e.isDescendentOfSingleProductTemplate))return null;const m="string"==typeof l?`wc-block-components-product-sale-badge--align-${l}`:"";return(0,o.createElement)("div",{className:(0,n.A)("wc-block-components-product-sale-badge",t,m,{[`${d}__product-onsale`]:d},i.className),style:i.style},(0,o.createElement)(s.Label,{label:(0,a.__)("Sale","woocommerce"),screenReaderLabel:(0,a.__)("Product on sale","woocommerce")}))},u=(0,i.withProductDataContext)(d)},4487:(e,t,l)=>{"use strict";l.d(t,{p:()=>i});var o=l(851),a=l(3993),n=l(1194),s=l(9786);function r(e={}){const t={};return(0,s.getCSSRules)(e,{selector:""}).forEach((e=>{t[e.key]=e.value})),t}function c(e,t){return e&&t?`has-${(0,n.c)(t)}-${e}`:""}const i=e=>{const t=(e=>{const t=(0,a.isObject)(e)?e:{style:{}};let l=t.style;return(0,a.isString)(l)&&(l=JSON.parse(l)||{}),(0,a.isObject)(l)||(l={}),{...t,style:l}})(e),l=function(e){var t,l,n,s,i,d,u;const{backgroundColor:m,textColor:g,gradient:p,style:y}=e,f=c("background-color",m),h=c("color",g),b=function(e){if(e)return`has-${e}-gradient-background`}(p),v=b||(null==y||null===(t=y.color)||void 0===t?void 0:t.gradient);return{className:(0,o.A)(h,b,{[f]:!v&&!!f,"has-text-color":g||(null==y||null===(l=y.color)||void 0===l?void 0:l.text),"has-background":m||(null==y||null===(n=y.color)||void 0===n?void 0:n.background)||p||(null==y||null===(s=y.color)||void 0===s?void 0:s.gradient),"has-link-color":(0,a.isObject)(null==y||null===(i=y.elements)||void 0===i?void 0:i.link)?null==y||null===(d=y.elements)||void 0===d||null===(u=d.link)||void 0===u?void 0:u.color:void 0}),style:r({color:(null==y?void 0:y.color)||{}})}}(t),n=function(e){var t;const l=(null===(t=e.style)||void 0===t?void 0:t.border)||{};return{className:function(e){var t;const{borderColor:l,style:a}=e,n=l?c("border-color",l):"";return(0,o.A)({"has-border-color":!!l||!(null==a||null===(t=a.border)||void 0===t||!t.color),[n]:!!n})}(e),style:r({border:l})}}(t),s=function(e){var t;return{className:void 0,style:r({spacing:(null===(t=e.style)||void 0===t?void 0:t.spacing)||{}})}}(t),i=(e=>{const t=(0,a.isObject)(e.style.typography)?e.style.typography:{},l=(0,a.isString)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:l,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,textDecoration:t.textDecoration,textTransform:t.textTransform}}})(t);return{className:(0,o.A)(i.className,l.className,n.className,s.className),style:{...i.style,...l.style,...n.style,...s.style}}}},5183:()=>{},6007:()=>{}}]);