PK
Current Path : /home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/ |
Current File : /home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/product-image-frontend.js |
(globalThis.webpackChunkwebpackWcBlocksFrontendJsonp=globalThis.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[232,442],{1677:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>S});var o=s(1616),a=s(6087),n=s(7723),l=s(4921),r=s(5703),c=s(2796),i=s(41),d=s(1509),u=s(8537),g=s(3993),p=s(3848);s(1189);let m=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});var h=s(790);const y=e=>(0,h.jsx)("img",{...e,src:r.PLACEHOLDER_IMG_SRC,alt:e.alt,width:void 0,height:void 0}),f=({image:e,loaded:t,showFullSize:s,fallbackAlt:o,width:a,scale:n,height:l,aspectRatio:r})=>{const{thumbnail:c,src:i,srcset:d,sizes:u,alt:g}=e||{},p={alt:g||o,hidden:!t,src:c,...s&&{src:i,srcSet:d,sizes:u}},m={height:l,width:a,objectFit:n,aspectRatio:r};return(0,h.jsxs)(h.Fragment,{children:[p.src&&(0,h.jsx)("img",{style:m,"data-testid":"product-image",...p}),!e&&(0,h.jsx)(y,{style:m,alt:p.alt})]})},b=(0,o.withProductDataContext)((e=>{const{className:t,imageSizing:s=m.SINGLE,showProductLink:o=!0,showSaleBadge:r,saleBadgeAlign:b="right",height:k,width:S,scale:w,aspectRatio:x,style:N,...j}=e,C=(0,i.p)(e),{parentClassName:v}=(0,c.useInnerBlockLayoutContext)(),{product:L,isLoading:_}=(0,c.useProductDataContext)(),{dispatchStoreEvent:A}=(0,d.y)();if(!L.id)return(0,h.jsx)("div",{className:(0,l.A)(t,"wc-block-components-product-image",{[`${v}__product-image`]:v},C.className),style:C.style,children:(0,h.jsx)(y,{})});const B=!!L.images.length,F=B?L.images[0]:null,P=o?"a":a.Fragment,R=(0,n.sprintf)(/* translators: %s is referring to the product name */ /* translators: %s is referring to the product name */ (0,n.__)("Link to %s","woocommerce"),L.name),z={href:L.permalink,...!B&&{"aria-label":R},onClick:()=>{A("product-view-link",{product:L})}};return(0,h.jsx)("div",{className:(0,l.A)(t,"wc-block-components-product-image",{[`${v}__product-image`]:v},C.className),style:C.style,children:(0,h.jsxs)(P,{...o&&z,children:[!!r&&(0,h.jsx)(p.default,{align:b,...j}),(0,h.jsx)(f,{fallbackAlt:(0,u.decodeEntities)(L.name),image:F,loaded:!_,showFullSize:s!==m.THUMBNAIL,width:S,height:k,scale:w,aspectRatio:(0,g.objectHasProp)(N,"dimensions")&&(0,g.objectHasProp)(N.dimensions,"aspectRatio")&&(0,g.isString)(N.dimensions.aspectRatio)?N.dimensions.aspectRatio:x})]})})})),k=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"}}}'),S=(0,o.withFilteredAttributes)(k.uK)(b)},3848:(e,t,s)=>{"use strict";s.r(t),s.d(t,{Block:()=>d,default:()=>u});var o=s(7723),a=s(4921),n=s(4656),l=s(2796),r=s(41),c=s(1616),i=(s(4313),s(790));const d=e=>{const{className:t,align:s}=e,c=(0,r.p)(e),{parentClassName:d}=(0,l.useInnerBlockLayoutContext)(),{product:u}=(0,l.useProductDataContext)();if(!(u.id&&u.on_sale||e.isDescendentOfSingleProductTemplate))return null;const g="string"==typeof s?`wc-block-components-product-sale-badge--align-${s}`:"";return(0,i.jsx)("div",{className:(0,a.A)("wc-block-components-product-sale-badge",t,g,{[`${d}__product-onsale`]:d},c.className),style:c.style,children:(0,i.jsx)(n.Label,{label:(0,o.__)("Sale","woocommerce"),screenReaderLabel:(0,o.__)("Product on sale","woocommerce")})})},u=(0,c.withProductDataContext)(d)},41:(e,t,s)=>{"use strict";s.d(t,{p:()=>i});var o=s(4921),a=s(3993),n=s(7356),l=s(9786);function r(e={}){const t={};return(0,l.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 s=t.style;return(0,a.isString)(s)&&(s=JSON.parse(s)||{}),(0,a.isObject)(s)||(s={}),{...t,style:s}})(e),s=function(e){const{backgroundColor:t,textColor:s,gradient:n,style:l}=e,i=c("background-color",t),d=c("color",s),u=function(e){if(e)return`has-${e}-gradient-background`}(n),g=u||l?.color?.gradient;return{className:(0,o.A)(d,u,{[i]:!g&&!!i,"has-text-color":s||l?.color?.text,"has-background":t||l?.color?.background||n||l?.color?.gradient,"has-link-color":(0,a.isObject)(l?.elements?.link)?l?.elements?.link?.color:void 0}),style:r({color:l?.color||{}})}}(t),n=function(e){const t=e.style?.border||{};return{className:function(e){const{borderColor:t,style:s}=e,a=t?c("border-color",t):"";return(0,o.A)({"has-border-color":!!t||!!s?.border?.color,[a]:!!a})}(e),style:r({border:t})}}(t),l=function(e){return{className:void 0,style:r({spacing:e.style?.spacing||{}})}}(t),i=(e=>{const t=(0,a.isObject)(e.style.typography)?e.style.typography:{},s=(0,a.isString)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:s,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,s.className,n.className,l.className),style:{...i.style,...s.style,...n.style,...l.style}}}},1189:()=>{},4313:()=>{}}]);