"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[1402],{95802:(e,t,a)=>{a.r(t),a.d(t,{SettingsPaymentsMethods:()=>g,default:()=>w});var o=a(69307),m=a(67221),l=a(9818),c=a(65736),s=a(55609),i=a(87778),n=a(40404),r=a(29346),d=a(22629),_=a(42058);const p=({method:e,paymentMethodsState:t,setPaymentMethodsState:a,isExpanded:m,...l})=>{var c,i,n;return e.enabled||m?(0,o.createElement)("div",(0,r.Z)({id:e.id,className:"woocommerce-list__item woocommerce-list__item-enter-done"},l),(0,o.createElement)("div",{className:"woocommerce-list__item-inner"},"apple_google"!==e.id&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"woocommerce-list__item-before"},(0,o.createElement)("img",{src:e.icon,alt:e.title+" logo"})),(0,o.createElement)("div",{className:"woocommerce-list__item-text"},(0,o.createElement)("span",{className:"woocommerce-list__item-title"},e.title),(0,o.createElement)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,_.ZP)((0,d.decodeEntities)(e.description))}))),"apple_google"===e.id&&(0,o.createElement)("div",{className:"woocommerce-list__item-multi"},(0,o.createElement)("div",{className:"woocommerce-list__item-multi-row multi-row-space"},(0,o.createElement)("div",{className:"woocommerce-list__item-before"},(0,o.createElement)("img",{src:e.icon,alt:e.title+" logo"})),(0,o.createElement)("div",{className:"woocommerce-list__item-text"},(0,o.createElement)("span",{className:"woocommerce-list__item-title"},e.title),(0,o.createElement)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,_.ZP)((0,d.decodeEntities)(e.description))}))),(0,o.createElement)("div",{className:"woocommerce-list__item-multi-row"},(0,o.createElement)("div",{className:"woocommerce-list__item-before"},(0,o.createElement)("img",{src:e.extraIcon,alt:e.extraTitle+" logo"})),(0,o.createElement)("div",{className:"woocommerce-list__item-text"},(0,o.createElement)("span",{className:"woocommerce-list__item-title"},e.extraTitle),(0,o.createElement)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,_.ZP)((0,d.decodeEntities)(null!==(c=e.extraDescription)&&void 0!==c?c:""))})))),(0,o.createElement)("div",{className:"woocommerce-list__item-after"},(0,o.createElement)("div",{className:"woocommerce-list__item-after__actions wc-settings-prevent-change-event"},(0,o.createElement)(s.ToggleControl,{checked:null!==(i=t[e.id])&&void 0!==i&&i,onChange:o=>{a({...t,[e.id]:o})},disabled:null!==(n=e.required)&&void 0!==n&&n}))))):null},E=e=>{const t=(0,i.ZA)("apple_pay")(e),a=(0,i.ZA)("google_pay")(e);return t&&a?e.map((e=>"apple_pay"===e.id?{...e,id:"apple_google",extraTitle:a.title,extraDescription:a.description,extraIcon:a.icon}:"google_pay"===e.id?null:e)).filter((e=>null!==e)):e},g=({paymentMethodsState:e,setPaymentMethodsState:t})=>{var a;const[r,d]=(0,o.useState)(!1),{paymentMethods:_,isFetching:g}=(0,l.useSelect)((e=>{const t=e(m.PAYMENT_SETTINGS_STORE_NAME).getPaymentProviders()||[],a=(0,i.V3)(t);return{isFetching:e(m.PAYMENT_SETTINGS_STORE_NAME).isFetching(),paymentMethods:E(a)}})),w=_.reduce(((e,{id:t,enabled:a})=>(e[t]=a,e)),{});return(0,o.useEffect)((()=>{null===w||g||t(w)}),[g]),(0,o.createElement)("div",{className:"settings-payments-methods__container"},g?(0,o.createElement)(n.a,{rows:3,hasDragIcon:!1}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"woocommerce-list"},_.map((a=>(0,o.createElement)(p,{method:a,paymentMethodsState:e,setPaymentMethodsState:t,isExpanded:r,key:a.id})))),(0,o.createElement)(s.Button,{className:"settings-payments-methods__show-more",onClick:()=>{d(!r)},tabIndex:0,"aria-expanded":r},!r&&(0,c.sprintf)((0,c.__)("Show more (%s)","woocommerce"),null!==(a=_.filter((e=>!1===e.enabled)).length)&&void 0!==a?a:0),r&&(0,c.__)("Show less","woocommerce"))))},w=g}}]);