(()=>{"use strict";var e={20:(e,s,i)=>{var t=i(609),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(e,s,i){var t,r={},l=null,p=null;for(t in void 0!==i&&(l=""+i),void 0!==s.key&&(l=""+s.key),void 0!==s.ref&&(p=s.ref),s)o.call(s,t)&&!a.hasOwnProperty(t)&&(r[t]=s[t]);if(e&&e.defaultProps)for(t in s=e.defaultProps)void 0===r[t]&&(r[t]=s[t]);return{$$typeof:n,type:e,key:l,ref:p,props:r,_owner:c.current}}s.Fragment=r,s.jsx=l,s.jsxs=l},609:e=>{e.exports=window.React},848:(e,s,i)=>{e.exports=i(20)}},s={};function i(t){var n=s[t];if(void 0!==n)return n.exports;var r=s[t]={exports:{}};return e[t](r,r.exports,i),r.exports}const t=window.wp.plugins,n=window.wc.blocksCheckout,r=window.wp.i18n,o=window.wc.priceFormat,c=window.wc.wcSettings,a=window.wp.data,l=window.wc.wcBlocksData;function p(e){return{day:(0,r._nx)("day","days",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),week:(0,r._nx)("week","weeks",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),month:(0,r._nx)("month","months",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),year:(0,r._nx)("year","years",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions")}}function u({billing_interval:e,billing_period:s},i,t){const n=p(e)[s];return i=i.trim(),1===e?`${t} ${i} ${n}`:(0,r.sprintf)(
/*
       * translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
       * %3$d is the length, %4$s is week, month, year
       */
/*
       * translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
       * %3$d is the length, %4$s is week, month, year
       */
(0,r.__)("%1$s %2$s %3$d %4$s","woocommerce-subscriptions"),t,i,e,n)}function d({subscriptionLength:e,billingInterval:s}){return e===s}const g=(0,c.getSetting)("countryData",{}),m=(0,c.getSetting)("countries",{}),_={...Object.fromEntries(Object.keys(g).filter(e=>!0===g[e].allowBilling).map(e=>[e,m[e]||""])),...Object.fromEntries(Object.keys(g).filter(e=>!0===g[e].allowShipping).map(e=>[e,m[e]||""]))},h=Object.fromEntries(Object.keys(_).map(e=>[e,g[e].locale||{}])),b={address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]},w=Object.entries(h).reduce((e,[s,i])=>(e[s]=Object.entries(i).reduce((e,[s,i])=>(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,r.sprintf)(/* translators: %s Field label. */ /* translators: %s Field label. */
(0,r.__)("%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})(i),e),{}),e),{}),y=["state","country","postcode","city"],f=e=>e.some(e=>!!e.shipping_rates.length),x=(0,c.getSetting)("collectableMethodIds",[]),v=(0,c.getSetting)("localPickupEnabled",!1);var k=i(848);const S=(0,c.getSetting)("displayCartPricesIncludingTax",!1),L=({currency:e,values:s,isLoading:i})=>{const{total_discount:t,total_discount_tax:o}=s,c=parseInt(t,10);if(!c)return null;const a=parseInt(o,10),l=S?c+a:c;return(0,k.jsx)(n.TotalsItem,{className:"wc-block-components-totals-discount",currency:e,label:(0,r.__)("Discount","woocommerce-subscriptions"),value:-1*l,showSkeleton:i})},j=({values:e,currency:s,shippingRatePackages:i,isLoading:t,calculatedShipping:n,shippingAddress:o})=>{const p=(0,a.useSelect)(e=>e(l.checkoutStore).prefersCollection());if(!n)return null;const u=(m=((e,s)=>e.map(e=>({...e,shipping_rates:e.shipping_rates.filter(e=>{const i=(t=e.method_id,!!v&&(Array.isArray(t)?!!t.find(e=>x.includes(e)):x.includes(t)));var t;return s?i:!i})})))(i,null!=p&&p),!!f(m)&&m.every(e=>e.shipping_rates.every(e=>!e.selected||(e=>x.includes(e.method_id))(e)))),d=!!(g=o).country&&((e,s,i="")=>{const t=i&&void 0!==w[i]?w[i]:{};return e.map(e=>({key:e,...s&&e in s?s[e]:{},...t&&e in t?t[e]:{}})).sort((e,s)=>e.index-s.index)})((0,c.getSetting)("addressFieldsLocations",b).address,c.defaultFields,g.country).filter(({key:e})=>y.includes(e)).every(({key:e,hidden:s,required:i})=>!0===s||!1===i||e in g&&""!==g[e]);var g,m;return(0,k.jsx)(I,{label:u?(0,r.__)("Pickup","woocommerce-subscriptions"):(0,r.__)("Delivery","woocommerce-subscriptions"),placeholder:(0,k.jsx)("span",{className:"wc-block-components-shipping-placeholder__value",children:d?(0,r.__)("No available delivery option","woocommerce-subscriptions"):(0,r.__)("Enter address to calculate","woocommerce-subscriptions")}),isLoading:t,shippingRatePackages:i,currency:s,values:e})},I=({values:e,currency:s,shippingRatePackages:i,label:t,placeholder:o,isLoading:a})=>{const l=i?.flatMap(e=>e.shipping_rates).find(({selected:e})=>e)?.name,p=!!f(u=i)&&u.some(e=>e.shipping_rates.some(e=>e.selected));var u;const d=!p||i?.length>1?t:(0,r.__)("Shipping","woocommerce-subscriptions"),g=S?parseInt(e.total_shipping,10)+parseInt(e.total_shipping_tax,10):parseInt(e.total_shipping,10),m=0===g&&(0,c.isWcVersion)("9.0",">=")?(0,k.jsx)("strong",{children:(0,r.__)("Free","woocommerce-subscriptions")}):g;return(0,k.jsx)(n.TotalsItem,{value:p?m:o,label:d,currency:s,showSkeleton:a,description:!!l&&(0,r.sprintf)(
// translators: %s selected shipping rate (ex: flat rate)
// translators: %s selected shipping rate (ex: flat rate)
(0,r.__)("via %s","woocommerce-subscriptions"),l)})},P=({nextPaymentDate:e,subscriptionLength:s,billingPeriod:i,billingInterval:t})=>{const n=function({subscriptionLength:e,billingPeriod:s}){const i=p(e);return(0,r.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,r.__)("For %1$d %2$s","woocommerce-subscriptions"),e,i[s],"woocommerce-subscriptions")}({subscriptionLength:s,billingPeriod:i}),o=d({subscriptionLength:s,billingInterval:t})?(0,r.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
(0,r.__)("Due: %1$s","woocommerce-subscriptions"),e):(0,r.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
(0,r.__)("Starting: %1$s","woocommerce-subscriptions"),e);return(0,k.jsxs)("span",{children:[!!e&&o," ",!!s&&s>=t&&(0,k.jsx)("span",{className:"wcs-recurring-totals__subscription-length",children:n})]})},O=({currency:e,billingInterval:s,billingPeriod:i,nextPaymentDate:t,subscriptionLength:o,totals:c,isLoading:a})=>{const l=d({billingInterval:s,subscriptionLength:o})?(0,r.__)("Total","woocommerce-subscriptions"):function({billingInterval:e,billingPeriod:s}){if(1!==e){const i=p(e)[s];return(0,r.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,r.__)("Recurring total every %1$d %2$s","woocommerce-subscriptions"),e,i)}return"day"===s?(0,r.__)("Daily recurring total","woocommerce-subscriptions"):"week"===s?(0,r.__)("Weekly recurring total","woocommerce-subscriptions"):"month"===s?(0,r.__)("Monthly recurring total","woocommerce-subscriptions"):"year"===s?(0,r.__)("Yearly recurring total","woocommerce-subscriptions"):void 0}({billingInterval:s,billingPeriod:i});return(0,k.jsx)(n.TotalsItem,{className:"wcs-recurring-totals-panel__title",currency:e,label:l,value:c,showSkeleton:a,description:(0,k.jsx)(P,{nextPaymentDate:t,subscriptionLength:o,billingInterval:s,billingPeriod:i})})},C=({subscription:e,needsShipping:s,calculatedShipping:i,shippingAddress:t})=>{const{isLoading:p}=(()=>{const{cartIsLoading:e,isLoadingRates:s,hasPendingItemsOperations:i,isApplyingCoupon:t,isRemovingCoupon:n}=(0,a.useSelect)(e=>{const s=e(l.cartStore);return{cartIsLoading:!s.hasFinishedResolution("getCartData",[]),isLoadingRates:s.isAddressFieldsForShippingRatesUpdating(),hasPendingItemsOperations:s.hasPendingItemsOperations(),isApplyingCoupon:s.isApplyingCoupon(),isRemovingCoupon:s.isRemovingCoupon()}},[]),r=(0,a.useSelect)(e=>e(l.checkoutStore).isCalculating(),[]);return{isLoading:e||s||t||n||r||i}})(),{totals:u,billing_interval:d,billing_period:g,next_payment_date:m,subscription_length:_,shipping_rates:h}=e;if(!m)return null;const b=e?.shipping_rates?.some(e=>e.needs_shipping),w=(0,o.getCurrencyFromPriceResponse)(u);return(0,k.jsxs)("div",{className:"wcs-recurring-totals-panel",children:[(0,k.jsx)(O,{billingInterval:d,billingPeriod:g,nextPaymentDate:m,subscriptionLength:_,totals:parseInt(u.total_price,10),currency:w,isLoading:p}),(0,k.jsxs)(n.Panel,{className:(0,c.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,r.__)("Details","woocommerce-subscriptions"),children:[(0,k.jsxs)(n.TotalsWrapper,{children:[(0,k.jsx)(n.Subtotal,{currency:w,values:u,showSkeleton:p}),(0,k.jsx)(L,{currency:w,values:u,isLoading:p})]}),s&&b&&(0,k.jsx)(n.TotalsWrapper,{className:"wc-block-components-totals-shipping",children:(0,k.jsx)(j,{currency:w,calculatedShipping:i,values:u,shippingAddress:t,shippingRatePackages:h,isLoading:p})}),!S&&(0,k.jsx)(n.TotalsWrapper,{children:(0,k.jsx)(n.TotalsTaxes,{currency:w,values:u})}),(0,k.jsx)(n.TotalsWrapper,{children:(0,k.jsx)(n.TotalsItem,{className:"wcs-recurring-totals-panel__details-total",currency:w,label:(0,r.__)("Total","woocommerce-subscriptions"),value:parseInt(u.total_price,10),showSkeleton:p})})]})]})},R=({extensions:e,cart:s})=>{const{subscriptions:i}=e,{cartNeedsShipping:t,cartHasCalculatedShipping:n,shippingAddress:r}=s;return i&&0!==i.length?i.map(({key:e,...s})=>(0,k.jsx)(C,{subscription:s,needsShipping:t,calculatedShipping:n,shippingAddress:r},e)):null},D=window.wp.element,T=(0,c.getSetting)("collectableMethodIds",[]),$=({extensions:e,collapsible:s,collapse:i,showItems:t,noResultsMessage:n,renderOption:r,components:o,context:c})=>{const{subscriptions:a=[]}=e,{ShippingRatesControlPackage:l}=o,p=(0,D.useMemo)(()=>Object.values(a).map(e=>e.shipping_rates).filter(Boolean).flat(),[a]),u=(0,D.useMemo)(()=>p.length>1||i,[p.length,i]),d=(0,D.useMemo)(()=>p.length>1||t,[p.length,t]);return p.filter(e=>!e.match_initial_rates&&e.needs_shipping).map(({package_id:e,...i})=>(i.shipping_rates=i.shipping_rates.filter(e=>!T.includes(e.method_id)),(0,k.jsx)(l,{packageId:e,packageData:i,collapsible:s,collapse:u,showItems:d,noResultsMessage:n,renderOption:r,highlightChecked:"woocommerce/checkout"===c},e)))};var E=i(609);const F=(0,c.getSetting)("collectableMethodIds",[]),N=({packageId:e,packageData:s,showItems:i,renderPickupLocation:t,pickupLocations:n,packageCount:r,LocalPickupSelect:o})=>{var c;const{selectShippingRate:p}=(0,a.useDispatch)(l.cartStore),[u,d]=(0,E.useState)(null!==(c=s.shipping_rates.find(e=>e.selected)?.rate_id)&&void 0!==c?c:s.shipping_rates[0]?.rate_id);return(0,D.useEffect)(()=>{u&&p(u,e)},[]),(0,k.jsx)(o,{title:s.name,packageData:s,selectedOption:null!=u?u:"",showItems:i,renderPickupLocation:t,pickupLocations:n,packageCount:r,onChange:s=>{d(s),p(s,e)}})},M=({extensions:e,showItems:s,renderPickupLocation:i,components:t})=>{const{subscriptions:n=[]}=e,{LocalPickupSelect:r}=t,o=(0,D.useMemo)(()=>Object.values(n).map(e=>e.shipping_rates).filter(Boolean).flat(),[n]),c=(0,D.useMemo)(()=>o.length>1||s,[o.length,s]);return o.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,k.jsx)(N,{packageId:e,packageData:s,showItems:c,renderPickupLocation:i,pickupLocations:s.shipping_rates,packageCount:o.length,LocalPickupSelect:r},e)))};(0,t.registerPlugin)("woocommerce-subscriptions",{render:()=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.ExperimentalOrderShippingPackages,{children:(0,k.jsx)($,{})}),(0,k.jsx)(n.ExperimentalOrderLocalPickupPackages,{children:(0,k.jsx)(M,{})}),(0,k.jsx)(n.ExperimentalOrderMeta,{children:(0,k.jsx)(R,{})})]}),scope:"woocommerce-checkout"}),(0,n.registerCheckoutFilters)("woocommerce-subscriptions",{totalLabel:(e,{subscriptions:s})=>s?.length>0?(0,r.__)("Total due today","woocommerce-subscriptions"):e,subtotalPriceFormat:(e,{subscriptions:s})=>{if(s?.billing_period&&s?.billing_interval){const{billing_interval:i,subscription_length:t}=s;return d({subscriptionLength:t,billingInterval:i})?u(s,1===t?
// 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,r.__)("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,r.__)("for","woocommerce-subscriptions"),e):u(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,r.__)("every","woocommerce-subscriptions"),e)}return e},saleBadgePriceFormat:(e,{subscriptions:s})=>s?.billing_period&&s?.billing_interval?u(s,"/",e):e,itemName:(e,{subscriptions:s})=>s?.is_resubscribe?(0,r.sprintf)(
// translators: %s Product name.
// translators: %s Product name.
(0,r.__)("%s (resubscription)","woocommerce-subscriptions"),e):s?.switch_type?(0,r.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,r.__)("%1$s (%2$s)","woocommerce-subscriptions"),e,function(e){switch(e){case"upgraded":return(0,r.__)("Upgrade","woocommerce-subscriptions");case"downgraded":return(0,r.__)("Downgrade","woocommerce-subscriptions");case"crossgraded":return(0,r.__)("Crossgrade","woocommerce-subscriptions");default:return""}}(s.switch_type)):e,cartItemPrice:(e,{subscriptions:s},{context:i})=>s?.sign_up_fees&&parseInt(s.sign_up_fees,10)>0?"cart"===i?(0,r.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
(0,r.__)("Due today %s","woocommerce-subscriptions"),e):(0,r.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
(0,r.__)("%s due today","woocommerce-subscriptions"),e):e,placeOrderButtonLabel:e=>{const s=(0,c.getSetting)("subscriptions_data");return s?.place_order_override?s?.place_order_override:e}})})();