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-stock-indicator.js |
(globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[]).push([[345],{6374:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Block:()=>d,default:()=>p});var s=r(7723),o=r(4921),c=r(415),n=r(371),i=r(1616),l=r(5703),a=r(2281),u=(r(3790),r(790));const d=t=>{const{className:e}=t,r=(0,n.p)(t),{parentClassName:i}=(0,c.useInnerBlockLayoutContext)(),{product:d}=(0,c.useProductDataContext)(),{text:p,class:y}=d.stock_availability,{current:g}=(0,a.A)();if(!((t,e,r)=>{if(0!==t.id)return""!==e;const s=(0,l.getSetting)("productTypesWithoutStockIndicator",["external","grouped","variable"]),o=r||t?.type;return!s.includes(o)})(d,p,g?.slug))return null;const f=0===d.id,k=d.low_stock_remaining;return(0,u.jsx)("div",{className:(0,o.A)(e,{[`${i}__stock-indicator`]:i,[`wc-block-components-product-stock-indicator--${y}`]:y,"wc-block-components-product-stock-indicator--in-stock":f,"wc-block-components-product-stock-indicator--low-stock":!!k,...t.isDescendantOfAllProducts&&{[r.className]:r.className,"wc-block-components-product-stock-indicator wp-block-woocommerce-product-stock-indicator":!0}}),...t.isDescendantOfAllProducts&&{style:r.style},children:f?(0,s.__)("In stock","woocommerce"):p})},p=t=>{const{product:e}=(0,c.useProductDataContext)();return 0===e.id?(0,u.jsx)(d,{...t}):(0,i.withProductDataContext)(d)(t)}},371:(t,e,r)=>{"use strict";r.d(e,{p:()=>i});var s=r(4921),o=r(3993),c=r(219),n=r(17);const i=t=>{const e=(t=>{const e=(0,o.isObject)(t)?t:{style:{}};let r=e.style;return(0,o.isString)(r)&&(r=JSON.parse(r)||{}),(0,o.isObject)(r)||(r={}),{...e,style:r}})(t),r=(0,n.BK)(e),i=(0,n.aR)(e),l=(0,n.fo)(e),a=(0,c.x)(e);return{className:(0,s.A)(a.className,r.className,i.className,l.className),style:{...a.style,...r.style,...i.style,...l.style}}}},219:(t,e,r)=>{"use strict";r.d(e,{x:()=>o});var s=r(3993);const o=t=>{const e=(0,s.isObject)(t.style.typography)?t.style.typography:{},r=(0,s.isString)(e.fontFamily)?e.fontFamily:"";return{className:t.fontFamily?`has-${t.fontFamily}-font-family`:r,style:{fontSize:t.fontSize?`var(--wp--preset--font-size--${t.fontSize})`:e.fontSize,fontStyle:e.fontStyle,fontWeight:e.fontWeight,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,textDecoration:e.textDecoration,textTransform:e.textTransform}}}},17:(t,e,r)=>{"use strict";r.d(e,{BK:()=>a,aR:()=>u,fo:()=>d});var s=r(4921),o=r(7356),c=r(9786),n=r(3993);function i(t={}){const e={};return(0,c.getCSSRules)(t,{selector:""}).forEach((t=>{e[t.key]=t.value})),e}function l(t,e){return t&&e?`has-${(0,o.c)(e)}-${t}`:""}function a(t){const{backgroundColor:e,textColor:r,gradient:o,style:c}=t,a=l("background-color",e),u=l("color",r),d=function(t){if(t)return`has-${t}-gradient-background`}(o),p=d||c?.color?.gradient;return{className:(0,s.A)(u,d,{[a]:!p&&!!a,"has-text-color":r||c?.color?.text,"has-background":e||c?.color?.background||o||c?.color?.gradient,"has-link-color":(0,n.isObject)(c?.elements?.link)?c?.elements?.link?.color:void 0}),style:i({color:c?.color||{}})}}function u(t){const e=t.style?.border||{};return{className:function(t){const{borderColor:e,style:r}=t,o=e?l("border-color",e):"";return(0,s.A)({"has-border-color":!!e||!!r?.border?.color,[o]:!!o})}(t),style:i({border:e})}}function d(t){return{className:void 0,style:i({spacing:t.style?.spacing||{}})}}},2266:(t,e,r)=>{"use strict";r.d(e,{EF:()=>s,Ie:()=>n,UI:()=>c,ht:()=>i,j9:()=>o});const s="woocommerce/product-type-template-state",o="SWITCH_PRODUCT_TYPE",c="SET_PRODUCT_TYPES",n="REGISTER_LISTENER",i="UNREGISTER_LISTENER"},8207:(t,e,r)=>{"use strict";r.d(e,{M:()=>l});var s=r(7143),o=r(2266);const c=(0,r(7254).c)(),n={productTypes:{list:c,current:c[0]?.slug},listeners:[]},i={switchProductType:t=>({type:o.j9,current:t}),setProductTypes:t=>({type:o.UI,productTypes:t}),registerListener:t=>({type:o.Ie,listener:t}),unregisterListener:t=>({type:o.ht,listener:t})},l=(0,s.createReduxStore)(o.EF,{reducer:(t=n,e)=>{switch(e.type){case o.UI:return{...t,productTypes:{...t.productTypes,list:e.productTypes||[]}};case o.j9:return{...t,productTypes:{...t.productTypes,current:e.current}};case o.Ie:return{...t,listeners:[...t.listeners,e.listener||""]};case o.ht:return{...t,listeners:t.listeners.filter((t=>t!==e.listener))};default:return t}},actions:i,selectors:{getProductTypes:t=>t.productTypes.list,getCurrentProductType:t=>t.productTypes.list.find((e=>e.slug===t.productTypes.current)),getRegisteredListeners:t=>t.listeners}});(0,s.select)(o.EF)||(0,s.register)(l)},2281:(t,e,r)=>{"use strict";r.d(e,{A:()=>c});var s=r(7143),o=r(8207);function c(){const{productTypes:t,current:e,registeredListeners:r}=(0,s.useSelect)((t=>{const{getProductTypes:e,getCurrentProductType:r,getRegisteredListeners:s}=t(o.M);return{productTypes:e(),current:r(),registeredListeners:s()}}),[]),{switchProductType:c,registerListener:n,unregisterListener:i}=(0,s.useDispatch)(o.M);return{productTypes:t,current:e,set:c,registeredListeners:r,registerListener:n,unregisterListener:i}}},7254:(t,e,r)=>{"use strict";r.d(e,{c:()=>o});const s=(0,r(5703).getSetting)("productTypes",{});function o(){return Object.keys(s).map((t=>({slug:t,label:s[t]})))}},3790:()=>{}}]);