(()=>{"use strict";var e={20:(e,s,t)=>{var n=t(609),i=Symbol.for("react.element"),o=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(e,s,t){var n,o={},l=null,p=null;for(n in void 0!==t&&(l=""+t),void 0!==s.key&&(l=""+s.key),void 0!==s.ref&&(p=s.ref),s)r.call(s,n)&&!a.hasOwnProperty(n)&&(o[n]=s[n]);if(e&&e.defaultProps)for(n in s=e.defaultProps)void 0===o[n]&&(o[n]=s[n]);return{$$typeof:i,type:e,key:l,ref:p,props:o,_owner:c.current}}s.Fragment=o,s.jsx=l,s.jsxs=l},609:e=>{e.exports=window.React},848:(e,s,t)=>{e.exports=t(20)}},s={};function t(n){var i=s[n];if(void 0!==i)return i.exports;var o=s[n]={exports:{}};return e[n](o,o.exports,t),o.exports}const n=window.wp.plugins,i=window.wc.blocksCheckout,o=window.wp.i18n,r=window.wc.blocksComponents,c=window.wc.priceFormat,a=window.wc.wcSettings,l=window.wp.data,p=window.wp.element,u=window.wc.wcBlocksData;function d(e){return{day:(0,o._nx)("day","days",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),week:(0,o._nx)("week","weeks",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),month:(0,o._nx)("month","months",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),year:(0,o._nx)("year","years",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions")}}function g({billing_interval:e,billing_period:s},t,n){const i=d(e)[s];return t=t.trim(),1===e?`${n} ${t} ${i}`:(0,o.sprintf)(
/*
       * translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
       * %3$d is the billing interval, %4$s is the period e.g. week, month, year.
       * The non-breaking space (\u00a0) between %1$s and %2$s ensures visible spacing
       * when rendered inside a CSS flex container. Please preserve it.
       */
/*
       * translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
       * %3$d is the billing interval, %4$s is the period e.g. week, month, year.
       * The non-breaking space (\u00a0) between %1$s and %2$s ensures visible spacing
       * when rendered inside a CSS flex container. Please preserve it.
       */
(0,o.__)("%1$s %2$s %3$d %4$s","woocommerce-subscriptions"),n,t,e,i)}function m({subscriptionLength:e,billingInterval:s}){return e===s}const _=(0,a.getSetting)("countryData",{}),h=(0,a.getSetting)("countries",{}),b={...Object.fromEntries(Object.keys(_).filter(e=>!0===_[e].allowBilling).map(e=>[e,h[e]||""])),...Object.fromEntries(Object.keys(_).filter(e=>!0===_[e].allowShipping).map(e=>[e,h[e]||""]))},w=Object.fromEntries(Object.keys(b).map(e=>[e,_[e].locale||{}])),f={address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]},v=Object.entries(w).reduce((e,[s,t])=>(e[s]=Object.entries(t).reduce((e,[s,t])=>(e[s]=(e=>{const s={};return void 0!==e.label&&(s.label=e.label),void 0!==e.required&&(s.required=e.required),void 0!==e.hidden&&(s.hidden=e.hidden),void 0===e.label||e.optionalLabel||(s.optionalLabel=(0,o.sprintf)(/* translators: %s Field label. */ /* translators: %s Field label. */
(0,o.__)("%s (optional)","woocommerce-subscriptions"),e.label)),void 0!==e.optionalLabel&&(s.optionalLabel=e.optionalLabel),e.index&&("number"==typeof e.index&&(s.index=e.index),"string"==typeof e.index&&(s.index=parseInt(e.index,10))),e.hidden&&(s.required=!1),s})(t),e),{}),e),{}),y=["state","country","postcode","city"],x=e=>e.some(e=>!!e.shipping_rates.length),k=(0,a.getSetting)("collectableMethodIds",[]),j=(0,a.getSetting)("localPickupEnabled",!1);var S=t(848);const L=(0,a.getSetting)("displayCartPricesIncludingTax",!1),I=({coupons:e})=>{const{removeCoupon:s}=(0,l.useDispatch)("wc/store/cart"),t=(0,l.useSelect)(e=>e("wc/store/cart").isRemovingCoupon(),[]),n=(0,p.useRef)(null),i=(0,p.useRef)(null);return(0,p.useEffect)(()=>{var e;const s=i.current;if(null===s)return;i.current=null;const t=n.current,o=t?.ownerDocument?.activeElement;if(o&&o!==t?.ownerDocument?.body&&!t?.contains(o))return;const r=Array.from(null!==(e=t?.querySelectorAll(".wc-block-components-chip__remove"))&&void 0!==e?e:[]).find(e=>e.closest("[data-coupon-code]")?.dataset.couponCode===s);r&&r.focus()},[e]),e&&0!==e.length?(0,S.jsxs)("div",{className:t?"wc-block-components-loading-mask":void 0,children:[(0,S.jsx)("div",{className:t?"wc-block-components-loading-mask__children":void 0,"aria-hidden":t,children:(0,S.jsx)("ul",{ref:n,className:"wc-block-components-totals-discount__coupon-list",children:e.map((n,c)=>(0,S.jsx)(r.RemovableChip,{element:"li",radius:"large",text:n.code,className:"wc-block-components-totals-discount__coupon-list-item","data-coupon-code":n.code,disabled:t,ariaLabel:(0,o.sprintf)(/* translators: %s is a coupon code. */ /* translators: %s is a coupon code. */
(0,o.__)('Remove coupon "%s"',"woocommerce-subscriptions"),n.code),onRemove:()=>{var t,o;const r=null!==(t=e[c+1])&&void 0!==t?t:e[c-1];i.current=null!==(o=r?.code)&&void 0!==o?o:null,s(n.code)}},n.code))})}),t&&(0,S.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Removing coupon…","woocommerce-subscriptions")})]}):null},P=({currency:e,values:s,isLoading:t})=>{const{total_discount:n,total_discount_tax:r}=s,c=parseInt(n,10);if(!c)return null;const a=parseInt(r,10),l=L?c+a:c;return(0,S.jsx)(i.TotalsItem,{className:"wc-block-components-totals-discount",currency:e,label:(0,o.__)("Discount","woocommerce-subscriptions"),value:-1*l,showSkeleton:t})},C=({values:e,currency:s,shippingRatePackages:t,isLoading:n,calculatedShipping:i,shippingAddress:r})=>{const c=(0,l.useSelect)(e=>e(u.checkoutStore).prefersCollection());if(!i)return null;const p=(m=((e,s)=>e.map(e=>({...e,shipping_rates:e.shipping_rates.filter(e=>{const t=(n=e.method_id,!!j&&(Array.isArray(n)?!!n.find(e=>k.includes(e)):k.includes(n)));var n;return s?t:!t})})))(t,null!=c&&c),!!x(m)&&m.every(e=>e.shipping_rates.every(e=>!e.selected||(e=>k.includes(e.method_id))(e)))),d=!!(g=r).country&&((e,s,t="")=>{const n=t&&void 0!==v[t]?v[t]:{};return e.map(e=>({key:e,...s&&e in s?s[e]:{},...n&&e in n?n[e]:{}})).sort((e,s)=>e.index-s.index)})((0,a.getSetting)("addressFieldsLocations",f).address,a.defaultFields,g.country).filter(({key:e})=>y.includes(e)).every(({key:e,hidden:s,required:t})=>!0===s||!1===t||e in g&&""!==g[e]);var g,m;return(0,S.jsx)(R,{label:p?(0,o.__)("Pickup","woocommerce-subscriptions"):(0,o.__)("Delivery","woocommerce-subscriptions"),placeholder:(0,S.jsx)("span",{className:"wc-block-components-shipping-placeholder__value",children:d?(0,o.__)("No available delivery option","woocommerce-subscriptions"):(0,o.__)("Enter address to calculate","woocommerce-subscriptions")}),isLoading:n,shippingRatePackages:t,currency:s,values:e})},R=({values:e,currency:s,shippingRatePackages:t,label:n,placeholder:r,isLoading:c})=>{const l=t?.flatMap(e=>e.shipping_rates).find(({selected:e})=>e)?.name,p=!!x(u=t)&&u.some(e=>e.shipping_rates.some(e=>e.selected));var u;const d=!p||t?.length>1?n:(0,o.__)("Shipping","woocommerce-subscriptions"),g=L?parseInt(e.total_shipping,10)+parseInt(e.total_shipping_tax,10):parseInt(e.total_shipping,10),m=0===g&&(0,a.isWcVersion)("9.0",">=")?(0,S.jsx)("strong",{children:(0,o.__)("Free","woocommerce-subscriptions")}):g;return(0,S.jsx)(i.TotalsItem,{value:p?m:r,label:d,currency:s,showSkeleton:c,description:!!l&&(0,o.sprintf)(
// translators: %s selected shipping rate (ex: flat rate)
// translators: %s selected shipping rate (ex: flat rate)
(0,o.__)("via %s","woocommerce-subscriptions"),l)})},O=({nextPaymentDate:e,subscriptionLength:s,billingPeriod:t,billingInterval:n})=>{const i=function({subscriptionLength:e,billingPeriod:s}){const t=d(e);return(0,o.sprintf)(
/*
   * Translators: %1$s is the number of intervals after which the subscription will stop.
   * %2$s is the interval unit (days, months etc).
   */
/*
   * Translators: %1$s is the number of intervals after which the subscription will stop.
   * %2$s is the interval unit (days, months etc).
   */
(0,o.__)("For %1$d %2$s","woocommerce-subscriptions"),e,t[s],"woocommerce-subscriptions")}({subscriptionLength:s,billingPeriod:t}),r=m({subscriptionLength:s,billingInterval:n})?(0,o.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
(0,o.__)("Due: %1$s","woocommerce-subscriptions"),e):(0,o.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
(0,o.__)("Starting: %1$s","woocommerce-subscriptions"),e);return(0,S.jsxs)("span",{children:[!!e&&r," ",!!s&&s>=n&&(0,S.jsx)("span",{className:"wcs-recurring-totals__subscription-length",children:i})]})},D=({currency:e,billingInterval:s,billingPeriod:t,nextPaymentDate:n,subscriptionLength:r,totals:c,isLoading:a})=>{const l=m({billingInterval:s,subscriptionLength:r})?(0,o.__)("Total","woocommerce-subscriptions"):function({billingInterval:e,billingPeriod:s}){if(1!==e){const t=d(e)[s];return(0,o.sprintf)(/* translators: %1$d is the billing interval (e.g. 2, 3), %2$s is the translated period (e.g. months, weeks) */ /* translators: %1$d is the billing interval (e.g. 2, 3), %2$s is the translated period (e.g. months, weeks) */
(0,o.__)("Recurring total every %1$d %2$s","woocommerce-subscriptions"),e,t)}return"day"===s?(0,o.__)("Daily recurring total","woocommerce-subscriptions"):"week"===s?(0,o.__)("Weekly recurring total","woocommerce-subscriptions"):"month"===s?(0,o.__)("Monthly recurring total","woocommerce-subscriptions"):"year"===s?(0,o.__)("Yearly recurring total","woocommerce-subscriptions"):void 0}({billingInterval:s,billingPeriod:t});return(0,S.jsx)(i.TotalsItem,{className:"wcs-recurring-totals-panel__title",currency:e,label:l,value:c,showSkeleton:a,description:(0,S.jsx)(O,{nextPaymentDate:n,subscriptionLength:r,billingInterval:s,billingPeriod:t})})},N=({subscription:e,needsShipping:s,calculatedShipping:t,shippingAddress:n})=>{const{isLoading:r}=(()=>{const{cartIsLoading:e,isLoadingRates:s,hasPendingItemsOperations:t,isApplyingCoupon:n,isRemovingCoupon:i}=(0,l.useSelect)(e=>{const s=e(u.cartStore);return{cartIsLoading:!s.hasFinishedResolution("getCartData",[]),isLoadingRates:s.isAddressFieldsForShippingRatesUpdating(),hasPendingItemsOperations:s.hasPendingItemsOperations(),isApplyingCoupon:s.isApplyingCoupon(),isRemovingCoupon:s.isRemovingCoupon()}},[]),o=(0,l.useSelect)(e=>e(u.checkoutStore).isCalculating(),[]);return{isLoading:e||s||n||i||o||t}})(),{totals:p,coupons:d,billing_interval:g,billing_period:m,next_payment_date:_,subscription_length:h,shipping_rates:b}=e;if(!_)return null;const w=e?.shipping_rates?.some(e=>e.needs_shipping),f=(0,c.getCurrencyFromPriceResponse)(p);return(0,S.jsxs)("div",{className:"wcs-recurring-totals-panel",children:[(0,S.jsx)(D,{billingInterval:g,billingPeriod:m,nextPaymentDate:_,subscriptionLength:h,totals:parseInt(p.total_price,10),currency:f,isLoading:r}),(0,S.jsxs)(i.Panel,{className:(0,a.isWcVersion)("10.6",">=")?"wcs-recurring-totals-panel__details wcs-recurring-totals-panel__details--x-small-font":"wcs-recurring-totals-panel__details",initialOpen:!1,title:(0,o.__)("Details","woocommerce-subscriptions"),children:[(0,S.jsxs)(i.TotalsWrapper,{children:[(0,S.jsx)(i.Subtotal,{currency:f,values:p,showSkeleton:r}),(0,S.jsx)(P,{currency:f,values:p,isLoading:r}),(0,S.jsx)(I,{coupons:d})]}),s&&w&&(0,S.jsx)(i.TotalsWrapper,{className:"wc-block-components-totals-shipping",children:(0,S.jsx)(C,{currency:f,calculatedShipping:t,values:p,shippingAddress:n,shippingRatePackages:b,isLoading:r})}),!L&&(0,S.jsx)(i.TotalsWrapper,{children:(0,S.jsx)(i.TotalsTaxes,{currency:f,values:p})}),(0,S.jsx)(i.TotalsWrapper,{children:(0,S.jsx)(i.TotalsItem,{className:"wcs-recurring-totals-panel__details-total",currency:f,label:(0,o.__)("Total","woocommerce-subscriptions"),value:parseInt(p.total_price,10),showSkeleton:r})})]})]})},A=({extensions:e,cart:s})=>{const{subscriptions:t}=e,{cartNeedsShipping:n,cartHasCalculatedShipping:i,shippingAddress:o}=s;return t&&0!==t.length?t.map(({key:e,...s})=>(0,S.jsx)(N,{subscription:s,needsShipping:n,calculatedShipping:i,shippingAddress:o},e)):null},E=(0,a.getSetting)("collectableMethodIds",[]),T=({extensions:e,collapsible:s,collapse:t,showItems:n,noResultsMessage:i,renderOption:o,components:r,context:c})=>{const{subscriptions:a=[]}=e,{ShippingRatesControlPackage:l}=r,u=(0,p.useMemo)(()=>Object.values(a).map(e=>e.shipping_rates).filter(Boolean).flat(),[a]),d=(0,p.useMemo)(()=>u.length>1||t,[u.length,t]),g=(0,p.useMemo)(()=>u.length>1||n,[u.length,n]);return u.filter(e=>!e.match_initial_rates&&e.needs_shipping).map(({package_id:e,...t})=>(t.shipping_rates=t.shipping_rates.filter(e=>!E.includes(e.method_id)),(0,S.jsx)(l,{packageId:e,packageData:t,collapsible:s,collapse:d,showItems:g,noResultsMessage:i,renderOption:o,highlightChecked:"woocommerce/checkout"===c},e)))};var $=t(609);const F=(0,a.getSetting)("collectableMethodIds",[]),M=({packageId:e,packageData:s,showItems:t,renderPickupLocation:n,pickupLocations:i,packageCount:o,LocalPickupSelect:r})=>{var c;const{selectShippingRate:a}=(0,l.useDispatch)(u.cartStore),[d,g]=(0,$.useState)(null!==(c=s.shipping_rates.find(e=>e.selected)?.rate_id)&&void 0!==c?c:s.shipping_rates[0]?.rate_id);return(0,p.useEffect)(()=>{d&&a(d,e)},[]),(0,S.jsx)(r,{title:s.name,packageData:s,selectedOption:null!=d?d:"",showItems:t,renderPickupLocation:n,pickupLocations:i,packageCount:o,onChange:s=>{g(s),a(s,e)}})},U=({extensions:e,showItems:s,renderPickupLocation:t,components:n})=>{const{subscriptions:i=[]}=e,{LocalPickupSelect:o}=n,r=(0,p.useMemo)(()=>Object.values(i).map(e=>e.shipping_rates).filter(Boolean).flat(),[i]),c=(0,p.useMemo)(()=>r.length>1||s,[r.length,s]);return r.filter(e=>!e.match_initial_rates&&e.needs_shipping).map(({package_id:e,...s})=>(s.shipping_rates=s.shipping_rates.filter(e=>F.includes(e.method_id)),(0,S.jsx)(M,{packageId:e,packageData:s,showItems:c,renderPickupLocation:t,pickupLocations:s.shipping_rates,packageCount:r.length,LocalPickupSelect:o},e)))};(0,n.registerPlugin)("woocommerce-subscriptions",{render:()=>(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.ExperimentalOrderShippingPackages,{children:(0,S.jsx)(T,{})}),(0,S.jsx)(i.ExperimentalOrderLocalPickupPackages,{children:(0,S.jsx)(U,{})}),(0,S.jsx)(i.ExperimentalOrderMeta,{children:(0,S.jsx)(A,{})})]}),scope:"woocommerce-checkout"}),(0,i.registerCheckoutFilters)("woocommerce-subscriptions",{totalLabel:(e,{subscriptions:s})=>s?.length>0?(0,o.__)("Total due today","woocommerce-subscriptions"):e,subtotalPriceFormat:(e,{subscriptions:s})=>{if(s?.billing_period&&s?.billing_interval){const{billing_interval:t,subscription_length:n}=s;return m({subscriptionLength:n,billingInterval:t})?g(s,1===n?
// translators: the word used to describe billing frequency, e.g. "for" 1 day or "for" 1 month.
// translators: the word used to describe billing frequency, e.g. "for" 1 day or "for" 1 month.
(0,o.__)("for 1","woocommerce-subscriptions"):
// translators: the word used to describe billing frequency, e.g. "for" 6 days or "for" 2 weeks.
// translators: the word used to describe billing frequency, e.g. "for" 6 days or "for" 2 weeks.
(0,o.__)("for","woocommerce-subscriptions"),e):g(s,
// translators: the word used to describe billing frequency, e.g. "every" 6 days or "every" 2 weeks.
// translators: the word used to describe billing frequency, e.g. "every" 6 days or "every" 2 weeks.
(0,o.__)("every","woocommerce-subscriptions"),e)}return e},saleBadgePriceFormat:(e,{subscriptions:s})=>s?.billing_period&&s?.billing_interval?g(s,"/",e):e,itemName:(e,{subscriptions:s})=>s?.is_resubscribe?(0,o.sprintf)(
// translators: %s Product name.
// translators: %s Product name.
(0,o.__)("%s (resubscription)","woocommerce-subscriptions"),e):s?.switch_type?(0,o.sprintf)(
// translators: %1$s Product name, %2$s Switch type (upgraded, downgraded, or crossgraded).
// translators: %1$s Product name, %2$s Switch type (upgraded, downgraded, or crossgraded).
(0,o.__)("%1$s (%2$s)","woocommerce-subscriptions"),e,function(e){switch(e){case"upgraded":return(0,o.__)("Upgrade","woocommerce-subscriptions");case"downgraded":return(0,o.__)("Downgrade","woocommerce-subscriptions");case"crossgraded":return(0,o.__)("Crossgrade","woocommerce-subscriptions");default:return""}}(s.switch_type)):e,cartItemPrice:(e,{subscriptions:s},{context:t})=>s?.sign_up_fees&&parseInt(s.sign_up_fees,10)>0?"cart"===t?(0,o.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
(0,o.__)("Due today %s","woocommerce-subscriptions"),e):(0,o.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
(0,o.__)("%s due today","woocommerce-subscriptions"),e):e,coupons:e=>{if(!Array.isArray(e)||!e.length)return e;const s=(0,l.select)("wc/store/cart");if(!s)return e;const t=s.getCartData()?.extensions?.subscriptions_cart_meta?.hidden_coupon_codes;if(!Array.isArray(t)||!t.length)return e;const n=new Set(t);return e.filter(e=>!n.has(e.code))},placeOrderButtonLabel:e=>{const s=(0,a.getSetting)("subscriptions_data");return s?.place_order_override?s?.place_order_override:e}})})();