"use strict";(globalThis.webpackChunkgoogle_listings_and_ads=globalThis.webpackChunkgoogle_listings_and_ads||[]).push([[663],{923:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Q});var s=n(6474),o=n(6476),a=n(7723),i=n(7539),l=n(2455),c=n(100),r=n(4848);const u=()=>(0,r.jsx)(i.A,{title:(0,a.__)("Set up your campaign","google-listings-and-ads"),helpButton:(0,r.jsx)(l.A,{eventContext:"setup-ads"}),backHref:(0,o.getNewPath)({},"/google/dashboard"),onBackButtonClick:()=>{(0,c.ce)("gla_setup_ads",{triggered_by:"back-button",action:"leave"})}});var d=n(8846),g=n(6087),_=n(7892),h=n(9370),p=n(3164),A=n(3704),x=n(9826),j=n(8678),y=n(458),m=n(1378),b=n(8e3),C=n(3741),k=n(8242),v=n(1351);const f=e=>{const{onContinue:t=()=>{}}=e,{google:n}=(0,b.A)(),{googleAdsAccount:s}=(0,m.A)(),{isLinkedToMerchantCenter:o}=(0,v.A)();if(!n||"yes"===n.active&&!s)return(0,r.jsx)(C.A,{});const i=!o;return(0,r.jsxs)(h.A,{children:[(0,r.jsx)(p.A,{title:(0,a.__)("Set up your accounts","google-listings-and-ads"),description:(0,a.__)("Connect your Google account and your Google Ads account to set up a Performance Max campaign.","google-listings-and-ads")}),(0,r.jsxs)(k.A,{title:(0,a.__)("Connect accounts","google-listings-and-ads"),description:(0,a.__)("Any campaigns created through this app will appear in your Google Ads account. You will be billed directly through Google.","google-listings-and-ads"),children:[(0,r.jsx)(j.Az,{googleAccount:n,hideAccountSwitch:!0,helper:(0,a.__)("This Google account is connected to your store’s product feed.","google-listings-and-ads")}),(0,r.jsx)(y.Ay,{})]}),(0,r.jsx)(x.A,{children:(0,r.jsx)(A.A,{children:(0,r.jsx)(_.A,{isPrimary:!0,disabled:i,onClick:t,children:(0,a.__)("Continue","google-listings-and-ads")})})})]})};var S=n(7541),w=n(5992),B=n(2581),P=n(8331),T=n(6893),G=n(1968),F=n(1650),R=n(5847),N=n(8519),E=n(6960),V=n(3323),D=n(3905),M=n(2280);const{APPROVED:Y}=D.CX;function z(){const{isDirty:e,adapter:t}=(0,E.h5)(),n=e&&!t.isSubmitted;return(0,F.A)((0,a.__)("You have unsaved campaign data. Are you sure you want to leave?","google-listings-and-ads"),n),null}const H=()=>{const e=(0,g.useRef)(),{billingStatus:t}=(0,T.A)(),[n,s]=(0,N.A)(),i=(0,G.A)(),{data:l}=(0,R.A)(),{handleError:u}=(0,M.A)(),d=(0,S.A)(c.eB);return l?(0,r.jsxs)(V.A,{countryCodes:l,onSubmit:e=>{const{level:t,dailyBudget:s,hasConfirmedEuPoliticalContent:a}=e;(0,c.ce)("gla_launch_paid_campaign_button_click",d({level:t,audiences:l.join(","),budget:s,has_confirmed_eu_political_content:a})),n(s,l,a,()=>{const e=(0,o.getNewPath)({guide:"campaign-creation-success"},"/google/dashboard");window.location.href=i+e}).catch(e=>{u(e)})},children:[(0,r.jsx)(z,{}),(0,r.jsx)(B.A,{headerTitle:(0,a.__)("Create your campaign","google-listings-and-ads"),context:"setup-ads",continueButton:n=>(0,r.jsx)(_.A,{variant:"primary",text:(0,a.__)("Create campaign","google-listings-and-ads"),disabled:!n.isValidForm||t?.status!==Y,loading:s,onClick:()=>{e.current.resolve(n.values.dailyBudget).then(e=>{null===e?n.handleSubmit():Number.isFinite(e)&&n.setValues({level:"custom",amount:e})})}})}),(0,r.jsx)(P.A,{ref:e,countryCodes:l})]}):(0,r.jsx)(C.A,{})};var L=n(1414);const O=()=>{const[e,t]=(0,g.useState)("1"),n=(0,g.useRef)(null),{hasFinishedResolution:s,hasGoogleAdsConnection:o}=(0,m.A)(),{hasAccess:i,hasFinishedResolution:l,step:u}=(0,w.A)();if((0,S.A)(c.T1,{context:c.lr,step:e}),null===n.current){if(!s||!l)return(0,r.jsx)(C.A,{});const e=o&&!0===i&&"conversion_action"!==u;n.current=e}const _=n=>{n<e&&((0,c.T)("gla_setup_ads",n),t(n))};let h=[{key:"1",label:(0,a.__)("Set up your accounts","google-listings-and-ads"),content:(0,r.jsx)(f,{onContinue:()=>{(()=>{const n=e;(0,c.dQ)("gla_setup_ads",n,"2"),t("2")})()}}),onClick:_},{key:"2",label:(0,a.__)("Create your campaign","google-listings-and-ads"),content:(0,r.jsx)(L.A,{context:c.lr,children:(0,r.jsx)(H,{})}),onClick:_}];return n.current&&(h.shift(),h=h.map((e,t)=>({...e,key:(t+1).toString()}))),(0,r.jsx)(d.Stepper,{className:"gla-setup-stepper",currentStep:e,steps:h})},Q=()=>((0,s.A)("full-page"),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u,{}),(0,r.jsx)(O,{})]}))}}]);