File: /home/shrsglobal/www/wp-content/plugins/woocommerce/assets/client/admin/chunks/6526.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6526],{12974:(e,t,s)=>{s.d(t,{A:()=>n});var o=s(42435);const n=e=>({__html:(0,o.sanitizeHTML)(e)})},7175:(e,t,s)=>{s.d(t,{A:()=>i});var o=s(56427),n=s(47804),r=s(56109),a=s(39793);function i({onClose:e}){return(0,a.jsxs)("div",{className:"settings-payments-onboarding-modal__header",children:[(0,a.jsx)("img",{src:`${r.GZ}images/woo-logo.svg`,alt:"",role:"presentation",className:"settings-payments-onboarding-modal__header--logo"}),(0,a.jsx)(o.Button,{className:"settings-payments-onboarding-modal__header--close",onClick:e,children:(0,a.jsx)(o.Icon,{icon:n.A})})]})}},58016:(e,t,s)=>{s.d(t,{A:()=>h});var o=s(27723),n=s(33068),r=s(51609),a=s(87007),i=s(86087),c=s(4921),l=s(56109),d=s(39793);function m({label:e,isCompleted:t,isActive:s}){return(0,d.jsxs)("div",{className:(0,c.A)("settings-payments-onboarding-modal__sidebar--list-item",{"is-active":s,"is-completed":t}),children:[(0,d.jsx)("span",{className:"settings-payments-onboarding-modal__sidebar--list-item-icon",children:t?(0,d.jsx)("img",{src:l.GZ+"images/onboarding/icons/complete.svg",alt:(0,o.__)("Step completed","woocommerce")}):(0,d.jsx)("img",{src:l.GZ+"images/onboarding/icons/pending.svg",alt:(0,o.__)("Step active","woocommerce")})}),(0,d.jsx)("span",{className:"settings-payments-onboarding-modal__sidebar--list-item-label",children:e})]})}var u=s(1069);function p({activeTopLevelStep:e,activeSubStep:t,steps:s,justCompletedStepId:n,includeSidebar:r=!1,sidebarTitle:a,context:c={}}){const l=s.find((t=>t.id===e));if((0,i.useEffect)((()=>{t&&(0,u.W7)("woopayments_onboarding_modal_step_view",{step:t.id,source:c?.sessionEntryPoint||"unknown"})}),[t]),!l)return null;const p=s.findIndex((t=>t.id===e))+1,_=e=>e.id===n||"completed"===e.status||p===s.length,h=s.sort(((e,t)=>{const s=_(e);return s===_(t)?0:s?-1:1}));return(0,d.jsxs)(d.Fragment,{children:[r&&(0,d.jsxs)("div",{className:"settings-payments-onboarding-modal__sidebar",children:[(0,d.jsxs)("div",{className:"settings-payments-onboarding-modal__sidebar--header",children:[(0,d.jsx)("h2",{className:"settings-payments-onboarding-modal__sidebar--header-title",children:a}),(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__sidebar--header-steps",children:(0,o.sprintf)((0,o.__)("Step %1$s of %2$s","woocommerce"),p,s.length)})]}),(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__sidebar--list",children:h.map((t=>(0,d.jsx)(m,{label:t.label,isCompleted:_(t),isActive:t.id===e},t.id)))})]}),(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__content",children:(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__step",id:t?.id,children:t?.content})})]})}var _=s(99096);function h({includeSidebar:e=!0}){const{steps:t,isLoading:s,currentTopLevelStep:i,currentStep:c,navigateToStep:l,justCompletedStepId:m,sessionEntryPoint:u}=(0,_.w)(),h=(0,n.zy)();return(0,r.useEffect)((()=>{var e;i&&!h.pathname.endsWith(null!==(e=i?.path)&&void 0!==e?e:"")&&l(i.id)}),[i,l,h.pathname]),s?(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__loading",children:(0,d.jsx)(a.A,{})}):t&&t.length>0?(0,d.jsx)(n.BV,{children:(0,d.jsx)(n.qh,{path:"*",element:(0,d.jsx)("div",{className:"settings-payments-onboarding-modal__wrapper",children:(0,d.jsx)(p,{steps:t,activeTopLevelStep:null!==(g=i?.id)&&void 0!==g?g:"",activeSubStep:c,justCompletedStepId:m,includeSidebar:e,sidebarTitle:(0,o.__)("Set up WooPayments","woocommerce"),context:{sessionEntryPoint:u}})})})}):null;var g}},87007:(e,t,s)=>{s.d(t,{A:()=>n}),s(51609);var o=s(39793);const n=()=>(0,o.jsx)("svg",{className:"stripe-spinner",width:"29",height:"29",viewBox:"0 0 29 29",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M14.3308 28.3333C14.0453 28.3333 13.7714 28.2199 13.5695 28.018C13.3675 27.816 13.2541 27.5422 13.2541 27.2566C13.2541 26.971 13.3675 26.6972 13.5695 26.4952C13.7714 26.2933 14.0453 26.1799 14.3308 26.1799C17.4727 26.1799 20.4859 24.9317 22.7076 22.7101C24.9293 20.4884 26.1774 17.4752 26.1774 14.3333C26.1774 11.1914 24.9293 8.17821 22.7076 5.95655C20.4859 3.73489 17.4727 2.48677 14.3308 2.48677C12.5754 2.48495 10.8416 2.87419 9.25541 3.62623C7.66923 4.37826 6.27049 5.4742 5.16082 6.83441C5.07124 6.94388 4.96097 7.03464 4.83631 7.1015C4.71165 7.16836 4.57504 7.21001 4.43428 7.22407C4.15001 7.25248 3.8661 7.16679 3.645 6.98587C3.42391 6.80494 3.28374 6.54359 3.25534 6.25932C3.22694 5.97505 3.31262 5.69114 3.49355 5.47005C4.80533 3.86303 6.45849 2.56827 8.33301 1.67977C10.2075 0.791267 12.2564 0.331321 14.3308 0.333319C22.0626 0.333319 28.3308 6.6015 28.3308 14.3333C28.3308 22.0651 22.0626 28.3333 14.3308 28.3333Z",fill:"#4F575D"})})},99096:(e,t,s)=>{s.d(t,{X:()=>p,w:()=>u});var o=s(86087),n=s(47143),r=s(40314),a=s(96476),i=s(22861),c=s(39793);const l=(e,t)=>{for(const s of t){if(s.id===e)return s;if(s.subSteps){const t=l(e,s.subSteps);if(t)return t}}},d={buildStepURL:e=>(0,a.getNewPath)({path:e},e,{page:"wc-settings",tab:"checkout"}),preserveParams:["source","from"]},m=(0,o.createContext)({steps:[],isLoading:!0,currentStep:void 0,currentTopLevelStep:void 0,context:{},navigateToStep:()=>{},navigateToNextStep:()=>{},getStepByKey:()=>{},refreshStoreData:()=>{},closeModal:()=>{},justCompletedStepId:null,setJustCompletedStepId:()=>{},sessionEntryPoint:"",snackbar:{show:!1,duration:4e3,message:""},setSnackbar:()=>{}}),u=()=>(0,o.useContext)(m),p=({children:e,onboardingSteps:t,closeModal:s,onFinish:u,urlStrategy:p,sessionEntryPoint:_=i.Fx})=>{const h=(0,a.getHistory)(),[g,y]=(0,o.useState)([]),[w,b]=(0,o.useState)(!0),[x,v]=(0,o.useState)([]),[f,j]=(0,o.useState)(null),[S,k]=(0,o.useState)({show:!1,duration:4e3,message:""}),N=(0,o.useCallback)((e=>{j(e)}),[]),{invalidateResolutionForStoreSelector:C}=(0,n.useDispatch)(r.woopaymentsOnboardingStore),{invalidateResolutionForStoreSelector:T}=(0,n.useDispatch)(r.paymentSettingsStore),{storeData:P,isStoreLoading:F}=(0,n.useSelect)((e=>({storeData:e(r.woopaymentsOnboardingStore).getOnboardingData(_),isStoreLoading:e(r.woopaymentsOnboardingStore).isOnboardingDataRequestPending()})),[_]),E=(0,o.useCallback)(((e,t=x)=>l(e,t)),[x]),A=(0,o.useCallback)(((e,t)=>!e.dependencies||0===e.dependencies.length||e.dependencies.every((e=>{const s=l(e,t);return"completed"===s?.status}))),[]),B=(0,o.useCallback)(((e,t,s)=>"frontend"!==e.type?"completed"===e.status:t?"completed"===t.status||s&&"backend"===s.type&&("in_progress"===s.status||"completed"===s.status):!!e.subSteps?.length&&e.subSteps.every((e=>!!e.status&&"completed"===e.status))),[]),D=(0,o.useCallback)((e=>{const t=E(e);if(t?.path){const e=p||d,s=e.preserveParams?(0,a.getQuery)():{},o=e.preserveParams?.reduce(((e,t)=>(s[t]&&(e[t]=s[t]),e)),{})||{},n=e.buildStepURL(t.path,o);h.push(n)}}),[E,h,p]),L=(0,o.useCallback)(((e,t,s)=>{for(const[o,n]of e.entries()){if("frontend"===n.type){const t=e[o+1];if(B(n,s,t))continue}if("completed"!==n.status&&A(n,t)){if(n.subSteps&&n.subSteps.length>0){const e=L(n.subSteps,t,n);if(e)return e}return n}}}),[A]),I=L(x,x),W=(e=>{if(e){for(const t of x){if(t.id===e.id)return t;if(t.subSteps?.some((t=>t.id===e.id)))return t}return e}})(I),O=(0,o.useCallback)((()=>{if(!I)return void u?.();const e=(t,s)=>t.map((t=>{if(t.id===s)return{...t,status:"completed"};if(t.subSteps){const o=e(t.subSteps,s);if(o!==t.subSteps){const e=o.every((e=>"completed"===e.status));return{...t,subSteps:o,status:e?"completed":t.status}}}return t})),t=e(x,I.id),s=L(t,t);v(t),s?D(s.id):u?.()}),[I,x,D,L,u]),M=()=>{y([]),b(!0),N(null),v([]),k({show:!1,message:""}),C("getOnboardingData")};return(0,o.useEffect)((()=>{!F&&P.steps.length>0&&(y(P.steps),b(!1))}),[P,F]),(0,o.useEffect)((()=>{const e=t=>t.map((t=>{let s={...t};if("backend"===s.type){const e=g.find((e=>e.id===s.id));if(!e)return null;const t=e;s={...s,status:("started"===t.status?"in_progress":t.status)||"not_started",dependencies:t.dependencies||[],path:t.path,context:{...s.context||{},...t.context||{}},actions:t.actions,errors:t.errors}}return s.subSteps&&(s.subSteps=e(s.subSteps)),s})).filter((e=>null!==e)),s=e(t),o=(e,t,s)=>e.map(((n,r)=>{const a={...n};if("frontend"===a.type){a.subSteps?.length&&(a.subSteps=o(a.subSteps,t,a));const n=e[r+1],i=B(a,s,n);a.status=i?"completed":"not_started"}return a.subSteps&&"frontend"!==a.type&&(a.subSteps=o(a.subSteps,t,a)),a})),n=o(s,s);v(n)}),[g,A,t]),(0,o.useEffect)((()=>{M()}),[]),(0,c.jsx)(m.Provider,{value:{steps:x,context:P.context,isLoading:w,currentStep:I,currentTopLevelStep:W,navigateToStep:D,navigateToNextStep:O,getStepByKey:E,refreshStoreData:M,closeModal:()=>{s(),T("getPaymentProviders")},justCompletedStepId:f,setJustCompletedStepId:N,sessionEntryPoint:_,snackbar:S,setSnackbar:k},children:e})}},98404:(e,t,s)=>{s.d(t,{A:()=>ae});var o=s(51609),n=s.n(o),r=s(27723),a=s(56427),i=s(99096),c=s(7175),l=s(66087),d=s(39793);const m=(e={})=>{const[t,s]=(0,o.useState)(e),[n,r]=(0,o.useState)({}),[a,i]=(0,o.useState)({});return{data:t,setData:e=>s((t=>({...t,...e}))),errors:n,setErrors:e=>r((t=>(0,l.omitBy)({...t,...e},l.isNil))),touched:a,setTouched:e=>i((t=>({...t,...e})))}},u=(0,o.createContext)(null),p=({children:e,initialData:t})=>(0,d.jsx)(u.Provider,{value:m(t),children:e}),_=()=>{const e=(0,o.useContext)(u);if(!e)throw new Error("useBusinessVerificationContext() must be used within <BusinessVerificationContextProvider>");return e};var h=s(86087);const g=(0,o.createContext)(null),y=({children:e,onStepView:t,...s})=>{const r=(e=>e.reduce(((e,t,s)=>{var o;return n().isValidElement(t)&&(e[null!==(o=t.props.name)&&void 0!==o?o:s]=t),e}),{}))(e),a=(({steps:e,initialStep:t,onStepChange:s,onComplete:n,onExit:r})=>{const a=Object.keys(e),{currentStep:c}=(0,i.w)(),[l,d]=(0,o.useState)(null!=t?t:a[0]);if("completed"===c?.context?.sub_steps[l]?.status){const e=a.indexOf(l),t=a[e+1];d(t),s?.(t)}const m=(a.indexOf(l)+1)/a.length;return{currentStep:l,progress:m,nextStep:()=>{const e=a.indexOf(l),t=a[e+1];t?(d(t),s?.(t)):n?.()},prevStep:()=>{const e=a.indexOf(l),t=a[e-1];t?(d(t),s?.(t)):r?.()},exit:()=>r?.()}})({steps:r,...s});(0,h.useEffect)((()=>{t?.(a.currentStep)}),[a.currentStep]);const c=r[a.currentStep];return(0,d.jsx)(g.Provider,{value:a,children:c})},w=()=>{const e=(0,o.useContext)(g);if(!e)throw new Error("useStepperContext() must be used within <Stepper>");return e};var b=s(4921),x=s(24148),v=s(90700),f=s(72744),j=s(21913);const S=e=>e?.name||"",k=({selectedItem:e},{type:t,changes:s,props:{items:o}})=>{switch(t){case j.WM.stateChangeTypes.ToggleButtonKeyDownArrowDown:return{selectedItem:o[e?Math.min(o.indexOf(e)+1,o.length-1):0]};case j.WM.stateChangeTypes.ToggleButtonKeyDownArrowUp:return{selectedItem:o[e?Math.max(o.indexOf(e)-1,0):o.length-1]};default:return s}},N=function({name:e,className:t,label:s,describedBy:o,options:n,onChange:i,value:c,placeholder:l,children:m}){const{getLabelProps:u,getToggleButtonProps:p,getMenuProps:_,getItemProps:g,isOpen:y,highlightedIndex:w,selectedItem:N}=(0,j.WM)({initialSelectedItem:n[0],items:n,itemToString:S,onSelectedItemChange:i,selectedItem:c||{},stateReducer:k}),C=S(N),T=_({className:"components-custom-select-control__menu","aria-hidden":!y}),P=(0,h.useCallback)((e=>{e.stopPropagation(),T?.onKeyDown?.(e)}),[T]);return T["aria-activedescendant"]?.startsWith("downshift-null")&&delete T["aria-activedescendant"],(0,d.jsxs)("div",{className:(0,b.A)("woopayments components-custom-select-control",t),children:[(0,d.jsx)("label",{...u({className:"components-custom-select-control__label"}),children:s}),(0,d.jsxs)(a.Button,{...p({"aria-label":s,"aria-labelledby":void 0,"aria-describedby":o||(C?(0,r.sprintf)((0,r.__)("Currently selected: %s","woocommerce"),C):(0,r.__)("No selection","woocommerce")),className:(0,b.A)("components-custom-select-control__button",{placeholder:!C}),name:e}),children:[(0,d.jsx)("span",{className:"components-custom-select-control__button-value",children:C||l}),(0,d.jsx)(x.A,{icon:v.A,className:"components-custom-select-control__button-icon"})]}),(0,d.jsx)("div",{...T,children:(0,d.jsx)("ul",{className:"components-custom-select-control__menu-container",onKeyDown:P,children:y&&n.map(((e,t)=>(0,d.jsxs)("li",{...g({item:e,index:t,className:(0,b.A)(e.className,"components-custom-select-control__item",{"is-highlighted":t===w}),style:e.style}),children:[m?m(e):e.name,e===N&&(0,d.jsx)(x.A,{icon:f.A,className:"components-custom-select-control__item-icon"})]},e.key)))})})]})};var C=s(56537);const T=({name:e,className:t,label:s,options:n,onChange:a,value:i,placeholder:c,searchable:l})=>{const m=(0,o.useRef)(null),u=(0,o.useRef)(),p=n.filter((e=>e.items?.length)).map((e=>e.key)),[_,h]=(0,o.useState)(new Set([p[0]])),[g,y]=(0,o.useState)(new Set([...p,...n[0]?.items||[]])),[w,S]=(0,o.useState)(""),k=n.filter((e=>g.has(e.key))),{isOpen:N,selectedItem:T,getToggleButtonProps:P,getMenuProps:F,getLabelProps:E,highlightedIndex:A,getItemProps:B}=(0,j.WM)({items:k,itemToString:e=>e?.name||"",selectedItem:i||{},onSelectedItemChange:a,stateReducer:(e,{changes:t,type:s})=>{if(l&&s===j.WM.stateChangeTypes.ToggleButtonKeyDownArrowDown)return e;if(t.selectedItem&&t.selectedItem.items){if(w)return e;const s=t.selectedItem.key;return _.has(s)?(_.delete(s),t.selectedItem.items.forEach((e=>g.delete(e)))):(_.add(s),t.selectedItem.items.forEach((e=>g.add(e)))),h(_),y(g),e}return t}}),D=F({className:"components-grouped-select-control__list","aria-hidden":!N,onFocus:()=>m.current?.focus(),onBlur:e=>{e.relatedTarget===m.current&&(e.nativeEvent.preventDownshiftDefault=!0)},onKeyDown:e=>{"Space"===e.code&&(e.nativeEvent.preventDownshiftDefault=!0)}});return(0,d.jsxs)("div",{className:(0,b.A)("woopayments components-grouped-select-control",t),children:[(0,d.jsx)("label",{...E({className:"components-grouped-select-control__label"}),children:s}),(0,d.jsxs)("button",{...P({type:"button",className:(0,b.A)("components-text-control__input components-grouped-select-control__button",{placeholder:!T?.name}),name:e}),children:[(0,d.jsx)("span",{className:"components-grouped-select-control__button-value",children:T?.name||c}),(0,d.jsx)(x.A,{icon:v.A,className:"components-grouped-select-control__button-icon"})]}),(0,d.jsx)("div",{...D,children:N&&(0,d.jsxs)(d.Fragment,{children:[l&&(0,d.jsx)("input",{className:"components-grouped-select-control__search",ref:m,type:"text",value:w,onChange:({target:e})=>{if(u.current||(u.current={visibleItems:g}),""===e.value)y(u.current.visibleItems),u.current=void 0;else{const t=n.filter((t=>t?.group&&`${t.name} ${t.context||""}`.toLowerCase().includes(e.value.toLowerCase()))),s=t.map((e=>e?.group||"")),o=new Set([...t.map((e=>e.key)),...s]);y(o)}S(e.value)},tabIndex:-1,placeholder:(0,r.__)("Search…","woocommerce")}),(0,d.jsx)("ul",{className:"components-grouped-select-control__list-container",children:k.map(((e,t)=>{const s=!!e.items;return(0,d.jsxs)("li",{...B({item:e,index:t,className:(0,b.A)("components-grouped-select-control__item",e.className,{"is-highlighted":t===A},{"is-group":s})}),children:[(0,d.jsx)("div",{className:"components-grouped-select-control__item-content",children:e.name}),e.key===T?.key&&(0,d.jsx)(x.A,{icon:f.A}),!w&&s&&(0,d.jsx)(x.A,{icon:_.has(e.key)?C.A:v.A})]},e.key)}))})]})})]})},P=(e,t,s)=>{const{error:o,...n}=t;return o?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e,{...n,ref:s,className:(0,b.A)(n.className,"has-error")}),(0,d.jsx)("div",{className:"components-form-field__error",children:o})]}):(0,d.jsx)(e,{...n,ref:s})},F=((0,o.forwardRef)(((e,t)=>P(a.TextControl,e,t))),e=>P(N,e)),E=e=>P(T,e),A={generic:{individual:(0,r.__)("Select if you run your own business as an individual and are self-employed","woocommerce"),company:(0,r.__)("Select if you filed documentation to register your business with a government agency","woocommerce"),non_profit:(0,r.__)("Select if you run a non-business entity","woocommerce"),government_entity:(0,r.__)("Select if your business is classed as a government entity","woocommerce")},US:{individual:(0,r.__)("Select if you run your own business as an individual and are self-employed","woocommerce"),company:(0,r.__)("Select if you filed documentation to register your business with a government agency","woocommerce"),non_profit:(0,r.__)("Select if you have been granted tax-exempt status by the Internal Revenue Service (IRS)","woocommerce"),government_entity:(0,r.__)("Select if your business is classed as a government entity","woocommerce")}},B=e=>{const t=window.wcSettings.admin?.onboarding?.profile?.industry?.[0];if(t)return e[t]},D=()=>{const{woocommerce_share_key:e,woocommerce_coming_soon:t,woocommerce_private_link:s}=window.wcSettings?.admin?.siteVisibilitySettings||{};return"yes"!==t||"no"===s?"":e?"?woo-share="+e:""};var L=s(1455),I=s.n(L);var W=s(36849);const O={steps:{activate:{heading:(0,r.__)("Start accepting real payments","woocommerce"),subheading:(0,W.A)({mixedString:(0,r.__)("You are currently testing payments on your store. To activate real payments, you will need to provide some additional details about your business. {{link}}Learn more{{/link}}.","woocommerce"),components:{link:(0,d.jsx)("a",{rel:"external noopener noreferrer",target:"_blank",href:"https://woocommerce.com/document/woopayments/startup-guide/#sign-up-process"})}}),cta:(0,r.__)("Activate payments","woocommerce")},business:{heading:(0,r.__)("Let’s get your store ready to accept payments","woocommerce"),subheading:(0,r.__)("We’ll use these details to enable payments for your store. This information can’t be changed after your account is created.","woocommerce")},store:{heading:(0,r.__)("Please share a few more details","woocommerce"),subheading:(0,r.__)("This info will help us speed up the set up process.","woocommerce")},loading:{heading:(0,r.__)("One last step! Verify your identity with our partner","woocommerce"),subheading:(0,r.__)("This will take place in a secure environment through our partner. Once your business details are verified, you’ll be redirected back to your store dashboard.","woocommerce"),cta:(0,r.__)("Finish your verification process","woocommerce")},embedded:{heading:(0,r.__)("One last step! Verify your identity with our partner","woocommerce"),subheading:(0,r.__)("This info will verify your account","woocommerce")}},fields:{country:(0,r.__)("Where is your business located?","woocommerce"),business_type:(0,r.__)("What type of legal entity is your business?","woocommerce"),"company.structure":(0,r.__)("What category of legal entity identify your business?","woocommerce"),mcc:(0,r.__)("What type of goods or services does your business sell? ","woocommerce")},errors:{generic:(0,r.__)("Please provide a response","woocommerce"),country:(0,r.__)("Please provide a country","woocommerce"),business_type:(0,r.__)("Please provide a business type","woocommerce"),mcc:(0,r.__)("Please provide a type of goods or services","woocommerce")},placeholders:{generic:(0,r.__)("Select an option","woocommerce"),country:(0,r.__)("Select a country","woocommerce")},tos:(0,W.A)({mixedString:(0,r.sprintf)((0,r.__)("By using %1$s, you agree to be bound by our {{tosLink}}Terms of Service{{/tosLink}} (including {{merchantTermsLink}}%2$s merchant terms{{/merchantTermsLink}}) and acknowledge that you have read our {{privacyPolicyLink}}Privacy Policy{{/privacyPolicyLink}}.","woocommerce"),"WooPayments","WooPay"),components:{tosLink:(0,d.jsx)("a",{rel:"external noopener noreferrer",target:"_blank",href:"https://wordpress.com/tos/"}),merchantTermsLink:(0,d.jsx)("a",{rel:"external noopener noreferrer",target:"_blank",href:"https://wordpress.com/tos/#more-woopay-specifically"}),privacyPolicyLink:(0,d.jsx)("a",{rel:"external noopener noreferrer",target:"_blank",href:"https://automattic.com/privacy/"})}}),continue:(0,r.__)("Continue","woocommerce"),back:(0,r.__)("Back","woocommerce"),cancel:(0,r.__)("Cancel","woocommerce")},M=e=>{const{data:t,errors:s,setErrors:n,touched:r,setTouched:a}=_(),i=(s=t[e])=>{r[e]||a({[e]:!0});const o=((e,t)=>!!t)(0,s)?void 0:O.errors[e]||O.errors.generic;n({[e]:o})};return(0,o.useEffect)((()=>(i(),t[e]||a({[e]:!1}),()=>n({[e]:void 0}))),[]),{validate:i,error:()=>r[e]?s[e]:void 0}};var R=s(1069);const z=({children:e})=>{const{data:t,errors:s,touched:n,setTouched:r}=_(),{currentStep:c,sessionEntryPoint:m}=(0,i.w)(),{nextStep:u}=w(),[p,h]=(0,o.useState)(!1);return(0,d.jsxs)("form",{onSubmit:async e=>{var o,a;e.preventDefault(),await((0,l.isEmpty)(s)&&(e=>["business_type","country","mcc"].every((t=>Boolean(e[t]))))(t)?(h(!0),((e,t,s)=>t?I()({url:t,method:"POST",data:{sub_steps:{...s,[e]:{status:"completed"}}}}):Promise.resolve())("business",null!==(o=c?.actions?.save?.href)&&void 0!==o?o:void 0,null!==(a=c?.context?.sub_steps)&&void 0!==a?a:{}).then((()=>((0,R.W7)("woopayments_onboarding_modal_kyc_sub_step_completed",{sub_step_id:"business",country:t.country||"unknown",business_type:t.business_type||"unknown",mcc:t.mcc||"unknown",source:m}),h(!1),u()))).catch((()=>{h(!1)}))):(r((0,l.mapValues)(n,(()=>!0))),Promise.resolve()))},children:[e,(0,d.jsx)(a.Button,{variant:"primary",type:"submit",className:"stepper__cta",onClick:()=>{var e;(0,R.W7)("woopayments_onboarding_modal_click",{step:null!==(e=c?.id)&&void 0!==e?e:"unknown",sub_step_id:"business",action:"business_form_continue",source:m})},isBusy:p,disabled:p,children:O.continue})]})},q=({onChange:e,...t})=>{var s;const{name:o}=t,{data:n,setData:r}=_(),{validate:a,error:i}=M(o);return(0,d.jsx)(F,{label:O.fields[o],value:t.options?.find((e=>e.key===n[o])),placeholder:null!==(s=O.placeholders[o])&&void 0!==s?s:O.placeholders.generic,onChange:({selectedItem:t})=>{e?e?.(o,t):r({[o]:t?.key}),a(t?.key)},options:[],error:i(),...t})},H=({onChange:e,...t})=>{var s;const{name:o}=t,{data:n,setData:r}=_(),{validate:a,error:i}=M(o);return(0,d.jsx)(E,{label:O.fields[o],value:t.options?.find((e=>e.key===n[o])),placeholder:null!==(s=O.placeholders[o])&&void 0!==s?s:O.placeholders.generic,onChange:({selectedItem:t})=>{e?e?.(o,t):r({[o]:t?.key}),a(t?.key)},options:[],error:i(),...t})},U=()=>{var e;const{data:t,setData:s}=_(),{currentStep:o,sessionEntryPoint:n}=(0,i.w)(),r=(e=>Object.entries(e||[]).map((([e,t])=>({key:e,name:t,types:[]}))).sort(((e,t)=>e.name.localeCompare(t.name))))(o?.context?.fields?.available_countries||{}),a=(e=>(e||[]).map((e=>({...e,types:e.types.map((t=>({...t,description:A[e.key]?A[e.key][t.key]:A.generic[t.key]})))}))).sort(((e,t)=>e.name.localeCompare(t.name)))||[])(o?.context?.fields?.business_types||[]),c=((null!==(e=o?.context?.fields?.mccs_display_tree)&&void 0!==e?e:[])||[]).filter((e=>!!e?.items&&(e.items?.filter((e=>!e?.items))||[]).length)).reduce(((e,t)=>{const s=t.items?.map((e=>({key:e.id,name:e.title,group:t.id,context:e?.keywords?e.keywords.join(" "):""})))||[];return[...e,{key:t.id,name:t.title,items:s.map((e=>e.key))},...s]}),[]),l=a.find((e=>"PR"===t.country?"US"===e.key:e.key===t.country)),m=l?.types.sort(((e,t)=>"company"===e.key?-1:"company"===t.key?1:0)),u=m?.find((e=>e.key===t.business_type)),p=0===u?.structures.length||u?.structures.find((e=>e.key===t["company.structure"])),h=e=>{s(e);const t=o?.actions?.save?.href;return t?I()({url:t,method:"POST",data:{self_assessment:e,source:n}}):Promise.resolve()},g=(e,t)=>{let s={[e]:t?.key};return"business_type"===e?s={...s,"company.structure":void 0}:"country"===e&&(s={...s,business_type:void 0}),h(s)};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{"data-testid":"country-select",children:(0,d.jsx)(q,{name:"country",options:r,onChange:g})}),l&&l.types.length>0&&(0,d.jsx)("span",{"data-testid":"business-type-select",children:(0,d.jsx)(q,{name:"business_type",options:l.types,onChange:g,children:e=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{children:e.name}),(0,d.jsx)("div",{className:"complete-business-info-task__option-description",children:e.description})]})})}),u&&u.structures.length>0&&(0,d.jsx)("span",{"data-testid":"business-structure-select",children:(0,d.jsx)(q,{name:"company.structure",options:u.structures,onChange:g})}),l&&u&&p&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{"data-testid":"mcc-select",children:(0,d.jsx)(H,{name:"mcc",options:c,onChange:(e,s)=>{const o={...t,[e]:s?.key};return h(o)},searchable:!0})}),(0,d.jsx)("span",{className:"woopayments-onboarding__tos",children:O.tos})]})]})};var V=s(87007),K=s(20195),G=s(73290),Y=s(94736),$=s(92991),Z=s(8181);f.A,$.A,Y.A,G.A;const X=({children:e,actions:t=[],className:s,status:o="info",isDismissible:n=!0,onRemove:i})=>{((e,t)=>{const s="string"==typeof t?t:(0,h.renderToString)(t),o="error"===e?"assertive":"polite";(0,h.useEffect)((()=>{s&&(0,K.speak)(s,o)}),[s,o])})(o,e);const c=(0,b.A)(s,"woopayments-banner-notice","is-"+o);return(0,d.jsxs)("div",{className:c,children:[(0,d.jsxs)("div",{className:"woopayments-banner-notice__content",children:[e,t.length>0&&(0,d.jsx)("div",{className:"woopayments-banner-notice__actions",children:t.map((({className:e,label:t,variant:s,onClick:o,url:n,urlTarget:r},i)=>{let c=s;return"primary"!==s&&(c=n?"link":"secondary"),(0,d.jsx)(a.Button,{href:n,variant:c,onClick:n?void 0:o,className:e,target:r,children:t},i)}))})]}),n&&(0,d.jsx)(a.Button,{className:"woopayments-banner-notice__dismiss",icon:(0,d.jsx)(Z.A,{}),label:(0,r.__)("Dismiss this notice","woocommerce"),onClick:()=>i?.(),showTooltip:!1})]})};var J=s(2929),Q=s(86948);const ee={variables:{colorPrimary:"#873EFF",colorBackground:"#FFFFFF",buttonPrimaryColorBackground:"#3858E9",buttonPrimaryColorBorder:"#3858E9",buttonPrimaryColorText:"#FFFFFF",buttonSecondaryColorBackground:"#FFFFFF",buttonSecondaryColorBorder:"#3858E9",buttonSecondaryColorText:"#3858E9",colorText:"#101517",colorSecondaryText:"#50575E",actionPrimaryColorText:"#3858E9",actionSecondaryColorText:"#101517",colorBorder:"#DDDDDD",formHighlightColorBorder:"#3858E9",formAccentColor:"#3858E9",colorDanger:"#CC1818",offsetBackgroundColor:"#F0F0F0",formBackgroundColor:"#FFFFFF",badgeNeutralColorText:"#2C3338",badgeNeutralColorBackground:"#F6F7F7",badgeNeutralColorBorder:"#F6F7F7",badgeSuccessColorText:"#005C12",badgeSuccessColorBackground:"#EDFAEF",badgeSuccessColorBorder:"#EDFAEF",badgeWarningColorText:"#614200",badgeWarningColorBackground:"#FCF9E8",badgeWarningColorBorder:"#FCF9E8",badgeDangerColorText:"#8A2424",badgeDangerColorBackground:"#FCF0F1",badgeDangerColorBorder:"#FCF0F1",borderRadius:"2px",buttonBorderRadius:"2px",formBorderRadius:"2px",badgeBorderRadius:"2px",overlayBorderRadius:"8px",spacingUnit:"10px",fontFamily:"-apple-system, BlinkMacSystemFont, 'system-ui', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Roboto', 'Arial', sans-serif",fontSizeBase:"16px",headingXlFontSize:"32px",headingXlFontWeight:"400",headingLgFontSize:"24px",headingLgFontWeight:"400",headingMdFontSize:"20px",headingMdFontWeight:"400",headingSmFontSize:"13px",headingSmFontWeight:"600",headingXsFontSize:"12px",headingXsFontWeight:"600",bodyMdFontWeight:"400",bodyMdFontSize:"16px",bodySmFontSize:"13px",bodySmFontWeight:"400",labelSmFontSize:"12px",labelSmFontWeight:"200",labelMdFontSize:"13px"}},te=({onboardingData:e,onExit:t,onLoaderStart:s,onLoadError:n,onStepChange:a,collectPayoutRequirements:c=!1})=>{const{stripeConnectInstance:m,initializationError:u}=(e=>{const[t,s]=(0,o.useState)(null),{currentStep:n,sessionEntryPoint:a}=(0,i.w)(),[c,d]=(0,o.useState)(null),[m,u]=(0,o.useState)(!0);return(0,o.useEffect)((()=>{(async()=>{try{var t;const o=await(async(e,t,s)=>{const o=(n=e,(0,l.toPairs)(n).reduce(((e,[t,s])=>null!==s?(0,l.set)(e,t,s):e),{}));var n;const r={};return Object.keys(o).length>0&&(r.self_assessment=o),s&&(r.source=s),await I()({url:t,method:"POST",data:r})})(e,null!==(t=n?.actions?.kyc_session?.href)&&void 0!==t?t:"",a),{clientSecret:i,publishableKey:c}=o.session;if(!c)throw new Error((0,r.__)("Unable to start the business verification session. If this problem persists, please contact support.","woocommerce"));const d=(0,J.e)({publishableKey:c,fetchClientSecret:async()=>i,appearance:{overlays:"drawer",...ee},locale:o.session.locale.replace("_","-")});s(d)}catch(e){d(e instanceof Error?e.message:(0,r.__)("Unable to start the business verification session. If this problem persists, please contact support.","woocommerce"))}finally{u(!1)}})()}),[e]),{stripeConnectInstance:t,initializationError:c,loading:m}})(e);return(0,d.jsxs)(d.Fragment,{children:[u&&(0,d.jsx)(X,{status:"error",children:u}),m&&(0,d.jsx)(Q.MT,{connectInstance:m,children:(0,d.jsx)(Q.hw,{onLoaderStart:s,onLoadError:n,onExit:t,onStepChange:e=>a?.(e.step),collectionOptions:{fields:c?"eventually_due":"currently_due",futureRequirements:"omit"}})})]})},se=({collectPayoutRequirements:e=!1})=>{var t;const{data:s}=_(),{currentStep:n,navigateToNextStep:a,sessionEntryPoint:c}=(0,i.w)(),[l,m]=(0,o.useState)(!1),[u,p]=(0,o.useState)(!0),[h,g]=(0,o.useState)(null),y=null!==(t=n?.actions?.kyc_fallback?.href)&&void 0!==t?t:"";return(0,d.jsxs)(d.Fragment,{children:[h&&("invalid_request_error"===h.error.type?(0,d.jsx)(X,{className:"woopayments-banner-notice--embedded-kyc",status:"warning",isDismissible:!1,actions:[{label:"Learn more",variant:"primary",url:"https://woocommerce.com/document/woopayments/startup-guide/#requirements",urlTarget:"_blank"},{label:"Cancel",variant:"link",url:y}],children:(0,r.__)("Payment activation through our financial partner requires HTTPS and cannot be completed.","woocommerce")}):(0,d.jsx)(X,{className:"woopayments-banner-notice--embedded-kyc",status:"error",isDismissible:!1,children:h.error.message})),u&&(0,d.jsx)("div",{className:"embedded-kyc-loader-wrapper padded",children:(0,d.jsx)(V.A,{})}),l&&(0,d.jsx)("div",{className:"embedded-kyc-loader-wrapper",children:(0,d.jsx)(V.A,{})}),(0,d.jsx)(te,{onExit:async()=>{m(!0);try{var e;(await(async(e,t)=>await I()({url:e,method:"POST",data:{source:t}}))(null!==(e=n?.actions?.kyc_session_finish?.href)&&void 0!==e?e:"",c)).success?a():window.location.href=y}catch(e){window.location.href=y}},onStepChange:t=>{(0,R.W7)("woopayments_onboarding_modal_kyc_step_change",{kyc_step_id:t,collect_payout_requirements:e,source:c})},onLoaderStart:()=>{(0,R.W7)("woopayments_onboarding_modal_kyc_started_loading",{collect_payout_requirements:e,source:c}),p(!1)},onLoadError:t=>{(0,R.W7)("woopayments_onboarding_modal_kyc_load_error",{error_type:t.error.type,error_message:t.error.message||"no_message",collect_payout_requirements:e,source:c}),g(t)},onboardingData:s,collectPayoutRequirements:e})]})},oe=()=>{const{currentStep:e,sessionEntryPoint:t,refreshStoreData:s}=(0,i.w)(),{nextStep:n}=w(),[r,c]=(0,o.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h1",{className:"stepper__heading",children:O.steps.activate.heading}),(0,d.jsx)("p",{className:"stepper__subheading",children:O.steps.activate.subheading}),(0,d.jsx)("div",{className:"stepper__content",children:(0,d.jsx)(a.Button,{variant:"primary",className:"stepper__cta",onClick:()=>{if((0,R.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",sub_step_id:"activate",action:"activate_payments",source:t}),!e?.actions?.test_account_disable?.href)return n();c(!0),I()({url:e?.actions?.test_account_disable?.href,method:"POST",data:{from:"step_"+(e?.id||"unknown"),source:t}}).then((async()=>(await("function"==typeof s?s():Promise.resolve()),c(!1),n()))).catch((()=>{c(!1)}))},isBusy:r,disabled:r,children:O.steps.activate.cta})})]})},ne=({name:e,children:t,showHeading:s=!0})=>(0,d.jsx)(d.Fragment,{children:(0,d.jsxs)("div",{className:"stepper__wrapper",children:[s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h1",{className:"stepper__heading",children:O.steps[e].heading}),(0,d.jsx)("h2",{className:"stepper__subheading",children:O.steps[e].subheading})]}),(0,d.jsx)("div",{className:"stepper__content",children:t})]})}),re=(0,r.__)("Something went wrong. Please try again.","woocommerce"),ae=()=>{var e,t,s,o;const{currentStep:n,closeModal:l,sessionEntryPoint:m}=(0,i.w)(),u={business_name:window.wcSettings?.siteTitle,mcc:B(null!==(e=n?.context?.fields?.mccs_display_tree)&&void 0!==e?e:[]),site:"localhost"===location.hostname?"https://wcpay.test":window.wcSettings?.homeUrl+D(),country:n?.context?.fields?.location,...null!==(t=n?.context?.self_assessment)&&void 0!==t?t:{}},_=null!==(s=n?.context?.has_test_account)&&void 0!==s&&s,h=null!==(o=n?.context?.has_sandbox_account)&&void 0!==o&&o,g=_||h&&"not_started"===n?.status,w=[...g?["activate"]:[],"business","embedded"].find((e=>"completed"!==n?.context?.sub_steps[e]?.status));return(0,d.jsxs)("div",{className:"settings-payments-onboarding-modal__step-business-verification",children:[(0,d.jsx)(c.A,{onClose:l}),(0,d.jsxs)("div",{className:"settings-payments-onboarding-modal__step-business-verification-content",children:[n?.errors&&n.errors.length>0&&(0,d.jsx)(a.Notice,{status:"error",isDismissible:!1,className:"settings-payments-onboarding-modal__step-business-verification-error",role:"alert",children:n.errors.length<=3?n.errors.map(((e,t)=>{var s,o;return(0,d.jsx)("p",{children:(o=e?.message,"string"==typeof o&&o.trim().length>0?o.trim():re)},null!==(s=e?.code)&&void 0!==s?s:t)})):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{children:(0,r.sprintf)((0,r._n)("%d error occurred during setup.","%d errors occurred during setup.",n.errors.length,"woocommerce"),n.errors.length)}),(0,d.jsx)("p",{children:re})]})}),(0,d.jsx)(p,{initialData:u,children:(0,d.jsxs)(y,{initialStep:w,onStepView:e=>{(0,R.W7)("woopayments_onboarding_modal_step_view",{step:n?.id||"unknown",sub_step_id:e,source:m})},onStepChange:()=>{window.scroll(0,0)},onExit:()=>{(0,R.W7)("woopayments_onboarding_modal_step_exit",{step:n?.id||"unknown",source:m})},onComplete:()=>{(0,R.W7)("woopayments_onboarding_modal_step_complete",{step:n?.id||"unknown",source:m})},children:[g&&(0,d.jsx)(ne,{name:"activate",showHeading:!1,children:(0,d.jsx)(oe,{})}),(0,d.jsx)(ne,{name:"business",children:(0,d.jsx)(z,{children:(0,d.jsx)(U,{})})}),(0,d.jsx)(ne,{name:"embedded",showHeading:!1,children:(0,d.jsx)(se,{})})]})})]})]})}},8148:(e,t,s)=>{s.d(t,{A:()=>l}),s(51609);var o=s(27723),n=s(56427),r=s(99096),a=s(7175),i=s(1069),c=s(39793);const l=()=>{const{context:e,currentStep:t,closeModal:s,sessionEntryPoint:l}=(0,r.w)();return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.A,{onClose:s}),(0,c.jsxs)("div",{className:"settings-payments-onboarding-modal__step--content",children:[t?.errors&&t.errors.length>0&&(0,c.jsx)(n.Notice,{status:"error",isDismissible:!1,className:"settings-payments-onboarding-modal__step--content-finish-error",children:(0,c.jsx)("p",{children:t.errors[0].message})}),(0,c.jsxs)("div",{className:"settings-payments-onboarding-modal__step--content-finish",children:[(0,c.jsx)("h1",{className:"settings-payments-onboarding-modal__step--content-finish-title",children:(0,o.__)("You’re ready to accept payments!","woocommerce")}),(0,c.jsx)("p",{className:"settings-payments-onboarding-modal__step--content-finish-description",children:(0,o.__)("Great news — your WooPayments account has been activated. You can now start accepting payments on your store.","woocommerce")}),(0,c.jsx)(n.Button,{variant:"primary",className:"settings-payments-onboarding-modal__step--content-finish-primary-button",onClick:()=>{var t;(0,i.W7)("woopayments_onboarding_modal_click",{step:"finish",action:"go_to_payments_overview",source:l}),window.location.href=null!==(t=e?.urls?.overview_page)&&void 0!==t?t:""},children:(0,o.__)("Go to Payments Overview","woocommerce")}),(0,c.jsxs)("div",{className:"divider",children:[(0,c.jsx)("span",{className:"divider-line"}),(0,c.jsx)("span",{className:"divider-text",children:(0,o.__)("OR","woocommerce")}),(0,c.jsx)("span",{className:"divider-line"})]}),(0,c.jsx)(n.Button,{variant:"secondary",className:"settings-payments-onboarding-modal__step--content-finish-secondary-button",onClick:()=>{(0,i.W7)("woopayments_onboarding_modal_click",{step:"finish",action:"close_window",source:l}),s()},children:(0,o.__)("Close this window","woocommerce")})]})]})]})}},3511:(e,t,s)=>{s.d(t,{A:()=>y});var o=s(27723),n=s(56427),r=s(83306),a=s(86087),i=s(1455),c=s.n(i),l=s(47804),d=s(4921),m=s(99096),u=s(18537),p=s(12974),_=s(1069),h=s(39793);const g=({method:e,paymentMethodsState:t,setPaymentMethodsState:s,isExpanded:o,initialVisibilityStatus:r,isLoading:i=!1,...c})=>{var l,d,m,g;const y=(0,a.useRef)(null);void 0===r&&null===y.current&&void 0!==t[e.id]&&(y.current=(0,_.TO)(e,t[e.id]));const w=void 0!==r?null!=r&&r:null!==(l=y.current)&&void 0!==l&&l;return o||w?(0,h.jsx)("div",{id:e.id,className:"woocommerce-list__item woocommerce-list__item-enter-done",...c,children:(0,h.jsxs)("div",{className:"woocommerce-list__item-inner",children:["apple_google"!==e.id&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"woocommerce-list__item-before",children:(0,h.jsx)("img",{src:e.icon,alt:e.title+" logo"})}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsx)("span",{className:"woocommerce-list__item-title",children:e.title}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,p.A)((0,u.decodeEntities)(e.description))})]})]}),"apple_google"===e.id&&(0,h.jsxs)("div",{className:"woocommerce-list__item-multi",children:[(0,h.jsxs)("div",{className:"woocommerce-list__item-multi-row multi-row-space",children:[(0,h.jsx)("div",{className:"woocommerce-list__item-before",children:(0,h.jsx)("img",{src:e.icon,alt:e.title+" logo"})}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsx)("span",{className:"woocommerce-list__item-title",children:e.title}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,p.A)((0,u.decodeEntities)(e.description))})]})]}),(0,h.jsxs)("div",{className:"woocommerce-list__item-multi-row",children:[(0,h.jsx)("div",{className:"woocommerce-list__item-before",children:(0,h.jsx)("img",{src:e.extraIcon,alt:e.extraTitle+" logo"})}),(0,h.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,h.jsx)("span",{className:"woocommerce-list__item-title",children:e.extraTitle}),(0,h.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,p.A)((0,u.decodeEntities)(null!==(d=e.extraDescription)&&void 0!==d?d:""))})]})]})]}),(0,h.jsx)("div",{className:"woocommerce-list__item-after",children:(0,h.jsx)("div",{className:"woocommerce-list__item-after__actions wc-settings-prevent-change-event",children:(0,h.jsx)(n.ToggleControl,{checked:null!==(m=t[e.id])&&void 0!==m&&m,onChange:o=>{s({...t,[e.id]:o})},disabled:null!==(g=e.required)&&void 0!==g&&g||i,label:""})})})]})}):null};function y(){const{currentStep:e,navigateToNextStep:t,closeModal:s,sessionEntryPoint:i}=(0,m.w)(),[u,p]=(0,a.useState)(!1),[y,w]=(0,a.useState)({}),[b,x]=(0,a.useState)(null),[v,f]=(0,a.useState)(!1),[j,S]=(0,a.useState)({}),k=e?.context?.pms_state,N=e?.context?.recommended_pms,C=(0,a.useMemo)((()=>N?(0,_.js)(N):[]),[N]),T=(0,a.useRef)(null),[P,F]=(0,a.useState)(!1);(0,a.useEffect)((()=>{k&&w(k)}),[k]);const E=(0,a.useMemo)((()=>(0,_.LI)(y)),[y]);(0,a.useEffect)((()=>{if(null===b&&C.length>0&&Object.keys(E).length>0&&C.every((e=>void 0!==E[e.id]))){const e={};C.forEach((t=>{e[t.id]=(0,_.TO)(t,E[t.id])})),x(e)}}),[C,E,b]);const A=(0,a.useMemo)((()=>!b||u?0:C.filter((e=>{var t;return!(null!==(t=b[e.id])&&void 0!==t&&t)})).length),[C,u,b]),B=(t,s)=>{const o=e?.actions?.save?.href,n={...y};return s&&S((e=>({...e,[s]:!0}))),w(t),o?c()({url:o,method:"POST",data:{payment_methods:t,source:i}}).then((()=>{})).catch((()=>{w(n)})).finally((()=>{s&&S((e=>({...e,[s]:!1})))})):(s&&S((e=>({...e,[s]:!1}))),Promise.resolve())},D=()=>setTimeout((()=>{const e=T.current;if(e){const t=e.scrollHeight>e.clientHeight;F(t)}}),10);return(0,a.useEffect)((()=>{let e=D();const t=()=>{clearTimeout(e),e=D()};return window.addEventListener("resize",t),()=>{clearTimeout(e),window.removeEventListener("resize",t)}}),[u,b]),(0,h.jsx)("div",{className:"settings-payments-onboarding-modal__step--content",children:(0,h.jsxs)("div",{className:"woocommerce-recommended-payment-methods",children:[(0,h.jsxs)("div",{className:"woocommerce-recommended-payment-methods__header",children:[(0,h.jsxs)("div",{className:"woocommerce-recommended-payment-methods__header--title",children:[(0,h.jsx)("h1",{className:"components-truncate components-text",children:(0,o.__)("Choose your payment methods","woocommerce")}),(0,h.jsx)(n.Button,{className:"settings-payments-onboarding-modal__header--close",onClick:s,children:(0,h.jsx)(n.Icon,{icon:l.A})})]}),(0,h.jsx)("div",{className:"woocommerce-recommended-payment-methods__header--description",children:(0,o.__)("Select which payment methods you'd like to offer to your shoppers. You can update these at any time.","woocommerce")})]}),e?.errors&&e.errors.length>0&&(0,h.jsx)(n.Notice,{status:"error",isDismissible:!1,className:"woocommerce-recommended-payment-methods__error",children:(0,h.jsx)("p",{children:e.errors[0].message})}),(0,h.jsx)("div",{className:"woocommerce-recommended-payment-methods__list",children:(0,h.jsxs)("div",{className:"settings-payments-methods__container",ref:T,children:[(0,h.jsx)("div",{className:"woocommerce-list",children:C?.map((e=>{var t,s;return(0,h.jsx)(g,{method:e,paymentMethodsState:(0,_.LI)(y),setPaymentMethodsState:t=>{B(t,e.id)},initialVisibilityStatus:b&&null!==(t=b[e.id])&&void 0!==t?t:null,isExpanded:u,isLoading:null!==(s=j[e.id])&&void 0!==s&&s},e.id)}))}),!u&&A>0&&(0,h.jsx)("div",{className:"settings-payments-methods__show-more--wrapper",children:(0,h.jsx)(n.Button,{className:"settings-payments-methods__show-more",onClick:()=>{(0,_.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",action:"show_more",hidden_count:A,source:i}),p(!u)},tabIndex:0,"aria-expanded":u,children:(0,o.sprintf)((0,o.__)("Show more (%s)","woocommerce"),A)})})]})}),(0,h.jsx)("div",{className:(0,d.A)("woocommerce-recommended-payment-methods__list_footer",{"has-border":P}),children:(0,h.jsx)(n.Button,{className:"components-button is-primary",onClick:()=>{const s=e?.actions?.finish?.href;s&&(f(!0),B(y).then((()=>c()({url:s,method:"POST",data:{source:i}}))).then((()=>{var s;const o=Object.keys(b||{}),n=Object.keys(y),a={displayed_payment_methods:o.join(", "),default_displayed_pms:o.filter((e=>!1!==b?.[e])).join(", "),default_selected_pms:C.filter((e=>e.enabled)).map((e=>e.id)).join(", "),selected_payment_methods:n.filter((e=>y[e])).join(", "),deselected_payment_methods:n.filter((e=>!y[e])).join(", "),business_country:null!==(s=window.wcSettings?.admin?.woocommerce_payments_nox_profile?.business_country_code)&&void 0!==s?s:"unknown",source:i};(0,_.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",action:"continue",...a}),(0,r.recordEvent)("wcpay_settings_payment_methods_continue",a),f(!1),t()})).catch((()=>{f(!1)})))},isBusy:v,disabled:v,children:(0,o.__)("Continue","woocommerce")})})]})})}},33623:(e,t,s)=>{s.d(t,{A:()=>w});var o=s(51609),n=s(1455),r=s.n(n),a=s(85816),i=s(27723),c=s(56427),l=s(96476),d=s(7175),m=s(99096),u=s(56109),p=s(1069),_=s(28239),h=s(39793);const g=({progress:e,title:t,message:s})=>(0,h.jsx)(a.Loader,{className:"woocommerce-payments-test-account-step__preloader",children:(0,h.jsxs)(a.Loader.Layout,{className:"woocommerce-payments-test-account-step__preloader-layout",children:[(0,h.jsx)(a.Loader.Illustration,{children:(0,h.jsx)("img",{src:`${u.GZ}images/onboarding/test-account-setup.svg`,alt:(0,i.__)("Setup","woocommerce"),style:{maxWidth:"223px"}})}),(0,h.jsx)(a.Loader.Title,{children:t||(0,i.__)("Finishing payments setup","woocommerce")}),(0,h.jsx)(a.Loader.ProgressBar,{progress:null!=e?e:0}),(0,h.jsx)(a.Loader.Sequence,{interval:0,children:s||(0,i.__)("In just a few moments, you'll be ready to test payments on your store.","woocommerce")})]})}),y=[(0,i.__)("Setting up your test account","woocommerce"),(0,i.__)("Finishing payments setup","woocommerce"),(0,i.__)("Almost there!","woocommerce")],w=()=>{const{currentStep:e,closeModal:t,setJustCompletedStepId:s,sessionEntryPoint:n,setSnackbar:a}=(0,m.w)(),[u,w]=(0,o.useState)("idle"),[b,x]=(0,o.useState)(20),[v,f]=(0,o.useState)(),[j,S]=(0,o.useState)(0),[k,N]=(0,o.useState)(0),[C,T]=(0,o.useState)(y[0]),[P,F]=(0,o.useState)(!1),[E,A]=(0,o.useState)(),B=(0,o.useRef)(null),D=(0,o.useRef)(null),L=(0,o.useRef)(null),I=(0,o.useRef)(0);(0,o.useEffect)((()=>{if("success"===u&&(0,p.W7)("woopayments_onboarding_modal_step_view",{step:e?.id||"unknown",sub_step_id:"ready_to_test_payments",source:n}),"polling"!==u&&"initializing"!==u)return void(I.current=0);0===I.current&&T(y[0]);const t=setTimeout((()=>{I.current+=1,I.current<y.length&&T(y[I.current])}),5e3);return()=>{clearTimeout(t)}}),[u]);const W=()=>{null!==B.current&&(clearTimeout(B.current),B.current=null),null!==L.current&&(clearTimeout(L.current),L.current=null)},O=(0,o.useCallback)((()=>{w("idle"),x(0),f(void 0),S(0),D.current=null,W()}),[w,x,f,S]);(0,o.useEffect)((()=>{if("idle"===u){if("completed"===e?.status)return w("success"),s(e.id),void x(100);if("blocked"===e?.status)return f(e?.errors?.[0]?.message||(0,i.__)("There are environment or store setup issues which are blocking progress. Please resolve them to proceed.","woocommerce")),void w("blocked");"not_started"===e?.status||"failed"===e?.status?(w("initializing"),x(10),(async()=>{e?.actions?.clean?.href&&(k>0||"failed"===e?.status)&&await r()({url:e?.actions?.clean?.href,method:"POST"})})().then((()=>r()({url:e?.actions?.init?.href,method:"POST",data:{source:n}}))).then((e=>{e?.success?w("polling"):(A(e?.code||""),f(e?.message||(0,i.__)("Creating test account failed. Please try again.","woocommerce")),w("error"))})).catch((e=>{A(e?.code||""),f(e.message),w("error")}))):w("polling")}if("polling"===u){const t=()=>{W(),r()({url:e?.actions?.check?.href,method:"POST"}).then((o=>{if("completed"===o?.status)return void(B.current=window.setTimeout((()=>{w("success"),x(100),s(e?.id||"")}),1e3));let n,r,a=0;x((e=>(a=0===j?Math.min(e+5,90):1===j?Math.min(e+1,96):e,a))),0===j&&a>=90?(n=1,r=5e3,D.current=Date.now()):1===j?D.current&&Date.now()-D.current>3e4?(n=2,r=7e3):(n=1,r=5e3):2===j?(n=2,r=7e3):(n=0,r=3e3),S(n),B.current=window.setTimeout(t,r)})).catch((e=>{f(e.message),w("error"),W()}))};t()}return"initializing"===u&&null===L.current&&(L.current=window.setInterval((()=>{x((e=>e<30?Math.min(e+2,30):e))}),1e3)),"initializing"!==u&&null!==L.current&&(clearTimeout(L.current),L.current=null),()=>{W()}}),[u,e,k,j,s]),(0,o.useEffect)((()=>{"success"===u&&(0,l.navigateTo)({url:(0,l.getNewPath)({nox:"test_account_created"},"",{page:"wc-admin"})})}),[u]);const M="woocommerce_woopayments_test_account_already_exists"===E?[{label:(0,i.__)("Reset Account","woocommerce"),variant:"secondary",onClick:()=>{F(!0)}}]:[{label:(0,i.__)("Try Again","woocommerce"),variant:"primary",onClick:()=>{(0,p.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",action:"try_again_on_error",retries:k+1,source:n}),O(),N((e=>e+1))}},{label:(0,i.__)("Cancel","woocommerce"),variant:"secondary",className:"woocommerce-payments-test-account-step__error-cancel-button",onClick:()=>{(0,p.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",action:"cancel_on_error",retries:k,source:n}),t()}}];return(0,h.jsxs)("div",{className:"woocommerce-payments-test-account-step",children:[(0,h.jsx)(d.A,{onClose:t}),("error"===u||"blocked"===u)&&(0,h.jsx)(c.Notice,{status:"blocked"===u?"error":"warning",isDismissible:!1,actions:"blocked"!==u?M:[],className:"woocommerce-payments-test-account-step__error",children:(0,h.jsx)("p",{className:"woocommerce-payments-test-account-step__error-message",children:v||(0,i.__)("An error occurred while creating your test account. Please try again.","woocommerce")})}),("initializing"===u||"polling"===u||"success"===u)&&(0,h.jsx)(g,{progress:b,title:C,message:(R=j,1===R?(0,i.__)("The test account creation is taking a bit longer than expected, but don't worry — we're on it! Please bear with us for a few seconds more as we set everything up for your store.","woocommerce"):2===R?(0,i.__)("Thank you for your patience! Unfortunately, the test account creation is taking a bit longer than we anticipated. But don't worry — we won't give up! Feel free to close this modal and check back later. We appreciate your understanding!","woocommerce"):void 0)}),(0,h.jsx)(_.Mk,{isOpen:P,onClose:()=>{F(!1),a({show:!0,message:(0,i.__)("Your test account was successfully reset.","woocommerce")})},isEmbeddedResetFlow:!0,resetUrl:e?.actions?.reset?.href})]});var R}},59530:(e,t,s)=>{s.d(t,{A:()=>g});var o=s(51609),n=s(27723),r=s(36849),a=s(56427),i=s(98846),c=s(1455),l=s.n(c),d=s(7175),m=s(99096),u=s(56109),p=s(1069),_=s(75854),h=s(39793);const g=()=>{const{closeModal:e,currentStep:t,sessionEntryPoint:s,navigateToNextStep:c,refreshStoreData:g,getStepByKey:y}=(0,m.w)(),[w,b]=(0,o.useState)(!1),x=y(_.CX)?.actions,v=x?.finish?.href;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.A,{onClose:e}),(0,h.jsx)("div",{className:"settings-payments-onboarding-modal__step--content",children:(0,h.jsx)("div",{className:"woocommerce-payments-test-or-live-account-step__success_content_container",children:(0,h.jsxs)("div",{className:"woocommerce-woopayments-modal__content woocommerce-payments-test-or-live-account-step__success_content",children:[(0,h.jsx)("h1",{className:"woocommerce-payments-test-or-live-account-step__success_content_title",children:(0,n.__)("You're almost there — time to activate payments!","woocommerce")}),(0,h.jsx)("div",{className:"woocommerce-woopayments-modal__content__item",children:(0,h.jsx)("div",{className:"woocommerce-woopayments-modal__content__item__description",children:(0,h.jsx)("p",{children:(0,n.__)("Activate payments to accept real orders and process transactions.","woocommerce")})})}),t?.errors&&t.errors.length>0&&(0,h.jsx)(a.Notice,{status:"error",isDismissible:!1,className:"woocommerce-payments-test-or-live-account-step__error",role:"alert",children:(0,h.jsx)("p",{children:t.errors[0]?.message||(0,n.__)("Something went wrong. Please try again.","woocommerce")})}),(0,h.jsxs)("div",{className:"woocommerce-payments-test-or-live-account-step__success-whats-next",children:[(0,h.jsxs)("div",{className:"woocommerce-woopayments-modal__content__item-flex",children:[(0,h.jsx)("img",{src:u.GZ+"images/icons/dollar.svg",alt:"",role:"presentation"}),(0,h.jsxs)("div",{className:"woocommerce-woopayments-modal__content__item-flex__description",children:[(0,h.jsx)("h3",{children:(0,n.__)("Activate real payments","woocommerce")}),(0,h.jsx)("div",{children:(0,r.A)({mixedString:(0,n.__)("Provide some additional details about your business to process real transactions. {{link}}Learn more{{/link}}","woocommerce"),components:{link:(0,h.jsx)(i.Link,{href:"https://woocommerce.com/document/woopayments/startup-guide/#sign-up-process",target:"_blank",rel:"noreferrer",type:"external"})}})})]})]}),(0,h.jsx)(a.Button,{variant:"primary",onClick:()=>{if(b(!0),(0,p.W7)("woopayments_onboarding_modal_click",{step:t?.id||"unknown",action:"activate_payments",source:s}),v){const e=x?.finish?.href;e&&l()({url:e,method:"POST"}).then((()=>{b(!1),g()})).catch((()=>{b(!1)}))}else{const e=y(_.kE),t=e?.actions?.start?.href;t&&l()({url:t,method:"POST"}).then((()=>{b(!1),g()})).catch((()=>{b(!1)}))}},isBusy:w,disabled:w,children:(0,n.__)("Start accepting payments","woocommerce")}),v&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"woocommerce-payments-test-or-live-account-step__success_content_or-divider",children:[(0,h.jsx)("hr",{}),(0,n.__)("OR","woocommerce"),(0,h.jsx)("hr",{})]}),(0,h.jsxs)("div",{className:"woocommerce-woopayments-modal__content__item-flex",children:[(0,h.jsx)("img",{src:u.GZ+"images/icons/post-list.svg",alt:"",role:"presentation"}),(0,h.jsxs)("div",{className:"woocommerce-woopayments-modal__content__item-flex__description",children:[(0,h.jsx)("h3",{children:(0,n.__)("Test payments first, activate later","woocommerce")}),(0,h.jsx)("div",{children:(0,h.jsx)("p",{children:(0,r.A)({mixedString:(0,n.__)("A test account will be created for you to {{link}}test payments on your store{{/link}}. You'll need to activate payments later to process real transactions.","woocommerce"),components:{link:(0,h.jsx)(i.Link,{href:"https://woocommerce.com/document/woopayments/testing-and-troubleshooting/test-accounts/",target:"_blank",rel:"noreferrer",type:"external"})}})})})]})]}),(0,h.jsx)(a.Button,{variant:"secondary",disabled:w,onClick:()=>{c()},children:(0,n.__)("Test payments","woocommerce")})]})]})]})})})]})}},10432:(e,t,s)=>{s.d(t,{A:()=>u}),s(51609);var o=s(27723),n=s(56427),r=s(86087),a=s(1455),i=s.n(a),c=s(99096),l=s(7175),d=s(1069),m=s(39793);const u=()=>{const{currentStep:e,closeModal:t,sessionEntryPoint:s}=(0,c.w)(),[a,u]=(0,r.useState)(!1);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.A,{onClose:t}),e?.errors&&e.errors.length>0&&(0,m.jsx)(n.Notice,{status:"error",isDismissible:!1,className:"settings-payments-onboarding-modal__step-jetpack-error",role:"alert",children:(0,m.jsx)("p",{children:e.errors[0]?.message||(0,o.__)("Something went wrong. Please try again.","woocommerce")})}),(0,m.jsx)("div",{className:"settings-payments-onboarding-modal__step--content",children:(0,m.jsxs)("div",{className:"settings-payments-onboarding-modal__step--content-jetpack",children:[(0,m.jsx)("h1",{className:"settings-payments-onboarding-modal__step--content-jetpack-title",children:(0,o.__)("Connect to WordPress.com","woocommerce")}),(0,m.jsx)("p",{className:"settings-payments-onboarding-modal__step--content-jetpack-description",children:(0,o.__)("You’ll be briefly redirected to connect your store to your WordPress.com account and unlock the full features and functionality of WooPayments","woocommerce")}),(0,m.jsx)(n.Button,{variant:"primary",className:"settings-payments-onboarding-modal__step--content-jetpack-button",isBusy:a,disabled:a,onClick:()=>{var t;u(!0);const o=e?.actions?.start?.href;o&&i()({url:o,method:"POST",data:{source:s}}),(0,d.W7)("woopayments_onboarding_modal_click",{step:e?.id||"unknown",action:"connect_to_wpcom",source:s}),window.location.href=null!==(t=e?.actions?.auth?.href)&&void 0!==t?t:""},children:(0,o.__)("Connect","woocommerce")})]})})]})}}}]);