(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,59002,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getAccountAddressUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/account/address",query:{experience:e.experience}}},a.getPaymentMethodsUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/account/payment-methods",query:{experience:e.experience}}}},535260,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getAccountAddress=i;let s=e.r(678651),r=e.r(414655),n=e.r(59002);async function i(e){let t=(0,n.getAccountAddressUrlConfig)(e),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},653462,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getPaymentMethods=i;let s=e.r(678651),r=e.r(414655),n=e.r(59002);async function i(e){let t=(0,n.getPaymentMethodsUrlConfig)(e),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},108471,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getBillingPreviewUrlConfig=function(e){let t={experience:e.experience,productId:e.productIds,soldCity:e.soldCity||"",soldState:e.soldState||"",soldPostalCode:e.soldPostalCode||"",promoCode:e.promoCode||""};return void 0!==e.isContinuousOrder&&(t.isContinuousOrder=e.isContinuousOrder.toString()),{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/preview",query:t}},a.getPromoCodeValidationUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/promo/validate",query:{productIds:e.productIds,promoCode:e.promoCode,experience:e.experience}}},a.getProductSummaryUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/catalog/summary",query:{productIds:e.productIds,experience:e.experience}}},a.getPaymentDetailsUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/payments",query:{paymentMethodId:e.refId,experience:e.experience}}},a.getCheckoutValidateUrlConfig=function(e){let t={experience:e.experience,productIds:e.productIds};return void 0!==e.isContinuousOrder&&(t.isContinuousOrder=e.isContinuousOrder.toString()),{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/validate",query:t}},a.getSubscriptionCallbackUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/subscription-callback",query:{experience:e.experience}}}},165799,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getCheckoutValidate=i;let s=e.r(678651),r=e.r(414655),n=e.r(108471);async function i(e){let t=(0,n.getCheckoutValidateUrlConfig)(e),a=(0,s.urlFrom)(t),i="u">typeof document?document.getElementById("JWT")?.getAttribute("token"):void 0,l=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json",...i&&{token:i}}});if(400===l.status)throw Error((await l.json()).error);return(0,r.handleFetchTextResponse)(l)}},702972,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getAddressSearchUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/address-query/search",query:{query:e.query,experience:e.experience}}},a.getAddressFormatUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/address-query/format",query:{key:e.key,experience:e.experience}}}},456843,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.searchAddress=i;let s=e.r(678651),r=e.r(414655),n=e.r(702972);async function i(e){let t=(0,n.getAddressSearchUrlConfig)(e),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},255502,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.formatAddress=i;let s=e.r(678651),r=e.r(414655),n=e.r(702972);async function i(e){let t=(0,n.getAddressFormatUrlConfig)(e),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},384790,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getRsaSignatureUrlConfig=function(e){return{host:"weather.com",protocol:"https",pathname:"/api/v1/subs/checkout/hostedpages",query:{reqPageId:e}}},a.getHPPCallbackUrlConfig=function(){return{host:"weather.com",protocol:"https",pathname:"/subscribe/checkout/callback"}}},571917,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getRsaSignature=i;let s=e.r(678651),r=e.r(414655),n=e.r(384790);async function i(e){let t=(0,n.getRsaSignatureUrlConfig)(e.pageId),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},502145,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getPaymentDetails=i;let s=e.r(678651),r=e.r(414655),n=e.r(108471);async function i(e){let t=(0,n.getPaymentDetailsUrlConfig)(e),a=(0,s.urlFrom)(t),i=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});return(0,r.handleFetchResponse)(i)}},58371,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.submitCheckout=i;let s=e.r(678651),r=e.r(414655),n=e.r(108471);async function i(e,t){let a=(0,n.getSubscriptionCallbackUrlConfig)({experience:t}),i=(0,s.urlFrom)(a),l=await fetch(i,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return(0,r.handleFetchResponse)(l)}},386203,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.getBillingPreview=i;let s=e.r(678651),r=e.r(414655),n=e.r(108471);async function i(e){let t=(0,n.getBillingPreviewUrlConfig)(e),a=(0,s.urlFrom)(t),i="u">typeof document?document.getElementById("JWT")?.getAttribute("token"):void 0,l=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json",...i&&{token:i}}});return(0,r.handleFetchResponse)(l)}},341205,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.validatePromoCode=i;let s=e.r(678651),r=e.r(414655),n=e.r(108471);async function i(e){let t=(0,n.getPromoCodeValidationUrlConfig)(e),a=(0,s.urlFrom)(t),i="u">typeof document?document.getElementById("JWT")?.getAttribute("token"):void 0,l=await fetch(a,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json",...i&&{token:i}}});return(0,r.handleFetchResponse)(l)}},649319,e=>{"use strict";var t=e.i(297647),a=e.i(475566),s=e.i(477716),r=e.i(737801),n=e.i(381477),i=e.i(901351),l=e.i(889753),o=e.i(310847),d=e.i(731672),c=e.i(535260),u=e.i(653462);let m={al:"Alabama",ak:"Alaska",as:"American Samoa",az:"Arizona",ar:"Arkansas",ca:"California",co:"Colorado",ct:"Connecticut",de:"Delaware",dc:"Washington DC",fm:"Federated States Of Micronesia",fl:"Florida",ga:"Georgia",gu:"Guam",hi:"Hawaii",id:"Idaho",il:"Illinois",in:"Indiana",ia:"Iowa",ks:"Kansas",ky:"Kentucky",la:"Louisiana",me:"Maine",mh:"Marshall Islands",md:"Maryland",ma:"Massachusetts",mi:"Michigan",mn:"Minnesota",ms:"Mississippi",mo:"Missouri",mt:"Montana",ne:"Nebraska",nv:"Nevada",nh:"New Hampshire",nj:"New Jersey",nm:"New Mexico",ny:"New York",nc:"North Carolina",nd:"North Dakota",mp:"Northern Mariana Islands",oh:"Ohio",ok:"Oklahoma",or:"Oregon",pw:"Palau",pa:"Pennsylvania",pr:"Puerto Rico",ri:"Rhode Island",sc:"South Carolina",sd:"South Dakota",tn:"Tennessee",tx:"Texas",ut:"Utah",vt:"Vermont",vi:"Virgin Islands",va:"Virginia",wa:"Washington",wv:"West Virginia",wi:"Wisconsin",wy:"Wyoming"},h={"united states":"USA","united states of america":"USA",usa:"USA",us:"USA",canada:"CA",mexico:"MX"},p=()=>Object.entries(m).map(([e,t])=>({value:t,label:`${t} (${e.toUpperCase()})`})),x={shouldRetryOnError:e=>"APIError"!==e.name,revalidateOnFocus:!1,revalidateOnReconnect:!1};var f=e.i(165799),g=e.i(499239),y=e.i(920654),v=e.i(352194),b=e.i(118119),j=e.i(264268),C=e.i(877957),w=e.i(368847),N=e.i(983950),P=e.i(528600),S=e.i(526824);let A=({initSignin:e})=>{let[a,r]=(0,s.useState)(e),n=(0,v.useTranslations)("UserAuth"),{user:i,userProfile:l}=(0,P.useUser)(),{email:o,firstName:c}=l||{},u=(0,d.useUserLogout)(),{userLastName:m}=(0,S.useUserLastName)();return i?.isUserLoggedIn?(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-6 flex items-end justify-between gap-1",children:[(0,t.jsx)(w.Text,{variant:"Title.M",color:"secondary",className:"font-semibold",children:n("yourAccount")}),(0,t.jsx)(C.Button,{variant:"link",type:"button",className:(0,w.textVariants)({className:"h-[revert] p-0",variant:"Body.M"}),onClick:()=>u(),children:n("logout")})]}),(0,t.jsxs)(w.Text,{color:"secondary",children:[c," ",m]}),(0,t.jsx)(w.Text,{color:"secondary",children:o})]}):(0,t.jsx)("div",{children:a?(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-4 flex justify-between",children:[(0,t.jsx)(w.Text,{variant:"Title.M",className:"font-semibold",children:n("signin")}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(w.Text,{color:"secondary",children:[n("noAccount")," "]}),(0,t.jsx)(C.Button,{variant:"link",type:"button",className:(0,w.textVariants)({className:"h-[revert] p-0",variant:"Body.M",color:"secondary"}),onClick:()=>r(!1),children:n("signup")})]})]}),(0,t.jsx)(b.default,{loginBtnText:n("signinAndContinue")})]}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(w.Text,{className:"mb-2",children:n("haveAccount")}),(0,t.jsxs)("div",{className:"flex justify-center gap-4",children:[(0,t.jsx)(C.Button,{variant:"secondary",className:"bg-gray-100",onClick:()=>r(!0),children:n("signin")}),(0,t.jsx)(N.default,{text:"signin_with",shape:"pill"})]})]}),(0,t.jsxs)("div",{className:"relative my-6",children:[(0,t.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,t.jsx)("div",{className:"w-full border-t border-gray-300"})}),(0,t.jsx)("div",{className:"relative flex justify-center text-sm",children:(0,t.jsx)("span",{className:"bg-white px-2 text-gray-500 uppercase",children:n("or")})})]}),(0,t.jsx)(w.Text,{variant:"Title.M",className:"mb-4 font-semibold",children:n("signup")}),(0,t.jsx)(j.default,{signupBtnText:n("signupAndContinue")})]})})};var k=e.i(671525),E=e.i(990420),I=e.i(666021),L=e.i(825440),D=e.i(632137);let M=({open:e,children:a,onClose:r})=>{let n=(0,s.useRef)(null);return((0,s.useEffect)(()=>{if(!e)return;let t=e=>{n.current&&!n.current.contains(e.target)&&r()},a=e=>{if(!n.current)return;let t=Array.from(n.current.querySelectorAll("button:not([disabled])"));switch(e.key){case"Escape":e.preventDefault(),r();break;case"ArrowDown":{e.preventDefault();let a=t.findIndex(e=>e===document.activeElement),s=ae===document.activeElement),s=a>0?a-1:t.length-1;t[s]?.focus();break}case"Home":e.preventDefault(),t[0]?.focus();break;case"End":{e.preventDefault();let a=t.length-1;t[a]?.focus()}}};return document.addEventListener("mousedown",t),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",a)}},[e,r]),e)?(0,t.jsx)("div",{ref:n,className:"absolute top-full left-0 -mt-6 max-h-60 w-full overflow-y-auto rounded-lg bg-white p-4 whitespace-normal shadow-[0_2px_12px_0_rgba(0,0,0,0.2)]",role:"menu",children:a}):null},R=(0,s.forwardRef)(({buttonCaption:e,buttonCaptionClassName:a,buttonCaptionLineClamp:r,children:n,options:i=[],selectedIndex:l,selectedValue:o,onSelect:d,onChange:c,value:u,name:m,...h},p)=>{let x=(0,s.useRef)(null),[f,g]=(0,s.useState)(!1),[y,v]=(0,s.useState)(void 0!==l&&i[l]?.value||""),b=()=>g(!f),j=u??o??y,C=i.find(e=>e.value===j),w=C?.label||j,N=e=>{void 0===u&&void 0===o&&v(e.value),c&&c({target:{value:e.value,name:m}}),d?.(e)};return(0,t.jsxs)("div",{ref:x,className:(0,D.cn)("relative inline-block w-full",h.className),children:[(0,t.jsx)(L.Input,{...h,name:m,onClick:b,value:w,readOnly:!0,onChange:()=>{}}),(0,t.jsx)("input",{...h,type:"hidden",name:m,value:j,ref:p}),(0,t.jsx)(M,{open:f,onClose:b,children:n&&"function"==typeof n?n(b):i.map((e,a)=>(0,t.jsx)(T,{option:e,selected:l===a,onSelect:N,toggleHandler:b},`${e.label}_${e.value}`))})]})});R.displayName="Dropdown";let T=({option:e,onSelect:a=()=>{},toggleHandler:s})=>{let{disabled:r}=e;return(0,t.jsx)("button",{onClick:()=>{a(e),s()},className:(0,D.cn)("relative box-border flex w-full items-center rounded-sm px-2 py-2 text-left text-sm whitespace-nowrap no-underline outline-0 hover:bg-[#252422] hover:text-white focus:bg-[#252422] focus:text-white disabled:bg-gray-600 disabled:text-gray-200","not-last:mb-[3px]"),disabled:r,role:"menuitem",children:e.label})};var F=e.i(873236);F.z.object({email:F.z.string().email("Invalid email address"),password:F.z.string().min(8,"Password must be at least 8 characters")}),F.z.object({firstName:F.z.string().optional(),lastName:F.z.string().optional(),email:F.z.string().email("Invalid email address"),password:F.z.string().min(8,"Password must be at least 8 characters"),confirmPassword:F.z.string().optional(),morningBrief:F.z.boolean().optional(),weatherChannelEmails:F.z.boolean().optional(),agreeToTerms:F.z.boolean().refine(e=>!0===e,{message:"You must agree to the terms"})}).refine(e=>!e.confirmPassword||e.password===e.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]});let U=F.z.object({firstName:F.z.string().min(1,"First name is required"),lastName:F.z.string().min(1,"Last name is required"),addressLine1:F.z.string().min(1,"Address is required"),addressLine2:F.z.string().optional(),city:F.z.string().min(1,"City is required"),state:F.z.string().min(1,"State/Province is required"),postalCode:F.z.string().min(1,"Postal code is required"),country:F.z.string().min(1,"Country is required")});var _=e.i(723356),O=e.i(274432),$=e.i(747961);let B=(0,s.forwardRef)(({title:e,titleId:a,desc:s,descId:r,...n},i)=>(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",ref:i,"aria-labelledby":a,"aria-describedby":r,...n,children:[s?(0,t.jsx)("desc",{id:r,children:s}):null,void 0===e?(0,t.jsx)("title",{id:a,children:"Map"}):e?(0,t.jsx)("title",{id:a,children:e}):null,(0,t.jsxs)("g",{fill:"currentColor",children:[(0,t.jsx)("path",{d:"M8 12 4.955 7.7A4.07 4.07 0 0 1 8 1a4.04 4.04 0 0 1 4 4.065 4.1 4.1 0 0 1-.9 2.565zM8 2a3.035 3.035 0 0 0-3 3.065c.003.734.267 1.443.745 2L8 10.26 10.315 7A3.12 3.12 0 0 0 11 5.065 3.035 3.035 0 0 0 8 2"}),(0,t.jsx)("path",{d:"M8 5.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2M14 6h-1v1h1v7H2V7h1V6H2a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1"})]})]})),z=s.default.forwardRef((e,a)=>(0,t.jsx)($.BaseIcon,{ref:a,icon:B,...e}));z.displayName="Map";var V=e.i(456843),q=e.i(255502);function G({onSubmit:e,defaultFirstName:a,defaultLastName:r}){let[n,i]=(0,s.useState)(!1),{register:l,handleSubmit:o,setValue:d,watch:c,formState:{errors:u,isSubmitting:h}}=(0,E.useForm)({resolver:(0,I.zodResolver)(U),defaultValues:{country:"USA",firstName:a||"",lastName:r||""}}),x=c(),{searchQuery:f,searchResults:g,isSearching:y,showDropdown:v,dropdownRef:b,inputRef:j,handleAddressSelect:w,handleSearchInputChange:N,handleClearSearch:P,handleInputBlur:S,handleInputFocus:A,clearSearchState:k}=function({experience:e="wx",onAddressSelected:t}={}){let[a,r]=(0,s.useState)(""),[n,i]=(0,s.useState)([]),[l,o]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!1),u=(0,s.useRef)(null),h=(0,s.useRef)(null),p=(0,s.useRef)(null),x=(0,s.useRef)(!1);(0,s.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{if(a.length{o(!0);try{let t=await (0,V.searchAddress)({query:a,experience:e});i(t),c(t.length>0)}catch(e){i([])}finally{o(!1)}},300),()=>{u.current&&clearTimeout(u.current)}},[a,e]);let f=(0,s.useCallback)(async a=>{c(!1),x.current=!0,r(a.address),o(!0),p.current&&p.current.blur();try{let s=await (0,q.formatAddress)({key:a.key,experience:e}),r=m[s.state.toLowerCase()]||s.state,n={addressLine1:s.address1,addressLine2:s.address2,city:s.city,state:r,postalCode:s.postalCode};t&&t(n)}catch(e){}finally{o(!1)}},[e,t]),g=(0,s.useCallback)(e=>{r(e.target.value)},[]),y=(0,s.useCallback)(()=>{r(""),i([]),c(!1)},[]),v=(0,s.useCallback)(()=>{setTimeout(()=>{c(!1)},200)},[]),b=(0,s.useCallback)(()=>{n.length>0&&a.length>=3&&c(!0)},[n.length,a.length]),j=(0,s.useCallback)(()=>{r(""),i([]),c(!1)},[]);return{searchQuery:a,setSearchQuery:r,searchResults:n,isSearching:l,showDropdown:d,setShowDropdown:c,dropdownRef:h,inputRef:p,handleAddressSelect:f,handleSearchInputChange:g,handleClearSearch:y,handleInputBlur:v,handleInputFocus:b,clearSearchState:j}}({experience:"wx",onAddressSelected:e=>{let t={shouldDirty:!0,shouldTouch:!0,shouldValidate:!0};d("addressLine1",e.addressLine1,t),e.addressLine2&&d("addressLine2",e.addressLine2,t),d("city",e.city,t),d("state",e.state,t),d("postalCode",e.postalCode,t)}});(0,s.useEffect)(()=>{d("country","USA",{shouldValidate:!0})},[d]),(0,s.useEffect)(()=>{n&&k()},[n,k]);let D=!n&&(u.addressLine1||u.city||u.state||u.postalCode)?"Please select an address from the search results or enter your address manually":void 0,M=(0,s.useMemo)(p,[]);return(0,t.jsxs)("form",{onSubmit:o(t=>{e(t)}),className:"space-y-4",children:[n?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Manual Address Entry"}),(0,t.jsx)(C.Button,{type:"button",onClick:()=>i(!1),variant:"link",className:"h-fit p-0",children:"Search Address"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("firstName"),label:"First Name",type:"text",autoComplete:"given-name",error:u.firstName?.message,disabled:h,value:x.firstName||"",icon:_.Person})}),(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("lastName"),label:"Last Name",type:"text",autoComplete:"family-name",error:u.lastName?.message,disabled:h,value:x.lastName||"",icon:_.Person})})]}),(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("addressLine1"),label:"Address Line 1",type:"text",autoComplete:"address-line1",error:u.addressLine1?.message,disabled:h,value:x.addressLine1||"",icon:z})}),(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("addressLine2"),label:"Address Line 2 (Optional)",type:"text",autoComplete:"address-line2",error:u.addressLine2?.message,disabled:h,value:x.addressLine2||"",icon:z})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("city"),label:"City",type:"text",autoComplete:"address-level2",error:u.city?.message,disabled:h,value:x.city||"",icon:z})}),(0,t.jsx)("div",{children:(0,t.jsx)(R,{...l("state"),label:"State/Province",options:M,autoComplete:"address-level1",error:u.state?.message,disabled:h,value:x.state||"",icon:z})})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("postalCode"),label:"Postal Code",type:"text",autoComplete:"postal-code",error:u.postalCode?.message,disabled:h,value:x.postalCode||"",icon:z})})})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("firstName"),label:"First Name",type:"text",autoComplete:"given-name",error:u.firstName?.message,disabled:h,value:x.firstName||"",icon:_.Person})}),(0,t.jsx)("div",{children:(0,t.jsx)(L.Input,{...l("lastName"),label:"Last Name",type:"text",autoComplete:"family-name",error:u.lastName?.message,disabled:h,value:x.lastName||"",icon:_.Person})})]}),(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("div",{className:"flex flex-col items-start md:flex-row md:gap-2",children:[(0,t.jsxs)("div",{className:"relative w-full flex-1",ref:b,children:[(0,t.jsx)(L.Input,{ref:j,label:"Billing Address (U.S.)",type:"text",value:f,onChange:N,onClear:P,onBlur:S,onFocus:A,autoComplete:"off",disabled:h,icon:O.Search,error:D}),v&&g.length>0&&(0,t.jsx)("div",{className:"absolute top-[38px] left-0 z-50 mt-1 w-full rounded-lg bg-white p-4 whitespace-normal shadow-[0_2px_12px_0_rgba(0,0,0,0.2)]",children:(0,t.jsx)("ul",{className:"max-h-60 overflow-auto",children:g.length>0?g.map((e,a)=>(0,t.jsx)("li",{className:aw(e),className:"relative box-border flex w-full items-center rounded-sm px-2 py-2 text-left text-sm whitespace-nowrap no-underline outline-0 hover:bg-[#252422] hover:text-white focus:bg-[#252422] focus:text-white",children:e.address})},a)):(0,t.jsx)("li",{className:"px-2 py-2 text-sm text-gray-500",children:y?"Searching...":"No results found"})})}),y&&(0,t.jsx)("div",{className:"absolute top-0 right-0 mt-3 mr-5",children:(0,t.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-blue-600"})})]}),(0,t.jsx)(C.Button,{type:"button",onClick:()=>i(!0),variant:"link",className:"h-fit w-fit p-0 text-left whitespace-normal md:-mt-1.5 md:max-w-[110px]",children:"Enter Address Manually"})]})})]}),(0,t.jsx)(C.Button,{type:"submit",disabled:h,children:h?"Processing...":"Continue"})]})}function H({addressData:e,isEditingAddress:a,userProfile:s,userLastName:r,onSubmit:n,onEdit:i}){return!e||a?(0,t.jsx)("div",{children:(0,t.jsx)(G,{onSubmit:n,defaultFirstName:s?.firstName,defaultLastName:r},`${s?.firstName&&"fn"}${r&&"ln"}`)}):(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"font-medium text-gray-900",children:[e.firstName," ",e.lastName]}),(0,t.jsx)("div",{className:"text-gray-600",children:e.addressLine1}),e.addressLine2&&(0,t.jsx)("div",{className:"text-gray-600",children:e.addressLine2}),(0,t.jsxs)("div",{className:"text-gray-600",children:[e.city,", ",e.state," ",e.postalCode]})]}),(0,t.jsx)(C.Button,{type:"button",onClick:i,variant:"link",className:"h-fit p-0",children:"Edit"})]})}function W({paymentMethods:e,selectedPaymentMethodId:a,onSelectPaymentMethod:s}){return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(w.default,{variant:"Body.M.Bold",className:"text-gray-900",children:"Saved Payment Methods"}),(0,t.jsxs)("div",{className:"space-y-2",children:[e.map(e=>{var r;let n;return(0,t.jsxs)("label",{className:"flex cursor-pointer items-start space-x-3 rounded-md border border-gray-300 p-4 hover:border-blue-500 hover:bg-blue-50",children:[(0,t.jsx)("input",{type:"radio",name:"payment-method",value:e.id,checked:a===e.id,onChange:()=>s(e.id),className:"mt-1 h-4 w-4 flex-shrink-0 border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"font-medium text-gray-900",children:(n=(r=e.card.brand).toLowerCase()).includes("visa")?"Visa":n.includes("mastercard")?"Mastercard":n.includes("amex")||n.includes("american express")?"American Express":n.includes("discover")?"Discover":r}),(0,t.jsxs)("span",{className:"text-gray-600",children:["•••• ",e.card.last4]})]}),e.isDefault&&(0,t.jsx)("span",{className:"rounded-full bg-blue-100 px-2 py-1 text-xs font-medium text-blue-800",children:"Default"})]}),(0,t.jsxs)("div",{className:"mt-1 text-sm text-gray-600",children:["Expires ",e.card.expiryMonth,"/",e.card.expiryYear]})]})]},e.id)}),(0,t.jsxs)("label",{className:"flex cursor-pointer items-start space-x-3 rounded-md border border-gray-300 p-4 hover:border-blue-500 hover:bg-blue-50",children:[(0,t.jsx)("input",{type:"radio",name:"payment-method",value:"new",checked:null===a,onChange:()=>s(null),className:"mt-1 h-4 w-4 flex-shrink-0 border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("span",{className:"font-medium text-gray-900",children:"Use a different card"})})]})]})]})}var J=e.i(694914),Z=e.i(571917),Y=e.i(502145),K=e.i(127667);let X=(0,s.memo)((0,s.forwardRef)(function({experience:e="wx",onSuccess:a,onError:r,addressData:n,userEmail:i},l){let o=(0,s.useRef)(null),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(!1),[x,f]=(0,s.useState)(!1),[g,y]=(0,s.useState)(),[v,b]=(0,s.useState)(0),[j,C]=(0,s.useState)(null),[N,P]=(0,s.useState)(null),[S,A]=(0,s.useState)(!1),[k,E]=(0,s.useState)(0),I=(0,s.useRef)(!1),L=(0,s.useCallback)(e=>{y(()=>e),r()},[r]),D=(0,s.useCallback)(()=>{p(!1),f(!1),C(null),P(null),I.current=!1,c(null),E(e=>e+1)},[]);(0,s.useImperativeHandle)(l,()=>({submitPayment:M,isReady:()=>h&&!x})),(0,s.useEffect)(()=>{let t=async(a=0)=>{m(!0);try{let t="wx"===e?"8a128c8886bb413c0186c82a1b69298c":J.default.env.NEXT_PUBLIC_WU_ZUORA_PAGE_ID;if(!t)throw Error(`Zuora page ID not configured for experience: ${e}`);let a=await (0,Z.getRsaSignature)({pageId:t});c({...a.rsaSignature,pageId:t}),b(0),m(!1)}catch(s){let e=s instanceof Error?s.message:"Failed to fetch RSA signature";if(a{t(e)},s)}else L(e),m(!1)}};d||t()},[d,e,L]),(0,s.useEffect)(()=>{let e=e=>{if(e.origin===window.location.origin&&"ZUORA_HPP_CALLBACK"===e.data.type){let{success:t,refId:a}=e.data.params;"true"===t&&a?C(a):(L("Payment processing failed"),D())}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[L,D]),(0,s.useEffect)(()=>{!j||I.current||(async()=>{A(!0);try{let t=await (0,Y.getPaymentDetails)({refId:j,experience:e});P(t),f(!1),A(!1),I.current=!0,a(j,t)}catch(e){L("Failed to retrieve payment details"),f(!1),A(!1)}})()},[j,e,a,L]),(0,s.useEffect)(()=>{if(!window.Z){let e=setInterval(()=>{window.Z&&(clearInterval(e),E(e=>e+1))},100),t=setTimeout(()=>{clearInterval(e),L("Zuora script failed to load. Please refresh the page.")},1e4);return()=>{clearInterval(e),clearTimeout(t)}}if(!d||!n||!i)return;let e={tenantId:d.tenantId,id:d.pageId,token:d.token,signature:d.signature,style:"inline",key:d.key,submitEnabled:"false",locale:"en-US",url:"https://zuora.com/apps/PublicHostedPageLite.do",param_supportedTypes:"Visa,MasterCard,Discover,Amex"},t={creditCardAddress1:n.addressLine1,creditCardAddress2:n.addressLine2||"",creditCardCity:n.city,creditCardState:n.state,creditCardPostalCode:n.postalCode,email:i,creditCardCountry:n.country||"USA",creditCardHolderName:`${n.firstName} ${n.lastName}`};try{window.Z.setEventHandler("onloadCallback",()=>{p(!0)}),window.Z.renderWithErrorHandler(e,t,()=>{},(e,t,a)=>{L(a),f(!1)})}catch(e){L(e instanceof Error?e.message:"Failed to render payment form")}},[d,n,i,e,k,L]);let M=()=>{if(window.Z&&!x&&h){f(!0),y("");try{window.Z.submit()}catch(e){L(e instanceof Error?e.message:"Failed to submit payment"),f(!1)}}};return u?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(K.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-blue-600"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:v>0?`Loading payment form... (Retry ${v}/3)`:"Loading payment form..."})]})}):S||N&&N.length>0?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(K.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-blue-600"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Processing payment details..."})]})}):(0,t.jsxs)("div",{className:"relative",children:[g&&(0,t.jsx)("div",{className:"mb-4 space-y-2",children:(0,t.jsx)(w.default,{color:"error",children:g})}),!h&&d&&(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(K.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-blue-600"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Preparing payment form..."})]})}),(0,t.jsx)("div",{ref:o,id:"zuora_payment"},k)]})}));var Q=e.i(681488);function ee({paymentMethods:e,selectedPaymentMethodId:a,onSelectPaymentMethod:s,shouldCollectPayment:r,termsAgreed:n,onTermsChange:i,paymentError:l,zuoraFormRef:o,onPaymentSuccess:d,onPaymentError:c,addressData:u,userEmail:m}){return(0,t.jsxs)("div",{className:"space-y-4",children:[l&&(0,t.jsx)("div",{className:"mb-4 rounded-md bg-red-50 p-3 text-sm text-red-800",children:l}),r&&(0,t.jsxs)(t.Fragment,{children:[e.length>0?(0,t.jsx)(W,{paymentMethods:e,selectedPaymentMethodId:a,onSelectPaymentMethod:s}):null,(0===e.length||null===a)&&(0,t.jsx)(X,{ref:o,experience:"wx",onSuccess:d,onError:c,addressData:u,userEmail:m})]}),(0,t.jsxs)("div",{className:"space-y-4 border-t border-gray-200 pt-4",children:[(0,t.jsxs)("div",{className:"text-sm text-gray-700",children:[(0,t.jsx)("p",{className:"font-semibold",children:"Automatic Renewal:"}),(0,t.jsxs)("p",{className:"mt-1",children:["By clicking Subscribe Now below, you authorize us to charge your account the above rate plus tax at the end of your free trial for the term shown, and to auto renew your subscription annually as set forth in our"," ",(0,t.jsx)("a",{href:"https://weather.com/en-US/twc/subscriber-agreement",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 underline hover:text-blue-800",children:"Subscriber Agreement"}),". You may cancel the renewal of your subscription through your"," ",(0,t.jsx)("a",{href:"https://weather.com",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 underline hover:text-blue-800",children:"weather.com account"})," ","at any time, up until 24 hours before it renews for an additional term."]})]}),(0,t.jsx)(Q.Checkbox,{id:"terms-agreement",checked:n,onCheckedChange:e=>i(!0===e),leftPos:!0,wrapperClassName:"items-start",label:"I confirm that I have read and agree to the Subscriber Agreement governing this purchase as well as the Terms of Use and TWC Privacy Policy which relate to the subscription and my use of it."})]})]})}function et({isSubmitting:e,termsAgreed:a,billingPreviewData:s,onSubmit:r}){return(0,t.jsx)(C.Button,{onClick:r,disabled:e||!a||!s,loading:e,size:"lg",variant:"default",className:"mt-4",children:e?"Processing...":"Subscribe Now"})}var ea=e.i(367810);function es({orderNumber:e,email:a,subscriptionPlan:s,startDate:r,total:n,paymentMethod:i,open:l,onLaunchAdFree:o,onReviewDetails:d}){return(0,t.jsx)(ea.Dialog,{open:l,children:(0,t.jsx)(ea.DialogContent,{showCloseButton:!1,className:"max-h-screen! max-w-screen! overflow-auto rounded-[0]! border-0 p-0",children:(0,t.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center text-gray-900",children:(0,t.jsxs)("div",{className:"w-full bg-white px-10 pt-12.5 text-center",children:[(0,t.jsx)(er,{}),(0,t.jsxs)("h1",{className:"mb-15.5 text-[40px] leading-[115%] max-md:mb-5 max-md:text-[32px]",children:[(0,t.jsx)("span",{className:"font-bold",children:"Thanks!"})," You've subscribed."]}),(0,t.jsxs)("div",{className:"mb-7.5 text-lg leading-[140%] font-medium",children:[(0,t.jsxs)("div",{className:"mb-2.5",children:["Order number is:"," ",(0,t.jsx)("span",{className:"font-bold",children:e})]}),(0,t.jsxs)("div",{children:["We'll send an email confirmation to:"," ",(0,t.jsx)("span",{className:"font-bold",children:a})]})]}),(0,t.jsxs)("div",{className:"mx-auto mb-2.5 max-w-[475px] space-y-2.5 border-t-1 border-gray-200 px-5 py-7.5 text-left text-base leading-[140%]",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-bold",children:"Subscription Plan:"}),(0,t.jsx)("div",{children:s})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-bold",children:"Start Date:"}),(0,t.jsx)("div",{children:r})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-bold",children:"Total:"}),(0,t.jsx)("div",{children:n})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-bold",children:"Payment:"}),(0,t.jsx)("div",{children:i})]})]}),(0,t.jsxs)("div",{className:"mb-15.5 flex flex-wrap justify-center gap-7.5",children:[(0,t.jsx)(C.Button,{variant:"default",size:"lg",onClick:o,className:"h-12 font-bold",children:"Launch Ad Free"}),(0,t.jsx)(C.Button,{variant:"secondary",size:"default",onClick:d,className:"h-12 bg-gray-100 font-bold",children:"Review Details"})]})]})})})})}let er=()=>(0,t.jsxs)("svg",{className:"mx-auto mb-7.5 h-30 w-30 max-md:h-22.5 max-md:w-22.5",viewBox:"0 0 120 120",fill:"none",children:[(0,t.jsx)("g",{clipPath:"url(#clip0_2008_11999)",children:(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M114.783 60C114.783 90.2557 90.2557 114.783 60 114.783C29.7444 114.783 5.21739 90.2557 5.21739 60C5.21739 29.7444 29.7444 5.21739 60 5.21739C90.2557 5.21739 114.783 29.7444 114.783 60ZM120 60C120 93.137 93.137 120 60 120C26.863 120 0 93.137 0 60C0 26.863 26.863 0 60 0C93.137 0 120 26.863 120 60ZM33.1625 56.4211C34.1739 55.4207 35.8023 55.4228 36.8113 56.4256L52.7752 72.2932L83.1983 42.2434C84.2116 41.2427 85.8425 41.2474 86.85 42.2538C87.8671 43.2702 87.8622 44.9204 86.8385 45.9305L55.5924 76.7671C54.0217 78.317 51.4959 78.313 49.9304 76.758L33.1589 60.1012C32.1373 59.0867 32.1391 57.4338 33.1625 56.4211Z",fill:"url(#paint0_linear_2008_11999)"})}),(0,t.jsxs)("defs",{children:[(0,t.jsxs)("linearGradient",{id:"paint0_linear_2008_11999",x1:"102",y1:"21",x2:"13",y2:"105.5",gradientUnits:"userSpaceOnUse",children:[(0,t.jsx)("stop",{stopColor:"#679CED"}),(0,t.jsx)("stop",{offset:"1",stopColor:"#204794"})]}),(0,t.jsx)("clipPath",{id:"clip0_2008_11999",children:(0,t.jsx)("rect",{width:"120",height:"120",fill:"white"})})]})]});var en=e.i(58371);async function ei(e){let{addressData:t,user:a,userProfile:s,productIds:r,promoCode:n,tpcc:i,refId:l,onSuccess:o,onError:d,startPolling:c,clearCart:u}=e;try{if(!t||!a||!s)throw Error("Missing required data for checkout submission");if(!r)throw Error("No product selected");let e={tpcc:i||"",deviceID:"",account:{id:a.userID||"",firstName:t.firstName,lastName:t.lastName,email:s.email||"",address1:t.addressLine1,address2:t.addressLine2||"",city:t.city,state:t.state,postalCode:t.postalCode,country:t.country||"USA",hpmId:l},soldTo:{firstName:t.firstName,lastName:t.lastName,address1:t.addressLine1,address2:t.addressLine2||"",city:t.city,state:t.state,postalCode:t.postalCode,country:t.country||"USA"},productIds:r,promoCode:n},d=await (0,en.submitCheckout)(e,"wx");if(d.success&&d.data)u(),c(),o(d.data);else throw Error("Checkout submission failed")}catch(e){d(e instanceof Error?e.message:"Failed to complete checkout. Please contact support.")}}var el=e.i(289607);function eo(e){let t=e.toLowerCase();return t.includes("visa")?"Visa":t.includes("mastercard")?"Mastercard":t.includes("amex")||t.includes("american express")?"American Express":t.includes("discover")?"Discover":e}var ed=e.i(782847),ec=e.i(959194),eu=e.i(947118),em=e.i(386203),eh=e.i(375570),ep=e.i(341205);function ex(){let e=(0,eh.useSearchParams)().get("promoCode"),[t,r]=(0,a.useAtom)(g.promoCodeAtom),[n,i]=(0,s.useState)(""),[l,o]=(0,s.useState)(!1),[d,c]=(0,s.useState)(null),u=(0,s.useRef)(!1),{productId:m}=(0,y.useCart)(),h=(0,s.useCallback)(async e=>{if(!e.trim())return c("Please enter a promo code"),null;o(!0),c(null);try{let t=await (0,ep.validatePromoCode)({productIds:m,promoCode:e.trim(),experience:"wx"});if(!t.valid)return c(t.text||"Invalid promo code. Please check and try again."),null;return t}catch(e){return c("Unable to validate promo code. Please try again later."),null}finally{o(!1)}},[m]);(0,s.useEffect)(()=>{e&&!u.current&&e!==t?.code&&(u.current=!0,i(e),h(e).then(e=>{e&&(r(e),i(""))}))},[e,t?.code,r,h]);let p=async()=>{let e=await h(n);e&&(r(e),i(""))};return{promoCodeResponse:t,promoCodeInput:n,setPromoCodeInput:i,isValidating:l,validationError:d,applyPromoCode:p,removePromoCode:()=>{r(null)},clearError:()=>{c(null)}}}function ef({isAuthenticated:e,addressData:n,paymentMethods:l}){let o,{navigate:d}=(0,k.default)(),{user:c,userProfile:u}=(0,P.useUser)(),{userLastName:m}=(0,S.useUserLastName)(),{startPolling:h}=(o=(0,s.useRef)(!1),{startPolling:(0,s.useCallback)(async()=>{if(o.current)return;o.current=!0;let e=0,t=async()=>{e++;try{await i.upsxClient.purchase.getPurchaseToken(),o.current=!1;return}catch(a){e{t()},2e3):o.current=!1}};t()},[])}),{promoCodeResponse:p}=ex(),x=function(){let[e,t]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),[n,i]=(0,s.useState)(null),[l,o]=(0,s.useState)(null),[d,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),x=(0,s.useRef)(!1),[f,g]=(0,s.useState)(!1),[y,v]=(0,s.useState)(null),b=(0,s.useCallback)(()=>{p(null),m(!1),i(null),x.current=!1},[]);return{isEditingAddress:e,setIsEditingAddress:t,selectedPaymentMethodId:a,setSelectedPaymentMethodId:r,paymentRefId:n,setPaymentRefId:i,cardDetails:l,setCardDetails:o,termsAgreed:d,setTermsAgreed:c,isSubmitting:u,setIsSubmitting:m,paymentError:h,setPaymentError:p,hasSubmittedCheckoutRef:x,showSuccess:f,setShowSuccess:g,checkoutData:y,setCheckoutData:v,resetPaymentState:b}}(),{productId:f,setProductId:v}=(0,y.useCart)(),[b,j]=(0,a.useAtom)(g.addressDataAtom),C=(0,a.useAtomValue)(g.tpccAtom),N=(0,a.useAtomValue)(g.billingPreviewDataAtom),A=(0,a.useAtomValue)(g.eventChainIdAtom),E=p?.collectPayment!=="False",I=(0,s.useRef)(null),L=(0,ed.usePurchaseStart)({step:"address",accountCreated:!1,accountLogin:e,completed:!1,eventChainId:A||"",premiumProductId:f||void 0}),D=(0,ed.usePurchaseStart)({step:"billing",accountCreated:!1,accountLogin:e,completed:!1,eventChainId:A||"",premiumProductId:f||void 0}),M=(e=>{let t=(0,eu.useIsInitialized)(),a=(0,r.useEventAttributes)(),[n,i]=(0,s.useState)(!1),l=(0,s.useRef)(!1),o=(0,s.useMemo)(()=>{let t={...a,step:e.step??"confirmation",accountCreated:e.accountCreated??!1,accountLogin:e.accountLogin??!1,completed:e.completed??!1,eventChainId:e.eventChainId,premiumProductId:e.premiumProductId??void 0,weatherMode:e.weatherMode??"normal",experimentJoinList:e.experimentJoinList??void 0,mParticleGranted:e.mParticleGranted??!0};return void 0===t.premiumProductId&&delete t.premiumProductId,void 0===t.experimentJoinList&&delete t.experimentJoinList,t},[a,e.step,e.accountCreated,e.accountLogin,e.completed,e.eventChainId,e.premiumProductId,e.weatherMode,e.experimentJoinList,e.mParticleGranted]);return(0,s.useEffect)(()=>{(0,ec.areObjectValuesDefined)(o)&&!n&&i(!0)},[o,n]),(0,s.useCallback)(async()=>{if(t&&n&&!l.current)try{window.mParticle?.logEvent?.("purchase-complete",window.mParticle?.EventType?.Other,o),l.current=!0,console.debug(`MParticle: Event "purchase-complete" tracked - ${o.pageId}`)}catch(e){console.error('MParticle: Event "purchase-complete" failed',e)}},[t,o,n])})({step:"confirmation",accountCreated:!1,accountLogin:e,completed:!0,eventChainId:A||"",premiumProductId:f||void 0});(0,s.useEffect)(()=>{n&&!b&&j(n)},[n,b,j]),(0,s.useEffect)(()=>{(!b||x.isEditingAddress)&&e&&L()},[b,x.isEditingAddress,e,L]),(0,s.useEffect)(()=>{b&&!x.isEditingAddress&&e&&D()},[b,x.isEditingAddress,e,D]),(0,s.useEffect)(()=>{x.showSuccess&&x.checkoutData&&M()},[x.showSuccess,x.checkoutData,M]);let{setSelectedPaymentMethodId:R}=x;(0,s.useEffect)(()=>{if(l.length>0){let e=l.find(e=>e.isDefault);e&&R(e.id)}},[l,R]);let T=(0,s.useCallback)(async e=>{await ei({addressData:b,user:c,userProfile:u,productIds:f,promoCode:p?.code,tpcc:C,refId:e,onSuccess:e=>{x.setCheckoutData(e),x.setIsSubmitting(!1),x.setShowSuccess(!0)},onError:e=>{x.setPaymentError(e),x.setIsSubmitting(!1)},startPolling:h,clearCart:()=>v("")})},[b,c,u,p,f,h,C,v,x.setCheckoutData,x.setShowSuccess,x.setPaymentError,x.setIsSubmitting,x.hasSubmittedCheckoutRef]),F=(0,s.useCallback)(async(e,t)=>{x.setPaymentRefId(e),x.setPaymentError(null),t.length>0&&t[0]&&x.setCardDetails(t[0]),x.hasSubmittedCheckoutRef.current?x.setIsSubmitting(!1):(x.hasSubmittedCheckoutRef.current=!0,await T(e))},[T,x.setPaymentRefId,x.setPaymentError,x.setCardDetails,x.setIsSubmitting,x.hasSubmittedCheckoutRef]),U=(0,s.useCallback)(()=>{x.setPaymentRefId(null),x.setIsSubmitting(!1)},[x.setPaymentRefId,x.setIsSubmitting]),_=e=>{j(e),x.setIsEditingAddress(!1)},O=()=>{x.setIsEditingAddress(!0)},$=(0,s.useCallback)(async()=>{let e=x.termsAgreed?{valid:!0}:{valid:!1,error:"Please agree to the Terms and Services to continue."};if(!e.valid)return void x.setPaymentError(e.error);x.setPaymentError(null),x.setIsSubmitting(!0);let t=function(e){let{selectedPaymentMethodId:t,paymentRefId:a,zuoraFormReady:s,shouldCollectPayment:r}=e;return r?t?{valid:!0,action:"use-saved-method"}:a?{valid:!0,action:"submit-checkout"}:s?{valid:!0,action:"submit-hpp"}:{valid:!1,error:"Payment form is not ready. Please wait and try again."}:{valid:!0,action:"submit-checkout"}}({selectedPaymentMethodId:x.selectedPaymentMethodId,paymentRefId:x.paymentRefId,zuoraFormReady:I.current?.isReady()||!1,shouldCollectPayment:E});if(!t.valid){x.setPaymentError(t.error),x.setIsSubmitting(!1);return}switch(t.action){case"submit-checkout":await T(x.paymentRefId||"");break;case"use-saved-method":await T(x.selectedPaymentMethodId);break;case"submit-hpp":I.current?.submitPayment()}},[x,E,T]),B=!b||x.isEditingAddress;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:`${!e?"pointer-events-none opacity-50":""}`,children:[(0,t.jsx)(w.default,{variant:"Display.S",className:"mb-2",children:"Payment"}),!e&&(0,t.jsx)("div",{className:"mb-4 rounded-md bg-gray-100 p-4 text-sm text-gray-700",children:"Please log in or sign up to continue with payment."}),e&&(0,t.jsx)("div",{className:"space-y-6",children:B?(0,t.jsx)(H,{addressData:b,isEditingAddress:x.isEditingAddress,userProfile:u,userLastName:m,onSubmit:_,onEdit:O}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(H,{addressData:b,isEditingAddress:!1,userProfile:u,userLastName:m,onSubmit:_,onEdit:O}),(0,t.jsx)(ee,{paymentMethods:l,selectedPaymentMethodId:x.selectedPaymentMethodId,onSelectPaymentMethod:R,shouldCollectPayment:E,termsAgreed:x.termsAgreed,onTermsChange:x.setTermsAgreed,paymentError:x.paymentError,zuoraFormRef:I,onPaymentSuccess:F,onPaymentError:U,addressData:b,userEmail:u?.email||null}),(0,t.jsx)(et,{isSubmitting:x.isSubmitting,termsAgreed:x.termsAgreed,billingPreviewData:N,onSubmit:$})]})})]}),x.checkoutData&&(0,t.jsx)(es,{open:x.showSuccess,orderNumber:x.checkoutData.orderNumber,email:u?.email||"",subscriptionPlan:x.checkoutData.products[0]?.name||"Weather.com Subscription",startDate:(0,el.formatIntlDateString)(new Date,"en-US","America/New_York",{year:"numeric",month:"long",day:"numeric"}),total:function(e){let{checkoutData:t,billingPreviewData:a}=e;if(!t)return"";let s=t.products?.[0]?.currencySymbol||"$";if(a&&(a.trialDays>0||a.trialMonths>0)&&a){let e=(0,el.formatIntlDateString)(new Date(1e3*(a?.date||0)),"en-US","America/New_York",{year:"numeric",month:"long",day:"numeric"});return`${s}${(a.amount||0).toFixed(2)} will be billed on ${e}, the end of your free trial`}return`${s}${(t.paidAmount||0).toFixed(2)}`}({checkoutData:x.checkoutData,billingPreviewData:N}),paymentMethod:function(e){let{cardDetails:t,selectedPaymentMethodId:a,paymentMethods:s}=e;if(t){let e=eo(t.brand);return`${e} ending in ${t.last4}`}if(a){let e=s.find(e=>e.id===a);if(e){let t=eo(e.card.brand);return`${t} ending in ${e.card.last4}`}}return"Credit Card"}({cardDetails:x.cardDetails,selectedPaymentMethodId:x.selectedPaymentMethodId,paymentMethods:l}),onLaunchAdFree:()=>{d("/")},onReviewDetails:()=>{d("/member/settings")}})]})}let eg=()=>{let{promoCodeResponse:e,promoCodeInput:a,setPromoCodeInput:s,isValidating:r,validationError:n,applyPromoCode:i,removePromoCode:l,clearError:o}=ex();return e?(0,t.jsxs)("div",{className:"mt-5 flex items-center justify-between bg-white px-[15px] py-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-sm leading-none",children:["Promotion (",e.code,"):"]}),(0,t.jsx)("span",{className:"text-sm leading-none font-semibold",children:e?e.discountPercentage>0?`-${e.discountPercentage}%`:e.discountAmount>0?`-$${e.discountAmount.toFixed(2)}`:"":""})]}),(0,t.jsx)("button",{type:"button",onClick:l,className:"text-sm leading-none font-semibold text-gray-900 hover:text-gray-700",children:"REMOVE"})]}):(0,t.jsxs)("div",{className:"mt-5 flex items-end justify-between bg-white px-[15px] pb-3",children:[(0,t.jsx)(L.Input,{label:"Promo Code",wrapperClassName:"mt-3 h-auto",name:"promoCode",value:a,error:n||void 0,onChange:e=>{s(e.target.value),o()}}),(0,t.jsx)(C.Button,{disabled:!a||r,className:"h-8 bg-gray-100 text-sm font-bold text-black hover:bg-gray-100 hover:text-black focus:bg-gray-100 focus:text-black",onClick:i,children:r?"Validating...":"Apply"})]})},ey=({billingPreviewData:e,soldToAddress:a,isContinuousOrder:r,experience:n=""})=>{let i=(0,s.useMemo)(()=>(function(e=[]){let t=[],a=[];return e?.length&&e.forEach(e=>{e.chargeName?.includes("Premium")||e.chargeName?.includes("Ad Free")?t.push(e):a.push(e)}),[...t,...a]})(e?.items),[e]),l=!!(e?.trialDays||e?.trialMonths),o=e?.amount,d=Number.isNaN(o)?"--":o?.toFixed(2),c=e?.trialDays||e?.trialMonths,u=e?.trialDays?"day":"month",m=(0,el.formatIntlDateString)(new Date(1e3*(e?.date||0)),"en-US","America/New_York",{year:"numeric",month:"long",day:"numeric"}),h=(0,el.formatIntlDateString)(new Date(1e3*(e?.nextBill.date||0)),"en-US","America/New_York",{year:"numeric",month:"long",day:"numeric"});return(0,t.jsxs)("div",{className:"bg-[#F6F6F6] p-7.5",children:[(0,t.jsx)("div",{className:"mb-5 align-middle text-xl leading-6 font-semibold tracking-normal",children:"Summary"}),e?(0,t.jsxs)(t.Fragment,{children:[i.map((e,a)=>(0,t.jsxs)("div",{className:"my-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between leading-[140%]",children:[(0,t.jsxs)("span",{children:[e.chargeName,":"]}),(0,t.jsxs)("span",{children:["$",e.price.toFixed(2)??"--"]})]}),l&&0===a&&(0,t.jsxs)("div",{className:"mt-[5px] inline-block rounded-sm bg-[#103293] p-2 text-xs leading-[1] font-bold text-white",children:["FREE ",c,"-",u," trial"]})]},e.chargeName)),(0,t.jsx)(eg,{experience:n}),(0,t.jsxs)("div",{className:"mt-6 flex justify-between border-t-2 border-gray-900 pt-6 leading-[20px]",children:[(0,t.jsxs)("span",{children:["Tax"," ",a?.postalCode?` (${a?.postalCode})`:""]}),(0,t.jsx)("span",{className:(0,D.cn)({"text-[#686C74]":!a?.postalCode}),children:a?.postalCode?`$${e?.taxAmount?.toFixed(2)}`:"Not yet calculated"})]}),(0,t.jsxs)("div",{className:"mt-5 flex justify-between text-xl leading-[20px] font-semibold",children:[(0,t.jsx)("span",{children:"Total"}),(0,t.jsxs)("span",{children:["$",d]})]}),(0,t.jsxs)("div",{className:"mt-6 bg-[#EAEAEA] px-4 py-6 text-sm leading-[16px] text-gray-500",children:[(0,t.jsxs)("div",{className:"font-semibold",children:["Start Date: ",(0,t.jsx)("span",{children:r?m:"Today"}),l&&(0,t.jsxs)("span",{children:[" ",c,"-",(0,t.jsx)("span",{className:"capitalize",children:u})," Free Trial"]})]}),(0,t.jsx)("br",{}),(0,t.jsxs)("div",{children:["Billing starts on ",m,",",l&&"the end of your free trial,"," and will renew automatically every ",e?.interval," until cancelled.",e?.nextBill?.amount&&`Renewal price will be $${e?.nextBill?.amount?.toFixed(2)}/${e.interval} starting on ${h}.`]})]})]}):(0,t.jsx)(w.default,{color:"error",children:"Failed to load summary. Please refresh."})]})};function ev({experience:e="wx"}){let{promoCodeResponse:r}=ex(),i=(0,a.useAtomValue)(g.addressDataAtom),l=(0,a.useSetAtom)(g.billingPreviewDataAtom),o=(0,a.useAtomValue)(g.checkoutValidationAtom),{productId:d}=(0,y.useCart)(),{data:c,error:u,isLoading:m}=function({productIds:e,soldCity:t,soldState:a,soldPostalCode:s,promoCode:r,experience:i,isContinuousOrder:l}){let{data:o,error:d,isLoading:c,mutate:u}=(0,n.default)(["billing-preview",e,t,a,s,r||"",i,l],async()=>(0,em.getBillingPreview)({productIds:e,soldCity:t,soldState:a,soldPostalCode:s,promoCode:r,experience:i,isContinuousOrder:l}),{revalidateOnFocus:!1,revalidateOnReconnect:!1,shouldRetryOnError:!0,errorRetryCount:3});return{data:o,error:d,isLoading:c,mutate:u}}({productIds:"valid"===o?d:"",soldCity:i?.city,soldState:i?.state,soldPostalCode:i?.postalCode,promoCode:r?.code,experience:e});if((0,s.useEffect)(()=>{u?l(null):c&&l(c)},[u,c,l]),"idle"===o||"loading"===o)return(0,t.jsxs)("div",{className:"bg-[#F6F6F6] p-7.5",children:[(0,t.jsx)("div",{className:"mb-5 align-middle text-xl leading-6 font-semibold tracking-normal",children:"Summary"}),(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("div",{className:"text-center text-gray-600",children:"Validating checkout..."})})]});if("invalid"===o)return(0,t.jsxs)("div",{className:"bg-[#F6F6F6] p-7.5",children:[(0,t.jsx)("div",{className:"mb-5 align-middle text-xl leading-6 font-semibold tracking-normal",children:"Summary"}),(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("div",{className:"text-center text-gray-600",children:"Please resolve checkout issues and try again"})})]});if(m)return(0,t.jsxs)("div",{className:"bg-[#F6F6F6] p-7.5",children:[(0,t.jsx)("div",{className:"mb-5 align-middle text-xl leading-6 font-semibold tracking-normal",children:"Summary"}),(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("div",{className:"text-center text-gray-600",children:"Loading..."})})]});if(u)return(0,t.jsxs)("div",{className:"bg-[#F6F6F6] p-7.5",children:[(0,t.jsx)("div",{className:"mb-5 align-middle text-xl leading-6 font-semibold tracking-normal",children:"Summary"}),(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("div",{className:"text-center text-red-600",children:"Failed to load checkout details. Please try again."})})]});let h={fullAddress:`${i?.addressLine1||""} ${i?.city||""} ${i?.state||""} ${i?.postalCode||""}`.trim(),address1:i?.addressLine1||"",address2:i?.addressLine2||"",city:i?.city||"",county:"USA",state:i?.state||"",postalCode:i?.postalCode||""};return(0,t.jsx)(ey,{billingPreviewData:c,soldToAddress:h,isContinuousOrder:!1,experience:"wx"})}var eb=e.i(828405),ej=e.i(156207),eC=e.i(144977),ew=e.i(867013),eN=e.i(291967),eP=e.i(93074),eS="AlertDialog",[eA,ek]=(0,ej.createContextScope)(eS,[ew.createDialogScope]),eE=(0,ew.createDialogScope)(),eI=e=>{let{__scopeAlertDialog:a,...s}=e,r=eE(a);return(0,t.jsx)(ew.Root,{...r,...s,modal:!0})};eI.displayName=eS;var eL=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,n=eE(s);return(0,t.jsx)(ew.Trigger,{...n,...r,ref:a})});eL.displayName="AlertDialogTrigger";var eD=e=>{let{__scopeAlertDialog:a,...s}=e,r=eE(a);return(0,t.jsx)(ew.Portal,{...r,...s})};eD.displayName="AlertDialogPortal";var eM=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,n=eE(s);return(0,t.jsx)(ew.Overlay,{...n,...r,ref:a})});eM.displayName="AlertDialogOverlay";var eR="AlertDialogContent",[eT,eF]=eA(eR),eU=(0,eP.createSlottable)("AlertDialogContent"),e_=s.forwardRef((e,a)=>{let{__scopeAlertDialog:r,children:n,...i}=e,l=eE(r),o=s.useRef(null),d=(0,eC.useComposedRefs)(a,o),c=s.useRef(null);return(0,t.jsx)(ew.WarningProvider,{contentName:eR,titleName:eO,docsSlug:"alert-dialog",children:(0,t.jsx)(eT,{scope:r,cancelRef:c,children:(0,t.jsxs)(ew.Content,{role:"alertdialog",...l,...i,ref:d,onOpenAutoFocus:(0,eN.composeEventHandlers)(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,t.jsx)(eU,{children:n}),(0,t.jsx)(eH,{contentRef:o})]})})})});e_.displayName=eR;var eO="AlertDialogTitle",e$=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,n=eE(s);return(0,t.jsx)(ew.Title,{...n,...r,ref:a})});e$.displayName=eO;var eB="AlertDialogDescription",ez=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,n=eE(s);return(0,t.jsx)(ew.Description,{...n,...r,ref:a})});ez.displayName=eB;var eV=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,n=eE(s);return(0,t.jsx)(ew.Close,{...n,...r,ref:a})});eV.displayName="AlertDialogAction";var eq="AlertDialogCancel",eG=s.forwardRef((e,a)=>{let{__scopeAlertDialog:s,...r}=e,{cancelRef:n}=eF(eq,s),i=eE(s),l=(0,eC.useComposedRefs)(a,n);return(0,t.jsx)(ew.Close,{...i,...r,ref:l})});eG.displayName=eq;var eH=({contentRef:e})=>{let t=`\`${eR}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${eR}\` by passing a \`${eB}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${eR}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return s.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},eW=e.i(634177);function eJ({...e}){return(0,t.jsx)(eI,{"data-slot":"alert-dialog",...e})}function eZ({...e}){return(0,t.jsx)(eL,{"data-slot":"alert-dialog-trigger",...e})}function eY({...e}){return(0,t.jsx)(eD,{"data-slot":"alert-dialog-portal",...e})}function eK({className:e,...a}){return(0,t.jsx)(eM,{"data-slot":"alert-dialog-overlay",className:(0,D.cn)((0,eW.dialogStyles)({type:"overlay"}),e),...a})}function eX({className:e,children:a,...s}){return(0,t.jsxs)(eY,{"data-slot":"alert-dialog-portal",children:[(0,t.jsx)(eK,{}),(0,t.jsx)(e_,{"data-slot":"alert-dialog-content",className:(0,D.cn)((0,eW.dialogStyles)({type:"content"}),e),...s,children:a})]})}function eQ({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,D.cn)((0,eW.dialogStyles)({type:"header"}),e),...a})}function e0({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,D.cn)((0,eW.dialogStyles)({type:"footer"}),e),...a})}function e1({className:e,children:a,...s}){return(0,t.jsx)(e$,{"data-slot":"alert-dialog-title",className:(0,D.cn)("text-lg leading-none font-semibold",e),...s,children:(0,t.jsx)(eW.DialogTextTitle,{children:a})})}function e2({className:e,children:a,...s}){return(0,t.jsx)(ez,{"data-slot":"alert-dialog-description",className:(0,D.cn)("text-muted-foreground text-center text-sm",e),...s,children:(0,t.jsx)(eW.DialogTextDescription,{children:a})})}function e5({className:e,...a}){return(0,t.jsx)(eV,{"data-slot":"alert-dialog-action",className:(0,D.cn)("bg-brand-400 text-primary-foreground flex h-10 cursor-pointer items-center justify-center rounded-lg px-4 py-3 hover:bg-[#252C3F] focus:ring-2 focus:ring-blue-500 focus:ring-offset-0 focus:outline-none active:bg-[#0C1226]",e),...a})}function e4({className:e,...a}){return(0,t.jsx)(eG,{"data-slot":"alert-dialog-cancel",className:(0,D.cn)("flex h-10 cursor-pointer items-center justify-center rounded-lg border-1 border-gray-500 bg-transparent px-4 py-3 hover:bg-white focus:ring-1 focus:ring-blue-500 focus:ring-offset-0 focus:outline-none active:bg-[#E6E6E6]",e),...a})}function e6({title:e,description:a,buttons:s,open:r,onOpenChange:n,trigger:i,className:l}){let o=(0,t.jsxs)(eX,{className:l,children:[(0,t.jsx)(eQ,{children:(0,t.jsx)(e1,{children:e})}),a&&(0,t.jsx)(e2,{children:a}),(0,t.jsx)(e0,{children:s.map((e,a)=>{let s=()=>{e.onClick&&e.onClick(),n&&void 0===r&&n(!1)};return"cancel"===e.variant?(0,t.jsx)(e4,{onClick:s,disabled:e.disabled,children:e.label},a):(0,t.jsx)(e5,{onClick:s,disabled:e.disabled,className:"destructive"===e.variant?"bg-red-600 hover:bg-red-700 active:bg-red-800":void 0,children:e.label},a)})})]});return i?(0,t.jsxs)(eJ,{open:r,onOpenChange:n,children:[(0,t.jsx)(eZ,{asChild:!0,children:i}),o]}):(0,t.jsx)(eJ,{open:r,onOpenChange:n,children:o})}function e3({validationError:e}){let a,r,n,{navigate:i}=(0,k.default)(),[l,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{e&&o(!0)},[e]),!e)return null;switch(e.isNoProductSelected?"noProductSelected":e.isAlreadySubscribed?"alreadySubscribed":"default"){case"noProductSelected":a=[{label:"Go to Homepage",variant:"cancel",onClick:()=>i("/")},{label:"Subscribe",variant:"action",onClick:()=>i("/subscribe")}],r="No product selected",n="Please select a product to continue with checkout.";break;case"alreadySubscribed":a=[{label:"Go to Homepage",variant:"cancel",onClick:()=>i("/")},{label:"Manage Account",variant:"action",onClick:()=>i("/member/settings")}],r="It looks like you have already subscribed.",n=void 0;break;default:a=[{label:"Go to Homepage",variant:"cancel",onClick:()=>i("/")},{label:"Subscribe",variant:"action",onClick:()=>i("/subscribe")}],r="An item in your cart is not valid.",n=void 0}return(0,t.jsx)(e6,{title:r,description:n,buttons:a,open:l,className:"max-w-md"})}var e7=e.i(186316);function e8(){let e=(0,eh.useSearchParams)(),t=(0,a.useSetAtom)(g.tpccAtom);return(0,s.useEffect)(()=>{let a=e.get("tpcc");if(a)(0,e7.setCookie)("tpcc",a),t(a);else{let e=(0,e7.getCookie)("tpcc");e&&"string"==typeof e&&t(e)}},[e,t]),null}function e9(){let e=(0,a.useAtomValue)(l.userTierAtom),[m,p]=(0,a.useAtom)(g.eventChainIdAtom),v=(0,a.useAtomValue)(g.billingPreviewDataAtom),{productId:b}=(0,y.useCart)();(0,s.useEffect)(()=>{m||p(crypto.randomUUID())},[m,p]);let j=(0,eb.isUserLoggedIn)(e),{addressData:C,paymentMethods:w}=function(e){let t=(0,a.useSetAtom)(l.userProfileAtom),r=(0,a.useSetAtom)(o.wxuUserAccountUserAccountResponseAtom),m=(0,d.useUserLogout)(),{data:p}=(0,n.default)(e?"upsx/id":null,()=>i.upsxClient.account.getAccountId(),x),{data:f,isLoading:g,error:y}=(0,n.default)(e?"upsx/account":null,()=>i.upsxClient.account.getAccount(),{...x,onSuccess:e=>{t(e),r(e)},onError:()=>{m()}}),{addressData:v,paymentMethods:b,isLoading:j,error:C}=function(e){let[t,a]=(0,s.useState)(null),[r,n]=(0,s.useState)([]),[i,l]=(0,s.useState)(!1),[o,d]=(0,s.useState)(null);return(0,s.useEffect)(()=>{e&&(async()=>{l(!0),d(null);try{let[e,t]=await Promise.all([(0,c.getAccountAddress)({experience:"wx"}).catch(()=>null),(0,u.getPaymentMethods)({experience:"wx"}).catch(()=>[])]);if(e?.billToContact){let t=e.billToContact,s=t.address,r={};t.firstName&&(r.firstName=t.firstName),t.lastName&&(r.lastName=t.lastName),s?.line1&&(r.addressLine1=s.line1),s?.line2&&(r.addressLine2=s.line2),s?.city&&(r.city=s.city),s?.state&&(r.state=s.state),s?.postalCode&&(r.postalCode=s.postalCode),s?.country&&(r.country=h[s.country.toLowerCase()]||"USA"),r.firstName&&r.lastName&&r.addressLine1&&r.city&&r.state&&r.postalCode,a(r)}t&&Array.isArray(t)&&n(t)}catch(e){d(e instanceof Error?e:Error("Unknown error"))}finally{l(!1)}})()},[e]),{addressData:t,paymentMethods:r,isLoading:i,error:o}}(e);return{accountId:p?.userID||null,userProfile:f||null,addressData:v,paymentMethods:b,isLoadingAccount:g,isLoadingZuoraData:j,accountError:y||null,zuoraError:C}}(j),{validationError:N}=function(e){let{productIds:t,isAuthenticated:r}=e,i=(0,a.useSetAtom)(g.checkoutValidationAtom),{isLoading:l,error:o}=(0,n.default)(t?`checkout/validate/${r}`:null,()=>(0,f.getCheckoutValidate)({productIds:t,experience:"wx"}),{shouldRetryOnError:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1,onSuccess:()=>{i("valid")},onError:()=>{i("invalid")}});(0,s.useEffect)(()=>{l&&i("loading")},[l,i]);let d=o?{isAlreadySubscribed:o.message?.toLowerCase().includes("already subscribed")||!1,isNoProductSelected:!t,message:o instanceof Error?o.message:"Unable to validate checkout. Please try again or contact support."}:null,c="idle";return l?c="loading":o?c="invalid":t&&(c="valid"),{validationStatus:c,isValidating:l,validationError:d}}({productIds:b,isAuthenticated:j}),P=(0,s.useMemo)(()=>(function(e){if(!e)return"Checkout";let{name:t,interval:a,trialDays:s,trialMonths:r}=e,n=t.toLowerCase(),i=a.toLowerCase(),l=n.includes("premium"),o=n.includes("ad-free")||n.includes("ad free"),d=i.includes("year"),c=i.includes("month");if(l&&d&&(s>0||r>0)){let e=s>0?`${s}-Day Trial`:`${r}-Month Trial`;return`Start your FREE ${e} — Ad Free Awaits!`}return l&&d?"Welcome! Premium & Ad Free Awaits!":l&&c||o?"Welcome! Ad Free Forecasting Awaits":"Checkout"})(v),[v]);return((e={})=>{let t=(0,r.useEventAttributes)(),a=(0,s.useMemo)(()=>{let a={...t,accountCreated:e.accountCreated??!1,accountLogin:e.accountLogin??!1,completed:e.completed??!1,premiumProductId:e.premiumProductId??void 0,weatherMode:e.weatherMode??"normal",experimentJoinList:e.experimentJoinList??void 0,mParticleGranted:e.mParticleGranted??!0};return void 0===a.premiumProductId&&delete a.premiumProductId,void 0===a.experimentJoinList&&delete a.experimentJoinList,a},[t,e.accountCreated,e.accountLogin,e.completed,e.premiumProductId,e.weatherMode,e.experimentJoinList,e.mParticleGranted]);(0,s.useEffect)(()=>{let e=()=>{if(window.mParticle?.isInitialized?.())try{window.mParticle?.logEvent?.("purchase-abandon",window.mParticle?.EventType?.Other,a),console.debug(`MParticle: Event "purchase-abandon" tracked - ${a.pageId}`)}catch(e){console.error('MParticle: Event "purchase-abandon" failed',e)}};return window.addEventListener("beforeunload",e),window.addEventListener("blur",e),()=>{window.removeEventListener("beforeunload",e),window.removeEventListener("blur",e)}},[a])})({accountCreated:!1,accountLogin:j,completed:!1,premiumProductId:b||void 0}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e8,{}),(0,t.jsx)(e3,{validationError:N}),(0,t.jsx)("div",{className:"min-h-screen bg-gray-50 px-4 py-8",children:(0,t.jsxs)("div",{className:"mx-auto max-w-7xl",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)("h1",{className:"text-4xl font-bold",children:P})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_400px]",children:[(0,t.jsxs)("div",{className:"order-1 space-y-8",children:[(0,t.jsx)(A,{}),(0,t.jsx)("div",{className:"border-t border-gray-300"}),(0,t.jsx)(ef,{isAuthenticated:j,addressData:C,paymentMethods:w})]}),(0,t.jsx)("div",{className:"order-2 lg:sticky lg:top-8 lg:self-start",children:(0,t.jsx)(ev,{})})]})]})})]})}e.s(["CheckoutPageClient",()=>e9],649319)}]);