"use strict";(globalThis.webpackChunkgoogle_listings_and_ads=globalThis.webpackChunkgoogle_listings_and_ads||[]).push([[553],{521:(e,s,n)=>{n.d(s,{A:()=>r});var t=n(7143),a=n(6520),i=n(7692),o=n(2775);const l="products",g={products:[],intervals:[],totals:{}};function r(e){const s=(0,o.A)();return(0,t.useSelect)(n=>{const{getReport:t}=n(a.Ui),o=t(l,e,s,"primary"),r=t(l,e,s,"secondary"),d=o.loaded&&r.loaded;let u=g;return d&&o.data&&r.data&&(u={products:o.data.products||g.products,intervals:o.data.intervals||g.intervals,totals:(0,i.bM)(o.data.totals,r.data.totals,o.reportQuery.fields)}),{data:u,loaded:d}},[e,s])}},6343:(e,s,n)=>{n.r(s),n.d(s,{default:()=>T});var t=n(6087),a=n(6427),i=n(7723),o=n(8468),l=n(7651),g=n(9927),r=n(8476),d=n(7892),u=n(9457);const c={confirmationModal:"_GQ4sGfGTeKA7JPcBsrS"};var h=n(4848);function _({onContinue:e,onRequestClose:s}){return(0,h.jsxs)(u.A,{className:c.confirmationModal,title:(0,i.__)("Before you save…","google-listings-and-ads"),buttons:[(0,h.jsx)(d.A,{isSecondary:!0,onClick:s,children:(0,i.__)("Don't save","google-listings-and-ads")},"cancel"),(0,h.jsx)(d.A,{isPrimary:!0,onClick:e,children:(0,i.__)("Continue to save","google-listings-and-ads")},"continue")],onRequestClose:s,children:[(0,h.jsx)("p",{children:(0,i.__)("Results typically improve with time.","google-listings-and-ads")}),(0,h.jsx)("p",{children:(0,i.__)("Changes will result in the loss of any optimisations learned over time.","google-listings-and-ads")}),(0,h.jsx)("p",{children:(0,i.__)("We recommend allowing your listings to run for at least 14 days after set up without changing them for optimal performance.","google-listings-and-ads")})]})}var p=n(5847),v=n(873),m=n(1650),S=n(6523),f=n(5622),A=n(5640),y=n(4716),C=n(1826),w=n(5807),j=n(8606),x=n(4772),b=n(6876),R=n(100);function T(){const{loaded:e,targetAudience:s,getFinalCountries:n}=(0,p.A)(),{settings:d,saveSettings:u,syncSettings:c}=(0,v.A)(),{saveTargetAudience:T}=(0,l.j)(),{saveShippingRates:q}=(0,C.A)(),{saveShippingTimes:E}=(0,w.A)(),[k,F]=(0,t.useState)(s),[M,G]=(0,t.useState)(d),{hasFinishedResolution:P,data:B}=(0,S.A)(),[N,Q]=(0,t.useState)(B),{hasFinishedResolution:U,data:Y}=(0,f.A)(),[D,J]=(0,t.useState)(Y),[K,L]=(0,t.useState)(null);(0,t.useEffect)(()=>G(d),[d]),(0,t.useEffect)(()=>F(s),[s]),(0,t.useEffect)(()=>Q(B),[B]),(0,t.useEffect)(()=>J(Y),[Y]);const{createNotice:W}=(0,A.A)(),z=!(0,o.isEqual)(...[k,s].map(e=>({...e,countries:new Set(e?.countries)}))),H=!(0,o.isEqual)(M,d),I=(V=B,(O=N).length!==V.length||(0,y.A)(O,V).length>0);var O,V;const X=!(0,o.isEqual)(new Set(D),new Set(Y)),Z=z||H||I||X;(0,m.A)((0,i.__)("You have unsaved changes. Are you sure you want to leave?","google-listings-and-ads"),Z);const $=k?.countries?k:null,ee=M?.shipping_rate?M:null,se=P?B:{},ne=U?Y:{},te=e&&P&&U;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.A,{}),(0,h.jsx)(g.A,{}),te&&(0,h.jsx)(r.A,{targetAudience:$,resolveFinalCountries:n,onTargetAudienceChange:F,settings:ee,onSettingsChange:G,shippingRates:se,onShippingRatesChange:Q,shippingTimes:ne,onShippingTimesChange:J,onRequestSubmit:()=>new Promise(e=>{L(()=>s=>{e(s),L(null)})}),onContinue:async()=>{try{const e=[T(k),u(M),q(N),E(D)],s=await(0,j.A)(e,[(0,i.__)("Target audience","google-listings-and-ads"),(0,i.__)("Merchant Center Settings","google-listings-and-ads"),(0,i.__)("Shipping rates","google-listings-and-ads"),(0,i.__)("Shipping times","google-listings-and-ads")]);await c(),s?W("error",s):W("success",(0,i.__)("Your changes have been saved and will be synced to your Google Merchant Center account.","google-listings-and-ads")),(0,R.ce)("gla_free_campaign_edited")}catch(e){(0,b.hS)(e,(0,i.__)("Unable to save your changes.","google-listings-and-ads"),(0,i.__)("Something went wrong while saving your changes. Please try again later.","google-listings-and-ads"))}},submitLabel:(0,i.__)("Save changes","google-listings-and-ads")}),(0,h.jsx)(a.Flex,{justify:"flex-end",children:(0,h.jsx)(r.A.SubmitButton,{})}),K&&(0,h.jsx)(_,{onContinue:()=>K(!0),onRequestClose:()=>K(!1)})]})}}}]);