import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Ht as t}from"./vendor-react-N_fu9J_Y.js";import{Ot as n}from"./Storyblok-DGCBwXgG.js";import{n as r,t as i}from"./matsuya-api-BAyFV8GL.js";var a=e(t()),o=()=>{let{data:e}=r.useQuery(`get`,`/v1/reference/countries`,{cache:`force-cache`});return{countries:(0,a.useMemo)(()=>e?.length?e.map(e=>({value:e.code??``,label:e.name??e.code??``})):[],[e]),getRegionsForCountry:(0,a.useCallback)(async e=>{if(!e)return[];try{let{data:t}=await i.GET(`/v1/reference/countries/{countryCode}/regions`,{params:{path:{countryCode:e}},cache:`force-cache`});return t?.length?t.map(e=>({id:e.code??``,value:e.code??``,label:e.name??e.code??``})):[]}catch{return[]}},[])}},s=()=>{let{setShippingAddress:e,setBillingAddress:t,isSignedIn:r,deliveryMethod:i,isTriggerAddressForm:s,triggerAddressForm:c,triggerAddressFormResolve:l}=n(),[u,d]=(0,a.useState)(`JP`),[f,p]=(0,a.useState)([]),{countries:m,getRegionsForCountry:h}=o(),g=(0,a.useCallback)(async e=>{d(e),p(await h(e))},[h]),_=(0,a.useCallback)((n,r)=>{r===`shipping`?e(n):r===`billing`&&t(n)},[e,t]);return(0,a.useEffect)(()=>{h(u).then(p)},[u,h]),{setAddress:_,regions:f,countries:m,defaultCountryCode:u,handleCountryChange:g,isSignedIn:r,deliveryMethod:i,isTriggerAddressForm:s,triggerAddressForm:c,triggerAddressFormResolve:l}};export{s as t};