(()=>{"use strict";const e=window.wp.element,t=window.wp.data,n=window.ReactJSXRuntime,a=()=>{const a=window.wc.wcSettings.getSetting("alma-widget-block_data",null);if(!a.can_be_displayed)return null;if(a.is_excluded_categories){let e=a.excluded_categories_message,t=a.url_alma_logo;return(0,n.jsxs)("div",{id:"alma-widget-excluded",className:"alma-widget-excluded",children:[(0,n.jsx)("img",{src:t,alt:"Alma Logo",className:"alma-logo-excluded-categories"}),e]})}const{CART_STORE_KEY:i}=window.wc.wcBlocksData,l=(0,t.useSelect)(e=>{const t=e(i);return t&&t.getCartTotals()?.total_price||0},[]);return(0,e.useEffect)(()=>{l&&window.Alma&&window.wc&&function(){const e=window.wc.wcSettings.getSetting("alma-widget-block_data",null);e&&Alma.Widgets.initialize(e.merchant_id,Alma.ApiMode[e.environment]).add(Alma.Widgets.PaymentPlans,{container:".alma-widget",purchaseAmount:l,locale:e.locale,hideIfNotEligible:!1,plans:e.plans.map(e=>({installmentsCount:e.installmentsCount,minAmount:e.minAmount,maxAmount:e.maxAmount,deferredDays:e.deferredDays,deferredMonths:e.deferredMonths}))})}()},[l]),(0,n.jsx)("div",{class:"alma-widget"})};!function(t){const i="alma-widget-container";var l;(l="#"+i,new Promise(e=>{const n=new MutationObserver(()=>{t(l).length>0&&(e(t(l)),n.disconnect())});n.observe(document.body,{childList:!0,subtree:!0})})).then(()=>{const t=document.getElementById(i);t&&(0,e.render)((0,n.jsx)(a,{}),t)})}(jQuery)})();