import{Y as S,q as A,T as le,a as e,hD as ue,hE as he,G as w,bi as pe,dW as me,d0 as ge,dR as fe,U as F,bx as ye,a2 as O,bL as j,hF as _e,hG as Ae,hH as Ce,hI as Pe,o as y,hJ as Se,hK as ve,fw as H,h9 as be,bA as Ie,bQ as Ee,fu as ke,B as u,cv as z,cu as R,aC as p,fb as N,ac as M,aS as P,hL as De,g_ as J,bO as b,hM as Ne,eD as xe,hN as Re,hO as K,b6 as v,hP as Q,bd as X,hQ as Me,g$ as Te,E as C,R as _,hR as Oe,fT as Le,K as T,hS as Be,hT as Y,hU as Z,eO as x,hV as we,hW as Fe,d7 as He,d8 as ze,bt as We,dv as Ge,aB as ee,d as Ue,e$ as Ve,a6 as qe,ai as $e,an as je,aw as Je,ao as Ke,ap as Qe,hX as Xe,hY as Ye,dj as Ze,af as se,hZ as es,gp as ne,gQ as ss,h_ as ns,h$ as ts,bp as U,i0 as os,i1 as is,av as as,b1 as te,I as rs,dd as oe,ae as cs,bC as ds,aV as ls,ag as us,a$ as hs}from"./app.B46ok1sD.js";import{P as ps,a as ms,b as gs,d as fs,c as ys}from"./ButtonWithRegisterWebPixel.rRVMeKxb.js";import{D as _s,S as ie,P as As,u as Cs,E as Ps,a as Ss}from"./DeliveryMethodSelectorSection.CyUGrHHq.js";import"./NoAddressLocationFullDetour.IjvhIHxd.js";import"./useEditorShopPayNavigation.CePpaa9N.js";import"./VaultedPayment.B9qZpD2h.js";const ae=ue(null),vs=({children:s})=>{const[n,o]=S(void 0),[t,i]=S(void 0),[a,r]=S(void 0),[c,d]=S(void 0),l=A((h,f)=>{o(h),i(f)},[o,i]),m=A((h,f)=>{r(h),d(f)},[r,d]),g=le(()=>({prefetchTime:n,prefetchAddress:t,negotiateTime:a,negotiateAddress:c,setPrefetchPoint:l,setNegotiatePoint:m}),[n,t,a,c,l,m]);return e(ae.Provider,{value:g,children:s})},bs=()=>he(ae);var W=(s=>(s.Autocomplete="PREFETCH_SHIPPING_RATES_ON_AUTOCOMPLETE",s))(W||{});const Is=()=>{const{id:s}=w(),{checkoutSessionIdentifier:n,sourceId:o}=pe(),t=n||o||"",i=new Date().valueOf(),a=`${t}-${i}`;return A((c,d,l)=>({schemaId:me.PrefetchOnAddressAutocomple,payload:{eventId:a,prefetchingOfRatesProjectName:"prefetch_on_address_autocomplete",prefetchingOfRatesProjectVersion:"v2",shopId:parseInt(ge(s),10),checkoutToken:t,successfulEarlyFetch:l,prefetchingRoutingRequestSubmittedAt:c,normalRoutingRequestSubmittedAt:d}}),[t,s,a])},V=()=>new Date().valueOf(),q=(s,n)=>s.name===n.name&&s.city===n.city&&s.countryCode===n.countryCode&&s.zoneCode===n.zoneCode&&s.postalCode===n.postalCode&&s.address1===n.address1&&s.address2===n.address2&&s.company===n.company&&s.firstName===n.firstName&&s.lastName===n.lastName&&s.phone===n.phone,re=()=>{const s=fe(),{shippingAddress:n}=F(),o=Is(),t=bs(),i=A(c=>{const d=V();if(c===W.Autocomplete){const l=n.peek();t?.setPrefetchPoint(d,l)}},[t,n]),a=A(()=>{const c=t?.prefetchTime,d=t?.prefetchAddress,l=t?.negotiateTime,m=t?.negotiateAddress;if(c===void 0||d===void 0)return;const g=V(),h=n.peek(),f=m!==void 0&&!q(h,m);if(!l||f){const I=q(d,h);s.record(o(c,g,I)),t?.setNegotiatePoint(g,h)}},[s,t,n,o]),r=A(()=>{a()},[a]);return{capturePrefetch:i,captureNegotiate:r}},Es=()=>{const n=!ye(),{prefetchShippingRatesEnabled:o}=w(),{negotiate:t}=O(),{capturePrefetch:i}=re();return A(()=>{n&&o&&(i(W.Autocomplete),t({include:[],silenceViolations:["non-stock"],prefetch:!0}))},[i,t,o,n])};function G({addressErrors:s,additionalFieldGroups:n,settings:o,addressSettings:t,showSavedAddressSelector:i}){const{shippingAddress:a}=F(),{inMemoryPayPalParts:{accountStatus:r}}=j(),c=_e(),d=Es(),{addresses:l,mustSelectProvidedAddress:m}=Ae();return Ce(),e(Pe,{id:"shippingAddressForm",addressType:"shipping",addressErrors:s,address:a,countries:c,settings:o,additionalFieldGroups:n,loading:r.value.status==="loading",onAddressAutoComplete:d,addressSettings:t,availableAddresses:l,mustSelectProvidedAddress:m,showSavedAddressSelector:i})}const ks="business_customer_shipping_address_selector",$="existing_shipping_address",B="custom_shipping_address";function Ds({existingShippingAddress:s,addressErrors:n,addressSettings:o}){const t=y(),{shippingAddress:i}=F(),{negotiate:a}=O(),{resetAddressErrors:r}=Se(n),[c,d]=S(!1),l=ve(),m=H(),g=be(i.peek(),s),{value:h}=Ie(),[f,I]=S(g?$:B),L=A(async([k])=>{I(k),d(!0),k===B?i.value={...De,company:""}:i.value=s,await a({progression:!1,fieldsToResolve:["merchandiseLines","deliveryNext"],onComplete(){r(),d(!1)}})},[s,a,i,r]);Ee({active:c});const E=m&&(!l||!ke(h));return e(P,{children:e(u,{children:e(z,{id:ks,selectedItems:[f],onChange:L,hideRadioButton:!E,children:[e(R,{id:$,children:e(u,{spacing:"none",children:[e(p,{type:"strong",children:e(N,{hiddenFields:["address2","phone","company","city","postalCode","zoneCode","countryCode","firstName","lastName"],address:s})}),e(N,{textColor:"subdued",hiddenFields:["phone","company","address1","firstName","lastName"],address:s}),e(N,{textColor:"subdued",hiddenFields:["address2","phone","company","city","postalCode","zoneCode","countryCode","phone","company","address1"],address:s})]})}),E&&e(R,{id:B,details:e(G,{addressErrors:n,addressSettings:o,showSavedAddressSelector:!1}),children:e(u,{spacing:"none",children:[e(M,{children:e(p,{type:"strong",children:t("contact.different_shipping_address_label")})}),e(M,{color:"subdued",children:t("contact.different_shipping_address_text")})]})})]})})})}function Ns(){const s=y(),{deliveryMethodsAddressErrors:n}=J(),{purchasingCompany:o}=b(),t=H(),{isValid:i}=Ne(),a=xe("shipping");if(!o)return null;const r=o.location.shippingAddress;return r&&i?e(Ds,{existingShippingAddress:r,addressErrors:n,addressSettings:a}):!t&&!r?e(u,{spacing:"large200",children:[e(z,{id:"delivery_methods_company_location_no_address",selectedItems:["delivery_methods_company_location_no_address_item"],hideRadioButton:!0,children:e(R,{id:"delivery_methods_company_location_no_address_item",children:e(u,{spacing:"none",children:[e(p,{children:o.location.name}),e(p,{color:"subdued",children:s("review.blocks.no_address")})]})})}),e(Re,{tone:"info",children:s("delivery_options.company_location_no_address_banner")})]}):e(G,{addressErrors:n,addressSettings:a,showSavedAddressSelector:!1})}function xs(){const s=y(),{purchasingCompany:n}=b(),o=H(),t=K();return n?e(X,{columns:["fill","auto"],spacing:"base",children:[e(u,{spacing:"small400",children:[e(v,{level:1,children:s("contact.ship_to_company",{companyName:n.location.name})}),o&&!n.location.shippingAddress&&e(p,{color:"subdued",children:s("contact.different_shipping_address_text")})]}),t&&e(Q,{})]}):null}function Rs(){const s=y(),{purchasingCompany:n}=b(),o=n?.location.shippingAddress,t=K();return n?e(P,{accessibilityLabel:s("company_location.location_title"),children:e(u,{children:[e(X,{columns:["fill","auto"],blockAlignment:"baseline",spacing:"base",children:[e(v,{level:1,children:s("company_location.location_title")}),t&&e(Q,{})]}),e(z,{id:"pickup_company_locations_list",selectedItems:["selected_pickup_company_location"],hideRadioButton:!0,children:e(R,{id:"selected_pickup_company_location",children:e(u,{spacing:"none",children:[e(p,{children:n.location.name}),o?e(N,{address:o,textSize:"small",textColor:"subdued",hiddenFields:Me}):e(M,{children:e(p,{type:"small",color:"subdued",children:s("review.blocks.no_address")})})]})})})]})}):null}function Ms(){const s=Te(),n=C("Checkout::Dynamic::Render","INFORMATION3"),o=t=>e(P,{children:t});return e(u,{spacing:"large400",children:[e(_s,{}),s&&e(_,{extensions:n,render:o}),e(Ts,{}),!s&&e(_,{extensions:n,render:o})]})}function Ts(){const{method:s}=Oe(),n=y(),{deliveryMethodsAddressErrors:o}=J(),{purchasingCompany:t}=b(),i=C("Checkout::DeliveryAddress::RenderBefore"),a=C("purchase.checkout.delivery-address.render-after"),r=Le()?e(M,{color:"subdued",children:n("contact.shipping_used_as_billing_notice")}):null,c=t?e(xs,{}):e(T,{children:[e(v,{level:1,children:n("delivery_options.shipping_address")}),r]});switch(s){case"PICKUP_POINT":return e(x,{sectionId:"pickupPoints",children:e(Fe,{})});case"PICK_UP":return e(x,{sectionId:"localPickup",children:[e(we,{}),e(Rs,{})]});default:return e(x,{sectionId:"shippingAddressForm",children:e(P,{accessibilityLabel:t?.location.name?n("contact.ship_to_company",{companyName:t?.location.name}):n("delivery_options.shipping_address"),children:[e(u,{children:[c,e(_,{extensions:i}),e(Be,{}),e(Y,{children:t?e(Ns,{}):e(T,{children:[e(G,{addressErrors:o}),e(ie,{}),e(Z,{})]})}),e(_,{extensions:a})]}),e(Os,{})]})})}}function Os(){const s=He(),n=ze();return We(o=>{o.type==="success"&&o.negotiationStage==="progression"&&(s("sectionComplete",{section:"deliveryAddress",timestamp:new Date}),n({type:"section_complete",section:"deliveryAddress"}))}),null}const Ls="•";function Bs(){const s=Ge(),{purchasingCompany:n}=b(),o=y();if(!n||!s)return null;const{firstName:t,lastName:i,email:a}=s,{company:r}=n;return e(u,{spacing:"small400",children:[e(p,{children:(t||i)&&o("general.display_name",{firstName:t??"",lastName:i??""})}),e(ee,{spacing:"small400",children:[e(p,{color:"subdued",size:"small",children:r.name}),a&&e(T,{children:[e(p,{color:"subdued",size:"small",children:Ls}),e(p,{color:"subdued",size:"small",children:a})]})]})]})}function $s(){const s=y(),{progress:n,progressing:o}=O(),{shippingRequired:t}=Ue(),i=s(t?"general.continue_to_shipping_method":"general.continue_to_payment_method"),a=Ve();qe(a);const r=$e(a,n);return e(T,{children:[e(je,{hasError:!1,children:s("contact.title")}),e(Je,{onSubmit:r,disabled:o,implicitSubmit:i,children:e(Ke,{section:"contact",children:e(Qe,{section:"contact",children:e(ws,{shippingRequired:t})})})}),t?e(Ye.Preload,{}):e(Ze.Prefetch,{}),e(As,{id:"Information"})]})}const D=s=>e(P,{children:s}),ws=Xe(function({shippingRequired:n}){const o=y(),{previousPage:t}=se(),{hasStorefront:i}=w(),a=es(),{purchasingCompany:r}=b(),c=ne(),d=ss(),{showLoginLink:l,loginUrl:m}=ns(),g=o("contact.contact_method_title"),h=o("payment.billing_address_title"),f=l?e(Hs,{contactTitle:g,loginUrl:m}):e(v,{id:oe,level:1,children:g}),I=C("Checkout::Contact::RenderAfter"),L=C("Checkout::Dynamic::Render","INFORMATION1"),E=C("Checkout::Dynamic::Render","INFORMATION2"),k=C("Checkout::Dynamic::Render","INFORMATION3"),{acceleratedWalletPaymentMethods:ce}=j(),de=Cs(ce);return e(vs,{children:[d?e("div",{ref:de,children:[e(u,{spacing:"none",children:e(x,{sectionId:"expressCheckout",children:e(Ps,{})})}),e(Ss,{})]}):null,e(ps,{children:[e(ms,{children:[e(_,{extensions:L,render:D}),e(P,{accessibilityLabel:g,children:e(u,{children:[f,r?e(Bs,{}):e(ts,{}),e(_,{extensions:I,render:D})]})}),e(_,{extensions:E,render:D}),n?e(U,{target:"cart.deliveryGroups[0].deliveryAddress",children:e(os,{children:e(Ms,{})})}):e(U,{target:"cart.paymentLines[0].billingAddress",children:[e(P,{accessibilityLabel:h,children:e(u,{children:[e(v,{children:h}),e(Y,{children:[e(is,{}),e(ie,{}),e(Z,{})]})]})}),e(_,{extensions:k,render:D})]}),e(as,{})]}),e(gs,{children:[e(Fs,{}),i&&a&&t.route&&e(fs,{children:e(te,{href:t.route,variant:"plain",inlineSize:"fill",textDecoration:"none",ref:c("go_to_previous_step"),children:e(ee,{spacing:"small200",blockAlignment:"center",children:[e(rs,{type:"chevron-left",size:"small"}),e(p,{children:t.label})]})})})]})]})]})});function Fs(){const{progressing:s,prefetch:n}=O(),o=cs(),{nextPage:t}=se(),{captureNegotiate:i}=re(),a=ne(),r=ds.usePreload(),c=ls();return e(ys,{children:e(te,{variant:"primary",disabled:o||!c,type:"submit",loading:s,size:"large",inlineSize:"fill",onMouseEnter:()=>{i(),n(),t.id==="shipping"&&r()},ref:a("go_to_next_step"),children:t.label})})}function Hs({contactTitle:s,loginUrl:n}){const o=y(),t=us("simulated");return e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",flexWrap:"wrap"},children:[e(v,{id:oe,level:1,children:s}),e(hs,{href:t?void 0:n,children:o("customer_account.sign_in_link_label")})]})}export{$s as default};